static void DrawChar(char c, Brush brush, DeviceContextRenderTarget g) { //if((p.Y / 8) >= 108) { if ((p.Top / 8) >= 108) { //Debug.WriteLine(p.Y); //p.X = 0; //p.Y = 0; p.Left = 0; p.Top = 0; g.BeginDraw(); //g.DrawText(c.ToString(), f, p, brush); g.FillRectangle(p, brush); g.EndDraw(); //g.DrawString(c.ToString(), f, brush, p); } else { //if ((p.X / 8) > (192 - 1)) { if ((p.Left / 8) > (192 - 1)) { //p.X = 0; //p.Y += 8; p.Left = 0; p.Top += 8; //g.DrawString(c.ToString(), f, brush, p); g.BeginDraw(); //g.DrawText(c.ToString(), f, p, brush); g.FillRectangle(p, brush); g.EndDraw(); } else { //g.DrawString(c.ToString(), f, brush, p); g.BeginDraw(); //g.DrawText(c.ToString(), f, p, brush); g.FillRectangle(p, brush); g.EndDraw(); //p.X += 8; p.Left += 8; } } }
public RenderTarget Create(Factory factory, Graphics g, Map map) { var hdc = g.GetHdc(); var rtp = new RenderTargetProperties( RenderTargetType.Default, new PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied), 0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT); var rt = new DeviceContextRenderTarget(factory, rtp); rt.Tag = hdc; rt.BindDeviceContext(hdc, new SharpDX.Rectangle(0, 0, map.Size.Width, map.Size.Height)); rt.BeginDraw(); return(rt); }
static void Main(string[] args) { string filename = null; using (var dialog = new OpenFileDialog { Multiselect = false, Title = "Select video", Filter = "Video|*.mp4" }) { if (dialog.ShowDialog() == DialogResult.OK) { filename = dialog.FileName; } else { Environment.Exit(0); } } //CONSOLE_FONT_INFO_EX fontInfo = new CONSOLE_FONT_INFO_EX(); //fontInfo.FaceName = "Terminal"; //fontInfo.FontFamily = 0x00; //fontInfo.FontWeight = 400; //fontInfo.cbSize = 100; //fontInfo.dwFontSize.X = fontInfo.dwFontSize.Y = 8; //SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), false, ref fontInfo); MoveWindow(GetConsoleWindow(), 100, 100, 100, 100, true); Console.BufferWidth = 192; Console.BufferHeight = 108; Console.WindowWidth = 192; Console.WindowHeight = 108; factory = new Factory(FactoryType.MultiThreaded); dwFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared); f = new SharpDX.DirectWrite.TextFormat(dwFactory, "Terminal", 8f); var renderTargetProperties = new RenderTargetProperties() { PixelFormat = new SharpDX.Direct2D1.PixelFormat(SharpDX.DXGI.Format.B8G8R8A8_UNorm, AlphaMode.Ignore) }; var renderTarget = new DeviceContextRenderTarget(factory, renderTargetProperties); //AppDomain.CurrentDomain.ProcessExit += (s, e) => { renderTarget.EndDraw(); }; System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(GetConsoleWindow()); renderTarget.BindDeviceContext(g.GetHdc(), new RawRectangle(0, 0, 192 * 8, 108 * 8)); //g.Transform = new System.Drawing.Drawing2D.Matrix(); //PlayVideo(filename, renderTarget); Random r = new Random(); RawRectangleF raw = new RawRectangleF(50, 50, 100, 100); Brush b = new SolidColorBrush(renderTarget, new RawColor4(100, 100, 100, 255)); for (int i = 0; i < 1473; i++) { //DrawChar('d', new SolidColorBrush(renderTarget, new RawColor4(r.Next(255), r.Next(255), r.Next(255), 255)), renderTarget); renderTarget.BeginDraw(); renderTarget.DrawRectangle(raw, new SolidColorBrush(renderTarget, new RawColor4(r.Next(255), r.Next(255), r.Next(255), 255))); renderTarget.EndDraw(); } Console.ReadKey(); }