示例#1
0
        public void createNewConcept(double x, double y, String type, String name, String attributs, String methods)
        {
            if (classes == null)
                classes = new List<Classe>();

            Label nam, var, fun;
            var = new Label
            {
                Content = attributs == "" ? "attributs" : attributs,
                FontSize = 16,
                Margin = new Thickness(x, y, 0, 0),
            };

            fun = new Label
            {
                Content = methods == "" ? "methodes" : methods,
                FontSize = 16,
                Margin = new Thickness(x, y, 0, 0)
            };

            nam = new Label
            {
                Content = name == "" ? "classe : " + classes.Count : name,
                FontSize = 16,
                Margin = new Thickness(x, y, 0, 0)
            };

            nam.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            nam.Arrange(new Rect(nam.DesiredSize));

            double myWidth = nam.ActualWidth;
            double myHeight = nam.ActualHeight + LABEL_SPACE;

            Classe clas = new Classe();
            double i = 0;

            if (type.Contains("classe"))
                i = 0.5;
            else
                i = 4;

            clas.Cadres = new List<Rectangle>();
            clas.Cadres.Add(generateMyRect(myWidth + LABEL_SPACE*2, myHeight, x - LABEL_SPACE, y, i));
            clas.Cadres.Add(generateMyRect(myWidth + LABEL_SPACE * 2, myHeight, x - LABEL_SPACE, y + myHeight + 4, i));
            clas.Cadres.Add(generateMyRect(myWidth + LABEL_SPACE * 2, myHeight, x - LABEL_SPACE, y + myHeight * 2 + 8, i));
            clas.Cadres.Add(generateMyRect(LABEL_SPACE * 4, LABEL_SPACE * 4, x - LABEL_SPACE, y - LABEL_SPACE * 4, 0.5));
            clas.Cadres.Add(generateMyRect(LABEL_SPACE * 4, LABEL_SPACE * 4, x + LABEL_SPACE*3, y - LABEL_SPACE * 4, 0.5));
            //clas.Cadres.Add(generateMyRect(myWidth + LABEL_SPACE * 2, myHeight, x - LABEL_SPACE, y, i));

            clas.Cadres[3].Fill = new SolidColorBrush(Colors.Red);
            clas.Cadres[4].Fill = new SolidColorBrush(Colors.Blue);

            clas.Nom = nam;
            var.Margin = clas.Cadres[1].Margin;
            clas.Variables = var;
            fun.Margin = clas.Cadres[2].Margin;
            clas.Fonctions = fun;

            clas.Type = type;

            clas.Nom_tb = generateTextBox(myWidth + LABEL_SPACE * 2
                                        , myHeight
                                        , clas.Cadres[0].Margin
                                        , clas.Nom.Content.ToString());

            clas.Variables_tb = generateRichTextBox(myWidth + LABEL_SPACE * 2
                                                    , myHeight
                                                    , clas.Cadres[1].Margin);

            clas.Fonctions_tb = generateRichTextBox(myWidth + LABEL_SPACE * 2
                                                    , myHeight
                                                    , clas.Cadres[2].Margin);

            classes.Add(clas);

            back.Children.Add(clas.Cadres[0]);
            back.Children.Add(clas.Cadres[1]);
            back.Children.Add(clas.Cadres[2]);
            back.Children.Add(clas.Cadres[3]);
            back.Children.Add(clas.Cadres[4]);
            back.Children.Add(clas.Nom);
            back.Children.Add(clas.Nom_tb);
            back.Children.Add(clas.Variables);
            back.Children.Add(clas.Variables_tb);
            back.Children.Add(clas.Fonctions);
            back.Children.Add(clas.Fonctions_tb);
        }