Пример #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();
        }
Пример #2
0
        protected async ValueTask SelectCamera(string deviceId)
        {
            await JavaScript.StartVideoAsync(deviceId, "#camera");

            _activeCamera = deviceId;

            if (CameraChanged.HasDelegate)
            {
                await CameraChanged.InvokeAsync(_activeCamera);
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
        protected async ValueTask SelectCamera(string deviceId, bool persist = true)
        {
            if (persist)
            {
                await JavaScript.SetAsync(DefaultDeviceId, deviceId);
            }

            await JavaScript.StartVideoAsync(deviceId, "#camera");

            _activeCamera = deviceId;

            if (CameraChanged.HasDelegate)
            {
                await CameraChanged.InvokeAsync(_activeCamera);
            }
        }
Пример #5
0
        public ObjectSelectPanel()
        {
            FlowDirection = FlowDirection.LeftToRight;
            AutoSize      = true;
            AutoSizeMode  = AutoSizeMode.GrowAndShrink;

            _Cameras = new LabeledControl <ComboBox>(new ComboBox(), "Camera:");
            Cameras.DropDownStyle         = ComboBoxStyle.DropDownList;
            Cameras.DisplayMember         = "Name";
            Cameras.SelectedIndexChanged += (s, e) => CameraChanged.Raise(s, e);
            Controls.Add(_Cameras);

            _BeamFlags = new LabeledControl <ComboBox>(new ComboBox(), "Beam Flags:");
            BeamFlags.DropDownStyle         = ComboBoxStyle.DropDownList;
            BeamFlags.DisplayMember         = "Name";
            BeamFlags.SelectedIndexChanged += (s, e) => BeamFlagsChanged.Raise(s, e);
            Controls.Add(_BeamFlags);
        }
Пример #6
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;
            }
        }
Пример #7
0
        /// <summary>
        /// Called when one of the dependency properties has changed.
        /// </summary>
        protected override async void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);

            if (!GraphicsCore.IsInitialized)
            {
                return;
            }
            if (this.IsInDesignMode())
            {
                return;
            }

            if (e.Property == SeeingSharpRendererElement.SceneProperty)
            {
                m_renderLoop.SetScene(this.Scene);
                SceneChanged.Raise(this, EventArgs.Empty);
            }
            else if (e.Property == SeeingSharpRendererElement.CameraProperty)
            {
                m_renderLoop.Camera = this.Camera;
                CameraChanged.Raise(this, EventArgs.Empty);
            }
            else if (e.Property == SeeingSharpRendererElement.DrawingLayer2DProperty)
            {
                if (e.OldValue != null)
                {
                    await m_renderLoop.Deregister2DDrawingLayerAsync(e.OldValue as Custom2DDrawingLayer);
                }
                if (e.NewValue != null)
                {
                    await m_renderLoop.Register2DDrawingLayerAsync(e.NewValue as Custom2DDrawingLayer);
                }
                DrawingLayer2DChanged.Raise(this, EventArgs.Empty);
            }
        }
Пример #8
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();
         }
     }
 }
Пример #9
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);
 }
Пример #12
0
 internal void SendOnCameraChange(Position point, double zoom)
 {
     CameraChanged?.Invoke(this, new CameraChangedEventArgs(point, zoom));
 }