Пример #1
0
        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");
            }
        }
Пример #2
0
		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 ();
		}
Пример #3
0
		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);
		}
Пример #4
0
 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);
 }
Пример #5
0
 public void SetBackgroundColors(Color newBackgroundColor, out BackgroundColors previousColors)
 {
     previousColors            = new BackgroundColors(this);
     Background                = newBackgroundColor;
     ComponentHeaderBackground = newBackgroundColor;
     AssetHeaderBackground     = newBackgroundColor;
 }
Пример #6
0
		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);
		}
Пример #7
0
        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);
        }
Пример #8
0
        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;
        }
Пример #9
0
        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();
        }
Пример #10
0
        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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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
        }
Пример #13
0
        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");
            }
        }
Пример #14
0
 public void RestoreBackgroundColors(BackgroundColors backgroundColors)
 {
     Background = backgroundColors.background;
     ComponentHeaderBackground = backgroundColors.componentHeaderBackground;
     AssetHeaderBackground     = backgroundColors.assetHeaderBackground;
 }