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 "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;
            }
        }