示例#1
0
        /// <summary>
        /// Permet de construire l'interface graphique (boutons, menu, texte, dessins)
        /// </summary>
        public Introduction(Programme p_programme) : base(new ÉtatIntroduction(p_programme))
        {
            Fond = Constantes.Fond;

            m_logoIntro = new List <Texte>();

            ConstruireLogo();

            Texte texteDemarrer = new Texte(new Coordonnée(CentreX, 3 * QuartY + 140), "Vous pouvez appuyer sur Enter pour démarrer ou ESC pour quitter", Blanc, 15);

            AjouterÉlément(texteDemarrer);

            Bouton btnDémarrer = new Bouton(new Coordonnée(CentreX, 3 * QuartY + 60),
                                            new Dimension(200, 100), PacMan, JauneFonce,
                                            "Démarrer", 30, ÉtatProgramme.TypeActionBouton.Information);

            AjouterBouton(btnDémarrer);

            m_déplacement = Déplacement.Droite;

            Partie.Instance.Pacman.MettreAJourCoordonnée(new Coordonnée(-200, CentreY - 90));
            Partie.Instance.Blinky.MettreAJourCoordonnée(new Coordonnée(-250, CentreY - 90));
            Partie.Instance.Pinky.MettreAJourCoordonnée(new Coordonnée(-275, CentreY - 90));
            Partie.Instance.Inky.MettreAJourCoordonnée(new Coordonnée(-300, CentreY - 90));
            Partie.Instance.Clyde.MettreAJourCoordonnée(new Coordonnée(-325, CentreY - 90));
        }
示例#2
0
        public Jeu(Programme p_programme) : base(new ÉtatJeu(p_programme))
        {
            m_vies = new List <ObjetDessinable>();

            Fond = Constantes.Fond;

            Texte oneUp = new Texte(new Coordonnée(QuartX, 25), "1UP", Lettres, 25);

            m_pointage = new Texte(new Coordonnée(QuartX, 50), Partie.Instance.Score.ToString("D3"), Lettres, 25);

            Texte record = new Texte(new Coordonnée(3 * QuartX, 25), "Record", Lettres, 25);

            m_record = new Texte(new Coordonnée(3 * QuartX, 50), Partie.Instance.Record.ToString("D3"), Lettres, 25);

            Texte niveau = new Texte(new Coordonnée(3 * QuartX + 100, 25), "Niveau", Lettres, 25);

            m_niveau = new Texte(new Coordonnée(3 * QuartX + 100, 50), Partie.Instance.Niveau.ToString("D3"), Lettres, 25);

            AjouterEnsembleÉléments(new ObjetDessinable[] { oneUp, m_pointage, record, m_record, niveau, m_niveau });

            Bouton aide = new Bouton(new Coordonnée(CentreX, 37), new Dimension(200, 55),
                                     PacMan, JauneFonce, "AIDE (F1)", 30, ÉtatProgramme.TypeActionBouton.Pause);

            AjouterBouton(aide);

            MettreAJourVies();
        }
示例#3
0
        /// <summary>
        /// Permet d'ajouter le fruit a la liste d'objet dessinable mais aussi dajouter la description de ce suivant
        /// </summary>
        /// <param name="p_fruit">Le fruit a ajouter a la liste des elements Dessinables</param>
        private void AjouterObjetDessinableFruit(Fruit p_fruit)
        {
            Coordonnée coordonnéeÉlement = new Coordonnée(p_fruit.Coordonnée.X, p_fruit.Coordonnée.Y + p_fruit.Dimension.Largeur);
            Texte      objetFruitTexte   = new Texte(coordonnéeÉlement, p_fruit.ToString(), p_fruit.CouleurPrincipale, p_fruit.Dimension.Hauteur);

            AjouterÉlément(objetFruitTexte);
            AjouterÉlément(p_fruit);
        }
示例#4
0
        private void AjouterFantôme(ObjetFantôme p_fantôme, String p_description, Color p_couleur)
        {
            Coordonnée coordonnéeFantôme = new Coordonnée(p_fantôme.Coordonnée.X, p_fantôme.Coordonnée.Y + p_fantôme.Dimension.Largeur + 10);
            Texte      texteFantôme      = new Texte(coordonnéeFantôme, p_description, p_couleur, 15);

            AjouterÉlément(texteFantôme);
            AjouterÉlément(p_fantôme);
        }
示例#5
0
        /// <summary>
        /// Permet de créer un texte.
        /// </summary>
        /// <param name="positionX"></param>
        /// <param name="positionY"></param>
        /// <param name="taillePolice"></param>
        /// <param name="contenu"></param>
        /// <returns></returns>
        public virtual Forme CreerTexte(int positionX, int positionY, int taillePolice, string contenu)
        {
            Forme f = new Texte(new Point(positionX, positionY), taillePolice, contenu);

            this.Canvas.Formes.Add(f);
            IMode.instance.Logger(f.Type + " " + f.ID + " : Création effectuée.", ConsoleColor.Green);
            return(f);
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Usuario user = new Usuario();


            Texte.InnerText = user.Nombre;
            Texte.DataBind();



            //ManagerUsuario managerUsuario = new ManagerUsuario();

            // // Usuario usuario =managerUsuario.getUsuario(Usuario)Session["USER" + Session.SessionID];
            // //   usuarioDAL usuario = new usuarioDAL();
            //      Perfil perfil = new Perfil();
            // //perfil.Funciones;

            //List<Funcion> funcionesPadre = /*usuario.*/perfil.Funciones.Where(f => f.FuncionPadre == "0").ToList();

            //List<Funcion> funcionesHija = new List<Funcion>();

            //foreach (Funcion funcion in funcionesPadre)
            //{
            //    HtmlGenericControl li = new HtmlGenericControl("li");
            //    menu.Controls.Add(li);
            //    HtmlGenericControl anchor = new HtmlGenericControl("a");
            //    anchor.Attributes.Add("href", funcion.Url);
            //    HtmlGenericControl span = new HtmlGenericControl("span");
            //    span.Attributes.Add("class", "flecha_abajo");

            //    anchor.InnerText = funcion.Etiqueta;
            //    anchor.Controls.Add(span);
            //    li.Controls.Add(anchor);

            //    funcionesHija = /*usuario.*/perfil.Funciones.Where(f => f.FuncionPadre == funcion.Id).ToList();

            //    if (funcionesHija.Count() > 0)
            //    {
            //        HtmlGenericControl ul = new HtmlGenericControl("ul");

            //        foreach (Funcion funcionHija in funcionesHija)
            //        {
            //            HtmlGenericControl ili = new HtmlGenericControl("li");
            //            ul.Controls.Add(ili);
            //            HtmlGenericControl a = new HtmlGenericControl("a");
            //            a.Attributes.Add("href", funcionHija.Url);
            //            a.InnerText = funcionHija.Etiqueta;
            //            ili.Controls.Add(a);
            //        }

            //        li.Controls.Add(ul);
            // }
            //  }
        }
示例#7
0
        private void Rechercher_Fichier()
        {
            if (!App.MacroEnCours)
            {
                try
                {
                    String OldChemin = Chemin;
                    // On regarde dans le repertoire du modèle courant

                    Chemin = Path.Combine(MdlActif.eDossier(), NomFichierParam);

                    AfficherComposant();

                    if (Chemin == OldChemin)
                    {
                        return;
                    }

                    ViderParam();

                    AfficherComposant();

                    if (!File.Exists(Chemin))
                    {
                        Chemin = Path.Combine(Directory.GetParent(MdlActif.eDossier()).FullName, NomFichierParam);
                        if (!File.Exists(Chemin))
                        {
                            Chemin = Path.Combine(MdlActif.eDossier(), NomFichierParam);
                        }
                    }

                    if (!(String.IsNullOrWhiteSpace(Chemin) || !File.Exists(Chemin)))
                    {
                        using (StreamReader sr = new StreamReader(Chemin, Texte.eGetEncoding(Chemin)))
                        {
                            while (sr.Peek() > -1)
                            {
                                _DicParam.Ajouter(sr.ReadLine());
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    //this.LogMethode(new Object[] { e });
                    ViderParam();
                }
            }
            else
            {
                ViderParam();
            }
        }
示例#8
0
        public Pause(Programme p_programme) : base(new ÉtatPause(p_programme))
        {
            Texte pause = new Texte(new Coordonnée(CentreX, 50), "PAUSE", FantômePeur, 50);

            InformationsTouche.MettreAJourTexte("Appuyer sur une touche pour reprendre");

            Precedent.MettreAJourTexte("Quitter");
            Suivant.MettreAJourTexte("Continuer");
            Suivant.MettreAJourAction(ÉtatProgramme.TypeActionBouton.Pause);

            AjouterÉlément(pause);
        }
示例#9
0
        static void Main(string[] args)
        {
            Texte      texte      = new Texte("fefzefezfefzf");
            Lien       lien       = new Lien("fzefezfezfze");
            Couleur    couleur    = new Couleur("jkjnkjnkjn");
            Horodatage horodatage = new Horodatage(DateTime.Now);

            MessageComposite root = new MessageComposite(horodatage, texte, lien, couleur);

            IMessageFilter filter = new MessageGrasFilter();

            filter.appliquer(root);
        }
示例#10
0
        private void ConstruireLogo()
        {
            Texte intro = new Texte(new Coordonnée(CentreX, QuartY / 2), "PacMan rencontre", Blinky, 40);

            m_logoIntro.Add(intro);

            Texte intro2 = new Texte(new Coordonnée(CentreX, QuartY / 2), "\n\nDesign Pattern", Pinky, 40);

            m_logoIntro.Add(intro2);

            Texte nom = new Texte(new Coordonnée(CentreX, CentreY), "Bastien Roy-Mazoyer", Clyde, 25);

            m_logoIntro.Add(nom);
        }
示例#11
0
        /// <summary>
        /// Permet de construire l'interface graphique (boutons, menu, texte, dessins)
        /// </summary>
        private void Construire()
        {
            Fond = Constantes.Fond;

            Texte description = new Texte(new Coordonnée(CentreX, 100), MessageInfoTableau, PacMan, 30);

            AjouterÉlément(description);

            CreerFruits();

            CreerFantômes();

            CreerBoutons();

            InformationsTouche = new Texte(new Coordonnée(CentreX, 3 * QuartY + 140), MessageToucheInfo, Blanc, 15);
            AjouterÉlément(InformationsTouche);
        }
示例#12
0
        private void SauverFichier()
        {
            if (!FichierCharger)
            {
                return;
            }

            if (!File.Exists(Chemin))
            {
                StreamWriter sw = File.CreateText(Chemin);
                sw.Close();
            }

            using (StreamWriter sw = new StreamWriter(Chemin, false, Texte.eGetEncoding(Chemin)))
            {
                sw.WriteAsync(_DicParam.Texte());
            }
        }
示例#13
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;
        }
        public PartieFinie(Programme p_programme, bool p_victoire) : base(new ÉtatPartieFinie(p_programme))
        {
            m_victoire = p_victoire;
            Fond       = Constantes.Fond;
            TextAlign(CENTER);
            String texteScore = "Votre score : " + Partie.Instance.Score.ToString("D3");
            Texte  score      = new Texte(new Coordonnée(CentreX, QuartY * 3 - 50), texteScore, Inky, 50);

            Texte gameOver = new Texte(new Coordonnée(CentreX, CentreY), p_victoire ? Victoire : GameOver, p_victoire ? MelonFond : Blinky, 100);

            String texteRecord = "Record : " + Partie.Instance.Record.ToString("D3");
            Texte  record      = new Texte(new Coordonnée(CentreX, QuartY), texteRecord, Clyde, 50);

            if (p_victoire)
            {
                Texte  texteSuivant = new Texte(new Coordonnée(QuartX * 3, Hauteur - 40), "Suivant", MelonFond, 20);
                Bouton suivant      = new Bouton(new Coordonnée(QuartX * 3, Hauteur - 100), new Dimension(75, 75),
                                                 MelonFond, MelonPédon, "⇢", 50, ÉtatProgramme.TypeActionBouton.DémarrerPartie);

                AjouterÉlément(texteSuivant);
                AjouterBouton(suivant);
            }

            Texte informationsTouche = new Texte(new Coordonnée(CentreX, 3 * QuartY + 160), p_victoire ? MessageToucheVictoire : MessageToucheDefaite, Blanc, 15);

            AjouterÉlément(informationsTouche);

            Texte  texteRecommencer = new Texte(new Coordonnée(CentreX, Hauteur - 40), "Recommencer", PacMan, 20);
            Bouton recommencer      = new Bouton(new Coordonnée(CentreX, Hauteur - 100), new Dimension(75, 75),
                                                 PacMan, JauneFonce, "⇣", 50, ÉtatProgramme.TypeActionBouton.Information);

            Texte  texteQuitter = new Texte(new Coordonnée(QuartX, Hauteur - 40), "Quitter", CeriseFond, 20);
            Bouton quitter      = new Bouton(new Coordonnée(QuartX, Hauteur - 100), new Dimension(75, 75), CeriseFond,
                                             CerisePédon, "⇠", 50, ÉtatProgramme.TypeActionBouton.TerminéPartie);

            AjouterEnsembleÉléments(new ObjetDessinable[] { score, gameOver, record, texteRecommencer, texteQuitter });
            AjouterBouton(recommencer);
            AjouterBouton(quitter);
        }
示例#15
0
        public IEnumerable <Cours> ChargerCours()
        {
            List <Cours> dataList           = new List <Cours>();
            Cours        nomDeLaProgression = new SousCours("Apprendre le C#");
            Cours        cours1chap1        = new SousCours("Fondamentaux du C#");
            Cours        cours1chap1contenu = new Texte("Les tableaux",
                                                        "DECLARATION ET ALLOCATION DYNAMIQUE DE LA MEMOIRE " +
                                                        "int[] tab; //tab est une référence. Ici, on sait juste que tab désignera un tableau d'entiers à 1 dimension. Ce n'est pas ici " +
                                                        "//qu'on indique la taille. tab étant une référence, il est alloué sur la pile." +
                                                        "tab = new int[3]; //maintenant on alloue la place en mémoire (ici pour 3 entiers) sur le tas." +
                                                        "// Il s'agit donc d'une allocation dynamique");

            cours1chap1.AjouterCours(cours1chap1contenu);

            Cours cours1chap1eval = new Evaluation("Evaluation des acquis sur les tableaux en C#", "texte de l'évaluation : **");

            cours1chap1.AjouterCours(cours1chap1eval);

            nomDeLaProgression.AjouterCours(cours1chap1);
            dataList.Add(nomDeLaProgression);


            nomDeLaProgression = new SousCours("Apprendre le Java");
            Cours cours2chap1        = new SousCours("Fondamentaux du Java");
            Cours cours2chap1contenu = new Texte("Les tableaux",
                                                 "Blabla ");

            cours2chap1.AjouterCours(cours2chap1contenu);

            Cours cours2chap1eval = new Evaluation("Evaluation des acquis en Java", "texte de l'évaluation : **");

            cours2chap1.AjouterCours(cours2chap1eval);

            nomDeLaProgression.AjouterCours(cours2chap1);
            dataList.Add(nomDeLaProgression);

            return(dataList.AsEnumerable());
        }
示例#16
0
        public Options()
        {
            xPos = 3 * TurkeySmashGame.manager.PreferredBackBufferWidth / 4;
            yPos = TurkeySmashGame.manager.PreferredBackBufferHeight / 4;

            son = new Texte(TurkeySmashGame.manager.PreferredBackBufferWidth * 0.2f, TurkeySmashGame.manager.PreferredBackBufferHeight * 0.3f);
            son.Texte = Langue.French ? "Son" : "Sound";
            texteBoutons.Add(son);

            affichage = new Texte(TurkeySmashGame.manager.PreferredBackBufferWidth * 0.25f, TurkeySmashGame.manager.PreferredBackBufferHeight * 0.5f);
            affichage.Texte = Langue.French ? "Affichage" : "Display";
            texteBoutons.Add(affichage);

            langue = new Texte(TurkeySmashGame.manager.PreferredBackBufferWidth * 0.2f, TurkeySmashGame.manager.PreferredBackBufferHeight * 0.7f);
            langue.Texte = Langue.French ? "Langue" : "Language";
            texteBoutons.Add(langue);

            retour = new Texte(TurkeySmashGame.manager.PreferredBackBufferWidth * 0.25f, TurkeySmashGame.manager.PreferredBackBufferHeight * 0.9f);
            retour.Texte = Langue.French ? "Retour" : "Back";
            texteBoutons.Add(retour);

            son.NameFont = affichage.NameFont = langue.NameFont = retour.NameFont = "MenuFont";
        }
示例#17
0
        /// <summary>
        /// Transforms equation object into a tex representation
        /// </summary>
        /// <param name="c">block collection</param>
        public void ToDocument(BlockCollection c)
        {
            List l = new List();

            l.Margin      = new System.Windows.Thickness(50.0d, 0, 0, 0);
            l.MarkerStyle = System.Windows.TextMarkerStyle.None;
            foreach (IDocument a in this.Get(listName))
            {
                if (a is Texte)
                {
                    Texte t = a as Texte;
                    if (t.IsTexMode)
                    {
                        t.InsertIntoDocument(l);
                    }
                    else
                    {
                        ListItem li = new ListItem(new Paragraph(new Run(t.ToString())));
                        l.ListItems.Add(li);
                    }
                }
                else if (a is Arithmetic)
                {
                    ListItem li = new ListItem();
                    li.TextAlignment = System.Windows.TextAlignment.Center;
                    FormulaControl fc = new FormulaControl();
                    fc.Formula = a.ToTex();
                    li.Blocks.Add(new BlockUIContainer(fc));
                    l.ListItems.Add(li);
                }
                else
                {
                    a.InsertIntoDocument(l);
                }
            }
            c.Add(l);
        }
示例#18
0
        /// <summary>
        /// Va permette d'aller verifier dans l'etat de la partie son nombre de vie pour mettre a jour
        /// l'affichage et va aller changer son etat si le nombre atteint 0
        /// </summary>
        public void MettreAJourVies()
        {
            if (m_vies.Count != Partie.Instance.ObtenirNbVies())
            {
                int nbVie = Partie.Instance.ObtenirNbVies();

                if (nbVie == 0)
                {
                    Actions.TerminéPartie(false);
                }

                EnleverEnsembleÉlémentsMemeType(typeof(ObjetPacMan));
                EnleverÉlément(m_vie);

                m_vies.Clear();

                if (nbVie > 3)
                {
                    ObjetPacMan vie = new ObjetPacMan(new Coordonnée(50, 25), 1, ObjetDessinable.Orientation.Droite);
                    m_vie = new Texte(new Coordonnée(75, 25), " x" + nbVie, Lettres, 25);

                    m_vies.Add(vie);
                    AjouterÉlément(m_vie);
                    AjouterÉlément(vie);
                }
                else
                {
                    for (int i = 0; i < nbVie; i++)
                    {
                        ObjetPacMan vie = new ObjetPacMan(new Coordonnée(50 + (25 * i), 25), 1, ObjetDessinable.Orientation.Droite);
                        m_vies.Add(vie);
                    }

                    AjouterEnsembleÉléments(m_vies.ToArray());
                }
            }
        }
示例#19
0
 /// <summary>
 /// Redéfinition de la méthode GetHashCode
 /// </summary>
 /// <returns>un entier : le code de hashage</returns>
 public override int GetHashCode()
 {
     return(Titre.GetHashCode() * Texte.GetHashCode() * Note.GetHashCode());
 }
示例#20
0
 public TextPropertyConverter(CoronaObject obj, Form1 MainForm) :
     base(obj, MainForm)
 {
     objSelected = obj;
     this.text   = obj.DisplayObject.Figure as Texte;
 }
示例#21
0
        public void dessineAllBodyELements(Graphics g, Brush brush, bool applyPointsAjustingWithParent, Point offsetPoint)
        {
            if (this.BodyElements.Count == 0)
            {
                this.isCustomizedBody = false;
            }

            if (this.isCustomizedBody == true)
            {
                for (int i = 0; i < this.BodyElements.Count; i++)
                {
                    BodyElement elem = this.BodyElements[i];

                    if (elem.Type.Equals("SHAPE"))
                    {
                        if (applyPointsAjustingWithParent == true)
                        {
                            //Creer un tableau de points ajustés
                            Point[] tabPointsAjust = new Point[elem.BodyShape.Count];
                            for (int j = 0; j < elem.BodyShape.Count; j++)
                            {
                                Point pAjust = new Point(elem.BodyShape[j].X + this.objectParent.DisplayObject.SurfaceRect.X + offsetPoint.X,
                                                         elem.BodyShape[j].Y + this.objectParent.DisplayObject.SurfaceRect.Y + offsetPoint.Y);

                                tabPointsAjust[j] = pAjust;
                            }
                            g.FillPolygon(brush, tabPointsAjust);
                        }
                        else
                        {
                            //Creer un tableau de points ajustés
                            Point[] tabPointsAjust = new Point[elem.BodyShape.Count];
                            for (int j = 0; j < elem.BodyShape.Count; j++)
                            {
                                Point pAjust = new Point(elem.BodyShape[j].X + offsetPoint.X,
                                                         elem.BodyShape[j].Y + offsetPoint.Y);

                                tabPointsAjust[j] = pAjust;
                            }
                            g.FillPolygon(brush, tabPointsAjust);
                        }
                    }
                    else if (elem.Type.Equals("CIRCLE"))
                    {
                        int radius = elem.Radius;

                        if (applyPointsAjustingWithParent == true)
                        {
                            g.FillEllipse(brush, new Rectangle(new Point(elem.SurfaceCircle.X + this.objectParent.DisplayObject.SurfaceRect.X + offsetPoint.X,
                                                                         elem.SurfaceCircle.Y + this.objectParent.DisplayObject.SurfaceRect.Y + offsetPoint.Y)
                                                               , new Size(elem.Radius * 2, elem.Radius * 2)));
                        }
                        else
                        {
                            g.FillEllipse(brush, new Rectangle(new Point(elem.SurfaceCircle.X + offsetPoint.X,
                                                                         elem.SurfaceCircle.Y + offsetPoint.Y)
                                                               , new Size(elem.Radius * 2, elem.Radius * 2)));
                        }
                    }
                    else if (elem.Type.Equals("LINE"))
                    {
                        if (applyPointsAjustingWithParent == true)
                        {
                            //Creer un tableau de points ajustés
                            Point[] tabPointsAjust = new Point[elem.BodyShape.Count];
                            for (int j = 0; j < elem.BodyShape.Count; j++)
                            {
                                Point pAjust;

                                pAjust = new Point(elem.BodyShape[j].X + this.objectParent.DisplayObject.SurfaceRect.X + offsetPoint.X,
                                                   elem.BodyShape[j].Y + this.objectParent.DisplayObject.SurfaceRect.Y + offsetPoint.Y);

                                tabPointsAjust[j] = pAjust;
                            }


                            g.DrawLines(Pens.GreenYellow, tabPointsAjust);
                        }
                        else
                        {
                            //Creer un tableau de points ajustés
                            Point[] tabPointsAjust = new Point[elem.BodyShape.Count];
                            for (int j = 0; j < elem.BodyShape.Count; j++)
                            {
                                Point pAjust = new Point(elem.BodyShape[j].X + offsetPoint.X,
                                                         elem.BodyShape[j].Y + offsetPoint.Y);

                                tabPointsAjust[j] = pAjust;
                            }
                            g.DrawLines(Pens.GreenYellow, tabPointsAjust);
                        }
                    }
                }
            }
            else
            {
                DisplayObject dispObj = this.objectParent.DisplayObject;
                if (dispObj.Type.Equals("FIGURE"))
                {
                    Figure fig = this.objectParent.DisplayObject.Figure;
                    if (fig != null)
                    {
                        if (fig.ShapeType.Equals("CIRCLE"))
                        {
                            Cercle circ = fig as Cercle;
                            g.FillEllipse(brush, circ.Position.X + offsetPoint.X, circ.Position.Y + offsetPoint.Y, circ.Rayon * 2, circ.Rayon * 2);
                        }
                        else if (fig.ShapeType.Equals("RECTANGLE"))
                        {
                            Rect rect = fig as Rect;
                            g.FillRectangle(brush, rect.Position.X + offsetPoint.X, rect.Position.Y + offsetPoint.Y, rect.Width, rect.Height);
                        }
                        else if (fig.ShapeType.Equals("LINE"))
                        {
                            Krea.CGE_Figures.Line line = fig as Krea.CGE_Figures.Line;
                            //Convertir tous les points et leur ajouter un offset
                            Point[] tabPoints = new Point[line.Points.Count];
                            for (int i = 0; i < line.Points.Count; i++)
                            {
                                tabPoints[i] = new Point(line.Points[i].X + offsetPoint.X, line.Points[i].Y + offsetPoint.Y);
                            }

                            if (line.Points.Count > 2)
                            {
                                g.DrawLines(Pens.GreenYellow, tabPoints);
                            }
                            else if (line.Points.Count == 2)
                            {
                                g.DrawLine(Pens.GreenYellow, tabPoints[0], tabPoints[1]);
                            }
                        }
                        else if (fig.ShapeType.Equals("TEXT"))
                        {
                            Texte txt  = fig as Texte;
                            SizeF size = g.MeasureString(txt.txt, new Font(txt.font2.FamilyName, txt.font2.Size));
                            g.FillRectangle(brush, txt.Position.X + offsetPoint.X, txt.Position.Y + offsetPoint.Y, size.Width, size.Height);
                        }
                    }
                }
                else
                {
                    if (applyPointsAjustingWithParent == true)
                    {
                        g.FillRectangle(brush, dispObj.SurfaceRect.X + offsetPoint.X, dispObj.SurfaceRect.Y + offsetPoint.Y, dispObj.SurfaceRect.Width, dispObj.SurfaceRect.Height);
                    }
                    else
                    {
                        g.FillRectangle(brush, offsetPoint.X, offsetPoint.Y, dispObj.SurfaceRect.Width, dispObj.SurfaceRect.Height);
                    }
                }
            }
        }
示例#22
0
 public int Position(char lettre)
 {
     return(Texte.IndexOf(lettre));
 }
示例#23
0
        public DisplayObject cloneInstance(bool keepLocation)
        {
            if (this.type.Equals("SPRITE"))
            {
                Point pDest;
                if (keepLocation == true)
                {
                    pDest = new Point(this.SurfaceRect.X,
                                      this.SurfaceRect.Y);
                }
                else
                {
                    pDest = new Point(this.SurfaceRect.X + 20, this.SurfaceRect.Y);
                }

                DisplayObject obj = new DisplayObject(this.SpriteSet, pDest, this.CoronaObjectParent);
                obj.OriginalAssetName = this.OriginalAssetName;
                obj.Name = this.Name;

                obj.setSequence(this.CurrentSequence);
                obj.CurrentFrame = this.CurrentFrame;
                obj.AutoPlay     = this.AutoPlay;

                return(obj);
            }
            else if (this.type.Equals("IMAGE"))
            {
                //Creer une nouvelle Image
                Image         newImage         = null;
                DisplayObject newDisplayObject = null;

                if (this.GorgonSprite != null)
                {
                    GorgonLibrary.Graphics.Sprite newGorgonSprite = (GorgonLibrary.Graphics.Sprite) this.GorgonSprite.Clone();
                    newDisplayObject = new DisplayObject(newGorgonSprite, new Point(0, 0), this.CoronaObjectParent);
                }
                else if (this.image != null)
                {
                    newImage         = new Bitmap(this.image);
                    newDisplayObject = new DisplayObject(newImage, new Point(0, 0), this.CoronaObjectParent);
                }
                else
                {
                    return(null);
                }


                newDisplayObject.OriginalAssetName = this.OriginalAssetName;
                newDisplayObject.Name = this.Name;
                //Changer la position de l'objet
                Point pDest;
                if (keepLocation == true)
                {
                    pDest = new Point(this.SurfaceRect.X,
                                      this.SurfaceRect.Y);
                }
                else
                {
                    pDest = new Point(this.SurfaceRect.X + 20, this.SurfaceRect.Y);
                }

                newDisplayObject.surfaceRect = new Rectangle(pDest, this.surfaceRect.Size);
                newDisplayObject.InitialRect = new Rectangle(this.InitialRect.X, this.InitialRect.Y,
                                                             this.InitialRect.Width, this.InitialRect.Height);

                newDisplayObject.ImageFillColor = this.ImageFillColor;


                return(newDisplayObject);
            }
            else if (this.type.Equals("FIGURE"))
            {
                //Recuperer le clone de la figure
                Figure newFig = this.Figure.CloneInstance(keepLocation);

                DisplayObject newDisplayObject = new DisplayObject(newFig, this.CoronaObjectParent);
                newFig.DisplayObjectParent         = newDisplayObject;
                newDisplayObject.OriginalAssetName = this.OriginalAssetName;
                newDisplayObject.Name = this.Name;

                //Copy the gradient color
                newDisplayObject.GradientColor.color1    = this.GradientColor.color1;
                newDisplayObject.GradientColor.color2    = this.GradientColor.color2;
                newDisplayObject.GradientColor.isEnabled = this.GradientColor.isEnabled;
                newDisplayObject.GradientColor.direction = this.GradientColor.direction;

                if (newFig.ShapeType.Equals("TEXT"))
                {
                    Texte text = (Texte)newFig;

                    if (this.GorgonSprite != null)
                    {
                        newDisplayObject.GorgonSprite = (GorgonLibrary.Graphics.Sprite) this.GorgonSprite.Clone();
                    }
                    Point pDest;
                    if (keepLocation == true)
                    {
                        pDest = new Point(text.Position.X,
                                          text.Position.Y);
                    }
                    else
                    {
                        pDest = new Point(text.Position.X + 20,
                                          text.Position.Y);
                    }
                    newDisplayObject.SurfaceRect = new Rectangle(pDest, this.surfaceRect.Size);
                }

                return(newDisplayObject);
            }

            return(null);
        }
示例#24
0
        private List <string> getAllFontsUsed(CoronaGameProject project)
        {
            if (project != null)
            {
                List <string> list = new List <string>();
                for (int i = 0; i < project.Scenes.Count; i++)
                {
                    Scene scene = this.project.Scenes[i];
                    for (int j = 0; j < scene.Layers.Count; j++)
                    {
                        CoronaLayer layer = scene.Layers[j];
                        for (int k = 0; k < layer.CoronaObjects.Count; k++)
                        {
                            CoronaObject obj = layer.CoronaObjects[k];
                            if (obj.isEntity == false)
                            {
                                if (obj.DisplayObject.Figure != null)
                                {
                                    Figure fig = obj.DisplayObject.Figure;
                                    if (fig.ShapeType.Equals("TEXT"))
                                    {
                                        Texte  txt      = fig as Texte;
                                        string fontName = txt.font2.getFontNameForAndroid();
                                        if (!list.Contains(fontName))
                                        {
                                            list.Add(fontName);

                                            string fontsfolder = System.Environment.GetFolderPath(
                                                System.Environment.SpecialFolder.Fonts);

                                            FontNameGetter fontNameGetter = new FontNameGetter();
                                            string         res            = fontNameGetter.GetFontFileName(new DirectoryInfo(fontsfolder), txt.font2);
                                            if (File.Exists(res))
                                            {
                                                string fileDest = project.BuildFolderPath + "\\" + fontName + ".ttf";
                                                File.Copy(res, fileDest, true);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                for (int l = 0; l < obj.Entity.CoronaObjects.Count; l++)
                                {
                                    CoronaObject child = obj.Entity.CoronaObjects[l];

                                    if (child.DisplayObject.Figure != null)
                                    {
                                        Figure fig = child.DisplayObject.Figure;
                                        if (fig.ShapeType.Equals("TEXT"))
                                        {
                                            Texte  txt      = fig as Texte;
                                            string fontName = txt.font2.getFontNameForAndroid();
                                            if (!list.Contains(fontName))
                                            {
                                                list.Add(fontName);

                                                string fontsfolder = System.Environment.GetFolderPath(
                                                    System.Environment.SpecialFolder.Fonts);

                                                FontNameGetter fontNameGetter = new FontNameGetter();
                                                string         res            = fontNameGetter.GetFontFileName(new DirectoryInfo(fontsfolder), txt.font2);
                                                if (File.Exists(res))
                                                {
                                                    string fileDest = project.BuildFolderPath + "\\" + fontName + ".ttf";
                                                    File.Copy(res, fileDest, true);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return(list);
            }
            return(null);
        }
示例#25
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)
            {
            }
        }