public NComboBox(Shape shape) : base(shape) { mListItems = new NListItemCollection(); mListItems.OnItemAdded+=new Netron.GraphLib.Utils.NListItemCollection.NListChange(mListItems_OnItemAdded); mListItems.OnItemRemoved+=new Netron.GraphLib.Utils.NListItemCollection.NListChange(mListItems_OnItemRemoved); }
/// <summary> /// 显示设备属性 /// </summary> /// <param name="shape"></param> private void showData(Netron.GraphLib.Shape shape) { if (shape is BaseShape) { BaseShape bs = shape as BaseShape; object obj = null; if (string.IsNullOrEmpty(bs.DeviceID)) { obj = DeviceHelper.SelectDevice(bs.DeviceType, Itop.Client.MIS.ProgUID); if (obj is PSPDEV) { bs.DeviceID = ((PSPDEV)obj).SUID; } } if (bs.DeviceID != null) { obj = DeviceHelper.GetDevice <PSPDEV>(bs.DeviceID); if (obj != null) { bs.Text = ((PSPDEV)obj).Name; DeviceHelper.ShowDeviceDlg((DeviceType)int.Parse(bs.DeviceType), bs.DeviceID); } } } }
public GL.Connection Connect(GL.Shape s1, GL.Shape s2, string linePath, GL.ConnectionEnd lineEnd) { GL.Connection con = GraphControl.AddConnection(s1.Connectors[0], s2.Connectors[0]); con.LinePath = linePath; con.LineEnd = lineEnd; return(con); }
public NTextBox(Shape shape) : base(shape) { mListItems = new NListItemCollection(); timer = new Timer(); timer.Interval = 600; timer.Tick+=new EventHandler(timer_Tick); }
public NComboBox(Shape shape, int width, int height) : base(shape) { this.mWidth = width; this.mHeight = height; mListItems = new NListItemCollection(); mListItems.OnItemAdded+=new Netron.GraphLib.Utils.NListItemCollection.NListChange(mListItems_OnItemAdded); mListItems.OnItemRemoved+=new Netron.GraphLib.Utils.NListItemCollection.NListChange(mListItems_OnItemRemoved); }
public NTextBox(Shape shape, int width, int height) : base(shape) { this.mWidth = width; this.mHeight = height; mListItems = new NListItemCollection(); timer = new Timer(); timer.Interval = 600; timer.Tick+=new EventHandler(timer_Tick); }
public event EventHandler OnLoactionXL;//定位线路 void ucGraph1_OnShapeMenuItemClick(object sender, Netron.GraphLib.Shape shape) { MenuItem menu = sender as MenuItem; switch (menu.Text) { case "定位到地理信息图": if (OnLoactionXL != null) { OnLoactionXL(((BaseShape)shape).DeviceID, null); } break; } }
/// <summary> /// Constructor of the FerdaConnector clss /// </summary> /// <param name="o">the underlying shape to which the connector belongs</param> /// <param name="socket">The connector will represent this socket</param> /// <param name="svgMan">SVGManager for drawing svg bitmaps</param> /// <param name="packed">If the connector is packed in the beginning</param> /// <remarks> /// Nevim jeste, jestli se oplati pro kazdy konektor drzet /// si svuj vlastni socket, zatim se to vyuziva jenom pri konstrukci k ziskani /// bitmapy /// </remarks> public FerdaConnector(Shape o, SVGManager svgMan, SocketInfo socket, bool packed) : base(o, socket.label, socket.moreThanOne) { //setting the svgManager and the Bitmap svgManager = svgMan; bitmap = svgManager.GetSocketBitmap(socket); this.socket = socket; hasPacked = packed; //this shlould eliminate the problems with connecting more than //one connection when the MoreThanOne property of ISocket is set to false this.AllowMultipleConnections = socket.moreThanOne; }
private void graphControl1_OnShapeAdded(object sender, Netron.GraphLib.Shape shape) { graphControl1.Nodes.Remove(shape); if (shape is ActiveRecordShape) { ActiveRecordShape arshape = shape as ActiveRecordShape; _actionSet.DoNewARWizard(); } else if (shape is ActiveRecordBaseClassShape) { ActiveRecordBaseClassShape arshape = shape as ActiveRecordBaseClassShape; // if (_actionSet.DoAssociateDatabase(arshape)) // { // } } }
void graphControl1_OnShapeMenuItemClick(object sender, Netron.GraphLib.Shape shape) { MenuItem menu = sender as MenuItem; switch (menu.Text) { case "设备参数": showData(shape); break; case "投入运行": setDeviceStatus((shape as BaseShape).DeviceID, 0); break; case "退出运行": setDeviceStatus((shape as BaseShape).DeviceID, 1); break; } if (OnShapeMenuItemClick != null) { OnShapeMenuItemClick(sender, shape); } }
public bool IsConnectedTo(Shape shape) { foreach(Connector c in this.connectors) { foreach(Connection con in c.Connections) { if(con.To.BelongsTo.Equals(shape) || con.From.BelongsTo.Equals(shape)) return true; } } return false; }
private Connection Connect(Shape childShape, Shape parentShape) { Connection conn = graphControl1.AddEdge(childShape.Connectors[1], parentShape.Connectors[0]); // conn.From.ConnectorLocation = ConnectorLocations.South; // conn.To.ConnectorLocation = ConnectorLocations.North; conn.LineEnd = ConnectionEnds.RightOpenArrow; return conn; }
public GL.Connection Connect(GL.Shape s1, GL.Shape s2) { return(GraphControl.AddConnection(s1.Connectors[0], s2.Connectors[0])); }
public void Remove(Shape shape) { this.InnerList.Remove(shape); }
private void ShowShapeProperties(Shape shape) { if (shape is ActiveRecordBaseClassShape) { ActiveRecordBasePropertiesDialog d = new ActiveRecordBasePropertiesDialog(); d.ShowDialog(); } else if (shape is ActiveRecordShape) { ActiveRecordDescriptor ar = (shape as ActiveRecordShape).ActiveRecordDescriptor; ActiveRecordPropertiesDialog dlg = new ActiveRecordPropertiesDialog(ar, _model.CurrentProject); dlg.ShowDialog(); } }
public static string lookupShapeKey(Shape a) { string shapecase = a.GetType().ToString(); string ZFunKey = typeof(Netron.GraphLib.BasicShapes.ZNode).ToString(); string simpleNodeKey = typeof(Netron.GraphLib.BasicShapes.SimpleNode).ToString(); string smallZFunKey = typeof(Netron.GraphLib.BasicShapes.smallZNode).ToString(); string tinyZFunKey = typeof(Netron.GraphLib.BasicShapes.tinyZNode).ToString(); if (shapecase == ZFunKey) return "6E92FCD0-75DF-4f8f-A5B2-2927E22F4F0F"; else if (shapecase == smallZFunKey) return "b2178640-076f-4520-b33c-c603466bc2fc"; else if (shapecase == tinyZFunKey) return "4F878611-3196-4d12-BA36-705F502C8A6B"; else if (shapecase == simpleNodeKey) return "57AF94BA-4129-45dc-B8FD-F82CA3B4433E"; else return "8ED1469D-90B2-43ab-B000-4FF5C682F530"; }
/// <summary> /// Handles the mouse down event /// </summary> /// <param name="e">Events arguments</param> protected override void OnMouseDown(MouseEventArgs e) { //make sure the canvas has the focus this.Focus(); // Get a point adjusted by the current scroll position and zoom factor PointF p = new PointF(e.X - this.AutoScrollPosition.X, e.Y - this.AutoScrollPosition.Y); p = UnzoomPoint(Point.Round(p)); //pass the event to the hit entity HitHover(p); #region Ctrl+Shift left if((e.Button==MouseButtons.Left) && (e.Clicks==1) && (CtrlShift)) { this.Zoom +=0.1F; CtrlShift = false; return; } #endregion #region Ctrl+Shift right if((e.Button==MouseButtons.Right) && (e.Clicks==1) && (CtrlShift)) { this.Zoom -=0.1F; CtrlShift = false; this.ContextMenu = null; return; } #endregion #region Double click left //shows the properties of the underlying object if ((e.Button == MouseButtons.Left) && (e.Clicks == 2)) { //do we hit something under the cursor? HitHover(p); if ((Hover != null) && (typeof(Entity).IsInstanceOfType(Hover))) { this.RaiseShowProps(((Entity) Hover).Properties); Update(); return; } } #endregion #region SINGLE click left if ((e.Button == MouseButtons.Left) && (e.Clicks == 1)) { // Alt+Click allows fast creation of elements if ((shapeObject == null) && (ModifierKeys == Keys.Alt)) { shapeObject = this.GetShapeInstance(lastAddedShapeKey); } if (shapeObject != null) { shapeObject.Invalidate(); RectangleF r = shapeObject.Rectangle; shapeObject.Rectangle = new RectangleF(p.X, p.Y, r.Width, r.Height); shapeObject.Invalidate(); if(OnShapeAdded!=null) OnShapeAdded(this,shapeObject); //raise the event extract.Insert(shapeObject); shapeObject = null; return; } //reset the selector marquee selector = null; //see if something under the cursor HitHover(p); if (Hover != null)//the click resulted in an object; shape or connection { if (typeof(Connector).IsInstanceOfType(Hover)) { if(!((Connector) Hover).AllowMultipleConnections && ((Connector) Hover).Connections.Count>0) return; if(!mAllowAddConnection) return; connection = new Connection(this); connection.Site=this; connection.From = (Connector) Hover; connection.ToPoint = p; //we use the mouse as To as long as we haven't a real connector, which will occur in the OnMouseUp Hover.Invalidate(); Capture = true; Update(); return; } // select object or add to the list of selected objects if (!Hover.IsSelected) { if (ModifierKeys != Keys.Shift) Deselect(); //s is empty only if shift is pushed //shift-click adds only ONE item while a normal click can change a set of shapes to //another state. Hover.IsSelected=true; Update(); } //fix the node if the layout is manipulating the position if (typeof(Shape).IsInstanceOfType(Hover)) { foreach(Shape sho in extract.Shapes) sho.Fixed=false; ((Shape) Hover).Fixed=true; } // search tracking handle Point h = new Point(0, 0); if (extract.Shapes.Contains(Hover)) { Shape o = (Shape) Hover; h = o.ShapeTracker.Hit(p); } foreach (Shape j in extract.Shapes) { if (j.ShapeTracker != null) //will only be one tracker per hit { j.ShapeTracker.Start(p, h); foreach(Connector c in j.Connectors) { foreach(Connection cn in c.Connections) if( cn.Tracker != null ) cn.Tracker.Start(p,Point.Empty); } } } // Search tracker handle of connection and start tracking if( typeof(Connection).IsInstanceOfType(Hover) ) { connection = Hover as Connection; h = connection.Tracker.Hit(p); connection.Tracker.Start(p,h); } mDoTrack = true; Capture = true; if ((Hover != null) && (typeof(Entity).IsInstanceOfType(Hover))) { (Hover as Entity).RaiseMouseDown(e); } SetCursor(p); return; } //TADY JE MOZNA DALSI PROBLEM p=new PointF(e.X,e.Y); selector = new Selector(p, this); } #endregion #region SINGLE click right if (e.Button == MouseButtons.Right) { if (Hover != null) { if (!Hover.IsSelected) { //Select s = new Select(); Deselect(); //s.Add(Hover, true); //extract.History.Do(s); Hover.IsSelected=true; Update(); } } if(this.mEnableContextMenu ) { if(OnContextMenu !=null) OnContextMenu(this, e); //This region must be dropped out. It is a little against the //concept of object programming to let the successor of this class //create some context menu and then erase it with this context menu /* this.ContextMenu=new ContextMenu(); ResetToBaseMenu(); if(typeof(Shape).IsInstanceOfType(Hover)) { //MenuItem[] tmp = new MenuItem[mContextMenu.MenuItems.Count]; //mContextMenu.MenuItems.CopyTo(tmp,0); MenuItem[] additionals = (Hover as Shape).ShapeMenu(); if(additionals != null) { this.ContextMenu.MenuItems.Add("-"); this.ContextMenu.MenuItems.AddRange(additionals); } } else if(typeof(Connection).IsInstanceOfType(Hover)) { if((Hover as Connection).LinePath== "Rectangular") return; this.insertionPoint = p; this.ContextMenu.MenuItems.Add("-"); MenuItem[] subconnection = new MenuItem[2]{ new MenuItem("Add point",new EventHandler(AddConnectionPoint)), new MenuItem("Delete point",new EventHandler(RemoveConnectionPoint)) }; this.ContextMenu.MenuItems.Add(new MenuItem("Connection",subconnection)); } */ } } #endregion }
/// <summary> /// Adds a given shape to the canvas at the mouse position /// </summary> /// <param name="sob"></param> /// <returns></returns> protected Shape AddShape(Shape sob) { return this.AddShape(sob, Center); }
/// <summary> /// Adds a given shape to the canvas at the specified position /// </summary> /// <param name="sob">a shape object</param> /// <param name="position">the position at twhich the shape has to be placed</param> /// <returns>the added shape object or null if unsuccessful</returns> protected Shape AddShape(Shape sob, PointF position) { try { sob.Site=this; //sob.Invalidate(); RectangleF r = sob.Rectangle; sob.Rectangle = new RectangleF(position.X, position.Y, r.Width, r.Height); sob.Invalidate(); #if NAFEnabled //only necessary if you want NAF integration sob.Root = this.root; #endif extract.Insert(sob); if(OnShapeAdded !=null) { OnShapeAdded(this,sob); } } catch(Exception exc) { Trace.WriteLine(exc.Message); sob = null; } return sob ; }
public void RemoveShape(Shape shape) { if(OnShapeRemoved!=null) OnShapeRemoved(this,shape); }
/// <summary> /// This should delete all the connectors of the shape /// </summary> /// <param name="sender">Sender of the event</param> /// <param name="shape">Shape that is being removed</param> void FerdaDesktop_OnShapeRemoved(object sender, Shape shape) { BoxNode bn = shape as BoxNode; if (bn != null) { //removing all the edges foreach (Connector connector in shape.Connectors) { foreach (Netron.GraphLib.Connection connection in Edges) { if (connection.From == connector || connection.To == connector) { DeleteConnection(connection); } } } IBoxModule box = bn.Box; view.Remove(box); //removing the box that was selected //SelectedBoxes.Remove(box); //removing the node //Nodes.Remove(shape); Adapt(); //adapting the menu and toolbar menuDisplayer.ControlHasFocus = this; menuDisplayer.Adapt(); toolBar.ControlHasFocus = this; toolBar.Adapt(); //resetting the other properties PropertiesDisplayer.Reset(); ContextHelpDisplayer.Reset(); UserNote.Reset(); } }
private Connection ConnectSubToSuperClass(Shape parentShape, Shape childShape) { Connection conn = graphControl1.AddEdge(parentShape.Connectors[1], childShape.Connectors[0]); conn.LineEnd = ConnectionEnds.RightOpenArrow; return conn; }
public int Add(Shape shape) { return this.InnerList.Add(shape); }
public NetronGraphControl(Shape parent) { this.parent = parent; Init(); }
public void SetShape(GL.Shape shape) { shape.X = Randomizer.Next(50, GraphControl.Width - 100); shape.Y = Randomizer.Next(50, GraphControl.Height - 20); }
private void SetShape(Shape shape) { shape.FitSize(false); shape.X = rnd.Next(50,this.graphControl1.Width-100); shape.Y = rnd.Next(50,this.graphControl1.Height-20); }
private void CreateConnectionsIfNecessary(Shape shape) { ActiveRecordShape arshape = shape as ActiveRecordShape; if (arshape != null) { if (arshape.ActiveRecordDescriptor is ActiveRecordDescriptorSubClass) { ActiveRecordDescriptorSubClass subclass = arshape.ActiveRecordDescriptor as ActiveRecordDescriptorSubClass; ConnectSubToSuperClass( ObtainShape(subclass.BaseClass), shape ); } else { ConnectSubToSuperClass( ObtainBaseShape(arshape), shape ); } } }
/// <summary> /// Inserts a new object into the plex. /// </summary> /// <param name="so">the object to insert</param> /// <remarks>Note that you can add only one shape at a time. /// </remarks> protected internal void Insert(Shape so) { so.Insert(this); }