private void newConfigurationToolStripMenuItem_Click(object sender, EventArgs e) { this.grid.CreateGraphics().Clear(Color.FromKnownColor(KnownColor.Control)); var s = Grid.GetSizeOfGrid(Properties.Settings.Default.GridSize); g = new Grid(Properties.Settings.Default.GridSize); this.Size = new Size(s.Width + 21, s.Height + 90); Timer t = new Timer(); t.Interval = 100; t.Tick += new EventHandler((_sender, _e) => { t.Stop(); g.BlockBorders(this.grid); g.Draw(this.grid.CreateGraphics()); __last_valid_grid_block = g.abs2grid(g.AgentPoint); MarkStartPointGrid_Click(new object(), new EventArgs()); __last_valid_grid_block = g.abs2grid(g.GoalPoint); MarkGoalPointGrid_Click(new object(), new EventArgs()); }); t.Start(); }
public GridForm() { InitializeComponent(); /** * Draw the grid */ Size gridSize = Properties.Settings.Default.GridSize; Size s = Grid.GetSizeOfGrid(gridSize); this.grid.Image = new Bitmap(s.Width + 1, s.Height + 1, this.grid.CreateGraphics()); using (Graphics gfx = Graphics.FromImage(this.grid.Image)) { g = new Grid(gridSize); g.Draw(gfx); this.Size = new Size(s.Width + 21, s.Height + 90); } /** * */ this.Load += new EventHandler((sender, e) => { Timer t = new Timer(); t.Interval = 100; t.Tick += new EventHandler((_sender, _e) => { t.Stop(); g.BlockBorders(this.grid); }); t.Start(); }); this.KeyPreview = true; this.KeyDown += new KeyEventHandler((sender, e) => { switch (e.KeyCode) { case Keys.Escape: System.Diagnostics.Process.GetCurrentProcess().Kill(); break; } }); this.grid.MouseMove += new MouseEventHandler((sender, e) => { if (this.__NearBySearchTimer != null) this.__NearBySearchTimer.Stop(); else { this.__NearBySearchTimer = new Timer(); this.__NearBySearchTimer.Interval = 15; this.__NearBySearchTimer.Tick += new EventHandler((__sender, __e) => { var p = (Point)this.__NearBySearchTimer.Tag; if (g.GetNearByLineInfo(this.grid, p).Value.A != 0) Cursor.Current = Cursors.Hand; else Cursor.Current = Cursors.Default; }); } if (g.GetNearByLineInfo(this.grid, e.Location).Value.A != 0) Cursor.Current = Cursors.Hand; this.__NearBySearchTimer.Tag = e.Location; this.__NearBySearchTimer.Start(); }); this.grid.MouseDown += new MouseEventHandler(grid_MouseDown); this.toolStripStatus.TextChanged += new EventHandler((sende, e) => { bool internal_change = false; if (internal_change) { internal_change = false; return; } if (this.toolStripStatus.Tag != null) (this.toolStripStatus.Tag as Timer).Stop(); Timer t = new Timer(); t.Interval = 4000; t.Tick += new EventHandler((_s, _e) => { t.Stop(); internal_change = true; this.toolStripStatus.Tag = null; this.toolStripStatus.Text = ""; }); t.Start(); this.toolStripStatus.Tag = t; }); if (System.IO.File.Exists("config.dat")) loadConfigurationToolStripMenuItem_Click(new object(), new EventArgs()); else newConfigurationToolStripMenuItem_Click(new object(), new EventArgs()); #if __DEBUG_PLOT__ loadToolStripMenuItem_Click(new object(), new EventArgs()); tDLambdaProgressShowToolStripMenuItem_Click(new object(), new EventArgs()); #endif }