Пример #1
0
 internal void FlushBaseWriter(ClipWriterAsync writer)
 {
     for (int x = writer.X; x < writer.X + writer.Width; ++x)
     {
         for (int y = writer.Y; y < writer.Y + writer.Height; ++y)
         {
             matrix[x, y].CopyData(writer.matrix[x, y]);
         }
     }
 }
Пример #2
0
        internal void Flush()
        {
            System.Threading.Monitor.Enter(flushlocker);
            //set Buffer
            if (LastSize != Size)
            {
                if (Buffer != null)
                {
                    Buffer.Dispose();
                }
                Buffer   = BufferedGraphicsManager.Current.Allocate(targetGraphics, new Rectangle(0, 0, Width, Height));
                LastSize = Size;
            }
            //Flush Elements
            var w = new Out.ClipWriterAsync(Owner);

            w.BeginWrite();
            Owner.MainContainer.DrawElements(w);
            w.EndWrite();
            //Draw Elements
            var g = Buffer.Graphics;

            if (g == null)
            {
                return;
            }
            g.Clear(Owner.Options.Background);
            var m = Owner.Matrix;
            int bw = Owner.Options.BoxWidth, bh = Owner.Options.BoxHeight;

            for (int x = 0; x < m.Width; ++x)
            {
                for (int y = 0; y < m.Height; ++y)
                {
                    using (var brush = new SolidBrush(m[x, y].Background))
                        g.FillRectangle(brush, new Rectangle(x * bw, y * bh, bw, bh));
                    using (var brush = new SolidBrush(m[x, y].Foreground))
                        g.DrawString((m[x, y].Value < 32 ? ' ' : m[x, y].Value).ToString(), Owner.Options.Font, brush, x * bw - 1, y * bh - 2);
                }
            }
            //Draw Mouse
            if (Owner.Options.ShowMouse)
            {
                if (Owner.Marker.Enabled)
                {
                    int sx = Math.Min(Owner.Marker.StartX, Owner.Marker.StopX), sy = Math.Min(Owner.Marker.StartY, Owner.Marker.StopY),
                        ex = Math.Max(Owner.Marker.StartX, Owner.Marker.StopX), ey = Math.Max(Owner.Marker.StartY, Owner.Marker.StopY);
                    using (var brush = new SolidBrush(Color.FromArgb(64, Color.White)))
                        g.FillRectangle(brush, new Rectangle(sx * bw, sy * bh, (ex - sx) * bw, (ey - sy) * bh));
                    g.DrawRectangle(Pens.Black, new Rectangle(sx * bw, sy * bh, (ex - sx) * bw, (ey - sy) * bh));
                }
                var x = (Cursor.Position.X - Left) / bw;
                var y = (Cursor.Position.Y - Top) / bh;
                using (var brush = new SolidBrush(Color.FromArgb(128, Color.White)))
                    g.FillRectangle(brush, new Rectangle(x * bw, y * bh, bw, bh));
                g.DrawRectangle(Pens.Black, new Rectangle(x * bw, y * bh, bw, bh));
            }
            //Render
            Buffer.Render();
            System.Threading.Monitor.Exit(flushlocker);
        }