Inheritance: RectangleElement, IControllable
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 6
0
		internal BaseLinkElement(ConnectorElement conn1, ConnectorElement conn2): base()
		{
			borderWidth = 1;
			borderColor = Color.Black;

			connector1 = conn1;
			connector2 = conn2;

			connector1.AddLink(this);
			connector2.AddLink(this);
		}
Ejemplo n.º 7
0
        internal BaseLinkElement(ConnectorElement conn1, ConnectorElement conn2) : base()
        {
            borderWidth = 1;
            borderColor = Color.Black;

            connector1 = conn1;
            connector2 = conn2;

            connector1.AddLink(this);
            connector2.AddLink(this);
        }
Ejemplo n.º 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]);
		}
Ejemplo n.º 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]);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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;
			}
		}
Ejemplo n.º 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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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;
		}
Ejemplo n.º 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();
		}
Ejemplo n.º 22
0
 internal bool CanAddLink(ConnectorElement connStart, ConnectorElement connEnd)
 {
     return((connStart != connEnd) && (connStart.ParentElement != connEnd.ParentElement));
 }
Ejemplo n.º 23
0
 internal StraightLinkElement(ConnectorElement conn1, ConnectorElement conn2) : base(conn1, conn2)
 {
     label.PositionBySite(line1);
 }
Ejemplo n.º 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();

		}
Ejemplo n.º 25
0
        protected virtual bool CanAddLink(ConnectorElement start, BaseElement end)
        {
            var connector = end as ConnectorElement;

            return(connector != null && document.CanAddLink(start, connector));
        }
Ejemplo n.º 26
0
		internal bool CanAddLink(ConnectorElement connStart, ConnectorElement connEnd)
		{
			return ((connStart != connEnd) && (connStart.ParentElement != connEnd.ParentElement));
		}
Ejemplo n.º 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);
		}
Ejemplo n.º 28
0
		internal StraightLinkElement(ConnectorElement conn1, ConnectorElement conn2): base(conn1, conn2)
		{
			label.PositionBySite(line1);
		}
Ejemplo n.º 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;
 }