示例#1
0
        /// <summary>
        /// This method executes the insert operation after the insertion position has been set
        /// </summary>
        public void Do()
        {
            if (!GraphDiagram.ValidateCopy(this.selectLayer.Elements))
            {
                MowayMessageBox.Show(CutMessages.CUT_START, CutMessages.CUT, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Cancel();
                return;
            }
            //The items to be copied are loaded
            List <GraphElement> elementsToCut = GraphDiagram.GetElementsToCopy(this.selectLayer);
            List <GraphElement> cloneElements = GraphDiagram.CloneElements(elementsToCut);

            GraphManager.Clipboard.SetElements(cloneElements);

            this.elementsToDelete = GraphDiagram.GetElementsToDelete(this.selectLayer);
            GraphDiagram.DeleteElements(this.diagramLayer, this.diagram, this.elementsToDelete);
            //Cleans and hides the selection layer
            this.selectLayer.ClearAndHide();
            //Updates the diagram layer
            this.diagramLayer.UpdateSurface();
            if (this.DiagramChanged != null)
            {
                this.DiagramChanged(this, new EventArgs());
            }
            if (this.ElementSelectedChanged != null)
            {
                this.ElementSelectedChanged(this, new EventArgs());
            }
            //Launch Event of operation completed
            if (this.OperationFinished != null)
            {
                this.OperationFinished(this, new OperationEventArgs(Operation.Cut));
            }
        }
示例#2
0
 /// <summary>
 /// Selects the item sent as a parameter
 /// </summary>
 /// <param name="element">Item to select</param>
 private void SelectElement(GraphElement element)
 {
     //The item is selected
     element.Selected = true;
     //The element is loaded into the temporary layer
     this.selectLayer.AddElement(element);
     if (GraphDiagram.ValidateCopy(this.selectLayer.Elements))
     {
         this.miCopy.Enabled = true;
         this.miCut.Enabled  = true;
     }
     else
     {
         if (this.OperationDisabled != null)
         {
             this.OperationDisabled(this, new OperationEventArgs(Operation.Copy));
             this.OperationDisabled(this, new OperationEventArgs(Operation.Cut));
         }
         this.miCopy.Enabled = false;
         this.miCut.Enabled  = false;
     }
     if (GraphDiagram.ValidateDelete(this.selectLayer.Elements))
     {
         this.miRemove.Enabled = true;
     }
     else
     {
         if (this.OperationDisabled != null)
         {
             this.OperationDisabled(this, new OperationEventArgs(Operation.Delete));
         }
         this.miRemove.Enabled = false;
     }
     if (GraphDiagram.ValidateSettings(this.selectLayer.Elements))
     {
         this.miSettings.Enabled = true;
     }
     else
     {
         if (this.OperationDisabled != null)
         {
             this.OperationDisabled(this, new OperationEventArgs(Operation.Settings));
         }
         this.miSettings.Enabled = false;
     }
 }
示例#3
0
        /// <summary>
        /// This method executes the insert operation after the insertion position has been set
        /// </summary>
        public void Do()
        {
            if (!GraphDiagram.ValidateCopy(this.selectLayer.Elements))
            {
                MowayMessageBox.Show(CopyMessages.COPY_START, CopyMessages.COPY, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Cancel();
                return;
            }
            //The items to be copied are loaded
            List <GraphElement> elementsToCopy = GraphDiagram.GetElementsToCopy(this.selectLayer);
            List <GraphElement> cloneElements  = GraphDiagram.CloneElements(elementsToCopy);

            GraphManager.Clipboard.SetElements(cloneElements);
            //Launch Event of operation completed
            if (this.OperationFinished != null)
            {
                this.OperationFinished(this, new OperationEventArgs(Operation.Copy));
            }
        }
示例#4
0
        public void MouseUp(MouseEventArgs e)
        {
            //When the left mouse button is released...
            if (e.Button == MouseButtons.Left)
            {
                //You get the upper left point of the selection box and the size
                Point location = new Point(Math.Min(this.initialPoint.X, e.X), Math.Min(this.initialPoint.Y, e.Y));
                Size  size     = new Size(Math.Abs(e.X - this.initialPoint.X), Math.Abs(e.Y - this.initialPoint.Y));
                //A Rectangle object is created that contains the two informations
                Rectangle rectangle = new Rectangle(location, size);

                //The items inside the selection box are selected
                this.SelectElements(rectangle);
                //The chart selection box is deleted
                this.tempLayer.ClearAndHide();
                this.selectionRectangle.Dispose();
                //The temporary layer is updated
                this.tempLayer.UpdateSurface();
                if (GraphDiagram.ValidateCopy(this.selectLayer.Elements))
                {
                }
                else
                {
                    if (this.OperationDisabled != null)
                    {
                        this.OperationDisabled(this, new OperationEventArgs(Operation.Copy));
                        this.OperationDisabled(this, new OperationEventArgs(Operation.Cut));
                    }
                }
                if (GraphDiagram.ValidateDelete(this.selectLayer.Elements))
                {
                }
                else
                {
                    if (this.OperationDisabled != null)
                    {
                        this.OperationDisabled(this, new OperationEventArgs(Operation.Delete));
                    }
                }
                if (GraphDiagram.ValidateSettings(this.selectLayer.Elements))
                {
                }
                else
                {
                    if (this.OperationDisabled != null)
                    {
                        this.OperationDisabled(this, new OperationEventArgs(Operation.Settings));
                    }
                }
                //Exception is thrown for change of operation depending on whether there are selected items
                if (this.selectLayer.Elements.Count == 0)
                {
                    this.selectLayer.Visible = false;
                    throw new OperationException(Operation.SelectRectangle, "Change to Nop Operation");
                }
                else
                {
                    if (this.ElementSelectedChanged != null)
                    {
                        this.ElementSelectedChanged(this, new EventArgs());
                    }
                    throw new OperationException(Operation.SelectRectangle, "Change to Select Operation");
                }
            }
        }