internal override void _window_DrawGraphics(object sender, DrawGraphicsEventArgs e)
        {
            if (!Loaded)
            {
                return;
            }
            if (!_windowLoaded)
            {
                return;
            }

            e.Graphics.ClearScene();

            var layerUsed = false;

            if (!CurrentOpacity.CloseTo(1f))
            {
                var lp = new LayerParameters()
                {
                    ContentBounds = new RawRectangleF(0, 0, Window.Width, Window.Height), Opacity = CurrentOpacity
                };
                e.Graphics.LayerHelper.AddOpacity(lp);
                layerUsed = true;
            }

            DxWindow.Draw(e.Graphics);

            OnDraw?.Invoke(sender, e);

            if (layerUsed)
            {
                e.Graphics.LayerHelper.RemoveOpacity();
            }
        }
 protected override void Draw(GameTime gameTime)
 {
     OnPreDraw.Raise(this, new GameTimeEventArgs(gameTime));
     OnDraw.Raise(this, new GameTimeEventArgs(gameTime));
     base.Draw(gameTime);
     OnPostDraw.Raise(this, new GameTimeEventArgs(gameTime));
 }
Esempio n. 3
0
        /// <summary>
        /// Invalidate the current frame and draw + display a new frame.
        /// </summary>
        public void DrawGame()
        {
            screenInvalidated = true;

            if (container.chessBoardBitmap.Image != null)
            {
                container.chessBoardBitmap.Image.Dispose();
            }

            container.chessBoardBitmap.Image = new Bitmap(container.chessBoardBitmap.Size.Width, container.chessBoardBitmap.Size.Height);

            tileWidth  = container.chessBoardBitmap.Size.Width / (float)BoardSize;
            tileHeight = container.chessBoardBitmap.Size.Height / (float)BoardSize;

            for (int y = 0; y < BoardSize; y++)
            {
                for (int x = 0; x < BoardSize; x++)
                {
                    DrawTile(new Point(x, y));
                }
            }

            OnDraw?.Invoke(this, null);

            screenInvalidated = false;
        }
Esempio n. 4
0
 private void Draw(float time)
 {
     _dx11DeviceContext.ClearRenderTargetView(_renderView, Color);
     _dx11DeviceContext.ClearDepthStencilView(_depthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0);
     OnDraw?.Invoke(time);
     _swapChain.Present(0, PresentFlags.None);
 }
Esempio n. 5
0
        public void Rotate(Vector3 clickInWorldPos, List <ControlPoint> points, List <Vector2> originalPositions)
        {
            var delta = clickInWorldPos - (Vector3)transformPoint;

            var angle = Mathf.Atan2(delta.y, delta.x) * Mathf.Rad2Deg;

            Matrix3x3 rotateMat = Matrix3x3.TranslateMatrix(transformPoint.x, transformPoint.y) * Matrix3x3.RotationZMatrix(angle) * Matrix3x3.TranslateMatrix(-transformPoint.x, -transformPoint.y);

            for (var i = 0; i < points.Count; i++)
            {
                var point = points[i];
                var pos   = rotateMat * originalPositions[i];
                //point.position = RotatePointAroundPivot(originalPositions[i], transformPoint, new Vector3(0, 0, angle));
                point.position = pos;
            }

            if (angle < 0)
            {
                angle += 360;
            }

            onDraw = () =>
            {
                Draw.Arc(transformPoint, BezierCurveManager.Instance.ControlPointRadius * 2, .1f, 0, angle * Mathf.Deg2Rad, pointColor);
            };
        }
Esempio n. 6
0
        public void Scale(Vector3 clickInWorldPos, List <ControlPoint> points, List <Vector2> originalPositions)
        {
            clickInWorldPos.y = transformPoint.y;

            var delta = clickInWorldPos - (Vector3)transformPoint;

            var distance = Vector2.Distance(clickInWorldPos, transformPoint);

            distance *= scaleSpeed * Mathf.Sign(delta.x);

            Matrix3x3 scaleMat = Matrix3x3.TranslateMatrix(transformPoint.x, transformPoint.y) * Matrix3x3.ScaleMatrix(1 + distance, 1 + distance) * Matrix3x3.TranslateMatrix(-transformPoint.x, -transformPoint.y);

            for (var i = 0; i < points.Count; i++)
            {
                var point = points[i];
                var pos   = scaleMat * originalPositions[i];
                //point.position = originalPositions[i] + (originalPositions[i] - transformPoint).normalized * (Vector2.Distance(originalPositions[i], transformPoint) * distance);
                point.position = pos;
            }

            onDraw = () =>
            {
                Draw.Line(transformPoint, clickInWorldPos, .2f, pointColor);
            };
        }
Esempio n. 7
0
        private void mapPanel_Paint(object sender, PaintEventArgs e)
        {
            if (mapImage != null)
            {
                double aspectRatioX = (double)mapPanel.Width / (double)mapImage.Width;
                double aspectRatioY = (double)mapPanel.Height / (double)mapImage.Height;

                ratio = aspectRatioX < aspectRatioY ? aspectRatioX : aspectRatioY;

                scaleHeight = Convert.ToInt32(mapImage.Height * ratio);
                scaleWidth  = Convert.ToInt32(mapImage.Width * ratio);

                Rectangle destination = new Rectangle()
                {
                    X = 0, Y = 0, Width = scaleWidth, Height = scaleHeight
                };

                e.Graphics.TranslateTransform(mapPanel.Width / 2, mapPanel.Height / 2);
                e.Graphics.ScaleTransform(fibonacciZoom[zoomIndex], fibonacciZoom[zoomIndex]);
                e.Graphics.TranslateTransform(-mapPanel.Width / 2, -mapPanel.Height / 2);
                e.Graphics.TranslateTransform(drawSpotX, drawSpotY);
                e.Graphics.DrawImage(mapImage, destination);
                OnDraw?.Invoke(e.Graphics);
                e.Graphics.ResetTransform();
            }
            e.Graphics.DrawLine(Pens.Yellow, 0, mapPanel.Height / 2, mapPanel.Width, mapPanel.Height / 2);
            e.Graphics.DrawLine(Pens.Yellow, mapPanel.Width / 2, 0, mapPanel.Width / 2, mapPanel.Height);
        }
Esempio n. 8
0
        /// <summary>
        /// Prepares the device for drawing and invoke OnDraw event
        /// </summary>
        /// <exception cref="System.Exception">
        /// </exception>
        public void BeginDraw()
        {
            if (d3dContext == null)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name + "DeviceContext is null");
            }

            if (d3dRenderTarget != null && viewport != null)
            {
                d3dContext.OutputMerger.SetRenderTargets(d3dDepthStencil, d3dRenderTarget);
                d3dContext.Rasterizer.SetViewport(viewport);
                d3dContext.ClearRenderTargetView(d3dRenderTarget, BackgroundColor);
                d3dContext.ClearDepthStencilView(d3dDepthStencil,
                                                 D3D11.DepthStencilClearFlags.Depth | D3D11.DepthStencilClearFlags.Stencil, 1, 0);

                if (OnDraw != null)
                {
                    OnDraw.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name + " RenderTarget or Viewport is null");
            }
        }
Esempio n. 9
0
        void IThreadProcess.Update()
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);

            OnDraw?.Invoke();

            _window.SwapBuffers();
        }
Esempio n. 10
0
 public override void Draw()
 {
     OnDraw?.Invoke(this, new DrawEventArgs($"It's square"));
     foreach (Point p in points)
     {
         p.Draw();
     }
 }
Esempio n. 11
0
 public WebMapTileImage()
 {
     Image         = new HTMLImageElement();
     Image.OnLoad += (e) =>
     {
         OnDraw?.Invoke(this, new EventArgs());
     };
 }
Esempio n. 12
0
        public void Draw()
        {
            var tempBitmap = new Bitmap(drawable.Width, drawable.Height);
            var g          = Graphics.FromImage(tempBitmap);

            population.First().Value.Draw(g);
            OnDraw?.Invoke(tempBitmap);
        }
Esempio n. 13
0
 public IFuture<ICardAgent> Draw()
 {
     var cardModel = Model.Draw();
     var futureAgent = New.Future<ICardAgent>();
     var agent = Registry.Get<ICardAgent>(cardModel);
     OnDraw?.Invoke(agent);
     futureAgent.Value = agent;
     return futureAgent;
 }
        protected override void Draw(GameTime gameTime)
        {
            _drawStopwatch.Start();
            OnDraw?.Invoke(this, gameTime);
            _drawStopwatch.Stop();

            DrawTime = (int)_drawStopwatch.ElapsedMilliseconds;
            _drawStopwatch.Reset();
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            ContextSettings contextSettings = new ContextSettings()
            {
                DepthBits         = 32,
                AntialiasingLevel = 8
            };

            Window = new RenderWindow(new VideoMode(700, 500), "Client", Styles.Default, contextSettings);
            Window.SetFramerateLimit(61);
            Window.SetActive();
            Window.Closed  += Window_Closed;
            Window.Resized += Window_Resized;

            sL = new GUI.ScanLines();
            Program.CConsole = new GUI.Console();
            TestMenu         = new TestMenu();

            Map = new GUI.Map();

            /*
             * PlayerName = LoadName();
             * CNetwork = new Network();
             * CConsole = new GUI.Console();
             * DebugView dv = new DebugView();*/
            PreShakeView = Window.GetView();
            Random random = new Random(DateTime.Now.Millisecond);

            while (Window.IsOpen())
            {
                Window.DispatchEvents();
                Window.Clear(new Color(50, 50, 50));
                if (OnUpdate != null)
                {
                    OnUpdate.Invoke();
                }

                if (Shake)
                {
                    View view = Window.GetView();
                    view.Move(new Vector2f(random.Next(-2, 3), random.Next(-2, 2)));
                    Window.SetView(view);
                }
                else
                {
                    View newView = new View(new FloatRect(0, 0, Window.Size.X, Window.Size.Y));
                    Window.SetView(newView);
                }

                ElapsedGameTime++;
                if (OnDraw != null)
                {
                    OnDraw.Invoke();
                }
                Window.Display();
            }
        }
Esempio n. 16
0
        protected virtual async void OnFrame(object sender, RangeBaseValueChangedEventArgs e)
        {
            if (m_current_frame.HasValue && m_current_frame.Value != (int)m_slider.Value)
            {
                await GetRenderObjects();

                OnDraw?.Invoke();
            }
            m_current_frame = (int)m_slider.Value;
        }
 public ShapeDrawerController()
 {
     client = new Client();
     client.Start("127.0.0.1", 1111);
     client.OnShadeSelected += (o, e) =>
     {
         ShapeDrawerPaint(e.Message.Shape);
         OnDraw?.Invoke(this, new ShapeEventArgs(e.Message.Shape));
     };
 }
Esempio n. 18
0
        //---------------------------------------//
        //-----         MÉTODOS             -----//
        //---------------------------------------//

        /// <summary>
        /// Desenha o ator.
        /// </summary>
        /// <param name="gameTime">Obtém acesso aos tempos de jogo.</param>
        /// <param name="spriteBatch">A instância do SpriteBatch para desenho.</param>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (Enable.IsVisible)
            {
                Components.Draw(gameTime, spriteBatch, ActorComponent.DrawPriority.Back);
                _Draw(gameTime, spriteBatch);
                OnDraw?.Invoke(this, gameTime, spriteBatch);
                Components.Draw(gameTime, spriteBatch, ActorComponent.DrawPriority.Forward);
            }
        }
Esempio n. 19
0
 public void Draw()
 {
     if (_x >= 0 && _y >= 0)
     {
         OnDraw?.Invoke(this, new DrawEventArgs($"({_x},{_y})"));
     }
     else
     {
         throw new PointException("I can't draw in negative...");
     }
 }
Esempio n. 20
0
        private void Canvas_OnDraw(DXCanvas canvas, DXCanvas.Layer layer)
        {
            Vector scale      = new Vector(1.0 / Scroll.Area.Width, 1.0 / Scroll.Area.Height);
            Matrix cameraView = new Matrix(scale.X, 0, 0, scale.Y, -scale.X * Scroll.Area.Location.X, -scale.Y * Scroll.Area.Location.Y);

            canvas.CameraView = cameraView;

            Scroll.Size = new Size(canvas.RenderCanvas.ClientSize.Width / RenderSettings.DpiScale.X, canvas.RenderCanvas.ClientSize.Height / RenderSettings.DpiScale.Y);

            OnDraw?.Invoke(canvas, layer, Scroll);
        }
Esempio n. 21
0
 private void EmitDrawEvent(DrawState state, bool isEmpty = false)
 {
     OnDraw.Invoke(this, new DrawEventArgs()
     {
         DrawType = current.Shape,
         Shape    = current.Element as Shape,
         IsEmpty  = isEmpty,
         Area     = current.ElementRect,
         State    = state
     });
 }
Esempio n. 22
0
 private void Draw()
 {
     if (isPaused)
     {
         return;
     }
     _dx11DeviceContext.ClearRenderTargetView(_renderView, new SharpDX.Color(0, 0, 0));
     _dx11DeviceContext.ClearDepthStencilView(_depthView, DX11.DepthStencilClearFlags.Depth | DX11.DepthStencilClearFlags.Stencil, 1.0f, 0);
     OnDraw?.Invoke(1);
     _swapChain.Present(0, PresentFlags.None);
 }
Esempio n. 23
0
 /// <summary>
 /// Draws the GameObject to the screen.
 /// </summary>
 /// <param name="spriteBatch">The spriteBatch to draw to.</param>
 void IGameObject.Draw(SpriteBatch spriteBatch)
 {
     if (OnDraw != null)
     {
         foreach (Func <SpriteBatch, bool> delg in OnDraw.GetInvocationList())
         {
             if (!delg.Invoke(spriteBatch))
             {
                 return;
             }
         }
     }
 }
Esempio n. 24
0
        public override void Draw(RenderContext rc, CommandBuffer cb)
        {
            Clear();

            if (OnDraw != null)
            {
                OnDraw.Invoke(this, rc, cb);
            }
            else
            {
                DrawScene(cb);
            }
        }
Esempio n. 25
0
        public void Draw(SpriteBatch sb)
        {
            float lastParallaxValue = float.NaN;

            foreach (IWorldObject obj in WorldObjects)
            {
                // skip objects that don't have anything to draw
                if (!(obj is IRenderedObject rObj))
                {
                    continue;
                }

                float parallaxValue = (obj is IParallaxable pObj) ? pObj.ParallaxMultiplier : 1.0f;

                if (parallaxValue != lastParallaxValue || rObj.DisableBatching)
                {
                    // if it isn't the first time we begin a new SpriteBatch we'll first have to end the old one
                    if (!float.IsNaN(lastParallaxValue))
                    {
                        sb.End();
                    }

                    Matrix transformMatrix = parallaxValue != 1.0f ? Camera.GetMatrix(parallaxValue) : Camera.GetMatrix();

                    sb.Begin(blendState: BlendState.AlphaBlend,
                             rasterizerState: RasterizerState.CullNone,
                             transformMatrix: transformMatrix);
                }

                rObj.Draw(sb, Camera);
                lastParallaxValue = parallaxValue;
            }

            sb.End();



            if (Settings.DrawColliders)
            {
                sb.Begin(transformMatrix: Camera.GetMatrix());
                foreach (ICollider collider in Colliders)
                {
                    collider.Draw(sb, Camera, Color.Green, false);
                }
                sb.End();
            }



            OnDraw?.Invoke(this, sb);
        }
Esempio n. 26
0
        protected override void Draw(GameTime gameTime)
        {
            if (UiThread == null)
            {
                UiThread = Thread.CurrentThread;
            }

            _drawStopwatch.Start();
            OnDraw?.Invoke(this, gameTime);
            _drawStopwatch.Stop();

            DrawTime = (int)_drawStopwatch.ElapsedMilliseconds;
            _drawStopwatch.Reset();
        }
Esempio n. 27
0
        private void Display()
        {
            // this is more or less part of what reshade/etc do to avoid having to manually
            // set the cursor inside the ui
            // This will just tell ImGui to draw its own software cursor instead of using the hardware cursor
            // The scene internally will handle hiding and showing the hardware (game) cursor
            // If the player has the game software cursor enabled, we can't really do anything about that and
            // they will see both cursors.
            // Doing this here because it's somewhat application-specific behavior
            //ImGui.GetIO().MouseDrawCursor = ImGui.GetIO().WantCaptureMouse;
            this.lastWantCapture = ImGui.GetIO().WantCaptureMouse;

            OnDraw?.Invoke();
        }
Esempio n. 28
0
        /// <summary>
        /// Draw this entity.
        /// </summary>
        /// <param name="parent">Parent node that's currently drawing this entity.</param>
        /// <param name="localTransformations">Local transformations from the direct parent node.</param>
        /// <param name="worldTransformations">World transformations to apply on this entity (this is what you should use to draw this entity).</param>
        public override void Draw(Node parent, ref Matrix localTransformations, ref Matrix worldTransformations)
        {
            // not visible / no active camera? skip
            if (!Visible || GraphicsManager.ActiveCamera == null)
            {
                return;
            }

            // call draw callback
            OnDraw?.Invoke(this);

            // draw all meshes
            foreach (DictionaryEntry mesh in _meshes)
            {
                GraphicsManager.DrawEntity(mesh.Value as MeshEntity, worldTransformations);
            }
        }
Esempio n. 29
0
        public void Draw(Image cameraSource)
        {
            if (DateTime.UtcNow > intervalEnd)
            {
                intervalEnd = DateTime.UtcNow.AddSeconds(1);
                fps         = frameCount;
                frameCount  = 0;
            }

            lock (mutex) // img disposed during resize - prevent error
            {
                backbufferGraphics.Clear(Color.Black);

                var imgSourceBmp      = (Bitmap)cameraSource.Clone();
                var imgSourceGraphics = Graphics.FromImage(imgSourceBmp);

                if (OnDraw != null)
                {
                    OnDraw.Invoke(new DrawEventArgs(imgSourceGraphics, cameraSource));
                }

                var newWidth  = 0;
                var newHeight = 0;

                if (panel.Width < panel.Height)
                {
                    var aspectRatio = (double)imgSourceBmp.Height / imgSourceBmp.Width;
                    newWidth  = (int)panel.Width;
                    newHeight = (int)(newWidth * aspectRatio);
                }
                else
                {
                    var aspectRatio = (double)imgSourceBmp.Width / imgSourceBmp.Height;
                    newHeight = panel.Height;
                    newWidth  = (int)(newHeight * aspectRatio);
                }

                backbufferGraphics.DrawImage(imgSourceBmp, new Rectangle((panel.Width - newWidth) / 2, 0, newWidth, newHeight), new Rectangle(0, 0, imgSourceBmp.Width, imgSourceBmp.Height), GraphicsUnit.Pixel);// prevent flickering
                foregroundGraphics.DrawImage(backBuffer, new Point(0, 0));
            }

            frameCount++;
        }
Esempio n. 30
0
        /// <summary> Отрисовка текста из буфера. </summary>
        public static void Flush()
        {
            OnDraw?.Invoke();
            while (writeData.Count > 0)
            {
                WriteData wd = writeData.Dequeue();
                if (wd.Text == null)
                {
                    continue;
                }

                // set pos
                if (wd.X.HasValue)
                {
                    Console.CursorLeft = wd.X.Value;
                }
                if (wd.Y.HasValue)
                {
                    Console.CursorTop = wd.Y.Value;
                }

                // set color
                if (wd.ForeColor.HasValue)
                {
                    Console.ForegroundColor = wd.ForeColor.Value;
                }
                if (wd.BackColor.HasValue)
                {
                    Console.BackgroundColor = wd.BackColor.Value;
                }

                // write
                if (wd.Text.Length > Console.BufferWidth)
                {
                    // fix width
                    Console.Write(wd.Text.Substring(0, Console.BufferWidth - 3) + "...");
                }
                else
                {
                    Console.Write(wd.Text);
                }
            }
        }