private void LoadImageBtn_Click(object sender, EventArgs e)
        {
            if (OpenImageDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    using (var stream = OpenImageDialog.OpenFile())
                        image = new Bitmap(stream);

                    imageName = Path.GetFileNameWithoutExtension(OpenImageDialog.FileName)?.Trim();

                    Properties.Settings.Default.LastImage = OpenImageDialog.FileName;
                }
                catch (ArgumentException)
                {
                    MessageBox.Show(this, @"The selected file was not a valid image.", @"Invalid image file",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    image     = null;
                    imageName = null;
                }
                finally
                {
                    isChanged = true; // force update
                    RedrawTimer.Stop();
                    RedrawTimer.Start();
                }
            }
        }
Esempio n. 2
0
 private void MainWindow_Load(object sender, EventArgs e)
 {
     OpenGLControl.InitializeContexts();
     panel1.Dock = DockStyle.Fill;
     panel2.Dock = DockStyle.Right;
     MainWindow_Resize(null, null);
     RedrawTimer.Interval = (int)(1000.0f / (float)Settings.Hz);
     RedrawTimer.Start();
 }
        private void FilterTextBox_TextChanged(object sender, EventArgs e)
        {
            if (!AutomaticRedrawChkBox.Checked)
            {
                return;
            }

            RedrawTimer.Stop();
            RedrawTimer.Start();
        }
Esempio n. 4
0
        private void RedrawTimer_Tick(object sender, EventArgs e)
        {
            CurrentTest.Step(Settings);
            Renderer.OpenGLDraw(CurrentTest);
            OpenGLControl.Draw();

            int errorCode = 0;

            if ((errorCode = Gl.glGetError()) > 0)
            {
                RedrawTimer.Stop();

                //Handled by the OpenGLControl
                //MessageBox.Show(Glu.gluErrorString(errorCode));
            }
        }
Esempio n. 5
0
        public Game()
        {
            InitializeComponent();

            ScreenBounds = ClientRectangle;

            new Player(new RectangleF((ScreenBounds.Width / 2) - 5, ScreenBounds.Height * 0.9f, 10, 10), Textures.Ship);

            float insetTop = 10, insetBottom = ScreenBounds.Height * 0.5f;
            float insetLeft = 10, insetRight = 10;

            RectangleF enemySpawnArea = ScreenBounds;

            enemySpawnArea.Location = PointF.Add(enemySpawnArea.Location, new SizeF(insetLeft, insetTop));
            enemySpawnArea.Size    -= new SizeF(insetLeft + insetRight, insetTop + insetBottom);

            float enemyWidth  = 10;
            float enemyHeight = 10;

            int enemyRows    = 10;
            int enemyColumns = 5;

            float enemySpaceX = (enemySpawnArea.Width - enemyWidth) / (enemyRows - 1);
            float enemySpaceY = (enemySpawnArea.Height - enemyHeight) / (enemyColumns - 1);

            for (int x = 0; x < enemyRows; x++)
            {
                for (int y = 0; y < enemyColumns; y++)
                {
                    new Enemy(new RectangleF(enemySpawnArea.X + x * enemySpaceX, enemySpawnArea.Y + y * enemySpaceY, 10, 10));
                }
            }

            UpdateTimer.Start();
            RedrawTimer.Start();

            this.KeyDown += new KeyEventHandler(Input.KeyDown);
            this.KeyUp   += new KeyEventHandler(Input.KeyUp);
        }