1600 lines
		
	
	
		
			58 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			1600 lines
		
	
	
		
			58 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using DrawGraph;
 | ||
| using DrawGraphManagement.MyUserControl;
 | ||
| using System;
 | ||
| using System.Collections.Generic;
 | ||
| using System.Data;
 | ||
| using System.Drawing;
 | ||
| using System.Drawing.Printing;
 | ||
| using System.Linq;
 | ||
| using System.Reflection;
 | ||
| using System.Windows.Forms;
 | ||
| 
 | ||
| namespace DrawGraphManagement
 | ||
| {
 | ||
|     public partial class AreaManageForm : Form
 | ||
|     {
 | ||
|         PackObjBase bb = null;
 | ||
|         PackObjBase selectPoB = null;
 | ||
|         //string outFlat = "||";
 | ||
|         string asFileName = "";
 | ||
|         private TreeNode selectNode = null; //选中的结点
 | ||
| 
 | ||
|         private PrintDocument pDoc;
 | ||
| 
 | ||
|         protected PackObjManager poManager = null;
 | ||
|         private AreaManageBase areaManage = null;
 | ||
| 
 | ||
|         public PageStatus pageStatus = PageStatus.Create;
 | ||
|         //private bool isAddNodeDown = true; //增加节点时是否是一层一层往下加,为真时是多层级的,为假是一层
 | ||
| 
 | ||
|         private int borderWidth = 600;
 | ||
|         private int borderHeight = 800;
 | ||
|         private bool isViewBackImg = true;
 | ||
| 
 | ||
|         public AreaManageForm()
 | ||
|         {
 | ||
|             InitializeComponent();
 | ||
|             poManager = new PackObjManager();
 | ||
|             btnOk.DialogResult = DialogResult.OK;
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 范围管理器构造方法
 | ||
|         /// </summary>
 | ||
|         /// <param name="_areaMange">范围管理器</param>
 | ||
|         /// <param name="isUseSelfControl">默认使用自己的组件</param>
 | ||
|         public AreaManageForm(AreaManageBase _areaMange, PageStatus _pageStatus = PageStatus.Create, int _borderWidth = 600, int _borderHeight = 800)
 | ||
|         {
 | ||
|             InitializeComponent();
 | ||
|             btnOk.DialogResult = DialogResult.OK;
 | ||
| 
 | ||
|             areaManage = _areaMange;
 | ||
|             poManager = areaManage.PackManage;
 | ||
|             pageStatus = _pageStatus;
 | ||
|             borderWidth = _borderWidth;
 | ||
|             borderHeight = _borderHeight;
 | ||
| 
 | ||
|             CommandManage.GetInstance.AreaManage = areaManage;
 | ||
|         }
 | ||
| 
 | ||
|         private void Form1_Load(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (areaManage == null)
 | ||
|             {
 | ||
|                 MessageBox.Show("区域管理器不能为空");
 | ||
|                 return;
 | ||
|             }
 | ||
|             this.deleteMenuItem.Enabled = true;
 | ||
|             //需要放在最前面,他会清理画板
 | ||
|             ControlDatabind(false);
 | ||
| 
 | ||
|             //画板加载背景图片
 | ||
|             loadBackImage();
 | ||
| 
 | ||
|             AutoSizeF();
 | ||
| 
 | ||
|             if (pageStatus == PageStatus.Create)
 | ||
|             {
 | ||
|                 bb = new BorderPackObj(zedGraphControl1, poManager); ;
 | ||
|                 if (bb != null)
 | ||
|                 {
 | ||
|                     ((BorderPackObj)bb).SetWidth = borderWidth;
 | ||
|                     ((BorderPackObj)bb).SetHeight = borderHeight;
 | ||
|                     poManager.ListPob.Add(bb);
 | ||
|                     InsertPackObjTree(bb);
 | ||
|                     bb.Changed += new PackObjBase.ChangedEventHandler(Bpo_Changed);
 | ||
|                 }
 | ||
|                 try
 | ||
|                 {
 | ||
|                     pDoc = new PrintDocument();
 | ||
|                     pDoc.DefaultPageSettings.Landscape = true;
 | ||
|                     pDoc.OriginAtMargins = true;
 | ||
|                     pDoc.DefaultPageSettings.PrinterResolution.Kind = PrinterResolutionKind.High;
 | ||
|                     pDoc.DefaultPageSettings.Margins = new Margins(8, 8, 4, 4);
 | ||
|                     pDoc.PrintPage += new PrintPageEventHandler(pDoc_PrintPage);
 | ||
|                 }
 | ||
|                 catch (Exception  )
 | ||
|                 {
 | ||
| 
 | ||
|                 }
 | ||
|             }
 | ||
|             if (pageStatus == PageStatus.Edit)
 | ||
|             {
 | ||
|                 foreach (PackObjBase pob in poManager.ListPob)
 | ||
|                 {
 | ||
|                     if (pob is AbleEditPackObj)
 | ||
|                     {
 | ||
|                         AbleEditPackObj a = pob as AbleEditPackObj;
 | ||
|                         a.IsViewBoard = EIsBool.True;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 ReLoad();
 | ||
|             }
 | ||
|             //areaManage.PackManage.ListPob.FindAll(s => s.PackTag.EndsWith("26".Replace('.', '_')))[0].Draw();
 | ||
|         }
 | ||
|         //画板加载背景图片
 | ||
|         private void loadBackImage()
 | ||
|         {
 | ||
|             if (isViewBackImg)
 | ||
|             {
 | ||
|                 //加载北京图片
 | ||
|                 Image img = null;
 | ||
|                 try
 | ||
|                 {
 | ||
|                     img = Image.FromFile(@"Resources/template/" + areaManage.Name + ".jpg");
 | ||
|                 }
 | ||
|                 catch (Exception  )
 | ||
|                 {
 | ||
|                 }
 | ||
|                 if (img != null)
 | ||
|                 {
 | ||
|                     zedGraphControl1.BackgroundImage = img;
 | ||
|                     zedGraphControl1.GraphPane.Fill.Color = Color.Transparent;
 | ||
|                     zedGraphControl1.MasterPane.Fill.IsVisible = false;
 | ||
|                     zedGraphControl1.GraphPane.Chart.Fill.IsVisible = false;
 | ||
|                 }
 | ||
|             }
 | ||
|             else {
 | ||
|                 zedGraphControl1.BackgroundImage = null;
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void AutoSizeF()
 | ||
|         {
 | ||
|             #region 设置界面自适应
 | ||
|             //在此处可随时设置板子的属性,横向的
 | ||
|             //if (borderWidth > borderHeight)
 | ||
|             //{
 | ||
|             //    borderHeight = zedGraphControl1.Parent.Height - 54;
 | ||
|             //    borderWidth = Convert.ToInt32(borderHeight * 1.414) + 2;
 | ||
|             //}
 | ||
|             //else
 | ||
|             //{
 | ||
|             //    borderWidth = zedGraphControl1.Parent.Width - 54;
 | ||
|             //    borderHeight = Convert.ToInt32(borderWidth * 1.414) + 2;
 | ||
|             //}
 | ||
|             zedGraphControl1.Width = borderWidth;
 | ||
|             zedGraphControl1.Height = borderHeight;
 | ||
| 
 | ||
|             PackObjBase pack = poManager.ListPob.FirstOrDefault(s => s is BorderPackObj);
 | ||
|             if(pack != null) {
 | ||
|                 ((BorderPackObj)pack).SetWidth = borderWidth;
 | ||
|                 ((BorderPackObj)pack).SetHeight = borderHeight;
 | ||
|             }
 | ||
|             areaManage.setPrint(false);
 | ||
|             zedGraphControl1.Refresh();
 | ||
|             #endregion
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 修改指定树结点的包控件内容
 | ||
|         /// </summary>
 | ||
|         private void ModPackObjTree(TreeNodeCollection tnc, PackObjBase pob)
 | ||
|         {
 | ||
|             if (selectPoB == null) return;
 | ||
|             foreach (TreeNode tn in tnc)
 | ||
|             {
 | ||
|                 try {
 | ||
|                     if (tn.Name == pob.PackName)
 | ||
|                     {
 | ||
|                         tn.Name = pob.PackName;
 | ||
|                         tn.Tag = pob;
 | ||
|                         tn.Text = pob.Descript;
 | ||
|                         break;
 | ||
|                     }
 | ||
|                     else if (tn.Nodes.Count > 0)
 | ||
|                     {
 | ||
|                         ModPackObjTree(tn.Nodes, pob);
 | ||
|                     }
 | ||
|                 } catch (Exception  ) { 
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 插入指定树结点的包控件内容
 | ||
|         /// </summary>
 | ||
|         /// <param name="pob"></param>
 | ||
|         private void InsertPackObjTree(PackObjBase pob, bool isSelMySelft = true)
 | ||
|         {
 | ||
|             TreeNode tnSub = new TreeNode();
 | ||
|             pob.IsSelect = false;
 | ||
|             tnSub.Name = pob.PackName;
 | ||
|             tnSub.Tag = pob;
 | ||
|             tnSub.Text = pob.Descript;
 | ||
|             if (treeView1.SelectedNode == null)
 | ||
|             {
 | ||
|                 //如果是白板对象直接加在顶层
 | ||
|                 if (pob is BorderPackObj)
 | ||
|                 {
 | ||
|                     treeView1.Nodes.Add(tnSub);
 | ||
|                     pob.SetParent = null;
 | ||
|                 }
 | ||
|                 else {
 | ||
|                     treeView1.SelectedNode = treeView1.Nodes[0];
 | ||
|                     treeView1.SelectedNode.Nodes.Add(tnSub);
 | ||
|                     PackObjBase ppob = (PackObjBase)treeView1.SelectedNode.Tag;
 | ||
|                     if (ppob != null) pob.SetParent = ppob;
 | ||
|                 }
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 treeView1.SelectedNode.Nodes.Add(tnSub);
 | ||
|                 PackObjBase ppob = (PackObjBase)treeView1.SelectedNode.Tag;
 | ||
|                 if (ppob != null) pob.SetParent = ppob;
 | ||
|             }
 | ||
|             //只有在多层级时才会把当前处理的结点做为选中结点,这下会生成多层级结点
 | ||
|             if (isSelMySelft)
 | ||
|             {
 | ||
|                 treeView1.SelectedNode = tnSub;
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 treeView1.SelectedNode = tnSub.Parent;
 | ||
|                 selectNode = tnSub.Parent;
 | ||
|             }
 | ||
|             TreeNodeMouseClickEventArgs e = new TreeNodeMouseClickEventArgs(tnSub, 0, 0, 0, 0);
 | ||
|             DrawPackObject(pob);
 | ||
|             if (isSelMySelft)
 | ||
|             {
 | ||
|                 selectPoB = pob;
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 selectPoB = pob.SetParent;
 | ||
|             }
 | ||
|             //treeView1_NodeMouseClick(null, e);
 | ||
|         }
 | ||
| 
 | ||
|         DrawGraphManagement.MyUserControl.UCBase uc = null;
 | ||
|         private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 | ||
|         {
 | ||
|             TreeNode tn = e.Node;
 | ||
|             selectNode = tn;
 | ||
|             PackObjBase pob = (PackObjBase)tn.Tag;
 | ||
|             DrawPackObject(pob);
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void DrawPackObject(PackObjBase pob)
 | ||
|         {
 | ||
|             if (pob != null)
 | ||
|             {
 | ||
|                 if (selectPoB != null && !pob.Equals(selectPoB))
 | ||
|                 {
 | ||
|                     selectPoB.IsSelect = false;
 | ||
|                     selectPoB.Draw();
 | ||
|                 }
 | ||
|                 
 | ||
|                 if (selectPoB == null || !pob.Equals(selectPoB))
 | ||
|                 {
 | ||
|                     pob.IsSelect = true;
 | ||
|                     selectPoB = pob;
 | ||
|                 }
 | ||
|                 //得先画才能显示属性
 | ||
|                 pob.Draw();
 | ||
|                 //设置属性
 | ||
|                 SetPropertyPanle(pob);
 | ||
|             }
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 设置属性面板的显示
 | ||
|         /// </summary>
 | ||
|         /// <param name="pob"></param>
 | ||
|         private void SetPropertyPanle(PackObjBase pob)
 | ||
|         {
 | ||
|             Type type = pob.GetType();
 | ||
|             PropertyInfo[] infos = type.GetProperties();
 | ||
| 
 | ||
|             toolTip1.RemoveAll();
 | ||
|             panel3.Controls.Clear();
 | ||
|             Panel panel = null;
 | ||
|             Panel sumPanel = new Panel();
 | ||
|             sumPanel.AutoSize = true;
 | ||
|             sumPanel.Dock = DockStyle.Top;
 | ||
|             foreach (PropertyInfo info in infos)
 | ||
|             {
 | ||
|                 Attribute[] attribs = Attribute.GetCustomAttributes(info);
 | ||
|                 Attribute attrib = attribs.FirstOrDefault<Attribute>(s => s is NoCreatControlAttributs);
 | ||
|                 //如果增加了NoCreatControlAttributs这个属性的属性则不生成控件
 | ||
|                 if (attrib != null) continue;
 | ||
|                 if (info.PropertyType == typeof(String) || info.PropertyType == typeof(uint) || info.PropertyType == typeof(int) || info.PropertyType == typeof(DateTime) || info.PropertyType == typeof(float) || info.PropertyType == typeof(double) || info.PropertyType == typeof(bool))
 | ||
|                 {
 | ||
|                     uc = new DrawGraphManagement.MyUserControl.UCAttrib(selectPoB);
 | ||
|                     uc.SetToolTip = toolTip1;
 | ||
|                     panel = uc.GreatPropertyPanel(info);
 | ||
|                 }
 | ||
|                 else if (info.PropertyType == typeof(Color))
 | ||
|                 {
 | ||
|                     uc = new DrawGraphManagement.MyUserControl.UCColor(selectPoB);
 | ||
|                     uc.SetToolTip = toolTip1;
 | ||
|                     uc.colorDialog1 = colorDialog1;
 | ||
|                     panel = uc.GreatPropertyPanel(info);
 | ||
|                 }
 | ||
|                 else if (info.PropertyType.IsEnum)
 | ||
|                 {
 | ||
|                     uc = new DrawGraphManagement.MyUserControl.UCSelect(selectPoB);
 | ||
|                     uc.datasource = System.Enum.GetNames(info.PropertyType);
 | ||
|                     uc.SetToolTip = toolTip1;
 | ||
|                     panel = uc.GreatPropertyPanel(info);
 | ||
|                 }
 | ||
|                 if (panel != null)
 | ||
|                 {
 | ||
|                     sumPanel.Controls.Add(panel);
 | ||
|                     ModPackObjTree(treeView1.Nodes, selectPoB);
 | ||
|                 }
 | ||
|                 uc.ChangeValue += new UCBase.ChangeValueEventHandler(UC_ChangeValue);
 | ||
|             }
 | ||
| 
 | ||
|             this.panel3.Controls.Add(sumPanel);
 | ||
|         }
 | ||
| 
 | ||
|         public void UC_ChangeValue(PackObjBase sender, EventArgs e)
 | ||
|         {
 | ||
|             uc.ChangeValue -= new UCBase.ChangeValueEventHandler(UC_ChangeValue);
 | ||
|             if (sender == null) return;
 | ||
|         }
 | ||
| 
 | ||
|         public void labColor_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (selectPoB == null) return;
 | ||
| 
 | ||
|             System.Windows.Forms.Label lab = (sender as System.Windows.Forms.Label);
 | ||
|             try
 | ||
|             {
 | ||
|                 Color col = ((BoxPackObj)selectPoB).FillColor;
 | ||
|                 if (colorDialog1.ShowDialog() == DialogResult.OK)
 | ||
|                 {
 | ||
|                     col = colorDialog1.Color;
 | ||
| 
 | ||
|                     ((BoxPackObj)selectPoB).FillColor = col;
 | ||
|                     lab.BackColor = col;
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (Exception)
 | ||
|             {
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|                 ModPackObjTree(treeView1.Nodes, selectPoB);
 | ||
|                 if (selectPoB != null)
 | ||
|                 {
 | ||
|                     selectPoB.Draw();
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         float moveSpanX = 0;
 | ||
|         float moveSpanY = 0;
 | ||
|         MovePackObjCommand moveCmd = null;
 | ||
|         private bool zedGraphControl1_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
 | ||
|         {
 | ||
|             moveSpanX = (float)(Convert.ToDouble(e.X) / Convert.ToDouble(zedGraphControl1.Width));
 | ||
|             moveSpanY = (float)(Convert.ToDouble(e.Y) / Convert.ToDouble(zedGraphControl1.Height));
 | ||
|             float x = (float)(Convert.ToDouble(e.X) / Convert.ToDouble(zedGraphControl1.Width));
 | ||
|             float y = (float)(Convert.ToDouble(e.Y) / Convert.ToDouble(zedGraphControl1.Height));
 | ||
|             if (e.Button == MouseButtons.Left)
 | ||
|             {
 | ||
|                 CommandManage.GetInstance.MouseLeftDown = true;
 | ||
|                 if (CommandManage.GetInstance.CtrlDown)
 | ||
|                 {
 | ||
|                     if (selectPoB != null)
 | ||
|                     {
 | ||
|                         moveCmd = new MovePackObjCommand(areaManage, selectPoB);
 | ||
|                         moveCmd.PreExecute();
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             if (e.Button == MouseButtons.Right)
 | ||
|             {
 | ||
|                 zedGraphControl1.ContextMenuStrip.Items.Clear();
 | ||
|                 List<PackObjBase> packs = areaManage.PackManage.ListPob.FindAll(s => s is TextPackObj);
 | ||
|                 bool isHaveSelect = false;
 | ||
|                 PackObjBase selPobT = null;
 | ||
|                 foreach (PackObjBase pack in packs)
 | ||
|                 {
 | ||
|                     if (pack.InScope((float)x, (float)y))
 | ||
|                     {
 | ||
|                         ToolStripItem mi = new ToolStripMenuItem();
 | ||
|                         int lent = 6;
 | ||
|                         if (pack.PackText.Length <= lent) lent = pack.PackText.Length;
 | ||
|                         mi.Text = pack.PackText.Substring(0, lent);
 | ||
|                         mi.Click -= new EventHandler(contextMenuStrip3_ItemClick);
 | ||
|                         mi.Click += new EventHandler(contextMenuStrip3_ItemClick);
 | ||
|                         mi.Tag = pack;
 | ||
|                         zedGraphControl1.ContextMenuStrip.Items.Add(mi);
 | ||
|                         selPobT = pack;
 | ||
|                         isHaveSelect = true;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 if (!isHaveSelect)
 | ||
|                 {
 | ||
|                     PackObjBase pack = areaManage.PackManage.ListPob.FirstOrDefault(s => s is BorderPackObj);
 | ||
|                     if (pack != null)
 | ||
|                     {
 | ||
|                         ToolStripItem mi = new ToolStripMenuItem();
 | ||
|                         //int lent = 6;
 | ||
|                         mi.Text = "白板对象";
 | ||
|                         mi.Click -= new EventHandler(contextMenuStrip3_ItemClick);
 | ||
|                         mi.Click += new EventHandler(contextMenuStrip3_ItemClick);
 | ||
|                         mi.Tag = pack;
 | ||
|                         zedGraphControl1.ContextMenuStrip.Items.Add(mi);
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             return default(bool);
 | ||
|         }
 | ||
| 
 | ||
|         private void contextMenuStrip3_ItemClick(object sender, EventArgs e)
 | ||
|         {
 | ||
|             ToolStripItem item = (ToolStripItem)sender;
 | ||
|             PackObjBase pack = item.Tag as PackObjBase;
 | ||
|             if (pack != null) {
 | ||
|                 DrawPackObject(pack);
 | ||
| 
 | ||
|                 ClearSelectColor(treeView1.Nodes);
 | ||
|                 //右键选中后右侧树结点标红
 | ||
|                 TreeColorRed(treeView1.Nodes, pack.Descript ,false);
 | ||
|                 treePropertyList.ExpandAll();
 | ||
|             }
 | ||
|         }
 | ||
|         private bool zedGraphControl1_MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
 | ||
|         {
 | ||
|             if (e.Button == MouseButtons.Left)
 | ||
|             {
 | ||
|                 if (CommandManage.GetInstance.CtrlDown && CommandManage.GetInstance.MouseLeftDown) {
 | ||
|                     if (selectPoB != null && moveCmd != null) {
 | ||
|                         float pointTX = (float)(Convert.ToDouble(e.X) / Convert.ToDouble(zedGraphControl1.Width));
 | ||
|                         float pointTY = (float)(Convert.ToDouble(e.Y) / Convert.ToDouble(zedGraphControl1.Height));
 | ||
|                         moveSpanX = pointTX - moveSpanX - poManager.X;
 | ||
|                         moveSpanY = pointTY - moveSpanY - poManager.Y;
 | ||
| 
 | ||
|                         moveCmd.Execute(moveSpanX, moveSpanY);
 | ||
| 
 | ||
|                         moveSpanX = selectPoB.X;
 | ||
|                         moveSpanY = selectPoB.Y;
 | ||
|                     }
 | ||
|                 }
 | ||
| 			}
 | ||
|             return default(bool);
 | ||
|         }
 | ||
|         private bool zedGraphControl1_MouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
 | ||
|         {
 | ||
|             double x = Convert.ToDouble(Convert.ToDouble(e.X) / Convert.ToDouble(zedGraphControl1.Width));
 | ||
|             double y = Convert.ToDouble(Convert.ToDouble(e.Y) / Convert.ToDouble(zedGraphControl1.Height));
 | ||
| 
 | ||
|             int scrollX = 0;
 | ||
|             int scrollY = 0;
 | ||
|             scrollX = panelzgc.HorizontalScroll.Value;
 | ||
|             scrollY = panelzgc.VerticalScroll.Value;
 | ||
| 
 | ||
|             txtXAisx.Text = x.ToString();// + "--" + scrollX.ToString();
 | ||
|             txtYAisx.Text = y.ToString(); //"--" + scrollY.ToString();
 | ||
| 			if (e.Button == MouseButtons.Left)
 | ||
|             {
 | ||
|                 if (CommandManage.GetInstance.CtrlDown && CommandManage.GetInstance.MouseLeftDown)
 | ||
|                 {
 | ||
|                     CommandManage.GetInstance.MouseLeftDown = false;
 | ||
|                     if (moveCmd != null)
 | ||
|                     {
 | ||
|                         moveCmd.LastExecute();
 | ||
|                         CommandManage.GetInstance.AddCommand(moveCmd);
 | ||
|                         if (selectPoB != null)
 | ||
|                         {
 | ||
|                             string propertyName = "X,Y,EndX,EndY";
 | ||
|                             SetSpecificPropertyValues(propertyName);
 | ||
|                         }
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
| 
 | ||
|             return default(bool);
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 设置属性面板中特定的值
 | ||
|         /// </summary>
 | ||
|         /// <param name="propertyName"></param>
 | ||
|         private void SetSpecificPropertyValues(string _propertyName)
 | ||
|         {
 | ||
|             string[] pros = _propertyName.Split(',');
 | ||
|             foreach (string propertyName in pros)
 | ||
|             {
 | ||
|                 Control[] conls = panel3.Controls.Find("textBox" + propertyName, true);
 | ||
|                 if (conls.Length > 0)
 | ||
|                 {
 | ||
|                     Type Ts = selectPoB.GetType();
 | ||
|                     object o = Ts.GetProperty(propertyName).GetValue(selectPoB, null);
 | ||
|                     string Value = Convert.ToString(o);
 | ||
|                     conls[0].Text = Value;
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 画直线
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         private void PackObjBtn_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             Button btn = (Button)sender;
 | ||
|             if (btn != null && btn.Tag != null)
 | ||
|             {
 | ||
|                 PackObjBase bpo = BoardUtil.PackObjFactory(btn.Tag.ToString(), zedGraphControl1, poManager);
 | ||
|                 if (bpo != null)
 | ||
|                 {
 | ||
|                     poManager.ListPob.Add(bpo);
 | ||
|                     InsertPackObjTree(bpo);
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 按顺序画组件
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         private void button1_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             poManager.DrawPackObj();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 保存文件
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         private void button2_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             bool reVal = false;
 | ||
| 
 | ||
|             reVal = areaManage.Save();
 | ||
|             if (reVal)
 | ||
|             {
 | ||
|                 MessageBox.Show(poManager.MsgStr);
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 MessageBox.Show(poManager.MsgStr);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 打开模板
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         private void button3_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             //poManager = new PackObjManager(zedGraphControl1);
 | ||
|             //poManager.AllClear();
 | ||
|             //selectPoB = null;
 | ||
|             //if (uc is DrawGraphManagement.MyUserControl.UCAttrib)
 | ||
|             //    (uc as DrawGraphManagement.MyUserControl.UCAttrib).Clear();
 | ||
|             //OpenFileDialog ofd = new OpenFileDialog();
 | ||
|             //ofd.Filter = "(*.pom)|*.pom|(*.khd)|*.KHD|(*.*)|*.*";
 | ||
|             //ofd.RestoreDirectory = true;
 | ||
|             //if (ofd.ShowDialog() == DialogResult.OK)
 | ||
|             //{
 | ||
|             //    try
 | ||
|             //    {
 | ||
|             //        asFileName = ofd.FileName;
 | ||
|             //        //管理器加载
 | ||
|             //        poManager.LoadContent(ofd.FileName);
 | ||
| 
 | ||
|             //        treeView1.Nodes.Clear();
 | ||
|             //        InsertPackObjToTree(poManager.ListPob);
 | ||
|             //    }
 | ||
|             //    catch (Exception exp)
 | ||
|             //    {
 | ||
|             //        MessageBox.Show(exp.Message);
 | ||
|             //    }
 | ||
|             //    ControlDatabind();
 | ||
|             //}
 | ||
|         }
 | ||
| 
 | ||
|         private void ControlDatabind(bool isDataSource = true)
 | ||
|         {
 | ||
|             txtManagerX.DataBindings.Clear();
 | ||
|             txtManagerX.DataBindings.Add("text", poManager, "X");
 | ||
|             txtManagerY.DataBindings.Clear();
 | ||
|             txtManagerY.DataBindings.Add("text", poManager, "Y");
 | ||
|             txtManageName.DataBindings.Clear();
 | ||
|             txtManageName.DataBindings.Add("text", areaManage, "Name");
 | ||
|             txtClassName.DataBindings.Clear();
 | ||
|             txtClassName.DataBindings.Add("text", areaManage, "ClassName");
 | ||
| 
 | ||
|             if (areaManage.DllName == "") areaManage.DllName = "DrawGraph.dll";
 | ||
|             txtDllName.DataBindings.Clear();
 | ||
|             txtDllName.DataBindings.Add("text", areaManage, "DllName");
 | ||
|             if (areaManage.NameSpace == "") areaManage.NameSpace = "DrawGraph.";
 | ||
|             txtNameSpace.DataBindings.Clear();
 | ||
|             txtNameSpace.DataBindings.Add("text", areaManage, "NameSpace");
 | ||
|             if (areaManage.InstanceName == "") areaManage.InstanceName = "OperationRecord";
 | ||
|             txtInstanceName.DataBindings.Clear();
 | ||
|             txtInstanceName.DataBindings.Add("text", areaManage, "InstanceName");
 | ||
| 
 | ||
|             BoardUtil.ZedControlClear(zedGraphControl1);
 | ||
| 
 | ||
|             if (isDataSource)
 | ||
|                 //绑定treePropertyList控件,手术类属性列表
 | ||
|                 BindPropertyList(areaManage.OpeRecord);
 | ||
|             else
 | ||
|                 BindEntityList();
 | ||
|         }
 | ||
|         private void BindEntityList()
 | ||
|         {
 | ||
|             List<string> Entitys = new List<string>();
 | ||
|             Assembly _Assembyle = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + "DrawGraph.dll");//你的loadfile
 | ||
|             Type[] _TypeList = _Assembyle.GetTypes();
 | ||
| 
 | ||
|             for (int i = 0; i != _TypeList.Length; i++)
 | ||
|             {
 | ||
|                 if (_TypeList[i].Namespace == "DrawGraphManagementArea.DocumentEntity")
 | ||
|                 {
 | ||
|                     Entitys.Add(_TypeList[i].Name);
 | ||
|                 }
 | ||
|             }
 | ||
|             txtInstanceName.DataSource = Entitys;
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 绑定treePropertyList控件,手术类属性列表
 | ||
|         /// </summary>
 | ||
|         private void BindPropertyList(Object classObj, string objName = "OperationRecord")
 | ||
|         {
 | ||
|             treePropertyList.Nodes.Clear();
 | ||
|             PropertyObject proObj = new PropertyObject();
 | ||
|             proObj.Key = objName;
 | ||
|             proObj.Description = "类名";
 | ||
|             List<PropertyObject> propertyList = BoardFormUtil.GetPropertyList(classObj);
 | ||
|             proObj.SubPropertyList = propertyList;
 | ||
|             TreeNode tnSub = new TreeNode();
 | ||
|             tnSub.Name = proObj.ViewTreeNode;
 | ||
|             tnSub.Text = proObj.ViewTreeNode;
 | ||
|             tnSub.Tag = proObj;
 | ||
|             treePropertyList.Nodes.Add(tnSub);
 | ||
|             BindPropertyListSubNode(propertyList, tnSub.Nodes);
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 绑定treePropertyList控件的子结点
 | ||
|         /// </summary>
 | ||
|         /// <param name="propertyList"></param>
 | ||
|         /// <param name="nodes"></param>
 | ||
|         private void BindPropertyListSubNode(List<PropertyObject> propertyList, TreeNodeCollection nodes)
 | ||
|         {
 | ||
|             foreach (PropertyObject propert in propertyList)
 | ||
|             {
 | ||
|                 TreeNode tnSub = new TreeNode();
 | ||
|                 tnSub.Name = propert.ViewTreeNode;
 | ||
|                 tnSub.Text = propert.ViewTreeNode;
 | ||
|                 tnSub.Tag = propert;
 | ||
|                 if (propert.SubPropertyList.Count > 0)
 | ||
|                 {
 | ||
|                     BindPropertyListSubNode(propert.SubPropertyList, tnSub.Nodes);
 | ||
|                 }
 | ||
|                 nodes.Add(tnSub);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void InsertPackObjToTree(List<PackObjBase> pobs)
 | ||
|         {
 | ||
|             List<PackObjBase> subPobs = pobs.FindAll((c) => { return c.ParentName == ""; });
 | ||
|             foreach (PackObjBase pob in subPobs)
 | ||
|             {
 | ||
|                 //先插入父节点为空的内容到根节点
 | ||
|                 InsertListPobObjToTree(pob);
 | ||
|                 //插入此结点下的所有子节点
 | ||
|                 InsertSubPackObjToTree(pobs, pob);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void InsertSubPackObjToTree(List<PackObjBase> pobs, PackObjBase parentPob)
 | ||
|         {
 | ||
|             List<PackObjBase> subPobs = pobs.FindAll((c) => { return c.ParentName == parentPob.PackName; });
 | ||
|             if (subPobs.Count > 0)
 | ||
|             {
 | ||
|                 foreach (PackObjBase pob in subPobs)
 | ||
|                 {
 | ||
|                     pob.SetParent = parentPob;
 | ||
|                     InsertListPobObjToTree(pob);
 | ||
|                     //回调查找自己下面是否有子对象
 | ||
|                     InsertSubPackObjToTree(pobs, pob);
 | ||
|                 }
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void InsertListPobObjToTree(PackObjBase pob)
 | ||
|         {
 | ||
|             pob.Changed += new PackObjBase.ChangedEventHandler(Bpo_Changed);
 | ||
|             TreeNode tnSub = new TreeNode();
 | ||
|             pob.IsSelect = false;
 | ||
|             tnSub.Name = pob.PackName;
 | ||
|             tnSub.Tag = pob;
 | ||
|             tnSub.Text = pob.Descript;
 | ||
|             if (pob.SetParent == null)
 | ||
|             {
 | ||
|                 treeView1.Nodes.Add(tnSub);
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 TreeNode[] tns = treeView1.Nodes.Find(pob.SetParent.PackName, true);
 | ||
|                 if (tns.Length > 0)
 | ||
|                 {
 | ||
|                     tns[0].Nodes.Add(tnSub);
 | ||
|                 }
 | ||
|             }
 | ||
|             pob.Draw();
 | ||
|         }
 | ||
| 
 | ||
|         private void MenuItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             ToolStripMenuItem btn = (ToolStripMenuItem)sender;
 | ||
|             if (btn != null && btn.Tag != null)
 | ||
|             {
 | ||
|                 string tag = btn.Tag.ToString();
 | ||
|                 switch (tag)
 | ||
|                 {
 | ||
|                     case "ChartPackObj":
 | ||
|                         this.CreateTreeItem(tag);
 | ||
|                         
 | ||
|                         this.CreateTreeItem(x1轴ToolStripMenuItem.Tag.ToString());
 | ||
|                         this.CreateTreeItem(x2轴ToolStripMenuItem.Tag.ToString(), true);
 | ||
|                         this.CreateTreeItem(y1轴ToolStripMenuItem.Tag.ToString(), true);
 | ||
|                         this.CreateTreeItem(y2轴ToolStripMenuItem.Tag.ToString(), true);
 | ||
|                         break;
 | ||
|                     default:
 | ||
|                         this.CreateTreeItem(tag);
 | ||
|                         break;
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 可建立绑定数据源的结点
 | ||
|         /// </summary>
 | ||
|         /// <param name="tag"></param>
 | ||
|         /// <param name="dataSourceName"></param>
 | ||
|         /// <param name="tagDesc"></param>
 | ||
|         /// <param name="viewText"></param>
 | ||
|         private void CreateTreeItem(string tag, string dataSourceName = "", string tagDesc = "", string viewText = "", bool isSelMySelf = true)
 | ||
|         {
 | ||
|             PackObjBase bpo = BoardUtil.PackObjFactory(tag, zedGraphControl1, poManager);
 | ||
|             //#region 增加初始默认值
 | ||
|             if (bpo is LinePackObj || bpo is BoxPackObj || bpo is DottedLinePackObj || bpo is DottedLinesPackObj || bpo is LinesPackObj || bpo is RectangleFramePackObj)
 | ||
|             {
 | ||
|                 bpo.EndX = 0.1f;
 | ||
|                 bpo.EndY = 0.1f;
 | ||
|             }
 | ||
|             if (bpo is AbleEditPackObj) {
 | ||
|                 AbleEditPackObj a = bpo as AbleEditPackObj;
 | ||
|                 a.IsViewBoard = EIsBool.True;
 | ||
|             }
 | ||
|             //#endregion
 | ||
| 
 | ||
|             if (bpo != null)
 | ||
|             {
 | ||
|                 if (dataSourceName != "")
 | ||
|                 {
 | ||
|                     bpo.DataSourceName = dataSourceName;
 | ||
|                     bpo.CreatePackTag();
 | ||
|                 }
 | ||
|                 if (tagDesc != "")
 | ||
|                 {
 | ||
|                     bpo.Descript = tagDesc;
 | ||
|                 }
 | ||
|                 if (viewText != "")
 | ||
|                 {
 | ||
|                     bpo.PackText = viewText;
 | ||
|                 }
 | ||
|                 if (bpo is TextPackObj) {
 | ||
|                     TextPackObj tpb = (bpo as TextPackObj);
 | ||
|                     float d = 0;
 | ||
|                     if (float.TryParse(txtFontSize.Text,out d))
 | ||
|                     {
 | ||
|                         tpb.FontSize = d;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 bool reVal = poManager.ListPobsAdd(bpo);
 | ||
|                 if (reVal)
 | ||
|                 {
 | ||
|                     InsertPackObjTree(bpo, isSelMySelf);
 | ||
|                     bpo.Changed += new PackObjBase.ChangedEventHandler(Bpo_Changed);
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     MessageBox.Show("创建组件不能重复");
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 建立普通非绑定数据源的结点
 | ||
|         /// </summary>
 | ||
|         /// <param name="tag"></param>
 | ||
|         /// <param name="hasBrother"></param>
 | ||
|         private void CreateTreeItem(string tag, bool hasBrother)
 | ||
|         {
 | ||
|             PackObjBase bpo = BoardUtil.PackObjFactory(tag, zedGraphControl1, poManager);
 | ||
|             if (bpo != null)
 | ||
|             {
 | ||
|                 if (hasBrother)
 | ||
|                     treeView1.SelectedNode = treeView1.SelectedNode.Parent;
 | ||
|                 poManager.ListPob.Add(bpo);
 | ||
|                 InsertPackObjTree(bpo);
 | ||
|                 bpo.Changed += new PackObjBase.ChangedEventHandler(Bpo_Changed);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void Bpo_Changed(PackObjBase pob)
 | ||
|         {
 | ||
|             ModPackObjTree(treeView1.Nodes, pob);
 | ||
|         }
 | ||
| 
 | ||
|         private void Form1_KeyUp(object sender, KeyEventArgs e)
 | ||
|         {
 | ||
|             if ((e.Control) && e.KeyCode == Keys.S)
 | ||
|             {
 | ||
|                 SaveFileForKey();
 | ||
|             }
 | ||
|             if ((e.Control) && e.KeyCode == Keys.Z) {
 | ||
|                 bool val = CommandManage.GetInstance.CtrlZCommand();
 | ||
|                 if (val)
 | ||
|                 {
 | ||
|                     ReLoad();
 | ||
|                 }
 | ||
|             }
 | ||
|             if ((e.Control) && e.KeyCode == Keys.Y)
 | ||
|             {
 | ||
|                 bool val = CommandManage.GetInstance.CtrlYCommand();
 | ||
|                 if (val)
 | ||
|                 {
 | ||
|                     ReLoad();
 | ||
|                 }
 | ||
|             }else if (e.Control && e.KeyCode == Keys.Left)
 | ||
|             {
 | ||
|                 TreeNode tn = treeView1.SelectedNode;
 | ||
|                 if (tn != null)
 | ||
|                 {
 | ||
|                     PackObjBase pob = (PackObjBase)tn.Tag;
 | ||
|                     if (pob != null)
 | ||
|                     {
 | ||
|                         float moveSpanX = float.Parse(txtMoveValue.Text.Trim());
 | ||
|                         float moveSpanY = 0f;
 | ||
|                         MovePackObjCommand cmd = new MovePackObjCommand(areaManage, pob);
 | ||
|                         cmd.Execute(-moveSpanX, moveSpanY);
 | ||
| 
 | ||
|                         string propertyName = "X,Y,EndX,EndY";
 | ||
|                         SetSpecificPropertyValues(propertyName);
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             else if (e.Control && e.KeyCode == Keys.Right)
 | ||
|             {
 | ||
|                 TreeNode tn = treeView1.SelectedNode;
 | ||
|                 if (tn != null)
 | ||
|                 {
 | ||
|                     PackObjBase pob = (PackObjBase)tn.Tag;
 | ||
|                     if (pob != null)
 | ||
|                     {
 | ||
|                         float moveSpanX = float.Parse(txtMoveValue.Text.Trim());
 | ||
|                         float moveSpanY = 0f;
 | ||
|                         MovePackObjCommand cmd = new MovePackObjCommand(areaManage, pob);
 | ||
|                         cmd.Execute(moveSpanX, moveSpanY);
 | ||
| 
 | ||
|                         string propertyName = "X,Y,EndX,EndY";
 | ||
|                         SetSpecificPropertyValues(propertyName);
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             else if (e.Control && e.KeyCode == Keys.Up)
 | ||
|             {
 | ||
|                 TreeNode tn = treeView1.SelectedNode;
 | ||
|                 if (tn != null)
 | ||
|                 {
 | ||
|                     PackObjBase pob = (PackObjBase)tn.Tag;
 | ||
|                     if (pob != null)
 | ||
|                     {
 | ||
|                         float moveSpanY = float.Parse(txtMoveValue.Text.Trim());
 | ||
|                         float moveSpanX = 0f;
 | ||
|                         MovePackObjCommand cmd = new MovePackObjCommand(areaManage, pob);
 | ||
|                         cmd.Execute(moveSpanX, -moveSpanY);
 | ||
| 
 | ||
|                         string propertyName = "X,Y,EndX,EndY";
 | ||
|                         SetSpecificPropertyValues(propertyName);
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             else if (e.Control && e.KeyCode == Keys.Down)
 | ||
|             {
 | ||
|                 TreeNode tn = treeView1.SelectedNode;
 | ||
|                 if (tn != null)
 | ||
|                 {
 | ||
|                     PackObjBase pob = (PackObjBase)tn.Tag;
 | ||
|                     if (pob != null)
 | ||
|                     {
 | ||
|                         float moveSpanY = float.Parse(txtMoveValue.Text.Trim());
 | ||
|                         float moveSpanX = 0f;
 | ||
|                         MovePackObjCommand cmd = new MovePackObjCommand(areaManage, pob);
 | ||
|                         cmd.Execute(moveSpanX, moveSpanY);
 | ||
| 
 | ||
|                         string propertyName = "X,Y,EndX,EndY";
 | ||
|                         SetSpecificPropertyValues(propertyName);
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             CommandManage.GetInstance.CtrlDown = false;
 | ||
|         }
 | ||
| 
 | ||
|         private void ReLoad()
 | ||
|         {
 | ||
|             selectPoB = null;
 | ||
|             zedGraphControl1.MasterPane.GraphObjList.Clear();
 | ||
|             treeView1.Nodes.Clear();
 | ||
|             panel3.Controls.Clear();
 | ||
|             poManager.SetZedControl(zedGraphControl1);
 | ||
|             InsertPackObjToTree(poManager.ListPob);
 | ||
|             treeView1.ExpandAll();
 | ||
|             zedGraphControl1.Refresh();
 | ||
|         }
 | ||
| 
 | ||
|         private void zedGraphControl1_KeyDown(object sender, KeyEventArgs e)
 | ||
|         {
 | ||
|             if (e.Control)
 | ||
|             {
 | ||
|                 CommandManage.GetInstance.CtrlDown = true;
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 使用Ctrl + S组合键保存
 | ||
|         /// </summary>
 | ||
|         private void SaveFileForKey()
 | ||
|         {
 | ||
|             poManager.SaveFile("", areaManage.Id);
 | ||
|         }
 | ||
| 
 | ||
|         private void 打印ToolStripMenuItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             pDoc.PrintPage += new PrintPageEventHandler(pDoc_PrintPage);
 | ||
|             System.Windows.Forms.PrintDialog pDlg = new System.Windows.Forms.PrintDialog();
 | ||
|             pDlg.Document = pDoc;
 | ||
|             if (pDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
 | ||
|             {
 | ||
|                 pDoc.Print();
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void pDoc_PrintPage(object sender, PrintPageEventArgs e)
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 pDoc.PrintPage -= new PrintPageEventHandler(pDoc_PrintPage);
 | ||
|                 Image img = zedGraphControl1.GetImage();
 | ||
|                 //e.Graphics.DrawImage(img,20f,0f,800f,1160f);
 | ||
|                 e.Graphics.DrawImage(img, 20f, 0f);
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 Console.Write(ex.ToString());
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void treeView1_MouseDown(object sender, MouseEventArgs e)
 | ||
|         {
 | ||
|             if (tabControl1.SelectedIndex == 0)
 | ||
|             {
 | ||
|                 if (e.Button == MouseButtons.Right)
 | ||
|                 {
 | ||
|                     Point ClickPoint = new Point(e.X, e.Y);
 | ||
|                     TreeNode current = treeView1.GetNodeAt(ClickPoint);
 | ||
|                     if (current != null)//判断你点的是不是一个节点
 | ||
|                     {
 | ||
|                         treeView1.SelectedNode = current;//选中这个节点
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 临时节点集合:用于临时存储剪切或者复制下的节点信息
 | ||
|         /// </summary>
 | ||
|         PackObjTree packObjTree = new PackObjTree();
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 树结构的操作方式:剪切或者拷贝
 | ||
|         /// </summary>
 | ||
|         bool isCopy = false;
 | ||
| 
 | ||
|         private void cutMenuItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             CutForKey();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 剪切节点操作
 | ||
|         /// </summary>
 | ||
|         private void CutForKey()
 | ||
|         {
 | ||
|             TreeNode node = treeView1.SelectedNode;
 | ||
| 
 | ||
|             packObjTree = InitPackObjTree(node);
 | ||
|             RemoveNode(node);
 | ||
|             //this.pasteMenuItem.Enabled = true;
 | ||
|             isCopy = false;
 | ||
|         }
 | ||
| 
 | ||
|         private void copyMenuItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             CopyForKey();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 复制操作
 | ||
|         /// </summary>
 | ||
|         private void CopyForKey()
 | ||
|         {
 | ||
|             TreeNode node = treeView1.SelectedNode;
 | ||
|             packObjTree = InitPackObjTree(node);
 | ||
|             //this.pasteMenuItem.Enabled = true;
 | ||
|             isCopy = true;
 | ||
|         }
 | ||
| 
 | ||
|         private void pasteMenuItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             PasteForKey();
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 粘贴操作
 | ||
|         /// </summary>
 | ||
|         private void PasteForKey()
 | ||
|         {
 | ||
|             //this.pasteMenuItem.Enabled = isCopy;
 | ||
| 
 | ||
|             if (isCopy)
 | ||
|             {
 | ||
|                 PackObjBase pob = packObjTree.Current.CloneParse();
 | ||
|                 if (pob != null)
 | ||
|                 {
 | ||
|                     poManager.ListPob.Add(pob);
 | ||
|                     InsertPackObjTree(pob);
 | ||
|                     pob.Changed += new PackObjBase.ChangedEventHandler(Bpo_Changed);
 | ||
|                 }
 | ||
|             }
 | ||
| 
 | ||
|             if (!isCopy)
 | ||
|                 packObjTree = null;
 | ||
|         }
 | ||
| 
 | ||
|         private void deleteMenuItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
| 
 | ||
|             DialogResult dr = MessageBox.Show("是否要确认删除?", "删除确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
 | ||
|             if (dr == DialogResult.OK)
 | ||
|             {
 | ||
|                 TreeNode node = treeView1.SelectedNode;
 | ||
|                 RemoveNode(node);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 构造临时节点树
 | ||
|         /// </summary>
 | ||
|         /// <param name="node">需要添加的节点</param>
 | ||
|         private PackObjTree InitPackObjTree(TreeNode node)
 | ||
|         {
 | ||
|             PackObjTree pobTree = new PackObjTree();
 | ||
|             if (node != null)
 | ||
|             {
 | ||
|                 PackObjBase pob = (PackObjBase)node.Tag;
 | ||
|                 pobTree.Current = pob;
 | ||
|                 pobTree.ParentPob = pob.SetParent;
 | ||
| 
 | ||
|                 if (node.Nodes != null && node.Nodes.Count > 0)
 | ||
|                 {
 | ||
|                     foreach (TreeNode tempNode in node.Nodes)
 | ||
|                     {
 | ||
|                         pobTree.SonPobs.Add(InitPackObjTree(tempNode));
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
| 
 | ||
|             return pobTree;
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 移除指定节点及子节点
 | ||
|         /// </summary>
 | ||
|         /// <param name="node">需要移除的节点</param>
 | ||
|         private void RemoveNode(TreeNode node)
 | ||
|         {
 | ||
|                 if (node != null)
 | ||
|                 {
 | ||
|                     PackObjBase pob = (PackObjBase)node.Tag;
 | ||
|                     if (pob != null)
 | ||
|                     {
 | ||
|                         DelPackObj(node, pob);
 | ||
|                     }
 | ||
| 
 | ||
|                     List<TreeNode> nodeCol = new List<TreeNode>();
 | ||
|                     foreach (TreeNode tempNode in node.Nodes)
 | ||
|                     {
 | ||
|                         nodeCol.Add(tempNode);
 | ||
|                     }
 | ||
|                     if (node.Nodes != null && node.Nodes.Count > 0)
 | ||
|                     {
 | ||
|                         foreach (TreeNode tempNode in nodeCol)
 | ||
|                         {
 | ||
|                             RemoveNode(tempNode);
 | ||
|                         }
 | ||
|                     }
 | ||
|                 }
 | ||
|         }
 | ||
| 
 | ||
|         private void treeView1_KeyUp(object sender, KeyEventArgs e)
 | ||
|         {
 | ||
|             if (e.KeyCode == Keys.Delete)
 | ||
|             {
 | ||
|                 TreeNode tn = treeView1.SelectedNode;
 | ||
|                 if (tn != null)
 | ||
|                 {
 | ||
|                     PackObjBase pob = (PackObjBase)tn.Tag;
 | ||
|                     if (pob != null)
 | ||
|                     {
 | ||
|                         DialogResult dr = MessageBox.Show("是否要确认删除?", "删除确认", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
 | ||
|                         if (dr == DialogResult.OK)
 | ||
|                         {
 | ||
|                             RemoveNode(tn);
 | ||
|                         }
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             else if ((e.Control) && e.KeyCode == Keys.S)
 | ||
|             {
 | ||
|                 //SaveFileForKey();
 | ||
|             }
 | ||
|             else if ((e.Control) && e.KeyCode == Keys.C)
 | ||
|             {
 | ||
|                 //CopyForKey();
 | ||
|             }
 | ||
|             else if ((e.Control) && e.KeyCode == Keys.X)
 | ||
|             {
 | ||
|                 //CutForKey();
 | ||
|             }
 | ||
|             else if ((e.Control) && e.KeyCode == Keys.V)
 | ||
|             {
 | ||
|                 //if (packObjTree != null)
 | ||
|                 //    PasteForKey();
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void DelPackObj(TreeNode tn, PackObjBase pob)
 | ||
|         {
 | ||
|             MovePackObjCommand cmd = new MovePackObjCommand(CommandManage.GetInstance.AreaManage, pob);
 | ||
|             cmd.PreExecute();
 | ||
|             bool reBool = poManager.RemovePob(pob);
 | ||
|             if (reBool)
 | ||
|             {
 | ||
|                 //如果执行成功保存命令
 | ||
|                 cmd.LastExecute();
 | ||
|                 CommandManage.GetInstance.AddCommand(cmd);
 | ||
| 
 | ||
|                 //执行其他操作;
 | ||
|                 pob.Clear();
 | ||
|                 selectPoB = null;
 | ||
|                 zedGraphControl1.Refresh();
 | ||
|                 panel3.Controls.Clear();
 | ||
|                 if (tn != null)
 | ||
|                 {
 | ||
|                     TreeNodeCollection tns = tn.Nodes;
 | ||
|                     TreeNode tnParent = tn.Parent;
 | ||
|                     treeView1.Nodes.Remove(tn);
 | ||
|                     if (tns.Count > 0)
 | ||
|                     {
 | ||
|                         foreach (TreeNode tnTemp in tns)
 | ||
|                         {
 | ||
|                             tnParent.Nodes.Add(tnTemp);
 | ||
|                         }
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void toolStripMenuItem1_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             TreeNode selNode = treePropertyList.SelectedNode;
 | ||
|             if (selNode != null)
 | ||
|             {
 | ||
|                 PropertyObject property = (PropertyObject)selNode.Tag;
 | ||
|                 if (property != null)
 | ||
|                 {
 | ||
|                     ToolStripMenuItem item = sender as ToolStripMenuItem;
 | ||
|                     if (item != null)
 | ||
|                     {
 | ||
|                         PackObjBase pack = areaManage.PackManage.ListPob.FirstOrDefault<PackObjBase>(s => s.DataSourceName == property.ViewDesignTag());
 | ||
|                         bool isAdd = true;
 | ||
|                         if (pack != null) {
 | ||
|                             
 | ||
|                             DialogResult result = MessageBox.Show("要增加的数据绑定组件,已经存在,且结点是:"+ pack.Descript, "是否增加", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 | ||
|                             if (result == DialogResult.Yes)
 | ||
|                             {
 | ||
|                                 isAdd = true;
 | ||
|                             }
 | ||
|                             else {
 | ||
|                                 isAdd = false;
 | ||
|                             }
 | ||
|                         }
 | ||
|                         if (isAdd)
 | ||
|                         {
 | ||
|                             if (selectNode != null)
 | ||
|                             {
 | ||
|                                 treeView1.SelectedNode = selectNode;
 | ||
|                             }
 | ||
|                             //自动增加一组带描述,下划线及文本对象的组件。
 | ||
|                             //设置成有层级关系的
 | ||
|                             //isAddNodeDown = true;
 | ||
|                             this.CreateTreeItem("TextPackObj", "", property.Key + "文本", property.Key);
 | ||
|                             this.CreateTreeItem(item.Tag.ToString(), property.ViewDesignTag(), property.Key,"", false);
 | ||
|                             //完成后换成无层级模式。
 | ||
|                             //isAddNodeDown = false;
 | ||
|                         }
 | ||
|                     }
 | ||
|                     else
 | ||
|                     {
 | ||
|                         MessageBox.Show("创建组件时TAG不能为空");
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             //if (tabControl1.SelectedIndex == 0)
 | ||
|             //{
 | ||
|             //    isAddNodeDown = true;
 | ||
|             //}
 | ||
|             //else
 | ||
|             //{
 | ||
|             //    isAddNodeDown = false;
 | ||
|             //}
 | ||
|         }
 | ||
| 
 | ||
|         private void button1_Click_1(object sender, EventArgs e)
 | ||
|         {
 | ||
|             string objName = txtInstanceName.Text.Trim();
 | ||
|             Object obj = BoardFormUtil.GetObjectFactory<Object>(areaManage.DllName, areaManage.NameSpace, areaManage.InstanceName);
 | ||
|             BindPropertyList(obj, objName);
 | ||
|         }
 | ||
| 
 | ||
|         private void btnSearchInfo_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             TreeColorRed(treePropertyList.Nodes, txtSearchInfo.Text.Trim());
 | ||
|             treePropertyList.ExpandAll();
 | ||
|         }
 | ||
|         private void btnSearchPack_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             string searchInfo = textBox2.Text.Trim();
 | ||
|             if (searchInfo == "") return;
 | ||
|             ClearSelectColor(treeView1.Nodes);
 | ||
| 
 | ||
|             List<PackObjBase> pobs = areaManage.PackManage.ListPob.FindAll(s => s.PackText.ToUpper().IndexOf(searchInfo.ToUpper()) >= 0);
 | ||
|             foreach (PackObjBase pob in pobs)
 | ||
|             {
 | ||
|                 TreeColorRed(treeView1.Nodes, pob.Descript);
 | ||
|             }
 | ||
|             treeView1.ExpandAll();
 | ||
|         }
 | ||
| 
 | ||
|         private void ClearSelectColor(TreeNodeCollection nodes) {
 | ||
|             foreach (TreeNode nodeInNode in nodes)
 | ||
|             {
 | ||
|                 nodeInNode.BackColor = Color.White; 
 | ||
|                 if (nodeInNode.Nodes.Count > 0)
 | ||
|                 {
 | ||
|                     ClearSelectColor(nodeInNode.Nodes);
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void TreeColorRed(TreeNodeCollection nodes, string searchInfo, bool isVague = true)
 | ||
|         {
 | ||
| 
 | ||
|             foreach (TreeNode nodeInNode in nodes)
 | ||
|             {
 | ||
|                 if (isVague)
 | ||
|                 {
 | ||
|                     if (nodeInNode.Text.Trim().ToUpper().IndexOf(searchInfo.ToUpper()) >= 0 && searchInfo != "")
 | ||
|                     {
 | ||
|                         nodeInNode.BackColor = Color.Red;
 | ||
|                         selectNode = nodeInNode;
 | ||
|                         treeView1.SelectedNode = selectNode;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 else {
 | ||
|                     if (nodeInNode.Text.Trim().ToUpper() == searchInfo.ToUpper() && searchInfo != "")
 | ||
|                     {
 | ||
|                         nodeInNode.BackColor = Color.Red;
 | ||
|                         selectNode = nodeInNode;
 | ||
|                         treeView1.SelectedNode = selectNode;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 if (nodeInNode.Nodes.Count > 0)
 | ||
|                 {
 | ||
|                     TreeColorRed(nodeInNode.Nodes, searchInfo, isVague);
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 | ||
|         {
 | ||
|             PackObjBase pack = e.Node.Tag as PackObjBase;
 | ||
|             if (pack != null && selectPoB != null && e.Label != null) {
 | ||
|                 selectPoB = null;
 | ||
|                 pack.Descript = e.Label.Trim();
 | ||
|                 pack.PackText = e.Label.Trim().Replace("文本","");
 | ||
|                 DrawPackObject(pack);
 | ||
|             } 
 | ||
|         }
 | ||
| 
 | ||
|         private void AreaManageForm_Resize(object sender, EventArgs e)
 | ||
|         {
 | ||
|             AutoSizeF();
 | ||
|         }
 | ||
| 
 | ||
|         private void checkBox1_CheckedChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             isViewBackImg = checkBox1.Checked;
 | ||
|             loadBackImage();
 | ||
|         }
 | ||
| 
 | ||
|         private void txtXAisx_DoubleClick(object sender, EventArgs e)
 | ||
|         {
 | ||
|             TextBox send = sender as TextBox;
 | ||
|             if (send != null)
 | ||
|             {
 | ||
|                 Clipboard.SetDataObject(send.Text);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void AreaManageForm_FormClosing(object sender, FormClosingEventArgs e)
 | ||
|         {
 | ||
|             Clipboard.Clear();
 | ||
|             CommandManage.GetInstance.Clear();
 | ||
|             foreach (PackObjBase pob in poManager.ListPob) {
 | ||
|                 if (pob is AbleEditPackObj) {
 | ||
|                     AbleEditPackObj a = pob as AbleEditPackObj;
 | ||
|                     a.IsViewBoard = EIsBool.False;
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void btnOk_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             string fontSize = txtFontSize.Text;
 | ||
| 
 | ||
|             List<PackObjBase> ables = areaManage.PackManage.ListPob.Where<PackObjBase>(s => s is AbleEditPackObj).ToList<PackObjBase>();
 | ||
|             foreach (PackObjBase pack in ables)
 | ||
|             {
 | ||
|                 AbleEditPackObj ableEdit = pack as AbleEditPackObj;
 | ||
|                 ableEdit.FontSize = int.Parse(fontSize);
 | ||
|             }
 | ||
| 
 | ||
|             List<PackObjBase> ablesT = areaManage.PackManage.ListPob.Where<PackObjBase>(s => s is TextPackObj).ToList<PackObjBase>();
 | ||
|             foreach (PackObjBase pack in ablesT)
 | ||
|             {
 | ||
|                 TextPackObj ableEdit = pack as TextPackObj;
 | ||
|                 ableEdit.FontSize = int.Parse(fontSize);
 | ||
|             }
 | ||
|             areaManage.Draw();
 | ||
|         }
 | ||
|         private void CmdToolStripMenuItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (selectPoB == null) return;
 | ||
|             ToolStripMenuItem item = sender as ToolStripMenuItem;
 | ||
|             switch (item.Tag.ToString())
 | ||
|             {
 | ||
|                 case "HCenterCmd":
 | ||
|                     CommandManage.GetInstance.HCenterCmd(selectPoB);
 | ||
|                     break;
 | ||
|                 case "VCenterCmd":
 | ||
|                     CommandManage.GetInstance.VCenterCmd(selectPoB);
 | ||
|                     break;
 | ||
|                 case "TopAlignCmd":
 | ||
|                     CommandManage.GetInstance.TopAlignCmd(selectPoB);
 | ||
|                     break;
 | ||
|                 case "LeftAlignCmd":
 | ||
|                     CommandManage.GetInstance.LeftAlignCmd(selectPoB);
 | ||
|                     break;
 | ||
|                 case "alignCmdOfPack":
 | ||
|                     alignCmdOfPackPnl.Visible = true;
 | ||
|                     cmbPackList.Items.Clear();
 | ||
|                     foreach (PackObjBase pack in areaManage.PackManage.ListPob)
 | ||
|                     {
 | ||
|                         cmbPackList.Items.Add(pack.Descript);
 | ||
|                     }
 | ||
|                     cmbPackList.AutoCompleteMode = AutoCompleteMode.SuggestAppend;//设置自动完成的模式
 | ||
|                     cmbPackList.AutoCompleteSource = AutoCompleteSource.ListItems;//设置自动完成字符串的源
 | ||
|                     break;
 | ||
|             }
 | ||
|             string propertyName = "X,Y,EndX,EndY";
 | ||
|             SetSpecificPropertyValues(propertyName);
 | ||
|         }
 | ||
| 
 | ||
|         private void button3_Click_1(object sender, EventArgs e)
 | ||
|         {
 | ||
|             alignCmdOfPackPnl.Visible = false;
 | ||
|         }
 | ||
| 
 | ||
|         private void btnAlignCmd_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (selectPoB == null)
 | ||
|             {
 | ||
|                 MessageBox.Show("要先选中组件");
 | ||
|                 return;
 | ||
|             }
 | ||
|             if (cmbPackList.Text.Trim() == "" && cmbPackAlignType.Text.Trim() == "")
 | ||
|             {
 | ||
|                 MessageBox.Show("对齐参数不能为空");
 | ||
|                 return;
 | ||
|             }
 | ||
|             PackObjBase JZPack = areaManage.PackManage.ListPob.FirstOrDefault(s => s.Descript == cmbPackList.Text);
 | ||
|             if (JZPack != null)
 | ||
|             {
 | ||
|                 if (cmbPackAlignType.Text.Trim() == "等宽")
 | ||
|                 {
 | ||
|                     CommandManage.GetInstance.SameWidthCmd(selectPoB, JZPack);
 | ||
|                 }
 | ||
|                 else if (cmbPackAlignType.Text.Trim() == "等高")
 | ||
|                 {
 | ||
|                     CommandManage.GetInstance.SameHeightCmd(selectPoB, JZPack);
 | ||
|                 }
 | ||
|                 else if (cmbPackAlignType.Text.Trim() == "右")
 | ||
|                 {
 | ||
|                     CommandManage.GetInstance.SameRightCmd(selectPoB, JZPack);
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     CommandManage.GetInstance.AlignCmdOfPack(selectPoB, JZPack, cmbPackAlignType.Text.Trim());
 | ||
|                 }
 | ||
|                 string propertyName = "X,Y,EndX,EndY";
 | ||
|                 SetSpecificPropertyValues(propertyName);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void cmbPackList_TextChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void 配置值转换ToolStripMenuItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (selectPoB == null)
 | ||
|             {
 | ||
|                 MessageBox.Show("要先选中组件");
 | ||
|                 return;
 | ||
|             }
 | ||
|             if (selectPoB.ConvertMode == EConvertMode.NoConvert)
 | ||
|             {
 | ||
|                 MessageBox.Show("选中对象的ConverMode不能是NoConvert");
 | ||
|                 return;
 | ||
|             }
 | ||
| 
 | ||
|             ConvertModeForm form = new ConvertModeForm(selectPoB, null);
 | ||
|             form.ShowDialog();
 | ||
|         }
 | ||
| 
 | ||
|         private void 生成可编辑区域不带前标签ToolStripMenuItem_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             TreeNode selNode = treePropertyList.SelectedNode;
 | ||
|             if (selNode != null)
 | ||
|             {
 | ||
|                 PropertyObject property = (PropertyObject)selNode.Tag;
 | ||
|                 if (property != null)
 | ||
|                 {
 | ||
|                     ToolStripMenuItem item = sender as ToolStripMenuItem;
 | ||
|                     if (item != null)
 | ||
|                     {
 | ||
|                         PackObjBase pack = areaManage.PackManage.ListPob.FirstOrDefault<PackObjBase>(s => s.DataSourceName == property.ViewDesignTag());
 | ||
|                         bool isAdd = true;
 | ||
|                         if (pack != null)
 | ||
|                         {
 | ||
|                             DialogResult result = MessageBox.Show("要增加的数据绑定组件,已经存在,且结点是:" + pack.Descript, "是否增加", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 | ||
|                             if (result == DialogResult.Yes)
 | ||
|                             {
 | ||
|                                 isAdd = true;
 | ||
|                             }
 | ||
|                             else
 | ||
|                             {
 | ||
|                                 isAdd = false;
 | ||
|                             }
 | ||
|                         }
 | ||
|                         if (isAdd)
 | ||
|                         {
 | ||
|                             if (selectNode != null)
 | ||
|                             {
 | ||
|                                 treeView1.SelectedNode = selectNode;
 | ||
|                             }
 | ||
|                             //自动增加一组带描述,下划线及文本对象的组件。
 | ||
|                             //完成后换成无层级模式。
 | ||
|                             //isAddNodeDown = false;
 | ||
|                             this.CreateTreeItem(item.Tag.ToString(), property.ViewDesignTag(), property.Key);
 | ||
|                         }
 | ||
|                     }
 | ||
|                     else
 | ||
|                     {
 | ||
|                         MessageBox.Show("创建组件时TAG不能为空");
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
|         //鼠标移动窗体移动
 | ||
|         private bool isMouseDown = false;
 | ||
|         private Point lableLocation;     //lable的location
 | ||
|         private Point mouseOffset;      //鼠标的按下位置
 | ||
|         private void lable_MouseDown(object sender, MouseEventArgs e)
 | ||
|         {
 | ||
| 
 | ||
|             if (e.Button == MouseButtons.Left)
 | ||
|             {
 | ||
|                 isMouseDown = true;
 | ||
|                 lableLocation = ((Panel)sender).Location;
 | ||
|                 mouseOffset = Control.MousePosition;
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void lable_MouseUp(object sender, MouseEventArgs e)
 | ||
|         {
 | ||
|             isMouseDown = false;
 | ||
|         }
 | ||
| 
 | ||
|         private void lable_MouseMove(object sender, MouseEventArgs e)
 | ||
|         {
 | ||
|             int _x = 0;
 | ||
|             int _y = 0;
 | ||
|             if (isMouseDown)
 | ||
|             {
 | ||
|                 Point pt = Control.MousePosition;
 | ||
|                 _x = mouseOffset.X - pt.X;
 | ||
|                 _y = mouseOffset.Y - pt.Y;
 | ||
|                 ((Panel)sender).Location = new Point(lableLocation.X - _x, lableLocation.Y - _y);
 | ||
|             }
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|         private void contextMenuStrip2_VisibleChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             contextMenuStrip2.Enabled = true;
 | ||
|             if (contextMenuStrip2.Visible) {
 | ||
| 
 | ||
|                 //根结点
 | ||
|                 TreeNode rootNode = treePropertyList.Nodes[0];
 | ||
|                 TreeNode selNode = treePropertyList.SelectedNode;
 | ||
|                 if (rootNode != null && selNode != null)
 | ||
|                 {
 | ||
|                     ////只有要根结点下的所有数据对象可以生成可编辑组件
 | ||
|                     //if (selNode.Parent == rootNode)
 | ||
|                     //{
 | ||
|                         toolStripMenuItem1.Enabled = true;
 | ||
|                         生成可编辑区域ToolStripMenuItem.Enabled = true;
 | ||
|                         生成可编辑区域不带前标签ToolStripMenuItem.Enabled = true;
 | ||
|                     //}
 | ||
|                     //else
 | ||
|                     //{
 | ||
|                     //    toolStripMenuItem1.Enabled = true;
 | ||
|                     //    生成可编辑区域ToolStripMenuItem.Enabled = false;
 | ||
|                     //    生成可编辑区域不带前标签ToolStripMenuItem.Enabled = false;
 | ||
|                     //}
 | ||
|                 }
 | ||
| 
 | ||
|                 if (selNode != null && selNode.Nodes.Count > 0)
 | ||
|                 {
 | ||
|                     contextMenuStrip2.Enabled = false;
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
|     }
 | ||
| }
 |