示例#1
0
		public bool MyEquals(object obj)
		{
			if (!(obj is FindTextResult))
			{
				return false;
			}
			FindTextResult other = (FindTextResult)obj;
			return this.m_Line == other.m_Line && this.m_StartIndex == other.m_StartIndex && this.m_EndIndex == other.m_EndIndex && this.m_Filename == other.m_Filename;
		}
示例#2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            try
            {
                e.Graphics.Clear(this.BackColor);
                int visible_item_count = Math.Min((base.ClientSize.Height + base.ClientSize.Height - 1) / this.ItemHeight, this.m_Items.Count - this.m_ScrollIndex);
                int select_index_start = Math.Min(this.m_SelectedIndexStart, this.m_SelectedIndexEnd) - this.m_ScrollIndex;
                int select_index_end   = Math.Max(this.m_SelectedIndexStart, this.m_SelectedIndexEnd) - this.m_ScrollIndex;
                if (this.m_SelectedIndexStart != -1)
                {
                    for (int select_index = select_index_start; select_index <= select_index_end; select_index++)
                    {
                        if (select_index >= 0 && select_index < visible_item_count)
                        {
                            e.Graphics.FillRectangle(this.m_SelectBarBrush, 0, select_index * this.ItemHeight, base.ClientSize.Width, this.ItemHeight);
                        }
                    }
                }
                int highlight_index = this.m_HighlightIndex - this.m_ScrollIndex;
                if (highlight_index >= 0 && highlight_index < visible_item_count && (highlight_index < select_index_start || highlight_index > select_index_end))
                {
                    e.Graphics.FillRectangle(this.m_HighlightBarBrush, 0, highlight_index * this.ItemHeight, base.ClientSize.Width, this.ItemHeight);
                }
                int y = 0;
                this.m_MaxItemWidth = 0;
                int i = 0;
                while (i < visible_item_count)
                {
                    object item       = this.m_Items[i + this.m_ScrollIndex];
                    bool   selected   = i >= select_index_start && i <= select_index_end;
                    int    x          = -this.m_HorzScroll;
                    int    line_width = 0;
                    if (item is FindTextResult)
                    {
                        FindTextResult find_text_result = (FindTextResult)item;
                        if (find_text_result != null)
                        {
                            string filename     = find_text_result.m_Filename;
                            int    display_line = find_text_result.m_LineIndex + 1;

                            const int fileNameDisplayLength = 40;

                            filename = string.Concat(new object[]
                            {
                                filename,
                                "(",
                                display_line,
                                "): "
                            });

                            if (filename.Length < fileNameDisplayLength)
                            {
                                filename += new string(' ', fileNameDisplayLength - filename.Length);
                            }

                            int    start = find_text_result.m_StartIndex;
                            int    end   = find_text_result.m_EndIndex;
                            string line  = find_text_result.m_Line;
                            string str   = line.Substring(0, start);
                            string str2  = line.Substring(start, end - start);
                            string str3  = line.Substring(end, line.Length - end);
                            str  = str.Replace("\t", "    ");
                            str2 = str2.Replace("\t", "    ");
                            str3 = str3.Replace("\t", "    ");
                            if (str.Length > 1024)
                            {
                                str = "..." + str.Substring(str.Length - 50);
                            }
                            if (str3.Length > 1024)
                            {
                                str3 = str3.Substring(0, 50) + "...";
                            }
                            MyListBox.DrawString(e.Graphics, filename, this.Font, selected ? this.m_HighlightTextBrush : this.m_FilenameBrush, (float)x, (float)y, this.m_StringFormat);
                            int filename_width = this.GetStringWidth(filename, filename.Length, e.Graphics, this.Font);
                            x          += filename_width;
                            line_width += filename_width;
                            int str1_width = this.GetStringWidth(str, str.Length, e.Graphics, this.Font);
                            if (str1_width != -1)
                            {
                                MyListBox.DrawString(e.Graphics, str, this.Font, selected ? this.m_HighlightTextBrush : this.m_FindTextBrush, (float)x, (float)y, this.m_StringFormat);
                                x          += str1_width;
                                line_width += str1_width;
                            }
                            int str2_width = this.GetStringWidth(str2, str2.Length, e.Graphics, this.Font);
                            if (str2_width != -1)
                            {
                                MyListBox.DrawString(e.Graphics, str2, this.Font, selected ? this.m_SelectedHighlightTextBrush : this.m_HighlightBrush, (float)x, (float)y, this.m_StringFormat);
                                x          += str2_width;
                                line_width += str2_width;
                            }
                            int str3_width = this.GetStringWidth(str3, str3.Length, e.Graphics, this.Font);
                            if (str3_width != -1)
                            {
                                MyListBox.DrawString(e.Graphics, str3, this.Font, selected ? this.m_HighlightTextBrush : this.m_FindTextBrush, (float)x, (float)y, this.m_StringFormat);
                                line_width += str3_width;
                            }
                        }
                    }
                    else if (item is FilteredFileItem)
                    {
                        FilteredFileItem filtered_file_item = (FilteredFileItem)item;
                        MyListBox.DrawString(e.Graphics, filtered_file_item.m_DisplayFilename, this.Font, selected ? this.m_HighlightTextBrush : this.m_FileBrush, (float)x, (float)y, this.m_StringFormat);
                        line_width += this.GetStringWidth(filtered_file_item.m_DisplayFilename, filtered_file_item.m_DisplayFilename.Length, e.Graphics, this.Font);
                    }
                    else if (item is InfoListBoxItem)
                    {
                        InfoListBoxItem info_item = (InfoListBoxItem)item;
                        MyListBox.DrawString(e.Graphics, info_item.Message, this.Font, this.m_InfoItemBrush, (float)x, (float)y, this.m_StringFormat);
                    }
                    else
                    {
                        string item_str = (string)item;
                        MyListBox.DrawString(e.Graphics, item_str, this.Font, selected ? this.m_HighlightTextBrush : this.m_FileBrush, (float)x, (float)y, this.m_StringFormat);
                        line_width += this.GetStringWidth(item_str, item_str.Length, e.Graphics, this.Font);
                    }
                    this.m_MaxItemWidth = Math.Max(this.m_MaxItemWidth, line_width);
                    i++;
                    y += this.ItemHeight;
                }
                this.DrawScrollBar(e.Graphics);
            }
            catch (Exception arg_57D_0)
            {
                Utils.LogException(arg_57D_0);
            }
            base.OnPaint(e);
        }