Ejemplo n.º 1
0
 private void ButtonConfirm_Click(object sender, RoutedEventArgs e)
 {
     if (DataGridList.SelectedItem != null)
     {
         Selection    = DataGridList.SelectedItem as Database.Augment;
         DialogResult = true;
         Close();
     }
     else
     {
         WPFCustomMessageBox.CustomMessageBox.ShowOK("Сначала следует выбрать нужный аугмент.", "", "Хорошо");
         ButtonConfirm.IsEnabled = false;
     }
 }
Ejemplo n.º 2
0
 public Augment EjectAugment()
 {
     if (IsAugmented)
     {
         Augment aug = AugmentEquivalent;
         AugmentEquivalent = null;
         if (aug.IsReplacement)
         {
             Virtual = true;
         }
         return(aug);
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
        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) { }
        }