Пример #1
0
        private void Initialize()
        {
            #region 热键

            this.SwHotKeyManager = new HotKeyManager(this);

            //增大宽度
            this.SwHotKeyManager.Register(
                (Enumeration.ModifierKeys)Enumeration.FromString<Enumeration.ModifierKeys>(SwGlobal.IncreaseWidthHotKeyModifierKey),
                (Keys)Enumeration.FromString<Keys>(SwGlobal.IncreaseWidthHotKeyKey),
                new HotKeyEventHandler(this.OnIncreaseWidthHotKey)
                );
            //减小宽度
            this.SwHotKeyManager.Register(
                (Enumeration.ModifierKeys)Enumeration.FromString<Enumeration.ModifierKeys>(SwGlobal.DecreaseWidthHotKeyModifierKey),
                (Keys)Enumeration.FromString<Keys>(SwGlobal.DecreaseWidthHotKeyKey),
                new HotKeyEventHandler(this.OnDecreaseWidthHotKey)
                );
            //增大高度
            this.SwHotKeyManager.Register(
                (Enumeration.ModifierKeys)Enumeration.FromString<Enumeration.ModifierKeys>(SwGlobal.IncreaseHeightHotKeyModifierKey),
                (Keys)Enumeration.FromString<Keys>(SwGlobal.IncreaseHeightHotKeyKey),
                new HotKeyEventHandler(this.OnIncreaseHeightHotKey)
                );
            //减小高度
            this.SwHotKeyManager.Register(
                (Enumeration.ModifierKeys)Enumeration.FromString<Enumeration.ModifierKeys>(SwGlobal.DecreaseHeightHotKeyModifierKey),
                (Keys)Enumeration.FromString<Keys>(SwGlobal.DecreaseHeightHotKeyKey),
                new HotKeyEventHandler(this.OnDecreaseHeightHotKey)
                );
            //增大不透明度
            this.SwHotKeyManager.Register(
                (Enumeration.ModifierKeys)Enumeration.FromString<Enumeration.ModifierKeys>(SwGlobal.IncreaseOpacityHotKeyModifierKey),
                (Keys)Enumeration.FromString<Keys>(SwGlobal.IncreaseOpacityHotKeyKey),
                new HotKeyEventHandler(this.OnIncreaseOpacityHotKey)
                );
            //减小不透明度
            this.SwHotKeyManager.Register(
                (Enumeration.ModifierKeys)Enumeration.FromString<Enumeration.ModifierKeys>(SwGlobal.DecreaseOpacityHotKeyModifierKey),
                (Keys)Enumeration.FromString<Keys>(SwGlobal.DecreaseOpacityHotKeyKey),
                new HotKeyEventHandler(this.OnDecreaseOpacityHotKey)
                );
            //显示隐藏
            this.SwHotKeyManager.Register(
                (Enumeration.ModifierKeys)Enumeration.FromString<Enumeration.ModifierKeys>(SwGlobal.ShowHideHotKeyModifierKey),
                (Keys)Enumeration.FromString<Keys>(SwGlobal.ShowHideHotKeyKey),
                new HotKeyEventHandler(this.OnShowHideHotKey)
                );
            //退出
            this.SwHotKeyManager.Register(
                (Enumeration.ModifierKeys)Enumeration.FromString<Enumeration.ModifierKeys>(SwGlobal.ExitHotKeyModifierKey),
                (Keys)Enumeration.FromString<Keys>(SwGlobal.ExitHotKeyKey),
                new HotKeyEventHandler(this.OnExitHotKey)
                );

            #endregion

            #region 窗体

            this.toolTip1.ToolTipTitle = SwGlobal.Title;
            this.toolTip1.SetToolTip(this.pictureBox1, "V" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            this.Size = Settings.Default.FormSize;

            #endregion

            #region 刷新定时器

            if (SwGlobal.RefreshInterval > 0)
            {
                timer1.Interval = SwGlobal.RefreshInterval;
                this.RefreshEnabled = true;
            }
            else
            {
                this.RefreshEnabled = false;
            }

            #endregion
        }
Пример #2
0
 private void Shadowin_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.SwHotKeyManager != null)
     {
         try
         {
             this.SwHotKeyManager.Dispose();
         }
         catch
         {
         }
         finally
         {
             this.SwHotKeyManager = null;
         }
     }
 }