public PolygonWindow(Polygon newPolygon) { InitializeComponent(); DataContext = this; foreach (PropertyInfo property in typeof(System.Drawing.Color).GetProperties(BindingFlags.Static | BindingFlags.Public)) { if (property.PropertyType == typeof(System.Drawing.Color)) { ComboBoxContour.Items.Add(property.Name); ComboBoxRemplissage.Items.Add(property.Name); } } _temp = newPolygon; Remplissage = MainWindow.GetColorName(newPolygon.RemplissageColor); Contour = MainWindow.GetColorName(newPolygon.ContourColor); StringOpacite = newPolygon.Opacite.ToString(); Latitude = "0,000"; Longitude = "0,000"; Description = newPolygon.Description; foreach (Coordonnees c in newPolygon.Collection) { ListBoxCoordonnees.Items.Add(c.ToString()); } hasAppliquerBeenClicked = true; modifier = true; ListBoxCoordonnees.SelectedIndex = 0; }
private void ButtunOk_Click(object sender, RoutedEventArgs e) { if (hasAppliquerBeenClicked) { _polygon = _temp; Hide(); } }
public UpdateWindow(ICartoObj receivedObj) { InitializeComponent(); TblkType.Text = receivedObj.GetType().Name + " #" + ((CartoObj)receivedObj).Id; TbDescription.Text = receivedObj.Description; switch (receivedObj.GetType().Name) { case "POI": POI receivedPOI = (POI)receivedObj; SaveReceivedObj = new POI(receivedPOI); SaveReceivedObj.Tag = receivedPOI.Tag; ReceivedObj = receivedPOI; CpStroke.IsEnabled = false; TbLatitude.Text = receivedPOI.Latitude.ToString(); TbLongitude.Text = receivedPOI.Longitude.ToString(); CpStroke.Background = Brushes.Gray; CpFill.SelectedColor = receivedPOI.Fill; break; case "Polyline": MyCartographyObjects.Polyline receivedPolyline = (MyCartographyObjects.Polyline)receivedObj; SaveReceivedObj = new MyCartographyObjects.Polyline(receivedPolyline); SaveReceivedObj.Tag = receivedPolyline.Tag; ReceivedObj = receivedPolyline; CpFill.IsEnabled = false; TbLatitude.IsEnabled = false; CpFill.IsEnabled = false; TbLatitude.Background = Brushes.Gray; TbLongitude.Background = Brushes.Gray; CpFill.Background = Brushes.Gray; CpStroke.SelectedColor = receivedPolyline.Stroke; break; case "Polygon": MyCartographyObjects.Polygon receivedPolygon = (MyCartographyObjects.Polygon)receivedObj; SaveReceivedObj = new MyCartographyObjects.Polygon(receivedPolygon); SaveReceivedObj.Tag = receivedPolygon.Tag; ReceivedObj = receivedPolygon; TbLatitude.IsEnabled = false; TbLongitude.IsEnabled = false; TbLatitude.Background = Brushes.Gray; TbLongitude.Background = Brushes.Gray; CpFill.SelectedColor = receivedPolygon.Fill; CpStroke.SelectedColor = receivedPolygon.Stroke; break; } }
//Méthodes private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (!modifier) { _polygon = null; } else { Polygon = _temp; } }
private void ButtonAppliquer_Click(object sender, RoutedEventArgs e) { if (_temp == null) { _temp = new MyCartographyObjects.Polygon(); } _temp.ContourColor = (Color)ColorConverter.ConvertFromString(Contour); _temp.RemplissageColor = (Color)ColorConverter.ConvertFromString(Remplissage); _temp.Opacite = Opacite; _temp.Description = Description; hasAppliquerBeenClicked = true; }
private void MainWindow_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && Keyboard.IsKeyDown(Key.LeftCtrl)) // CTRL + Enter { if (IsDrawingTravel) { MyCartographyObjects.Polyline newPolyline = new MyCartographyObjects.Polyline(CurrentTravel); MapData.Add(newPolyline); MapPolyline currentTravelMapPolyline = (MapPolyline)(CurrentTravel.Tag); MapPolyline newMapPolyline = new MapPolyline() { Stroke = currentTravelMapPolyline.Stroke, StrokeThickness = currentTravelMapPolyline.StrokeThickness, Opacity = currentTravelMapPolyline.Opacity, Locations = new LocationCollection() }; foreach (Location location in currentTravelMapPolyline.Locations) { newMapPolyline.Locations.Add(location); } MyMap.Children.Add(newMapPolyline); newPolyline.Tag = newMapPolyline; ResetCurrentTravel(); } else if (IsDrawingSurface) { MyCartographyObjects.Polygon newPolygon = new MyCartographyObjects.Polygon(CurrentSurface); MapData.Add(newPolygon); MapPolygon currentSurfaceMapPolygon = (MapPolygon)(CurrentSurface.Tag); MapPolygon newMapPolygon = new MapPolygon() { Fill = currentSurfaceMapPolygon.Fill, Stroke = currentSurfaceMapPolygon.Stroke, StrokeThickness = currentSurfaceMapPolygon.StrokeThickness, Opacity = currentSurfaceMapPolygon.Opacity, Locations = new LocationCollection() }; foreach (Location location in currentSurfaceMapPolygon.Locations) { newMapPolygon.Locations.Add(location); } MyMap.Children.Add(newMapPolygon); newPolygon.Tag = newMapPolygon; ResetCurrentSurface(); } } }
private void Modifier_Click(object sender, RoutedEventArgs e) { if (myPersonalMapData.ObservableCollection.Count == 0) { return; } int position = ListBox.SelectedIndex; ICartoObj i = myPersonalMapData.ObservableCollection.ElementAt(position); if (i is POI) { POI p = i as POI; PoiWindow poiWindow = new PoiWindow(p); poiWindow.ShowDialog(); myPersonalMapData.ObservableCollection[position] = poiWindow.Poi; ListBox.SelectedIndex = position; poiWindow.Close(); } if (i is Polyline) { Polyline p = i as Polyline; PolylineWindow polylineWindow = new PolylineWindow(p); polylineWindow.ShowDialog(); myPersonalMapData.ObservableCollection[position] = polylineWindow.Polyline; ListBox.SelectedIndex = position; polylineWindow.Close(); } if (i is Polygon) { Polygon p = i as Polygon; PolygonWindow polygonWindow = new PolygonWindow(p); polygonWindow.ShowDialog(); myPersonalMapData.ObservableCollection[position] = polygonWindow.Polygon; ListBox.SelectedIndex = position; polygonWindow.Close(); } UpdateMainWindow(); }
public MappingWindow(MyPersonnalMapData mapData) { InitializeComponent(); MapData = mapData; CurrentTravel = new MyCartographyObjects.Polyline(); CurrentTravel.Tag = new MapPolyline() { Stroke = new SolidColorBrush(CurrentTravel.Stroke), StrokeThickness = CurrentTravel.Thickness, Opacity = CurrentTravel.Opacity, Locations = new LocationCollection() }; CurrentSurface = new MyCartographyObjects.Polygon(); CurrentSurface.Tag = new MapPolygon() { Fill = new SolidColorBrush(CurrentSurface.Fill), Stroke = new SolidColorBrush(CurrentSurface.Stroke), StrokeThickness = CurrentSurface.Thickness, Opacity = CurrentSurface.Opacity, Locations = new LocationCollection() }; string sessionFileFullPath = MyPersonnalMapData.BINARIES_DIR + "\\" + MapData.GetSessionFilename(); if (File.Exists(sessionFileFullPath)) // If the user has a session file { LoadBinaryFile(MyPersonnalMapData.BINARIES_DIR + "\\" + MapData.GetSessionFilename()); } else { File.WriteAllText(sessionFileFullPath, ""); // If not, we create a new file without any data } UpdateLbCartographyObjectsItemsSource(); }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { ReceivedObj.Description = SaveReceivedObj.Description; if (ReceivedObj is POI receivedPOI) { POI savedPOI = SaveReceivedObj as POI; receivedPOI.Latitude = savedPOI.Latitude; receivedPOI.Longitude = savedPOI.Longitude; receivedPOI.Fill = savedPOI.Fill; Pushpin receivedPushpin = (Pushpin)receivedPOI.Tag; receivedPushpin.Location.Latitude = savedPOI.Latitude; receivedPushpin.Location.Longitude = savedPOI.Longitude; receivedPushpin.Background = new SolidColorBrush(savedPOI.Fill); } else if (ReceivedObj is MyCartographyObjects.Polyline receivedPolyline) { MyCartographyObjects.Polyline savedPolyline = SaveReceivedObj as MyCartographyObjects.Polyline; receivedPolyline.Stroke = savedPolyline.Stroke; MapPolyline mapPolyline = (MapPolyline)receivedPolyline.Tag; mapPolyline.Stroke = new SolidColorBrush(savedPolyline.Stroke); } else if (ReceivedObj is MyCartographyObjects.Polygon receivedPolygon) { MyCartographyObjects.Polygon savedPolygon = SaveReceivedObj as MyCartographyObjects.Polygon; receivedPolygon.Fill = savedPolygon.Fill; receivedPolygon.Stroke = savedPolygon.Stroke; MapPolygon mapPolygon = (MapPolygon)receivedPolygon.Tag; mapPolygon.Fill = new SolidColorBrush(savedPolygon.Fill); mapPolygon.Stroke = new SolidColorBrush(savedPolygon.Stroke); } send?.Invoke(); Close(); }
public void UpdateMainWindow() { if (myPersonalMapData != null) { Map.Children.Clear(); ListBox.Items.Clear(); foreach (ICartoObj i in myPersonalMapData.ObservableCollection) { if (i is POI) { POI p = i as POI; Pushpin pushpin = new Pushpin(); pushpin.Opacity = 0.7; pushpin.Location = new Location(p.Latitude, p.Longitude); ListBox.Items.Add("POI: " + p.Description); pushpin.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue); Map.Children.Add(pushpin); } if (i is Polyline) { Polyline p = i as Polyline; MapPolyline mapPolyline = new MapPolyline(); mapPolyline.Opacity = 0.7; mapPolyline.StrokeThickness = p.Epaisseur; ListBox.Items.Add("Trajet: " + p.Description); mapPolyline.Stroke = new SolidColorBrush(p.Color); mapPolyline.Locations = new LocationCollection(); foreach (object obj in p.Collection) { if (obj is POI) { POI poi = obj as POI; Pushpin pushpin = new Pushpin(); pushpin.Opacity = 0.7; pushpin.Location = new Location(poi.Latitude, poi.Longitude); pushpin.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green); Map.Children.Add(pushpin); } mapPolyline.Locations.Add(new Location(((Coordonnees)obj).Latitude, ((Coordonnees)obj).Longitude)); } Map.Children.Add(mapPolyline); } if (i is Polygon) { Polygon p = i as Polygon; MapPolygon mapPolygon = new MapPolygon(); mapPolygon.Opacity = 0.7; mapPolygon.StrokeThickness = 3; ListBox.Items.Add("Surface: " + p.Description); mapPolygon.Fill = new System.Windows.Media.SolidColorBrush(p.RemplissageColor); mapPolygon.Stroke = new System.Windows.Media.SolidColorBrush(p.ContourColor); mapPolygon.Locations = new LocationCollection(); foreach (Coordonnees coords in p.Collection) { mapPolygon.Locations.Add(new Location(coords.Latitude, coords.Longitude)); } Map.Children.Add(mapPolygon); } } for (int i = 0; i < collectionCoordonnees.Count; i++) { if (collectionCoordonnees[i] is POI) { POI poi = (POI)collectionCoordonnees[i]; Pushpin pushpin = new Pushpin(); pushpin.Opacity = 0.7; pushpin.Location = new Location(poi.Latitude, poi.Longitude); pushpin.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Green); Map.Children.Add(pushpin); } else if (collectionCoordonnees[i] is Coordonnees) { Coordonnees coordonnees = collectionCoordonnees[i]; Pushpin pushpin = new Pushpin(); pushpin.Opacity = 0.7; pushpin.Location = new Location(coordonnees.Latitude, coordonnees.Longitude); pushpin.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Red); Map.Children.Add(pushpin); } } } ListBox.SelectedIndex = ListBox.Items.Count - 1; }