Пример #1
0
		internal void Remove(BaseElement element)
		{
			InnerList.Remove(element);

			needCalc = true;

		}
Пример #2
0
		public void AddElements(BaseElement[] els)
		{
			elements.EnabledCalc = false;
			foreach (BaseElement el in els)
			{
				this.AddElement(el);
			}
			elements.EnabledCalc = true;
		}
Пример #3
0
		public static IResizeController GetResizeController(BaseElement el)
		{
			if (el is IControllable)
			{
				IController ctrl = ((IControllable) el).GetController();
				return GetResizeController(ctrl);
			}
			else
				return null;
		}
Пример #4
0
		public static ILabelController GetLabelController(BaseElement el)
		{
			if ((el is IControllable) && (el is ILabelElement))
			{
				IController ctrl = ((IControllable) el).GetController();
				return GetLabelController(ctrl);
			}
			else
				return null;
		}
Пример #5
0
		public static IMoveController GetMoveController(BaseElement el)
		{
			if (el is IControllable)
			{
				IController ctrl = ((IControllable) el).GetController();
				if (ctrl is IMoveController)
					return (IMoveController) ctrl;
				else
					return null;
			}
			else
				return null;
		}
		public RectangleController(BaseElement element)
		{
			el = element;

			//Create corners
			for(int i = 0; i < selectionCorner.Length; i++)
			{
				selectionCorner[i] = new RectangleElement(0, 0, selCornerSize * 2, selCornerSize * 2);
				selectionCorner[i].BorderColor = Color.Black;
				selectionCorner[i].FillColor1 = Color.White;
				selectionCorner[i].FillColor2 = Color.Empty;
			}
		}
Пример #7
0
		public void StartEdit(BaseElement el, TextBox textBox)
		{
			if (!(el is ILabelElement)) return;

			if (((ILabelElement) el).Label.ReadOnly) return;

			this.siteLabelElement = el;
			this.labelElement = ((ILabelElement) siteLabelElement).Label;
			this.labelTextBox = textBox;
			if (siteLabelElement is BaseLinkElement)
				this.direction = LabelEditDirection.Both;
			else
				this.direction = LabelEditDirection.UpDown;
			
			EditLabelAction.SetTextBoxLocation(siteLabelElement, labelTextBox);

			labelTextBox.AutoSize = true;
			labelTextBox.Show();
			labelTextBox.Text = labelElement.Text;
			labelTextBox.Font = labelElement.Font;
			labelTextBox.WordWrap = labelElement.Wrap;
			
			labelElement.Invalidate();
			
			switch(labelElement.Alignment)
			{
				case StringAlignment.Near:
					labelTextBox.TextAlign = HorizontalAlignment.Left;
					break;
				case StringAlignment.Center:
					labelTextBox.TextAlign = HorizontalAlignment.Center;
					break;
				case StringAlignment.Far:
					labelTextBox.TextAlign = HorizontalAlignment.Right;
					break;
			}	

			labelTextBox.KeyPress += new KeyPressEventHandler(labelTextBox_KeyPress);
			labelTextBox.Focus();
			center.X = textBox.Location.X + (textBox.Size.Width / 2);
			center.Y = textBox.Location.Y + (textBox.Size.Height / 2);
		}
Пример #8
0
        public static void SetTextBoxLocation(BaseElement el, TextBox tb)
        {
            if (!(el is ILabelElement))
            {
                return;
            }

            LabelElement lab = ((ILabelElement)el).Label;

            el.Invalidate();
            lab.Invalidate();

            if (lab.Text.Length > 0)
            {
                tb.Location = lab.Location;
                tb.Size     = lab.Size;
            }
            else
            {
                string tmpText = "XXXXXXX";
                Size   sizeTmp = DiagramUtil.MeasureString(tmpText, lab.Font, lab.Size.Width, lab.Format);

                if (el is BaseLinkElement)
                {
                    tb.Size     = sizeTmp;
                    tb.Location = new Point(el.Location.X + (el.Size.Width / 2) - (sizeTmp.Width / 2),
                                            el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
                }
                else
                {
                    sizeTmp.Width = el.Size.Width;
                    tb.Size       = sizeTmp;
                    tb.Location   = new Point(el.Location.X,
                                              el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
                }
            }

            SetTextBoxBorder(tb);
        }
Пример #9
0
        public new void Invalidate()
        {
            base.Invalidate();

            if (document.Elements.Count > 0)
            {
                for (int i = 0; i <= document.Elements.Count - 1; i++)
                {
                    BaseElement el = document.Elements[i];

                    Invalidate(el);

                    if (el is ILabelElement)
                    {
                        Invalidate(((ILabelElement)el).Label);
                    }
                }
            }

            //if ((moveAction != null) && (moveAction.IsMoving))
            //	this.AutoScrollMinSize = new Size((int) ((document.Location.X + document.Size.Width) * document.Zoom), (int) ((document.Location.Y + document.Size.Height) * document.Zoom));
        }
Пример #10
0
        public static int GetInnerElementsCount(BaseElement el)
        {
            int ret = 0;

            if (el is ILabelElement)
            {
                ret++;
            }

            if (el is NodeElement)
            {
                NodeElement nel = (NodeElement)el;
                ret += nel.Connectors.Length;
            }

//			if (el is IContainer)
//			{
//				IContainer cel = (IContainer) el;
//				ret += cel.Elements.Count;
//			}

            return(ret);
        }
Пример #11
0
        private void StartSelectElements(BaseElement selectedElement, Point mousePoint)
        {
            // Vefiry if element is in selection
            if (!document.SelectedElements.Contains(selectedElement))
            {
                //Clear selection and add new element to selection
                document.ClearSelection();
                document.SelectElement(selectedElement);
            }

            changed = false;


            moveAction = new MoveAction();
            OnElementMovingDelegate onElementMovingDelegate = new OnElementMovingDelegate(OnElementMoving);

            moveAction.Start(mousePoint, document, onElementMovingDelegate);


            // Get Controllers
            controllers = new IController[document.SelectedElements.Count];
            for (int i = document.SelectedElements.Count - 1; i >= 0; i--)
            {
                if (document.SelectedElements[i] is IControllable)
                {
                    // Get General Controller
                    controllers[i] = ((IControllable)document.SelectedElements[i]).GetController();
                }
                else
                {
                    controllers[i] = null;
                }
            }

            resizeAction = new ResizeAction();
            resizeAction.Select(document);
        }
Пример #12
0
        internal void CalcWindowSize(BaseElement element)
        {
            if (!enabledCalc)
            {
                return;
            }

            int val;

            Point elementLocation = element.Location;
            Size  elementSize     = element.Size;

            val = (elementLocation.X + elementSize.Width) - location.X;
            if (val > size.Width)
            {
                size.Width = val;
            }

            val = (elementLocation.Y + elementSize.Height) - location.Y;
            if (val > size.Height)
            {
                size.Height = val;
            }
        }
Пример #13
0
		internal void PositionBySite(BaseElement site)
		{
			Point newLocation = Point.Empty;

			Point siteLocation = site.Location;
			Size siteSize = site.Size;
			Size thisSize = this.Size;
			
			newLocation.X = (siteLocation.X + (siteSize.Width / 2)) - (thisSize.Width / 2);
			newLocation.Y = (siteLocation.Y + (siteSize.Height / 2)) - (thisSize.Height / 2);

			this.Location = newLocation;
		}
Пример #14
0
        public void DeleteElement(Point p)
        {
            BaseElement selectedElement = FindElement(p);

            DeleteElement(selectedElement);
        }
Пример #15
0
        public BaseElement FindElement(string name)
        {
            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)
                    {
                        continue;
                    }

                    //Find element in a Connector array
                    if (el is NodeElement)
                    {
                        NodeElement nel = (NodeElement)el;
                        if (el.Name == name)
                        {
                            return(el);
                        }
                        foreach (ConnectorElement cel in nel.Connectors)
                        {
                            if (cel.Name == name)
                            {
                                return(cel);
                            }
                        }
                    }

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

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

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

                    if (el.Name == name)
                    {
                        return(el);
                    }
                }
            }
            return(null);
        }
		public CommentBoxController(BaseElement element): base(element) {}
Пример #17
0
        protected virtual bool CanAddLink(ConnectorElement start, BaseElement end)
        {
            var connector = end as ConnectorElement;

            return(connector != null && document.CanAddLink(start, connector));
        }
Пример #18
0
		private void DeleteElement(Point mousePoint)
		{
			document.DeleteElement(mousePoint);
			selectedElement = null;
			document.Action = DesignerAction.Select;		
		}
Пример #19
0
		public bool Contains(BaseElement element)
		{
			return InnerList.Contains(element);
		}
Пример #20
0
		public void DeleteElement(BaseElement el)
		{
			if ((el != null) && !(el is ConnectorElement))
			{
				//Delete link
				if (el is BaseLinkElement)
				{
					BaseLinkElement lnk = (BaseLinkElement) el;
					DeleteLink(lnk);
					return;
				}

				//Delete node
				if (el is NodeElement)
				{
					NodeElement conn = ((NodeElement) el);
					foreach (ConnectorElement elconn in conn.Connectors)
					{
						BaseLinkElement lnk;
						for (int i = elconn.Links.Count - 1; i>=0; i--)
						{
							lnk = (BaseLinkElement) elconn.Links[i];
							DeleteLink(lnk);
						}
					}
					
					if (selectedNodes.Contains(el))
						selectedNodes.Remove(el);
				}

				if (SelectedElements.Contains(el))
					selectedElements.Remove(el);

				elements.Remove(el);
				
				OnAppearancePropertyChanged(new EventArgs());	
			}
			el = null;
		}
Пример #21
0
		public void SelectElement(BaseElement el)
		{
			selectedElements.Add(el);
			if (el is NodeElement)
			{
				selectedNodes.Add(el);
			}
			if (canFireEvents)
				OnElementSelection(this, new ElementSelectionEventArgs(selectedElements));
		}
Пример #22
0
 public ElementEventArgs(BaseElement el)
 {
     element = el;
 }
Пример #23
0
		public ElipseController(BaseElement element): base(element)
		{
		}
Пример #24
0
 public ElipseController(BaseElement element) : base(element)
 {
 }
Пример #25
0
		internal void Insert(int index, BaseElement element)
		{
			needCalc = true;
						
			InnerList.Insert(index, element);
		}
Пример #26
0
		public int IndexOf(BaseElement element)
		{
			return InnerList.IndexOf(element);
		}
Пример #27
0
 public bool Contains(BaseElement element)
 {
     return(InnerList.Contains(element));
 }
Пример #28
0
		public void SelectElements(BaseElement[] els)
		{
			selectedElements.EnabledCalc = false;
			selectedNodes.EnabledCalc = false;

			canFireEvents = false;
			
			try
			{
				foreach(BaseElement el in els)
				{
					SelectElement(el);
				}
			}
			finally
			{
				canFireEvents = true;
			}
			selectedElements.EnabledCalc = true;
			selectedNodes.EnabledCalc = true;
			
			OnElementSelection(this, new ElementSelectionEventArgs(selectedElements));
		}
Пример #29
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            Point mousePoint;

            //ShowSelectionCorner((document.Action==DesignerAction.Select));

            switch (document.Action)
            {
            // SELECT
            case DesignerAction.Connect:
            case DesignerAction.Select:
                if (e.Button == MouseButtons.Left)
                {
                    mousePoint = Gsc2Goc(new Point(e.X, e.Y));

                    //Verify resize action
                    StartResizeElement(mousePoint);
                    if ((resizeAction != null) && (resizeAction.IsResizing))
                    {
                        break;
                    }

                    // Search element by click
                    selectedElement = document.FindElement(mousePoint);

                    if (selectedElement != null)
                    {
                        //Events
                        ElementMouseEventArgs eventMouseDownArg = new ElementMouseEventArgs(selectedElement, e.X, e.Y);
                        OnElementMouseDown(eventMouseDownArg);

                        // Element selected
                        if (selectedElement is ConnectorElement)
                        {
                            StartAddLink((ConnectorElement)selectedElement, mousePoint);
                            selectedElement = null;
                        }
                        else
                        {
                            StartSelectElements(selectedElement, mousePoint);
                        }
                    }
                    else
                    {
                        // If click is on neutral area, clear selection
                        document.ClearSelection();
                        Point p = Gsc2Goc(new Point(e.X, e.Y));;
                        isMultiSelection       = true;
                        selectionArea.Visible  = true;
                        selectionArea.Location = p;
                        selectionArea.Size     = new Size(0, 0);

                        if (resizeAction != null)
                        {
                            resizeAction.ShowResizeCorner(false);
                        }
                    }
                    base.Invalidate();
                }
                break;

            // ADD
            case DesignerAction.Add:

                if (e.Button == MouseButtons.Left)
                {
                    mousePoint = Gsc2Goc(new Point(e.X, e.Y));
                    StartAddElement(mousePoint);
                }
                break;

            // DELETE
            case DesignerAction.Delete:
                if (e.Button == MouseButtons.Left)
                {
                    mousePoint = Gsc2Goc(new Point(e.X, e.Y));
                    DeleteElement(mousePoint);
                }
                break;
            }

            base.OnMouseDown(e);
        }
Пример #30
0
		public void MoveDownElement(BaseElement el)
		{
			int i = elements.IndexOf(el);
			if (i != 0)
			{
				elements.ChangeIndex(i, i - 1);
				OnAppearancePropertyChanged(new EventArgs());
			}
		}
Пример #31
0
		private void Invalidate(BaseElement el, bool force)
		{
			if (el == null) return;

			if ((force) || (el.IsInvalidated))
			{
				Rectangle invalidateRec = Goc2Gsc(el.invalidateRec);
				invalidateRec.Inflate(10, 10);
				base.Invalidate(invalidateRec);
			}			
		}
Пример #32
0
		public void BringToFrontElement(BaseElement el)
		{
			int i = elements.IndexOf(el);
			for (int x = i + 1; x <= elements.Count - 1; x++)
			{
				elements.ChangeIndex(i, x);
				i = x;
			}
			OnAppearancePropertyChanged(new EventArgs());
		}
Пример #33
0
		public static void SetTextBoxLocation(BaseElement el, TextBox tb)
		{
			if (!(el is ILabelElement)) return;

			LabelElement lab = ((ILabelElement) el).Label;

			el.Invalidate();
			lab.Invalidate();

			if (lab.Text.Length > 0)
			{
				tb.Location = lab.Location;
				tb.Size = lab.Size;
			}
			else
			{
				string tmpText = "XXXXXXX";
				Size sizeTmp = DiagramUtil.MeasureString(tmpText, lab.Font, lab.Size.Width, lab.Format);
				
				if (el is BaseLinkElement)
				{
					tb.Size = sizeTmp;
					tb.Location = new Point(el.Location.X + (el.Size.Width / 2) - (sizeTmp.Width / 2),
						el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
				}
				else
				{
					sizeTmp.Width = el.Size.Width;
					tb.Size = sizeTmp;
					tb.Location = new Point(el.Location.X,
						el.Location.Y + (el.Size.Height / 2) - (sizeTmp.Height / 2));
				}
			}

			SetTextBoxBorder(tb);
		}
Пример #34
0
		public void SendToBackElement(BaseElement el)
		{
			int i = elements.IndexOf(el);
			for (int x = i - 1; x >= 0; x--)
			{
				elements.ChangeIndex(i, x);
				i = x;
			}
			OnAppearancePropertyChanged(new EventArgs());
		}
Пример #35
0
 public int IndexOf(BaseElement element)
 {
     return(InnerList.IndexOf(element));
 }
Пример #36
0
		public void AddElement(BaseElement el)
		{
			elements.Add(el);
			el.AppearanceChanged +=new EventHandler(element_AppearanceChanged);
			OnAppearancePropertyChanged(new EventArgs());
		}
Пример #37
0
 public CommentBoxController(BaseElement element) : base(element)
 {
 }
Пример #38
0
		protected override void OnMouseMove(MouseEventArgs e)
		{

			if (e.Button == MouseButtons.None)
			{
				this.Cursor = Cursors.Arrow;
				Point mousePoint = Gsc2Goc(new Point(e.X, e.Y));

				if ((resizeAction != null)
					&& ((document.Action == DesignerAction.Select)				
						|| ((document.Action == DesignerAction.Connect)
							&& (resizeAction.IsResizingLink))))
				{
					this.Cursor = resizeAction.UpdateResizeCornerCursor(mousePoint);
				}
				
				if (document.Action == DesignerAction.Connect)
				{
					BaseElement mousePointerElementTMP = document.FindElement(mousePoint);
					if (mousePointerElement != mousePointerElementTMP)
					{
						if (mousePointerElementTMP is ConnectorElement)
						{
							mousePointerElement = mousePointerElementTMP;
							mousePointerElement.Invalidate();
							this.Invalidate(mousePointerElement, true);
						}
						else if (mousePointerElement != null)
						{
							mousePointerElement.Invalidate();
							this.Invalidate(mousePointerElement, true);
							mousePointerElement = null;
						}
						
					}
				}
				else
				{
					this.Invalidate(mousePointerElement, true);
					mousePointerElement = null;
				}
			}			

			if (e.Button == MouseButtons.Left)
			{
				Point dragPoint = Gsc2Goc(new Point(e.X, e.Y));

				if ((resizeAction != null) && (resizeAction.IsResizing))
				{
					resizeAction.Resize(dragPoint);
					this.Invalidate();					
				}

				if ((moveAction != null) && (moveAction.IsMoving))
				{
					moveAction.Move(dragPoint);
					this.Invalidate();
				}
				
				if ((isMultiSelection) || (isAddSelection))
				{
					Point p = Gsc2Goc(new Point(e.X, e.Y));
					selectionArea.Size = new Size (p.X - selectionArea.Location.X, p.Y - selectionArea.Location.Y);
					selectionArea.Invalidate();
					this.Invalidate(selectionArea, true);
				}
				
				if (isAddLink)
				{
					selectedElement = document.FindElement(dragPoint);
					if ((selectedElement is ConnectorElement) 
						&& (document.CanAddLink(connStart, (ConnectorElement) selectedElement)))
						linkLine.Connector2 = (ConnectorElement) selectedElement;
					else
						linkLine.Connector2 = connEnd;

					IMoveController ctrl = (IMoveController) ((IControllable) connEnd).GetController();
					ctrl.Move(dragPoint);
					
					//this.Invalidate(linkLine, true); //TODO
					base.Invalidate();
				}
			}

			base.OnMouseMove (e);
		}
Пример #39
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)
                    {
                        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);
                        }
                    }
                }
            }
            return(null);
        }
Пример #40
0
        internal virtual int Add(BaseElement element)
        {
            needCalc = true;

            return(InnerList.Add(element));
        }
Пример #41
0
 public void AddElement(BaseElement el)
 {
     elements.Add(el);
     el.AppearanceChanged += new EventHandler(element_AppearanceChanged);
     OnAppearancePropertyChanged(new EventArgs());
 }
Пример #42
0
 public ElementMouseEventArgs(BaseElement el, int x, int y) : base(el)
 {
     this.x = x;
     this.y = y;
 }
Пример #43
0
 private void DeleteElement(Point mousePoint)
 {
     document.DeleteElement(mousePoint);
     selectedElement = null;
     document.Action = DesignerAction.Select;
 }
 public AdvancedStraightLinkElement(BaseElement StartElement, ConnectorElement conn1, BaseElement EndElement, ConnectorElement conn2)
     : base(conn1, conn2)
 {
     this.StartElement = StartElement;
     this.EndElement   = EndElement;
 }
Пример #45
0
 private void Invalidate(BaseElement el)
 {
     this.Invalidate(el, false);
 }
Пример #46
0
        internal void Remove(BaseElement element)
        {
            InnerList.Remove(element);

            needCalc = true;
        }
Пример #47
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.None)
            {
                this.Cursor = Cursors.Arrow;
                Point mousePoint = Gsc2Goc(new Point(e.X, e.Y));

                if ((resizeAction != null) &&
                    ((document.Action == DesignerAction.Select) ||
                     ((document.Action == DesignerAction.Connect) &&
                      (resizeAction.IsResizingLink))))
                {
                    this.Cursor = resizeAction.UpdateResizeCornerCursor(mousePoint);
                }

                if (document.Action == DesignerAction.Connect)
                {
                    BaseElement mousePointerElementTMP = document.FindElement(mousePoint);
                    if (mousePointerElement != mousePointerElementTMP)
                    {
                        if (mousePointerElementTMP is ConnectorElement)
                        {
                            mousePointerElement = mousePointerElementTMP;
                            mousePointerElement.Invalidate();
                            this.Invalidate(mousePointerElement, true);
                        }
                        else if (mousePointerElement != null)
                        {
                            mousePointerElement.Invalidate();
                            this.Invalidate(mousePointerElement, true);
                            mousePointerElement = null;
                        }
                    }
                }
                else
                {
                    this.Invalidate(mousePointerElement, true);
                    mousePointerElement = null;
                }
            }

            if (e.Button == MouseButtons.Left)
            {
                Point dragPoint = Gsc2Goc(new Point(e.X, e.Y));

                if ((resizeAction != null) && (resizeAction.IsResizing))
                {
                    resizeAction.Resize(dragPoint);
                    this.Invalidate();
                }

                if ((moveAction != null) && (moveAction.IsMoving))
                {
                    moveAction.Move(dragPoint);
                    this.Invalidate();
                }

                if ((isMultiSelection) || (isAddSelection))
                {
                    Point p = Gsc2Goc(new Point(e.X, e.Y));
                    selectionArea.Size = new Size(p.X - selectionArea.Location.X, p.Y - selectionArea.Location.Y);
                    selectionArea.Invalidate();
                    this.Invalidate(selectionArea, true);
                }

                if (isAddLink)
                {
                    selectedElement = document.FindElement(dragPoint);
                    if ((selectedElement is ConnectorElement) &&
                        (document.CanAddLink(connStart, (ConnectorElement)selectedElement)))
                    {
                        linkLine.Connector2 = (ConnectorElement)selectedElement;
                    }
                    else
                    {
                        linkLine.Connector2 = connEnd;
                    }

                    IMoveController ctrl = (IMoveController)((IControllable)connEnd).GetController();
                    ctrl.Move(dragPoint);

                    //this.Invalidate(linkLine, true); //TODO
                    base.Invalidate();
                }
            }

            base.OnMouseMove(e);
        }
Пример #48
0
        internal void Insert(int index, BaseElement element)
        {
            needCalc = true;

            InnerList.Insert(index, element);
        }
Пример #49
0
		private void Invalidate(BaseElement el)
		{
			this.Invalidate(el, false);
		}
Пример #50
0
		public void EndEdit()
		{
			if (siteLabelElement == null) return;
			
			labelTextBox.KeyPress -= new KeyPressEventHandler(labelTextBox_KeyPress);

			ILabelController lblCtrl = ControllerHelper.GetLabelController(siteLabelElement);
			labelElement.Size = MeasureTextSize();
			labelElement.Text = labelTextBox.Text;
			labelTextBox.Hide();
			if (lblCtrl != null)
			{
				lblCtrl.SetLabelPosition();
			}
			else
			{
				labelElement.PositionBySite(siteLabelElement);
			}
			labelElement.Invalidate();
			siteLabelElement = null;
			labelElement = null;
			labelTextBox= null;
		}
Пример #51
0
		protected override void OnMouseDown(MouseEventArgs e)
		{
			Point mousePoint;

			//ShowSelectionCorner((document.Action==DesignerAction.Select));

			switch (document.Action)
			{
				// SELECT
				case DesignerAction.Connect:
				case DesignerAction.Select:
                    if (e.Button == MouseButtons.Left)
                    {
                        mousePoint = Gsc2Goc(new Point(e.X, e.Y));

                        //Verify resize action
                        StartResizeElement(mousePoint);
                        if ((resizeAction != null) && (resizeAction.IsResizing)) break;

                        //Verify label editing
                        if (isEditLabel)
                        {
                            EndEditLabel();
                        }

                        // Search element by click
                        selectedElement = document.FindElement(mousePoint);

                        if (selectedElement != null)
                        {
                            //Events
                            ElementMouseEventArgs eventMouseDownArg = new ElementMouseEventArgs(selectedElement, e.X, e.Y);
                            OnElementMouseDown(eventMouseDownArg);

                            //// Double-click to edit Label
                            //if ((e.Clicks == 2) && (selectedElement is ILabelElement))
                            //{
                            //    //selectedLabel = ((ILabelElement)selectedElement).Label;
                            //    StartEditLabel();
                            //    break;
                            //}

                            //// Element selected
                            //if (selectedElement is ConnectorElement)
                            //{
                            //    StartAddLink((ConnectorElement)selectedElement, mousePoint);
                            //    selectedElement = null;
                            //}
                            //else
                            if(selectedElement.GetType() != typeof(ConnectorElement))
                                StartSelectElements(selectedElement, mousePoint);
                        }
                        else
                        {
                            // If click is on neutral area, clear selection
                            document.ClearSelection();
                            Point p = Gsc2Goc(new Point(e.X, e.Y)); ;
                            isMultiSelection = true;
                            selectionArea.Visible = true;
                            selectionArea.Location = p;
                            selectionArea.Size = new Size(0, 0);

                            if (resizeAction != null)
                                resizeAction.ShowResizeCorner(false);
                        }
                        base.Invalidate();
                    }
                    else
                    {
                        mousePoint = Gsc2Goc(new Point(e.X, e.Y));

                        // Search element by click
                        selectedElement = document.FindElement(mousePoint);

                        if (selectedElement != null)
                        {
                            //Events
                            ElementMouseEventArgs eventMouseDownArg = new ElementMouseEventArgs(selectedElement, e.X, e.Y);
                            OnElementMouseDown(eventMouseDownArg);

                            StartSelectElements(selectedElement, mousePoint);
                        }
                        else
                        {
                            // If click is on neutral area, clear selection
                            document.ClearSelection();
                            Point p = Gsc2Goc(new Point(e.X, e.Y)); ;
                            isMultiSelection = true;
                            selectionArea.Visible = true;
                            selectionArea.Location = p;
                            selectionArea.Size = new Size(0, 0);

                            if (resizeAction != null)
                                resizeAction.ShowResizeCorner(false);
                        }
                        base.Invalidate();
                    }
					break;

				// ADD
				case DesignerAction.Add:

					if (e.Button == MouseButtons.Left)
					{
						mousePoint = Gsc2Goc(new Point(e.X, e.Y));
						StartAddElement(mousePoint);
					}
					break;

				// DELETE
				case DesignerAction.Delete:
					if (e.Button == MouseButtons.Left)
					{
						mousePoint = Gsc2Goc(new Point(e.X, e.Y));
						DeleteElement(mousePoint);
					}					
					break;
			}
			
			base.OnMouseDown (e);
		
		}
Пример #52
0
		internal virtual int Add(BaseElement element)
		{
			needCalc = true;

			return InnerList.Add(element);
		}
Пример #53
0
		private void StartSelectElements(BaseElement selectedElement, Point mousePoint)
		{
			// Vefiry if element is in selection
			if (!document.SelectedElements.Contains(selectedElement))
			{
				//Clear selection and add new element to selection
				document.ClearSelection();
				document.SelectElement(selectedElement);
			}

			changed = false;
			

			moveAction = new MoveAction();
			MoveAction.OnElementMovingDelegate onElementMovingDelegate = new Dalssoft.DiagramNet.MoveAction.OnElementMovingDelegate(OnElementMoving);
			moveAction.Start(mousePoint, document, onElementMovingDelegate);


			// Get Controllers
			controllers = new IController[document.SelectedElements.Count];
			for(int i = document.SelectedElements.Count - 1; i >= 0; i--)
			{
				if (document.SelectedElements[i] is IControllable)
				{
					// Get General Controller
					controllers[i] = ((IControllable) document.SelectedElements[i]).GetController();
				}
				else
				{
					controllers[i] = null;
				}
			}

			resizeAction = new ResizeAction();
			resizeAction.Select(document);
		}
Пример #54
0
		private bool NeedDrawElement(BaseElement el, Rectangle clippingRegion)
		{
			if (!el.Visible) return false;

			Rectangle elRectangle = el.GetUnsignedRectangle();
			elRectangle.Inflate(5, 5);
			return clippingRegion.IntersectsWith(elRectangle);
		}