Пример #1
0
 static void DrawCur()
 {
     buf.SetBuffer(ConsoleBase.cbuf[x, y].fg, ConsoleBase.cbuf[x, y].bg, ConsoleBase.cbuf[x, y].ch);
     ConsoleBase.cbuf[x, y].bg = ConsoleColor.DarkYellow;
     ConsoleBase.cbuf[x, y].dr = true;
     ConsoleBase.Draw(x, y, 1, 1);
 }
Пример #2
0
        /// <summary>
        /// Redraws the text box, overrideable
        /// </summary>
        public override void Draw()
        {
            //Field
            int i, x;

            for (x = bounds.x; x < bounds.x + bounds.width; x++)
            {
                ConsoleBase.cbuf[x, bounds.y].SetBuffer(cfg, cbg, ' ');
            }
            //Text
            i = idx - bounds.width + 1;
            if (i < 0)
            {
                i = 0;
            }
            for (x = bounds.x; i < idx; i++, x++)
            {
                ConsoleBase.cbuf[x, bounds.y].SetBuffer(cfg, cbg, data[i]);
            }
            //Cursor if focused
            if (focused)
            {
                ConsoleBase.cbuf[x, bounds.y].SetBuffer(cfg, cbg, '_');
            }
            ConsoleBase.Draw(bounds);
        }
Пример #3
0
        /// <summary>
        /// Redraws the list box, overrideable
        /// </summary>
        public override void Draw()
        {
            string tmp;

            for (int s = scr, y = bounds.y; y < bounds.y + bounds.height; y++, s++)
            {
                tmp = items[s].PadRight(bounds.width - 1);
                if (s == idx)
                {
                    for (int i = 0, x = bounds.x; i < tmp.Length; i++, x++)
                    {
                        ConsoleBase.cbuf[x, y].SetBuffer(sfg, sbg, tmp[i]);
                    }
                }
                else
                {
                    for (int i = 0, x = bounds.x; i < tmp.Length; i++, x++)
                    {
                        ConsoleBase.cbuf[x, y].SetBuffer(fg, bg, tmp[i]);
                    }
                }
                ConsoleBase.cbuf[bounds.x + bounds.width - 1, y].SetBuffer(fg, bg, '█');
            }
            ConsoleBase.cbuf[bounds.x + bounds.width - 1, bounds.y].SetBuffer(cfg, cbg, up_a);
            ConsoleBase.cbuf[bounds.x + bounds.width - 1, bounds.y + bounds.height - 1].SetBuffer(cfg, cbg, dw_a);
            ConsoleBase.Draw(bounds);
        }
Пример #4
0
        /// <summary>
        /// Redraws the form and all of its controls
        /// </summary>
        public override void Draw()
        {
            base.Draw();
            uint br = (uint)border - 1;
            uint sh = (uint)shadow - 1;

            //Draw form
            if (border != BorderStyle.None)
            {
                for (int y = bounds.y + 1; y < bounds.y + 1 + bounds.height - 1; y++)
                {
                    ConsoleBase.cbuf[bounds.x, y].SetBuffer(fg, bg, fr[br, 1]);
                    ConsoleBase.cbuf[bounds.x + bounds.width - 1, y].SetBuffer(fg, bg, fr[br, 1]);
                }
                //Borders
                Console.SetCursorPosition(bounds.x, bounds.y);
                for (int x = bounds.x; x < bounds.x + bounds.width; x++)
                {
                    ConsoleBase.cbuf[x, bounds.y].SetBuffer(fg, bg, fr[br, 0]);
                }
                for (int x = bounds.x; x < bounds.x + bounds.width; x++)
                {
                    ConsoleBase.cbuf[x, bounds.y + bounds.height - 1].SetBuffer(fg, bg, fr[br, 0]);
                }
                //Corners
                ConsoleBase.cbuf[bounds.x, bounds.y].SetBuffer(fg, bg, fr[br, 2]);
                ConsoleBase.cbuf[bounds.x + bounds.width - 1, bounds.y].SetBuffer(fg, bg, fr[br, 3]);
                ConsoleBase.cbuf[bounds.x, bounds.y + bounds.height - 1].SetBuffer(fg, bg, fr[br, 4]);
                ConsoleBase.cbuf[bounds.x + bounds.width - 1, bounds.y + bounds.height - 1].SetBuffer(fg, bg, fr[br, 5]);
            }
            //Title
            if (text != null && text.Length > 0)
            {
                for (int i = 0, x = (bounds.x + bounds.x + bounds.width) / 2 - text.Length / 2; i < text.Length; i++, x++)
                {
                    ConsoleBase.cbuf[x, bounds.y].SetBuffer(tfg, bg, text[i]);
                }
            }
            //Shadow
            if (shadow != ShadowStyle.None)
            {
                for (int y = bounds.y + 1; y < bounds.y + 1 + bounds.height; y++)
                {
                    ConsoleBase.cbuf[bounds.x + bounds.width, y].SetBuffer(sfg, sbg, sw[sh]);
                }
                for (int x = bounds.x + 1; x < bounds.x + 1 + bounds.width; x++)
                {
                    ConsoleBase.cbuf[x, bounds.y + bounds.height].SetBuffer(sfg, sbg, sw[sh]);
                }
            }
            //Draw controls
            foreach (Control c in controls)
            {
                if (c.visible)
                {
                    c.Draw();
                }
            }
            ConsoleBase.Draw(bounds.x, bounds.y, bounds.width + 1, bounds.height + 1);
        }
Пример #5
0
        /// <summary>
        /// Redraws the control, overrideable
        /// </summary>
        public override void Draw()
        {
            string tmp = text.PadRight(bounds.width);

            for (int i = 0, x = bounds.x; i < tmp.Length; i++, x++)
            {
                ConsoleBase.cbuf[x, bounds.y].SetBuffer(cfg, cbg, tmp[i]);
            }
            ConsoleBase.Draw(bounds);
        }
Пример #6
0
 static void Thd()
 {
     while (enabled)
     {
         Thread.Sleep(ConsoleBase.TIME_WAIT);
         //Movement
         NativeClass.GetCursorPos(ref pos);
         delta = pos;
         NativeClass.SetCursorPos(cur_center.X, cur_center.Y);;
         if (delta.X != delta2.X || delta.Y != delta2.Y)
         {
             DrawBuff();
             delta2.X = delta.X - delta2.X;
             if (delta2.X > 0)
             {
                 x += 1;
             }
             else if (delta2.X < 0)
             {
                 x -= 1;
             }
             delta2.Y = delta.Y - delta2.Y;
             if (delta2.Y > 0)
             {
                 y += 1;
             }
             else if (delta2.Y < 0)
             {
                 y -= 1;
             }
             if (x < 0)
             {
                 x = 0;
             }
             else if (x > ConsoleBase.width - 1)
             {
                 x = ConsoleBase.width - 1;
             }
             if (y < 0)
             {
                 y = 0;
             }
             else if (y > ConsoleBase.height - 2)
             {
                 y = ConsoleBase.height - 2;
             }
             DrawCur();
             NativeClass.GetCursorPos(ref pos);
             delta = pos;
             ConsoleBase.ReDraw();
         }
         delta2 = delta;
     }
 }
Пример #7
0
        /// <summary>
        /// Redraws the check box, overrideable
        /// </summary>
        public override void Draw()
        {
            string tmp = ("[" + (check ? "X" : " ") + "] " + text).PadRight(bounds.width);

            for (int i = 0, x = bounds.x; i < tmp.Length; i++, x++)
            {
                ConsoleBase.cbuf[x, bounds.y].SetBuffer(cfg, cbg, tmp[i]);
            }
            for (int x = bounds.x; x < bounds.width; x++)
            {
                ConsoleBase.cbuf[x, y].SetBuffer(cfg, cbg, ' ');
            }
            ConsoleBase.Draw(bounds);
        }
Пример #8
0
        /// <summary>
        /// Redraws the progress bar, overrideable
        /// </summary>
        public override void Draw()
        {
            int tmp = (int)(bounds.width * ((float)val / (max - min)));

            for (int i = 0; i < tmp; i++)
            {
                ConsoleBase.cbuf[bounds.x + i, bounds.y].SetBuffer(sfg, sbg, ' ');
            }
            for (int i = tmp; i < bounds.width; i++)
            {
                ConsoleBase.cbuf[bounds.x + i, bounds.y].SetBuffer(fg, bg, ' ');
            }
            ConsoleBase.Draw(bounds);
        }
Пример #9
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);
            }
        }
Пример #10
0
 /// <summary>
 /// Draws the container
 /// </summary>
 public override void Draw()
 {
     for (int y = bounds.y; y < bounds.y + bounds.height; y++)
     {
         for (int x = bounds.x; x < bounds.x + bounds.width; x++)
         {
             ConsoleBase.cbuf[x, y].fg = fg;
             ConsoleBase.cbuf[x, y].bg = bg;
             ConsoleBase.cbuf[x, y].ch = ' ';
             ConsoleBase.cbuf[x, y].dr = true;
         }
     }
     //Draw controls
     foreach (Control c in controls)
     {
         if (c.visible)
         {
             c.Draw();
         }
     }
     ConsoleBase.Draw(bounds.x, bounds.y, bounds.width, bounds.height);
 }
Пример #11
0
 static void DrawBuff()
 {
     ConsoleBase.cbuf[x, y].SetBuffer(buf.fg, buf.bg, buf.ch);
     ConsoleBase.Draw(x, y, 1, 1);
 }