예제 #1
0
        public static JsonPalette Auto(ConsoleBrush defaultBrush)
        {
            string setting;

            try
            {
                setting = Settings.Default[defaultBrush.Background + "Palette"];
            }
            catch (KeyNotFoundException)
            {
                setting = null;
            }

            if (string.IsNullOrEmpty(setting))
            {
                setting      = Settings.BlackPalette;
                defaultBrush = new ConsoleBrush(ConsoleColor.White, ConsoleColor.Black);
            }

            var palette = new JsonPalette(defaultBrush);

            palette.ImportJson(setting);

            return(palette);
        }
예제 #2
0
파일: JsonPalette.cs 프로젝트: db48x/KeeFox
 public JsonPalette(ConsoleBrush defaultBrush)
 {
     DefaultBrush = defaultBrush;
     Null = defaultBrush;
     String = defaultBrush;
     Number = defaultBrush;
     Boolean = defaultBrush;
     Object = defaultBrush;
     Member = defaultBrush;
     Array = defaultBrush;
 }
예제 #3
0
 public JsonPalette(ConsoleBrush defaultBrush)
 {
     this.defaultBrush = defaultBrush;
     this.nullBrush = defaultBrush;
     this.stringBrush = defaultBrush;
     this.numberBrush = defaultBrush;
     this.booleanBrush = defaultBrush;
     this.objectBrush = defaultBrush;
     this.memberBrush = defaultBrush;
     this.arrayBrush = defaultBrush;
 }
예제 #4
0
 public JsonPalette(ConsoleBrush defaultBrush)
 {
     DefaultBrush = defaultBrush;
     Null         = defaultBrush;
     String       = defaultBrush;
     Number       = defaultBrush;
     Boolean      = defaultBrush;
     Object       = defaultBrush;
     Member       = defaultBrush;
     Array        = defaultBrush;
 }
예제 #5
0
파일: JsonPalette.cs 프로젝트: db48x/KeeFox
        public static JsonPalette Auto(ConsoleBrush defaultBrush)
        {
            string setting;

            try
            {
                setting = (string) Settings.Default[defaultBrush.Background + "Palette"];
            }
            catch (SettingsPropertyNotFoundException)
            {
                setting = null;
            }

            if (string.IsNullOrEmpty(setting))
            {
                setting = Settings.Default.BlackPalette;
                defaultBrush = new ConsoleBrush(ConsoleColor.White, ConsoleColor.Black);
            }

            var palette = new JsonPalette(defaultBrush);
            palette.ImportJson(setting);

            return palette;
        }
예제 #6
0
파일: JsonPalette.cs 프로젝트: db48x/KeeFox
        void IJsonImportable.Import(ImportContext context, JsonReader reader)
        {
            reader.MoveToContent();

            if (reader.TokenClass != JsonTokenClass.Object)
            {
                reader.Skip();
                return;
            }

            reader.Read(/* object */);

            do
            {
                var brushName = reader.ReadMember().ToLowerInvariant();
                var color = reader.ReadString();

                var foreground = EnumHelper.TryParse<ConsoleColor>(color, true) ?? DefaultBrush.Foreground;

                switch (brushName)
                {
                    case "arr":
                    case "array":
                        Array = Array.ResetForeground(foreground);
                        break;
                    case "obj":
                    case "object":
                        Object = Object.ResetForeground(foreground);
                        break;
                    case "mem":
                    case "member":
                        Member = Member.ResetForeground(foreground);
                        break;
                    case "str":
                    case "string":
                        String = String.ResetForeground(foreground);
                        break;
                    case "num":
                    case "number":
                        Number = Number.ResetForeground(foreground);
                        break;
                    case "bit":
                    case "boolean":
                        Boolean = Boolean.ResetForeground(foreground);
                        break;
                    case "nil":
                    case "null":
                        Null = Null.ResetForeground(foreground);
                        break;
                    default:
                        continue;
                }
            }
            while (reader.TokenClass != JsonTokenClass.EndObject);

            reader.Read( /* end object */);
        }
예제 #7
0
        void IJsonImportable.Import(ImportContext context, JsonReader reader)
        {
            reader.MoveToContent();

            if (reader.TokenClass != JsonTokenClass.Object)
            {
                reader.Skip();
                return;
            }

            reader.Read(/* object */);

            do
            {
                var brushName = reader.ReadMember().ToLowerInvariant();
                var color     = reader.ReadString();

                var foreground = Enum.TryParse <ConsoleColor>(color, true, out var cc) ? cc
                               : DefaultBrush.Foreground;

                switch (brushName)
                {
                case "arr":
                case "array":
                    Array = Array.ResetForeground(foreground);
                    break;

                case "obj":
                case "object":
                    Object = Object.ResetForeground(foreground);
                    break;

                case "mem":
                case "member":
                    Member = Member.ResetForeground(foreground);
                    break;

                case "str":
                case "string":
                    String = String.ResetForeground(foreground);
                    break;

                case "num":
                case "number":
                    Number = Number.ResetForeground(foreground);
                    break;

                case "bit":
                case "boolean":
                    Boolean = Boolean.ResetForeground(foreground);
                    break;

                case "nil":
                case "null":
                    Null = Null.ResetForeground(foreground);
                    break;

                default:
                    continue;
                }
            }while (reader.TokenClass != JsonTokenClass.EndObject);

            reader.Read(/* end object */);
        }