示例#1
0
        /// <summary>
        /// Deinitializes the extended console
        /// </summary>
        /// <returns></returns>
        public static bool DeInit()
        {
            if (!enabled)
            {
                return(false);
            }

            ConsoleKeyPress.DeInit();
            enabled = false;
            NativeClass.NullThread(ref thd);
            return(true);
        }
示例#2
0
 /// <summary>
 /// Sets the mouse key handler, only one can be set
 /// </summary>
 /// <param name="hndl"></param>
 public static void SetMouseKeyHandler(MouseKeyHandler hndl)
 {
     ConsoleMouse.hndl = hndl;
     mousekey          = hndl != null;
     if (mousekey)
     {
         if (thd2 != null)
         {
             return;
         }
         thd2 = new Thread(Thd2);
         thd2.Start();
     }
     else
     {
         NativeClass.NullThread(ref thd2);
     }
 }
示例#3
0
 /// <summary>
 /// Sets the hotkey handler, only one can be set
 /// </summary>
 /// <param name="hndl"></param>
 public static void SetHotkeyHandler(HotKeyHandler hndl)
 {
     ConsoleBase.hndl = hndl;
     hotkey           = hndl != null;
     if (hotkey)
     {
         if (thd != null)
         {
             return;
         }
         thd = new Thread(Thd);
         thd.Start();
     }
     else
     {
         NativeClass.NullThread(ref thd);
     }
 }
示例#4
0
        /// <summary>
        /// Enables/Disables all controls event handlers including focus chaning behaviours
        /// </summary>
        /// <param name="input"></param>
        public static void EnableHandlers(bool input)
        {
            if (active == input)
            {
                return;
            }

            active = input;
            if (active)
            {
                thd = new Thread(Thd);
                thd.Start();
            }
            else
            {
                NativeClass.NullThread(ref thd);
            }
        }
示例#5
0
        /// <summary>
        /// Enables/Disables the mouse cursor
        /// </summary>
        /// <param name="input"></param>
        public static void SetCursorState(bool input)
        {
            if (enabled == input)
            {
                return;
            }

            enabled = input;
            if (buf == null)
            {
                buf = new ConsoleBuffer();
            }
            if (enabled)
            {
                thd = new Thread(Thd);
                thd.Start();
                //Trap mouse
                NativeClass.GetWindowRect(NativeClass.winhndl, ref clip);
                clip.Left   += 32;
                clip.Top    += 32;
                clip.Right  -= 32;
                clip.Bottom -= 32;
                NativeClass.ClipCursor(ref clip);
                cur_center.X = clip.Left + (clip.Right - clip.Left) / 2;
                cur_center.Y = clip.Top + (clip.Bottom - clip.Top) / 2;
                NativeClass.SetCursorPos(cur_center.X, cur_center.Y);
                NativeClass.GetCursorPos(ref pos);
                delta = delta2 = pos;
                DrawCur();
                ConsoleBase.ReDraw();
            }
            else
            {
                NativeClass.NullThread(ref thd);
                DrawBuff();
                ConsoleBase.ReDraw();
                clip.Left   = -1;
                clip.Top    = -1;
                clip.Right  = -1;
                clip.Bottom = -1;
                NativeClass.ClipCursor(ref clip);
            }
        }
示例#6
0
 internal static void DeInit()
 {
     enabled = false;
     NativeClass.NullThread(ref thd);
 }