static void Main() { Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var clientForm = new ClientForm() { ClientSize = new Size(800, 576), Text = "Maze™", }; GDIRenderer renderer = new GDIRenderer(clientForm); ClientFormInput input = new ClientFormInput(); ClientGameState state = new ClientGameState(); HookInputEvents(clientForm, input); GameEngine engine = new GameEngine(renderer, input, new InterpolationEngine(state)) { EnableRender = true, MinFrameTime = 16, UpdateTimeStep = 33, }; var game = new GameRunner(engine, state); var synchronizer = new StateSynchronizer(state, input); // TODO: Stop game thread and clean up when window starts closing game.RunAsync(); Application.Run(clientForm); }
private void DrawColumnBg(GDIRenderer ntr, PaintEventArgs e) { ntr.SetBrush(SystemColors.ControlLight); if (HorizontalOrientation) { var colWidth = HorizontalOrientedColumnWidth; ntr.DrawRectangle(0, 0, colWidth, Height - 2); ntr.FillRectangle(1, 1, colWidth - 1, Height - 3); int start = 0; foreach (var column in Columns) { start += CellHeight; ntr.Line(0, start, colWidth, start); } } else { ntr.DrawRectangle(0, 0, Width - 2, CellHeight); ntr.FillRectangle(1, 1, Width - 3, CellHeight - 1); int start = 0; foreach (var column in Columns) { start += column.Width; ntr.Line(start, 0, start, CellHeight); } } }
public PGDIRenderer(GDIContext gdi) { Graphics = new GDIRenderer(gdi); HollowBrush = new GDIBrush(BrushStyle.Hollow, HatchStyle.Horizontal, (Colorref)0, Guid.NewGuid()); Graphics.UseDefaultPen(); Graphics.UseDefaultBrush(); }
public Game(GameState state = null) { this.gameTimeTracker = new Stopwatch(); this.InitializeComponent(); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true); this.GameState = state ?? new GameState(); this.hasSavedState = state != null; this.gameRenderer = new GDIRenderer(); this.Initialize(); }
public InputRoll() { CellPadding = 3; //SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.Opaque, true); this.Font = new Font("Courier New", 8); //BackColor = Color.Transparent; gdi = new GDIRenderer(this); }
private void DrawBg(GDIRenderer ntr, PaintEventArgs e) { var start = StartBg; ntr.SetBrush(Color.White); ntr.FillRectangle(StartBg.X, StartBg.Y, Width, Height); ntr.DrawRectangle(StartBg.X, StartBg.Y, Width, Height); if (HorizontalOrientation) { } else { } }
public HexView() { NormalFont = new Font("Courier New", 8); // Only support fixed width SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.Opaque, true); Gdi = new GDIRenderer(); using (var g = CreateGraphics()) using (var LCK = Gdi.LockGraphics(g)) { _charSize = Gdi.MeasureString("A", NormalFont); // TODO make this a property so changing it updates other values. } }
private void DrawColumnText(GDIRenderer ntr, PaintEventArgs e) { if (HorizontalOrientation) { int start = 0; foreach (var column in Columns) { ntr.DrawString(column.Text, this.Font, Color.Black, new Point(CellPadding, start + CellPadding)); start += CellHeight; } } else { int start = 0; foreach (var column in Columns) { ntr.DrawString(column.Text, this.Font, Color.Black, new Point(start + CellPadding, CellPadding)); start += column.Width; } } }
public PixelBuffer(int width, int height) { // Create a MemoryDC to hold the bitmap. Use IntPtr.Zero // to create a device context that is compatible with the screen. fMemoryDC = GDI32.CreateCompatibleDC(IntPtr.Zero); fGraphPort = new GDIRenderer(new GDIDeviceContext(fMemoryDC)); // Create a bitmap compatible with the screen fBitmapInfo = new BITMAPINFO(); fBitmapInfo.Init(); fBitmapInfo.bmiHeader.biWidth = width; fBitmapInfo.bmiHeader.biHeight = -height; fBitmapInfo.bmiHeader.biPlanes = 1; fBitmapInfo.bmiHeader.biBitCount = 32; fBitmapInfo.bmiHeader.biClrImportant = 0; fBitmapInfo.bmiHeader.biClrUsed = 0; fBitmapInfo.bmiHeader.biCompression = GDI32.BI_RGB; fBitmapInfo.bmiColors = IntPtr.Zero; fBitmapHandle = GDI32.CreateDIBSection(User32.GetDC(IntPtr.Zero), ref fBitmapInfo, GDI32.DIB_RGB_COLORS, ref fBits, IntPtr.Zero, 0); fPixelData = new PixelData(width, height, 32, width * 4, fBits); // Get the bitmap structure back out so we can // get our hands on the created pointer and whatnot //GDI32.GetBitmap(fBitmapHandle, ref fBitmapStructure); //fBits = fBitmapStructure.bmBits; // Select the bitmap into the memoryDC fOldBitmapHandle = GDI32.SelectObject(fMemoryDC, fBitmapHandle); fAlpha = 255; }
public GDIRendererTest() { _form = new Mock <IGraphicsForm>(); _renderer = new GDIRenderer(_form.Object); }