Exemplo n.º 1
0
        private void _backward()
        {
            List <object> deletedList = new List <object>();

            try
            {
                int    lastIndex = MyBoardObjects.Count - 1;
                object obj       = MyBoardObjects[lastIndex];
                if (obj is MySketch)
                {
                    MySketch tempSketch = obj as MySketch;
                    int      no_lines   = tempSketch.pointsSet.Count - 1;
                    ///<summary>To removet the no_lines number of lines</summary>
                    MyBoard.Children.RemoveRange(MyBoard.Children.Count - no_lines, no_lines - 1);
                    deletedList.Add(MyBoardObjects[lastIndex]);
                    MyBoardObjects.RemoveAt(lastIndex);
                }
                else
                {
                    deletedList.Add(MyBoardObjects[lastIndex]);
                    MyBoardObjects.RemoveAt(lastIndex);
                    MyBoard.Children.RemoveAt(MyBoard.Children.Count - 1);
                }
                deletedObjects.Push(deletedList);
            }
            catch (Exception) { }
        }
Exemplo n.º 2
0
        //private Point _start, _end;

        //List<object> MyBoardObjects;

        #endregion

        #region Window Load Events

        /*
         * private void MainWindow_Loaded(object sender, RoutedEventArgs e)
         * {
         *
         * }*/

        private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            foreach (var obj in MyBoardObjects)
            {
                if (obj is Line)
                {
                    Line line = obj as Line;
                    line.IsEnabled = false;
                }
                else if (obj is Rectangle)
                {
                    Rectangle temprect = obj as Rectangle;
                    temprect.IsEnabled = false;
                }
                else if (obj is Ellipse)
                {
                    Ellipse tempell = obj as Ellipse;
                    tempell.IsEnabled = false;
                }
                else if (obj is PointCollection)
                {
                    PointCollection pntc = obj as PointCollection;
                    pntc.Clear();
                }
            }
            MyBoardObjects.Clear();
            MyBoard.Children.Clear();
        }
Exemplo n.º 3
0
        private void _forward()
        {
            List <object> lastObj;

            if (deletedObjects.Count == 0)
            {
                return;
            }
            lastObj = deletedObjects.Pop();
            foreach (object obj in lastObj)
            {
                if (obj is MySketch)
                {
                    MySketch        mySketch = obj as MySketch;
                    PointCollection points   = mySketch.pointsSet;
                    try
                    {
                        addLines(points);
                        MyBoardObjects.Add(mySketch);
                    }
                    catch (Exception) { }
                }
                else if (obj is MyRectangle)
                {
                    MyRectangle myrect = obj as MyRectangle;
                    try
                    {
                        MyBoard.Children.Add(myrect.rect);
                        MyBoardObjects.Add(myrect);
                    }
                    catch (Exception) { }
                }
                else if (obj is MyLine)
                {
                    MyLine myline = obj as MyLine;
                    try
                    {
                        MyBoard.Children.Add(myline._line);
                        MyBoardObjects.Add(myline);
                    }
                    catch (Exception) { }
                }
                else if (obj is MyEllipse)
                {
                    MyEllipse myelli = obj as MyEllipse;
                    try
                    {
                        MyBoard.Children.Add(myelli.ellipse);
                        MyBoardObjects.Add(myelli);
                    }
                    catch (Exception) { }
                }
                else
                {
                }
            }
        }
Exemplo n.º 4
0
 private void btn_Clear_Click(object sender, RoutedEventArgs e)
 {
     MyBoard.Children.Clear();
     if (MyBoardObjects.Count > 0)
     {
         deletedObjects.Push(MyBoardObjects);
     }
     MyBoardObjects.Clear();
 }