Ejemplo n.º 1
0
        private void ddlWeaponFamilyMakeModel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string selectedDDLValue = (((ComboBox)sender).SelectedValue != null) ? ((ComboBox)sender).SelectedValue.ToString() : string.Empty;

            //I know I could have simplified this with a DataTemplate or using the same DDLS for everything but cest la vie
            //Maybe on a saturday I'll refactor.
            switch (((ComboBox)sender).Name)
            {
            case "ddlDPSCalc_Family":
                ddlDPSCalc_Make.ItemsSource = WeaponModel.GetWeaponMakesByFamily(weaponList, selectedDDLValue);
                ddlDPSCalc_Make.IsEnabled   = true;
                if (!lvDPSCalc_CompareView.HasItems)
                {
                    wpDPSCalc_Controls.Visibility = Visibility.Collapsed;
                }
                btnDPSCalc_Add.IsEnabled = false;

                chkDPSCalc_CustomMagSize.IsChecked = false;
                chkDPSCalc_CustomReload.IsChecked  = false;
                chkDPSCalc_CustomRPM.IsChecked     = false;
                chkDPSCalc_CustomMagSize.IsEnabled = false;
                chkDPSCalc_CustomReload.IsEnabled  = false;
                chkDPSCalc_CustomRPM.IsEnabled     = false;
                txtDPSCalc_GunDmg.IsEnabled        = false;
                txtDPSCalc_MagSize.IsEnabled       = false;
                txtDPSCalc_Reload.IsEnabled        = false;
                txtDPSCalc_RPM.IsEnabled           = false;

                break;

            case "ddlDPSCalc_Make":
                ddlDPSCalc_Model.ItemsSource = (String.IsNullOrEmpty(selectedDDLValue)) ? null : WeaponModel.GetWeaponModelsByMake(weaponList, ddlDPSCalc_Family.SelectedValue.ToString(), selectedDDLValue);
                ddlDPSCalc_Model.IsEnabled   = (String.IsNullOrEmpty(selectedDDLValue)) ? false : true;
                if (!lvDPSCalc_CompareView.HasItems)
                {
                    wpDPSCalc_Controls.Visibility = Visibility.Collapsed;
                }
                btnDPSCalc_Add.IsEnabled = false;

                chkDPSCalc_CustomMagSize.IsChecked = false;
                chkDPSCalc_CustomReload.IsChecked  = false;
                chkDPSCalc_CustomRPM.IsChecked     = false;
                chkDPSCalc_CustomMagSize.IsEnabled = false;
                chkDPSCalc_CustomReload.IsEnabled  = false;
                chkDPSCalc_CustomRPM.IsEnabled     = false;
                txtDPSCalc_GunDmg.IsEnabled        = false;
                txtDPSCalc_MagSize.IsEnabled       = false;
                txtDPSCalc_Reload.IsEnabled        = false;
                txtDPSCalc_RPM.IsEnabled           = false;

                break;

            case "ddlDPSCalc_Model":

                if (!String.IsNullOrEmpty(selectedDDLValue))
                {
                    WeaponModel selectedModel = (WeaponModel)weaponList.Where(x => x.Model == selectedDDLValue).ToArray()[0];
                    txtDPSCalc_MagSize.Text  = selectedModel.MagSize.ToString();
                    txtDPSCalc_RPM.Text      = selectedModel.RPM.ToString();
                    txtDPSCalc_Reload.Text   = selectedModel.ReloadSpeed.ToString();
                    btnDPSCalc_Add.IsEnabled = true;

                    chkDPSCalc_CustomMagSize.IsEnabled = true;
                    chkDPSCalc_CustomReload.IsEnabled  = true;
                    chkDPSCalc_CustomRPM.IsEnabled     = true;
                    txtDPSCalc_GunDmg.IsEnabled        = true;
                    txtDPSCalc_MagSize.IsEnabled       = false;
                    txtDPSCalc_Reload.IsEnabled        = false;
                    txtDPSCalc_RPM.IsEnabled           = false;

                    if (!lvDPSCalc_CompareView.HasItems)
                    {
                        wpDPSCalc_Controls.Visibility   = Visibility.Visible;
                        btnDPSCalc_Clear.Visibility     = Visibility.Collapsed;
                        btnDPSCalc_Remove.Visibility    = Visibility.Collapsed;
                        btnDPSCalc_Calculate.Visibility = Visibility.Collapsed;
                    }
                }

                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        private void ddlWeaponFamilyMakeModel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string selectedDDLValue = (((ComboBox)sender).SelectedValue != null) ? ((ComboBox)sender).SelectedValue.ToString() : string.Empty;

            //I know I could have simplified this with a DataTemplate or using the same DDLS for everything but cest la vie
            //Maybe on a saturday I'll refactor.
            switch (((ComboBox)sender).Name)
            {
            case "ddlFamily":
                ddlMake.ItemsSource = WeaponModel.GetWeaponMakesByFamily(weaponList, selectedDDLValue);
                ddlMake.IsEnabled   = true;

                btnCalculate.Visibility     = Visibility.Hidden;
                lblCalculateRoll.Visibility = Visibility.Hidden;
                spWeaponRoll.Visibility     = Visibility.Hidden;
                lblUpdatedRng.Visibility    = Visibility.Hidden;

                break;

            case "ddlMake":
                ddlModel.ItemsSource = (String.IsNullOrEmpty(selectedDDLValue)) ? null : WeaponModel.GetWeaponModelsByMake(weaponList, ddlFamily.SelectedValue.ToString(), selectedDDLValue);
                ddlModel.IsEnabled   = (String.IsNullOrEmpty(selectedDDLValue)) ? false : true;

                btnCalculate.Visibility     = Visibility.Hidden;
                lblCalculateRoll.Visibility = Visibility.Hidden;
                spWeaponRoll.Visibility     = Visibility.Hidden;
                lblUpdatedRng.Visibility    = Visibility.Hidden;
                break;

            case "ddlModel":

                if (!String.IsNullOrEmpty(selectedDDLValue))
                {
                    selectedWeapon           = WeaponModel.GetWeaponByName(selectedDDLValue);
                    btnCalculate.Visibility  = Visibility.Visible;
                    btnWeaponInfo.Visibility = Visibility.Visible;
                }

                spWeaponRoll.Visibility     = Visibility.Hidden;
                lblUpdatedRng.Visibility    = Visibility.Hidden;
                lblCalculateRoll.Visibility = Visibility.Hidden;

                break;

            default:
                break;
            }
        }