예제 #1
0
        /// <summary>
        /// Updates this menu item's properties after a definition change.
        /// </summary>
        public void Update()
        {
            string displayText = TextProvider?.GetText();

            if (!string.IsNullOrWhiteSpace(displayText))
            {
                if (!OpensDialog)
                {
                    // Make sure ampersand characters are shown in menu items, instead of giving rise to a mnemonic.
                    Text = displayText.Replace("&", "&&");
                }
                else
                {
                    // Add OpensDialogIndicatorSuffix.
                    Text = displayText.Replace("&", "&&") + OpensDialogIndicatorSuffix;
                }
            }
            else
            {
                DisplayStyle = ToolStripItemDisplayStyle.Image;
                Text         = string.Empty;
            }

            Image = IconProvider?.GetImage();

            if (ShortcutKeyDisplayTextProviders != null)
            {
                ShortcutKeyDisplayString = string.Join("+", ShortcutKeyDisplayTextProviders.Select(x => x.GetText()));
            }
            else
            {
                ShortcutKeyDisplayString = string.Empty;
            }
        }
예제 #2
0
        public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
        {
            var text = TextProvider.GetText(new TextRange(sourceIndex, count));

            for (int i = 0; i < count; i++)
            {
                destination[destinationIndex + i] = text[i];
            }
        }
예제 #3
0
        public void TextProvider_GetText()
        {
            var text       = "Quick brown fox jumps over the lazy dog";
            var textBuffer = new TextBufferMock(text, "text");

            var textProvider = new TextProvider(textBuffer.CurrentSnapshot, 10);

            textProvider.GetText(9, 5).Should().Be("wn fo");
        }
예제 #4
0
        public void Execute(ActionContext context)
        {
            GuiTextField textField = (GuiTextField)context.GetSession().FindById(path);

            if (textField != null)
            {
                textField.Text = TextProvider.GetText();
            }
        }
        private static string GetName(MarkdownObject mdo, TextProvider textProvider)
        {
            switch (mdo)
            {
            case HeadingBlock heading:
                var text = textProvider.GetText(heading);
                var name = text.Trim(heading.HeaderChar).Trim();
                return(name);

            default:
                return(string.Empty);    // TODO: RKN mdo.GetType().Name;
            }
        }
예제 #6
0
    public void updateHudTexts()
    {
        // 0404.MT.0600.L.01[Höhe] m
        //0404.MT.0600.L.02[Geschwindigkeit] km / h
        //0404.MT.0600.L.03   m / sek
        //0404.MT.0600.C  Welt[Zahl] / 4
        // TextProvider.GetText("")


        string alt   = "0404.MT." + stateToString(state) + ".L.01";
        string speed = "0404.MT." + stateToString(state) + ".L.02";
        string level = "0404.MT." + stateToString(state) + ".C";

        HUD.altUnit   = TextProvider.GetText(alt);
        HUD.speedUnit = TextProvider.GetText(speed);
        HUD.setLevelString(TextProvider.GetText(level) + " " + currentLevel + "/" + levelControl.getLastLevel());
    }
예제 #7
0
 public string GetText(string key, params string[] args)
 => TextProvider.GetText(string.Empty, string.Empty, key, args)
 ?? throw new Exception($"{key} was not found in the resources file");
예제 #8
0
 public string this[string key]
 => TextProvider.GetText(string.Empty, string.Empty, key)
 ?? throw new Exception($"{key} was not found in the resources file");
예제 #9
0
 public string GetText(Span span)
 {
     return(TextProvider.GetText(new TextRange(span.Start, span.Length)));
 }
예제 #10
0
 public string GetText(int startIndex, int length)
 {
     return(TextProvider.GetText(new TextRange(startIndex, length)));
 }
예제 #11
0
 public string GetText()
 {
     return(TextProvider.GetText(new TextRange(0, TextProvider.Length)));
 }
예제 #12
0
        public void ReportError(Error error)
        {
            HasErrors = true;

#if DEBUG && PRINT_SRC_LOCATION
            Log($"{error.File}:{error.LineNumber} - {error.Function}()", ConsoleColor.DarkYellow);
#endif

            if (error.Location != null)
            {
                var text = TextProvider.GetText(error.Location);

                TokenLocation beginning = error.Location.Beginning;
                TokenLocation end       = error.Location.End;

                // location, message
                LogInline($"{beginning}: ", ConsoleColor.White);
                Log(error.Message, ConsoleColor.Red);

                if (DoPrintLocation)
                {
                    PrintLocation(text, error.Location, linesBefore: LinesBeforeError, linesAfter: LinesAfterError);
                }
            }
            else
            {
                Log(error.Message, ConsoleColor.Red);
            }

            // details
            if (error.Details != null)
            {
                foreach (var d in error.Details)
                {
                    Console.WriteLine("|");

                    foreach (var line in d.message.Split('\n'))
                    {
                        if (!string.IsNullOrEmpty(line))
                        {
                            Log("| " + line, ConsoleColor.White);
                        }
                    }

                    if (d.location != null)
                    {
                        var detailText = TextProvider.GetText(d.location);

                        Log($"{d.location.Beginning}: ", ConsoleColor.White);

                        if (DoPrintLocation)
                        {
                            PrintLocation(detailText, d.location, linesBefore: 0, highlightColor: ConsoleColor.Green);
                        }
                    }
                }
            }

            if (error.SubErrors?.Count > 0)
            {
                Log("| Related:", ConsoleColor.White);

                foreach (var e in error.SubErrors)
                {
                    ReportError(e);
                }
            }
        }
예제 #13
0
 public string GetText() => TextProvider.GetText(new TextRange(0, TextProvider.Length));
예제 #14
0
 public string this[string key]
 => TextProvider.GetText(string.Empty, string.Empty, key);