private void effect_user_config_Click(object sender, RoutedEventArgs e) { TreeMenuItem curTreeMenuItem = (TreeMenuItem)((TreeViewItem)((Grid)((Border)((ContentPresenter)((StackPanel)((Button)sender).Parent).TemplatedParent).Parent).Parent).TemplatedParent).DataContext; EffectType effectType = EffectType._EFFECT_ENUM_MAX; foreach (var pair in m_treeMenuItemsMap) { if (pair.Value == curTreeMenuItem) { effectType = pair.Key; break; } } if (effectType != EffectType._EFFECT_ENUM_MAX) { EffectInfo effectInfo = EffectsMap[effectType]; EffectData effectData = GetEffectData(effectType); EffectConfig effectConfig = new EffectConfig(effectData, effectInfo); effectConfig.ShowDialog(); if (effectConfig.IsSaved) { effectData.TimedType = effectConfig.effectconf_timer_type_enable.IsChecked.Value ? (EffectTimedType)effectConfig.effectconf_timer_type.SelectedIndex : effectInfo.IsShort ? EffectTimedType.TIMED_SHORT : EffectTimedType.TIMED_NORMAL; effectData.CustomTime = effectConfig.effectconf_timer_time_enable.IsChecked.Value ? effectConfig.effectconf_timer_time.Text.Length > 0 ? int.Parse(effectConfig.effectconf_timer_time.Text) : -1 : -1; effectData.Permanent = effectConfig.effectconf_timer_permanent_enable.IsChecked.Value; effectData.WeightMult = effectConfig.effectconf_effect_weight_mult.SelectedIndex + 1; effectData.ExcludedFromVoting = effectConfig.effectconf_exclude_voting_enable.IsChecked.Value; effectData.CustomName = effectConfig.effectconf_effect_custom_name.Text.Trim(); Key shortcut = (Key)effectConfig.effectconf_effect_shortcut_combo.SelectedItem; effectData.Shortcut = KeyInterop.VirtualKeyFromKey(shortcut); } } }
private void effect_user_config_Click(object sender, RoutedEventArgs e) { TreeMenuItem curTreeMenuItem = (TreeMenuItem)((TreeViewItem)((Grid)((Border)((ContentPresenter)((StackPanel)((Button)sender).Parent).TemplatedParent).Parent).Parent).TemplatedParent).DataContext; EffectType effectType = EffectType._EFFECT_ENUM_MAX; foreach (var pair in TreeMenuItemsMap) { if (pair.Value == curTreeMenuItem) { effectType = pair.Key; break; } } if (effectType != EffectType._EFFECT_ENUM_MAX) { EffectInfo effectInfo = EffectsMap[effectType]; EffectData effectData = EffectDataMap[effectType]; EffectConfig effectConfig = new EffectConfig(effectData, effectInfo); effectConfig.Title = effectInfo.Name; effectConfig.ShowDialog(); if (effectConfig.IsSaved) { effectData.EffectTimedType = effectConfig.effectconf_timer_type_enable.IsChecked.Value ? (EffectTimedType)effectConfig.effectconf_timer_type.SelectedIndex : effectInfo.IsShort ? EffectTimedType.TIMED_SHORT : EffectTimedType.TIMED_NORMAL; effectData.EffectCustomTime = effectConfig.effectconf_timer_time_enable.IsChecked.Value ? effectConfig.effectconf_timer_time.Text.Length > 0 ? int.Parse(effectConfig.effectconf_timer_time.Text) : -1 : -1; effectData.EffectPermanent = effectConfig.effectconf_timer_permanent_enable.IsChecked.Value; effectData.EffectWeight = effectConfig.effectconf_effect_weight.SelectedIndex + 1; } } }