private void New_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp"; if (!ofd.ShowDialog().GetValueOrDefault(false)) { return; } MessageBox.Show("Enter the name of the map."); LabelNameWindow nameWindow = new LabelNameWindow(); if (!nameWindow.ShowDialog().GetValueOrDefault(false)) { return; } this.MapDisplay.MapLandmarks.Clear(); this.MapDisplay.MapLandmarks.MapName = nameWindow.EnteredText; this.MapDisplay.SetMapImageFromFile(ofd.FileName); }
void MapDisplay_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (!this.MapDisplay.IsReady) { return; } var mousePos = e.GetPosition(this.MapDisplay); LabelNameWindow nameWindow = new LabelNameWindow(); if (nameWindow.ShowDialog().Value) { MapLandmark newLandmark = new MapLandmark(); newLandmark.Name = nameWindow.EnteredText; var mapTransform = this.MapDisplay.CalculateMapTransform(); var mapPoint = mapTransform.Inverse.Transform(mousePos); newLandmark.Position = new System.Drawing.Point((int)mapPoint.X, (int)mapPoint.Y); this.MapDisplay.MapLandmarks.Add(newLandmark); } }