コード例 #1
0
        public void SaveGraphicsProfile(GraphicsProfile graphicsProfile)
        {
            if (_settingsStorage == null)
            {
                return;
            }

            // Serialize the graphicsProfile data to string and store that into applications settings
            _settingsStorage.UserGraphicProfileText = GraphicsProfileSerializer.Serialize(graphicsProfile);
        }
コード例 #2
0
        public void InitializeGraphicProfiles()
        {
            GraphicsProfile serializedGraphicsProfile = null;

            // First check if DXEngineGraphicProfile is set in application config file (this overrides saved setting)
            string dxEngineGraphicProfileText;

            if (_settingsStorage != null)
            {
                dxEngineGraphicProfileText = _settingsStorage.OverrideGraphicProfileText;
            }
            else
            {
                dxEngineGraphicProfileText = null;
            }

            if (!string.IsNullOrEmpty(dxEngineGraphicProfileText))
            {
                try
                {
                    serializedGraphicsProfile = GraphicsProfileSerializer.Deserialize(dxEngineGraphicProfileText, SystemCapabilities.AllAdapters, throwExceptions: false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Cannot serialize the GraphicsProfile setting in config file (appSettings is DXEngineGraphicProfile).\r\n\r\nError:\r\n" + ex.Message);
                }
            }



            // If GraphicsProfile is not yet set, read the GraphicsProfile setting saved to application's settings
            if (serializedGraphicsProfile == null && _settingsStorage != null)
            {
                dxEngineGraphicProfileText = _settingsStorage.UserGraphicProfileText;

                if (!string.IsNullOrEmpty(dxEngineGraphicProfileText))
                {
                    try
                    {
                        serializedGraphicsProfile = GraphicsProfileSerializer.Deserialize(dxEngineGraphicProfileText, SystemCapabilities.AllAdapters, throwExceptions: false);
                    }
                    catch
                    {
                        // UH - this should not happen (maybe the  GraphicsProfile was serialized with previous version)
                    }
                }
            }

            if (serializedGraphicsProfile != null)
            {
                // CreateArrayOfRecommendedGraphicsProfiles creates an array of GraphicsProfile where the first GraphicsProfile is serializedGraphicsProfile.
                // The following graphics profiles in the list are fallback GraphicsProfiles that can be used if serializedGraphicsProfile cannot be used (for example software rendering and wpf 3D)
                this.GraphicsProfiles = SystemCapabilities.CreateArrayOfRecommendedGraphicsProfiles(serializedGraphicsProfile);
            }
            else
            {
                // GraphicsProfile still not set - probably the first run or user never changed graphics profile manually
                // Use the recommended settings for this computer

                this.GraphicsProfiles = DXEngineSettings.Current.SystemCapabilities.GetRecommendedGraphicsProfiles();
            }
        }