예제 #1
0
        /// <summary>
        /// Draw Timer tick
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DrawTimer_Tick(object sender, EventArgs e)
        {
            // If not floating panel and the panel is active and AutoRefresh is OK
            if (this.DockAreas != DockAreas.Float && DockPanel.ActiveDocument == this)
            {
                int elapsed = Environment.TickCount - Time;

                Time = Environment.TickCount;


                // Stop the drawtimer
                DrawTimer.Stop();

                //Animation.Update(TimeSpan.FromMilliseconds(elapsed));

                Animation.Update(new GameTime(TimeSpan.Zero, TimeSpan.Zero, TimeSpan.Zero, TimeSpan.FromMilliseconds(elapsed)));

                GlFramesControl.Invalidate();
                GlTilesControl.Invalidate();
                GlPreviewControl.Invalidate();

                // Restart the draw timer
                DrawTimer.Start();
            }
        }
예제 #2
0
        /// <summary>
        /// OnResize
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GlTilesControl_Resize(object sender, EventArgs e)
        {
            //if (GlTilesControl.Context == null)
            //    return;

            GlTilesControl.MakeCurrent();
            Display.ViewPort = new Rectangle(new Point(), GlTilesControl.Size);
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AnimationForm_Load(object sender, EventArgs e)
        {
            GlTilesControl.MakeCurrent();
            Display.Init();

            GlFramesControl.MakeCurrent();
            Display.Init();

            GlPreviewControl.MakeCurrent();
            Display.Init();

            SpriteBatch = new SpriteBatch();

            // Preload background texture resource
            CheckerBoard = new Texture2D(ResourceManager.GetInternalResource("ArcEngine.Resources.checkerboard.png"));
            CheckerBoard.HorizontalWrap = TextureWrapFilter.Repeat;
            CheckerBoard.VerticalWrap   = TextureWrapFilter.Repeat;


            BuildInterface();

            // Draw timer
            DrawTimer.Start();
        }
예제 #4
0
        /// <summary>
        /// OnPaint
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GlTilesControl_Paint(object sender, PaintEventArgs e)
        {
            // Draws all tiles
            GlTilesControl.MakeCurrent();
            Display.ClearBuffers();


            SpriteBatch.Begin();

            // Background texture
            Rectangle dst = new Rectangle(Point.Empty, GlTilesControl.Size);

            SpriteBatch.Draw(CheckerBoard, dst, dst, Color.White);


            if (Animation.TileSet != null)
            {
                // Find the cursor location
                Point mouse = GlTilesControl.PointToClient(Control.MousePosition);


                int       maxheight = 0;
                Rectangle rect      = Rectangle.Empty;
                foreach (int id in Animation.TileSet.Tiles)
                {
                    // Get the display rectangle
                    Tile tile = Animation.TileSet.GetTile(id);
                    if (tile == null)
                    {
                        continue;
                    }
                    rect.Size = tile.Size;

                    // Blit the tile
                    //Animation.TileSet.Draw(id, new Point(rect.X + tile.HotSpot.X, rect.Y + tile.HotSpot.Y));
                    SpriteBatch.DrawTile(Animation.TileSet, id, new Point(rect.X + tile.Pivot.X, rect.Y + tile.Pivot.Y));

                    // Is mouse over or selected tile
                    if (rect.Contains(mouse) || TileID == id)
                    {
                        SpriteBatch.DrawRectangle(rect, Color.White);
                    }

                    // Move right
                    rect.X += tile.Size.Width;


                    // End of line ?
                    if (rect.X + rect.Width > GlTilesControl.Width)
                    {
                        rect.X    = 0;
                        rect.Y   += maxheight + 10;
                        maxheight = 0;
                    }


                    // Get the maximum height
                    maxheight = Math.Max(maxheight, rect.Height);
                }
            }

            SpriteBatch.End();
            GlTilesControl.SwapBuffers();
        }