Пример #1
0
        public void OnDocumentSelectionChanged(object sender, EventArgs e)
        {
            if (sender != null)
            {
                ModelingDocView view = sender as ModelingDocView;
                if (view != null)
                {
                    ICollection selection = view.GetSelectedComponents();
                    if (selection.Count == 1)
                    {
                        IEnumerator enumerator = selection.GetEnumerator();
                        enumerator.MoveNext();
                        ClassShape shape = enumerator.Current as ClassShape;
                        if (shape != null)
                        {
                            ModelClass modelClass = shape.ModelElement as ModelClass;
                            if (modelClass != null)
                            {
                                control.Display(modelClass);
                                return;
                            }
                        }

                        ModelProperty property = enumerator.Current as ModelProperty;
                        if (property != null)
                        {
                            control.Display(property.ModelClass);
                            return;
                        }
                    }
                }

                control.Clear();
            }
        }
Пример #2
0
        private void InjectReflectedData(ClassShape newShape)
        {
            Random rnd = new Random();

            Type type = sampleTypes[rnd.Next(0, sampleTypes.Length)];


            MethodInfo[]   meths = type.GetMethods();
            PropertyInfo[] props = type.GetProperties();

            ObservableCollection <ClassMember> methods = new ObservableCollection <ClassMember>();

            for (int i = 0; i < meths.Length && i < 10; i++)
            {
                methods.Add(new ClassMember(meths[i].Name, "PublicMethod"));
            }


            ClassCategory methodSection = new ClassCategory("Methods", methods);

            ObservableCollection <ClassMember> properties = new ObservableCollection <ClassMember>();

            for (int i = 0; i < props.Length && i < 10; i++)
            {
                properties.Add(new ClassMember(props[i].Name, "PublicProperty"));
            }
            ;
            ClassCategory propertySection = new ClassCategory("Properties", properties);

            ObservableCollection <ClassCategory> categories = new ObservableCollection <ClassCategory>();

            categories.Add(propertySection);
            categories.Add(methodSection);

            newShape.Title = type.Name;
            if (type.IsPublic)
            {
                newShape.SubTitle += "public ";
            }
            //if (type.IsSealed)
            //    newShape.SubTitle += "sealed ";
            if (type.IsAbstract)
            {
                newShape.SubTitle += "abstract ";
            }
            if (type.IsInterface)
            {
                newShape.SubTitle += "interface ";
            }

            newShape.SubTitle += "class";

            newShape.TreeData = categories;
        }
Пример #3
0
            public UIElement Create(Rect rect)
            {
                ClassShape shape = new ClassShape();

                //shape.Width = rect.Width;
                //shape.Height = rect.Height;
                shape.ShapeColor = RandomLowSaturationColor;


                Canvas.SetLeft(shape, rect.X);
                Canvas.SetTop(shape, rect.Y);
                return(shape);
            }
Пример #4
0
        private void cboModifier_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (diagram.SelectedItemCount == 1 && diagram.FirstSelectedItem is ClassShape)
            {
                ClassShape shape = (ClassShape)diagram.FirstSelectedItem;
                ClassType  type  = (ClassType)shape.Entity;

                int index = cboModifier.SelectedIndex;
                if (type.Language == Language.CSharp)
                {
                    type.Modifier = csharpModifierOrder[index];
                }
                else
                {
                    type.Modifier = javaModifierOrder[index];
                }

                shape.Refresh();
            }
        }
Пример #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            ClassShape cls1 = new ClassShape();

            cls1.HeadColor = Color.SteelBlue;
            cls1.Location  = new Point(100, 10);
            cls1.BodyType  = BodyType.None;
            cls1.Text      = "What is this?";
            cls1.Title     = "This is the title";
            cls1.SubTitle  = "The subtitle";
            this.diagramControl1.AddShape(cls1);

            ClassShape cls2 = new ClassShape();

            cls2.HeadColor = Color.SlateGray;
            cls2.Location  = new Point(100, 10);
            cls2.BodyType  = BodyType.None;
            cls2.Text      = "What is this?";
            cls2.Title     = "This is the title";
            cls2.SubTitle  = "The subtitle";
            this.diagramControl1.AddShape(cls2);

            this.diagramControl1.AddConnection(cls1.Connectors[0], cls2.Connectors[0]);
        }
Пример #6
0
 public ClassStroke(ClassShape classShape, StylusPointCollection pts) : base(pts, classShape)
 {
     attributes = classShape.attributes;
     methods    = classShape.methods;
 }
        private void btnConsoleRun_Click(object sender, EventArgs e)
        {
            Regex regex1 = new Regex(@"drawto (.*[\d])([,])(.*[\d]) line (.*[\d])([,])(.*[\d])");
            Regex regex2 = new Regex(@"drawto (.*[\d])([,])(.*[\d]) rectangle (.*[\d])([,])(.*[\d])");
            Regex regex3 = new Regex(@"drawto (.*[\d])([,])(.*[\d]) circle (.*[\d])");
            Regex regex4 = new Regex(@"drawto (.*[\d])([,])(.*[\d]) triangle (.*[\d])([,])(.*[\d])([,])(.*[\d])");
            Regex regex5 = new Regex(@"drawto (.*[\d])([,])(.*[\d]) pentagon point2 (.*[\d])([,])(.*[\d]) point3 (.*[\d])([,])(.*[\d]) point4 (.*[\d])([,])(.*[\d]) point5 (.*[\d])([,])(.*[\d])");

            Regex regexClear = new Regex(@"clear board");
            Regex regexMT    = new Regex(@"moveto (.*[\d])([,])(.*[\d])");

            Regex regexR = new Regex(@"rectangle (.*[\d])([,])(.*[\d])");
            Regex regexC = new Regex(@"circle (.*[\d])");
            Regex regexT = new Regex(@"triangle (.*[\d])([,])(.*[\d])([,])(.*[\d])");

            Regex regexRepeat = new Regex(@"repeat (.*[\d])");

            Regex regexIfelse = new Regex(@"if drawto x= (.*[\d]) >= 0 or y= (.*[\d]) >= 0 ");

            //if drawto x= 9 >= 0 or y= 19 >= 0
            //----------------------------------------------------------------------------------------------------------------------
            //----------------------------------------------------------------------------------------------------------------------
            Match match1 = regex1.Match(rtxtConsole.Text.ToLower());
            Match match2 = regex2.Match(rtxtConsole.Text.ToLower());
            Match match3 = regex3.Match(rtxtConsole.Text.ToLower());
            Match match4 = regex4.Match(rtxtConsole.Text.ToLower());
            Match match5 = regex5.Match(rtxtConsole.Text.ToLower());

            Match matchClear = regexClear.Match(rtxtConsole.Text.ToLower());
            Match matchMT    = regexMT.Match(rtxtConsole.Text.ToLower());

            Match matchR = regexR.Match(rtxtConsole.Text.ToLower());
            Match matchC = regexC.Match(rtxtConsole.Text.ToLower());
            Match matchT = regexT.Match(rtxtConsole.Text.ToLower());

            Match matchRepeat = regexRepeat.Match(rtxtConsole.Text.ToLower());

            Match matchIfelse = regexIfelse.Match(rtxtConsole.Text.ToLower());

            //============================== DRAWING LINE =========================================
            if (match1.Success)
            {
                try
                {
                    g      = DrawAreaPanel.CreateGraphics();
                    _size1 = int.Parse(match1.Groups[1].Value);
                    _size2 = int.Parse(match1.Groups[3].Value);
                    _size3 = int.Parse(match1.Groups[4].Value);
                    _size4 = int.Parse(match1.Groups[6].Value);

                    ClassShapeFactory shapeFactory = new ClassShapeFactory();
                    ClassShape        c            = shapeFactory.GetShape("line");
                    c.set(texturestyle, bb, paintcolor, _size1, _size2, _size3, _size4);
                    c.draw(g);
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                    //MessageBox.Show(ex.Message);
                }
            }
            //=============================== RECTANGLE with DrawTo ====================================================
            else if (match2.Success)
            {
                try
                {
                    g      = DrawAreaPanel.CreateGraphics();
                    _size1 = int.Parse(match2.Groups[1].Value);
                    _size2 = int.Parse(match2.Groups[3].Value);
                    _size3 = int.Parse(match2.Groups[4].Value);
                    _size4 = int.Parse(match2.Groups[6].Value);

                    ClassShapeFactory shapeFactory = new ClassShapeFactory();
                    ClassShape        c            = shapeFactory.GetShape("rectangle");

                    c.set(texturestyle, bb, paintcolor, _size1, _size2, _size3, _size4);
                    c.draw(g);
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                    //MessageBox.Show(ex.Message);
                }
            }

            //=================================== RECTANGLE ==============================================================
            else if (matchR.Success)
            {
                try
                {
                    g      = DrawAreaPanel.CreateGraphics();
                    _size1 = int.Parse(lbl_StartPosX.Text);
                    _size2 = int.Parse(lbl_StartPosY.Text);
                    _size3 = int.Parse(matchR.Groups[1].Value);
                    _size4 = int.Parse(matchR.Groups[3].Value);

                    ClassShapeFactory shapeFactory = new ClassShapeFactory();
                    ClassShape        c            = shapeFactory.GetShape("rectangle");
                    c.set(texturestyle, bb, paintcolor, _size1, _size2, _size3, _size4);
                    c.draw(g);
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                }
            }

            //================================== CIRCLE with Drawto ======================================
            else if (match3.Success)
            {
                try
                {
                    g      = DrawAreaPanel.CreateGraphics();
                    _size1 = int.Parse(match3.Groups[1].Value);
                    _size2 = int.Parse(match3.Groups[3].Value);
                    _size3 = int.Parse(match3.Groups[4].Value);

                    ClassShapeFactory shapeFactory = new ClassShapeFactory();
                    ClassShape        c            = shapeFactory.GetShape("circle");
                    c.set(texturestyle, bb, paintcolor, _size1, _size2, _size3 * 2, _size3 * 2);
                    c.draw(g);
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                }
            }

            //=========================================== Circle =======================================================
            else if (matchC.Success)
            {
                try
                {
                    g      = DrawAreaPanel.CreateGraphics();
                    _size1 = int.Parse(lbl_StartPosX.Text);
                    _size2 = int.Parse(lbl_StartPosY.Text);
                    _size3 = int.Parse(matchC.Groups[1].Value);

                    ClassShapeFactory shapeFactory = new ClassShapeFactory();
                    ClassShape        c            = shapeFactory.GetShape("circle");
                    c.set(texturestyle, bb, paintcolor, _size1, _size2, _size3 * 2, _size3 * 2);
                    //c.draw(set);
                    c.draw(g);
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                    // MessageBox.Show(ex.Message);
                }
            }

            //==================================== TRIANGLE with DrawTo ===================================================
            else if (match4.Success)
            {
                try
                {
                    g      = DrawAreaPanel.CreateGraphics();
                    _size1 = int.Parse(match4.Groups[1].Value);
                    _size2 = int.Parse(match4.Groups[3].Value);

                    _size3 = int.Parse(match4.Groups[4].Value);
                    _size4 = int.Parse(match4.Groups[6].Value);
                    _size5 = int.Parse(match4.Groups[8].Value);

                    xi1 = _size1;
                    yi1 = _size2;
                    xi2 = Math.Abs(_size3);
                    yi2 = _size2;

                    xii1 = _size1;
                    yii1 = _size2;
                    xii2 = _size1;
                    yii2 = Math.Abs(_size4);

                    xiii1 = Math.Abs(_size3);
                    yiii1 = _size2;
                    xiii2 = _size1;
                    yiii2 = Math.Abs(_size4);

                    ClassShapeFactory shapeFactory = new ClassShapeFactory();
                    ClassShape        c            = shapeFactory.GetShape("triangle");
                    c.set(texturestyle, bb, paintcolor, xi1, yi1, xi2, yi2, xii1, yii1, xii2, yii2, xiii1, yiii1, xiii2, yiii2);
                    c.draw(g);
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                }
            }

            //==================================================== Triangle =====================================================
            else if (matchT.Success)
            {
                try
                {
                    g      = DrawAreaPanel.CreateGraphics();
                    _size1 = int.Parse(lbl_StartPosX.Text);
                    _size2 = int.Parse(lbl_StartPosY.Text);

                    _size3 = int.Parse(matchT.Groups[1].Value);
                    _size4 = int.Parse(matchT.Groups[3].Value);
                    _size5 = int.Parse(matchT.Groups[5].Value);

                    xi1 = _size1;
                    yi1 = _size2;
                    xi2 = Math.Abs(_size3);
                    yi2 = _size2;

                    xii1 = _size1;
                    yii1 = _size2;
                    xii2 = _size1;
                    yii2 = Math.Abs(_size4);

                    xiii1 = Math.Abs(_size3);
                    yiii1 = _size2;
                    xiii2 = _size1;
                    yiii2 = Math.Abs(_size4);

                    ClassShapeFactory shapeFactory = new ClassShapeFactory();
                    ClassShape        c            = shapeFactory.GetShape("triangle"); //new rectangles();
                    c.set(texturestyle, bb, paintcolor, xi1, yi1, xi2, yi2, xii1, yii1, xii2, yii2, xiii1, yiii1, xiii2, yiii2);
                    c.draw(g);
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                }
            }

            //================================================= PENTAGON ==============================================================

            if (match5.Success)
            {
                try
                {
                    //1,3,4,6,7,9,10,12,13,15,16,18
                    g       = DrawAreaPanel.CreateGraphics();
                    _size1  = int.Parse(match5.Groups[1].Value);
                    _size2  = int.Parse(match5.Groups[3].Value);
                    _size3  = int.Parse(match5.Groups[4].Value);
                    _size4  = int.Parse(match5.Groups[6].Value);
                    _size5  = int.Parse(match5.Groups[7].Value);
                    _size6  = int.Parse(match5.Groups[9].Value);
                    _size7  = int.Parse(match5.Groups[10].Value);
                    _size8  = int.Parse(match5.Groups[12].Value);
                    _size9  = int.Parse(match5.Groups[13].Value);
                    _size10 = int.Parse(match5.Groups[15].Value);

                    ClassShapeFactory shapeFactory = new ClassShapeFactory();
                    ClassShape        c            = shapeFactory.GetShape("pentagon");
                    c.set(texturestyle, bb, paintcolor, _size1, _size2, _size3, _size4, _size5, _size6, _size7, _size8, _size9, _size10);
                    c.draw(g);
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                    //MessageBox.Show(ex.Message);
                }
            }

            //================================================ CLEAR BOARD ====================================================================

            else if (matchClear.Success)
            {
                DrawAreaPanel.Refresh();
                this.DrawAreaPanel.BackgroundImage = null;
            }

            //================================================= MOVETO ==========================================================
            else if (matchMT.Success)
            {
                try
                {
                    _size1 = int.Parse(matchMT.Groups[1].Value);
                    _size2 = int.Parse(matchMT.Groups[3].Value);

                    lbl_StartPosX.Text = _size1.ToString();
                    lbl_StartPosY.Text = _size2.ToString();
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                    //MessageBox.Show(ex.Message);
                }
            }

            //======================================================== REPEAT ====================================================
            else if (matchRepeat.Success)
            {
                try
                {
                    _repeatNo = int.Parse(matchRepeat.Groups[1].Value);

                    //=================================================== Repeat Shapes ====================================

                    //Regex regexRepCircle = new Regex(@"circle radius (.*[\d]) by radius (.*[\d]) end");

                    Regex regexRepCircle = new Regex(@"circle radius (.*[\d]) by (.*[\d]) end");
                    //repeat 4 circle radius 30 by 20 end

                    Regex regexRepRectangle = new Regex(@"rectangle width (.*[\d]) height (.*[\d]) by width (.*[\d]) height (.*[\d]) end");
                    //repeat 4 rectangle width 90 height 120 by width 20 height 20

                    Match matchRepCircle    = regexRepCircle.Match(rtxtConsole.Text.ToLower());
                    Match matchRepRectangle = regexRepRectangle.Match(rtxtConsole.Text.ToLower());

                    //================================================== Repeat Circle ================================================
                    if (matchRepCircle.Success)
                    {
                        int _repeatAdd = 0;
                        int _repeatAddConstant;
                        _size1             = int.Parse(lbl_StartPosX.Text);
                        _size2             = int.Parse(lbl_StartPosY.Text);
                        _size3             = int.Parse(matchRepCircle.Groups[1].Value);
                        _repeatAdd         = int.Parse(matchRepCircle.Groups[2].Value);
                        _repeatAddConstant = int.Parse(matchRepCircle.Groups[2].Value);

                        ClassShapeFactory shapeFactory = new ClassShapeFactory();
                        ClassShape        c            = shapeFactory.GetShape("circle");

                        for (int i = 0; i < _repeatNo; i++)
                        {
                            c.set(texturestyle, bb, paintcolor, _size1, _size2, (_size3 + _repeatAdd), (_size3 + _repeatAdd));
                            c.draw(g);
                            _size1     = _size1 - (_repeatAddConstant / 2);
                            _size2     = _size2 - (_repeatAddConstant / 2);
                            _repeatAdd = _repeatAdd + _repeatAddConstant;

                            //_repeatAdd = _repeatAdd + _repeatAdd;
                        }
                    }

                    //=================================================== Repeat Rectangle ==============================================
                    else if (matchRepRectangle.Success)
                    {
                        try
                        {
                            int _repeatAddWidth = 0;
                            int _repeatAddConstantWidth;
                            int _repeatAddHeight = 0;
                            int _repeatAddConstantHeight;

                            //g = DrawAreaPanel.CreateGraphics();
                            _size1 = int.Parse(lbl_StartPosX.Text);
                            _size2 = int.Parse(lbl_StartPosY.Text);
                            _size3 = int.Parse(matchRepRectangle.Groups[1].Value);
                            _size4 = int.Parse(matchRepRectangle.Groups[2].Value);

                            _repeatAddWidth         = int.Parse(matchRepRectangle.Groups[3].Value);
                            _repeatAddConstantWidth = int.Parse(matchRepRectangle.Groups[3].Value);

                            _repeatAddHeight         = int.Parse(matchRepRectangle.Groups[4].Value);
                            _repeatAddConstantHeight = int.Parse(matchRepRectangle.Groups[4].Value);

                            ClassShapeFactory shapeFactory = new ClassShapeFactory();
                            ClassShape        c            = shapeFactory.GetShape("rectangle");

                            for (int i = 0; i < _repeatNo; i++)
                            {
                                c.set(texturestyle, bb, paintcolor, _size1, _size2, _size3 + _repeatAddWidth, _size4 + _repeatAddHeight);
                                c.draw(g);
                                _size1           = _size1 - (_repeatAddConstantWidth / 2);
                                _size2           = _size2 - (_repeatAddConstantHeight / 2);
                                _repeatAddWidth  = _repeatAddWidth + _repeatAddConstantWidth;
                                _repeatAddHeight = _repeatAddHeight + _repeatAddConstantHeight;
                            }
                        }
                        catch (Exception ex)
                        {
                            rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                            //MessageBox.Show(ex.Message);
                        }
                    }

                    //=============================================== IF ELSE ==================================================

                    else if (matchIfelse.Success)
                    {
                        try
                        {
                            int checkX, checkY;

                            //g = drawareapanel.CreateGraphics();
                            checkX             = int.Parse(matchIfelse.Groups[1].Value);
                            checkY             = int.Parse(matchIfelse.Groups[2].Value);
                            lbl_StartPosX.Text = checkX.ToString();
                            lbl_StartPosY.Text = checkY.ToString();
                            _size1             = checkX;
                            _size2             = checkY;

                            if (checkX > 0 && checkY > 0)
                            {
                                Regex regexIfelseCircle = new Regex(@"draw circle (.*[\d])");
                                Match matchIfelseCircle = regexIfelseCircle.Match(rtxtConsole.Text.ToLower());

                                Regex regexIfelseRectangle = new Regex(@"draw rectangle (.*[\d])([,])(.*[\d])");
                                Match matchIfelseRectangle = regexIfelseRectangle.Match(rtxtConsole.Text.ToLower());

                                //if drawto x= 9 >= 0 or y= 19 >= 0 draw circle 90
                                //draw circle 90
                                //draw rectangle 90,70
                                if (matchIfelseCircle.Success)
                                {
                                    try
                                    {
                                        _size3 = int.Parse(matchIfelseCircle.Groups[1].Value);

                                        ClassShapeFactory shapeFactory = new ClassShapeFactory();
                                        ClassShape        c            = shapeFactory.GetShape("circle");
                                        c.set(texturestyle, bb, paintcolor, _size1, _size2, _size3 * 2, _size3 * 2);
                                        c.draw(g);
                                    }
                                    catch (Exception ex)
                                    {
                                        rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                                        // MessageBox.Show(ex.Message);
                                    }
                                }
                                else if (matchIfelseRectangle.Success)
                                {
                                    try
                                    {
                                        _size3 = int.Parse(matchIfelseRectangle.Groups[1].Value);
                                        _size4 = int.Parse(matchIfelseRectangle.Groups[3].Value);

                                        ClassShapeFactory shapeFactory = new ClassShapeFactory();
                                        ClassShape        c            = shapeFactory.GetShape("rectangle");
                                        c.set(texturestyle, bb, paintcolor, _size1, _size2, _size3, _size4);
                                        c.draw(g);
                                    }
                                    catch (Exception ex)
                                    {
                                        rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                                    }
                                }
                            }
                            else
                            {
                                if (checkX < 0)
                                {
                                    MessageBox.Show("Drawto X= " + checkX + " cannot be less than zero(0)");
                                }
                                else
                                {
                                    MessageBox.Show("Drawto Y= " + checkY + " cannot be less than zero(0)");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                            //MessageBox.Show(ex.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    rtxtErrors.AppendText(ex.Message + Environment.NewLine);
                }
            }

            //=================================================== HISTORY RECORDING ===============================================
            rtxtHistory.AppendText(rtxtConsole.Text + Environment.NewLine);
            //=================================================== ***************** ==============================================
        }