Advertisement
Guest User

Untitled

a guest
Jul 9th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using thesis.core;
  5. using System.Collections.Generic;
  6.  
  7. namespace thesis.visualisation
  8. {
  9.     public class LevelViewForm : Form
  10.     {
  11.         private CellularLevel level;
  12.         private List<FloorDrawPanel> renderingPanels = new List<FloorDrawPanel>();
  13.         private FlowLayoutPanel layoutPanel = new FlowLayoutPanel();
  14.        
  15.         public LevelViewForm (CellularLevel level)
  16.         {
  17.             this.level = level;
  18.            
  19.             this.layoutPanel.SuspendLayout();
  20.             this.SuspendLayout();
  21.             this.ClientSize = new Size(1024,768);
  22.             this.layoutPanel.WrapContents = true;
  23.             this.layoutPanel.FlowDirection = FlowDirection.LeftToRight;
  24.             this.layoutPanel.Location = new System.Drawing.Point(0, 0);
  25.            
  26.             for (int i = level.z - 1; i >= 0; --i) {
  27.                 Console.WriteLine("level {0}",i);
  28.                 FloorDrawPanel fp = new FloorDrawPanel(level,i);
  29.                 fp.Location = new Point(100 * i,100*i);
  30.                 fp.TabIndex = i;
  31.                 this.renderingPanels.Add(fp);
  32.                 this.layoutPanel.Controls.Add(fp);
  33.             }
  34.             this.layoutPanel.Controls.Add(new FloorDrawPanel(level,1));                                      
  35.             this.Controls.Add(layoutPanel);
  36.             this.layoutPanel.ResumeLayout(false);
  37.             this.ResumeLayout(false);          
  38.         }
  39.        
  40.         protected override void OnPaint (PaintEventArgs e)
  41.         {
  42.             Console.WriteLine("base paint");
  43.             foreach (FloorDrawPanel pan in renderingPanels) {
  44.                 pan.Invalidate();
  45.             }
  46.             base.OnPaint (e);
  47.         }
  48.     }
  49. }
  50.  
  51. using System;
  52. using System.Drawing;
  53. using System.Windows.Forms;
  54. using thesis.core;
  55.  
  56. namespace thesis.visualisation
  57. {
  58.     public class FloorDrawPanel : Panel
  59.     {
  60.         private int z;
  61.         private CellularLevel level;
  62.        
  63.         public FloorDrawPanel (CellularLevel level,int z)
  64.         {
  65.             this.level = level;
  66.             this.z = z;
  67.             this.Size = new Size(100,100);
  68.             this.ClientSize = new Size(100,100);
  69.         }
  70.        
  71.         protected override void OnPaint (PaintEventArgs e)
  72.         {
  73.             Console.WriteLine("painting {0}",z.ToString());
  74.             e.Graphics.DrawString(z.ToString(),new Font(FontFamily.GenericSansSerif,10.5f),new SolidBrush(Color.Black),10 * z,0);
  75.             //e.Graphics.DrawLine(new Pen(col,10),new Point(0,0),new Point(100,100));
  76.         }
  77.        
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement