Example #1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            mx = e.X;
            my = e.Y;
            md = true;

            sb = Diagram.AtPoint(mx - ScrollX, my - ScrollY);
        }
Example #2
0
 private void btnAddBlock_Click(object sender, EventArgs e)
 {
     var b = new ClassBlock();
     var dlg = new dlgBlockInfo(b);
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         b.Name = dlg.BlockName;
         b.Type = dlg.BlockType;
         b.PosX = dlg.PosX;
         b.PosY = dlg.PosY;
         b.SizeX = dlg.SizeX;
         diagramView.AddBlock(b);
     }
 }
        public void Draw(Graphics g, ClassBlock b)
        {
            //g.DrawRectangle(Pens.White, b.PosX, b.PosY, b.SizeX, b.SizeY);

            var y = b.PosY + 2 + dv.ScrollY;
            var ts = g.MeasureString(b.Name, rf);
            g.DrawString(b.Name, rf, Brushes.White, b.PosX + b.SizeX / 2 - ts.Width / 2 + dv.ScrollX, y);
            y += ts.Height + 2;

            g.DrawLine(Pens.White, b.PosX + dv.ScrollX, y, b.PosX + b.SizeX + dv.ScrollX, y);
            y += 3;

            foreach (var f in b._fields)
            {
                g.DrawString(((f.AccessModifier == AccessModifier.Public) ? "+" : (f.AccessModifier == AccessModifier.Private ? "-" : "?")), rf, Brushes.White, b.PosX + dv.ScrollX, y);
                g.DrawString(f.Name + ":" + f.Type, f.Static ? sf : rf, Brushes.White, b.PosX + 8 + dv.ScrollX, y);
                y += 14;
            }

            y += 2;
            g.DrawLine(Pens.White, b.PosX + dv.ScrollX, y, b.PosX + b.SizeX + dv.ScrollX, y);
            y += 3;

            foreach (var m in b._methods)
            {
                var s = m.Name + '(';
                for (int i = 0; i < m.ParameterCount; i++)
                {
                    s += m.ParameterTypes[i];
                    if (i < m.ParameterCount - 1)
                        s += ", ";
                }
                s += ')' + (string.IsNullOrEmpty(m.ReturnType) ? "" : (":" + m.ReturnType));
                g.DrawString(((m.AccessModifier == AccessModifier.Public) ? "+" : (m.AccessModifier == AccessModifier.Private ? "-" : "?")), rf, Brushes.White, b.PosX + dv.ScrollX, y);
                g.DrawString(s, m.Static ? sf : rf, Brushes.White, b.PosX + 8 + dv.ScrollX, y);
                y += 14;
            }
            y += 2;

            g.DrawRectangle(Pens.White, b.PosX + dv.ScrollX, b.PosY + dv.ScrollY, b.SizeX, y - b.PosY - dv.ScrollY);

            b.SizeY = y - b.PosY - dv.ScrollY;
        }
Example #4
0
        public dlgBlockInfo(ClassBlock b)
        {
            InitializeComponent();

            txtName.Text = b.Name;
            txtPosX.Text = b.PosX.ToString();
            txtPosY.Text = b.PosY.ToString();
            txtSizeX.Text = b.SizeX.ToString();
            switch (b.Type)
            {
                case ClassBlock.ClassType.Class:
                    cbxType.SelectedIndex = 0;
                    break;
                case ClassBlock.ClassType.Interface:
                    cbxType.SelectedIndex = 1;
                    break;
                case ClassBlock.ClassType.Struct:
                    cbxType.SelectedIndex = 2;
                    break;
            }
        }
Example #5
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            var d = new ClassDiagram();
            var cb = new ClassBlock("TestClass", ClassBlock.ClassType.Class) { PosX = 10, PosY = 30, SizeX = 200 };
            cb.AddField(new Field("TEST_CONST", "int", true, AccessModifier.Public));
            cb.AddField(new Field("testField", "String", false, AccessModifier.Public));
            cb.AddField(new Field("testField", "String", false, AccessModifier.Public));
            cb.AddField(new Field("testField", "String", false, AccessModifier.Private));
            cb.AddMethod(new Method("TestClass", null, false, AccessModifier.Public, "String", "String", "int"));
            cb.AddMethod(new Method("testMethod", "void", false, AccessModifier.Public, "String", "String", "int"));
            d.Blocks.Add(cb);

            cb = new ClassBlock("TestClass", ClassBlock.ClassType.Class) { PosX = 10, PosY = 30, SizeX = 200 };
            cb.AddField(new Field("TEST_CONST", "int", true, AccessModifier.Public));
            cb.AddField(new Field("testField", "String", false, AccessModifier.Public));
            cb.AddField(new Field("testField", "String", false, AccessModifier.Public));
            cb.AddField(new Field("testField", "String", false, AccessModifier.Private));
            cb.AddMethod(new Method("TestClass", null, false, AccessModifier.Public, "String", "String", "int"));
            cb.AddMethod(new Method("testMethod", "void", false, AccessModifier.Public, "String", "String", "int"));
            d.Blocks.Add(cb);
            diagramView.Diagram = d;
        }
Example #6
0
 public void AddBlock(ClassBlock cb)
 {
     Diagram.Blocks.Add(cb);
     Invalidate();
 }