480 lines
14 KiB
C#
480 lines
14 KiB
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Collections;
|
||
|
using System.Text;
|
||
|
using System.Drawing;
|
||
|
|
||
|
|
||
|
namespace Ease.UICreator
|
||
|
{
|
||
|
#region Enum
|
||
|
public enum BESFControlEnum
|
||
|
{
|
||
|
Lebel = 1,
|
||
|
Text = 2,
|
||
|
Combo = 3,
|
||
|
Check = 4,
|
||
|
DTPicker = 5,
|
||
|
NumText = 6,
|
||
|
IntNumText = 7
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Class
|
||
|
public class SingleFormControl
|
||
|
{
|
||
|
#region Variables
|
||
|
private string _propertyName;
|
||
|
private string _caption;
|
||
|
private string _name;
|
||
|
private int _maxLength;
|
||
|
private int _height;
|
||
|
private int _width;
|
||
|
private int _positionX;
|
||
|
private int _positionY;
|
||
|
private bool _isReadOnly;
|
||
|
|
||
|
private bool _isTabStop;
|
||
|
|
||
|
private bool _isMustEntry;
|
||
|
private bool _isFocused;
|
||
|
private BESFControlEnum _controlType;
|
||
|
private SingleFormComboBox _SingleFormComboBox;
|
||
|
private int _verticalSeparation;
|
||
|
#endregion
|
||
|
|
||
|
#region Constructor
|
||
|
public SingleFormControl()
|
||
|
{
|
||
|
_verticalSeparation = 27;
|
||
|
_propertyName = "";
|
||
|
_caption = "";
|
||
|
_name = "";
|
||
|
_height = 20;
|
||
|
_width = 100;
|
||
|
_positionX = 0;
|
||
|
_positionY = 0;
|
||
|
_maxLength = 50;
|
||
|
_isReadOnly = false;
|
||
|
_isMustEntry = false;
|
||
|
_SingleFormComboBox = new SingleFormComboBox();
|
||
|
_maxLength = 0;
|
||
|
_isCodeAutoGenerated = false;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Properties
|
||
|
|
||
|
#region Source
|
||
|
public string PropertyName
|
||
|
{
|
||
|
get { return _propertyName; }
|
||
|
set { _propertyName = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Caption
|
||
|
public string Caption
|
||
|
{
|
||
|
get { return _caption; }
|
||
|
set { _caption = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Name
|
||
|
public string Name
|
||
|
{
|
||
|
get { return _name; }
|
||
|
set { _name = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Control Type
|
||
|
public BESFControlEnum ControlType
|
||
|
{
|
||
|
get { return _controlType; }
|
||
|
set { _controlType = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Height
|
||
|
public int Height
|
||
|
{
|
||
|
get { return _height; }
|
||
|
set { _height = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Width
|
||
|
public int Width
|
||
|
{
|
||
|
get { return _width; }
|
||
|
set { _width = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region PositionX
|
||
|
public int PositionX
|
||
|
{
|
||
|
get { return _positionX; }
|
||
|
set { _positionX = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region PositionY
|
||
|
public int PositionY
|
||
|
{
|
||
|
get { return _positionY; }
|
||
|
set { _positionY = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Max Length
|
||
|
public int MaxLength
|
||
|
{
|
||
|
get { return _maxLength; }
|
||
|
set { _maxLength = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region IsReadOnly
|
||
|
public bool IsReadOnly
|
||
|
{
|
||
|
get { return _isReadOnly; }
|
||
|
set { _isReadOnly = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//#region BackColor
|
||
|
//public Color BackColor
|
||
|
//{
|
||
|
// get { return _backColor; }
|
||
|
// set { _backColor = value; }
|
||
|
//}
|
||
|
//#endregion
|
||
|
private bool _isCodeAutoGenerated;
|
||
|
public bool IsCodeAutoGenerated
|
||
|
{
|
||
|
get { return _isCodeAutoGenerated; }
|
||
|
set { _isCodeAutoGenerated = value; }
|
||
|
}
|
||
|
|
||
|
#region IsTabStop
|
||
|
public bool IsTabStop
|
||
|
{
|
||
|
get { return _isTabStop; }
|
||
|
set { _isTabStop = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region IsMustEntry
|
||
|
public bool IsMustEntry
|
||
|
{
|
||
|
get { return _isMustEntry; }
|
||
|
set { _isMustEntry = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Is Focus
|
||
|
public bool IsFocused
|
||
|
{
|
||
|
get { return _isFocused; }
|
||
|
set { _isFocused = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region SingleFormComboBox
|
||
|
public SingleFormComboBox CboBox
|
||
|
{
|
||
|
get { return _SingleFormComboBox; }
|
||
|
set { _SingleFormComboBox = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region VerticalSeparation
|
||
|
public int VerticalSeparation
|
||
|
{
|
||
|
get { return _verticalSeparation; }
|
||
|
set { _verticalSeparation = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Collection
|
||
|
public class SingleFormControls : CollectionBase
|
||
|
{
|
||
|
#region Methods
|
||
|
|
||
|
#region Indexer
|
||
|
public SingleFormControl this[int index]
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return ((SingleFormControl)List[index]);
|
||
|
}
|
||
|
set
|
||
|
{
|
||
|
List[index] = value;
|
||
|
}
|
||
|
}
|
||
|
public SingleFormControl this[string ControlName]
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
foreach (SingleFormControl item in this)
|
||
|
{
|
||
|
if (item.Name == ControlName)
|
||
|
{
|
||
|
return item;
|
||
|
}
|
||
|
}
|
||
|
return new SingleFormControl();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Add
|
||
|
public int Add(SingleFormControl value)
|
||
|
{
|
||
|
return (List.Add(value));
|
||
|
}
|
||
|
#region PositionY
|
||
|
public SingleFormControl LastAddedControl
|
||
|
{
|
||
|
get { return this[this.Count - 1]; }
|
||
|
set { this[this.Count - 1] = value; }
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
public int Add(BESFControlEnum controlType, string caption, string name, string propertyName, int height, int width, int posX, int posY)
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.Height = height;
|
||
|
item.Width = width;
|
||
|
item.PositionX = posX;
|
||
|
item.PositionY = posY;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
|
||
|
public int Add(BESFControlEnum controlType, string caption, string name, string propertyName, int height, int width, int posX, int posYofChosenControl, int nVerticalSeparation)
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.Height = height;
|
||
|
item.Width = width;
|
||
|
item.PositionX = posX;
|
||
|
item.PositionY = posYofChosenControl + nVerticalSeparation;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
|
||
|
public int Add(BESFControlEnum controlType, string caption, string name, string propertyName, int height, int width)
|
||
|
{
|
||
|
if (this.Count == 0)
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.Height = height;
|
||
|
item.Width = width;
|
||
|
item.PositionX = 12;
|
||
|
item.PositionY = 9;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
else if (this.Count == 1)
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.Height = height;
|
||
|
item.Width = width;
|
||
|
item.PositionX = 118;
|
||
|
item.PositionY = 9;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if ((this.Count) % 2 == 0)
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.Height = height;
|
||
|
item.Width = width;
|
||
|
item.PositionX = this[this.Count - 2].PositionX;
|
||
|
//item.PositionY = this[this.Count - 1].PositionY + item.VerticalSeparation + this[this.Count - 1].Height-20;
|
||
|
item.PositionY = this[this.Count - 1].PositionY + item.VerticalSeparation;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.Height = height;
|
||
|
item.Width = width;
|
||
|
item.PositionX = this[this.Count - 2].PositionX;
|
||
|
//item.PositionY = this[this.Count - 2].PositionY + item.VerticalSeparation+this[this.Count - 2].Height - 20;
|
||
|
item.PositionY = this[this.Count - 2].PositionY + item.VerticalSeparation;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public int Add(BESFControlEnum controlType, string caption, string name, string propertyName)
|
||
|
{
|
||
|
if (this.Count == 0)
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.PositionX = 12;
|
||
|
item.PositionY = 9;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
else if (this.Count == 1)
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.PositionX = 118;
|
||
|
item.PositionY = 9;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if ((this.Count) % 2 == 0)
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.PositionX = this[this.Count - 2].PositionX;
|
||
|
item.PositionY = this[this.Count - 2].PositionY + item.VerticalSeparation;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SingleFormControl item = new SingleFormControl();
|
||
|
item.ControlType = controlType;
|
||
|
item.Caption = caption;
|
||
|
item.PropertyName = propertyName;
|
||
|
item.Name = name;
|
||
|
item.PositionX = this[this.Count - 2].PositionX;
|
||
|
item.PositionY = this[this.Count - 2].PositionY + item.VerticalSeparation;
|
||
|
return (List.Add(item));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region IndexOf
|
||
|
public int IndexOf(SingleFormControl value)
|
||
|
{
|
||
|
return (List.IndexOf(value));
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Insert
|
||
|
public void Insert(int index, SingleFormControl value)
|
||
|
{
|
||
|
List.Insert(index, value);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Remove
|
||
|
public void Remove(SingleFormControl value)
|
||
|
{
|
||
|
List.Remove(value);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region Contains
|
||
|
public bool Contains(SingleFormControl value)
|
||
|
{
|
||
|
// If value is not of type SingleFormControl, this will return false.
|
||
|
return (List.Contains(value));
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
public void IsDuplicateCtlName()
|
||
|
{
|
||
|
int nIndex = -1;
|
||
|
foreach (SingleFormControl item in this)
|
||
|
{
|
||
|
nIndex = nIndex + 1;
|
||
|
for (int i = 0; i < this.Count; i++)
|
||
|
{
|
||
|
if (nIndex != i)
|
||
|
{
|
||
|
if ((this[nIndex].PropertyName == this[i].PropertyName) && (this[nIndex].PropertyName != ""))
|
||
|
{
|
||
|
throw new Exception("Duplicate Control Name Exist:" + this[nIndex].PropertyName);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
public SingleFormControl GetControl(string propertyName)
|
||
|
{
|
||
|
foreach (SingleFormControl item in this)
|
||
|
{
|
||
|
if (item.PropertyName == propertyName)
|
||
|
{
|
||
|
return item;
|
||
|
}
|
||
|
}
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
#region Migth be needed
|
||
|
//protected override void OnInsert(int index, Object value)
|
||
|
//{
|
||
|
// // Insert additional code to be run only when inserting values.
|
||
|
//}
|
||
|
|
||
|
//protected override void OnRemove(int index, Object value)
|
||
|
//{
|
||
|
// // Insert additional code to be run only when removing values.
|
||
|
//}
|
||
|
|
||
|
//protected override void OnSet(int index, Object oldValue, Object newValue)
|
||
|
//{
|
||
|
// // Insert additional code to be run only when setting values.
|
||
|
//}
|
||
|
|
||
|
//protected override void OnValidate(Object value)
|
||
|
//{
|
||
|
// if (value.GetType() != typeof(MasterFormlvw))
|
||
|
// throw new ArgumentException("value must be of type List view column.", "value");
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
#endregion
|
||
|
}
|