public void Run(string[] args)
        {
            using (frm = new PixelBufferForm())
            {
                frm.Show();

                DisplayWindow wind = DisplayWindow.CreateFromControl(frm.panel1);

                image  = new Surface("9ball.png");
                buffer = image.ReadPixels(PixelFormat.Any);

                Input.Unhandled.MouseDown += Mouse_MouseDown;
                Input.Unhandled.MouseMove += Mouse_MouseMove;
                Input.Unhandled.MouseUp   += (sender, e) => mouseDown = false;

                while (AgateApp.IsAlive && frm.IsDisposed == false)
                {
                    Display.BeginFrame();
                    Display.Clear();

                    image.Draw(imageLocation);

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }
            }
        }
Beispiel #2
0
        private void Run(string[] args)
        {
            using (new AgateWinForms(args)
                   .Initialize())
                using (new DisplayWindowBuilder(args)
                       .BackbufferSize(1280, 720)
                       .QuitOnClose()
                       .Build())
                {
                    inputHandler = new SimpleInputHandler();

                    inputHandler.KeyDown    += InputHandler_KeyDown;
                    inputHandler.KeyUp      += InputHandler_KeyUp;
                    inputHandler.MouseDown  += InputHandler_MouseDown;
                    inputHandler.MouseMove  += InputHandler_MouseMove;
                    inputHandler.MouseUp    += InputHandler_MouseUp;
                    inputHandler.MouseWheel += InputHandler_MouseWheel;

                    Input.Handlers.Add(inputHandler);

                    font = new Font(Font.AgateSans, 12);

                    while (AgateApp.IsAlive)
                    {
                        RenderScreen();

                        AgateApp.KeepAlive();
                    }

                    // Dispose of the input handler
                    inputHandler.Dispose();
                }
        }
Beispiel #3
0
        public void Run(string[] args)
        {
            using (var window = new DisplayWindowBuilder(args)
                                .BackbufferSize(640, 480)
                                .QuitOnClose()
                                .AllowResize()
                                .AutoResizeBackBuffer()
                                .Build())
            {
                window.Resize  += wind_Resize;
                window.Closed  += wind_Closed;
                window.Closing += wind_Closing;

                while (window.IsClosed == false)
                {
                    Display.BeginFrame();
                    Display.Clear(Color.Blue);

                    Font.AgateSans.Size = 12;
                    Font.AgateSans.DrawText(instructionText + count);
                    Font.AgateSans.DrawText(0, Font.AgateSans.FontHeight, text);

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }

                if (closedEvent == false)
                {
                    System.Windows.Forms.MessageBox.Show(
                        "Closed event did not fire!");
                }
            }
        }
        private void Run(string[] args)
        {
            using (new AgateWinForms(args)
                   .Initialize())
                using (new DisplayWindowBuilder(args)
                       .BackbufferSize(1280, 720)
                       .QuitOnClose()
                       .Build())
                {
                    inputHandler = new GamepadInputHandler();

                    playerOne = inputHandler.Gamepads.First();

                    Input.Handlers.Add(inputHandler);

                    font = new Font(Font.AgateSans, 12);

                    while (AgateApp.IsAlive)
                    {
                        Update(AgateApp.GameClock.Elapsed);
                        RenderScreen();

                        AgateApp.KeepAlive();
                    }

                    // Dispose of the input handler
                    inputHandler.Dispose();
                }
        }
Beispiel #5
0
        public void Run(string[] args)
        {
            using (new DisplayWindowBuilder(args)
                   .BackbufferSize(800, 600)
                   .QuitOnClose()
                   .Build())
            {
                Input.Unhandled.KeyDown += Keyboard_KeyDown;
                AgateApp.AutoPause       = true;

                fonts.Add(Font.AgateSans);
                fonts.Add(Font.AgateSerif);
                fonts.Add(Font.AgateMono);

                while (AgateApp.IsAlive)
                {
                    Display.BeginFrame();
                    Display.Clear(Color.Navy);

                    Rectangle drawRect;

                    FontTests(fonts[currentFont], out drawRect);

                    Display.Primitives.DrawRect(Color.Red, drawRect);

                    Display.EndFrame();
                    AgateApp.KeepAlive();

                    if (Input.Unhandled.Keys[KeyCode.Escape])
                    {
                        return;
                    }
                }
            }
        }
        public void Run(string[] args)
        {
            using (var wind = new DisplayWindowBuilder(args)
                              .BackbufferSize(300, 300)
                              .QuitOnClose()
                              .Title(Name)
                              .Build())
            {
                FrameBuffer buffer = new FrameBuffer(300, 300);

                while (AgateApp.IsAlive)
                {
                    IFont font = Font.AgateSans;
                    font.Size  = 24;
                    font.Color = Color.White;

                    Display.RenderTarget = buffer;
                    Display.BeginFrame();
                    Display.Clear(Color.Gray);

                    font.DrawText(string.Format("Time: {0}", Timing.TotalSeconds.ToString("0.0")));

                    Display.EndFrame();

                    Display.RenderTarget = wind.FrameBuffer;
                    Display.BeginFrame();
                    Display.Clear(Color.Gray);

                    buffer.RenderTarget.Draw();

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }
            }
        }
        public void Run(string[] args)
        {
            frmTileTester frm = new frmTileTester();

            frm.Show();

            tile = new Surface("bg-bricks.png");

            while (frm.IsDisposed == false)
            {
                Display.BeginFrame();
                Display.Clear(Color.FromRgb(255, 0, 255));

                DrawTiles();

                Display.EndFrame();
                AgateApp.KeepAlive();

                // move at 100 pixels per second
                if (frm.ScrollX)
                {
                    xval += (float)AgateApp.GameClock.Elapsed.TotalMilliseconds / 10.0f;
                }
                if (frm.ScrollY)
                {
                    yval += (float)AgateApp.GameClock.Elapsed.TotalMilliseconds / 10.0f;
                }

                frm.FPS = Display.FramesPerSecond;
            }
        }
        public void Run(string[] args)
        {
            using (windows = new DisplayWindowBuilder()
                             .BackbufferSize(800, 600)
                             .QuitOnClose()
                             .BuildSeparateWindowsForAllScreens())
            {
                Surface mousePointerSurface = new Surface("Images/pointer.png");

                Input.Unhandled.KeyDown   += Keyboard_KeyDown;
                Input.Unhandled.MouseMove += Mouse_MouseMove;

                Font font = new Font(Font.AgateSans);

                Size bottomSize = font.MeasureString(bottomText);
                Size topSize    = font.MeasureString(topText + "z\nz");

                var primaryWindow = windows.Single(x => x.Screen.IsPrimary);

                // Run the program while the window is open.
                while (AgateApp.IsAlive)
                {
                    var mouseText = topText +
                                    $"Resolution: {currentResolution}\nMouse: {mousePosition}";

                    Display.RenderTarget = primaryWindow.FrameBuffer;
                    Display.BeginFrame();
                    Display.Clear(Color.DarkGreen);

                    font.DrawText(0, Display.CurrentWindow.Height - bottomSize.Height, bottomText);

                    Display.Primitives.FillRect(Color.Maroon,
                                                new Rectangle(0, 0, Display.CurrentWindow.Width, topSize.Height));

                    font.DrawText(mouseText);

                    DrawMousePointer(primaryWindow, mousePointerSurface);

                    Display.EndFrame();

                    foreach (var window in windows.Where(w => !w.Screen.IsPrimary))
                    {
                        Display.RenderTarget = window.FrameBuffer;
                        Display.BeginFrame();
                        Display.Clear(Color.Gray);

                        font.DrawText(0, 0, $"Screen {window.Screen.Bounds}");

                        DrawMousePointer(window, mousePointerSurface);

                        Display.EndFrame();
                    }

                    AgateApp.KeepAlive();
                }

                mousePointerSurface.Dispose();
            }
        }
Beispiel #9
0
        public void Dispose()
        {
            Dispose(true);

            window.Dispose();
            platform.Dispose();
            AgateApp.Dispose();
        }
Beispiel #10
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (AgateApp.IsAlive == false)
            {
                return;
            }

            AgateApp.KeepAlive();
        }
        internal void UpdateDisplay()
        {
            if (this.Visible == false)
            {
                return;
            }

            Display.BeginFrame();
            Display.Clear(Color.LightGray);

            // draw the grid
            Color clr = Color.Gray;

            for (int x = 0; x < pctGraphics.Width; x += 30)
            {
                Display.Primitives.DrawRect(clr, new Rectangle(0, 0, x, pctGraphics.Height));
            }

            for (int y = 0; y < pctGraphics.Height; y += 30)
            {
                Display.Primitives.DrawRect(clr, new Rectangle(0, 0, pctGraphics.Width, y));
            }

            if (mSurface != null)
            {
                // set all the state-drawing options on the surface
                UpdateSurface();

                mSurface.Draw((int)nudX.Value, (int)nudY.Value);


                // this image should be drawn at 200, 100 unrotated.
                // this is to test to make sure that RotationCenter does not have
                // any effect on a displayed, unrotated sprite.
                mSurface.RotationAngleDegrees = 0;
                mSurface.DisplayAlignment     = OriginAlignment.TopLeft;
                mSurface.Alpha = 1.0;
                mSurface.SetScale(1.0, 1.0);

                mSurface.Draw(200, 100);
            }

            // box around sprite point to check alignment
            const int rectsize = 3;

            Display.Primitives.DrawRect(Color.Fuchsia,
                                        new Rectangle(
                                            (int)nudX.Value - rectsize,
                                            (int)nudY.Value - rectsize,
                                            2 * rectsize,
                                            2 * rectsize));


            Display.EndFrame();
            AgateApp.KeepAlive();
        }
Beispiel #12
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        public void Run(string[] args)
        {
            // create a random number generation object
            // so that we can make pretty colors.
            Random rand = new Random();

            frm = new DrawingTester();

            frm.btnClear.Click       += btnClear_Click;
            frm.btnDrawLine.Click    += btnDrawLine_Click;
            frm.btnDrawRect.Click    += btnDrawRect_Click;
            frm.btnDrawCircle.Click  += btnDrawCircle_Click;
            frm.btnDrawPolygon.Click += btnDrawPolygon_Click;
            frm.btnFillRect.Click    += btnFillRect_Click;
            frm.btnFillCircle.Click  += btnFillCircle_Click;
            frm.btnFillPolygon.Click += btnFillPolygon_Click;
            frm.Show();

            // This creates the window that we will be drawing in.
            // 640x480 are the dimensions of the screen area that we will write to
            using (var window = new DisplayWindowBuilder(args)
                                .RenderToControl(frm.panel1)
                                .AutoResizeBackBuffer()
                                .Build())
            {
                while (window.IsClosed == false)
                {
                    // Display.BeginFrame must be called before any rendering takes place.
                    Display.BeginFrame();

                    // Clear back buffer
                    Display.Clear();

                    // draw shapes
                    foreach (Shape s in shapes)
                    {
                        s.Draw();
                    }

                    // Display.EndFrame must be called after rendering is done
                    // in order to actually update the display.
                    Display.EndFrame();

                    // AgateApp.KeepAlive() is where we play nice window the OS,
                    // allowing events to be processed and such.
                    // This is also required to process events that happen in our OWN
                    // code (ie. user input), so be sure to call this once a frame.
                    AgateApp.KeepAlive();

                    // This gives a nice 1 second delay between each frame.
                    // Using the Sleep() call causes this application to
                    // relinquish CPU time.
                    System.Threading.Thread.Sleep(10);
                }
            }
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            using (new AgateWinForms(args)
                   .AssetPath("Assets")
                   .Initialize())
                using (new DisplayWindowBuilder(args)
                       .BackbufferSize(500, 400)
                       .Build())
                {
                    // Load the resource file and initialize the resource manager.
                    var resourceLoader  = new ResourceDataLoader();
                    var resourceManager = new AgateResourceManager(resourceLoader.Load("resources.yaml"));

                    // Create the object which will hold the UI.
                    var facet = new MyFacet();

                    resourceManager.InitializeContainer(facet);

                    // If the user hits escape or the B button on a game controller,
                    // exit the program.
                    facet.MainMenu.MenuCancel += (sender, e) => { AgateApp.IsAlive = false; };

                    // Attach a handler to each menu item if the user
                    // hits enter, the A button on a game controller, or
                    // clicks it with the mouse.
                    facet.StartItem.PressAccept += (sender, e) =>
                    {
                        facet.StartLabel.Text = "Thanks for starting the game!";
                    };

                    facet.QuitItem.PressAccept += (sender, e) =>
                    {
                        AgateApp.IsAlive = false;
                    };

                    // Install the user interface so that it captures input.
                    Input.Handlers.Add(facet.InterfaceRoot);

                    // Run the game loop
                    while (AgateApp.IsAlive)
                    {
                        // Update the UI outside a BeginFrame..EndFrame section.
                        facet.InterfaceRoot.OnUpdate(AgateApp.ApplicationClock.Elapsed, true);

                        Display.BeginFrame();
                        Display.Clear(Color.Gray);

                        // Draw the UI as the last thing before Display.EndFrame.
                        facet.InterfaceRoot.Draw();

                        Display.EndFrame();
                        AgateApp.KeepAlive();
                    }
                }
        }
Beispiel #14
0
        private static void DrawFormContents()
        {
            Display.RenderTarget = form.DisplayWindow.FrameBuffer;
            Display.BeginFrame();
            Display.Clear(Color.Maroon);

            var layout = Font.AgateSans.LayoutText(form.EntryText, form.DisplayWindow.Width);

            layout.Draw(new Point(0, 0));

            Display.EndFrame();
            AgateApp.KeepAlive();
        }
Beispiel #15
0
        public void Run(string[] args)
        {
            frmSpriteTester form = new frmSpriteTester();

            form.Show();

            while (form.Visible)
            {
                form.UpdateDisplay();

                AgateApp.KeepAlive();
            }
        }
Beispiel #16
0
        public void Run(string[] args)
        {
            using (var window = new DisplayWindowBuilder(args)
                                .BackbufferSize(800, 600)
                                .QuitOnClose()
                                .Build())
            {
                Input.Unhandled.KeyDown   += Keyboard_KeyDown;
                Input.Unhandled.MouseDown += Mouse_MouseDown;

                Surface surf = new Surface("Images/jellybean.png")
                {
                    Color = Color.Cyan
                };

                while (AgateApp.IsAlive)
                {
                    Display.BeginFrame();
                    Display.Clear(Color.DarkGreen);

                    switch (ortho)
                    {
                    case 1:
                        AgateBuiltInShaders.Basic2DShader.CoordinateSystem = new Rectangle
                                                                                 (0, 0, surf.SurfaceWidth * 2, surf.SurfaceHeight * 2);
                        break;

                    case 2:
                        AgateBuiltInShaders.Basic2DShader.CoordinateSystem = new Rectangle
                                                                                 (-surf.SurfaceWidth, -surf.SurfaceHeight, surf.SurfaceWidth * 2, surf.SurfaceHeight * 2);
                        break;
                    }

                    AgateBuiltInShaders.Basic2DShader.Activate();

                    Display.Primitives.FillRect(Color.Red, new Rectangle(-2, -2, 4, 4));
                    surf.Draw();

                    Display.FlushDrawBuffer();
                    AgateBuiltInShaders.Basic2DShader.CoordinateSystem =
                        new Rectangle(Point.Zero, Display.CurrentWindow.Size);
                    AgateBuiltInShaders.Basic2DShader.Activate();

                    Font.AgateSans.DrawText("Press space to cycle through coordinate systems.");

                    Display.EndFrame();

                    AgateApp.KeepAlive();
                }
            }
        }
Beispiel #17
0
        public void Run(string[] args)
        {
            var f1 = new frmCssEdit();

            f1.Show();

            Display.RenderState.WaitForVerticalBlank = false;

            while (f1.IsDisposed == false)
            {
                f1.RenderAgateStuff();
                AgateApp.KeepAlive();
                Thread.Sleep(5);
            }
        }
        public void Run(string[] args)
        {
            using (new DisplayWindowBuilder(args)
                   .BackbufferSize(800, 600)
                   .QuitOnClose()
                   .Build())
            {
                Surface someSurface = new Surface("Images/wallpaper.png");
                bool    capturing   = false;

                FrameBuffer capture = new FrameBuffer(1600, 1200);

                while (AgateApp.IsAlive)
                {
                    if (Input.Unhandled.Keys[KeyCode.C])
                    {
                        capturing = true;
                        Input.Unhandled.Keys.Release(KeyCode.C);
                    }
                    if (capturing)
                    {
                        Display.RenderTarget = capture;
                        someSurface.SetScale(2, 2);
                    }

                    Display.BeginFrame();

                    Display.Clear(Color.White);

                    someSurface.Draw();
                    Display.Primitives.FillRect(Color.Gray, new Rectangle(10, 10, 10, 10));

                    Display.EndFrame();

                    if (capturing)
                    {
                        capture.RenderTarget.SaveTo("CapturedImage.png", ImageFileFormat.Png);
                        Display.RenderTarget = Display.CurrentWindow.FrameBuffer;
                        someSurface.SetScale(1, 1);
                        capturing = false;

                        Debug.WriteLine("Captured image to CapturedImage.png");
                    }

                    AgateApp.KeepAlive();
                }
            }
        }
Beispiel #19
0
        void Application_Idle(object sender, EventArgs e)
        {
            if (Visible == false)
            {
                return;
            }

            for (int i = 0; i < InputLib.Input.Joysticks.Count; i++)
            {
                FillJoystickInfo(i, joystickLabels[i]);
            }

            timer1.Enabled = false;
            AgateApp.KeepAlive();

            timer1.Enabled = true;
        }
Beispiel #20
0
        public void Run(string[] args)
        {
            using (var wind = new DisplayWindowBuilder(args)
                              .BackbufferSize(800, 600)
                              .QuitOnClose()
                              .Build())
            {
                Input.Unhandled.KeyDown += Keyboard_KeyDown;

                FontState state = new FontState
                {
                    Size  = 14,
                    Style = FontStyles.None,
                };

                FontSurface font = Font.AgateSans.Core.FontSurface(state);

                FontSurface unkerned = ConstructUnkernedFont(font);

                string text = ConstructKerningText(wind, font);

                while (AgateApp.IsAlive)
                {
                    Display.BeginFrame();
                    Display.Clear();

                    FontSurface thisFont = useKerning ? font : unkerned;

                    if (useKerning)
                    {
                        thisFont.DrawText(state, "Using kerning. (space to toggle)");
                    }
                    else
                    {
                        thisFont.DrawText(state, "No kerning used. (space to toggle)");
                    }

                    state.Color = Color.White;
                    thisFont.DrawText(state, new Vector2(0, thisFont.FontHeight(state)), text);

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }
            }
        }
Beispiel #21
0
        public void Run(string[] args)
        {
            using (new DisplayWindowBuilder(args)
                   .BackbufferSize(800, 600)
                   .QuitOnClose()
                   .Build())
            {
                font      = Font.AgateSans;
                font.Size = 14;

                Input.Unhandled.MouseDown += Mouse_MouseDown;
                Input.Unhandled.KeyDown   +=
                    (sender, e) => done    = e.KeyCode == KeyCode.Escape;

                mySurface = new Surface("9ball.png");

                while (AgateApp.IsAlive && done == false)
                {
                    Display.RenderTarget = Display.CurrentWindow.FrameBuffer;
                    Display.BeginFrame();
                    Display.Clear(Color.Gray);

                    font.Color            = Color.White;
                    font.DisplayAlignment = OriginAlignment.TopLeft;
                    font.DrawText("Click or tap to create another frame buffer.");

                    int y = font.FontHeight;
                    int x = 10;
                    foreach (var surf in tests)
                    {
                        surf.Draw(x, y);
                        y += surf.DisplayHeight + 10;

                        if (y + 42 >= Display.CurrentWindow.Height)
                        {
                            y  = font.FontHeight;
                            x += 42;
                        }
                    }

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }
            }
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            using (new AgateWinForms(args).Initialize())
                using (new DisplayWindowBuilder(args)
                       .Title("AgateLib Settings Storage")
                       .BackbufferSize(500, 400)
                       .QuitOnClose()
                       .Build())
                {
                    Input.Unhandled.KeyDown += InputKeyDown;

                    var font = new Font(Font.AgateSans)
                    {
                        Size  = 12,
                        Style = FontStyles.Bold,
                    };

                    while (AgateApp.IsAlive)
                    {
                        Display.BeginFrame();
                        Display.Clear(Color.Gray);

                        font.DrawText(0, 0,
                                      "Use +/- keys to adjust hue.\nUse < and > to adjust saturation\nThese settings will persist \neach time this example is run.");

                        // Read the ColorSetting object from the configuration, or create it if it does not exist.
                        var setting = AgateApp.Settings.GetOrCreate <ColorSetting>("color", () => new ColorSetting());

                        Point point = new Point(10, 300);
                        Size  size  = new Size(480, 90);

                        Rectangle dest = new Rectangle(point, size);
                        Display.Primitives.FillRect(Color.FromHsv(setting.Hue, setting.Saturation, setting.Value), dest);

                        Display.EndFrame();

                        AgateApp.KeepAlive();
                    }

                    AgateApp.Settings.Save();
                }
        }
Beispiel #23
0
        public void Run(string[] args)
        {
            using (var window = new DisplayWindowBuilder(args)
                                .BackbufferSize(800, 600)
                                .QuitOnClose()
                                .Build())
            {
                LoopingStream sa = new LoopingStream();
                sa.Frequency = 100;

                StreamingSoundBuffer buf = new StreamingSoundBuffer(sa, SoundFormat.Pcm16(44100), 100);

                buf.Play();

                Stopwatch w = new Stopwatch();
                w.Start();

                var font = Font.AgateSans;

                while (AgateApp.IsAlive)
                {
                    Display.BeginFrame();
                    Display.Clear();

                    font.Color = Color.White;
                    font.DrawText(0, 0, string.Format("Frequency: {0}", sa.Frequency));

                    Display.EndFrame();
                    AgateApp.KeepAlive();

                    if (w.ElapsedMilliseconds > 500)
                    {
                        sa.Frequency += 50;
                        w.Reset();
                        w.Start();
                    }
                }

                buf.Stop();
            }
        }
        public void Run(string[] args)
        {
            frmRenderStateTest frm = new frmRenderStateTest();

            frm.Show();

            int count = 0;

            while (frm.Visible)
            {
                frm.UpdateFrame();

                count++;
                if (count > 60)
                {
                    frm.Text = string.Format("Render States - {0:0.00} FPS", AgateLib.DisplayLib.Display.FramesPerSecond);
                }

                AgateApp.KeepAlive();
            }
        }
Beispiel #25
0
        public void Draw()
        {
            Display.BeginFrame();
            Display.Clear(Color.Black);
            IFont font = Font.AgateSans;

            font.Size = 14;

            font.DrawText("FPS: " + Display.FramesPerSecond);

            pe.Draw();
            font.DrawText((int)pe.Position.X, (int)pe.Position.Y, "Particles: " + pe.Particles.Count + "/" + pe.Particles.Capacity);

            sm.Draw();
            font.DrawText((int)sm.Position.X, (int)sm.Position.Y, "Particles: " + sm.Particles.Count + "/" + sm.Particles.Capacity);

            se.Draw();
            font.DrawText((int)se.Position.X, (int)se.Position.Y, "Particles: " + se.Particles.Count + "/" + se.Particles.Capacity);

            Display.EndFrame();
            AgateApp.KeepAlive();
        }
        public void Run(string[] args)
        {
            using (var window = new DisplayWindowBuilder(args)
                                .BackbufferSize(800, 600)
                                .QuitOnClose()
                                .Build())
            {
                AgateConsole.CommandLibraries.Add(new LibraryVocabulary(this));

                while (AgateApp.IsAlive)
                {
                    Display.BeginFrame();
                    Display.Clear(Color.LightBlue);

                    Font.AgateSans.Color = Color.Black;
                    Font.AgateSans.DrawText("Press ~ key to open console.");

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }
            }
        }
        public void Run(string[] args)
        {
            using (new DisplayWindowBuilder(args)
                   .BackbufferSize(800, 600)
                   .QuitOnClose()
                   .Build())
            {
                Display.BeginFrame();
                Display.Clear(Color.Navy);
                Display.EndFrame();
                AgateApp.KeepAlive();

                BitmapFontOptions fontOptions = new BitmapFontOptions("Times", 18, FontStyles.None);
                fontOptions.TextRenderer = TextRenderEngine.TextRenderer;

                FontSurface surface = new FontSurface(BitmapFontUtil.ConstructFromOSFont(fontOptions));
                Font        font    = new FontBuilder("Times")
                                      .AddFontSurface(new FontSettings(18, FontStyles.None), surface)
                                      .Build();

                // TODO: Fix this
                //font.Save("testfont.xml");

                //FontSurface second = FontSurface.LoadBitmapFont("testfont.png", "testfont.xml");

                while (AgateApp.IsAlive)
                {
                    Display.BeginFrame();
                    Display.Clear(Color.Navy);

                    font.DrawText("The quick brown fox jumped over the lazy dogs.");

                    //second.DrawText(0, font.StringDisplayHeight("M"), "The quick brown fox jumps over the lazy dog.");

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }
            }
        }
        public void Run(string[] args)
        {
            ChangeDisplayWindow(3);

            Surface mySurface = new Surface("Images/pointer.png");

            Input.Unhandled.KeyDown   += Keyboard_KeyDown;
            Input.Unhandled.MouseMove += (sender, e) => mousePosition = e.MousePosition;

            IFont font = Font.AgateSans;

            Size bottomSize = font.MeasureString(bottomText);
            Size topSize    = font.MeasureString(topText + "z\nz");

            // Run the program while the window is open.
            while (AgateApp.IsAlive)
            {
                var mouseText = topText +
                                $"Resolution: {currentResolution}\nMouse: {mousePosition}";

                Display.BeginFrame();
                Display.Clear(Color.DarkGreen);

                font.DrawText(0, Display.CurrentWindow.Height - bottomSize.Height, bottomText);

                Display.Primitives.FillRect(Color.Maroon,
                                            new Rectangle(0, 0, Display.CurrentWindow.Width, topSize.Height));

                font.DrawText(mouseText);

                mySurface.Draw(mousePosition.X, mousePosition.Y);

                Display.EndFrame();
                AgateApp.KeepAlive();
            }

            mySurface.Dispose();
            wind.Dispose();
        }
Beispiel #29
0
        public void Run(string[] args)
        {
            using (var window = new DisplayWindowBuilder(args)
                                .BackbufferSize(800, 600)
                                .QuitOnClose()
                                .Build())
            {
                snda = new SoundBuffer("snda.wav");
                sndb = new SoundBuffer("sndb.wav");

                IFont font = Font.AgateSans;

                Input.Unhandled.KeyDown   += Keyboard_KeyDown;
                Input.Unhandled.MouseDown += Mouse_MouseDown;

                while (AgateApp.IsAlive)
                {
                    Display.BeginFrame();
                    Display.Clear();

                    font.Size  = 14;
                    font.Color = Color.White;
                    font.DrawText("Press a for first sound, b for second sound.");

                    if (snda.IsPlaying)
                    {
                        font.DrawText(0, 30, "first sound is playing");
                    }
                    if (sndb.IsPlaying)
                    {
                        font.DrawText(0, 60, "second sound is playing");
                    }

                    Display.EndFrame();
                    AgateApp.KeepAlive();
                }
            }
        }
Beispiel #30
0
        public void Run(string[] args)
        {
            using (new DisplayWindowBuilder(args)
                   .BackbufferSize(800, 600)
                   .QuitOnClose()
                   .Build())
            {
                FrameBuffer myBuffer = new FrameBuffer(200, 35);

                IFont font = Font.AgateSans;
                RenderToFrameBuffer(myBuffer, font);

                var watch = System.Diagnostics.Stopwatch.StartNew();

                while (AgateApp.IsAlive)
                {
                    Display.BeginFrame();
                    Display.Clear(Color.Black);

                    myBuffer.RenderTarget.Draw(35, 35);
                    font.DrawText(38, 73, "HELLO WORLD");

                    Display.EndFrame();

                    AgateApp.KeepAlive();

                    if (watch.ElapsedMilliseconds > 3000)
                    {
                        RenderToFrameBuffer(myBuffer, font);

                        watch.Reset();
                        watch.Start();
                    }
                }
            }
        }