示例#1
0
        public List <CoronaSpriteSetSequence> checkSequencesIntegrity()
        {
            List <CoronaSpriteSetSequence> sequencesToReturn = new List <CoronaSpriteSetSequence>();

            for (int i = 0; i < this.Sequences.Count; i++)
            {
                CoronaSpriteSetSequence sequence = this.Sequences[i];
                if (sequence != null)
                {
                    if (sequence.FrameDepart - 1 + sequence.FrameCount - 1 >= this.Frames.Count)
                    {
                        sequencesToReturn.Add(sequence);
                    }
                }
            }

            if (sequencesToReturn.Count > 0)
            {
                return(sequencesToReturn);
            }
            else
            {
                sequencesToReturn = null;
                return(null);
            }
        }
示例#2
0
        private void addSequenceBt_Click(object sender, EventArgs e)
        {
            if (this.set != null)
            {
                if (this.framesSetListView.SelectedIndices.Count > 0)
                {
                    bool canCreate = true;
                    int indexDepart = this.framesSetListView.SelectedIndices[0];
                    for (int i = 0; i < this.framesSetListView.SelectedIndices.Count; i++)
                    {
                        if (i != 0)
                        {
                            int indexPrevious = this.framesSetListView.SelectedIndices[i - 1];
                            int index = this.framesSetListView.SelectedIndices[i];
                            if (index - indexPrevious != 1)
                            {
                                canCreate = false;
                                break;
                            }
                        }
                    }

                    if (canCreate == true)
                    {
                        this.stopAnimCurrentSequence();
                        CoronaSpriteSetSequence sequence = new CoronaSpriteSetSequence("sequence" + set.Sequences.Count, indexDepart + 1, this.framesSetListView.SelectedIndices.Count, 1000, 0);
                        this.set.Sequences.Add(sequence);

                        this.sequencesCmbBx.Items.Clear();

                        for (int i = 0; i < set.Sequences.Count; i++)
                        {
                            this.sequencesCmbBx.Items.Add(set.Sequences[i]);
                        }

                        this.sequencesCmbBx.SelectedIndex = set.Sequences.Count - 1;

                    }
                    else
                    {
                        MessageBox.Show("Can not create sequences with non-consecutive frames!", "Information",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Please select Sprite set frame to create a new sequence!", "Information",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

            }
        }
示例#3
0
 public SequencePropertyConverter(CoronaSpriteSetSequence seq)
 {
     this.seq = seq;
 }
示例#4
0
        public void addSequence(String name, int frameDep, int frameCount, int time, int iteration)
        {
            CoronaSpriteSetSequence sequence = new CoronaSpriteSetSequence(name, frameDep, frameCount, time, iteration);

            this.Sequences.Add(sequence);
        }
示例#5
0
        private void removeSequence(CoronaSpriteSetSequence sequence)
        {
            this.stopAnimCurrentSequence();

            if (sequence != null)
            {
                this.stopAnimCurrentSequence();

                this.set.SequenceSelected = null;

                this.set.Sequences.Remove(sequence);
                this.refreshSpriteSetFramesListView();

            }
        }
示例#6
0
 public void addSequence(String name, int frameDep, int frameCount, int time, int iteration)
 {
     CoronaSpriteSetSequence sequence = new CoronaSpriteSetSequence(name, frameDep, frameCount, time, iteration);
     this.Sequences.Add(sequence);
 }
示例#7
0
        public void dessineAt(Graphics g, Point offsetPoint, bool showSelection, Matrix matrixToApply, float xScale, float yScale)
        {
            try
            {
                Rectangle rectDest = new Rectangle(new Point(offsetPoint.X + this.surfaceRect.Location.X,
                                                             offsetPoint.Y + this.surfaceRect.Location.Y), this.surfaceRect.Size);
                Matrix m = null;
                if (matrixToApply != null)
                {
                    m = matrixToApply;
                }
                else
                {
                    m = this.getMatrixForDrawing(rectDest, xScale, yScale);
                }

                //Si c'est un sprite  -----------
                if (this.type.Equals("SPRITE"))
                {
                    if (this.CoronaObjectParent != null)
                    {
                        if (this.SpriteSet != null)
                        {
                            if (this.currentFrame < this.SpriteSet.Frames.Count)
                            {
                                g.Transform = m;


                                if (this.CurrentSequence == "")
                                {
                                    this.setSequence("");
                                }

                                if (this.CurrentSequence == "DEFAULT")
                                {
                                    Image image = this.SpriteSet.Frames[this.currentFrame].Image;

                                    float factor = this.SpriteSet.Frames[this.currentFrame].SpriteSheetParent.FramesFactor;
                                    if (factor <= 0)
                                    {
                                        factor = 1;
                                    }

                                    int width  = Convert.ToInt32((float)image.Size.Width / factor);
                                    int height = Convert.ToInt32((float)image.Size.Height / factor);
                                    this.surfaceRect = new Rectangle(this.surfaceRect.Location, new Size(width, height));

                                    g.DrawImage(image, rectDest.X, rectDest.Y, this.surfaceRect.Width, this.surfaceRect.Height);
                                }
                                else
                                {
                                    CoronaSpriteSetSequence sequence = this.getSequenceByName(this.CurrentSequence);
                                    if (sequence == null)
                                    {
                                        this.setSequence("");

                                        Image image = this.SpriteSet.Frames[this.currentFrame].Image;

                                        float factor = this.SpriteSet.Frames[this.currentFrame].SpriteSheetParent.FramesFactor;
                                        if (factor <= 0)
                                        {
                                            factor = 1;
                                        }

                                        int width  = Convert.ToInt32((float)image.Size.Width / factor);
                                        int height = Convert.ToInt32((float)image.Size.Height / factor);
                                        this.surfaceRect = new Rectangle(this.surfaceRect.Location, new Size(width, height));

                                        g.DrawImage(image, rectDest.X, rectDest.Y, this.surfaceRect.Width, this.surfaceRect.Height);
                                    }
                                    else
                                    {
                                        int   convertedFrame = this.currentFrame + sequence.FrameDepart - 1;
                                        Image image          = this.SpriteSet.Frames[convertedFrame].Image;

                                        float factor = this.SpriteSet.Frames[convertedFrame].SpriteSheetParent.FramesFactor;
                                        if (factor <= 0)
                                        {
                                            factor = 1;
                                        }

                                        int width  = Convert.ToInt32((float)image.Size.Width / factor);
                                        int height = Convert.ToInt32((float)image.Size.Height / factor);
                                        this.surfaceRect = new Rectangle(this.surfaceRect.Location, new Size(width, height));

                                        g.DrawImage(image, rectDest.X, rectDest.Y, this.surfaceRect.Width, this.surfaceRect.Height);
                                    }
                                }
                            }
                        }
                    }
                    else if (this.AnimSpritePictBxParent != null)
                    {
                        if (this.SpriteSet.Frames.Count > 0)
                        {
                            Image img = this.SpriteSet.Frames[CurrentFrame].Image;
                            if (img.Height > this.AnimSpritePictBxParent.Height || img.Height > this.AnimSpritePictBxParent.Height)
                            {
                                g.DrawImage(img, 0, 0, this.AnimSpritePictBxParent.Width, this.AnimSpritePictBxParent.Height);
                            }
                            else
                            {
                                int   xDest = System.Convert.ToInt32(this.AnimSpritePictBxParent.Size.Width * 0.5 - rectDest.Size.Width * 0.5);
                                int   yDest = System.Convert.ToInt32(this.AnimSpritePictBxParent.Size.Height * 0.5 - rectDest.Size.Height * 0.5);
                                Point pDest = new Point(xDest, yDest);
                                g.DrawImage(img, pDest);
                            }
                        }
                    }
                }
                //Si c'est une image simple -----------
                else if (this.type.Equals("IMAGE"))
                {
                    if (this.CoronaObjectParent != null)
                    {
                        g.Transform = m;

                        if (this.ImageFillColor.IsEmpty)
                        {
                            this.ImageFillColor = Color.White;
                        }

                        float       tR = (float)ImageFillColor.R / 255;
                        float       tG = (float)ImageFillColor.G / 255;
                        float       tB = (float)ImageFillColor.B / 255;
                        float       tA = this.Alpha;
                        ColorMatrix cm = new ColorMatrix(new float[][]
                        {
                            new float[] { tR, 0, 0, 0, 0 },
                            new float[] { 0, tG, 0, 0, 0 },
                            new float[] { 0, 0, tB, 0, 0 },
                            new float[] { 0, 0, 0, tA, 0 },
                            new float[] { 0, 0, 0, 0, 1 }
                        });

                        // Create ImageAttributes
                        ImageAttributes imgAttribs = new ImageAttributes();
                        // Set color matrix
                        imgAttribs.SetColorMatrix(cm);

                        try
                        {
                            // Draw image with ImageAttributes
                            g.DrawImage(image,
                                        rectDest,
                                        0, 0, image.Width, image.Height,
                                        GraphicsUnit.Pixel, imgAttribs);
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }


                //Si c'est une figure -----------
                else if (this.type.Equals("FIGURE"))
                {
                    int alphaARGB = System.Convert.ToInt32(this.Alpha * 255);
                    if (this.Figure.ShapeType.Equals("RECTANGLE"))
                    {
                        Rect rect = this.Figure as Rect;
                        g.Transform = m;

                        rect.DessineAt(g, rectDest.Location, alphaARGB);
                    }
                    else if (this.Figure.ShapeType.Equals("CIRCLE"))
                    {
                        Cercle circ = this.Figure as Cercle;
                        g.Transform = m;

                        circ.DessineAt(g, rectDest.Location, alphaARGB);
                    }
                    else if (this.Figure.ShapeType.Equals("CURVE"))
                    {
                        CourbeBezier bezier = this.Figure as CourbeBezier;
                        g.Transform = m;

                        bezier.Dessine(g, alphaARGB, offsetPoint);
                    }
                    else if (this.Figure.ShapeType.Equals("LINE"))
                    {
                        Line line = this.Figure as Line;
                        g.Transform = m;


                        line.Dessine(g, alphaARGB, offsetPoint);
                    }
                    else if (this.Figure.ShapeType.Equals("TEXT"))
                    {
                        Texte txt = this.Figure as Texte;
                        g.Transform = m;

                        txt.DessineAt(g, rectDest.Location, alphaARGB);
                        rectDest = new Rectangle(rectDest.Location, new Size((int)txt.stringSize.Width, (int)txt.stringSize.Height));
                    }
                }



                //DRAW SELECTION
                if (showSelection == true)
                {
                    if (this.CoronaObjectParent.isSelected == true)
                    {
                        /* float[] dashValues = { 2, 2 };
                         * Pen pen = new Pen(Color.FromArgb(150, Color.Blue), 3);
                         * pen.DashPattern = dashValues;
                         *
                         * g.ResetTransform();*/

                        Matrix matrixPath = new Matrix();
                        matrixPath.Scale(xScale, yScale);
                        g.Transform = matrixPath;


                        if (this.CoronaObjectParent.PathFollow != null)
                        {
                            if (this.CoronaObjectParent.PathFollow.isEnabled == true)
                            {
                                this.CoronaObjectParent.PathFollow.dessine(g, offsetPoint);
                            }
                        }


                        if (this.CoronaObjectParent.TransformBox != null)
                        {
                            this.CoronaObjectParent.TransformBox.drawTransformBox(g, offsetPoint, xScale, yScale);
                        }

                        /* GraphicsPath gp = new GraphicsPath();
                         *
                         * gp.AddRectangle(rectDest);
                         *
                         * RectangleF rectF = gp.GetBounds(m);
                         * g.DrawRectangle(pen, rectF.X, rectF.Y, rectF.Width, rectF.Height);*/

                        g.Transform = m;
                    }
                }
            }
            catch (Exception Exception)
            {
            }
        }