Beispiel #1
0
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonUp(e);
            string drawingCode = "";

            if (Isrectangle && ContiniousDrawing)
            {
                ContiniousDrawing = false;
                Isrectangle       = false;
                this.Cursor       = Cursors.Arrow;
                drawingCode       = ("1," +
                                     rect.Margin.Left + "," +
                                     rect.Margin.Top + "," +
                                     rect.Width + "," +
                                     rect.Height);
                if (!double.IsNaN(rect.Height))
                {
                    CallDrawAPB(drawingCode, rect);
                }
                else
                {
                    EndDraw();
                }
            }
            else if (Isellipse && ContiniousDrawingellipse)
            {
                ContiniousDrawingellipse = false;
                Isellipse   = false;
                this.Cursor = Cursors.Arrow;
                drawingCode = ("3," +
                               ellipse.Margin.Left + "," +
                               ellipse.Margin.Top + "," +
                               ellipse.Width + "," +
                               ellipse.Height);
                if (!double.IsNaN(ellipse.Height))
                {
                    CallDrawAPB(drawingCode, ellipse);
                    EndDraw();
                }
                else
                {
                    EndDraw();
                }
            }

            else
            {
                if (selectdeobject != null)
                {
                    if ((!new Point(((FrameworkElement)selectdeobject).Margin.Left, ((FrameworkElement)selectdeobject).Margin.Top).Equals(previousMarginOfSelectedObject)))
                    {
                        if (e != null)
                        {
                            ChangeRepresentationObject ChangeRepresentationObjectOfResize = UnDoObject.MakeChangeRepresentationObjectForMove(previousMarginOfSelectedObject, (FrameworkElement)selectdeobject);
                            UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectOfResize);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void delete()
        {
            if (selectdeobject == null)
            {
                return;
            }
            if (selectdeobject is Image)
            {
                if (this.Children.Contains((UIElement)(((Image)selectdeobject).Parent)))
                {
                    UndoColorChangeForApbAndDevice();
                    ChangeRepresentationObject ChangeRepresentationObjectofDelete = UnDoObject.MakeChangeRepresentationObjectForDelete(((FrameworkElement)((Image)selectdeobject).Parent));
                    UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectofDelete);
                    this.Children.Remove(((UIElement)((Image)selectdeobject).Parent));

                    selectdeobject = null;
                }
            }
            else if (this.Children.Contains(((UIElement)selectdeobject)))
            {
                UndoColorChangeForApbAndDevice();

                ChangeRepresentationObject ChangeRepresentationObjectofDelete = UnDoObject.MakeChangeRepresentationObjectForDelete((FrameworkElement)selectdeobject);
                UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectofDelete);
                this.Children.Remove((UIElement)selectdeobject);

                selectdeobject = null;
            }
        }
        public void RedoPushInUnDoForDelete(FrameworkElement ApbOrDevice)
        {
            ChangeRepresentationObject dataobject = new ChangeRepresentationObject();

            dataobject.Action    = ActionType.Delete;
            dataobject.UiElement = ApbOrDevice;
            _RedoActionsCollection.Push(dataobject);
        }
        public ChangeRepresentationObject MakeChangeRepresentationObjectForDelete(FrameworkElement ApbOrDevice)
        {
            ChangeRepresentationObject dataobject = new ChangeRepresentationObject();

            dataobject.Action    = ActionType.Delete;
            dataobject.UiElement = ApbOrDevice;
            return(dataobject);
        }
 public void InsertObjectforUndoRedo(ChangeRepresentationObject dataobject)
 {
     _UndoActionsCollection.Push(dataobject);
     _RedoActionsCollection.Clear();
     if (EnableDisableUndoRedoFeature != null)
     {
         EnableDisableUndoRedoFeature(null, null);
     }
 }
Beispiel #6
0
        private void CallDrawAPB(string drawingCode, Shape oshape)
        {
            oshape.Tag = drawingCode;

            ChangeRepresentationObject ChangeRepresentationObjectforInsert = UnDoObject.MakeChangeRepresentationObjectForInsert(oshape);

            UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectforInsert);

            EndDraw();
        }
        public void RedoPushInUnDoForResize(Point margin, double width, double height, FrameworkElement UIelement)
        {
            ChangeRepresentationObject ResizeStruct = new ChangeRepresentationObject();

            ResizeStruct.Margin    = margin;
            ResizeStruct.height    = height;
            ResizeStruct.Width     = width;
            ResizeStruct.UiElement = UIelement;
            ResizeStruct.Action    = ActionType.Resize;
            _RedoActionsCollection.Push(ResizeStruct);
        }
        public void RedoPushInUnDoForMove(Point margin, FrameworkElement UIelement)
        {
            ChangeRepresentationObject MoveStruct = new ChangeRepresentationObject();

            MoveStruct.Action    = ActionType.Move;
            MoveStruct.Margin    = margin;
            MoveStruct.height    = 0;
            MoveStruct.Width     = 0;
            MoveStruct.UiElement = UIelement;
            _RedoActionsCollection.Push(MoveStruct);
        }
        public ChangeRepresentationObject MakeChangeRepresentationObjectForResize(Point margin, double width, double height, FrameworkElement UIelement)
        {
            ChangeRepresentationObject ResizeStruct = new ChangeRepresentationObject();

            ResizeStruct.Action    = ActionType.Resize;
            ResizeStruct.Margin    = margin;
            ResizeStruct.height    = height;
            ResizeStruct.Width     = width;
            ResizeStruct.UiElement = UIelement;
            return(ResizeStruct);
        }
        public ChangeRepresentationObject MakeChangeRepresentationObjectForMove(Point margin, FrameworkElement UIelement)
        {
            ChangeRepresentationObject MoveStruct = new ChangeRepresentationObject();

            MoveStruct.Action    = ActionType.Move;
            MoveStruct.Margin    = margin;
            MoveStruct.height    = 0;
            MoveStruct.Width     = 0;
            MoveStruct.UiElement = UIelement;
            return(MoveStruct);
        }
Beispiel #11
0
        void eleps_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            Thumb oEle = ((Thumb)sender);

            Shape  oRect      = (Shape)oEle.Tag;
            double tempwidth  = Math.Abs(oRect.ActualWidth - _PreviouWidth);
            double tempheight = Math.Abs(oRect.ActualHeight - _PreviouHeight);

            if (tempwidth > 6 || tempheight > 6)
            {
                ChangeRepresentationObject ChangeRepresentationObjectOfResize = UnDoObject.MakeChangeRepresentationObjectForResize(_PreviouMargin, _PreviouWidth, _PreviouHeight, (FrameworkElement)selectdeobject);
                UnDoObject.InsertObjectforUndoRedo(ChangeRepresentationObjectOfResize);
            }
        }
        public void Redo(int level)
        {
            for (int i = 1; i <= level; i++)
            {
                if (_RedoActionsCollection.Count == 0)
                {
                    return;
                }

                ChangeRepresentationObject Undostruct = _RedoActionsCollection.Pop();
                if (Undostruct.Action == ActionType.Delete)
                {
                    Container.Children.Remove(Undostruct.UiElement);
                    ChangeRepresentationObject ChangeRepresentationObjectForDelete = this.MakeChangeRepresentationObjectForDelete(Undostruct.UiElement);
                    _UndoActionsCollection.Push(ChangeRepresentationObjectForDelete);
                }
                else if (Undostruct.Action == ActionType.Insert)
                {
                    Container.Children.Add(Undostruct.UiElement);
                    ChangeRepresentationObject ChangeRepresentationObjectForInsert = this.MakeChangeRepresentationObjectForInsert(Undostruct.UiElement);
                    _UndoActionsCollection.Push(ChangeRepresentationObjectForInsert);
                }
                else if (Undostruct.Action == ActionType.Resize)
                {
                    Point previousMarginOfSelectedObject = new Point(((FrameworkElement)Undostruct.UiElement).Margin.Left, ((FrameworkElement)Undostruct.UiElement).Margin.Top);
                    ChangeRepresentationObject ChangeRepresentationObjectforResize = this.MakeChangeRepresentationObjectForResize(previousMarginOfSelectedObject, Undostruct.UiElement.Width, Undostruct.UiElement.Height, Undostruct.UiElement);
                    _UndoActionsCollection.Push(ChangeRepresentationObjectforResize);

                    Undostruct.UiElement.Margin = new Thickness(Undostruct.Margin.X, Undostruct.Margin.Y, 0, 0);
                    Undostruct.UiElement.Height = Undostruct.height;
                    Undostruct.UiElement.Width  = Undostruct.Width;
                }
                else if (Undostruct.Action == ActionType.Move)
                {
                    Point previousMarginOfSelectedObject = new Point(((FrameworkElement)Undostruct.UiElement).Margin.Left, ((FrameworkElement)Undostruct.UiElement).Margin.Top);
                    ChangeRepresentationObject ChangeRepresentationObjectForMove = this.MakeChangeRepresentationObjectForMove(previousMarginOfSelectedObject, Undostruct.UiElement);
                    _UndoActionsCollection.Push(ChangeRepresentationObjectForMove);
                    Undostruct.UiElement.Margin = new Thickness(Undostruct.Margin.X, Undostruct.Margin.Y, 0, 0);
                }
            }
            if (EnableDisableUndoRedoFeature != null)
            {
                EnableDisableUndoRedoFeature(null, null);
            }
        }