基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using System.Drawing;
|
||||
using NewMyFormDesigner.Core;
|
||||
using NewMyFormDesigner;
|
||||
|
||||
namespace NewMyFormDesigner
|
||||
{
|
||||
class ControlHelper
|
||||
{
|
||||
public static Control CreateControl(string userName, string ctrName, int fileTypeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
Control ctrl = null;
|
||||
switch (fileTypeId)
|
||||
{
|
||||
case 8888:
|
||||
ctrl = new LabelGroupBox();
|
||||
ctrl.Name = userName;
|
||||
ctrl.Tag = 8888;
|
||||
ctrl.Text = "分组名称";
|
||||
break;
|
||||
case 8889:
|
||||
ctrl = new Panel();
|
||||
ctrl.Name = userName;
|
||||
ctrl.Tag = 8889;
|
||||
ctrl.BackColor = Color.LightGreen;
|
||||
ctrl.Height = 24;
|
||||
ctrl.Width = 100;
|
||||
ctrl.Text = "分页名称";
|
||||
break;
|
||||
case 8890:
|
||||
ctrl = new LabelDivider();
|
||||
ctrl.Name = userName;
|
||||
ctrl.Tag = 8890;
|
||||
ctrl.BackColor = Color.LightGreen;
|
||||
ctrl.Height = 2;
|
||||
ctrl.Width = 200;
|
||||
ctrl.Text = "分割线";
|
||||
break;
|
||||
default:
|
||||
ctrl = new LabelTextEx();
|
||||
(ctrl as LabelTextEx).LabelText = userName;
|
||||
break;
|
||||
}
|
||||
if (ctrl != null)
|
||||
{
|
||||
ctrl.Name = ctrName;
|
||||
}
|
||||
return ctrl;
|
||||
}
|
||||
catch (Exception ex) //创建失败
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
return new Control();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MyFormDesinger
|
||||
{
|
||||
public class ControlParentProperty
|
||||
{
|
||||
private Control ctr;
|
||||
public ControlParentProperty() { }
|
||||
|
||||
public ControlParentProperty(Control _ctr)
|
||||
{
|
||||
this.ctr = _ctr;
|
||||
}
|
||||
|
||||
private int width;
|
||||
[Description("宽度")]
|
||||
[DisplayName("宽度")]
|
||||
public int Width
|
||||
{
|
||||
get { return width; }
|
||||
set
|
||||
{
|
||||
width = value;
|
||||
ctr.Width = value;
|
||||
}
|
||||
}
|
||||
private int height;
|
||||
[Description("高度")]
|
||||
[DisplayName("高度")]
|
||||
public int Height
|
||||
{
|
||||
get { return height; }
|
||||
set
|
||||
{
|
||||
height = value;
|
||||
ctr.Height = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace NewMyFormDesigner
|
||||
{
|
||||
public class ControlProperty
|
||||
{
|
||||
private Control ctr;
|
||||
public ControlProperty() { }
|
||||
|
||||
public ControlProperty(Control _ctr)
|
||||
{
|
||||
this.ctr = _ctr;
|
||||
}
|
||||
|
||||
private int top;
|
||||
[Description("上边距")]
|
||||
[DisplayName("上边距")]
|
||||
public int Top
|
||||
{
|
||||
get { return top; }
|
||||
set
|
||||
{
|
||||
top = value;
|
||||
ctr.Top = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int left;
|
||||
[Description("左边距")]
|
||||
[DisplayName("左边距")]
|
||||
public int Left
|
||||
{
|
||||
get { return left; }
|
||||
set
|
||||
{
|
||||
left = value;
|
||||
ctr.Left = value;
|
||||
}
|
||||
}
|
||||
private int width;
|
||||
[Description("宽度")]
|
||||
[DisplayName("宽度")]
|
||||
public int Width
|
||||
{
|
||||
get { return width; }
|
||||
set
|
||||
{
|
||||
width = value;
|
||||
ctr.Width = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int height;
|
||||
[Description("高度")]
|
||||
[DisplayName("高度")]
|
||||
public int Height
|
||||
{
|
||||
get { return height; }
|
||||
set
|
||||
{
|
||||
height = value;
|
||||
ctr.Height = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string groupName;
|
||||
[Description("分组名称")]
|
||||
[DisplayName("分组名称")]
|
||||
public string GroupName
|
||||
{
|
||||
get { return groupName; }
|
||||
set
|
||||
{
|
||||
groupName = value;
|
||||
if (ctr is LabelGroupBox)
|
||||
ctr.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string name;
|
||||
[Description("控件名称")]
|
||||
[DisplayName("控件名称")]
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
ctr.Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int tabIndex;
|
||||
[Description("TAB次序")]
|
||||
[DisplayName("TAB次序")]
|
||||
public int TabIndex
|
||||
{
|
||||
get { return tabIndex; }
|
||||
set
|
||||
{
|
||||
tabIndex = value;
|
||||
ctr.TabIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string pageName;
|
||||
[Description("页面名字")]
|
||||
[DisplayName("页面名字")]
|
||||
public string PageName
|
||||
{
|
||||
get { return pageName; }
|
||||
set
|
||||
{
|
||||
pageName = value;
|
||||
}
|
||||
}
|
||||
|
||||
private string pageOrder;
|
||||
[Description("页面顺序")]
|
||||
[DisplayName("页面顺序")]
|
||||
public string PageOrder
|
||||
{
|
||||
get { return pageOrder; }
|
||||
set
|
||||
{
|
||||
pageOrder = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace NewMyFormDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// 消息过滤器
|
||||
/// </summary>
|
||||
class MessageFilter : IMessageFilter
|
||||
{
|
||||
HostFrame _thehost;
|
||||
DesignerControl _theDesignerBoard;
|
||||
public MessageFilter(HostFrame hostFrame, DesignerControl designer)
|
||||
{
|
||||
_thehost = hostFrame;
|
||||
_theDesignerBoard = designer;
|
||||
}
|
||||
#region IMessageFilter 成员
|
||||
public bool PreFilterMessage(ref Message m) //过滤所有控件的WM_PAINT消息
|
||||
{
|
||||
Control ctrl = (Control)Control.FromHandle(m.HWnd);
|
||||
if (_thehost != null && _theDesignerBoard != null && _thehost.Controls.Contains(ctrl) && m.Msg == 0x000F) // 0x000F == WM_PAINT
|
||||
{
|
||||
_theDesignerBoard.Refresh();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
|
||||
namespace MyFormDesinger
|
||||
{
|
||||
/// <summary>
|
||||
/// 选中控件时,周围出现的方框
|
||||
/// </summary>
|
||||
class Recter
|
||||
{
|
||||
Rectangle _rect = new Rectangle();
|
||||
bool _isform = false; //是否为窗体周围的方框(如果是,则位置不可改变,且只有从下、右、右下三个方向改变大小)
|
||||
|
||||
public Rectangle Rect
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rect;
|
||||
}
|
||||
set
|
||||
{
|
||||
_rect = value;
|
||||
}
|
||||
}
|
||||
public bool IsForm
|
||||
{
|
||||
set
|
||||
{
|
||||
_isform = value;
|
||||
}
|
||||
}
|
||||
public Recter()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 绘制方框
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void Draw(Graphics g)
|
||||
{
|
||||
Rectangle rect = _rect;
|
||||
using (Pen p = new Pen(Brushes.Black,1))
|
||||
{
|
||||
p.DashStyle = DashStyle.Dot;
|
||||
rect.Inflate(new Size(+1, +1));
|
||||
g.DrawRectangle(p, rect); //方框
|
||||
|
||||
p.DashStyle = DashStyle.Solid;
|
||||
|
||||
//8个方块
|
||||
g.FillRectangle(Brushes.White, new Rectangle(rect.Left - 6, rect.Top - 6, 6, 6));
|
||||
g.FillRectangle(Brushes.White, new Rectangle(rect.Left + rect.Width / 2 - 3, rect.Top - 6, 6, 6));
|
||||
g.FillRectangle(Brushes.White, new Rectangle(rect.Left + rect.Width, rect.Top - 6, 6, 6));
|
||||
g.FillRectangle(Brushes.White, new Rectangle(rect.Left - 6, rect.Top + rect.Height / 2 - 3, 6, 6));
|
||||
g.FillRectangle(Brushes.White, new Rectangle(rect.Left - 6, rect.Top + rect.Height, 6, 6));
|
||||
g.FillRectangle(Brushes.White, new Rectangle(rect.Left + rect.Width, rect.Top + rect.Height / 2 - 3, 6, 6));
|
||||
g.FillRectangle(Brushes.White, new Rectangle(rect.Left + rect.Width / 2 - 3, rect.Top + rect.Height, 6, 6));
|
||||
g.FillRectangle(Brushes.White, new Rectangle(rect.Left + rect.Width, rect.Top + rect.Height, 6, 6));
|
||||
|
||||
g.DrawRectangle(p, new Rectangle(rect.Left - 6, rect.Top - 6, 6, 6));
|
||||
g.DrawRectangle(p, new Rectangle(rect.Left + rect.Width / 2 - 3, rect.Top - 6, 6, 6));
|
||||
g.DrawRectangle(p, new Rectangle(rect.Left + rect.Width, rect.Top - 6, 6, 6));
|
||||
g.DrawRectangle(p, new Rectangle(rect.Left - 6, rect.Top + rect.Height / 2 - 3, 6, 6));
|
||||
g.DrawRectangle(p, new Rectangle(rect.Left - 6, rect.Top + rect.Height, 6, 6));
|
||||
g.DrawRectangle(p, new Rectangle(rect.Left + rect.Width, rect.Top + rect.Height / 2 - 3, 6, 6));
|
||||
g.DrawRectangle(p, new Rectangle(rect.Left + rect.Width / 2 - 3, rect.Top + rect.Height, 6, 6));
|
||||
g.DrawRectangle(p, new Rectangle(rect.Left + rect.Width, rect.Top + rect.Height, 6, 6));
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 判断鼠标操作类型
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
/// <returns></returns>
|
||||
public DragType GetMouseDragType(Point p)
|
||||
{
|
||||
Rectangle _rect = this._rect;
|
||||
_rect.Inflate(new Size(3, 3));
|
||||
if (new Rectangle(_rect.Left - 2, _rect.Top - 2, 4, 4).Contains(p) && !_isform)
|
||||
{
|
||||
return DragType.LeftTop;
|
||||
}
|
||||
if (new Rectangle(_rect.Left + 2, _rect.Top - 2, _rect.Width - 4, 4).Contains(p) && !_isform)
|
||||
{
|
||||
return DragType.Top;
|
||||
}
|
||||
if (new Rectangle(_rect.Left - 2, _rect.Top + 2, 4, _rect.Height - 4).Contains(p) && !_isform)
|
||||
{
|
||||
return DragType.Left;
|
||||
}
|
||||
if (new Rectangle(_rect.Left - 2, _rect.Top + _rect.Height - 2, 4, 4).Contains(p) && !_isform)
|
||||
{
|
||||
return DragType.LeftBottom;
|
||||
}
|
||||
if (new Rectangle(_rect.Left + 2, _rect.Top + _rect.Height - 2, _rect.Width - 4, 4).Contains(p))
|
||||
{
|
||||
return DragType.Bottom;
|
||||
}
|
||||
if (new Rectangle(_rect.Left + _rect.Width - 2, _rect.Top + _rect.Height - 2, 4, 4).Contains(p))
|
||||
{
|
||||
return DragType.RightBottom;
|
||||
}
|
||||
if (new Rectangle(_rect.Left + _rect.Width - 2, _rect.Top + 2, 4, _rect.Height - 4).Contains(p))
|
||||
{
|
||||
return DragType.Right;
|
||||
}
|
||||
if (new Rectangle(_rect.Left + _rect.Width - 2, _rect.Top - 2, 4, 4).Contains(p) && !_isform)
|
||||
{
|
||||
return DragType.RightTop;
|
||||
}
|
||||
if (new Rectangle(_rect.Left + 2, _rect.Top + 2, _rect.Width - 4, _rect.Height - 4).Contains(p) && !_isform)
|
||||
{
|
||||
return DragType.Center;
|
||||
}
|
||||
return DragType.None;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标操作类型
|
||||
/// </summary>
|
||||
enum DragType
|
||||
{
|
||||
None,
|
||||
Left,
|
||||
Top,
|
||||
Right,
|
||||
Bottom,
|
||||
LeftTop,
|
||||
RightTop,
|
||||
LeftBottom,
|
||||
RightBottom,
|
||||
Center
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user