private void ConfirmClick(object sender, RoutedEventArgs e) { if (Editor.Count == 0) { MessageBox.Show("Trasa jest pusta. Stwórz trasę lub wybierz 'Anuluj'.", "Błąd", MessageBoxButton.OK); return; } switch (TypeComboBox.SelectedIndex) { case 0: Result = new Plane(Editor.Route); break; case 1: Result = new Helicopter(Editor.Route); break; case 2: Result = new Glider(Editor.Route); break; case 3: Result = new Balloon(Editor.Route); break; default: MessageBox.Show("Wybierz rodzaj statku.", "Błąd", MessageBoxButton.OK); return; } Editor = null; Close(); }
public void Dispose() { PreviewImage.MouseLeftButtonDown -= ImageLeftClick; PreviewImage.MouseRightButtonDown -= ImageRightClick; ConfirmButton.Click -= ConfirmClick; CancelButton.Click -= CancelClick; UndoButton.Click -= UndoClick; HelpButton.Click -= HelpClick; Editor = null; }
unsafe public AdditionWindow(WriteableBitmap mapBitmap, WriteableBitmap routesBitmap, WriteableBitmap aircraftsBitmap) { InitializeComponent(); TypeComboBox.Items.Add("Samolot"); TypeComboBox.Items.Add("Helikopter"); TypeComboBox.Items.Add("Szybowiec"); TypeComboBox.Items.Add("Balon"); BackgroundBitmap = new WriteableBitmap(mapBitmap.PixelWidth, mapBitmap.PixelHeight, 96, 96, PixelFormats.Bgra32, null); BackgroundImage.Source = BackgroundBitmap; PreviewBitmap = new WriteableBitmap(mapBitmap.PixelWidth, mapBitmap.PixelHeight, 96, 96, PixelFormats.Bgra32, null); PreviewImage.Source = PreviewBitmap; uint *pDest = (uint *)BackgroundBitmap.BackBuffer, pEnd = pDest + BackgroundBitmap.PixelWidth * BackgroundBitmap.PixelHeight; uint *pAircrafts = (uint *)aircraftsBitmap.BackBuffer; uint *pRoutes = (uint *)routesBitmap.BackBuffer; uint *pMap = (uint *)mapBitmap.BackBuffer; for (; pDest < pEnd; ++pDest) { //Nakładamy na siebie 3 warstwy bitmap. *pDest = *pAircrafts; if (*pDest == 0) { *pDest = *pRoutes; } if (*pDest == 0) { *pDest = *pMap; } ++pAircrafts; ++pRoutes; ++pMap; } BackgroundBitmap.Lock(); BackgroundBitmap.AddDirtyRect(new Int32Rect(0, 0, BackgroundBitmap.PixelWidth, BackgroundBitmap.PixelHeight)); BackgroundBitmap.Unlock(); Editor = new Flight.Editor(); }
private void CancelClick(object sender, RoutedEventArgs e) { Editor = null; Close(); }