Пример #1
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);
		
		}
Пример #2
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);
        }