|
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Web.UI.WebControls;
namespace dynFormLib
{
public class DynForm
{
public virtual void AddControl(DynControl ctrl) {}
}
public class DynWindowForm : DynForm
{
public DynWindowForm() {}
public void Init(System.Windows.Forms.Form form)
{
this.form=form;
}
public void Create(int x, int y, int sx, int sy, string caption, string name)
{
form.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
form.StartPosition=FormStartPosition.Manual;
form.Location=new Point(x, y);
form.ClientSize=new Size(sx, sy);
form.Text=caption;
form.Name=name;
// KA.Info.Forms.AddForm(this);
}
public override void AddControl(DynControl ctrl)
{
form.Controls.Add(ctrl.GetWindowCtrl());
// controls.Add(ctrl, ctrl.Name);
}
public void LoadControls(ControlInfo[] ctrlInfo)
{
for (int i=0; i<ctrlInfo.Length; i++)
{
DynWindowControl ctrl=null;
switch(ctrlInfo[i].type)
{
case "label":
{
ctrl=new DynWindowLabel();
break;
}
case "edit":
{
ctrl=new DynWindowTextBox();
break;
}
case "button":
{
ctrl=new DynWindowButton();
break;
}
case "imageButton":
{
ctrl=new DynWindowImageButton();
break;
}
case "groupBox":
{
ctrl=new DynWindowGroupBox();
break;
}
case "checkBox":
{
ctrl=new DynWindowCheckBox();
break;
}
case "radioButton":
{
ctrl=new DynWindowRadioButton();
break;
}
case "comboBox":
{
ctrl=new DynWindowComboBox();
break;
}
case "listView":
{
ctrl=new DynWindowListView();
break;
}
}
if (ctrl != null)
{
ctrl.Create(ctrlInfo[i]);
AddControl(ctrl);
}
}
}
public void Run()
{
System.Windows.Forms.Application.Run(form);
}
public System.Windows.Forms.Form form;
}
public class DynWebForm : DynForm
{
public DynWebForm() {}
public void Init(System.Web.UI.WebControls.Label lbl)
{
form=lbl;
}
public override void AddControl(DynControl ctrl)
{
form.Controls.Add(ctrl.GetWebCtrl());
}
public void LoadControls(ControlInfo[] ctrlInfo)
{
for (int i=0; i<ctrlInfo.Length; i++)
{
DynWebControl ctrl=null;
switch(ctrlInfo[i].type)
{
case "label":
{
ctrl=new DynWebLabel();
break;
}
case "edit":
{
ctrl=new DynWebTextBox();
break;
}
case "button":
{
ctrl=new DynWebButton();
break;
}
case "groupBox":
{
ctrl=new DynWebGroupBox();
break;
}
case "checkBox":
{
ctrl=new DynWebCheckBox();
break;
}
case "imageButton":
{
ctrl=new DynWebImageButton();
break;
}
case "radioButton":
{
ctrl=new DynWebRadioButton();
break;
}
case "comboBox":
{
ctrl=new DynWebComboBox();
break;
}
case "listView":
{
ctrl=new DynWebListView();
break;
}
}
if (ctrl != null)
{
ctrl.Create(ctrlInfo[i]);
AddControl(ctrl);
}
}
}
public void Run() {}
public System.Web.UI.WebControls.Label form;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here