private void ItemBackground_DataContextChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
        {
            Grid         cb = ((Grid)sender);
            CombatHotKey hk = (CombatHotKey)cb.DataContext;

            UpdateBackground(cb, hk);
        }
Esempio n. 2
0
 public CombatHotKey(CombatHotKey hk)
 {
     _Key      = hk._Key;
     _Modifier = hk._Modifier;
     _Type     = hk._Type;
     _Subtype  = hk._Subtype;
 }
        private void ItemBackground_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            Grid         cb = ((Grid)sender);
            CombatHotKey hk = (CombatHotKey)cb.DataContext;

            UpdateBackground(cb, hk);
        }
        private void CheckBox_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            CheckBox     cb     = ((CheckBox)sender);
            CombatHotKey hk     = (CombatHotKey)cb.DataContext;
            Grid         parent = (Grid)VisualTreeHelper.GetParent(cb);

            UpdateBackground(parent, hk);
        }
        private void SubtypeComboBox_Initialized(object sender, System.EventArgs e)
        {
            ComboBox     cb    = (ComboBox)sender;
            CombatHotKey hk    = (CombatHotKey)cb.DataContext;
            int          index = hk.IntType;

            UpdateSubtypeCombo(index, cb);
        }
        private void ItemBackground_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            Grid         cb = ((Grid)sender);
            CombatHotKey hk = (CombatHotKey)cb.DataContext;

            UpdateBackground(cb, hk);

            UpdateSubtypeCombo(cb.GetChild <ComboBox>("SubtypeCombo"));
        }
        private void SubtypeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            ComboBox cb = ((ComboBox)sender);

            CombatHotKey hk = (CombatHotKey)cb.DataContext;

            if (cb.SelectedValue != null)
            {
                hk.Subtype = (String)((ComboBoxItem)cb.SelectedValue).Content;
            }
        }
 private void UpdateBackground(Grid grid, CombatHotKey hk)
 {
     if (hk.Modifier == ModifierKeys.None || hk.Modifier == ModifierKeys.Shift)
     {
         grid.Background = new SolidColorBrush(Colors.Pink);
     }
     else
     {
         grid.Background = null;
     }
 }
        private void KeyComboBox_Initialized(object sender, System.EventArgs e)
        {
            ComboBox     cb = (ComboBox)sender;
            CombatHotKey hk = (CombatHotKey)cb.DataContext;

            string key = (String) new KeyToStringConverter().Convert(hk.Key,
                                                                     typeof(String), null, System.Globalization.CultureInfo.CurrentCulture);


            SetIndexForString(cb, key);
        }
        private void CommandComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            ComboBox typeCombo = (ComboBox)sender;

            ComboBoxItem cbi = (ComboBoxItem)typeCombo.SelectedItem;
            CombatHotKey hk  = (CombatHotKey)typeCombo.DataContext;

            hk.Type = (CharacterAction)cbi.DataContext;

            ComboBox subtypeCombo = typeCombo.GetSibling <ComboBox>("SubtypeComboBox");

            UpdateSubtypeCombo(subtypeCombo);
        }
        private void UpdateSubtypeCombo(ComboBox subtypeCombo)
        {
            if (subtypeCombo != null)
            {
                ComboBox     cb = subtypeCombo;
                CombatHotKey hk = (CombatHotKey)cb.DataContext;


                subtypeCombo.Items.Clear();
                switch ((CharacterAction)hk.Type)
                {
                case CharacterAction.Save:
                    subtypeCombo.IsEnabled = true;
                    subtypeCombo.Items.Add(new ComboBoxItem()
                    {
                        Content = "Fort"
                    });
                    subtypeCombo.Items.Add(new ComboBoxItem()
                    {
                        Content = "Ref"
                    });
                    subtypeCombo.Items.Add(new ComboBoxItem()
                    {
                        Content = "Will"
                    });
                    SetIndexForString(cb, hk.Subtype);
                    break;

                case CharacterAction.Skill:
                    subtypeCombo.IsEnabled = true;
                    foreach (Monster.SkillInfo si in Monster.SkillsDetails.Values)
                    {
                        subtypeCombo.Items.Add(new ComboBoxItem()
                        {
                            Content = si.Name, Tag = si
                        });
                    }
                    SetIndexForString(cb, hk.Subtype);
                    break;

                case CharacterAction.ApplyCondition:
                    UpdateConditionSubtype(subtypeCombo, hk);
                    break;

                default:
                    subtypeCombo.IsEnabled = false;
                    break;
                }
            }
        }
        private void UpdateSubtypeCombo(int selectedIndex, ComboBox subtypeCombo)
        {
            if (subtypeCombo != null)
            {
                subtypeCombo.Items.Clear();
                switch (selectedIndex)
                {
                case 0:
                    subtypeCombo.IsEnabled = false;
                    break;

                case 1:
                    subtypeCombo.IsEnabled = false;
                    break;

                case 2:
                    subtypeCombo.IsEnabled = true;
                    subtypeCombo.Items.Add(new ComboBoxItem()
                    {
                        Content = "Fort"
                    });
                    subtypeCombo.Items.Add(new ComboBoxItem()
                    {
                        Content = "Ref"
                    });
                    subtypeCombo.Items.Add(new ComboBoxItem()
                    {
                        Content = "Will"
                    });
                    break;

                case 3:
                    subtypeCombo.IsEnabled = true;
                    foreach (Monster.SkillInfo si in Monster.SkillsDetails.Values)
                    {
                        subtypeCombo.Items.Add(new ComboBoxItem()
                        {
                            Content = si.Name, Tag = si
                        });
                    }
                    break;
                }

                ComboBox     cb = subtypeCombo;
                CombatHotKey hk = (CombatHotKey)cb.DataContext;
                SetIndexForString(cb, hk.Subtype);
            }
        }
        private void KeyPressButton_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            CombatHotKey hk = (CombatHotKey)((FrameworkElement)sender).DataContext;


            bool ctrl  = Keyboard.Modifiers.HasFlag(ModifierKeys.Control);
            bool alt   = Keyboard.Modifiers.HasFlag(ModifierKeys.Alt);
            bool shift = Keyboard.Modifiers.HasFlag(ModifierKeys.Shift);

            if (!KeyToStringConverter.IgnoreKeys.Contains(e.Key) && (ctrl | alt | shift))
            {
                hk.Key      = e.Key;
                hk.CtrlKey  = ctrl;
                hk.AltKey   = alt;
                hk.ShiftKey = shift;
            }
        }
        private void UpdateConditionSubtype(ComboBox subtypeCombo, CombatHotKey hk)
        {
            subtypeCombo.IsEnabled = true;

            String hkcond = hk.Subtype;
            bool   found  = false;

            foreach (Condition c in from x in Condition.Conditions where x.Spell == null select x)
            {
                StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;


                Image       i  = new Image();
                BitmapImage bi = StringImageSmallIconConverter.FromName(c.Image);
                i.Source = bi;
                i.Width  = 16;
                i.Height = 16;

                panel.Children.Add(i);
                panel.Children.Add(new TextBlock()
                {
                    Text = c.Name
                });
                ComboBoxItem cbi = new ComboBoxItem()
                {
                    Content = panel, Tag = c
                };

                subtypeCombo.Items.Add(cbi);

                if (c.Name == hkcond)
                {
                    subtypeCombo.SelectedItem = cbi;
                    found = true;
                }
            }
            if (!found)
            {
                subtypeCombo.SelectedIndex = 0;
            }
        }
        private void KeyComboBox_Initialized(object sender, System.EventArgs e)
        {
            ComboBox     cb = (ComboBox)sender;
            CombatHotKey hk = (CombatHotKey)cb.DataContext;


            foreach (var k in KeyToStringConverter.KeysList)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Content     = k.Key;
                item.DataContext = k.Value;
                cb.Items.Add(item);
            }

            string key = hk.Key.ToString();// (String)new KeyToStringConverter().Convert(hk.Key,

            //typeof(String), null, System.Globalization.CultureInfo.CurrentCulture);


            SetIndexForString(cb, key);
        }
        private void CommandComboBox_Initialized(object sender, System.EventArgs e)
        {
            ComboBox cb = (ComboBox)sender;

            CombatHotKey hk = (CombatHotKey)cb.DataContext;

            ComboBoxItem selected = null;

            foreach (var kv in names)
            {
                ComboBoxItem cbi = new ComboBoxItem();
                cbi.Content     = kv.Key;
                cbi.DataContext = kv.Value;

                if (kv.Value == hk.Type)
                {
                    selected = cbi;
                }

                cb.Items.Add(cbi);
            }
            cb.SelectedItem = selected;
        }
        private void DeleteButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            CombatHotKey hk = (CombatHotKey)((FrameworkElement)sender).DataContext;

            _CombatHotKeys.Remove(hk);
        }