Example #1
0
        public void OpenTheme(DataGridViewCellEventArgs e)
        {
            var theme = View.Grid.Rows[e.RowIndex].DataBoundItem as Theme;
            var form  = new ThemeReader(theme);

            form.ShowDialog();
        }
Example #2
0
        public void ExtractData_ExpressionSuccessfully()
        {
            var reader = new ThemeReader();

            var component = reader.ExtractData(FileText);

            component.Expression.ShouldNotBeNull();
            component.Expression.ShouldBe(FileText);
        }
 public SyntaxHighlighter(string themeFilename)
 {
     this.theme                = ThemeReader.GetTheme(themeFilename);
     this.colorCache           = new MemoryCache(new MemoryCacheOptions());
     this.colorCacheExpiration = new MemoryCacheEntryOptions {
         AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5)
     };
     this.ForegroundColor = theme[ThemeReader.Foreground];
     this.BackgroundColor = theme[ThemeReader.Background];
 }
Example #4
0
 /// <summary>
 /// Handles the updating of the player's current theme and passing the update to all objects that are theme-able
 /// </summary>
 /// <param name="themeIndex">The index of the theme selected in the settings menu</param>
 private void SelectTheme(int themeIndex)
 {
     CurrentTheme       = Themes[themeIndex];
     prefs.CurrentTheme = themeIndex;
     if (CurrentTheme.themeName != "Default")
     {
         CurrentTheme = ThemeReader.AssignSprites(CurrentTheme);
     }
     WriteToPreferences();
     UpdateTheme(CurrentTheme);
 }
Example #5
0
        public IRawTheme LoadTheme(ThemeName name)
        {
            string themeFile = GetThemeFile(name);

            if (themeFile == null)
            {
                return(null);
            }

            using (Stream s = ResourceLoader.TryOpenThemeStream(GetThemeFile(name)))
                using (StreamReader reader = new StreamReader(s))
                {
                    return(ThemeReader.ReadThemeSync(reader));
                }
        }
Example #6
0
 public SyntaxHighlighter(string themeFilename)
 {
     this.theme           = ThemeReader.GetTheme(themeFilename);
     this.ForegroundColor = theme[ThemeReader.Foreground];
     this.BackgroundColor = theme[ThemeReader.Background];
 }
Example #7
0
        public void ExtractData_WhenTextIsEmpty_ExceptionRaised(string text)
        {
            var reader = new ThemeReader();

            Assert.Throws <ArgumentNullException>(() => reader.ExtractData(text));
        }
Example #8
0
        /// <summary>
        /// Sets up the preferences when Awake is called
        /// </summary>
        private void Awake()
        {
            #region Preferences
            // Define prefs
            prefs = new PlayerPreferences();

            // Enter the preferences directory
            string        prefsPath  = Application.persistentDataPath;
            DirectoryInfo prefsDir   = new DirectoryInfo(prefsPath);
            FileInfo[]    prefsFiles = prefsDir.GetFiles("*.*", SearchOption.AllDirectories);
            bool          prefsFound = false;

            // Find the preferences file
            foreach (FileInfo file in prefsFiles)
            {
                if (file.Name.Contains("preferences.xml"))
                {
                    prefsFound = true;
                }
            }

            // If found, read from it
            if (prefsFound)
            {
                prefs = ReadFromPreferences();
            }

            // Otherwise, create one
            else
            {
                // Define controls
                InputDefinitions input = new InputDefinitions
                {
                    Menu_Pause    = KeyCode.Escape,
                    Ship_Forward  = KeyCode.W,
                    Ship_Reverse  = KeyCode.S,
                    Ship_CW       = KeyCode.D,
                    Ship_CCW      = KeyCode.A,
                    Ship_Fire     = KeyCode.Space,
                    Ship_Dampener = KeyCode.Q
                };
                prefs.Controls = input;

                // Define graphics
                GraphicSettings graphics = new GraphicSettings
                {
                    AntiAliasingMode     = 0,
                    PostProcessingPreset = 0,
                    TargetFramerate      = 60,
                    UseVsync             = true
                };
                prefs.Graphics = graphics;

                // Define misc settings
                prefs.CurrentTheme     = 0;
                prefs.TargetLockForce  = 0.5f;
                prefs.DoDamageFlashing = false;

                WriteToPreferences();
            }
            #endregion

            #region Graphics
            // Post processing
            for (int i = 0; i < ppPresets.Length; i++)
            {
                if (prefs.Graphics.PostProcessingPreset == i)
                {
                    ppPresets[i].SetActive(true);
                }
                else
                {
                    ppPresets[i].SetActive(false);
                }
            }
            camLayer.antialiasingMode = (PostProcessLayer.Antialiasing)prefs.Graphics.AntiAliasingMode;

            // Framerate
            if (prefs.Graphics.UseVsync)
            {
                QualitySettings.vSyncCount = 1;
            }
            else
            {
                QualitySettings.vSyncCount = 0;
            }
            Application.targetFrameRate = prefs.Graphics.TargetFramerate;
            #endregion

            #region Themes
            Themes = new List <Theme>();

            // Enter the themes directory
            string        path          = Application.streamingAssetsPath + "/Themes";
            DirectoryInfo directoryInfo = new DirectoryInfo(path);
            FileInfo[]    allFiles      = null;

            if (directoryInfo.Exists)
            {
                allFiles = directoryInfo.GetFiles("*.*", SearchOption.AllDirectories);

                // Read all the themes in the directory
                foreach (FileInfo file in allFiles)
                {
                    if (file.Extension.Contains("theme"))
                    {
                        Themes.Add(ThemeReader.GetTheme(file));
                    }
                }

                // If there are none, create a default theme
                if (Themes.Count == 0)
                {
                    Themes.Add(new Theme("Default"));
                }
            }

            else
            {
                directoryInfo.Create();
                Themes.Add(new Theme("Default"));
            }
            #endregion
        }