Beispiel #1
0
 private void UnregisterHotKey()
 {
     HotKeyHelper.UnregisterHotKey(this.Handle, HotKeyHelper.HOTKEY_ID_START_MACRO);
     HotKeyHelper.UnregisterHotKey(this.Handle, HotKeyHelper.HOTKEY_ID_END_MACRO);
 }
Beispiel #2
0
 /// <summary>
 /// 初始化注册快捷键
 /// </summary>
 /// <param name="hotKeyModelList">待注册热键的项</param>
 /// <returns>true:保存快捷键的值;false:弹出设置窗体</returns>
 private bool InitHotKey(HotKeyModel hotKeyModel = null)
 {
     // 注册全局快捷键
     return(HotKeyHelper.RegisterHotKey(hotKeyModel, m_Hwnd));
 }
 private void OptionsView_Closed(object sender, EventArgs e)
 {
     HotKeyHelper.RegisterHotKey((uint)this.config.ModifierKey, this.config.KeyCode);
 }
Beispiel #4
0
        /// <summary>
        /// 将图形界面设置保存到设置模块
        /// </summary>
        private async Task <bool> SaveSettingsToConfig()
        {
            tbHotKey.Text = tbHotKey.Text.ToUpper();

            int tryInt;

            if (!int.TryParse(tbProxyPort.Text, out tryInt))
            {
                await this.ShowMessageAsync("错误 - 保存失败", "代理服务器端口号必须是整数!");

                return(false);
            }
            if (!int.TryParse(tbAPTarget.Text, out tryInt))
            {
                await this.ShowMessageAsync("错误 - 保存失败", "指定体力必须是整数!");

                return(false);
            }
            if (!int.TryParse(tbBPTarget.Text, out tryInt))
            {
                await this.ShowMessageAsync("错误 - 保存失败", "指定战点必须是整数!");

                return(false);
            }
            if (chkEnableHotKey.IsChecked.HasValue && (bool)chkEnableHotKey.IsChecked)
            {
                if (!(bool)chkHotKeyAlt.IsChecked && !(bool)chkHotKeyCtrl.IsChecked && !(bool)chkHotKeyShift.IsChecked)
                {
                    await this.ShowMessageAsync("错误 - 保存失败", "老板键必须要选择Ctrl、Alt、Shift中的一个或者多个!");

                    return(false);
                }
            }

            DataUtil.Config.sysConfig.showLoginDialog = chkShowLogin.IsChecked.HasValue ? (bool)chkShowLogin.IsChecked : false;
            DataUtil.Config.sysConfig.showLoginNews   = chkShowNews.IsChecked.HasValue ? (bool)chkShowNews.IsChecked : false;
            DataUtil.Config.sysConfig.gameServer      = cbGameServer.SelectedIndex;
            DataUtil.Config.sysConfig.gameHomePage    = cbLoginPage.SelectedIndex;

            if (rbNotUseProxy.IsChecked.HasValue && (bool)rbNotUseProxy.IsChecked)
            {
                DataUtil.Config.sysConfig.proxyType = SysConfig.ProxySettingsType.DirectAccess;
            }
            else if (rbUseIEProxy.IsChecked.HasValue && (bool)rbUseIEProxy.IsChecked)
            {
                DataUtil.Config.sysConfig.proxyType = SysConfig.ProxySettingsType.UseSystemProxy;
            }
            else if (rbUseCusProxy.IsChecked.HasValue && (bool)rbUseCusProxy.IsChecked)
            {
                DataUtil.Config.sysConfig.proxyType = SysConfig.ProxySettingsType.UseUserProxy;
            }
            DataUtil.Config.sysConfig.proxyServer = tbProxyServer.Text;
            DataUtil.Config.sysConfig.proxyPort   = int.Parse(tbProxyPort.Text);

            DataUtil.Config.sysConfig.apTargetNotify   = chkAPTarget.IsChecked.HasValue ? (bool)chkAPTarget.IsChecked ? short.Parse(tbAPTarget.Text) : (short)0 : (short)0;
            DataUtil.Config.sysConfig.apFullNotify     = chkAPFull.IsChecked.HasValue ? (bool)chkAPFull.IsChecked : false;
            DataUtil.Config.sysConfig.bpTargetNotify   = chkBPTarget.IsChecked.HasValue ? (bool)chkBPTarget.IsChecked ? short.Parse(tbBPTarget.Text) : (short)0 : (short)0;
            DataUtil.Config.sysConfig.bpFullNotify     = chkBPFull.IsChecked.HasValue ? (bool)chkBPFull.IsChecked : false;
            DataUtil.Config.sysConfig.spEveryNotify    = chkSPEvery.IsChecked.HasValue ? (bool)chkSPEvery.IsChecked : false;
            DataUtil.Config.sysConfig.spFullNotify     = chkSPFull.IsChecked.HasValue ? (bool)chkSPFull.IsChecked : false;
            DataUtil.Config.sysConfig.foundStageNotify = chkFoundStage.IsChecked.HasValue ? (bool)chkFoundStage.IsChecked : false;
            DataUtil.Config.sysConfig.foundBossNotify  = chkFoundBoss.IsChecked.HasValue ? (bool)chkFoundBoss.IsChecked : false;

            DataUtil.Config.sysConfig.logGame  = chkGameLog.IsChecked.HasValue ? (bool)chkGameLog.IsChecked : false;
            DataUtil.Config.sysConfig.logGacha = chkGachaLog.IsChecked.HasValue ? (bool)chkGachaLog.IsChecked : false;

            DataUtil.Config.sysConfig.autoGoInMaps  = chkAutoGo.IsChecked.HasValue ? (bool)chkAutoGo.IsChecked : false;
            DataUtil.Config.sysConfig.autoGoTimeout = (int)slAutoRate.Value;

            DataUtil.Config.sysConfig.changeTitle    = chkTitleChange.IsChecked.HasValue ? (bool)chkTitleChange.IsChecked : false;
            DataUtil.Config.sysConfig.alwaysShowTray = chkAlwaysTray.IsChecked.HasValue ? (bool)chkAlwaysTray.IsChecked : false;
            DataUtil.Config.sysConfig.miniToTray     = chkMiniToTray.IsChecked.HasValue ? (bool)chkMiniToTray.IsChecked : false;
            DataUtil.Config.sysConfig.miniToMute     = chkAutoMute.IsChecked.HasValue ? (bool)chkAutoMute.IsChecked : false;
            DataUtil.Config.sysConfig.exitConfirm    = chkExitConfrim.IsChecked.HasValue ? (bool)chkExitConfrim.IsChecked : false;

            DataUtil.Config.sysConfig.enableHotKey = chkEnableHotKey.IsChecked.HasValue ? (bool)chkEnableHotKey.IsChecked : false;
            DataUtil.Config.sysConfig.hotKeyCtrl   = chkHotKeyCtrl.IsChecked.HasValue ? (bool)chkHotKeyCtrl.IsChecked : false;
            DataUtil.Config.sysConfig.hotKeyAlt    = chkHotKeyAlt.IsChecked.HasValue ? (bool)chkHotKeyAlt.IsChecked : false;
            DataUtil.Config.sysConfig.hotKeyShift  = chkHotKeyShift.IsChecked.HasValue ? (bool)chkHotKeyShift.IsChecked : false;
            DataUtil.Config.sysConfig.hotKey       = tbHotKey.Text[0];

            DataUtil.Config.sysConfig.capFormat = (SysConfig.ScreenShotFormat)cbCapFormat.SelectedIndex;

            if (cbGameServer.SelectedIndex == (int)GameInfo.ServersList.American || cbGameServer.SelectedIndex == (int)GameInfo.ServersList.AmericanR18)
            {
                DataUtil.Config.sysConfig.userCSSAmerican = tbCssStyle.Text;
            }
            else
            {
                DataUtil.Config.sysConfig.userCSS = tbCssStyle.Text;
            }

            if (DataUtil.Config.sysConfig.alwaysShowTray)
            {
                notifyIcon.Visible = true;
            }
            else
            {
                notifyIcon.Visible = false;
            }

            if (DataUtil.Config.sysConfig.enableHotKey)
            {
                EnableHotKey();
            }
            else if (HotKeyHelper.isRegistered)
            {
                IntPtr handle = new WindowInteropHelper(this).Handle;
                HotKeyHelper.UnregisterHotKey(handle, HotKeyHelper.hotKeyId);
            }

            ApplyProxySettings();

            //修改瀏覽器尺寸
            ApplyWebBrowserSize();
            _gameFrameVM.SaveSettings();

            return(true);
        }
Beispiel #5
0
 private void AboutView_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     HotKeyHelper.RegisterHotKey((uint)this.config.ModifierKey, this.config.KeyCode);
 }
Beispiel #6
0
 // --------------------------------------------------------------------------
 /// <summary>
 /// Once we have a window handle, register for hot keys
 /// </summary>
 // --------------------------------------------------------------------------
 protected override void OnSourceInitialized(EventArgs e)
 {
     base.OnSourceInitialized(e);
     _hotKeys = new HotKeyHelper(this, HandleHotKey);
     _hotKey1 = _hotKeys.ListenForHotKey(System.Windows.Forms.Keys.Space, HotKeyModifiers.Shift | HotKeyModifiers.Control);
 }
Beispiel #7
0
        /// <summary>
        /// 取消热键,程序退出时调用,窗体句柄,热键ID
        /// </summary>
        private void UnRegisterHotKey()
        {
            var success = HotKeyHelper.UnregisterHotKey(this.Handle, 0);

            Console.WriteLine("--反注册热键:" + success);
        }
Beispiel #8
0
 public MainWindow()
 {
     InitializeComponent();
     this._hotkey = new HotKeyHelper(this);
     this.Initialize();
 }
Beispiel #9
0
        public MySimpleLauncherMain()
        {
            InitializeComponent();

            using (var key = new FileOperator(AppCommon.GetAppPath() + "key")) {
                if (key.Exists())
                {
                    key.OpenForRead();
                    ProfileDatabase.Password = key.ReadLine();
                }
            }

            this.CreateContextMenu();
            this.SetUpNotifyIcon();
            this._settings = AppSettings.GetInstance();
            this._settings.Load();
            this.Title    = AppCommon.GetAppName();
            _self         = this;
            _assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

            this._hotkey = new HotKeyHelper(this);
            this._hotkey.Register(ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt,
                                  Key.A,
                                  (_, __) => {
                if (!this.ShowInTaskbar)
                {
                    NotifyMenuShow_Click(null, null);
                }
                else
                {
                    if (this.WindowState == WindowState.Minimized)
                    {
                        this.WindowState = WindowState.Normal;
                    }
                    this.Activate();
                }
            }
                                  );

            if (0 <= this._settings.WindowPosX && (this._settings.WindowPosX + this._settings.WindowSizeW) < SystemParameters.VirtualScreenWidth)
            {
                this.Left = this._settings.WindowPosX;
            }
            if (0 <= this._settings.WindowPosY && (this._settings.WindowPosY + this._settings.WindowSizeH) < SystemParameters.VirtualScreenHeight)
            {
                this.Top = this._settings.WindowPosY;
            }
            if (0 < this._settings.WindowSizeW && this._settings.WindowSizeW <= SystemParameters.WorkArea.Width)
            {
                this.Width = this._settings.WindowSizeW;
            }
            if (0 < this._settings.WindowSizeH && this._settings.WindowSizeH <= SystemParameters.WorkArea.Height)
            {
                this.Height = this._settings.WindowSizeH;
            }
            if (0 < this._settings.CategoryListW && this._settings.CategoryListW < this.Width)
            {
                this.cMainGrid.ColumnDefinitions[0].Width = new GridLength(this._settings.CategoryListW);
                // this.cCategoryList.Width = this._settings.CategoryListW;
            }
        }