private void Initialize() { if (!_initialized) { Fullscreen(); _Dimension = GetResolution(); Size size = new Size((int)(_Dimension.Width * 1.2), (int)(_Dimension.Height * 1.2)); img = Properties.Resources._3; img = CT_Helper.resizeImage(img, size); initGame(); #region Menu int drawingPointWidth = _Dimension.Width / 2; int drawingPointHeight = _Dimension.Height / 2; Point menu = new Point(drawingPointWidth - 683 / 2, drawingPointHeight - 384 / 2); menuContainer = new DoubleBufferedPanel(menu); menuContainer.Width = _Dimension.Width; menuContainer.Height = _Dimension.Height; menuContainer.Location = new Point(0, 0); menuContainer.Name = "Menu"; menuHolder = new DoubleBufferedPanel(); string[] buttonTexts = { "Starten", "Laden", "Speichern", "Highscore","Pong spielen","Beenden" }; int positionMultiplicator = 1; int offset = 10; foreach (string text in buttonTexts) { VistaButton button = new VistaButton(); button.ButtonText = text; button.Width = 160; button.Height = 38; button.Location = new Point(offset + button.Width / 4, (button.Height + offset) * positionMultiplicator); menuHolder.Controls.Add(button); positionMultiplicator++; button.Click += Button_Click; button.KeyDown += CT_UI_KeyDown; button.KeyUp += CT_UI_KeyUp; button.BackColor = Color.Transparent; button.BaseColor = Color.Transparent; button.ButtonColor = Color.FromArgb(155, Color.DarkSlateGray); button.GlowColor = Color.LightGray; button.Font = new System.Drawing.Font("Pricedown", 16.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); button.CornerRadius = 8; } this.Controls.Add(menuContainer); this.Controls.Add(menuHolder); menuHolder.BringToFront(); menuHolder.BorderStyle = BorderStyle.Fixed3D; menuHolder.Width = 683; menuHolder.Height = 384; menuHolder.Location = menu; menuHolder.BackColor = Color.Black; menuContainer.BackColor = Color.FromArgb(150, Color.Black); #endregion setCursor(); this.Focus(); this.TransparencyKey = Color.FromArgb(255, 255, 254); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); pong=new Pong(new Size(_Dimension.Width,_Dimension.Height)); gameBox.Size = new Size(_Dimension.Width, _Dimension.Height); // Resize our backbuffer backbuffer = new Bitmap(gameBox.Size.Width,gameBox.Size.Height, PixelFormat.Format32bppPArgb); backBufferGraphics = Graphics.FromImage(backbuffer); Updater.Interval = UPDATE_INTERVAL; _initialized = true; } }
private void Initialize() { if (!_initialized) { Fullscreen(); _Dimension = GetResolution(); Size size = new Size((int)(_Dimension.Width * 1.2), (int)(_Dimension.Height * 1.2)); img = Properties.Resources._3; img = CT_Helper.resizeImage(img, size); initGame(); #region Menu int drawingPointWidth = _Dimension.Width / 2; int drawingPointHeight = _Dimension.Height / 2; Point menu = new Point(drawingPointWidth - 683 / 2, drawingPointHeight - 384 / 2); menuContainer = new DoubleBufferedPanel(menu); menuContainer.Width = _Dimension.Width; menuContainer.Height = _Dimension.Height; menuContainer.Location = new Point(0, 0); menuContainer.Name = "Menu"; menuHolder = new DoubleBufferedPanel(); string[] buttonTexts = { "Starten", "Laden", "Speichern", "Highscore", "Pong spielen", "Beenden" }; int positionMultiplicator = 1; int offset = 10; foreach (string text in buttonTexts) { VistaButton button = new VistaButton(); button.ButtonText = text; button.Width = 160; button.Height = 38; button.Location = new Point(offset + button.Width / 4, (button.Height + offset) * positionMultiplicator); menuHolder.Controls.Add(button); positionMultiplicator++; button.Click += Button_Click; button.KeyDown += CT_UI_KeyDown; button.KeyUp += CT_UI_KeyUp; button.BackColor = Color.Transparent; button.BaseColor = Color.Transparent; button.ButtonColor = Color.FromArgb(155, Color.DarkSlateGray); button.GlowColor = Color.LightGray; button.Font = new System.Drawing.Font("Pricedown", 16.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); button.CornerRadius = 8; } this.Controls.Add(menuContainer); this.Controls.Add(menuHolder); menuHolder.BringToFront(); menuHolder.BorderStyle = BorderStyle.Fixed3D; menuHolder.Width = 683; menuHolder.Height = 384; menuHolder.Location = menu; menuHolder.BackColor = Color.Black; menuContainer.BackColor = Color.FromArgb(150, Color.Black); #endregion setCursor(); this.Focus(); this.TransparencyKey = Color.FromArgb(255, 255, 254); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); pong = new Pong(new Size(_Dimension.Width, _Dimension.Height)); gameBox.Size = new Size(_Dimension.Width, _Dimension.Height); // Resize our backbuffer backbuffer = new Bitmap(gameBox.Size.Width, gameBox.Size.Height, PixelFormat.Format32bppPArgb); backBufferGraphics = Graphics.FromImage(backbuffer); Updater.Interval = UPDATE_INTERVAL; _initialized = true; } }