コード例 #1
0
ファイル: Single.cs プロジェクト: BlackGad/PS.Framework
        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);