Example #1
0
    /// <summary>
    /// Function to print characters on GUI and put required spacing between each characters.
    /// </summary>
    /// <param name="c">Bitmap array of the character to be printed.</param>
    /// <param name="C">Canvas Parameter.</param>
    /// <param name="CurrentPoint">Current Pointer of Text.</param>
    /// <returns></returns>
    public Point PrintAndSpace(int[] c, Canvas C, Point CurrentPoint)
    {
        for (ii = 0; ii < 20; ii++)
        {
            for (jj = 0; jj < (c.Length) / 20; jj++)
            {
                if (c[((c.Length) / 20) * ii + jj] == 1)
                {
                    C.DrawPoint(TextPen, CurrentPoint.X + jj, CurrentPoint.Y + ii);
                }
            }
        }


        CurrentPoint.X = CurrentPoint.X + jj;

        if (750 - CurrentPoint.X >= 16)
        {
            CurrentPoint.X = CurrentPoint.X + 1;
        }
        else
        {
            CurrentPoint.X = 16;
            CurrentPoint.Y = CurrentPoint.Y + 23;
        }



        return(CurrentPoint);
    }
Example #2
0
 private void Render()
 {
     Text.StringTextHandler(C, "welcome to jackal os v1.0", WelcomeStart);
     DrawEnd     = Text.StringTextHandler(C, "1. draw", DrawStart);
     TextBoxEnd  = Text.StringTextHandler(C, "2. notepad", TextBoxStart);
     ShutdownEnd = Text.StringTextHandler(C, "3. shutdown", ShutdownStart);
 }
        public static void DrawRectanglePartial(UIEnvironment env, Pen pen, Rectangle bounds, Rectangle relativeBounds)
        {
            var cosPoint = new Point(bounds.X, bounds.Y);

            Kernel.PrintDebug("drawing @ " + bounds.X + " | " + bounds.Y);
            env.DrawFilledRectangle(pen, cosPoint, relativeBounds.Width, relativeBounds.Height);
        }
Example #4
0
        private void CheckAndRenderIcons(Point Removed)
        {
            //Icon sizes & Positions

            /* Point ShutdownStart = new Point(750, 20);
             * int ShutdownSize = 30;
             * Point DrawStart = new Point(750, 60);
             * int DrawSize = 30;
             * Point TextBoxStart = new Point(750, 100);
             * int TextBoxSize = 30;*/

            //Check
            if ((Removed.X > ShutdownStart.X - 8) && (Removed.X < ShutdownStart.X + ShutdownSize + 8))
            {
                if ((Removed.Y > ShutdownStart.Y - 8) && (Removed.Y < ShutdownStart.Y + ShutdownSize + 8))
                {
                    Render();
                }
            }
            if ((Removed.X > DrawStart.X - 8) && (Removed.X < DrawStart.X + DrawSize + 8))
            {
                if ((Removed.Y > DrawStart.Y - 8) && (Removed.Y < DrawStart.Y + DrawSize + 8))
                {
                    Render();
                }
            }
            if ((Removed.X > TextBoxStart.X - 8) && (Removed.X < TextBoxStart.X + TextBoxSize + 8))
            {
                if ((Removed.Y > TextBoxStart.Y - 8) && (Removed.Y < TextBoxStart.Y + TextBoxSize + 8))
                {
                    Render();
                }
            }
        }
Example #5
0
        private void MouseClicked(Point CurMouse)
        {
            //Icon sizes & Positions

            /*Point ShutdownStart = new Point(750, 20);
             * int ShutdownSize = 30;
             * Point DrawStart = new Point(750, 60);
             * int DrawSize = 30;*/

            if ((CurMouse.X > ShutdownStart.X) && (CurMouse.X < ShutdownStart.X + ShutdownEnd.X))
            {
                if ((CurMouse.Y > ShutdownStart.Y) && (CurMouse.Y < ShutdownStart.Y + YSize))
                {
                    Sys.Power.Shutdown();
                }
            }
            if ((CurMouse.X > DrawStart.X) && (CurMouse.X < DrawStart.X + DrawEnd.X))
            {
                if ((CurMouse.Y > DrawStart.Y) && (CurMouse.Y < DrawStart.Y + YSize))
                {
                    DrawApp Draw = new DrawApp();
                    Draw.Draw(C);
                    Initialize();
                }
            }
            if ((CurMouse.X > TextBoxStart.X) && (CurMouse.X < TextBoxStart.X + TextBoxEnd.X))
            {
                if ((CurMouse.Y > TextBoxStart.Y) && (CurMouse.Y < TextBoxStart.Y + YSize))
                {
                    Notepad Note = new Notepad();
                    Note.Launch(C);
                    Initialize();
                }
            }
        }
Example #6
0
 /// <summary>
 /// Local function to remove the mouse specifically for the DrawApp.
 /// Not to be used outside the class.
 /// </summary>
 /// <param name="C">Canvas Object</param>
 /// <param name="Remove">Point from which mouse is to be removed</param>
 private void RemoveMouse(Canvas C, Point Remove)
 {
     C.DrawFilledRectangle(GUIHomePen, Remove, 8, 8);
     if (Remove.Y <= 20)
     {
         Initialize(C);
     }
 }
Example #7
0
 public ElPueblo(UIEnvironment env, Point location, Size?size = null) : base(env, location, size ?? new Size(64, 64))
 {
     InputBindings.Add(new MouseBinding(BeepBoopElPueblo, this));
     InputBindings.Add(new KeyBinding(() => Move(5), ConsoleKeyEx.RightArrow));
     InputBindings.Add(new KeyBinding(() => Move(-5), ConsoleKeyEx.LeftArrow));
     InputBindings.Add(new KeyBinding(() => Move(y: 5), ConsoleKeyEx.UpArrow));
     InputBindings.Add(new KeyBinding(() => Move(y: -5), ConsoleKeyEx.DownArrow));
 }
Example #8
0
 /// <summary>
 /// Starts a new instance of the Label class.
 /// </summary>
 /// <param name="text">The label text in the default color (white).</param>
 /// <param name="foreColor">The text color.</param>
 /// <param name="point">The point to place the label.</param>
 public Label(string text, Color foreColor, Cosmos.System.Graphics.Point point)
 {
     controlType    = ControlType.Label;
     X              = point.X;
     Y              = point.Y;
     Text           = text;
     prevText       = text;
     this.foreColor = foreColor;
 }
Example #9
0
 private void draw_chunky_pixel(int x, int y, Graphics.Pen pen)
 {
     for (int y_delta = y; y_delta <= y + 3; y_delta++)
     {
         for (int x_delta = x; x_delta <= x + 3; x_delta++)
         {
             Graphics.Point pixel = new Graphics.Point(x_delta, y_delta);
             screen.DrawPoint(pen, pixel);
         }
     }
 }
Example #10
0
 //Draw Filled Rectangle
 public static void DrawFilledRectangle(CGS.Pen color, CGS.Point position, int width, int height)
 {
     if (GraphicsInitialised())
     {
         aCanvas.DrawFilledRectangle(color, position, width, height);
     }
     else
     {
         InitialiseGraphics();
         DrawFilledRectangle(color, position, width, height);
     }
 }
Example #11
0
 public static void DrawRectangle(Color color, CGS.Point position, int width, int height)
 {
     if (GraphicsInitialised())
     {
         CGS.Pen pen = new CGS.Pen(color);
         aCanvas.DrawRectangle(pen, position, width, height);
     }
     else
     {
         InitialiseGraphics();
         DrawRectangle(color, position, width, height);
     }
 }
Example #12
0
        public void demo(string[] maincommand)
        {
            Init();

            Graphics.Pen pen;
            int          colour = 0;

            //colour squares
            for (int v = 0; v <= 2; v += 1)
            {
                for (int w = 0; w <= 2; w += 1)
                {
                    for (int y = 0; y <= 254; y += 3)
                    {
                        for (int x = 0; x <= 254; x += 3)
                        {
                            Color pixelcolour = new Color();
                            pixelcolour = Color.FromArgb(x, y, 44 * (v + w));
                            pen         = new Graphics.Pen(pixelcolour);

                            draw_chunky_pixel(x + 260 * w, y + 260 * v, pen);

                            colour++;
                            if (colour == 3)
                            {
                                colour = 0;
                            }
                        }
                    }
                }
            }
            //eyes
            screen.Clear();
            pen = new Graphics.Pen(Color.White);
            for (int y = 50; y <= 700; y += 42)
            {
                for (int x = 100; x <= 1000; x += 102)
                {
                    Graphics.Point pixel = new Graphics.Point(x, y);
                    for (int i = 20; i <= 50; i += 3)
                    {
                        screen.DrawEllipse(pen, pixel, i, 20);
                    }
                }
            }
            //triangles
            screen.CreateCursor();
            screen.SetCursor(true, 200, 300);
        }
Example #13
0
        public void Run()
        {
            Initialize();
            while (true)
            {
                Point CurMouse = Mouse.MouseLimit((int)CMouse.X, (int)CMouse.Y);
                Mouse.DrawMouse(C, MousePen, CurMouse);

                //To Remove the Mouse
                if ((PrevMouse.X != CurMouse.X) || (PrevMouse.Y != CurMouse.Y))
                {
                    RemoveMouse(PrevMouse);
                    PrevMouse = CurMouse;
                }

                if (Mouse.Click())
                {
                    MouseClicked(CurMouse);
                }
            }
        }
Example #14
0
        /// <summary>
        /// THis will launch the DrawApp on the current Canvas.
        /// </summary>
        /// <param name="C">Canvas on which DrawApp is to be launched.</param>
        public void Draw(Canvas C)
        {
            C.Clear(BackColor);
            Initialize(C);
            do
            {
                Point CurMouse = Mouse.MouseLimit((int)CMouse.X, (int)CMouse.Y);


                Mouse.DrawMouse(C, MousePen, CurMouse);

                if (Mouse.Click())
                {
                    //First Check Click on Power Button
                    if ((CurMouse.X > ScreenWidth - 21) && (CurMouse.X < ScreenWidth))
                    {
                        if (CurMouse.Y < 21)
                        {
                            return;
                        }
                    }

                    RemoveMouse(C, CurMouse);
                    do
                    {
                        CurMouse = Mouse.MouseLimit((int)CMouse.X, (int)CMouse.Y);
                        if ((PrevMouse.X != CurMouse.X) || (PrevMouse.Y != CurMouse.Y))
                        {
                            C.DrawLine(MousePen, CurMouse, PrevMouse);
                            PrevMouse = CurMouse;
                        }
                    } while (Mouse.Click());
                }
                else if ((PrevMouse.X != CurMouse.X) || (PrevMouse.Y != CurMouse.Y))
                {
                    RemoveMouse(C, PrevMouse);
                    PrevMouse = CurMouse;
                }
            } while (true);
        }
Example #15
0
        /// <summary>
        /// This function will draw the mouse on the Sceen.
        /// </summary>
        /// <param name="C">Canvas object onto which mouse is to be drawn</param>
        /// <param name="pen">Pen object with which mouse is to be drawn</param>
        public static void DrawMouse(Canvas C, Pen pen, Point CurMouse)
        {
            //CurMouse = MouseLimit((int)CurMouse.X, (int)CurMouse.Y);
            //Mouse Traingle Points are Below
            C.DrawPoint(pen, CurMouse.X, CurMouse.Y);
            C.DrawPoint(pen, new Point(CurMouse.X + 1, CurMouse.Y));
            C.DrawPoint(pen, new Point(CurMouse.X + 2, CurMouse.Y));
            C.DrawPoint(pen, new Point(CurMouse.X + 3, CurMouse.Y));
            C.DrawPoint(pen, new Point(CurMouse.X + 4, CurMouse.Y));
            C.DrawPoint(pen, new Point(CurMouse.X + 5, CurMouse.Y));

            C.DrawPoint(pen, new Point(CurMouse.X, CurMouse.Y + 1));
            C.DrawPoint(pen, new Point(CurMouse.X + 1, CurMouse.Y + 1));
            C.DrawPoint(pen, new Point(CurMouse.X + 2, CurMouse.Y + 1));
            C.DrawPoint(pen, new Point(CurMouse.X + 3, CurMouse.Y + 1));
            C.DrawPoint(pen, new Point(CurMouse.X + 4, CurMouse.Y + 1));

            C.DrawPoint(pen, new Point(CurMouse.X, CurMouse.Y + 2));
            C.DrawPoint(pen, new Point(CurMouse.X + 1, CurMouse.Y + 2));
            C.DrawPoint(pen, new Point(CurMouse.X + 2, CurMouse.Y + 2));
            C.DrawPoint(pen, new Point(CurMouse.X + 3, CurMouse.Y + 2));

            C.DrawPoint(pen, new Point(CurMouse.X, CurMouse.Y + 3));
            C.DrawPoint(pen, new Point(CurMouse.X + 1, CurMouse.Y + 3));
            C.DrawPoint(pen, new Point(CurMouse.X + 2, CurMouse.Y + 3));

            C.DrawPoint(pen, new Point(CurMouse.X, CurMouse.Y + 4));
            C.DrawPoint(pen, new Point(CurMouse.X + 1, CurMouse.Y + 4));

            C.DrawPoint(pen, new Point(CurMouse.X, CurMouse.Y + 5));
            // Mouse Triangle Over

            //Mouse Tail points are below
            C.DrawPoint(pen, new Point(CurMouse.X + 3, CurMouse.Y + 3));
            C.DrawPoint(pen, new Point(CurMouse.X + 4, CurMouse.Y + 4));
            C.DrawPoint(pen, new Point(CurMouse.X + 5, CurMouse.Y + 5));
            C.DrawPoint(pen, new Point(CurMouse.X + 6, CurMouse.Y + 6));
            C.DrawPoint(pen, new Point(CurMouse.X + 7, CurMouse.Y + 7));
        }
Example #16
0
 public static void MouseForDraw(Canvas C, Pen mousePen, Point CurMouse, Point PrevMouse)
 {
     C.DrawLine(mousePen, PrevMouse, CurMouse);
 }
Example #17
0
        private void MouseClicked(Point CurMouse)
        {
            //Icon sizes & Positions

            /*Point ShutdownStart = new Point(750, 20);
             * int ShutdownSize = 30;
             * Point DrawStart = new Point(750, 60);
             * int DrawSize = 30;*/

            if ((CurMouse.X > ShutdownStart.X) && (CurMouse.X < ShutdownStart.X + ShutdownSize))
            {
                if ((CurMouse.Y > ShutdownStart.Y) && (CurMouse.Y < ShutdownStart.Y + ShutdownSize))
                {
                    Sys.Power.Shutdown();
                }
            }
            if ((CurMouse.X > DrawStart.X) && (CurMouse.X < DrawStart.X + DrawSize))
            {
                if ((CurMouse.Y > DrawStart.Y) && (CurMouse.Y < DrawStart.Y + DrawSize))
                {
                    draw.Draw(C);
                    Initialize();
                }
            }
            if ((CurMouse.X > TextBoxStart.X) && (CurMouse.X < TextBoxStart.X + TextBoxSize))
            {
                if ((CurMouse.Y > TextBoxStart.Y) && (CurMouse.Y < TextBoxStart.Y + TextBoxSize))
                {
                    Console.WriteLine("Enter your text below. Press y to continue.");
                    Console.WriteLine("Press 1 to end the text");

                    TextPoint.X = 16;
                    TextPoint.Y = 16;

                    //To print the heading
                    Text.StringTextHandler(C, "enter your text below. press any key to continue. press ~ to end the text. press ` for backspace. ", TextPoint);
                    key         = Console.ReadKey();
                    CurrentChar = key.KeyChar;
                    //To start text from the last written character position
                    if (TextIconClickTest == true)
                    {
                        CurrentPoint.X    = 16;
                        CurrentPoint.Y    = 66;
                        TextIconClickTest = false;
                    }

                    //To print individual characters
                    while (CurrentChar != '~')
                    {
                        if (CurrentChar == '`')
                        {
                            C.DrawFilledRectangle(new Pen(Color.Gold), CurrentPoint.X - 8, CurrentPoint.Y, 15, 22);
                            CurrentPoint.X = CurrentPoint.X - 8;
                            if (CurrentPoint.X < 16) // To go in previous line while backspacing.
                            {
                                if (CurrentPoint.Y - 23 >= 66)
                                {
                                    CurrentPoint.X = 734;
                                    CurrentPoint.Y = CurrentPoint.Y - 23;
                                }
                                else
                                {
                                    CurrentPoint.X = 16;
                                    CurrentPoint.Y = 66;
                                }
                            }

                            goto here;
                        }

                        CurrentPoint = Text.CharTextHandler(C, CurrentChar, CurrentPoint);
here:
                        key         = Console.ReadKey();
                        CurrentChar = key.KeyChar;
                    }
                }
            }
        }
Example #18
0
 private void RemoveMouse(Point Remove)
 {
     C.DrawFilledRectangle(GUIHomePen, Remove, 8, 8);
     CheckAndRenderIcons(Remove);
 }
Example #19
0
 private void BeepBoopElPueblo()
 {
     Songs.ElPuebloTouch.Play();
     Location = new Point(RandomX(), RandomY());
 }
Example #20
0
 public MouseCursorElement(UIEnvironment env, Color mouseColor, Point loc, Size size) : base(env, loc, size, true)
 {
     _pen.Color = mouseColor;
 }
Example #21
0
        /// <summary>
        /// Launch the Notepad Application.
        /// </summary>
        /// <param name="C">Canvas Object</param>
        public void Launch(Canvas C)
        {
            C.Clear(BackColor);
            Initialize(C);
            bool  AllowText     = true;
            bool  TextTrigger   = true;
            Point InitialPoint  = new Point(10, 30);
            Point CurrentCursor = new Point(10, 60);
            Point OldCursor     = new Point(10, 60);

            do
            {
                while (AllowText)
                {
                    if (TextTrigger)
                    {
                        Text.StringTextHandler(C, "enter your text below, press ~ to stop, press ` for backspace.", InitialPoint);
                        TextTrigger = false;
                    }

                    Key = Console.ReadKey();
                    char CurrentChar = Key.KeyChar;

                    if (CurrentChar == '~')
                    {
                        AllowText = false;
                        break;
                    }
                    else if (CurrentChar == '`')
                    {
                        C.DrawFilledRectangle(GUIHomePen, OldCursor, CurrentCursor.X - OldCursor.X, 20);
                        CurrentCursor = OldCursor;
                    }
                    else
                    {
                        OldCursor     = CurrentCursor;
                        CurrentCursor = Text.CharTextHandler(C, CurrentChar, CurrentCursor);
                    }

                    if (CurrentCursor.X > 800)
                    {
                        CurrentCursor.X  = 10;
                        CurrentCursor.Y += 30;
                    }
                }

                Point CurMouse = Mouse.MouseLimit((int)CMouse.X, (int)CMouse.Y);
                Mouse.DrawMouse(C, MousePen, CurMouse);

                if (Mouse.Click())
                {
                    //Check Click on Power Button
                    if ((CurMouse.X > ScreenWidth - 21) && (CurMouse.X < ScreenWidth))
                    {
                        if (CurMouse.Y < 21)
                        {
                            return;
                        }
                    }
                }
                if ((PrevMouse.X != CurMouse.X) || (PrevMouse.Y != CurMouse.Y))
                {
                    RemoveMouse(C, PrevMouse);
                    PrevMouse = CurMouse;
                }
            } while (true);
        }
Example #22
0
    /// <summary>
    /// Function to detect characters from input string.
    /// </summary>
    /// <param name="C">Canvas Parameter.</param>
    /// <param name="ToPrint">String to be printed.</param>
    /// <param name="CurrentPoint1">Current pointer of Text.</param>
    public void StringTextHandler(Canvas C, string ToPrint, Point CurrentPoint1)

    {
        TextPen.Color = Color.Black;


        for (int ip = 0; ip < ToPrint.Length; ip++)
        {
            char currentChar = ToPrint[ip];
            switch (currentChar)
            {
            case 'a':
                CurrentPoint1 = PrintAndSpace(a, C, CurrentPoint1);
                break;

            case 'b':
                CurrentPoint1 = PrintAndSpace(b, C, CurrentPoint1);
                break;

            case 'c':
                CurrentPoint1 = PrintAndSpace(c, C, CurrentPoint1);
                break;

            case 'd':
                CurrentPoint1 = PrintAndSpace(d, C, CurrentPoint1);
                break;

            case 'e':
                CurrentPoint1 = PrintAndSpace(e, C, CurrentPoint1);
                break;

            case 'f':
                CurrentPoint1 = PrintAndSpace(f, C, CurrentPoint1);
                break;

            case 'g':
                CurrentPoint1 = PrintAndSpace(g, C, CurrentPoint1);
                break;

            case 'h':
                CurrentPoint1 = PrintAndSpace(h, C, CurrentPoint1);
                break;

            case 'i':
                CurrentPoint1 = PrintAndSpace(i, C, CurrentPoint1);
                break;

            case 'j':
                CurrentPoint1 = PrintAndSpace(j, C, CurrentPoint1);
                break;

            case 'k':
                CurrentPoint1 = PrintAndSpace(k, C, CurrentPoint1);
                break;

            case 'l':
                CurrentPoint1 = PrintAndSpace(l, C, CurrentPoint1);
                break;

            case 'm':
                CurrentPoint1 = PrintAndSpace(m, C, CurrentPoint1);
                break;

            case 'n':
                CurrentPoint1 = PrintAndSpace(n, C, CurrentPoint1);
                break;

            case 'o':
                CurrentPoint1 = PrintAndSpace(o, C, CurrentPoint1);
                break;

            case 'p':
                CurrentPoint1 = PrintAndSpace(p, C, CurrentPoint1);
                break;

            case 'q':
                CurrentPoint1 = PrintAndSpace(q, C, CurrentPoint1);
                break;

            case 'r':
                CurrentPoint1 = PrintAndSpace(r, C, CurrentPoint1);
                break;

            case 's':
                CurrentPoint1 = PrintAndSpace(s, C, CurrentPoint1);
                break;

            case 't':
                CurrentPoint1 = PrintAndSpace(t, C, CurrentPoint1);
                break;

            case 'u':
                CurrentPoint1 = PrintAndSpace(u, C, CurrentPoint1);
                break;

            case 'v':
                CurrentPoint1 = PrintAndSpace(v, C, CurrentPoint1);
                break;

            case 'w':
                CurrentPoint1 = PrintAndSpace(w, C, CurrentPoint1);
                break;

            case 'x':
                CurrentPoint1 = PrintAndSpace(x, C, CurrentPoint1);
                break;

            case 'y':
                CurrentPoint1 = PrintAndSpace(y, C, CurrentPoint1);
                break;

            case 'z':
                CurrentPoint1 = PrintAndSpace(z, C, CurrentPoint1);
                break;



            case ' ':
                CurrentPoint1 = PrintAndSpace(space, C, CurrentPoint1);
                break;

            case ',':
                CurrentPoint1 = PrintAndSpace(comma, C, CurrentPoint1);
                break;

            case '.':
                CurrentPoint1 = PrintAndSpace(fs, C, CurrentPoint1);
                break;

            case '~':
                CurrentPoint1 = PrintAndSpace(negation, C, CurrentPoint1);
                break;

            case '`':
                CurrentPoint1 = PrintAndSpace(bs, C, CurrentPoint1);
                break;


            case 'A':
                CurrentPoint1 = PrintAndSpace(A, C, CurrentPoint1);
                break;

            case '0':
                CurrentPoint1 = PrintAndSpace(zero, C, CurrentPoint1);
                break;

            case '1':
                CurrentPoint1 = PrintAndSpace(one, C, CurrentPoint1);
                break;

            case '2':
                CurrentPoint1 = PrintAndSpace(two, C, CurrentPoint1);
                break;

            case '3':
                CurrentPoint1 = PrintAndSpace(three, C, CurrentPoint1);
                break;

            case '4':
                CurrentPoint1 = PrintAndSpace(four, C, CurrentPoint1);
                break;

            case '5':
                CurrentPoint1 = PrintAndSpace(five, C, CurrentPoint1);
                break;

            case '6':
                CurrentPoint1 = PrintAndSpace(six, C, CurrentPoint1);
                break;

            case '7':
                CurrentPoint1 = PrintAndSpace(seven, C, CurrentPoint1);
                break;

            case '8':
                CurrentPoint1 = PrintAndSpace(eight, C, CurrentPoint1);
                break;

            case '9':
                CurrentPoint1 = PrintAndSpace(nine, C, CurrentPoint1);
                break;
            }
        }
    }
Example #23
0
 private void Move(int x = 0, int y = 0)
 {
     Location = new Point(Location.X + x, Location.Y + y);
 }