Наследование: RectangleElement, IControllable
Пример #1
0
        private void StartAddLink(ConnectorElement connStart, Point mousePoint)
        {
            if (document.Action == DesignerAction.Connect)
            {
                this.connStart = connStart;
                this.connEnd   = new ConnectorElement(connStart.ParentElement);

                connEnd.Location = connStart.Location;
                IMoveController ctrl = (IMoveController)((IControllable)connEnd).GetController();
                ctrl.Start(mousePoint);

                isAddLink = true;

                switch (document.LinkType)
                {
                case (LinkType.Straight):
                    linkLine = new StraightLinkElement(connStart, connEnd);
                    break;

                case (LinkType.RightAngle):
                    linkLine = new RightAngleLinkElement(connStart, connEnd);
                    break;
                }
                linkLine.Visible     = true;
                linkLine.BorderColor = Color.FromArgb(150, Color.Black);
                linkLine.BorderWidth = 1;

                this.Invalidate(linkLine, true);

                OnElementConnecting(new ElementConnectEventArgs(connStart.ParentElement, null, linkLine));
            }
        }
Пример #2
0
        public BaseLinkElement AddLink(ConnectorElement connStart, ConnectorElement connEnd)
        {
            if (CanAddLink(connStart, connEnd))
            {
                BaseLinkElement lnk;

                if (linkType == LinkType.Straight)
                {
                    lnk = new StraightLinkElement(connStart, connEnd);
                }
                else                 // (linkType == LinkType.RightAngle)
                {
                    lnk = new RightAngleLinkElement(connStart, connEnd);
                }

                elements.Add(lnk);
                lnk.AppearanceChanged += new EventHandler(element_AppearanceChanged);
                OnAppearancePropertyChanged(new EventArgs());
                return(lnk);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        private void EndAddLink()
        {
            if (connEnd != linkLine.Connector2)
            {
                linkLine.Connector1.RemoveLink(linkLine);
                linkLine = document.AddLink(linkLine.Connector1, linkLine.Connector2);

                if (ElementsWillLink != null)
                {
                    var args = new ElementsLinkedArgs {
                        Connector1 = linkLine.Connector1, Connector2 = linkLine.Connector2, Element1 = linkLine.Connector1.ParentElement, Element2 = linkLine.Connector2.ParentElement, NewLink = linkLine
                    };

                    ElementsWillLink(this, args);

                    if (args.Cancel)
                    {
                        document.DeleteLink(linkLine);
                        connStart = null;
                        connEnd   = null;
                        linkLine  = null;
                        return;
                    }
                }

                OnElementConnected(new ElementConnectEventArgs(linkLine.Connector1.ParentElement, linkLine.Connector2.ParentElement, linkLine));
            }

            connStart = null;
            connEnd   = null;
            linkLine  = null;
        }
Пример #4
0
 protected virtual void InitConnectors()
 {
     Connectors[0] = new ConnectorElement(this);
     Connectors[1] = new ConnectorElement(this);
     Connectors[2] = new ConnectorElement(this);
     Connectors[3] = new ConnectorElement(this);
     UpdateConnectorsPosition();
 }
Пример #5
0
 protected void InitConnectors()
 {
     connects[0] = new ConnectorElement(this);
     connects[1] = new ConnectorElement(this);
     //connects[2] = new ConnectorElement(this);
     //connects[3] = new ConnectorElement(this);
     UpdateConnectorsPosition();
 }
Пример #6
0
		internal BaseLinkElement(ConnectorElement conn1, ConnectorElement conn2): base()
		{
			borderWidth = 1;
			borderColor = Color.Black;

			connector1 = conn1;
			connector2 = conn2;

			connector1.AddLink(this);
			connector2.AddLink(this);
		}
Пример #7
0
        internal BaseLinkElement(ConnectorElement conn1, ConnectorElement conn2) : base()
        {
            borderWidth = 1;
            borderColor = Color.Black;

            connector1 = conn1;
            connector2 = conn2;

            connector1.AddLink(this);
            connector2.AddLink(this);
        }
Пример #8
0
        private void EndAddLink()
        {
            if (connEnd != linkLine.Connector2)
            {
                linkLine.Connector1.RemoveLink(linkLine);
                linkLine = document.AddLink(linkLine.Connector1, linkLine.Connector2);
                OnElementConnected(new ElementConnectEventArgs(linkLine.Connector1.ParentElement, linkLine.Connector2.ParentElement, linkLine));
            }

            connStart = null;
            connEnd   = null;
            linkLine  = null;
        }
		public RightAngleLinkElement(ConnectorElement conn1, ConnectorElement conn2): base(conn1, conn2)
		{
			needCalcLink = true;
			InitConnectors(conn1, conn2);
			foreach(LineElement l in lines)
			{
				l.StartCap = LineCap.Round;
				l.EndCap = LineCap.Round;
			}
			startCap = LineCap.Round;
			endCap = LineCap.Round;

			label.PositionBySite(lines[1]);
		}
Пример #10
0
        public RightAngleLinkElement(ConnectorElement conn1, ConnectorElement conn2) : base(conn1, conn2)
        {
            needCalcLink = true;
            InitConnectors(conn1, conn2);
            foreach (LineElement l in lines)
            {
                l.StartCap = LineCap.Round;
                l.EndCap   = LineCap.Round;
            }
            startCap = LineCap.Round;
            endCap   = LineCap.Round;

            label.PositionBySite(lines[1]);
        }
Пример #11
0
        private void RestartInitValues()
        {
            // Reinitialize status
            moveAction = null;

            isMultiSelection = false;
            isAddSelection   = false;
            isAddLink        = false;

            changed = false;

            connStart = null;

            selectionArea.FillColor1  = SystemColors.Control;
            selectionArea.BorderColor = SystemColors.Control;
            selectionArea.Visible     = false;

            document.CalcWindow(true);
        }
Пример #12
0
        private void StartAddLink(ConnectorElement connStart, Point mousePoint)
        {
            if (document.Action == DesignerAction.Connect)
            {
                this.connStart = connStart;
                this.connEnd   = new ConnectorElement(connStart.ParentElement);

                connEnd.Location = connStart.Location;
                IMoveController ctrl = (IMoveController)((IControllable)connEnd).GetController();
                ctrl.Start(mousePoint);

                isAddLink = true;

                linkLine = CreateElementInstance(connStart, connEnd);

                this.Invalidate(linkLine, true);

                OnElementConnecting(new ElementConnectEventArgs(connStart.ParentElement, null, linkLine));
            }
        }
Пример #13
0
		public BaseLinkElement AddLink(ConnectorElement connStart, ConnectorElement connEnd)
		{
			if (CanAddLink(connStart, connEnd))
			{
				BaseLinkElement lnk;
				
				if (linkType == LinkType.Straight)
					lnk = new StraightLinkElement(connStart, connEnd);
				else // (linkType == LinkType.RightAngle)
					lnk = new RightAngleLinkElement(connStart, connEnd);

				elements.Add(lnk);
				lnk.AppearanceChanged +=new EventHandler(element_AppearanceChanged);
				OnAppearancePropertyChanged(new EventArgs());
				return lnk;
			}
			else
			{
				return null;
			}
		}
Пример #14
0
        protected virtual BaseLinkElement CreateElementInstance(ConnectorElement connStart, ConnectorElement connEnd)
        {
            BaseLinkElement linkLine;

            switch (document.LinkType)
            {
            default:
            case (LinkType.Straight):
                linkLine = new StraightLinkElement(connStart, connEnd);
                break;

            case (LinkType.RightAngle):
                linkLine = new RightAngleLinkElement(connStart, connEnd);
                break;
            }
            linkLine.Visible     = true;
            linkLine.BorderColor = Color.FromArgb(150, Color.Black);
            linkLine.BorderWidth = 1;

            return(linkLine);
        }
Пример #15
0
        private void InitConnectors(ConnectorElement conn1, ConnectorElement conn2)
        {
            conn1Dir = conn1.GetDirection();
            conn2Dir = conn2.GetDirection();

            if ((conn1Dir == CardinalDirection.North) || (conn1Dir == CardinalDirection.South))
            {
                orientation = Orientation.Vertical;
            }
            else
            {
                orientation = Orientation.Horizontal;
            }

            if (
                (
                    ((conn1Dir == CardinalDirection.North) || (conn1Dir == CardinalDirection.South)) &&
                    ((conn2Dir == CardinalDirection.East) || (conn2Dir == CardinalDirection.West)))
                ||
                (
                    ((conn1Dir == CardinalDirection.East) || (conn1Dir == CardinalDirection.West)) &&
                    ((conn2Dir == CardinalDirection.North) || (conn2Dir == CardinalDirection.South)))
                )
            {
                lines    = new LineElement[2];
                lines[0] = new LineElement(0, 0, 0, 0);
                lines[1] = new LineElement(0, 0, 0, 0);
            }
            else
            {
                lines    = new LineElement[3];
                lines[0] = new LineElement(0, 0, 0, 0);
                lines[1] = new LineElement(0, 0, 0, 0);
                lines[2] = new LineElement(0, 0, 0, 0);
            }

            CalcLinkFirtTime();
            CalcLink();
            RestartProps();
        }
Пример #16
0
        public BaseLinkElement AddLink(ConnectorElement connStart, ConnectorElement connEnd)
        {
            if (CanAddLink(connStart, connEnd))
            {
                BaseLinkElement lnk;

                if (linkType == LinkType.Straight)
                {
                    lnk = new StraightLinkElement(connStart, connEnd);
                }
                else                 // (linkType == LinkType.RightAngle)
                {
                    lnk = new RightAngleLinkElement(connStart, connEnd);
                }

                AddLink(lnk);
                return(lnk);
            }
            else
            {
                return(null);
            }
        }
Пример #17
0
		private void EndAddLink()
		{
			if (connEnd != linkLine.Connector2)
			{
				linkLine.Connector1.RemoveLink(linkLine);
				linkLine = document.AddLink(linkLine.Connector1, linkLine.Connector2);
				OnElementConnected(new ElementConnectEventArgs(linkLine.Connector1.ParentElement, linkLine.Connector2.ParentElement, linkLine));
			}

			connStart = null;
			connEnd = null;
			linkLine = null;
		}
Пример #18
0
		public ConnectorController(ConnectorElement element): base(element)
		{}
 public ConnectorController(ConnectorElement element) : base(element)
 {
 }
        public AdvancedStraightLinkElement(BaseElement StartElement, ConnectorElement conn1, BaseElement EndElement, ConnectorElement conn2)
            : base(conn1, conn2)
		{
			this.StartElement = StartElement;
            this.EndElement = EndElement;
		}
		private void InitConnectors(ConnectorElement conn1, ConnectorElement conn2)
		{
			conn1Dir = conn1.GetDirection();
			conn2Dir = conn2.GetDirection();

			if ((conn1Dir == CardinalDirection.North) || (conn1Dir == CardinalDirection.South))
				orientation = Orientation.Vertical;
			else
				orientation = Orientation.Horizontal;

			if (
				(
				((conn1Dir == CardinalDirection.North) || (conn1Dir == CardinalDirection.South))
				&& ((conn2Dir == CardinalDirection.East) || (conn2Dir == CardinalDirection.West)))
				||
				(
				((conn1Dir == CardinalDirection.East) || (conn1Dir == CardinalDirection.West))
				&& ((conn2Dir == CardinalDirection.North) || (conn2Dir == CardinalDirection.South)))
				)
			{
				lines = new LineElement[2];
				lines[0] = new LineElement(0, 0, 0, 0);
				lines[1] = new LineElement(0, 0, 0, 0);
			}
			else	
			{
				lines = new LineElement[3];
				lines[0] = new LineElement(0, 0, 0, 0);
				lines[1] = new LineElement(0, 0, 0, 0);
				lines[2] = new LineElement(0, 0, 0, 0);
			}
			
			CalcLinkFirtTime();
			CalcLink();
			RestartProps();
		}
Пример #22
0
 internal bool CanAddLink(ConnectorElement connStart, ConnectorElement connEnd)
 {
     return((connStart != connEnd) && (connStart.ParentElement != connEnd.ParentElement));
 }
 internal StraightLinkElement(ConnectorElement conn1, ConnectorElement conn2) : base(conn1, conn2)
 {
     label.PositionBySite(line1);
 }
Пример #24
0
		protected void InitConnectors()
		{
			connects[0] = new ConnectorElement(this);
			connects[1] = new ConnectorElement(this);
			connects[2] = new ConnectorElement(this);
			connects[3] = new ConnectorElement(this);
            connects[4] = new ConnectorElement(this);
            connects[5] = new ConnectorElement(this);
			UpdateConnectorsPosition();

		}
Пример #25
0
        protected virtual bool CanAddLink(ConnectorElement start, BaseElement end)
        {
            var connector = end as ConnectorElement;

            return(connector != null && document.CanAddLink(start, connector));
        }
Пример #26
0
		internal bool CanAddLink(ConnectorElement connStart, ConnectorElement connEnd)
		{
			return ((connStart != connEnd) && (connStart.ParentElement != connEnd.ParentElement));
		}
Пример #27
0
		private void RestartInitValues()
		{
			
			// Reinitialize status
			moveAction = null;

			isMultiSelection = false;
			isAddSelection = false;
			isAddLink = false;

			changed = false;

			connStart = null;
			
			selectionArea.FillColor1 = SystemColors.Control;
			selectionArea.BorderColor = SystemColors.Control;
			selectionArea.Visible = false;

			document.CalcWindow(true);
		}
Пример #28
0
		internal StraightLinkElement(ConnectorElement conn1, ConnectorElement conn2): base(conn1, conn2)
		{
			label.PositionBySite(line1);
		}
Пример #29
0
		private void StartAddLink(ConnectorElement connStart, Point mousePoint)
		{
			if (document.Action == DesignerAction.Connect)
			{
				this.connStart = connStart;
				this.connEnd = new ConnectorElement(connStart.ParentElement);

				connEnd.Location = connStart.Location;
				IMoveController ctrl = (IMoveController) ((IControllable) connEnd).GetController();
				ctrl.Start(mousePoint);

				isAddLink = true;
				
				switch(document.LinkType)
				{
					case (LinkType.Straight):
						linkLine = new StraightLinkElement(connStart, connEnd);
						break;
					case (LinkType.RightAngle):
						linkLine = new RightAngleLinkElement(connStart, connEnd);
						break;
				}
				linkLine.Visible = true;
				linkLine.BorderColor = Color.FromArgb(150, Color.Black);
				linkLine.BorderWidth = 1;
				
				this.Invalidate(linkLine, true);
				
				OnElementConnecting(new ElementConnectEventArgs(connStart.ParentElement, null, linkLine));
			}
		}
 public AdvancedStraightLinkElement(BaseElement StartElement, ConnectorElement conn1, BaseElement EndElement, ConnectorElement conn2)
     : base(conn1, conn2)
 {
     this.StartElement = StartElement;
     this.EndElement   = EndElement;
 }