예제 #1
0
        protected override float GetPreset(PresetMode preset)
        {
            {
                switch (preset)
                {
                case PresetMode.None:
                case PresetMode.Default:
                    return(default);

                case PresetMode.Minimum:
                    return(float.MinValue);

                case PresetMode.Maximum:
                    return(float.MaxValue);

                case PresetMode.PositiveInfinity:
                    return(float.PositiveInfinity);

                case PresetMode.NegativeInfinity:
                    return(float.NegativeInfinity);

                case PresetMode.NaN:
                    return(float.NaN);

                case PresetMode.Epsilon:
                    return(float.Epsilon);

                default:
                    throw new ArgumentOutOfRangeException("preset", preset, null);
                }
            }
        }
예제 #2
0
        public static Brush GetPresetColor(PresetMode value, UserControl ctrl)
        {
            switch (value)
            {
            case PresetMode.AlwaysOn:   return(new SolidColorBrush(Colors.LightGreen));

            case PresetMode.OnOff:      return(ctrl.FindResource("OnOff") as DrawingBrush);

            case PresetMode.OffOn:      return(ctrl.FindResource("OffOn") as DrawingBrush);

            case PresetMode.AlwaysOff:  return(new SolidColorBrush(Colors.LightPink));
            }
            return(null);
        }
예제 #3
0
        static void SetPresetMode(PresetMode value, out bool?OnState, out bool?OffState)
        {
            switch (value)
            {
            case PresetMode.AlwaysOn:   OnState = OffState = true; break;

            case PresetMode.OnOff:      OnState = true; OffState = false; break;

            case PresetMode.OffOn:      OnState = false; OffState = true; break;

            case PresetMode.AlwaysOff:  OnState = OffState = false; break;

            default:                    OnState = OffState = null; break;
            }
        }
예제 #4
0
        private void CmbPreset_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (SuspendChange != 0)
            {
                return;
            }

            PresetMode Value = (PresetMode)(cmbPreset.SelectedItem as ComboBoxItem).Tag;

            cmbPreset.Background = GetPresetColor(Value, this);

            SetPresetMode(Value, out rule.OnState, out rule.OffState);

            RuleChanged?.Invoke(this, new EventArgs());
        }
예제 #5
0
        private T GetPreset(PresetMode value)
        {
            if (!typeof(T).TryGetNumericLimits(out var max, out var min))
            {
                throw new NotSupportedException();
            }

            switch (value)
            {
            case PresetMode.None:
            case PresetMode.Default:
                return(default);

            case PresetMode.Minimum:
                return((T)min);

            case PresetMode.Maximum:
                return((T)max);

            default:
                throw new ArgumentOutOfRangeException("value", value, null);
            }
        }
예제 #6
0
        public void DoUpdate(FirewallPreset.SingleRule rule)
        {
            this.rule = rule;

            SuspendChange++;

            PresetMode Value = GetPresetMode(rule.OnState, rule.OffState);

            WpfFunc.CmbSelect(cmbPreset, Value.ToString());
            cmbPreset.Background = GetPresetColor(Value, this);

            SuspendChange--;

            if (FwRule == null)
            {
                label.Content = rule.RuleId;
                return;
            }

            label.Content   = App.GetResourceStr(FwRule.Name);
            info.Text       = App.GetResourceStr(GetRuleDescription(FwRule, true));
            info.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(FwRule.Action == FirewallRule.Actions.Block ? "#ffe6e9" : "#e9fce9"));
        }
예제 #7
0
        public void preset(PresetMode mode)
        {
            byte value = Convert.ToByte(mode);

            send(new byte[] { 0x7e, 0x05, 0x03, value, 0x03, 0xff, 0xff, 0x00, 0xef });
        }
예제 #8
0
 protected abstract T GetPreset(PresetMode value);