示例#1
0
 public void tray_settings(object sender, EventArgs e)
 {
     if (_settingsOpen)
     {
         try
         {
             _settingsWindow.Focus();
         }
         catch (Exception)
         {
             //ignore
         }
         return;
     }
     using (_settingsWindow = new frmSettings())
     {
         _settingsOpen = true;
         _settingsWindow.actionManager = _actions;
         var tempConfig = _config.Clone();
         _settingsWindow.config = _config;
         var dlgResult = _settingsWindow.ShowDialog();
         if (dlgResult == DialogResult.OK)
         {
             _config = _settingsWindow.config;
             if (_settingsWindow.startWithWindows)
             {
                 if (!Autostart.IsAutoStartEnabled())
                 {
                     Autostart.SetAutoStart();
                 }
             }
             else
             {
                 if (Autostart.IsAutoStartEnabled())
                 {
                     Autostart.UnSetAutoStart();
                 }
             }
             _config.Save(_configPath);
             _actions.LoadConfig(_config);
         }
         else
         {
             _config = tempConfig;
             _synapticsHelper.Config = tempConfig;
             _actions.LoadConfig(_config);
         }
         _settingsWindow.Close();
         _settingsOpen = false;
     }
 }
示例#2
0
        private void frmSettings_Load(object sender, EventArgs e)
        {
            setHeight(settingsHeight[0]);
            var defaultActions    = DefaultActions.getDefaultActions();
            var defaultActionList =
                (from action in defaultActions
                 select new
            {
                DisplayMember = action.Key,
                ValueMember = action.Value
            }).ToList();

            comboSingleTap.DisplayMember         = "DisplayMember";
            comboSingleTap.ValueMember           = "ValueMember";
            comboSingleTap.DataSource            = defaultActionList;
            comboSingleTap.SelectedValue         = config.MouseTapOne == null ? DefaultAction.NoAction : config.MouseTapOne.GetValue();
            comboSingleTap.SelectedValueChanged += comboTapsChanged;

            comboLongSingleTap.BindingContext        = new BindingContext();
            comboLongSingleTap.DisplayMember         = "DisplayMember";
            comboLongSingleTap.ValueMember           = "ValueMember";
            comboLongSingleTap.DataSource            = defaultActionList;
            comboLongSingleTap.SelectedValue         = config.MouseTapOneLong == null ? DefaultAction.NoAction : config.MouseTapOneLong.GetValue();
            comboLongSingleTap.SelectedValueChanged += comboTapsChanged;

            comboTwoTaps.BindingContext        = new BindingContext();
            comboTwoTaps.DisplayMember         = "DisplayMember";
            comboTwoTaps.ValueMember           = "ValueMember";
            comboTwoTaps.DataSource            = defaultActionList;
            comboTwoTaps.SelectedValue         = config.MouseTapTwo == null ? DefaultAction.NoAction : config.MouseTapTwo.GetValue();
            comboTwoTaps.SelectedValueChanged += comboTapsChanged;

            comboLongTwoTaps.BindingContext        = new BindingContext();
            comboLongTwoTaps.DisplayMember         = "DisplayMember";
            comboLongTwoTaps.ValueMember           = "ValueMember";
            comboLongTwoTaps.DataSource            = defaultActionList;
            comboLongTwoTaps.SelectedValue         = config.MouseTapTwoLong == null ? DefaultAction.NoAction : config.MouseTapTwoLong.GetValue();
            comboLongTwoTaps.SelectedValueChanged += comboTapsChanged;

            comboThreeTaps.BindingContext        = new BindingContext();
            comboThreeTaps.DisplayMember         = "DisplayMember";
            comboThreeTaps.ValueMember           = "ValueMember";
            comboThreeTaps.DataSource            = defaultActionList;
            comboThreeTaps.SelectedValue         = config.MouseTapThree == null ? DefaultAction.NoAction : config.MouseTapThree.GetValue();
            comboThreeTaps.SelectedValueChanged += comboTapsChanged;

            comboLongThreeTaps.BindingContext        = new BindingContext();
            comboLongThreeTaps.DisplayMember         = "DisplayMember";
            comboLongThreeTaps.ValueMember           = "ValueMember";
            comboLongThreeTaps.DataSource            = defaultActionList;
            comboLongThreeTaps.SelectedValue         = config.MouseTapThreeLong == null ? DefaultAction.NoAction : config.MouseTapThreeLong.GetValue();
            comboLongThreeTaps.SelectedValueChanged += comboTapsChanged;

            trackTapTolerance.Value = config.MouseTapsLongMovingArea;
            trackLongTapTime.Value  = config.MouseTapsLongMs;
            lblTapTolerance.Text    = trackTapTolerance.Value + " px";
            lblLongTapTime.Text     = trackLongTapTime.Value + " ms";


            trackScrollingAcceleration.Value = trackScrollingAcceleration.Maximum - config.ScrollAcceleration + trackScrollingAcceleration.Minimum;
            trackScrollingSpeed.Value        = config.ScrollSpeed;
            chkScrollingVertical.Checked     = config.ScrollVertical;
            chkScrollingHorizontal.Checked   = config.ScrollHorizontal;
            chkScrollingReverse.Checked      = config.ScrollReverse;
            chkScrollingAcceleration.Checked = config.ScrollAccelerationEnabled;

            startWithWindows           = Autostart.IsAutoStartEnabled();
            chkWindows.Checked         = startWithWindows;
            chkWindows.CheckedChanged += windowsAutoStartChanged;


            cbSwipe2L.BindingContext        = new BindingContext();
            cbSwipe2L.DisplayMember         = "DisplayMember";
            cbSwipe2L.ValueMember           = "ValueMember";
            cbSwipe2L.DataSource            = defaultActionList;
            cbSwipe2L.SelectedValue         = config.SwipeTwoLeft == null ? DefaultAction.NoAction : config.SwipeTwoLeft.GetValue();
            cbSwipe2L.SelectedValueChanged += comboSwipesChanged;

            cbSwipe2R.BindingContext        = new BindingContext();
            cbSwipe2R.DisplayMember         = "DisplayMember";
            cbSwipe2R.ValueMember           = "ValueMember";
            cbSwipe2R.DataSource            = defaultActionList;
            cbSwipe2R.SelectedValue         = config.SwipeTwoRight == null ? DefaultAction.NoAction : config.SwipeTwoRight.GetValue();
            cbSwipe2R.SelectedValueChanged += comboSwipesChanged;

            cbSwipe3U.BindingContext        = new BindingContext();
            cbSwipe3U.DisplayMember         = "DisplayMember";
            cbSwipe3U.ValueMember           = "ValueMember";
            cbSwipe3U.DataSource            = defaultActionList;
            cbSwipe3U.SelectedValue         = config.SwipeThreeUp == null ? DefaultAction.NoAction : config.SwipeThreeUp.GetValue();
            cbSwipe3U.SelectedValueChanged += comboSwipesChanged;

            cbSwipe3D.BindingContext        = new BindingContext();
            cbSwipe3D.DisplayMember         = "DisplayMember";
            cbSwipe3D.ValueMember           = "ValueMember";
            cbSwipe3D.DataSource            = defaultActionList;
            cbSwipe3D.SelectedValue         = config.SwipeThreeDown == null ? DefaultAction.NoAction : config.SwipeThreeDown.GetValue();
            cbSwipe3D.SelectedValueChanged += comboSwipesChanged;

            cbSwipe3L.BindingContext        = new BindingContext();
            cbSwipe3L.DisplayMember         = "DisplayMember";
            cbSwipe3L.ValueMember           = "ValueMember";
            cbSwipe3L.DataSource            = defaultActionList;
            cbSwipe3L.SelectedValue         = config.SwipeThreeLeft == null ? DefaultAction.NoAction : config.SwipeThreeLeft.GetValue();
            cbSwipe3L.SelectedValueChanged += comboSwipesChanged;

            cbSwipe3R.BindingContext        = new BindingContext();
            cbSwipe3R.DisplayMember         = "DisplayMember";
            cbSwipe3R.ValueMember           = "ValueMember";
            cbSwipe3R.DataSource            = defaultActionList;
            cbSwipe3R.SelectedValue         = config.SwipeThreeRight == null ? DefaultAction.NoAction : config.SwipeThreeRight.GetValue();
            cbSwipe3R.SelectedValueChanged += comboSwipesChanged;

            cbSwipeBorderT.BindingContext        = new BindingContext();
            cbSwipeBorderT.DisplayMember         = "DisplayMember";
            cbSwipeBorderT.ValueMember           = "ValueMember";
            cbSwipeBorderT.DataSource            = defaultActionList;
            cbSwipeBorderT.SelectedValue         = config.SwipeBorderTop == null ? DefaultAction.NoAction : config.SwipeBorderTop.GetValue();
            cbSwipeBorderT.SelectedValueChanged += comboSwipesChanged;

            cbSwipeBorderB.BindingContext        = new BindingContext();
            cbSwipeBorderB.DisplayMember         = "DisplayMember";
            cbSwipeBorderB.ValueMember           = "ValueMember";
            cbSwipeBorderB.DataSource            = defaultActionList;
            cbSwipeBorderB.SelectedValue         = config.SwipeBorderBottom == null ? DefaultAction.NoAction : config.SwipeBorderBottom.GetValue();
            cbSwipeBorderB.SelectedValueChanged += comboSwipesChanged;

            cbSwipeBorderL.BindingContext        = new BindingContext();
            cbSwipeBorderL.DisplayMember         = "DisplayMember";
            cbSwipeBorderL.ValueMember           = "ValueMember";
            cbSwipeBorderL.DataSource            = defaultActionList;
            cbSwipeBorderL.SelectedValue         = config.SwipeBorderLeft == null ? DefaultAction.NoAction : config.SwipeBorderLeft.GetValue();
            cbSwipeBorderL.SelectedValueChanged += comboSwipesChanged;

            cbSwipeBorderR.BindingContext        = new BindingContext();
            cbSwipeBorderR.DisplayMember         = "DisplayMember";
            cbSwipeBorderR.ValueMember           = "ValueMember";
            cbSwipeBorderR.DataSource            = defaultActionList;
            cbSwipeBorderR.SelectedValue         = config.SwipeBorderRight == null ? DefaultAction.NoAction : config.SwipeBorderRight.GetValue();
            cbSwipeBorderR.SelectedValueChanged += comboSwipesChanged;
        }