protected override void initConnector() { //leftConnector = new Connector(this, "leftconnector", true); //leftConnector.ConnectorLocation = ConnectorLocation.West; //Connectors.Add(leftConnector); //topConnector = new Connector(this, "topconnector", true); //topConnector.ConnectorLocation = ConnectorLocation.North; //Connectors.Add(topConnector); //rightConnector = new Connector(this, "rightconnector", true); //rightConnector.ConnectorLocation = ConnectorLocation.East; //Connectors.Add(rightConnector); //bottomConnector = new Connector(this, "bottomconnector", true); //bottomConnector.ConnectorLocation = ConnectorLocation.South; //Connectors.Add(bottomConnector); for (int i = 1; i <= connectorNumber; i++) { //Connector cr = new Connector(this, "top" + i, true); //cr.ConnectorLocation = ConnectorLocation.North; //Connectors.Add(cr); Connector cr = new Connector(this, "bottom" + i, true); cr.ConnectorLocation = ConnectorLocation.South; Connectors.Add(cr); } }
/// <summary> /// Deserialization constructor /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected ImageShape(SerializationInfo info, StreamingContext context) : base(info, context) { TopNode = (Connector)info.GetValue("TopNode", typeof(Connector)); TopNode.BelongsTo = this; Connectors.Add(TopNode); BottomNode = (Connector)info.GetValue("BottomNode", typeof(Connector)); BottomNode.BelongsTo = this; Connectors.Add(BottomNode); LeftNode = (Connector)info.GetValue("LeftNode", typeof(Connector)); LeftNode.BelongsTo = this; Connectors.Add(LeftNode); RightNode = (Connector)info.GetValue("RightNode", typeof(Connector)); RightNode.BelongsTo = this; Connectors.Add(RightNode); IsResizable = true; try { mImage = info.GetValue("mImage", typeof(Image)) as Image; if (mImage != null) { //the following line will reset the original image size, but I guess it's safer to keep the serialized size; //Rectangle = new RectangleF(Rectangle.X, Rectangle.Y, mImage.Width, mImage.Height); mImagePath = info.GetString("mImagePath"); } } catch { } }
protected KBSShape(SerializationInfo info, StreamingContext context) : base(info, context) { for (int i = 1; i <= connectorNumber; i++) { try { Connector cr = (Connector)info.GetValue("bottom" + i, typeof(Connector)); cr.BelongsTo = this; Connectors.Add(cr); } catch { } } //leftConnector = (Connector)info.GetValue("leftconnector", typeof(Connector)); //rightConnector = (Connector)info.GetValue("rightconnector", typeof(Connector)); //topConnector = (Connector)info.GetValue("topconnector", typeof(Connector)); //bottomConnector = (Connector)info.GetValue("bottomconnector", typeof(Connector)); //leftConnector.BelongsTo = this; //rightConnector.BelongsTo = this; //topConnector.BelongsTo = this; //bottomConnector.BelongsTo = this; //Connectors.Add(leftConnector); //Connectors.Add(rightConnector); //Connectors.Add(topConnector); //Connectors.Add(bottomConnector); }
/// <summary> /// This is the default constructor of the class. /// </summary> public ComboControl() : base() { //set the default size Rectangle = new RectangleF(0, 0, 70, 40); //set the connector leftConnector = new Connector(this, "Connector", true); leftConnector.ConnectorLocation = ConnectorLocation.West; Connectors.Add(leftConnector); //cannot be resized IsResizable = false; this.OnMouseDown += new MouseEventHandler(ComboControl_OnMouseDown); this.OnMouseMove += new MouseEventHandler(ComboControl_OnMouseMove); combo = new NComboBox(this, 50, 15); combo.OnResize += new Netron.GraphLib.NComboBox.ResizeInfo(combo_OnResize); combo.ListItems.Add(new NListItem("Christiaan Huyghens")); combo.ListItems.Add(new NListItem("Werner Heisenberg")); combo.ListItems.Add(new NListItem("Marie Curie")); combo.ListItems.Add(new NListItem("Isaac Newton")); combo.ListItems.Add(new NListItem("Ilya Prigogine")); combo.ListItems.Add(new NListItem("Wolfgang Pauli")); combo.ListItems.Add(new NListItem("Paul Dirac")); combo.ListItems.Add(new NListItem("Richard Feynman")); combo.ListItems.Add(new NListItem("Gustav Hertz")); combo.ListItems.Add(new NListItem("Gaspard Monge")); combo.ListItems.Add(new NListItem("David Mermin")); combo.SelectedIndex = 0; this.Text = "Physicists"; this.Controls.Add(combo); this.IsResizable = false; }
public DynamicRelaxationSystem() { this.Nodes = new List <Node>(); this.Connectors = new List <Connector>(); this.Mesh = new List <MeshElement>(); Gravity = 0; double stiffness = 100; Nodes.Add(new Node(10, new Point3D(0, 0, 0)) { Fixed = true }); for (int i = 1; i < 10; i++) { Nodes.Add(new Node(10, new Point3D(i * 1000, 0, 0))); Connectors.Add(new Connector(Nodes[i - 1], Nodes[i]) { NaturalLength = 1000, Stiffness = stiffness }); } for (int i = 1; i < 10; i++) { Nodes.Add(new Node(10, new Point3D(0, i * 1000, 0))); Connectors.Add(new Connector(Nodes[i * 10], Nodes[(i - 1) * 10]) { NaturalLength = 1000, Stiffness = stiffness }); for (int j = 1; j < 10; j++) { Nodes.Add(new Node(10, new Point3D(j * 1000, i * 1000, 0))); Connectors.Add(new Connector(Nodes[i * 10 + j - 1], Nodes[i * 10 + j]) { NaturalLength = 1000, Stiffness = stiffness }); Connectors.Add(new Connector(Nodes[i * 10 + j], Nodes[(i - 1) * 10 + j]) { NaturalLength = 1000, Stiffness = stiffness }); Mesh.Add(new MeshElement((i - 1) * 10 + j - 1, (i - 1) * 10 + j, i * 10 + j - 1)); Mesh.Add(new MeshElement((i - 1) * 10 + j, i * 10 + j, i * 10 + j - 1)); } } Nodes[99].Position = new Point3D(Nodes[99].Position.X, Nodes[99].Position.Y, 0); Nodes[99].Fixed = true; Nodes[9].Position = new Point3D(Nodes[9].Position.X, Nodes[9].Position.Y, 0); Nodes[9].Fixed = true; Nodes[90].Position = new Point3D(Nodes[90].Position.X, Nodes[90].Position.Y, 0); Nodes[90].Fixed = true; double minX = Nodes.Min(a => a.Position.X); double minY = Nodes.Min(a => a.Position.Y); double maxX = Nodes.Max(a => a.Position.X); double maxY = Nodes.Max(a => a.Position.Y); foreach (var node in Nodes) { node.uvPoint = new Point((int)(node.Position.X - minX) / (maxX - minX), (node.Position.Y - minY) / (maxY - minY)); } }
public override void Init() { base.Init(); cTop = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Top), Model); cTop.Name = "Top connector"; cTop.Parent = this; Connectors.Add(cTop); cRight = new Connector(new Point(Rectangle.Right, (int)(Rectangle.Top + Rectangle.Height / 2)), Model); cRight.Name = "Right connector"; cRight.Parent = this; Connectors.Add(cRight); cBottom = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Bottom), Model); cBottom.Name = "Bottom connector"; cBottom.Parent = this; Connectors.Add(cBottom); cLeft = new Connector(new Point(Rectangle.Left, (int)(Rectangle.Top + Rectangle.Height / 2)), Model); cLeft.Name = "Left connector"; cLeft.Parent = this; Connectors.Add(cLeft); LabelMaterial label = new LabelMaterial(); label.Text = "Complex rectangle example"; label.Transform(new Rectangle(Rectangle.X + 10, Rectangle.Y + 10, Rectangle.Width - 20, Rectangle.Height - 30)); this.Children.Add(label); }
public DbConnector GetInstanceOfDbConnector() { var connector = new DbConnector(GetNewOpenConnectionByName()); Connectors.Add(connector); return(connector); }
/// <summary> /// 连接串口 /// </summary> /// <returns>是否连接成功</returns> public override bool Connect() { try { if (!Connectors.ContainsKey(_com)) { Connectors.Add(_com, new SerialPortLock { PortName = _com, BaudRate = _baudRate, Parity = _parity, StopBits = _stopBits, DataBits = _dataBits, ReadTimeout = _timeoutTime }); } if (!Linkers.ContainsKey(_slave)) { Linkers.Add(_slave, _com); } SerialPort.Open(); Log.Information("Com client {ConnectionToken} connect success", ConnectionToken); return(true); } catch (Exception e) { Log.Error(e, "Com client {ConnectionToken} connect error", ConnectionToken); return(false); } }
// ----------------------------------------------------------------- /// <summary> /// Initializes this instance. /// </summary> // ----------------------------------------------------------------- protected override void Initialize() { base.Initialize(); //the initial size Transform(0, 0, 200, 50); #region Connectors cTop = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Top), Model); cTop.Name = "Top connector"; cTop.Parent = this; Connectors.Add(cTop); cRight = new Connector(new Point(Rectangle.Right, (int)(Rectangle.Top + Rectangle.Height / 2)), Model); cRight.Name = "Right connector"; cRight.Parent = this; Connectors.Add(cRight); cBottom = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Bottom), Model); cBottom.Name = "Bottom connector"; cBottom.Parent = this; Connectors.Add(cBottom); cLeft = new Connector(new Point(Rectangle.Left, (int)(Rectangle.Top + Rectangle.Height / 2)), Model); cLeft.Name = "Left connector"; cLeft.Parent = this; Connectors.Add(cLeft); #endregion }
public static void LoadConnectors() { //var test = Assembly.GetExecutingAssembly().GetManifestResourceNames(); var connectorsXml = GetResourceText("Data.Primitive connectors.xml"); var xmlDoc = XDocument.Parse(connectorsXml); var connElems = xmlDoc.Descendants("Connector"); Connectors.Clear(); foreach (var connElem in connElems) { if (!connElem.TryReadAttribute("type", out ConnectorType connType)) { continue; } if (!connElem.TryReadAttribute("subtype", out int subType)) { continue; } //connElem.TryReadAttribute("gender", out string gender); var connInfo = new ConnectorInfo() { Type = connType, SubType = subType, Description = connElem.ReadAttribute("description", string.Empty), }; Connectors.Add(connInfo); } }
/// <summary> /// Deserialization constructor /// </summary> /// <param name="info"></param> /// <param name="context"></param> public ZNode(SerializationInfo info, StreamingContext context) : base(info, context) { Connectors.Clear(); this.centralConnector = info.GetValue("centralConnector", typeof(Connector)) as Connector; this.centralConnector.BelongsTo = this; Connectors.Add(centralConnector); }
public void CreateNewConnection() { // Create a new interNode that will be previewed as the SelectedObject var newInterNode = new InterNode() { Name = "InterNode" + (InterNodes.Count + 1), IsNew = true }; InterNodes.Add(newInterNode); SelectedObject = newInterNode; // Create a connector that will be referenced as interConnector and connect the PreviousObject with the new Internode var connector = new Connector() { Name = "Connector" + (Connectors.Count + 1), IsNew = true, }; Connectors.Add(connector); interConnector = connector; interConnector.Start = PreviousObject; // We only create a logic connection if it is starting from a Logic Element // Because if the PreviousObject is not a logic element, that means it is an interNode // and we're still building a connection. if (PreviousObject is LogicElement) { newConnection = new Connection(); Connections.Add(newConnection); newConnection.Start = PreviousObject as LogicElement; newConnection.Connectors.Add(connector); } }
//private void Port_OnMouseDown(object sender, MouseEventArgs e) //{ // this.IsSelected //} //改写Shape的InitEntity方法 //初始化对象的矩形坐标,设定画边框的画笔Pen和Shape的背景颜色ShapeColor protected override void InitEntity() { base.InitEntity(); Pen = new Pen(Color.FromArgb(167, 58, 95)); ShapeColor = Color.FromArgb(255, 253, 205); //this.Rectangle = new RectangleF(100, 100, 15, 15); //设定大小不可更改 this.IsResizable = false; Text = this.Port_ID; //MessageBox.Show(Text); //Font = new Font("宋体", 10); //鼠标点击响应 //this.OnMouseDown += new MouseEventHandler(this.Component_OnMouseDown); //双击图标修改文字 //OnMouseDown += SequenceShape_OnMouseDown; //创建连接点,名称“PortConnector” //Connector构造函数的第一个参数是Shape对象,代表的Connector对象依附的图形对象; //第二个参数是Connector的名字 //第三个参数表示是否允许Connector有多个连接 PortConnector = new Connector(this, "PortConnector", true); //将创建的连接点加入连接点集合 Connectors.Add(PortConnector); }
public bool AddNode(Node node) { bool added = false; if (node.ParentNetwork == this && !Nodes.Contains(node)) { added = true; Nodes.Add(node); if (node is OutputPipeNode && !Outputs.Contains(node)) { Outputs.Add((OutputPipeNode)node); } else if (node is InputPipeNode && !Inputs.Contains(node)) { Inputs.Add((InputPipeNode)node); } else if (node is ConnectorPipeNode && !Connectors.Contains(node)) { Connectors.Add((ConnectorPipeNode)node); } else if (node is PPMNode && Invis == null) { Invis = (PPMNode)node; } } else if (node.ParentNetwork != this) { //Printer.Info($"Tried to add {node.Print()} to N{ID}, but they dont match."); } return(added); }
public DrmResources(int fd) { var res = drmModeGetResources(fd); if (res == null) { throw new Win32Exception("drmModeGetResources failed"); } var crtcs = new drmModeCrtc[res->count_crtcs]; for (var c = 0; c < res->count_crtcs; c++) { var crtc = drmModeGetCrtc(fd, res->crtcs[c]); crtcs[c] = *crtc; drmModeFreeCrtc(crtc); } for (var c = 0; c < res->count_encoders; c++) { var enc = drmModeGetEncoder(fd, res->encoders[c]); Encoders[res->encoders[c]] = new DrmEncoder(*enc, crtcs); drmModeFreeEncoder(enc); } for (var c = 0; c < res->count_connectors; c++) { var conn = drmModeGetConnector(fd, res->connectors[c]); Connectors.Add(new DrmConnector(conn)); drmModeFreeConnector(conn); } }
private void Init() { m_leftConnector = new Connector(this, "Left", true); Connectors.Add(m_leftConnector); m_rightConnector = new Connector(this, "Right", true); Connectors.Add(m_rightConnector); }
void Connectors_ConnectorAdded(ConnectorModel c) { var viewModel = new ConnectorViewModel(this, c); if (Connectors.All(x => x.ConnectorModel != c)) { Connectors.Add(viewModel); } }
/// <summary> /// the ctor /// </summary> public YPlotter() : base() { Rectangle = new RectangleF(0, 0, plotWindowWidth, plotWindowHeight); IsResizable = false; inConnector = new Connector(this, "Incoming values", false); inConnector.ConnectorLocation = ConnectorLocation.West; Connectors.Add(inConnector); InitEntity(); }
public Node(NodeInfo info) : this() { this.Info = info; this.Tag = info.Tag; this.pSelfConnector.Tag = info.Tag; if (info.Header.NameChangeable) { this.pName.MouseDoubleClick += NameLabelDClick; } Binding bind = new Binding("NodeNameProperty"); bind.Source = info; bind.Mode = BindingMode.TwoWay; this.pName.SetBinding(Label.ContentProperty, bind); foreach (NodeInfo.SectionInfo sectInfo in info.Sections) { addSection(sectInfo); } info.Sections.CollectionChanged += (s, e) => { // adding happens only at the end of the list if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { addSection(e.NewItems[0] as NodeInfo.SectionInfo); } else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove) { removeSectionAt(e.OldStartingIndex); } RaiseEvent(new RoutedEventArgs(NodeSelectedEvent)); }; foreach (Connector c in pSectionsGrid.Children.OfType <Connector>().Union( pNameGrid.Children.OfType <Connector>())) { c.ParentNode = this; if (!Connectors.Contains(c)) //remove mb? { Connectors.Add(c); } } // context menu feature! if (info.Menu == null) { this.ContextMenu = new ContextMenu(); } else { this.ContextMenu = info.Menu; } pRect.Fill = new LinearGradientBrush(info.FillColor, Colors.LightGray, 90.0); }
/// <summary> /// Adds a connector /// </summary> /// <param name="connector">Connector to be added</param> public virtual void AddConnector(Connector connector) { if (connector == null) { throw new ArgumentNullException("Cannot add null connector"); } Connectors.Add(connector); OnConnectorAdded.SafeInvoke(this, new ConnectorAddedEventArgs(connector)); }
/// <summary> /// Initializes a new instance of the <see cref="T:TextLabel"/> class. /// </summary> public TextLabel() : base() { PaintStyle = ArtPallet.GetDefaultSolidPaintStyle(); Resizable = false; connector = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Bottom), Model); connector.Name = "Central connector"; connector.Parent = this; Connectors.Add(connector); }
protected LoopShape(SerializationInfo info, StreamingContext context) : base(info, context) { m_leftConnector = (Connector)info.GetValue("m_leftConnector", typeof(Connector)); m_leftConnector.BelongsTo = this; Connectors.Add(m_leftConnector); m_rightConnector = (Connector)info.GetValue("m_rightConnector", typeof(Connector)); m_rightConnector.BelongsTo = this; Connectors.Add(m_rightConnector); }
/// <summary> /// default constructor /// </summary> public HelloShape() : base() { //the base rectangle on which the shape's design is based Rectangle = new RectangleF(0, 0, 70, 20); //initialize the connector TopConnector = new Connector(this, "Top", true); TopConnector.ConnectorLocation = ConnectorLocation.North; Connectors.Add(TopConnector); //set to false if you donnot want the shape to be resizable IsResizable = true; }
// ----------------------------------------------------------------- /// <summary> /// Initializes this instance. /// </summary> // ----------------------------------------------------------------- protected override void Initialize() { base.Initialize(); PaintStyle = ArtPalette.GetDefaultSolidPaintStyle(); Resizable = false; connector = new Connector(new Point((int)(Rectangle.Left + Rectangle.Width / 2), Rectangle.Bottom), Model); connector.Name = "Central connector"; connector.Parent = this; Connectors.Add(connector); }
/// <summary> /// Constructor /// </summary> /// <param name="site"></param> public SimpleNode(IGraphSite site) : base(site) { //set the default size Rectangle = new RectangleF(0, 0, 70, 20); //set the connector leftConnector = new Connector(this, "Connector", true); leftConnector.ConnectorLocation = ConnectorLocation.West; Connectors.Add(leftConnector); //cannot be resized IsResizable = true; }
public TextBoxControlShape(IGraphSite site) : base(site) { //set the default size Rectangle = new RectangleF(0, 0, 70, 40); //set the connector leftConnector = new Connector(this, "Connector", true); leftConnector.ConnectorLocation = ConnectorLocation.West; Connectors.Add(leftConnector); //cannot be resized IsResizable = false; }
public void CreateNewConnector() { var connector = new Connector() { Name = "Connector" + (Connectors.Count + 1), IsNew = true, }; Connectors.Add(connector); SelectedObject = connector; }
void addSection(NodeInfo.SectionInfo sectInfo) { int numRows = pSectionsGrid.RowDefinitions.Count; pSectionsGrid.RowDefinitions.Add(new RowDefinition()); if (sectInfo.IsInput) { Connector conn = new Connector(Connector.ConnectorMode.Input, sectInfo.Data); conn.SetValue(Grid.RowProperty, numRows); conn.SetValue(Grid.ColumnProperty, 0); pSectionsGrid.Children.Add(conn); if (sectInfo.InputValidation != null) { conn.ConnectionBeforeAdd += sectInfo.InputValidation; } if (sectInfo.InputAdded != null) { conn.InputAdded += sectInfo.InputAdded; } conn.Tag = sectInfo.Data; sectInfo.Input = conn; conn.ParentNode = this; if (!Connectors.Contains(conn)) //remove mb? { Connectors.Add(conn); } } if (sectInfo.IsOutput) { Connector conn = new Connector(Connector.ConnectorMode.Output, sectInfo.Data); conn.SetValue(Grid.RowProperty, numRows); conn.SetValue(Grid.ColumnProperty, 2); pSectionsGrid.Children.Add(conn); if (sectInfo.OutputAdded != null) { conn.OutputAdded += sectInfo.OutputAdded; } conn.Tag = sectInfo.Data; sectInfo.Output = conn; conn.ParentNode = this; if (!Connectors.Contains(conn)) //remove mb? { Connectors.Add(conn); } } if (sectInfo.UIPanel != null) { sectInfo.UIPanel.SetValue(Grid.RowProperty, numRows); sectInfo.UIPanel.SetValue(Grid.ColumnProperty, 1); pSectionsGrid.Children.Add(sectInfo.UIPanel); } }
public void AddConnector(String name, Enums.ConnectorType type, String[] directions) { foreach (String dir in directions) { if (!ShieldBase.IsConnectable(dir, type)) { throw new Exception("El tipo de conector no es compatible en esa direccion del micro"); } } Connectors.Add(new Connector(name, type, directions)); }
/// <summary> /// This is the default constructor of the class. /// </summary> public ZNode() : base() { //set the default size Rectangle = new RectangleF(0, 0, 30, 30); //set the centralConnector centralConnector = new Connector(this, "Connector", true); centralConnector.ConnectorLocation = ConnectorLocation.Omni; Connectors.Add(centralConnector); //cannot be resized IsResizable = false; ShapeColor = Color.DarkSlateBlue; }