public void Run() { OnStart?.Invoke(this, EventArgs.Empty); var windowSettings = _config.WindowSettings; if (windowSettings == null) { throw new Exception("Window settings option is null"); } _window = new MainWindow(windowSettings); MainWindowUtils.Initialize(_window); _window.Closed += (sender, args) => { ShouldExit = true; }; _window.Run(); var eventArgs = new EventArgs(); while (!ShouldExit) { MainLoop?.Invoke(this, eventArgs); } OnExit?.Invoke(this, EventArgs.Empty); }
protected override void Initialize() { if (string.IsNullOrEmpty(Text) || Font == null) { return; } TextureManager = new RectangleTextureManager(); using (var graphics = MainWindowUtils.GetGraphics()) { var size = graphics.MeasureString(Text, Font); var bitmap = new Bitmap((int)size.Width, (int)size.Height); using (var gfx = System.Drawing.Graphics.FromImage(bitmap)) using (var brush = new SolidBrush(FontColor)) { gfx.DrawString(Text, Font, brush, 0, 0); } var texture = new Texture2D(bitmap); texture.Initialize(); TextureManager.Face = new Face(texture, Color.FromArgb((int)(Opacity * 255), Color.White)); Height = size.Height; Width = size.Width; } base.Initialize(); Initialized = true; }