コード例 #1
0
        private void setCondition(ConditionNumber number, MenuItemViewModel item)
        {
            ConditionProxy proxy     = null;
            ACondition     condition = null;

            if (item.Tag is ConditionProxy)
            {
                proxy = item.Tag as ConditionProxy;
            }
            else if (item.Tag is ACondition)
            {
                condition = item.Tag as ACondition;
            }

            foreach (var mapping in _mappings)
            {
                if (proxy != null)
                {
                    mapping.SetCondition(number, proxy);
                }
                else if (condition != null)
                {
                    mapping.SetCondition(number, condition);
                }
                else
                {
                    mapping.SetCondition(number, condition); // clear condition with null value
                }
            }

            if (number == ConditionNumber.One)
            {
                _selectedC1Conditions = new List <ACondition> {
                    _mappings.First().Conditions.Condition1
                }
            }
            ;
            else
            {
                _selectedC2Conditions = new List <ACondition> {
                    _mappings.First().Conditions.Condition2
                }
            };

            update();
        }
コード例 #2
0
ファイル: MappingViewModel.cs プロジェクト: pestrela/cmdr
        public void SetCondition(ConditionNumber number, ConditionProxy proxy)
        {
            var changed = _mapping.SetCondition(number, proxy);

            if (changed)
            {
                if (number == ConditionNumber.One)
                {
                    raisePropertyChanged("Condition1");
                }
                else
                {
                    raisePropertyChanged("Condition2");
                }
                raisePropertyChanged("ConditionExpression");
                IsChanged = true;
            }
        }
コード例 #3
0
 /// <summary>
 /// Set condition by proxy.
 /// </summary>
 /// <param name="number">Number of condition</param>
 /// <param name="proxy">ConditionProxy or null to reset condition.</param>
 /// <returns>True if condition was changed.</returns>
 public bool SetCondition(ConditionNumber number, ConditionProxy proxy)
 {
     return(_conditions.SetCondition(_rawMapping.Settings, number, proxy));
 }
コード例 #4
0
        // code based on conditionsEditorViewMode::setCondition()
        public void rotateModifierCondition(int which, int step)
        {
            ConditionNumber number;

            if (which == 1)
            {
                number = ConditionNumber.One;
            }
            else
            {
                number = ConditionNumber.Two;
            }

            var conditions_editor = this.ConditionsEditor;
            var conditions_list   = conditions_editor.Conditions;

            var modifier_list = conditions_list.Where(x => x.Text == "Modifier").First().Children;

            foreach (var mapping in _mappings)
            {
                ACondition cur_condition;
                if (which == 1)
                {
                    cur_condition = mapping.Conditions.Condition1;
                }
                else
                {
                    cur_condition = mapping.Conditions.Condition2;
                }

                if (cur_condition == null)
                {
                    continue;       // ignore no condition
                }
                KnownCommands id = (KnownCommands)cur_condition.Id;
                if (!((id >= KnownCommands.Modifier_Modifier1) &&
                      (id <= KnownCommands.Modifier_Modifier8)))
                {
                    continue;       // ignore non-modifiers
                }
                var cur_value = cur_condition.GetValue();

                ////
                int cur_modifier = id - KnownCommands.Modifier_Modifier1 + 1;
                int new_modifier = rotate_modifier_key_int(cur_modifier, step);

                MenuItemViewModel item          = modifier_list[new_modifier - 1];
                ConditionProxy    new_proxy     = null;
                ACondition        new_condition = null;

                if (item.Tag is ConditionProxy)
                {
                    new_proxy = item.Tag as ConditionProxy;
                }
                else if (item.Tag is ACondition)
                {
                    new_condition = item.Tag as ACondition;
                }

                if (new_proxy != null)
                {
                    mapping.SetCondition(number, new_proxy);
                }
                else if (new_condition != null)
                {
                    mapping.SetCondition(number, new_condition);
                }
                else
                {
                    mapping.SetCondition(number, new_condition); // clear condition with null value
                }
                cur_condition.SetValue(cur_value);
                mapping.UpdateConditionExpression();
            }
            conditions_editor.Refresh();
        }
コード例 #5
0
        // code was based on conditionsEditorViewMode::setCondition()
        public void rotateConditionItself(int which, int step)
        {
            ConditionNumber number;

            if (which == 1)
            {
                number = ConditionNumber.One;
            }
            else
            {
                number = ConditionNumber.Two;
            }

            var conditions_editor = this.ConditionsEditor;
            var conditions_list   = conditions_editor.Conditions;

            var first_modifier = conditions_list.FirstOrDefault(x => x.Text == "M1");

            // FIXME: this broken because of the tree removal
            if (first_modifier == null)
            {
                return;
            }
            ;

            int location      = conditions_list.IndexOf(first_modifier);
            var modifier_list = conditions_list.Skip(location).Take(8).ToList();

            foreach (var mapping in _mappings)
            {
                ACondition cur_condition;
                if (which == 1)
                {
                    cur_condition = mapping.Conditions.Condition1;
                }
                else
                {
                    cur_condition = mapping.Conditions.Condition2;
                }

                if (cur_condition == null)
                {
                    continue;       // ignore no condition
                }
                KnownCommands id = (KnownCommands)cur_condition.Id;
                if (!((id >= KnownCommands.Modifier_Modifier1) &&
                      (id <= KnownCommands.Modifier_Modifier8)))
                {
                    continue;       // ignore non-modifiers
                }
                var cur_value = cur_condition.GetValue();

                ////
                int cur_modifier = id - KnownCommands.Modifier_Modifier1 + 1;
                int new_modifier = rotate_modifier_key_int(cur_modifier, step, 1, 8);

                MenuItemViewModel item          = modifier_list[new_modifier - 1];
                ConditionProxy    new_proxy     = null;
                ACondition        new_condition = null;

                if (item.Tag is ConditionProxy)
                {
                    new_proxy = item.Tag as ConditionProxy;
                }
                else if (item.Tag is ACondition)
                {
                    new_condition = item.Tag as ACondition;
                }

                if (new_proxy != null)
                {
                    mapping.SetCondition(number, new_proxy);
                }
                else if (new_condition != null)
                {
                    mapping.SetCondition(number, new_condition);
                }
                else
                {
                    mapping.SetCondition(number, new_condition); // clear condition with null value
                }
                cur_condition.SetValue(cur_value);
                mapping.UpdateConditionExpression();
            }
            conditions_editor.Refresh();
        }