Esempio n. 1
0
 internal static void FixFonts(ToolStripItem item)
 {
     item.Font = GetDefaultFont();
     if (Configuration.Settings.General.UseDarkTheme)
     {
         DarkTheme.SetDarkTheme(item);
     }
 }
Esempio n. 2
0
 public static void FixFonts(Control form, int iterations = 5)
 {
     FixFontsInner(form, iterations);
     if (Configuration.Settings.General.UseDarkTheme)
     {
         DarkTheme.SetDarkTheme(form, 1500);
     }
 }
Esempio n. 3
0
 public static void FixFonts(ToolStripSeparator item)
 {
     item.Font = GetDefaultFont();
     if (Configuration.Settings.General.UseDarkTheme)
     {
         DarkTheme.SetDarkTheme(item);
     }
 }
Esempio n. 4
0
        public static bool AutoCompleteTextBox(SETextBox textBox, ListBox listBox)
        {
            var textBeforeCursor  = string.IsNullOrEmpty(textBox.Text) ? string.Empty : textBox.Text.Substring(0, textBox.SelectionStart);
            var activeTagAtCursor = GetInsideTag(textBox, textBeforeCursor);
            var activeTagToCursor = GetLastString(textBeforeCursor) ?? string.Empty;

            var keywords = Configuration.Settings.Tools.AssaTagTemplates.Select(p => new IntellisenseItem(p.Tag, p.Hint, false)).ToList();

            keywords.AddRange(Keywords);
            keywords = (activeTagToCursor.StartsWith('\\') ? keywords.Select(p => new IntellisenseItem(p.Value.TrimStart('{'), p.Hint, p.AllowInTransformations, p.HelpLink)) : keywords.Select(p => p)).ToList();

            if (textBeforeCursor.EndsWith("\\t(", StringComparison.Ordinal))
            {
                // use smaller list inside transformation
                keywords          = Keywords.Where(p => p.AllowInTransformations).Select(p => new IntellisenseItem(p.Value.TrimStart('{'), p.Hint, p.AllowInTransformations, p.HelpLink)).ToList();
                activeTagToCursor = string.Empty;
            }

            var filteredList = keywords
                               .Where(n => string.IsNullOrEmpty(activeTagToCursor) || n.Value.StartsWith(GetLastString(activeTagToCursor), StringComparison.OrdinalIgnoreCase))
                               .ToList();

            if (filteredList.Count == 0 && activeTagToCursor.EndsWith("\\"))
            {
                // continuing ass tag, remove "{\" + "}"
                activeTagToCursor = string.Empty;
                filteredList      = keywords
                                    .Select(p => new IntellisenseItem(p.Value.Replace("{\\", string.Empty).RemoveChar('}'), p.Hint, p.AllowInTransformations, p.HelpLink))
                                    .ToList();
            }

            listBox.Items.Clear();

            foreach (var item in filteredList)
            {
                item.TypedWord         = activeTagToCursor;
                item.ActiveTagAtCursor = activeTagAtCursor;
                item.Font = listBox.Font;
                listBox.Items.Add(item);
            }

            if (listBox.Items.Count == 0)
            {
                return(false);
            }

            listBox.SelectedIndex = 0;
            var endTag = GetEndTagFromLastTagInText(textBeforeCursor);

            if (!string.IsNullOrEmpty(endTag))
            {
                var item = filteredList.Find(p => p.Value == endTag);
                if (item != null)
                {
                    listBox.SelectedIndex = filteredList.IndexOf(item);
                }
            }
            else if (IsLastTwoTagsEqual())
            {
                var item = filteredList.Find(p => p.Value == LastAddedTags.Last());
                if (item != null)
                {
                    listBox.SelectedIndex = filteredList.IndexOf(item);
                }
            }

            IntellisenseItem.IntellisenseItemEdit.Font = textBox.TextBoxFont;
            listBox.Items.Add(IntellisenseItem.IntellisenseItemEdit);

            if (Configuration.Settings.General.UseDarkTheme)
            {
                DarkTheme.SetDarkTheme(listBox);
            }

            listBox.Width  = 500;
            listBox.Height = 200;
            var height = listBox.Items.Count * listBox.ItemHeight + listBox.Items.Count + listBox.ItemHeight;

            if (height < listBox.Height)
            {
                listBox.Height = height;
            }

            listBox.Visible = true;
            return(true);
        }