Ejemplo n.º 1
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     this.isMouseDown = false;
     if (mode == 1)
     {
         int x, y, width, height;
         x      = Math.Min(begin.X, e.X);
         y      = Math.Min(begin.Y, e.Y);
         width  = Math.Max(x, Math.Max(begin.X, e.X)) - x;
         height = Math.Max(y, Math.Max(begin.Y, e.Y)) - y;
         if (width < 20 || height < 20)
         {
             return;
         }
         Shape s = new Shape(new Point(x, y), width, height, color, shape);
         this.Controls.Add(s);
         s.topic.mindMap = this.mindmap;
         TopicControllers.UpdateTopic(s.topic);
         using (Graphics g = Graphics.FromImage(this.Image))
         {
             g.FillRectangle(Brushes.White, this.ClientRectangle);
         }
         this.Invalidate();
     }
 }
Ejemplo n.º 2
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();
             }
         }
     }
 }
Ejemplo n.º 3
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     base.OnKeyDown(e);
     if (e.KeyCode == Keys.Delete)
     {
         TopicControllers.DeleteTopicConnection(first, second);
         this.Dispose();
     }
 }
Ejemplo n.º 4
0
        public Shape(Point cor, int width, int height, Color color, int shape)
        {
            topic                   = new TopicClass();
            this.Location           = cor;
            this.shape              = shape;
            this.Width              = width;
            this.Height             = height;
            this.color              = color;
            this.textBox1.Text      = "Nhap noi dung";
            this.BackgroundImage    = new Bitmap(this.Width, this.Height);
            this.textBox1.BackColor = color;
            using (Graphics g = Graphics.FromImage(this.BackgroundImage))
            {
                Rectangle r = new Rectangle(1, 1, this.Width - 5, this.Height - 5);
                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);
                    this.Padding = new Padding(r.Height / 5);
                    break;

                default:
                    break;
                }
            }
            this.Refresh();

            topic.Color  = ColorTranslator.ToHtml(this.color);
            topic.ID     = TopicControllers.GetIDfromDB();
            topic.X      = this.Location.X;
            topic.Y      = this.Location.Y;
            topic.Height = this.Height;
            topic.Width  = this.Width;
            topic.Text   = this.textBox1.Text;
            topic.shape  = this.shape;
            TopicControllers.AddTopic(this.topic);
            this.textBox1.TextChanged += textchanged;
        }
Ejemplo n.º 5
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;
                }
            }
        }
Ejemplo n.º 6
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            if (((Draw)this.Parent).mode == 2)
            {
                ((Draw)this.Parent).current = this.topic;
                if (((Draw)this.Parent).first is null ||
                    ((Draw)this.Parent).first == this.topic)
                {
                    ((Draw)this.Parent).first = this.topic;
                }
                else
                {
                    ((Draw)this.Parent).second = this.topic;
                    ((Draw)this.Parent).fish(((Draw)this.Parent).first, this.topic);

                    this.topic.listTopics.Add(((Draw)this.Parent).first);
                    TopicControllers.UpdateTopic(this.topic);

                    ((Draw)this.Parent).second = null;
                    ((Draw)this.Parent).first  = null;
                }
            }
Ejemplo n.º 7
0
 public void connect(TopicClass First, TopicClass Second)
 {
     first      = First;
     second     = Second;
     this.Image = new Bitmap(this.Parent.Width, this.Parent.Height);
     //Random rnd = new Random();
     //Color randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
     p         = new Pen(Color.Black, 5);
     this.Dock = DockStyle.Fill;
     gra       = new GraphicsPath();
     if (this.Image == null)
     {
         this.Image = new Bitmap(this.Width, this.Height);
     }
     p1 = new Point(first.X + first.Width / 2,
                    first.Y + first.Height / 2);
     p4 = new Point(second.X + second.Width / 2,
                    second.Y + second.Height / 2);
     p2 = new Point((p1.X + p4.X) / 2, (p1.Y + p4.Y) / 2);
     p3 = new Point((p1.X + p4.X) / 2, (p1.Y + p4.Y) / 2);
     if (p1 == p4)
     {
         this.Dispose();
         return;
     }
     using (Graphics g = Graphics.FromImage(this.Image))
     {
         g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
         g.DrawBezier(p, p1, p2, p3, p4);
     }
     first.listTopics.Add(second);
     second.listTopics.Add(first);
     TopicControllers.UpdateTopic(first);
     TopicControllers.UpdateTopic(second);
     gra.AddBezier(p1, p2, p3, p4);
     gra.Widen(p);
     this.Region = new Region(gra);
     this.show   = false;
 }
Ejemplo n.º 8
0
 private void textchanged(object sender, EventArgs e)
 {
     topic.Text = this.textBox1.Text.Trim();
     TopicControllers.UpdateTopic(topic);
 }