示例#1
0
        /// <summary>
        /// Initializes the input bindings.
        /// </summary>
        private void InitializeBindings()
        {
            this.changeLookAtHandler = new RotateHandler(this, true);
            this.rotateHandler = new RotateHandler(this);
            this.zoomRectangleHandler = new ZoomRectangleHandler(this);
            this.zoomHandler = new ZoomHandler(this);
            this.panHandler = new PanHandler(this);
            this.changeFieldOfViewHandler = new ZoomHandler(this, true);

            this.CommandBindings.Add(new CommandBinding(ZoomRectangleCommand, this.zoomRectangleHandler.Execute));
            this.CommandBindings.Add(new CommandBinding(ZoomExtentsCommand, this.ZoomExtentsHandler));
            this.CommandBindings.Add(new CommandBinding(RotateCommand, this.rotateHandler.Execute));
            this.CommandBindings.Add(new CommandBinding(ZoomCommand, this.zoomHandler.Execute));
            this.CommandBindings.Add(new CommandBinding(PanCommand, this.panHandler.Execute));
            this.CommandBindings.Add(new CommandBinding(ResetCameraCommand, this.ResetCameraHandler));
            this.CommandBindings.Add(new CommandBinding(ChangeLookAtCommand, this.changeLookAtHandler.Execute));
            this.CommandBindings.Add(
                new CommandBinding(ChangeFieldOfViewCommand, this.changeFieldOfViewHandler.Execute));

            this.CommandBindings.Add(new CommandBinding(TopViewCommand, this.TopViewHandler));
            this.CommandBindings.Add(new CommandBinding(BottomViewCommand, this.BottomViewHandler));
            this.CommandBindings.Add(new CommandBinding(LeftViewCommand, this.LeftViewHandler));
            this.CommandBindings.Add(new CommandBinding(RightViewCommand, this.RightViewHandler));
            this.CommandBindings.Add(new CommandBinding(FrontViewCommand, this.FrontViewHandler));
            this.CommandBindings.Add(new CommandBinding(BackViewCommand, this.BackViewHandler));
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Viewport3DX" /> class.
        /// </summary>
        public Viewport3DX()
        {
            this.perspectiveCamera = new PerspectiveCamera();
            this.orthographicCamera = new OrthographicCamera();
            this.perspectiveCamera.Reset();
            this.orthographicCamera.Reset();

            this.Camera = this.Orthographic ? (ProjectionCamera)this.orthographicCamera : this.perspectiveCamera;

            this.Children = new Element3DCollection();

            this.rotateHandler = new RotateHandler(this);
            this.panHandler = new PanHandler(this);
            this.zoomHandler = new ZoomHandler(this);
            this.changeFieldOfViewHandler = new ZoomHandler(this, true);
            this.zoomRectangleHandler = new ZoomRectangleHandler(this);

            this.CommandBindings.Add(new CommandBinding(ViewportCommands.ZoomExtents, this.ZoomExtentsHandler));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.SetTarget, this.SetTargetHandler));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.Reset, this.ResetHandler));

            this.CommandBindings.Add(new CommandBinding(ViewportCommands.Zoom, this.zoomHandler.Execute));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.Pan, this.panHandler.Execute));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.Rotate, this.rotateHandler.Execute));
            this.CommandBindings.Add(
                new CommandBinding(ViewportCommands.ChangeFieldOfView, this.changeFieldOfViewHandler.Execute));
            this.CommandBindings.Add(
                new CommandBinding(ViewportCommands.ZoomRectangle, this.zoomRectangleHandler.Execute));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.BottomView, this.BottomViewHandler));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.TopView, this.TopViewHandler));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.FrontView, this.FrontViewHandler));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.BackView, this.BackViewHandler));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.LeftView, this.LeftViewHandler));
            this.CommandBindings.Add(new CommandBinding(ViewportCommands.RightView, this.RightViewHandler));

            this.SetDefaultGestures();

            this.fpsWatch.Start();

            this.renderingEventListener = new RenderingEventListener(this.OnCompositionTargetRendering);

            this.Loaded += this.ControlLoaded;
            this.Unloaded += this.ControlUnloaded;
        }