Exemplo n.º 1
0
        //Mouse released ---------------------------------------------------------------------------------------------------
        private void surfacePictBx_MouseUp(object sender, MouseEventArgs e)
        {
            isMousePressed = false;
            moveFocusSceneActive = false;
            moveObjectActive = false;
            moveSurfaceAdActive = false;
            moveSurfaceControlActive = false;

            Point offSetPoint = this.getOffsetPoint();

            Point pTouched = new Point(Convert.ToInt32(-offSetPoint.X + e.Location.X * (1 / this.CurrentScale)),
                    Convert.ToInt32(-offSetPoint.Y + e.Location.Y * (1 / this.CurrentScale)));

            if (this.Mode.Equals("CREATE_SHAPE"))
            {
                if (this.mainForm.ShapeType != 5 && this.mainForm.ShapeType != 2)
                {
                    if (this.mainForm.ShapeType == 4 && this.surfaceTextTemp != null)
                    {
                        Font2 font = new Font2("ARIAL", 16, FontStyle.Regular);
                        this.FigActive = new Texte(this.surfaceTextTemp.Location, "New Text", font, Color.Blue, 1, false, null);
                    }
                    this.mainForm.addFigureBt_Click(null, null);
                }

                if (this.mainForm.isFormLocked == false)
                    GorgonLibrary.Gorgon.Go();
            }
            //------------------------------------------------------------------------------
            //--------------------------CREATION DES JOINTURES--------------------------
            //------------------------------------------------------------------------------
            else if (this.Mode.Equals("JOINT"))
            {
                UserControl jointPanel = this.mainForm.CurrentJointPanel;

                //Verifier que le panel n'est pas null
                if (jointPanel != null)
                {

                    //Recuperer le panel correspondant au joint
                    if (jointPanel.Name.Equals("PIVOT"))
                    {
                        PivotPropertiesPanel pivotPanel = (PivotPropertiesPanel)jointPanel;
                        pivotPanel.nextCreationStep(pTouched);

                    }
                    else if (jointPanel.Name.Equals("DISTANCE"))
                    {
                        DistancePropertiesPanel panel = (DistancePropertiesPanel)jointPanel;
                        panel.nextCreationStep(pTouched);

                    }
                    else if (jointPanel.Name.Equals("FRICTION"))
                    {
                        FrictionPropertiesPanel panel = (FrictionPropertiesPanel)jointPanel;
                        panel.nextCreationStep(pTouched);

                    }
                    else if (jointPanel.Name.Equals("PISTON"))
                    {
                        PistonPropertiesPanel panel = (PistonPropertiesPanel)jointPanel;
                        panel.nextCreationStep(pTouched);

                    }
                    else if (jointPanel.Name.Equals("PULLEY"))
                    {
                        PulleyPropertiesPanel panel = (PulleyPropertiesPanel)jointPanel;
                        panel.nextCreationStep(pTouched);

                    }
                    else if (jointPanel.Name.Equals("WHEEL"))
                    {
                        WheelPropertiesPanel panel = (WheelPropertiesPanel)jointPanel;
                        panel.nextCreationStep(pTouched);

                    }
                    else if (jointPanel.Name.Equals("WELD"))
                    {
                        WeldPropertiesPanel panel = (WeldPropertiesPanel)jointPanel;
                        panel.nextCreationStep(pTouched);

                    }
                    else if (jointPanel.Name.Equals("TOUCH"))
                    {
                        TouchPropertiesPanel panel = (TouchPropertiesPanel)jointPanel;
                        panel.nextCreationStep(pTouched);

                    }

                }

                if (this.mainForm.isFormLocked == false)
                    GorgonLibrary.Gorgon.Go();

            }
        }
Exemplo n.º 2
0
 public FigurePropertyConverter(CoronaObject obj, Form1 MainForm)
     : base(obj,MainForm)
 {
     this.shape = obj.DisplayObject.Figure;
     this.obj = obj;
 }
Exemplo n.º 3
0
        //Mousse pressed --------------------------------------------------------------------------------------------------
        private void surfacePictBx_MouseDown(object sender, MouseEventArgs e)
        {
            isMousePressed = true;
            Point offSetPoint = this.getOffsetPoint();
            Point pTouched = new Point(Convert.ToInt32(-offSetPoint.X + e.Location.X * (1 / this.CurrentScale)),
                    Convert.ToInt32(-offSetPoint.Y + e.Location.Y * (1 / this.CurrentScale)));

            GameElementTreeView treeView = this.mainForm.getElementTreeView();
            Scene sceneSelected = treeView.SceneSelected;

            this.pDepart = pTouched;
            if (CurentCalque.Equals("LAYER"))
            {
                CoronaLayer layer = treeView.LayerSelected;
                if (layer != null)
                {

                    if (this.Mode.Equals("MOVE") || this.Mode.Contains("RESIZE") || this.Mode.Equals("ROTATION") || this.Mode.Equals("DELETE"))
                    {

                        if (this.movingMode.Equals("OBJECT"))
                        {
                            for (int i = 0; i < this.objectsSelected.Count; i++)
                            {
                                CoronaObject coronaObject = this.objectsSelected[i];
                                if (coronaObject.isEnabled == true)
                                {
                                    if (coronaObject.isEntity == false)
                                    {
                                        coronaObject.setSelected(true);
                                        coronaObject.DisplayObject.LastPos = pTouched;
                                        if (coronaObject.DisplayObject.Type.Equals("FIGURE"))
                                        {
                                            coronaObject.DisplayObject.Figure.LastPos = pTouched;
                                        }
                                    }
                                }

                            }

                            moveObjectActive = true;
                        }
                        else if (this.movingMode.Equals("ENTITY"))
                        {
                            for (int i = 0; i < this.objectsSelected.Count; i++)
                            {
                                CoronaObject entity = this.objectsSelected[i];
                                if (entity.isEnabled == true)
                                {
                                    if (entity.isEntity == true)
                                    {
                                        for (int j = 0; j < entity.Entity.CoronaObjects.Count; j++)
                                        {
                                            CoronaObject coronaObject = entity.Entity.CoronaObjects[j];

                                            coronaObject.DisplayObject.LastPos = pTouched;
                                            if (coronaObject.DisplayObject.Type.Equals("FIGURE"))
                                            {
                                                coronaObject.DisplayObject.Figure.LastPos = pTouched;
                                            }
                                        }

                                    }
                                }

                            }

                            moveObjectActive = true;
                        }
                        else if (this.movingMode.Equals("CONTROL"))
                        {
                            this.moveSurfaceControlActive = true;
                            for (int i = 0; i < this.joysticksSelected.Count; i++)
                            {
                                JoystickControl joy = this.joysticksSelected[i];
                                if(joy.isEnabled == true)
                                    joy.lastPos = pTouched;
                            }
                        }

                    }
                    else if (this.Mode.Equals("CREATE_SHAPE"))
                    {
                        pDepart = pTouched;
                        //Si un rectangle
                        if (this.mainForm.ShapeType == 1)
                        {
                            this.FigActive = new Rect(pTouched, 10, 10, false, Color.Empty, Color.White, 2, false, null);

                        }
                        //Si une Ligne
                        else if (this.mainForm.ShapeType == 2)
                        {

                            //Creer la ligne si elle ne l'est pas
                            if (isLineCreated == false)
                            {
                                this.FigActive = new Line(pTouched, Color.White, 2, false, null);
                                isLineCreated = true;

                            }
                            else
                            {

                                //Sinon ajouter seulement le point au tableau
                                Line line = this.FigActive as Line;
                                line.Points.Add(pTouched);

                            }
                        }
                        //Si un Cercle
                        else if (this.mainForm.ShapeType == 3)
                        {
                            this.FigActive = new Cercle(pTouched, 2, Color.Empty, Color.White, 2, false, null);

                        }
                        //Si un Texte
                        else if (this.mainForm.ShapeType == 4)
                        {
                            Font2 font = new Font2("ARIAL", 16, FontStyle.Regular);
                            //this.FigActive = new Texte(pDepart, "New Text", font, Color.Blue, 1, false, null);

                            this.surfaceTextTemp = new Rectangle(pTouched, TextRenderer.MeasureText("New Text", new System.Drawing.Font(font.FamilyName, font.Size)));
                            font = null;
                        }
                        //Si un une courbe de bezier
                        else if (this.mainForm.ShapeType == 5)
                        {
                            //Creer le bezier s'il ne l'est pas
                            if (isBezierCreated == false)
                            {
                                List<Point> tabP = new List<Point>();
                                tabP.Add(pTouched);

                                this.FigActive = new CourbeBezier(pTouched, tabP, Color.Empty, Color.White, 2, false, null);
                                isBezierCreated = true;

                            }
                            else
                            {

                                //Sinon ajouter seulement le point au tableau
                                CourbeBezier bezier = this.FigActive as CourbeBezier;
                                bezier.UserPoints.Add(pTouched);

                            }

                        }
                        //Si un rectangle arrondi
                        else if (this.mainForm.ShapeType == 6)
                        {
                            this.FigActive = new Rect(pTouched, 10, 10, true, Color.Empty, Color.White, 2, false, null);
                        }
                    }
                    else if (this.Mode.Equals("PATH_FOLLOW"))
                    {
                        if (this.objectsSelected.Count > 0)
                        {
                            CoronaObject obj = objectsSelected[0];
                            if (obj != null)
                            {
                                if (obj.isEnabled == true)
                                {
                                    if (obj.isEntity == false)
                                        obj.PathFollow.Path.Add(pTouched);
                                }

                            }

                        }
                    }

                }
            }
            else if (CurentCalque.Equals("STAGE"))
            {
                if (sceneSelected != null)
                {
                    if (this.Mode.Equals("CAMERA_RECTANGLE"))
                    {
                        pDepart = pTouched;
                        sceneSelected.Camera.CameraFollowLimitRectangle = new Rectangle(pTouched, new Size(10, 10));
                    }
                    else if (this.Mode.Equals("CREATE_SHAPE"))
                    {
                        if (treeView.CoronaObjectSelected != null)
                        {
                            if (treeView.CoronaObjectSelected.isEntity == true)
                            {
                                pDepart = pTouched;
                                //Si un rectangle
                                if (this.mainForm.ShapeType == 1)
                                {
                                    this.FigActive = new Rect(pTouched, 10, 10, false, Color.Empty, Color.White, 2, false, null);

                                }
                                //Si une Ligne
                                else if (this.mainForm.ShapeType == 2)
                                {

                                    //Creer la ligne si elle ne l'est pas
                                    if (isLineCreated == false)
                                    {
                                        this.FigActive = new Line(pTouched, Color.White, 2, false, null);
                                        isLineCreated = true;

                                    }
                                    else
                                    {

                                        //Sinon ajouter seulement le point au tableau
                                        Line line = this.FigActive as Line;
                                        line.Points.Add(pTouched);

                                    }
                                }
                                //Si un Cercle
                                else if (this.mainForm.ShapeType == 3)
                                {
                                    this.FigActive = new Cercle(pTouched, 2, Color.Empty, Color.White, 2, false, null);

                                }
                                //Si un Texte
                                else if (this.mainForm.ShapeType == 4)
                                {
                                    Font2 font = new Font2("ARIAL", 16, FontStyle.Regular);
                                    //this.FigActive = new Texte(pDepart, "New Text", font, Color.Blue, 1, false, null);

                                    this.surfaceTextTemp = new Rectangle(pTouched, TextRenderer.MeasureText("New Text", new System.Drawing.Font(font.FamilyName, font.Size)));
                                    font = null;
                                }
                                //Si un une courbe de bezier
                                else if (this.mainForm.ShapeType == 5)
                                {
                                    //Creer le bezier s'il ne l'est pas
                                    if (isBezierCreated == false)
                                    {
                                        List<Point> tabP = new List<Point>();
                                        tabP.Add(pTouched);

                                        this.FigActive = new CourbeBezier(pTouched, tabP, Color.Empty, Color.White, 2, false, null);
                                        isBezierCreated = true;

                                    }
                                    else
                                    {

                                        //Sinon ajouter seulement le point au tableau
                                        CourbeBezier bezier = this.FigActive as CourbeBezier;
                                        bezier.UserPoints.Add(pTouched);

                                    }

                                }
                                //Si un rectangle arrondi
                                else if (this.mainForm.ShapeType == 6)
                                {
                                    this.FigActive = new Rect(pTouched, 10, 10, true, Color.Empty, Color.White, 2, false, null);
                                }
                            }
                            else
                            {
                                this.Mode = "NONE";
                                this.isMousePressed = false;
                                MessageBox.Show("Please select a layer before adding a new display object!", "Select a layer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }

                        }
                        else
                        {
                            this.Mode = "NONE";
                            this.isMousePressed = false;
                            MessageBox.Show("Please select a layer before adding a new display object!", "Select a layer", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }

                    }
                    else if (this.Mode.Equals("MOVE") || this.Mode.Contains("RESIZE") || this.Mode.Equals("ROTATION"))
                    {
                        if (this.movingMode.Equals("FOCUS") && this.Mode.Equals("MOVE"))
                        {
                            if (sceneSelected.Camera.SurfaceFocus.Contains(pTouched))
                            {
                                sceneSelected.lastPos = pTouched;
                                this.moveFocusSceneActive = true;
                            }
                        }
                        else if (this.movingMode.Equals("OBJECT"))
                        {
                            for (int i = 0; i < this.objectsSelected.Count; i++)
                            {
                                CoronaObject coronaObject = this.objectsSelected[i];
                                if (coronaObject.isEnabled == true)
                                {
                                    if (coronaObject.isEntity == false)
                                    {
                                        coronaObject.DisplayObject.LastPos = pTouched;
                                        coronaObject.PhysicsBody.OriginSize = coronaObject.DisplayObject.SurfaceRect.Size;
                                        if (coronaObject.DisplayObject.Type.Equals("FIGURE"))
                                        {
                                            coronaObject.DisplayObject.Figure.LastPos = pTouched;
                                        }
                                    }
                                }
                            }

                            moveObjectActive = true;

                        }
                        else if (this.movingMode.Equals("ENTITY"))
                        {
                            for (int i = 0; i < this.objectsSelected.Count; i++)
                            {
                                CoronaObject entity = this.objectsSelected[i];
                                if (entity.isEnabled == true)
                                {

                                    if (entity.isEntity == true)
                                    {
                                        for (int j = 0; j < entity.Entity.CoronaObjects.Count; j++)
                                        {
                                            CoronaObject coronaObject = entity.Entity.CoronaObjects[j];
                                            coronaObject.DisplayObject.LastPos = pTouched;
                                            if (coronaObject.DisplayObject.Type.Equals("FIGURE"))
                                            {
                                                coronaObject.DisplayObject.Figure.LastPos = pTouched;
                                            }
                                        }

                                    }
                                }
                            }

                            moveObjectActive = true;
                        }
                        else if (this.movingMode.Equals("AD"))
                        {

                            if (sceneSelected.Ad.isActive == true)
                            {
                                Rectangle rect = new Rectangle(
                                    new Point(sceneSelected.Ad.location.X + offSetPoint.X + sceneSelected.Camera.SurfaceFocus.Location.X,
                                        sceneSelected.Ad.location.Y+ offSetPoint.Y + sceneSelected.Camera.SurfaceFocus.Location.Y),
                                    sceneSelected.Ad.size);

                                if (rect.Contains(e.Location))
                                {
                                    sceneSelected.lastPos = pTouched;
                                    this.moveSurfaceAdActive = true;
                                }
                            }

                        }
                        else if (this.movingMode.Equals("CONTROL"))
                        {
                            this.moveSurfaceControlActive = true;
                            for (int i = 0; i < this.joysticksSelected.Count; i++)
                            {
                                JoystickControl joy = this.joysticksSelected[i];
                                if(joy.isEnabled == true)
                                    joy.lastPos = pTouched;
                            }
                        }

                    }
                    else if (this.Mode.Equals("PATH_FOLLOW"))
                    {
                        if (this.objectsSelected.Count > 0)
                        {
                            CoronaObject obj = objectsSelected[0];
                            if (obj != null)
                            {
                                if(obj.isEnabled == true)
                                 obj.PathFollow.Path.Add(pTouched);

                            }

                        }
                    }

                }
            }

            if (this.mainForm.isFormLocked == false)
                GorgonLibrary.Gorgon.Go();
        }
Exemplo n.º 4
0
        public DisplayObject(Figure fig,CoronaObject coronaObjectParent)
        {
            this.Name = "Figure";
            this.type = "FIGURE";
            this.Figure = fig;
            this.Figure.DisplayObjectParent = this;

            if (this.Figure.ShapeType.Equals("RECTANGLE"))
            {
                Rect rect = this.Figure as Rect;
                this.surfaceRect = rect.getBounds(new Matrix());
            }
            else if (this.Figure.ShapeType.Equals("CIRCLE"))
            {
                Cercle cercle = this.Figure as Cercle;
                this.surfaceRect = cercle.getBounds(new Matrix());
            }
            else if (this.Figure.ShapeType.Equals("LINE"))
            {
                Line line = this.Figure as Line;

                this.surfaceRect = line.getBounds(new Matrix());
            }
            else if (this.Figure.ShapeType.Equals("TEXT"))
            {
                Texte text = this.Figure as Texte;
                this.surfaceRect = new Rectangle(text.Position,
                    System.Windows.Forms.TextRenderer.MeasureText(text.txt,
                    new Font(text.font2.FamilyName,text.font2.Size, text.font2.Style)));
            }
            else if (this.Figure.ShapeType.Equals("CURVE"))
            {
                CourbeBezier courbe = this.Figure as CourbeBezier;
                this.surfaceRect = courbe.getBounds(new Matrix());
            }

            Alpha = 1.0F;
            this.GradientColor = new GradientColor();
            this.CoronaObjectParent = coronaObjectParent;
        }