public DlgColors(ImageList w, ImageList d) { whiteImages = w; darkImages = d; Font = SystemFonts.MessageBoxFont; InitializeComponent(); images.BorderStyle = backColors.BorderStyle = foreColors.BorderStyle = BorderStyle.None; images.DrawMode = backColors.DrawMode = foreColors.DrawMode = DrawMode.OwnerDrawFixed; images.ItemHeight = 30; backColors.ItemHeight = foreColors.ItemHeight = 8 + FormsToolbox.GetTextHeight("00", Font); images.Height = images.ItemHeight * 6; foreColors.Height = backColors.Height = backColors.ItemHeight * 6; for (int i = 0; i < Math.Min(whiteImages.Images.Count, darkImages.Images.Count); i++) { images.Items.Add(new ImageDefinition(i.ToString(), i)); } AddForeColor("Unk", 214, 157, 133); AddForeColor("Unk", 181, 206, 168); AddForeColor("turquoise green", 78, 201, 176); AddForeColor("green symbol", 124, 165, 160); AddForeColor("blue", 95, 149, 250); AddForeColor("enum breen", 184, 215, 163); AddForeColor("blue", 86, 156, 214); AddForeColor("gray litteral", 218, 218, 218); AddForeColor("gray identifier", 220, 220, 220); AddForeColor("line number", 42, 145, 175); AddForeColor("dark text", 20, 72, 82); AddForeColor("unk", 86, 156, 214); AddForeColor("standard forecolor", 220, 220, 220); AddForeColor("violet", 202, 121, 236); AddForeColor("yellow peach", 255, 219, 163); AddForeColor("blush red", 216, 80, 80); AddForeColor("brown tan", 215, 186, 125); AddBackColor("ncBackColor", 45, 45, 48); AddBackColor("backColor", 30, 30, 30); AddBackColor("backColor2", 62, 62, 66); AddBackColor("backColor3", 104, 104, 104); AddBackColor("backColor0", 45, 45, 48); AddBackColor("backColor4", 51, 51, 51); AddBackColor("backColor5", 37, 37, 38); AddBackColor("backColor6", 51, 51, 55); AddBackColor("headerBackColor", 51, 51, 55); }
public bool UpdateSuggestions(SuggestionList suggestions, Point p) { suggestionList = suggestions; theList.Sorted = false; // !suggestionList.queryMode; Point pOrig = p; p = parent.PointToClient(p); leftWidth = 0; rightWidth = 0; middleWidth = 0; int lineHeight = theList.ItemHeight = FormsToolbox.GetTextHeight("0", this.Font) + 4; // suggestions.Clear(); if (suggestions != null && suggestions.Count > 0) { int maxWidth = 0; theList.BeginUpdate(); theList.Items.Clear(); theList.SelectedIndex = -1; Suggestion selectedItem = null; string match = suggestions.textEntered.ToLower().Trim(); foreach (Suggestion s in suggestions.GetSuggestions(!suggestionList.queryMode, match)) { if (s.expr.Trim().Length > 0) { if (s.expr.ToLower().Contains(match)) { leftWidth = Math.Max(leftWidth, 20 + FormsToolbox.GetTextWidth(s.expr + "00", Font)); if (s.middleStuff != null) { middleWidth = Math.Max(middleWidth, FormsToolbox.GetTextWidth(s.middleStuff + "00", SystemFonts.MessageBoxFont)); } if (s.rightStuff != null) { rightWidth = Math.Max(rightWidth, FormsToolbox.GetTextWidth(s.rightStuff + "00", SystemFonts.MessageBoxFont)); } theList.Items.Add(s); if (s.expr.ToLower().StartsWith(match) && (selectedItem == null || s.position < selectedItem.position)) { selectedItem = s; } } } } theList.EndUpdate(); if (selectedItem != null) { theList.SelectedItem = selectedItem; int topItem = Math.Max(0, theList.SelectedIndex - (maxVisibleItems / 2)); theList.TopIndex = topItem; } maxWidth = leftWidth + middleWidth + rightWidth; if (theList.Items.Count > 0) { if (!Visible) { Show(); BringToFront(); } T.Debug(p.Y.ToString() + " " + pOrig.Y.ToString()); int maxHeight = maxVisibleItems * lineHeight; theList.Size = new Size(T.MinMax(20, 600, maxWidth), T.MinMax(lineHeight, maxHeight, lineHeight * theList.Items.Count)); int y = p.Y; if (!suggestionList.queryMode) { y += lineHeight; } Bounds = new Rectangle(p.X, y, theList.Width, theList.Height); editor.Focus(); return(theList.Items.Count > 0); } } Hide(); editor.Focus(); return(false); }