protected override void Initialize() { Window.Title = "Voxel Seeds"; base.Initialize(); IsMouseVisible = true; var windowControl = Window.NativeWindow as System.Windows.Forms.Control; System.Diagnostics.Debug.Assert(windowControl != null); _camera = new Camera((float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, (float)Math.PI * 0.35f, 1.0f, 1000.0f, windowControl); var mainThreadDispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher; windowControl.MouseClick += (object sender, System.Windows.Forms.MouseEventArgs e) => { if (e.Button == System.Windows.Forms.MouseButtons.Left) { mainThreadDispatcher.BeginInvoke(new Action(() => { if (_pickPosAvailable && _seedbar.GetSelected() >= 0 && _currentLevel.GetMap().IsInside(_pickedPos.X, _pickedPos.Y, _pickedPos.Z) && TypeInformation.GetPrice(_seedbar.GetSeedInfo()._type) <= _currentLevel.Resources) { _currentLevel.Resources -= TypeInformation.GetPrice(_seedbar.GetSeedInfo()._type); _currentLevel.InsertSeed(_pickedPos.X, _pickedPos.Y, _pickedPos.Z, _seedbar.GetSeedInfo()._type); } })); } }; }