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(); } } } }
public static bool UpdateMindMap(MindMapClass mindmap) { using (var _context = new DBTopicContext()) { _context.dbMM.AddOrUpdate(mindmap); _context.SaveChanges(); return(true); } }
public TopicLoad(MindMapClass mm) { InitializeComponent(); this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; this.pictureBox1.BorderStyle = BorderStyle.FixedSingle; try { this.pictureBox1.Image = Image.FromFile(mm.name); } catch { this.pictureBox1.Image = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height); using (Graphics g = Graphics.FromImage(this.pictureBox1.Image)) { g.DrawString("Khong tim duoc hinh", new Font("Arial", 14), new SolidBrush(Color.Black), 10, 10); } } this.ID = mm.ID.ToString(); this.label1.Text = Path.GetFileName(mm.name); this.pictureBox1.Click += picturebox_Click; }
public void save() { if (mindmap == null) { mindmap = new MindMapClass(); mindmap.ID = MindMapControllers.GetIDfromDB(); } mindmap.listTopics.Clear(); if (this.Image == null) { this.Image = new Bitmap(this.Width, this.Height); this.BackColor = Color.White; } try { using (Graphics g = Graphics.FromImage(this.Image)) { g.FillRectangle(Brushes.White, this.ClientRectangle); this.BackColor = Color.White; foreach (Control c in this.Controls) { if (c == this.tb) { continue; } if (c is Connect) { g.DrawBezier(((Connect)c).p, ((Connect)c).p1, ((Connect)c).p2, ((Connect)c).p3, ((Connect)c).p4); continue; } } foreach (Control c in this.Controls) { if (c is Shape) { g.DrawImage(((Shape)c).save(), c.Location); mindmap.listTopics.Add(((Shape)c).topic); } } } { SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = "Images|*.png; *.bmp"; ImageFormat format = ImageFormat.Png; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string ext = System.IO.Path.GetExtension(sfd.FileName); switch (ext) { case ".jpg": format = ImageFormat.Jpeg; break; case ".bmp": format = ImageFormat.Bmp; break; } } this.Image.Save(sfd.FileName, format); mindmap.name = sfd.FileName; MindMapControllers.UpdateMindMap(mindmap); using (Graphics g = Graphics.FromImage(this.Image)) { g.FillRectangle(Brushes.White, this.ClientRectangle); } } } catch { } }