Användargränssnitt med Wimark Controls  

Formulär i Wimark Controls

I Wimark Controls fungerar det i stort sett på samma sätt. Det finns tre klasser som representerar olika typer av fönster; StandardForm, MdiContainer och MdiChild. De har alla samma programmeringsgränssnitt och ärver från klassen Form i Microsoft .NET. Anledningen till att det finns tre klasser är att man ofta vill ha olika grafik beroende på fönstrets typ.

Fönstrets innehåll, kontrollerna, adderas inte direkt till kollektionen Form.Controls, utan till containerkontrollen ClientArea, som i sin tur adderas till fönstret. Detta beror på tekniska problem med regioner samt av prestandaskäl.

För att layouta ett fönster visuellt i Visual Studio rekommenderar vi att man väljer att skapa ett formulär som ärver från någon av våra fönsterklasser. Därefter väljer man kontrollen ClientArea från verktygslådan i Visual Studio och adderar det till fönstret. Kontrollen kommer automatiskt att täcka hela klientytan. Ytterligare kontroller kan sedan adderas till ClientArea kontrollen.

Notera att det går alldeles utmärkt att blanda kontroller och fönster från Microsoft .NET och Wimark Controls.

// C#
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace TestApp2 {
  public class Form4 : Wimark.Controls.StandardForm {
    private Wimark.Controls.ClientArea clientArea1;
    private Wimark.Controls.Button button1;
    private System.ComponentModel.IContainer components = null;

    public Form4() {
      // This call is required by the Windows Form Designer.
      InitializeComponent();

      // TODO: Add any initialization after the InitializeComponent call
    }

    /// Clean up any resources being used.
    protected override void Dispose( bool disposing ) {
      if( disposing ) {
        if (components != null) {
          components.Dispose();
        }
      }
      base.Dispose( disposing );
    }

    #region Designer generated code
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    private void InitializeComponent() {
      this.clientArea1 = new Wimark.Controls.ClientArea();
      this.button1 = new Wimark.Controls.Button();
      this.clientArea1.SuspendLayout();
      this.SuspendLayout();
      // 
      // clientArea1
      // 
      this.clientArea1.Controls.Add(this.button1);
      this.clientArea1.Location = new System.Drawing.Point(0, 0);
      this.clientArea1.Name = "clientArea1";
      this.clientArea1.Size = new System.Drawing.Size(296, 110);
      this.clientArea1.TabIndex = 1;
      // 
      // button1
      // 
      this.button1.Location = new System.Drawing.Point(48, 48);
      this.button1.Name = "button1";
      this.button1.TabIndex = 0;
      this.button1.Text = "button1";
      // 
      // Form4
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(296, 110);
      this.Controls.Add(this.clientArea1);
      this.Name = "Form4";
      this.Text = "Form 4";
      this.Controls.SetChildIndex(this.clientArea1, 0);
      this.clientArea1.ResumeLayout(false);
      this.ResumeLayout(false);

    }
    #endregion
  }
}

Kod som genererats av Visual Studio för att skapa ett fönster från StandardForm, innehållande en ClientArea som i sin tur innehåller en Button kontroll.


För mer information

Wimark.Controls Namespace | Form Class