private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { TabMapPoint = new Mapping.Point(e.Location) / Map.TabMap.Aspect; AddWayPointToolStripMenuItem.Visible = Map.PathFinder.WayPoints.Where(wayPoint => wayPoint.Point == new Mapping.Point(e.Location)).Count() <= 0; RemoveWayPointToolStripMenuItem.Visible = !AddWayPointToolStripMenuItem.Visible; TabMapMenu.Show(pictureBox1.PointToScreen(e.Location)); } }
private void LoadMapToolStripMenuItem_Click(object sender, EventArgs e) { using OpenFileDialog ofd = new OpenFileDialog { Filter = "JSON Map Files|*.map.json" }; DialogResult result = ofd.ShowDialog(this); if (result == DialogResult.OK && ofd.FileName.ToLower().EndsWith(".map.json") && ofd.CheckFileExists) { Map = new Map(ofd.FileName); Map.PathFinder.AddWayPoint(new Mapping.Point(5, 5)); Map.PathFinder.AddWayPoint(new Mapping.Point(Map.Bounds.X - 5, 5)); Map.PathFinder.AddWayPoint(new Mapping.Point(Map.Bounds.X - 5, Map.Bounds.Y - 5)); Map.PathFinder.AddWayPoint(new Mapping.Point(5, Map.Bounds.Y - 5)); pictureBox1.Location = new System.Drawing.Point(10, menuStrip1.Size.Height + 10); pictureBox1.Size = new Size(300, 300); Mapping.Point aspect = (new Mapping.Point(pictureBox1.Size) / Map.Bounds); int minAspect = aspect.Min; Map.TabMap.Aspect = new Mapping.Point(minAspect, minAspect); Map.TabMap.Draw(); CheckPictureBox(); } }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { Mapping.Point Point = new Mapping.Point(e.X, e.Y) / Map.TabMap.Aspect; Text = $"Dreamer {Point}"; }