Exemplo n.º 1
0
        internal void Initialize()
        {
            _threadSafety = new ThreadSafetyEnforcer("Main Window Class");
            _invoker      = new Invoker(_threadSafety);

            //This selects our first screen, and Loads it.


            //Width, Height, BitsPerPixle, resizable, openGL, fullscreen, hardware, frame
            //Video.SetVideoMode(ScreenWidth, ScreenHeight, BestBitsPerPixle, true, false, false, true, true);
            //Video.WindowCaption = "Tortoise Demo";

            //MainSurface = GenerateSurface();


            DebugFont = FontManager.GetInstance(Graphics, 12, FontTypes.Sans);

            TMouseState mouse    = Graphics.InputManager.MouseStateManager;
            TKeyState   keyboard = Graphics.InputManager.KeyStateManager;


            mouse.MouseDownEvent += Mouse_ButtonDown;
            mouse.MouseUpEvent   += Mouse_ButtonUp;
            mouse.MouseMoveEvent += Mouse_Move;

            keyboard.KeyboardKeyPressEvent   += Window_KeyDown;
            keyboard.KeyboardKeyReleaseEvent += Window_KeyUp;
            keyboard.KeyboardEvent           += Window_KeyPress;

            //_keyboard.KeyPress += new EventHandler<KeyEventArgs>(Window_KeyPress);

            Graphics.Control.Resize += new EventHandler(Window_Resize);


            tickEventData  = new TickEventArgs();
            frameTimer     = new Timer(true);
            TotalTimer     = new Timer(true);
            lastFrameTimes = new LimitedList <double>(30, 0);


            StormLib.Console.SetIfNotExsistValue("gf_RenderUpdateRec", ConsoleVarable.OnOffVarable("Draw Boxes showing Updated Areas"));
            StormLib.Console.SetIfNotExsistValue("gf_ShowFPS", ConsoleVarable.OnOffVarable("Displays FPS information"));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     绘制窗体的系统控制按钮
        /// </summary>
        /// <param name="g">画板</param>
        /// <param name="rect">按钮所在的区域</param>
        /// <param name="image">图片</param>
        /// <param name="state">鼠标状态</param>
        private void DrawSysButton(Graphics g, Rectangle rect, Image image, TMouseState state)
        {
            var imageRect = Rectangle.Empty;

            switch (state)
            {
            case TMouseState.Normal:
            case TMouseState.Leave:
                imageRect = new Rectangle(0, 0, rect.Width, rect.Height);
                break;

            case TMouseState.Move:
            case TMouseState.Up:
                imageRect = new Rectangle(rect.Width, 0, rect.Width, rect.Height);
                break;

            case TMouseState.Down:
                imageRect = new Rectangle(rect.Width * 2, 0, rect.Width, rect.Height);
                break;
            }
            g.DrawImage(image, rect, imageRect, GraphicsUnit.Pixel);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 动态获取文本高度
 /// </summary>
 public int AutoWidth(TMouseState state, string text, Size size)
 {
     return(TextRenderer.MeasureText(text, AutoFont(state), size).Width);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 动态获取文本高度
 /// </summary>
 public int AutoHeight(TMouseState state)
 {
     return(TextRenderer.MeasureText("Hello", AutoFont(state)).Height);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 绘画按钮
        /// </summary>
        /// <param name="g">画板</param>
        /// <param name="mouseState">鼠标状态</param>
        /// <param name="rect">按钮区域</param>
        /// <param name="str">图片字符串</param>
        internal void DrawButton(Graphics g, TMouseState mouseState, Rectangle rect, string str)
        {
            Bitmap bitmap = null;

            switch (mouseState)
            {
            case TMouseState.Normal:
                switch (str)
                {
                case "mini":
                    bitmap = Resources.QQ_SysButton_btn_mini_normal;
                    break;

                case "restore":
                    bitmap = Resources.QQ_SysButton_btn_restore_normal;
                    break;

                case "max":
                    bitmap = Resources.QQ_SysButton_btn_max_normal;
                    break;

                case "close":
                    bitmap = Resources.QQ_SysButton_btn_close_normal;
                    break;
                }
                break;

            case TMouseState.Move:
            case TMouseState.Up:
                switch (str)
                {
                case "mini":
                    bitmap = Resources.QQ_SysButton_btn_mini_highlight;
                    break;

                case "restore":
                    bitmap = Resources.QQ_SysButton_btn_restore_highlight;
                    break;

                case "max":
                    bitmap = Resources.QQ_SysButton_btn_max_highlight;
                    break;

                case "close":
                    bitmap = Resources.QQ_SysButton_btn_close_highlight;
                    break;
                }
                break;

            case TMouseState.Down:
                switch (str)
                {
                case "mini":
                    bitmap = Resources.QQ_SysButton_btn_mini_down;
                    break;

                case "restore":
                    bitmap = Resources.QQ_SysButton_btn_restore_down;
                    break;

                case "max":
                    bitmap = Resources.QQ_SysButton_btn_max_down;
                    break;

                case "close":
                    bitmap = Resources.QQ_SysButton_btn_close_down;
                    break;
                }
                break;
            }
            if (bitmap != null)
            {
                g.DrawImage(bitmap, rect);
            }
        }