Exemplo n.º 1
0
        private void Render()
        {
            if (!this.IsVisible)
            {
                return;
            }
            // do lock to avoid resize/repaint race in control
            // where are BMP and GFX recreates
            // better practice is Monitor.TryEnter() pattern, but here we do it simpler
            lock (razorPainterWPFCtl1.RazorLock)
            {
                //if (visualization != null)
                //	visualization.DrawFrame(razorPainterWPFCtl1.RazorGFX, razorPainterWPFCtl1.RazorWidth, razorPainterWPFCtl1.RazorHeight, frame);

                if (renderedframe != frame)
                {
                    Visualization.DrawFrame(g, Buffer.Width, Buffer.Height, frame);
                    g.Flush();
                    renderedframe = frame;
                }
                if (Visualization == null)
                {
                    razorPainterWPFCtl1.RazorGFX.Clear(System.Drawing.SystemColors.Control);
                    var nya = global::project.Properties.Resources.horo_vector_4_by_straywolf;
                    razorPainterWPFCtl1.RazorGFX.DrawImage(nya, 0, razorPainterWPFCtl1.RazorHeight - (nya.Height * razorPainterWPFCtl1.RazorWidth / nya.Width), razorPainterWPFCtl1.RazorWidth, nya.Height * razorPainterWPFCtl1.RazorWidth / nya.Width);
                }
                else
                {
                    razorPainterWPFCtl1.RazorGFX.DrawImageUnscaled(Buffer, 0, 0);
                }
                if ((Buffer.Width != razorPainterWPFCtl1.RazorWidth || Buffer.Height != razorPainterWPFCtl1.RazorHeight) && (
                        razorPainterWPFCtl1.RazorWidth > 0 && razorPainterWPFCtl1.RazorWidth < 10000 &&
                        razorPainterWPFCtl1.RazorHeight > 0 && razorPainterWPFCtl1.RazorHeight < 10000
                        ))
                {
                    g.Dispose();
                    Buffer = new Bitmap((int)razorPainterWPFCtl1.RazorWidth, (int)razorPainterWPFCtl1.RazorHeight);
                    g      = Graphics.FromImage(Buffer);
                }
                razorPainterWPFCtl1.RazorGFX.DrawString(fps2.ToString(), font, System.Drawing.Brushes.Black, new PointF(0, 0));
                razorPainterWPFCtl1.RazorPaint();
            }
            fps++;
        }
Exemplo n.º 2
0
 public void SetTimeAndFrame(int time, float frame)
 {
     lock (razorPainterWPFCtl1.RazorLock)
     {
         if (visualization == null)
         {
             return;
         }
         if (time != this.time)
         {
             this.time = Math.Min(Visualization.BattleLength, time);
             Visualization.SetTime(time);
         }
         if (frame == this.frame)
         {
             return;
         }
         this.frame = frame;
     }
 }