示例#1
0
        protected override void WriteToInternal(RichTextWriter writer)
        {
            switch (this.Letters.Expand().Take(2).Count())
            {
            case 0:
                break;

            case 1:
                writer.Write(letterToString(this.Letters.Expand().Single()));
                break;

            default:
                writer.Write('[');
                foreach (var range in this.letters)
                {
                    writer.Write(letterToString(range.From));
                    if (!range.From.Equals(range.To))
                    {
                        writer.Write('-');
                        writer.Write(letterToString(range.To));
                    }
                }
                writer.Write(']');
                break;
            }
        }
 protected override void WriteToInternal(RichTextWriter writer)
 {
     this.Inner.WriteTo(writer, this.EvaluationPrecedence);
     if (this.Max.GetValueOrDefault(int.MaxValue) > 0)
     {
         if ((this.Min == 0) && (this.Max == 1))
         {
             writer.Write("?");
         }
         else if ((this.Min == 0) && !this.Max.HasValue)
         {
             writer.Write("*");
         }
         else if ((this.Min == 1) && !this.Max.HasValue)
         {
             writer.Write("+");
         }
         else
         {
             writer.Write('{');
             writer.Write(this.Min);
             if (this.Min != this.Max)
             {
                 writer.Write(',');
                 if (this.Max.HasValue)
                 {
                     writer.Write(this.Max.Value);
                 }
             }
             writer.Write('}');
         }
     }
 }
 protected override void WriteToInternal(RichTextWriter writer)
 {
     this.Inner.WriteTo(writer, this.EvaluationPrecedence);
     writer.Write("√");
     writer.Write("(");
     writer.Write(this.Symbol);
     writer.Write(")");
 }
示例#4
0
 public sealed override string ToString()
 {
     using (var result = new StringWriter()) {
         using (var writer = RichTextWriter.Wrap(result)) {
             this.WriteTo(writer, this.EvaluationPrecedence);
         }
         return(result.ToString());
     }
 }
示例#5
0
        ///// <summary>
        ///// Writes a part of the highlighted line to the RichTextWriter.
        ///// </summary>
        internal void WriteTo(RichTextWriter writer, int startOffset, int endOffset)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            int documentLineStartOffset = this.DocumentLine.Offset;
            int documentLineEndOffset   = documentLineStartOffset + this.DocumentLine.Length;

            if (startOffset < documentLineStartOffset || startOffset > documentLineEndOffset)
            {
                throw new ArgumentOutOfRangeException("startOffset", startOffset, "Value must be between " + documentLineStartOffset + " and " + documentLineEndOffset);
            }
            if (endOffset < startOffset || endOffset > documentLineEndOffset)
            {
                throw new ArgumentOutOfRangeException("endOffset", endOffset, "Value must be between startOffset and " + documentLineEndOffset);
            }
            ISegment requestedSegment = new SimpleSegment(startOffset, endOffset - startOffset);

            List <HtmlElement> elements = new List <HtmlElement>();

            for (int i = 0; i < this.Sections.Count; i++)
            {
                HighlightedSection s = this.Sections[i];
                if (SimpleSegment.GetOverlap(s, requestedSegment).Length > 0)
                {
                    elements.Add(new HtmlElement(s.Offset, i, false, s.Color));
                    elements.Add(new HtmlElement(s.Offset + s.Length, i, true, s.Color));
                }
            }
            elements.Sort();

            IDocument document   = this.Document;
            int       textOffset = startOffset;

            foreach (HtmlElement e in elements)
            {
                int newOffset = Math.Min(e.Offset, endOffset);
                if (newOffset > startOffset)
                {
                    document.WriteTextTo(writer, textOffset, newOffset - textOffset);
                }
                textOffset = Math.Max(textOffset, newOffset);
                if (e.IsEnd)
                {
                    writer.EndSpan();
                }
                else
                {
                    writer.BeginSpan(e.Color);
                }
            }
            document.WriteTextTo(writer, textOffset, endOffset - textOffset);
        }
示例#6
0
 public void WriteTo(RichTextWriter writer, int currentPrecedenceLevel)
 {
     if (currentPrecedenceLevel < this.EvaluationPrecedence)
     {
         writer.Write('(');
         this.WriteToInternal(writer);
         writer.Write(')');
     }
     else
     {
         this.WriteToInternal(writer);
     }
 }
示例#7
0
        public static void Postfix(ref FactoryStation __instance, ref Recipe recipe, ref RichTextWriter result, ref FactoryTexts ___m_texts, ref OnlineCargo ___m_cargo)
        {
            foreach (var inventoryItemData in recipe.Inputs)
            {
                var inputAmount     = (int)GET_INPUT_AMOUNT_METHOD_INFO.Invoke(__instance, new object[] { inventoryItemData });
                var availableAmount = ___m_cargo.GetAmount(inventoryItemData.Item, inventoryItemData.Stats);

                // Show input amount needed.
                result.CurrentStyle = inputAmount >= inventoryItemData.Amount ? "Text" : "TextError";
                result.Text.ConcatFormat(___m_texts.InputFormat.Text, inventoryItemData.Amount, inventoryItemData.Item.Name);
                // Show available amount.
                result.CurrentStyle = "Text";
                result.Text.ConcatFormat(___m_texts.InputAvailableFormat.Text, availableAmount);

                result.Text.AppendLine();
            }
        }
示例#8
0
        static void Main(string[] args)
        {
            int    maxEditions      = 2;
            int    insertionCost    = 1;
            int    deletionCost     = 1;
            int    substitutionCost = 2;
            int    errorCost        = -1;
            Stream inputStream      = Console.OpenStandardInput();
            Stream outputStream     = Console.OpenStandardOutput();

            LevenshteinDistanceAnalyzer analyzer = new LevenshteinDistanceAnalyzer(maxEditions, insertionCost, deletionCost, substitutionCost, errorCost);
            WordParser     parser = new WordParser(inputStream);
            RichTextWriter writer = new RichTextWriter(outputStream);
            StaticWordDictionaryBuilder dictionaryBuilder = new StaticWordDictionaryBuilder(parser, analyzer);
            RichTextBuilder             textBuilder       = new RichTextBuilder(parser);
            WordNeighborsFormater       formater          = new WordNeighborsFormater();

            SpellCheckProcessor.SpellChecker spellChecker = new SpellCheckProcessor.SpellChecker(dictionaryBuilder, textBuilder, "===");
            spellChecker.Check(writer, formater, 2);
            writer.Flush();
        }
示例#9
0
        ///// <summary>
        ///// Writes the highlighted line to the RichTextWriter.
        ///// </summary>
        internal void WriteTo(RichTextWriter writer)
        {
            int startOffset = this.DocumentLine.Offset;

            WriteTo(writer, startOffset, startOffset + this.DocumentLine.Length);
        }
示例#10
0
 protected abstract void WriteToInternal(RichTextWriter writer);
 protected override void WriteToInternal(RichTextWriter writer)
 {
 }
 protected override void WriteToInternal(RichTextWriter writer)
 {
     this.Left.WriteTo(writer, this.EvaluationPrecedence);
     this.Right.WriteTo(writer, this.EvaluationPrecedence);
 }
示例#13
0
 /// <summary>
 /// Sets the application's standard output to write to the form's RichTextBox
 /// control.
 /// </summary>
 public void SetupConsole()
 {
     _writer = new RichTextWriter(richTextBox);
     Console.SetOut(_writer);
 }
示例#14
0
 public RichTextFormatter(string language)
 {
     writer = new RichTextWriter(language);
 }
示例#15
0
 /// <summary>
 /// Sets the application's standard output to write to the form's RichTextBox control.
 /// </summary>
 public void SetupConsole()
 {
     this.writer = new RichTextWriter(this.richTextBox);
     Console.SetOut(this.writer);
 }