Exemplo n.º 1
0
 public static void WriteWarning(VText warning)
 {
     warning = Text("WARNING: ").Plus(warning);
     warning.Apply(VTextTransform.SetForeground(ColorStandards.Warning, true));
     Log.Add(warning.ToString(), Log.MessageType.Warning);
     Console.WriteLine(warning);
 }
Exemplo n.º 2
0
 public static void WriteError(VText error, bool deadly = false)
 {
     error = Text("ERROR: ").Plus(error);
     error = error.Apply(VTextTransform.SetForeground(ColorStandards.Error, true));
     Log.Add(error.ToString(), Log.MessageType.Error);
     Console.WriteLine(error);
 }
Exemplo n.º 3
0
 public Region(string nameText, VText description, List <Terrain> terrains, List <Region> neighbours = null)
 {
     NameText    = nameText;
     Description = description;
     Terrains    = terrains;
     Neighbours  = neighbours ?? new List <Region>();
 }
Exemplo n.º 4
0
 public static void WriteDebug(VText debug)
 {
     debug = Text("DEBUG: ").Plus(debug);
     debug.Apply(VTextTransform.SetForeground(ColorStandards.Debug, true));
     Log.Add(debug.ToString(), Log.MessageType.Debug);
     Console.WriteLine(debug);
 }
Exemplo n.º 5
0
 public GameEvent(string nameText, VText description, GameEventType type, Game game, VColor nameForeground = null)
 {
     NameText       = nameText;
     Description    = description;
     Type           = type;
     Game           = game;
     NameForeground = nameForeground;
 }
Exemplo n.º 6
0
 /* 1.Enter按下说明用户已完成编辑,移除文本框焦点到隐形文本框 不管是不是正常输入
  * 2.隐形文本框获得焦点后,相当于四个文本框失去焦点,程序响应Text_LostFocus事件
  * 3.隐形文本框不可能响应键盘按下事件,响应此事件时一定是无焦点状态
  */
 private void KeyEnterDown(object sender, KeyEventArgs e)
 {
     if (e.Key != Key.Enter)
     {
         return;
     }
     VText.Focus();
 }
Exemplo n.º 7
0
 protected ListElement(List <T> contents, VText title = null, bool doClear = true, Func <T, VText> itemDisplayFunction = null, Func <int, VText> indexer = null)
 {
     Contents            = contents;
     Title               = title;
     DoClear             = doClear;
     ItemDisplayFunction = itemDisplayFunction;
     Indexer             = indexer;
 }
Exemplo n.º 8
0
 public Tag(string nameText, VText description, List <Argument> arguments = null, List <Argument> optionalArguments = null, VColor nameForeground = null)
 {
     NameText          = nameText;
     Description       = description;
     NameForeground    = nameForeground ?? ColorStandards.Tag;
     Arguments         = arguments ?? new List <Argument>();
     OptionalArguments = optionalArguments ?? new List <Argument>();
 }
 public override ExpressionElement Convert(IExpressionConverter converter, MethodCallExpression method)
 {
     var v = new VText();
     var overMethod = method;
     v.Add(overMethod.Method.Name.ToUpper() + "(");
     v.AddRange(1, overMethod.Arguments.Skip(1).
         Where(e => !(e is ConstantExpression)). //Skip null.
         Select(e => converter.Convert(e)).ToArray());
     return v.ConcatToBack(")");
 }
Exemplo n.º 10
0
 public static ListElement <T> CreateListElement(List <T> contents, VText title = null, bool doClear = true, Func <T, VText> itemDisplayFunction = null, Func <int, VText> indexer = null)
 {
     if (contents.Count >= Settings.MultiPageDisplayThreshold.Content)
     {
         return(new MultiPageListElement <T>(contents, Settings.MultiPageDisplayThreshold.Content, title, doClear, itemDisplayFunction, indexer));
     }
     else
     {
         return(new SinglePageListElement <T>(contents, title, doClear, itemDisplayFunction, indexer));
     }
 }
Exemplo n.º 11
0
 protected Command(string name,
                   VText useThisCommandTo, VColor nameForeground = null, List <Argument> arguments = null, List <Argument> optionalArguments = null, List <Tag> tags = null,
                   List <Permission> requiredPermissions         = null, VColor color = null)
 {
     Description       = useThisCommandTo;
     NameText          = name;
     NameForeground    = nameForeground ?? ColorStandards.Command;
     Arguments         = arguments ?? new List <Argument>();
     OptionalArguments = optionalArguments ?? new List <Argument>();
     Tags = tags ?? new List <Tag>();
     RequiredPermissions = requiredPermissions ?? new List <Permission>();
 }
        public override ExpressionElement Convert(IExpressionConverter converter, MethodCallExpression method)
        {
            var arg = method.Arguments[method.SkipMethodChain(0)];
            var array = arg as NewArrayExpression;

            var orderBy = new VText();
            orderBy.Add("ORDER BY");
            var sort = new VText() { Separator = "," };
            sort.AddRange(1, array.Expressions.Select(e => converter.Convert(e)).ToList());
            orderBy.Add(sort);
            return orderBy;
        }
        public override ExpressionElement Convert(IExpressionConverter converter, MethodCallExpression method)
        {
            var partitionBy = new VText();
            partitionBy.Add("PARTITION BY");

            var elements = new VText() { Indent = 1, Separator = "," };
            var array = method.Arguments[0] as NewArrayExpression;
            foreach (var e in array.Expressions.Select(e => converter.Convert(e)))
            {
                elements.Add(e);
            }
            partitionBy.Add(elements);

            return partitionBy;
        }
Exemplo n.º 14
0
        public static bool AttemptFill(string[] input, IHasArguments item, VText textItem)
        {
            if (input.Length < item.Arguments.Count)
            {
                WriteError(textItem + Text(" needs at least " + item.Arguments.Count + " arguments! (received " + input.Length + ")"));
                return(false);
            }

            if (input.Length > item.Arguments.Count + item.OptionalArguments.Count)
            {
                WriteError(textItem + Text(" receives at most " + item.Arguments.Count + " arguments! (received " + input.Length + ")"));
                return(false);
            }

            var count = 0;

            foreach (var part in input)
            {
                bool success;

                if (count < item.Arguments.Count)
                {
                    success = item.Arguments[count].Fill(part);
                }
                else
                {
                    success = item.OptionalArguments[count - item.Arguments.Count].Fill(part);
                }

                count++;
                if (!success)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 15
0
 public GameException(VText explanation, Action <Game> callback = null)
 {
     Callback    = callback;
     Explanation = explanation;
 }
Exemplo n.º 16
0
 public Argument(string nameText, VText description)
 {
     NameText    = nameText;
     Description = description;
 }
Exemplo n.º 17
0
 public IntegerArgument(string nameText, VText description) : base(nameText, description)
 {
 }
Exemplo n.º 18
0
 public StringArgument(string nameText, VText description) : base(nameText, description)
 {
 }
Exemplo n.º 19
0
 public static ListElement <T> CreateListElement(VText title = null, bool doClear = true, Func <T, VText> itemDisplayFunction = null, Func <int, VText> indexer = null, params T[] contents)
 {
     return(CreateListElement(contents.ToList(), title, doClear, itemDisplayFunction, indexer));
 }
Exemplo n.º 20
0
 public SoVGameEvent(string nameText, VText description, GameEventType type, SettlersOfValgard game, VColor nameForeground = null) : base(nameText, description, type, game, nameForeground)
 {
     Game = game;
 }
Exemplo n.º 21
0
 public SinglePageListElement(List <T> contents, VText title = null, bool doClear = true, Func <T, VText> itemDisplayFunction = null, Func <int, VText> indexer = null) : base(contents, title, doClear, itemDisplayFunction, indexer)
 {
 }
Exemplo n.º 22
0
 public CommandBuilder WithDescription(VText description)
 {
     _description = description;
     return(this);
 }
Exemplo n.º 23
0
        private static void DisplayCommand(Game game, Command command)
        {
            game.AddElement(new TitleElement(command));
            WriteLine(command.Description.Apply(VTextTransform.Capitalize()));
            var usage = Text("Usage: ") + command;

            foreach (var argument in command.Arguments)
            {
                usage += Text(" ") + argument.Apply(VTextTransform.Quote("[", "]"))
                         .Apply(VTextTransform.SetForeground(ColorStandards.Argument));
            }

            foreach (var argument in command.OptionalArguments)
            {
                usage += Text(" ") + argument.Apply(VTextTransform.Quote("(", ")"))
                         .Apply(VTextTransform.SetForeground(ColorStandards.Optional));
            }

            WriteLine(usage);
            if (command.Arguments.Count > 0 || command.OptionalArguments.Count > 0)
            {
                WriteLine(Text("Arguments:", ColorStandards.Title));
            }

            foreach (var argument in command.Arguments)
            {
                WriteLine(Text(" ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Argument)) + Text(": ") + argument.Description);
            }
            foreach (var argument in command.OptionalArguments)
            {
                WriteLine(Text(" ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Optional)) + Text(": ") + argument.Description);
            }

            if (command.Tags.Count > 0)
            {
                WriteLine(Text("Tags:", ColorStandards.Title));
            }

            foreach (var tag in command.Tags)
            {
                VText tagUsage = Text(" ") + tag;
                foreach (var argument in tag.Arguments)
                {
                    tagUsage += Text(" ") + argument.Apply(VTextTransform.Quote("[", "]"))
                                .Apply(VTextTransform.SetForeground(ColorStandards.Argument));
                }

                foreach (var argument in tag.OptionalArguments)
                {
                    tagUsage += Text(" ") + argument.Apply(VTextTransform.Quote("(", ")"))
                                .Apply(VTextTransform.SetForeground(ColorStandards.Argument));
                }

                WriteLine(tagUsage);
                WriteLine(Text("  ") + tag.Description);

                foreach (var argument in tag.Arguments)
                {
                    WriteLine(Text("  ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Argument)) + Text(": ") + argument.Description);
                }
                foreach (var argument in tag.OptionalArguments)
                {
                    WriteLine(Text("  ") + argument.Apply(VTextTransform.SetForeground(ColorStandards.Optional)) + Text(": ") + argument.Description);
                }
            }
        }
Exemplo n.º 24
0
 public TitleElement(VText title)
 {
     Title = title;
 }
Exemplo n.º 25
0
 public override VText Plus(VText other)
 {
     return(ToVText().Plus(other));
 }