public void GenerateID(Global.DrawType type) { Random ra = new Random(unchecked ((int)DateTime.Now.Ticks)); int i = ra.Next(1, 100000); id = (uint)i; }
public virtual void ReadFromXml(XmlElement xmlElement) { string val; xmlElement.GetAttribute("Type"); val = xmlElement.GetAttribute("DrawType"); switch (val) { case "DrawEllipse": objectType = Global.DrawType.DrawEllipse; break; case "DrawLine": objectType = Global.DrawType.DrawLine; break; case "DrawPic": objectType = Global.DrawType.DrawPic; break; case "DrawRectangle": objectType = Global.DrawType.DrawRectangle; break; case "DrawText": objectType = Global.DrawType.DrawText; break; } ObjName = xmlElement.GetAttribute("ObjName"); val = xmlElement.GetAttribute("Run"); RunMode = Convert.ToBoolean(val); val = xmlElement.GetAttribute("Lock"); Lock = Convert.ToBoolean(val); val = xmlElement.GetAttribute("ID"); ID = Convert.ToUInt32(val); Click = xmlElement.GetAttribute("Click"); DoubleClick = xmlElement.GetAttribute("DoubleClick"); Format = xmlElement.GetAttribute("Format"); textName = xmlElement.GetAttribute("textName"); xName = xmlElement.GetAttribute("xName"); yName = xmlElement.GetAttribute("yName"); widthName = xmlElement.GetAttribute("widthName"); heightName = xmlElement.GetAttribute("heightName"); visibleName = xmlElement.GetAttribute("visibleName"); FillColorName = xmlElement.GetAttribute("FillColorName"); val = xmlElement.GetAttribute("Color"); Color = Color.FromArgb(Convert.ToInt32(val)); val = xmlElement.GetAttribute("PenWidth"); PenWidth = Convert.ToInt32(val); val = xmlElement.GetAttribute("X"); X = Convert.ToInt32(val); val = xmlElement.GetAttribute("Y"); Y = Convert.ToInt32(val); val = xmlElement.GetAttribute("Width"); Width = Convert.ToInt32(val); val = xmlElement.GetAttribute("Height"); Height = Convert.ToInt32(val); ShapeRect = new Rectangle(X, Y, Width, Height); }
//将所选工具加入到页面容器中 private void VisualGraph_DragDrop(object sender, DragEventArgs e) { Point point = new Point(e.X, e.Y); point = this.PointToClient(point); switch (activedObjType) { case Global.DrawType.DrawText: DrawText text = new DrawText(point, this); objList.UnselectAll(); objList.AddObject(text); text.Selected = true; break; case Global.DrawType.DrawRectangle: DrawRectangle rect = new DrawRectangle(point, this); objList.UnselectAll(); objList.AddObject(rect); rect.Selected = true; break; case Global.DrawType.DrawEllipse: DrawEllipse elip = new DrawEllipse(point, this); objList.UnselectAll(); objList.AddObject(elip); elip.Selected = true; break; case Global.DrawType.DrawLine: DrawLine line = new DrawLine(point, this); objList.UnselectAll(); objList.AddObject(line); line.Selected = true; break; case Global.DrawType.DrawPic: DrawPic pic = new DrawPic(point, this); objList.UnselectAll(); objList.AddObject(pic); pic.Selected = true; break; } activedObjType = Global.DrawType.POINTER; this.Refresh(); }