Наследование: BaseElement
Пример #1
0
		internal ConnectorElement(NodeElement parent): base(new Rectangle(0, 0, 0, 0))
		{
			parentElement = parent;
			borderColor = Color.Black;
			fillColor1 = Color.LightGray;
			fillColor2 = Color.Empty;
		}
		public ElementConnectEventArgs(NodeElement node1, NodeElement node2, BaseLinkElement link)
		{
			this.node1 = node1;
			this.node2 = node2;
			this.link = link;
		}
Пример #3
0
		private void UpdateLinkPosition(NodeElement node)
		{
			foreach(ConnectorElement conn in node.Connectors)
			{
				foreach (BaseElement el in conn.Links)
				{
					BaseLinkElement lnk = (BaseLinkElement) el;
					IController ctrl = ((IControllable) lnk).GetController();
					if (ctrl is IMoveController)
					{
						IMoveController mctrl = (IMoveController) ctrl;
						if (!mctrl.IsMoving) lnk.NeedCalcLink = true;
					}
					else lnk.NeedCalcLink = true;

					if (lnk is ILabelElement)
					{
						LabelElement label = ((ILabelElement) lnk).Label;

						ILabelController lblCtrl = ControllerHelper.GetLabelController(lnk);
						if (lblCtrl != null)
							lblCtrl.SetLabelPosition();
						else
						{
							label.PositionBySite(lnk);
						}		
						label.Invalidate();
					}
				}
			}
		}
Пример #4
0
        public BaseElement FindElement(Point point)
        {
            BaseElement el;

            if ((elements != null) && (elements.Count > 0))
            {
                // First, find elements
                for (int i = elements.Count - 1; i >= 0; i--)
                {
                    el = elements[i];

                    if (el is BaseLinkElement || el is LabelElement || el is RectangleGroup)
                    {
                        continue;
                    }

                    //Find element in a Connector array
                    if (el is NodeElement)
                    {
                        NodeElement nel = (NodeElement)el;
                        foreach (ConnectorElement cel in nel.Connectors)
                        {
                            IController ctrl = ((IControllable)cel).GetController();
                            if (ctrl.HitTest(point))
                            {
                                return(cel);
                            }
                        }
                    }

                    //Find element in a Container Element
                    if (el is IContainer)
                    {
                        BaseElement inner = FindInnerElement((IContainer)el, point);
                        if (inner != null)
                        {
                            return(inner);
                        }
                    }

                    //Find element by hit test
                    if (el is IControllable)
                    {
                        IController ctrl = ((IControllable)el).GetController();
                        if (ctrl.HitTest(point))
                        {
                            return(el);
                        }
                    }
                }

                // Then, find links
                for (int i = elements.Count - 1; i >= 0; i--)
                {
                    el = elements[i];

                    if (!(el is BaseLinkElement))
                    {
                        continue;
                    }

                    if (el is IControllable)
                    {
                        IController ctrl = ((IControllable)el).GetController();
                        if (ctrl.HitTest(point))
                        {
                            return(el);
                        }
                    }
                }

                for (int i = elements.Count - 1; i >= 0; i--)
                {
                    el = elements[i];

                    if (!(el is RectangleGroup))
                    {
                        continue;
                    }

                    if (el is IControllable)
                    {
                        IController ctrl = ((IControllable)el).GetController();
                        if (ctrl.HitTest(point))
                        {
                            return(el);
                        }
                    }
                }
            }
            return(null);
        }