Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void MainForm_Paint(object sender, PaintEventArgs e)
- {
- const int r = 15;
- e.Graphics.Clear(SystemColors.Control);
- foreach (Node n in this.nodes.Values)
- {
- // ロックされているノードは赤くする
- Brush br = this.nodes.IsLocked(n)
- ? Brushes.Red
- : Brushes.Green;
- // ノードは、n.R を中心とする半径 r の円で表す
- e.Graphics.FillEllipse(br,
- ToScreenX(n.R.X) - r, ToScreenY(n.R.Y) - r,
- 2 * r, 2 * r);
- // 円の中にノード名を描く
- e.Graphics.DrawString(n.Name,
- SystemFonts.DefaultFont, Brushes.White,
- ToScreenX(n.R.X) - r / 2, ToScreenY(n.R.Y) - r / 2);
- foreach (Node nn in n.Neighbors)
- {
- // エッジは、ノードの中心をつなぐ直線で表す
- e.Graphics.DrawLine(Pens.Black,
- ToScreenX(n.R.X), ToScreenY(n.R.Y),
- ToScreenX(nn.R.X), ToScreenY(nn.R.Y));
- }
- }
- }
Add Comment
Please, Sign In to add comment