Ejemplo n.º 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)
        {
            whichToBeRotated = null;
            ArrayList array = History.GetInstance().historyArray;

            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_temp = (Shape)actionParameters;
                    shape_temp.ShowAsNotSelected();
                }
                catch (InvalidCastException)
                {
                    ;
                }
            }

            Shape shape = null;

            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)actionParameters;
                    Rotatable dummy = (Rotatable)shape;
                    if (shape.IsSelectMe(e.Location))
                    {
                        History.GetInstance().AddBackUpClone(shape.RetMAction());
                        shape.ShowAsSelected();
                        whichToBeRotated = (Rotatable)shape;
                        ShowRotatingWin();
                        break;
                    }
                    else
                    {
                        shape.ShowAsNotSelected();
                    }
                }
                catch (InvalidCastException)
                {
                    ;
                }
            }
            // VERY IMPORTANT
            History.GetInstance().Update();
        }
Ejemplo n.º 2
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public override void MakeAction(ActionParameters_t toolParameters)
        ///
        /// \brief Makes an action
        ///
        /// \exception InvalidCastException Thrown when an object cannot be cast to a required type.
        ///
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        public override void MakeAction(ActionParameters_t toolParameters)
        {
            try
            {
                FloodFillParam fillParam = (FloodFillParam)toolParameters;
                FillAction(fillParam.point, fillParam.color);
            }
            catch (InvalidCastException)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
 public void MakeAction(ActionParameters_t toolParameters)
 {
     try
     {
         ResizeParam resizeParam = (ResizeParam)toolParameters;
         ResizeAction(resizeParam.size, resizeParam.backgroundColor);
         this.Location = new Point(resizeParam.size);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 4
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public override void MakeAction(ActionParameters_t toolParameters)
        ///
        /// \brief Makes an action
        ///
        /// \exception InvalidCastException Thrown when an object cannot be cast to a required type.
        ///
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        public override void MakeAction(ActionParameters_t toolParameters)
        {
            try
            {
                Ellipse ellipse = (Ellipse)toolParameters;
                Draw(ellipse.pen, ellipse.rect, ellipse.midPoint, ellipse.angle, ellipse.backColor);
                //add into shape array
            }
            catch (InvalidCastException)
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public override void MakeAction(ActionParameters_t toolParameters)
        ///
        /// \brief Makes an action
        ///
        /// \exception InvalidCastException Thrown when an object cannot be cast to a required type.
        ///
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        public override void MakeAction(ActionParameters_t toolParameters)
        {
            try
            {
                Line line = (Line)toolParameters;
                using (Graphics g = Graphics.FromImage(mainView.Image))
                {
                    Draw(g, line.pen, line.a, line.b);
                }
            }
            catch (InvalidCastException)
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public override void MakeAction(ActionParameters_t toolParameters)
        ///
        /// \brief Makes an action
        ///
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        public override void MakeAction(ActionParameters_t toolParameters)
        {
            try
            {
                Bezier bezier = (Bezier)toolParameters;
                using (Graphics g = Graphics.FromImage(mainView.Image))
                {
                    Draw(g, bezier.pointArray, bezier.pen);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 7
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public override void MakeAction(ActionParameters_t toolParameters)
        ///
        /// \brief Makes an action
        ///
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        public override void MakeAction(ActionParameters_t toolParameters)
        {
            try
            {
                BSpline bSpline = (BSpline)(toolParameters);
                using (Graphics g = Graphics.FromImage(mainView.Image))
                {
                    Draw(g, bSpline.pointArray, bSpline.pen);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 8
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public override void MakeAction(ActionParameters_t toolParameters)
        ///
        /// \brief Makes an action
        ///
        /// \exception InvalidCastException Thrown when an object cannot be cast to a required type.
        ///
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        public override void MakeAction(ActionParameters_t toolParameters)
        {
            try
            {
                Circle circle = (Circle)toolParameters;
                using (Graphics g = Graphics.FromImage(mainView.Image))
                {
                    circleAgent.DrawCircle(g, circle.pen, circle.startPoint, circle.endPoint, circle.backColor);
                }
                //add into shape array
            }
            catch (InvalidCastException)
            {
                throw;
            }
        }
Ejemplo n.º 9
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)
                {
                    ;
                }
            }
        }
Ejemplo n.º 10
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)
        {
            Color newColor;

            if (e.Button == MouseButtons.Left)
            {
                newColor = Setting.GetInstance().FrontColor;
            }
            else
            {
                newColor = Setting.GetInstance().BackgroundColor;
            }
            ArrayList array = History.GetInstance().historyArray;

            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_temp = (Shape)actionParameters;
                    if (shape_temp.IsSelectMe(e.Location))
                    {
                        History.GetInstance().AddBackUpClone((MAction)array[i]);
                        shape_temp.backColor = newColor;
                        break;
                    }
                }
                catch (InvalidCastException)
                {
                    ;
                }
            }
            History.GetInstance().Update();
        }
Ejemplo n.º 11
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public override void MakeAction(ActionParameters_t toolParameters)
        ///
        /// \brief Makes an action
        ///
        /// \exception InvalidCastException Thrown when an object cannot be cast to a required type.
        ///
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        public override void MakeAction(ActionParameters_t toolParameters)
        {
            try
            {
                Polygon polygon = (Polygon)toolParameters;
                using (Graphics g = Graphics.FromImage(mainView.Image))
                {
                    LineTool lineTool = (LineTool)ToolKit.GetInstance().lineTool;
                    int      length   = polygon.pointArray.Count;
                    for (int i = 0; i < length; i++)
                    {
                        lineTool.Draw(g, polygon.pen, polygon.pointArray[i % length], polygon.pointArray[(i + 1) % length]);
                    }
                    if (polygon.backColor != Color.White)
                    {
                        g.FillPolygon(new SolidBrush(polygon.backColor), polygon.pointArray.ToArray());
                    }
                }
            }
            catch (InvalidCastException)
            {
                throw;
            }
        }
Ejemplo n.º 12
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn abstract public void MakeAction(ActionParameters_t toolParameters);
        ///
        /// \brief Makes an action
        ///
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        abstract public void MakeAction(ActionParameters_t toolParameters);
Ejemplo n.º 13
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public override void MakeAction(ActionParameters_t toolParameters)
        ///
        /// \brief Makes an action
        ///
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        public override void MakeAction(ActionParameters_t toolParameters)
        {
            ;
        }
Ejemplo n.º 14
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public MAction(Actionable actionable, ActionParameters_t toolParameters)
        ///
        /// \brief Constructor
        ///
        /// \param actionable     The actionable.
        /// \param toolParameters Options for controlling the tool.
        ///-------------------------------------------------------------------------------------------------

        public MAction(Actionable actionable,
                       ActionParameters_t toolParameters)
        {
            this.actionable       = actionable;
            this.actionParameters = toolParameters;
        }