Esempio n. 1
0
        internal void HandleMouseWheel(object sender, MouseEventArgs e)
        {
            float worldX, worldY;

            Camera.ScreenToWorld(e.X, e.Y, out worldX, out worldY);

            float differenceX = Camera.X - worldX;
            float differenceY = Camera.Y - worldY;

            float oldZoom = Camera.Zoom;

            if (e.Delta < 0)
            {
                mWireframeEditControl.ZoomOut();
            }
            else
            {
                mWireframeEditControl.ZoomIn();
            }

            float newDifferenceX = differenceX * oldZoom / Camera.Zoom;
            float newDifferenceY = differenceY * oldZoom / Camera.Zoom;

            Camera.X = worldX + newDifferenceX;
            Camera.Y = worldY + newDifferenceY;

            CameraChanged?.Invoke();
        }
Esempio n. 2
0
        public void Initialize(WireframeEditControl wireframeEditControl, Panel wireframeParentPanel)
        {
            try
            {
                mWireframeEditControl = wireframeEditControl;



                mWireframeEditControl.ZoomChanged += HandleZoomChanged;

                SystemManagers.Default = new SystemManagers();
                SystemManagers.Default.Initialize(GraphicsDevice);

                Renderer.Self.SamplerState = SamplerState.PointWrap;

                LoaderManager.Self.ContentLoader = new ContentLoader();

                LoaderManager.Self.Initialize(null, "content/TestFont.fnt", Services, null);
                CameraController.Self.Initialize(Camera, mWireframeEditControl, Width, Height);
                CameraController.Self.CameraChanged += () => CameraChanged?.Invoke();

                InputLibrary.Cursor.Self.Initialize(this);
                InputLibrary.Keyboard.Self.Initialize(this);

                mScreenBounds        = new LineRectangle();
                mScreenBounds.Name   = "Gum Screen Bounds";
                mScreenBounds.Width  = 800;
                mScreenBounds.Height = 600;
                mScreenBounds.Color  = ScreenBoundsColor;
                ShapeManager.Self.Add(mScreenBounds, SelectionManager.Self.UiLayer);

                this.KeyDown        += OnKeyDown;
                this.KeyPress       += OnKeyPress;
                this.MouseDown      += CameraController.Self.HandleMouseDown;
                this.MouseMove      += CameraController.Self.HandleMouseMove;
                this.MouseWheel     += CameraController.Self.HandleMouseWheel;
                this.mTopRuler       = new Ruler(this, null, InputLibrary.Cursor.Self);
                mLeftRuler           = new Ruler(this, null, InputLibrary.Cursor.Self);
                mLeftRuler.RulerSide = RulerSide.Left;

                if (AfterXnaInitialize != null)
                {
                    AfterXnaInitialize(this, null);
                }

                UpdateToProject();

                mHasInitialized = true;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error initializing the wireframe control\n\n" + exception);
            }
        }
Esempio n. 3
0
        internal void HandleMouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Middle)
            {
                int xChange = e.X - mLastMouseLocation.X;
                int yChange = e.Y - mLastMouseLocation.Y;

                Renderer.Self.Camera.Position.X -= xChange / Renderer.Self.Camera.Zoom;
                Renderer.Self.Camera.Position.Y -= yChange / Renderer.Self.Camera.Zoom;

                Gum.ToolCommands.GuiCommands.Self.RefreshWireframe();

                if (xChange != 0 || yChange != 0)
                {
                    CameraChanged?.Invoke();
                }

                mLastMouseLocation = e.Location;
            }
        }
Esempio n. 4
0
 internal void HandleKeyPress(KeyEventArgs e)
 {
     if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
     {
         if (e.KeyCode == System.Windows.Forms.Keys.Up)
         {
             SystemManagers.Default.Renderer.Camera.Y -= 10 / SystemManagers.Default.Renderer.Camera.Zoom;
             CameraChanged?.Invoke();
         }
         else if (e.KeyCode == System.Windows.Forms.Keys.Down)
         {
             SystemManagers.Default.Renderer.Camera.Y += 10 / SystemManagers.Default.Renderer.Camera.Zoom;
             CameraChanged?.Invoke();
         }
         else if (e.KeyCode == System.Windows.Forms.Keys.Left)
         {
             SystemManagers.Default.Renderer.Camera.X -= 10 / SystemManagers.Default.Renderer.Camera.Zoom;
             CameraChanged?.Invoke();
         }
         else if (e.KeyCode == System.Windows.Forms.Keys.Right)
         {
             SystemManagers.Default.Renderer.Camera.X += 10 / SystemManagers.Default.Renderer.Camera.Zoom;
             CameraChanged?.Invoke();
         }
         else if (e.KeyCode == Keys.Oemplus || e.KeyCode == Keys.Add)
         {
             mWireframeEditControl.ZoomIn();
             CameraChanged?.Invoke();
         }
         else if (e.KeyCode == Keys.OemMinus || e.KeyCode == Keys.Subtract)
         {
             mWireframeEditControl.ZoomOut();
             CameraChanged?.Invoke();
         }
     }
 }
Esempio n. 5
0
 internal void SendCameraChanged(CameraPosition position)
 {
     CameraChanged?.Invoke(this, new CameraChangedEventArgs(position));
 }
 //called when a camera event needs to be generated
 protected virtual void OnCamera(EventData eventData)
 {
     CameraChanged?.Invoke(eventData);
 }
 public void OnCameraChanged(EventData evt)
 {
     CameraChanged?.Invoke("camera changed data..." + evt);
 }
Esempio n. 8
0
 internal void SendOnCameraChange(Position point, double zoom)
 {
     CameraChanged?.Invoke(this, new CameraChangedEventArgs(point, zoom));
 }