public SettingsViewModel()
        {
            SelectedRenderer = Direct3D11CompatibilityHelper.SupportsDirectX10
                ? typeof(Direct3D11RenderSurface)
                : typeof(HighSpeedRenderSurface);

            this.WithTrait <AllowFeedbackSettingBehaviour>();
            IsDirectXAvailable = Direct3D11CompatibilityHelper.SupportsDirectX10;

            if (Direct3D11CompatibilityHelper.HasDirectX10CapableGpu)
            {
                UseD3D11 = true;
                UseD3D9  = false;
            }
            else
            {
                UseD3D11 = false;
                UseD3D9  = true;
            }

            Use3DAA4x   = false;
            Use3DAANone = true;
            EnableResamplingCPlusPlus = false;

            Observable.CombineLatest(
                this.WhenPropertyChanged(x => x.UseAlternativeFillSourceD3D),
                this.WhenPropertyChanged(x => EnableForceWaitForGPU),
                Tuple.Create)
            .Subscribe(t =>
            {
                Direct3D11RenderSurface.UseAlternativeFillSource = t.Item1;
                Viewport3D.UseAlternativeFillSource           = t.Item1;
                Direct3D11RenderSurface.EnableForceWaitForGPU = t.Item2;
                Viewport3D.ForceStallUntilGPUIsIdle           = t.Item2;
                CreateGlobalStyle <SciChartSurface>();
                CreateGlobalStyle <SciStockChart>();
            })
            .DisposeWith(this);

            Observable.CombineLatest(
                this.WhenPropertyChanged(x => x.UseD3D9),
                this.WhenPropertyChanged(x => x.UseD3D11),
                this.WhenPropertyChanged(x => x.Use3DAANone),
                this.WhenPropertyChanged(x => x.Use3DAA4x),
                Tuple.Create)
            .Skip(1)
            .Throttle(TimeSpan.FromMilliseconds(1))
            .ObserveOnDispatcher()
            .Subscribe(t =>
            {
                Viewport3D.Restart3DEngineWith(
                    UseD3D9 ? DirectXMode.DirectX9c : DirectXMode.AutoDetect,
                    Use3DAA4x ? FullScreenAntiAliasingMode.MSAA4x : FullScreenAntiAliasingMode.None);
            });
        }
Esempio n. 2
0
        public SettingsViewModel()
        {
            SelectedRenderer = Direct3D11CompatibilityHelper.SupportsDirectX10
                ? typeof(TsrRenderSurface)
                : typeof(HighSpeedRenderSurface);

            this.WithTrait <AllowFeedbackSettingBehaviour>();
            IsDirectXAvailable = Direct3D11CompatibilityHelper.SupportsDirectX10;

            if (Direct3D11CompatibilityHelper.HasDirectX10CapableGpu)
            {
                UseD3D11 = true;
                UseD3D9  = false;
            }
            else
            {
                UseD3D11 = false;
                UseD3D9  = true;
            }

            UseD3D10AsFallback = true;

            Use3DAA4x   = false;
            Use3DAANone = true;
            EnableResamplingCPlusPlus   = true;
            EnableExtremeDrawingManager = true;
            EnableDropShadows           = true;

            Observable.CombineLatest(
                this.WhenPropertyChanged(x => x.UseAlternativeFillSourceD3D),
                this.WhenPropertyChanged(x => EnableForceWaitForGPU),
                Tuple.Create)
            .Subscribe(t =>
            {
                Direct3D11RenderSurface.UseAlternativeFillSource = t.Item1;
                Viewport3D.UseAlternativeFillSource           = t.Item1;
                Direct3D11RenderSurface.EnableForceWaitForGPU = t.Item2;
                Viewport3D.ForceStallUntilGPUIsIdle           = t.Item2;
                TsrRenderSurface.UseAlternativeFillSource     = t.Item1;
                TsrRenderSurface.ForceStallUntilGPUIsIdle     = t.Item2;
                CreateGlobalStyle <SciChartSurface>();
                CreateGlobalStyle <SciStockChart>();
            })
            .DisposeWith(this);

            Observable.CombineLatest(
                this.WhenPropertyChanged(x => x.UseD3D9),
                this.WhenPropertyChanged(x => x.UseD3D11),
                this.WhenPropertyChanged(x => x.UseD3D10AsFallback),
                this.WhenPropertyChanged(x => x.Use3DAANone),
                this.WhenPropertyChanged(x => x.Use3DAA4x),
                Tuple.Create)
            .Skip(1)
            .Throttle(TimeSpan.FromMilliseconds(1))
            .ObserveOn(DispatcherSchedulerEx.Current)
            .Subscribe(t =>
            {
                GoHomeInCaseOfProblemExample();

                // Restart 3D Engine with D3D9/D3D10/Auto, AntiAliasing mode
                Viewport3D.Restart3DEngineWith(
                    UseD3D9 ? DirectXMode.DirectX9c : DirectXMode.AutoDetect,
                    Use3DAA4x ? FullScreenAntiAliasingMode.MSAA4x : FullScreenAntiAliasingMode.None,
                    UseD3D10AsFallback);

                // Restart 2D engine with D3D9
                TsrRenderSurface.RestartEngineWith(
                    UseD3D9 ? DirectXMode.DirectX9c : DirectXMode.AutoDetect);
            });

            this.WhenPropertyChanged(x => x.EnableDropShadows).Subscribe(b => EffectManager.EnableDropShadows = b)
            .DisposeWith(this);
        }