public void RegisterHotKeys(bool reload) { if (reload) { HotKeyUtil.UnRegisterHotKeys(); } HotKeyUtil.RegisterHotKey(SettingItemUtils.GetMainWindowOpenHotkey(), OnOpenWindowHotKey); }
protected override void OnContentRendered(EventArgs e) { base.OnContentRendered(e); if (AppUtil.IsHotKeyEnabled) { Enum.TryParse(HotKeyUtil.GetHotKey(), out System.Windows.Forms.Keys hotKey); if (!RegHotKey(hotKey, out string message)) { VirtualRoot.Out.ShowWarn(message, header: "热键设置失败", toConsole: true); } } }
protected override void OnContentRendered(EventArgs e) { base.OnContentRendered(e); if (NotiCenterWindowViewModel.IsHotKeyEnabled) { Enum.TryParse(HotKeyUtil.GetHotKey(), out System.Windows.Forms.Keys hotKey); if (!RegHotKey(hotKey, out string message)) { NotiCenterWindowViewModel.Instance.Manager .CreateMessage() .Warning("失败", message) .Dismiss().WithButton("忽略", null) .Queue(); } } }
public MainWindow() { #region ViewModel this.qqVideoView = new QQVideoView(this); this.DataContext = qqVideoView; #endregion //缓动 ease.EasingMode = EasingMode.EaseOut; ease.Oscillations = 3; ease.Springiness = 8; InitializeComponent(); #region 初始位置 this.Height = windowHeight; double left = (SystemParameters.PrimaryScreenWidth - this.Width) / 2; this.Left = left; //MessageBox.Show(SystemParameters.PrimaryScreenWidth.ToString() + "," + this.Width + "," + left); this.Top = 100; ShowAnimation(null, null); #endregion //注册热键 HotKeyUtil hk = new HotKeyUtil(this, HotKeyUtil.KeyModifiers.MOD_ALT, keyCode.vbKeyF1); hk.OnHotKey += this.OnHotkey; }
private void root_Closed(object sender, EventArgs e) { HotKeyUtil.UnRegisterHotKeys(); }