Exemple #1
0
 public void load(string ID)
 {
     this.Controls.Clear();
     {
         using (var _context = new DBTopicContext())
         {
             if (ID == null)
             {
                 return;
             }
             int idd = Int32.Parse(ID);
             this.mindmap = MindMapControllers.LoadMindMap(idd);
             foreach (var t in mindmap.listTopics)
             {
                 var first = TopicControllers.GetTopic(t.ID);
                 foreach (var second in first.listTopics)
                 {
                     this.fish(first, second);
                 }
             }
             foreach (var t in mindmap.listTopics)
             {
                 Shape s = new Shape(t);
                 this.Controls.Add(s);
                 s.BringToFront();
             }
         }
     }
 }
Exemple #2
0
        public Shape(TopicClass t)
        {
            this.Location           = new Point(t.X, t.Y);
            this.color              = ColorTranslator.FromHtml(t.Color);
            this.Size               = new Size(t.Width, t.Height);
            this.textBox1.Text      = t.Text;
            this.shape              = t.shape;
            this.BackgroundImage    = new Bitmap(this.Width, this.Height);
            this.textBox1.BackColor = color;
            this.cT    = t.listTopics.ToList();
            this.topic = TopicControllers.GetTopic(t.ID);
            this.textBox1.TextChanged += textchanged;
            using (Graphics g = Graphics.FromImage(this.BackgroundImage))
            {
                Rectangle r = new Rectangle(1, 1, this.Width - 6, this.Height - 6);
                g.SmoothingMode = SmoothingMode.HighQuality;
                switch (shape)
                {
                case 1:
                    g.DrawRectangle(new Pen(Color.Black, 3), r);
                    g.FillRectangle(new SolidBrush(this.color), r);
                    break;

                case 2:
                    g.DrawEllipse(new Pen(Color.Black, 3), r);
                    g.FillEllipse(new SolidBrush(this.color), r);
                    int lr = (this.Width - (int)(this.Width / Math.Sqrt(2))) / 2 + 5;
                    int tb = (this.Height - (int)(this.Height / Math.Sqrt(2))) / 2 + 5;
                    this.Padding = new Padding(lr, tb, lr, tb);
                    break;

                case 3:
                    g.DrawRoundedRectangle(new Pen(Color.Black, 3), r, r.Width / 5);
                    g.FillRoundedRectangle(new SolidBrush(this.color), r, r.Height / 5);
                    break;

                default:
                    break;
                }
            }
        }