Exemple #1
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn private void MainView_MouseClick(object sender, MouseEventArgs e)
        ///
        /// \brief Event handler. Called by MainView for mouse click events
        ///
        /// \param sender Source of the event.
        /// \param e      Mouse event information.
        ///-------------------------------------------------------------------------------------------------

        private void MainView_MouseClick(object sender, MouseEventArgs e)
        {
            ArrayList array = History.GetInstance().historyArray;

            for (int i = 0; i <= History.GetInstance().Index; i++)
            {
                try
                {
                    ActionParameters_t actionParameters = ((MAction)array[i]).ActionParameters;
                    Resizeable         resizeable       = (Resizeable)actionParameters;
                    resizeable.ShowAsNotResizing();
                }
                catch (InvalidCastException)
                {
                    ;
                }
            }

            History.GetInstance().Update();

            for (int i = 0; i <= History.GetInstance().Index; i++)
            {
                if (array[i] is BackUpMAction)
                {
                    continue;
                }
                try
                {
                    ActionParameters_t actionParameters = ((MAction)array[i]).ActionParameters;
                    Shape      shape      = (Shape)actionParameters;
                    Resizeable resizeable = (Resizeable)shape;
                    if (shape.IsSelectMe(e.Location))
                    {
                        resizeable.ShowAsResizing();
                        break;
                    }
                    else
                    {
                        resizeable.ShowAsNotResizing();
                    }
                }
                catch (InvalidCastException)
                {
                    ;
                }
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Shape shape = new Shape();

            Console.WriteLine(shape);

            shape = new Shape("red", false);
            Console.WriteLine(shape);
            Circle circle = new Circle();

            Console.WriteLine(circle);

            circle = new Circle(3.5);
            Console.WriteLine(circle);
            circle = new Circle(3.5, "indigo", false);
            Console.WriteLine(circle);
            Square square = new Square();

            Console.WriteLine(square);

            square = new Square(2.3);
            Console.WriteLine(square);

            square = new Square(5.8, "yellow", true);
            Console.WriteLine(square);

            Resizeable[] resizeables = new Resizeable[3];
            resizeables[0] = new Circle();
            resizeables[1] = new Rectangle();
            resizeables[2] = new Square();
            Console.WriteLine("Truoc khi resize");
            for (int i = 0; i < resizeables.Length; i++)
            {
                Console.WriteLine(resizeables[i].ReSize(10));
            }
            Console.WriteLine("Sau khi resize");
            for (int i = 0; i < resizeables.Length; i++)
            {
                resizeables[i].Resize(10);
            }
        }