Esempio n. 1
0
        public static void CustomTechTypeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            string newTechType = (string)e.NewValue;

            if (!string.IsNullOrEmpty(newTechType))
            {
                UserControl_TechType ctrl = (UserControl_TechType)o;
                ctrl.TransitionTechType = newTechType;
            }
        }
Esempio n. 2
0
        public static void TransitionTechTypeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            string newTechType = (string)e.NewValue;

            if (!string.IsNullOrEmpty(newTechType))
            {
                UserControl_TechType ctrl = (UserControl_TechType)o;
                if (ctrl != null)
                {
                    if (AllTechTypes.ContainsValue(newTechType))
                    {
                        bool isCustom = true;
                        foreach (KeyValuePair <TechType, string> elem in AllTechTypes)
                        {
                            if (string.Compare(elem.Value, newTechType, false, CultureInfo.InvariantCulture) == 0)
                            {
                                foreach (object item in ctrl.ComboBox_TechType.Items)
                                {
                                    ComboBoxItem boxItem = (ComboBoxItem)item;
                                    if (boxItem != null && !string.IsNullOrEmpty(boxItem.Name) && string.Compare(boxItem.Name, newTechType, true, CultureInfo.InvariantCulture) == 0)
                                    {
#if DEBUG_TECHTYPE_SELECTOR
                                        Logger.Log("DEBUG: Found TechType [{0}] in combobox name=[{1}].", elem.Key.AsString(), boxItem.Name);
#endif
                                        ctrl.ComboBox_TechType.SelectedItem = boxItem;
                                        isCustom = false;
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                        if (isCustom)
                        {
#if DEBUG_TECHTYPE_SELECTOR
                            Logger.Log("DEBUG: TechType [{0}] not found in combobox, adding it as custom TechType.", newTechType);
#endif
                            ctrl.TB_CustomTechTypeName.Text = TryGetTechTypeNameFromId(newTechType);
                            ctrl.CustomTechType             = ctrl.TB_CustomTechTypeName.Text;
                        }
                    }
                    else if (TechTypeExtensions.FromString(newTechType, out TechType techType, true) && techType != TechType.None)
                    {
                        bool isCustom = true;
                        if (AllTechTypes.ContainsKey(techType))
                        {
                            foreach (object item in ctrl.ComboBox_TechType.Items)
                            {
                                ComboBoxItem boxItem = (ComboBoxItem)item;
                                if (boxItem != null && !string.IsNullOrEmpty(boxItem.Name) && string.Compare(boxItem.Name, AllTechTypes[techType], true, CultureInfo.InvariantCulture) == 0)
                                {
#if DEBUG_TECHTYPE_SELECTOR
                                    Logger.Log("DEBUG: Found TechType [{0}] in combobox name=[{1}].", techType.AsString(), boxItem.Name);
#endif
                                    ctrl.ComboBox_TechType.SelectedItem = boxItem;
                                    isCustom = false;
                                    break;
                                }
                            }
                        }
                        if (isCustom)
                        {
#if DEBUG_TECHTYPE_SELECTOR
                            Logger.Log("DEBUG: TechType [{0}] not found in combobox, adding it as custom TechType.", newTechType);
#endif
                            ctrl.TB_CustomTechTypeName.Text = TryGetTechTypeNameFromId(newTechType);
                            ctrl.CustomTechType             = ctrl.TB_CustomTechTypeName.Text;
                        }
                    }
                    else
                    {
#if DEBUG_TECHTYPE_SELECTOR
                        Logger.Log("DEBUG: TechType \"{0}\" is unknown. Using CUSTOM mode.", newTechType);
#endif
                        ctrl.TB_CustomTechTypeName.Text = TryGetTechTypeNameFromId(newTechType);
                        ctrl.CustomTechType             = ctrl.TB_CustomTechTypeName.Text;
                    }
                }
            }