public ActionResult Delete(TopicClass t) { TopicList tList = new TopicList(); tList.DeleteAccount(t); return(RedirectToAction("Index")); }
public ActionResult Edit(TopicClass t) { TopicList tList = new TopicList(); tList.UpdateTopic(t); return(RedirectToAction("Index")); }
public static bool AddTopic(TopicClass topic) { using (var _context = new DBTopicContext()) { _context.dbTopic.Add(topic); _context.SaveChanges(); return(true); } }
public ActionResult Create(TopicClass t) { if (ModelState.IsValid) { TopicList tList = new TopicList(); tList.AddTopic(t); return(RedirectToAction("Index")); } return(View()); }
public void fish(TopicClass first, TopicClass second) { if (second is null || first is null) { return; } Connect c = new Connect(); this.Controls.Add(c); c.connect(first, second); }
public async Task <IActionResult> Create(TopicClass newTopic) { if (ModelState.IsValid) { _db.Add(newTopic); await _db.SaveChangesAsync(); return(RedirectToAction("Topics")); } return(View(newTopic)); }
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; }
public void updateP(TopicClass t) { if (first == t) { p1 = new Point(t.X + t.Width / 2, t.Y + t.Height / 2); } if (second == t) { p1 = new Point(t.X + t.Width / 2, t.Y + t.Height / 2); } }
public static bool DeleteTopicConnection(TopicClass first, TopicClass second) { using (var _context = new DBTopicContext()) { var a = (from u in _context.dbTopic where u.ID == first.ID select u).Single(); var b = (from u in _context.dbTopic where u.ID == second.ID select u).Single(); a.listTopics.Remove(b); _context.dbTopic.AddOrUpdate(a); _context.SaveChanges(); return(true); } }
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; } } }
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; }
public static bool UpdateTopic(TopicClass topic) { using (var _context = new DBTopicContext()) { var a = (from u in _context.dbTopic.Include("mindMap") where u.ID == topic.ID select u).Single(); foreach (var t in topic.listTopics) { var to = (from u in _context.dbTopic.Include("listTopics") where u.ID == t.ID select u).Single(); if (!to.listTopics.Contains(a)) { to.listTopics.Add(a); } else { continue; } } a.Text = topic.Text; a.Width = topic.Width; a.Height = topic.Height; a.X = topic.X; a.Y = topic.Y; if (a.mindMap == null) { a.mindMap = (from u in _context.dbMM where u.ID == topic.mindMap.ID select u).Single(); } _context.SaveChanges(); return(true); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="id">主键编号</param> /// <param name="articletitle">标题</param> /// <param name="TopicClassId">资讯大类别</param> public InfoArticleBase(string id, string articletitle, TopicClass TopicClassId) { this.ID = id; this.ArticleTitle = articletitle; this.TopicClassId = TopicClassId; }