private async void ButtonPatientViewHealOperationReplaceOrgan_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = WPFCustomMessageBox.CustomMessageBox.ShowYesNoCancel("Заменить повреждение органом или протезом?", "", "Орган", "Протез", "Отменить"); Database.Organ operatingOrgan = (DataGridPatientViewHealOperationWounds.SelectedItem as HealingDetails.Wound).Organ; switch (result) { case MessageBoxResult.Yes: // Install organ List <Database.Organ> organsList = (await Economics.Exchange.GetUserItems(1, operatingOrgan.Slot)) .Cast <Database.Organ>().ToList(); if (organsList.Count <= 0) { if (WPFCustomMessageBox.CustomMessageBox.ShowYesNo("К сожалению, на складе нет подходящих органов. Просмотреть протезы?", "", "Да", "Нет, отменить") == MessageBoxResult.Yes) { goto case MessageBoxResult.No; } } else { if (WPFCustomMessageBox.CustomMessageBox.ShowYesNo("Есть подходящий орган. Провести установку?", "", "Да", "Нет, отменить") == MessageBoxResult.Yes) { if (operatingOrgan.IsAugmented) { new AugmentationDetails(AugmentationType.Primary, AugmentationAction.Remove, _target: operatingOrgan).Execute(); } new AugmentationDetails(AugmentationType.Organ, AugmentationAction.Remove, _target: operatingOrgan).Execute(); new AugmentationDetails(AugmentationType.Organ, AugmentationAction.Install, _implant: organsList[0]).Execute(); Database.Controller.SaveCharacters(); DisplayCharacter(); if (DataGridPatientViewHealOperationWounds.SelectedItem is HealingDetails.Wound) { wounds.RemoveAll((HealingDetails.Wound wound) => { return(wound.OrganSlot == operatingOrgan.SlotString); }); } UpdateDataGridPatientViewHealOperationData(); } } break; case MessageBoxResult.No: // Install augment AugmentRequest augWindow = await AugmentRequest.CreateInstance(1, operatingOrgan.Slot, true); bool requestResult = augWindow.ShowDialog().GetValueOrDefault(false); if (requestResult) { AugmentationDetails augmentation = new AugmentationDetails(AugmentationType.Primary, AugmentationAction.Install, _implant: augWindow.Selection); augmentation.Execute(); Database.Controller.SaveCharacters(); DisplayCharacter(); if (DataGridPatientViewHealOperationWounds.SelectedItem is HealingDetails.Wound) { wounds.RemoveAll((HealingDetails.Wound wound) => { return(wound.OrganSlot == selectedOrgan.SlotString); }); } } break; } }
private async void ButtonPatientViewAddImplant_Click(object sender, RoutedEventArgs e) { AugmentRequest augWindow = await AugmentRequest.CreateInstance(2); bool result = augWindow.ShowDialog().GetValueOrDefault(false); if (result) { new AugmentationDetails(AugmentationType.Auxilary, AugmentationAction.Install, _implant: augWindow.Selection).Execute(); } }
private async void Augmentate_Click(object sender, RoutedEventArgs e) { if (DatagridOrgans.SelectedItem is Organ organ) { try { AugmentRequest augWindow = await AugmentRequest.CreateInstance(1, organ.Slot); if (augWindow.ShowDialog().GetValueOrDefault(false)) { new AugmentationDetails(AugmentationType.Primary, AugmentationAction.Install, _implant: augWindow.Selection).Execute(); } } catch (OperationCanceledException) { } } UpdateGrids(); }
private async void ButtonPatientViewInstallOrgan_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = WPFCustomMessageBox.CustomMessageBox.ShowYesNoCancel("Провести установку органа или протеза?", "", "Орган", "Протез", "Отменить установку"); switch (result) { case MessageBoxResult.Yes: // Install organ List <Database.Organ> organsList = (await Economics.Exchange.GetUserItems(1, selectedOrgan.Slot, selectedOrgan.Race)).Cast <Database.Organ>().ToList(); if (organsList.Count <= 0) { if (WPFCustomMessageBox.CustomMessageBox.ShowYesNo("К сожалению, на складе нет подходящих органов. Просмотреть протезы?", "", "Да", "Нет, отменить") == MessageBoxResult.Yes) { goto case MessageBoxResult.No; } } else { if (WPFCustomMessageBox.CustomMessageBox.ShowYesNo("Есть подходящий орган. Провести установку?", "", "Да", "Нет, отменить") == MessageBoxResult.Yes) { AugmentationDetails augmentation = new AugmentationDetails(AugmentationType.Organ, AugmentationAction.Install, _implant: organsList[0]); augmentation.Execute(); Database.Controller.SaveCharacters(); DisplayCharacter(); } } break; case MessageBoxResult.No: // Install augment AugmentRequest augWindow = await AugmentRequest.CreateInstance(1, selectedOrgan.Slot, true); bool requestResult = augWindow.ShowDialog().GetValueOrDefault(false); if (requestResult) { AugmentationDetails augmentation = new AugmentationDetails(AugmentationType.Primary, AugmentationAction.Install, _implant: augWindow.Selection); augmentation.Execute(); Database.Controller.SaveCharacters(); DisplayCharacter(); } break; } }
private async void OrganClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { Database.Organ organ = Database.Controller.SelectedCharacter.GetOrgan(GetSlotByImageEntity(sender as Image)); selectedOrgan = organ; try { switch (CurrentOrganClickAction) { case OrganClickAction.DisplayOrganInfo: textblockPatientOrganName.Text = organ.Name; textblockPatientOrganDescription.Text = organ.Description; // If there is no organ, we should be able to install it if (organ.Virtual) { ButtonPatientViewInstallOrgan.Visibility = Visibility.Visible; } else { ButtonPatientViewInstallOrgan.Visibility = Visibility.Collapsed; } if (organ.IsAugmented) { Database.Augment aug = organ.AugmentEquivalent; textblockPatientOrganAugName.Text = aug.Name; textblockPatientOrganAugDescription.Text = aug.Description; textblockPatientOrganAugSlotType.Text = organ.Name; datagridPatientOrganAugParams.Items.Clear(); foreach (KeyValuePair <string, string> pair in aug.AllCustomParameters ?? new Dictionary <string, string>()) { datagridPatientOrganAugParams.Items.Add(pair); } textblockPatientOrganAugmentNotifier.Visibility = Visibility.Visible; rectanglePatientOrganAug.Visibility = Visibility.Collapsed; } else { textblockPatientOrganAugmentNotifier.Visibility = Visibility.Collapsed; rectanglePatientOrganAug.Visibility = Visibility.Visible; } rectanglePatientOrgan.Visibility = Visibility.Collapsed; break; case OrganClickAction.WoundInput: wounds.Add(new HealingDetails.Wound(organ, WoundSelection.SelectWound())); UpdateDataGridPatientViewHealOperationData(); ButtonPatientViewHealOperationBegin.IsEnabled = true; break; case OrganClickAction.RemoveOrgan: if (organ.Virtual) { WPFCustomMessageBox.CustomMessageBox.ShowOK("Здесь нет органа.", "", "ОК"); } else if (organ.IsAugmented) { if (organ.AugmentEquivalent.IsReplacement) { if (WPFCustomMessageBox.CustomMessageBox.ShowYesNo("Удалить выбранный протез?", "", "Да", "Нет") == MessageBoxResult.Yes) { new AugmentationDetails(AugmentationType.Primary, AugmentationAction.Remove, _target: organ).Execute(); SwitchOperationMode(OrganClickAction.DisplayOrganInfo); } else { WPFCustomMessageBox.CustomMessageBox.ShowOK("Нельзя удалить аугментированный орган. Сначала удалите аугмент.", "", "Понятно"); } } DisplayCharacter(Database.Controller.SelectedCharacter); } else if (WPFCustomMessageBox.CustomMessageBox.ShowYesNo("Удалить выбранный орган?", "", "Да", "Нет") == MessageBoxResult.Yes) { new AugmentationDetails(AugmentationType.Organ, AugmentationAction.Remove, _target: organ).Execute(); DisplayCharacter(); SwitchOperationMode(OrganClickAction.DisplayOrganInfo); } break; case OrganClickAction.AugmentateOrgan: if (organ.Virtual) // No organ { WPFCustomMessageBox.CustomMessageBox.ShowOK("Здесь нет органа.", "", "ОК"); } else if (organ.IsAugmented) // Either augmented or replaced organ { if (organ.AugmentEquivalent.IsReplacement) { WPFCustomMessageBox.CustomMessageBox.ShowOK("Протез извлечь нельзя. Необходимо воспользоваться операцией удаления органа.", "", "Понятно"); } else if (WPFCustomMessageBox.CustomMessageBox.ShowYesNo("Извлечь аугмент из органа?", "", "Да", "Назад") == MessageBoxResult.Yes) { new AugmentationDetails(AugmentationType.Primary, AugmentationAction.Remove, _target: organ).Execute(); DisplayCharacter(); SwitchOperationMode(OrganClickAction.DisplayOrganInfo); } } else // Just an organ { if (WPFCustomMessageBox.CustomMessageBox.ShowYesNo("Выберите аугмент для установки.", "", "ОК", "Отменить") == MessageBoxResult.Yes) { AugmentRequest augWindow = await AugmentRequest.CreateInstance(1, selectedOrgan.Slot); bool result = augWindow.ShowDialog().GetValueOrDefault(false); if (result) { new AugmentationDetails(AugmentationType.Primary, AugmentationAction.Install, _implant: augWindow.Selection).Execute(); } else { WPFCustomMessageBox.CustomMessageBox.ShowOK("Установка аугмента отменена.", "", "ОК"); } DisplayCharacter(); } SwitchOperationMode(OrganClickAction.DisplayOrganInfo); } break; case OrganClickAction.ReplaceOrgan: break; } } catch (OperationCanceledException) { } }