public static void WriteLine(string text, ForegroundColors foreColor, BackgroundColors backColor) { var stdout = GetStdHandle(Constants.STD_OUTPUT_HANDLE); if (stdout == Constants.INVALID_HANDLE_VALUE) { throw new System.Exception("Unable to get standard output handle"); } if (!GetConsoleScreenBufferInfo(stdout, out csbi)) { throw new System.Exception("Unable to get existing console settings"); } if (!SetConsoleTextAttribute(stdout, (ushort)((ushort)foreColor | (ushort)backColor))) { throw new System.Exception("Unable to set console colors"); } System.Console.WriteLine(text); if (!SetConsoleTextAttribute(stdout, csbi.wAttributes)) { throw new System.Exception("Unable to restore normal console colors"); } }
static void LoadDefaultValues () { var settingsDict = new NSDictionary (NSBundle.MainBundle.PathForResource ("Settings.bundle/Root.plist", null)); var prefSpecifierArray = settingsDict["PreferenceSpecifiers"] as NSArray; foreach (var prefItem in NSArray.FromArray<NSDictionary> (prefSpecifierArray)) { var key = (NSString)prefItem["Key"]; if (key == null) continue; var val = prefItem["DefaultValue"]; switch (key.ToString ()) { case firstNameKey: FirstName = val.ToString (); break; case lastNameKey: LastName = val.ToString (); break; case nameColorKey: TextColor = (TextColors)((NSNumber)val).Int32Value; break; case backgroundColorKey: BackgroundColor = (BackgroundColors)((NSNumber)val).Int32Value; break; } } var appDefaults = new NSDictionary (firstNameKey, FirstName, lastNameKey, LastName, nameColorKey, (int)TextColor, backgroundColorKey, (int)BackgroundColor); NSUserDefaults.StandardUserDefaults.RegisterDefaults (appDefaults); NSUserDefaults.StandardUserDefaults.Synchronize (); }
public static void SetupByPreferences () { FirstName = NSUserDefaults.StandardUserDefaults.StringForKey (firstNameKey); LastName = NSUserDefaults.StandardUserDefaults.StringForKey (lastNameKey); TextColor = (TextColors)(int)NSUserDefaults.StandardUserDefaults.IntForKey (nameColorKey); BackgroundColor = (BackgroundColors)(int)NSUserDefaults.StandardUserDefaults.IntForKey (backgroundColorKey); }
public static void SetupByPreferences() { FirstName = NSUserDefaults.StandardUserDefaults.StringForKey(firstNameKey); LastName = NSUserDefaults.StandardUserDefaults.StringForKey(lastNameKey); TextColor = (TextColors)(int)NSUserDefaults.StandardUserDefaults.IntForKey(nameColorKey); BackgroundColor = (BackgroundColors)(int)NSUserDefaults.StandardUserDefaults.IntForKey(backgroundColorKey); }
public void SetBackgroundColors(Color newBackgroundColor, out BackgroundColors previousColors) { previousColors = new BackgroundColors(this); Background = newBackgroundColor; ComponentHeaderBackground = newBackgroundColor; AssetHeaderBackground = newBackgroundColor; }
public static void SetupByPreferences () { var testValue = NSUserDefaults.StandardUserDefaults.StringForKey (firstNameKey); if (testValue == null) LoadDefaultValues (); FirstName = NSUserDefaults.StandardUserDefaults.StringForKey (firstNameKey); LastName = NSUserDefaults.StandardUserDefaults.StringForKey (lastNameKey); TextColor = (TextColors)(int)NSUserDefaults.StandardUserDefaults.IntForKey (nameColorKey); BackgroundColor = (BackgroundColors)(int)NSUserDefaults.StandardUserDefaults.IntForKey (backgroundColorKey); }
public static void SetupByPreferences() { var testValue = NSUserDefaults.StandardUserDefaults.StringForKey(firstNameKey); if (testValue == null) { LoadDefaultValues(); } FirstName = NSUserDefaults.StandardUserDefaults.StringForKey(firstNameKey); LastName = NSUserDefaults.StandardUserDefaults.StringForKey(lastNameKey); TextColor = (TextColors)NSUserDefaults.StandardUserDefaults.IntForKey(nameColorKey); BackgroundColor = (BackgroundColors)NSUserDefaults.StandardUserDefaults.IntForKey(backgroundColorKey); }
public ColorRulesViewModel(MainViewModel mainViewModel) { MainViewModel = mainViewModel; _ForegroundColors = new ObservableCollection <SwatchViewModel>(); _BackgroundColors = new ObservableCollection <SwatchViewModel>(); ForegroundColors.Add(new SwatchViewModel(MainViewModel, new Swatch(Colors.Red))); ForegroundColors.Add(new SwatchViewModel(MainViewModel, new Swatch(Colors.Green))); ForegroundColors.Add(new SwatchViewModel(MainViewModel, new Swatch(Colors.Blue))); BackgroundColors.Add(new SwatchViewModel(MainViewModel, new Swatch(Colors.Yellow))); BackgroundColors.Add(new SwatchViewModel(MainViewModel, new Swatch(Colors.Purple))); BackgroundColors.Add(new SwatchViewModel(MainViewModel, new Swatch(Colors.Silver))); Interval = 1; }
static void LoadDefaultValues() { var settingsDict = new NSDictionary(NSBundle.MainBundle.PathForResource("Settings.bundle/Root.plist", null)); var prefSpecifierArray = settingsDict[(NSString)"PreferenceSpecifiers"] as NSArray; foreach (var prefItem in NSArray.FromArray <NSDictionary> (prefSpecifierArray)) { var key = prefItem[(NSString)"Key"] as NSString; if (key == null) { continue; } var val = prefItem[(NSString)"DefaultValue"]; switch (key.ToString()) { case firstNameKey: FirstName = val.ToString(); break; case lastNameKey: LastName = val.ToString(); break; case nameColorKey: TextColor = (TextColors)((NSNumber)val).Int32Value; break; case backgroundColorKey: BackgroundColor = (BackgroundColors)((NSNumber)val).Int32Value; break; } } var appDefaults = NSDictionary.FromObjectsAndKeys(new object[] { new NSString(FirstName), new NSString(LastName), new NSNumber((int)TextColor), new NSNumber((int)BackgroundColor) }, new object [] { firstNameKey, lastNameKey, nameColorKey, backgroundColorKey } ); NSUserDefaults.StandardUserDefaults.RegisterDefaults(appDefaults); NSUserDefaults.StandardUserDefaults.Synchronize(); }
public static void WriteLine(string text, ForegroundColors foreColor) { System.IntPtr stdout = GetStdHandle(Constants.STD_OUTPUT_HANDLE); if (stdout == Constants.INVALID_HANDLE_VALUE) { throw new System.Exception("Unable to get standard output handle."); } if (!GetConsoleScreenBufferInfo(stdout, out csbi)) { throw new System.Exception("Unable to get existing console settings"); } BackgroundColors defaultBackground = (BackgroundColors)(csbi.wAttributes & 0xF0); System.Console.WriteLine(text, foreColor, defaultBackground); }
public static void LoadDefaultValues() { var settingsDict = new NSDictionary(NSBundle.MainBundle.PathForResource("Settings.bundle/Root.plist", null)); var prefSpecifierArray = settingsDict["PreferenceSpecifiers"] as NSArray; foreach (var prefItem in NSArray.FromArray <NSDictionary> (prefSpecifierArray)) { var key = (NSString)prefItem["Key"]; if (key == null) { continue; } var val = prefItem["DefaultValue"]; switch (key.ToString()) { case firstNameKey: FirstName = val.ToString(); break; case lastNameKey: LastName = val.ToString(); break; case nameColorKey: TextColor = (TextColors)((NSNumber)val).Int32Value; break; case backgroundColorKey: BackgroundColor = (BackgroundColors)((NSNumber)val).Int32Value; break; } } var appDefaults = new NSDictionary(firstNameKey, FirstName, lastNameKey, LastName, nameColorKey, (int)TextColor, backgroundColorKey, (int)BackgroundColor); NSUserDefaults.StandardUserDefaults.RegisterDefaults(appDefaults); }
private void SetFontSetting(string command) { string val = command.Replace("[", "").Replace("m", ""); String[] fontSettings = val.Split(';'); for (int i = 0; i < fontSettings.Length; i++) { int setting = int.Parse(fontSettings[i].Replace(";", "")); int settingType = setting / 10; switch (settingType) { case 0: // Enable Fontstyle if (setting == 0) { //System.Diagnostics.Debug.WriteLine("Reseting font style front:{0} back:{1}", (int)_fontColor, (int)_fontBackColor); _fontStyle.Clear(); // Reset _fontColor = FontColors.Default; _fontBackColor = BackgroundColors.Default; break; } _fontStyle.Add((FontStyles)setting); break; case 2: // Disable fontstyles _fontStyle.Remove((FontStyles)setting); break; case 3: // Set fontcolor _fontColor = (FontColors)setting; break; case 4: // Set backgroundcolor _fontBackColor = (BackgroundColors)setting; break; case 5: // Special fontstyles // Reserved, (Non-)Framed, Encircled, Overlined break; } } // for }
public static void WriteLine(string text, ForegroundColors foreColor, BackgroundColors backColor) { var stdout = GetStdHandle(Constants.STD_OUTPUT_HANDLE); if (stdout == Constants.INVALID_HANDLE_VALUE) { throw new System.Exception("Unable to get standard output handle"); } if (!GetConsoleScreenBufferInfo(stdout, out csbi)) { throw new System.Exception("Unable to get existing console settings"); } if (!SetConsoleTextAttribute(stdout, (ushort) ((ushort) foreColor | (ushort) backColor))) { throw new System.Exception("Unable to set console colors"); } System.Console.WriteLine(text); if (!SetConsoleTextAttribute(stdout, csbi.wAttributes)) { throw new System.Exception("Unable to restore normal console colors"); } }
public void RestoreBackgroundColors(BackgroundColors backgroundColors) { Background = backgroundColors.background; ComponentHeaderBackground = backgroundColors.componentHeaderBackground; AssetHeaderBackground = backgroundColors.assetHeaderBackground; }