// We have to draw this ourselves to ensure the alignment works correctly when we change font sizes void m_lvMatches_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { FwListView lv = (FwListView)sender; // In the future, different image indexes may be used for affixes or other kinds of results //int imageIndex = 0; e.SubItem.BackColor = e.Item.Selected ? (lv.Focused ? SystemColors.Highlight : SystemColors.GrayText) : lv.BackColor; e.DrawBackground(); // Per LT-4815 comments, we don't want the icon. If we reinstate it, it should be the // new find entry icon. Image image = null; // m_ilEntries.Images[imageIndex]; Rectangle rect = e.Bounds; if (image != null && e.ColumnIndex == 0) { // Create a bounds rectangle that isn't larger than the area we have to draw in Rectangle imageRect = new Rectangle(rect.Location, new Size(Math.Min(rect.Width, image.Width), Math.Min(rect.Height, image.Height))); e.Graphics.DrawImage(image, imageRect); rect.X += image.Width; } TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font, rect, lv.GetTextColor(e), TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MatchingEntries)); this.m_lvMatches = new SIL.FieldWorks.Common.Controls.FwListView(); this.m_chLF = new System.Windows.Forms.ColumnHeader(); this.m_chCF = new System.Windows.Forms.ColumnHeader(); this.m_chAltFms = new System.Windows.Forms.ColumnHeader(); this.m_chGlosses = new System.Windows.Forms.ColumnHeader(); this.m_ilEntries = new System.Windows.Forms.ImageList(this.components); this.SuspendLayout(); // // m_lvMatches // resources.ApplyResources(this.m_lvMatches, "m_lvMatches"); this.m_lvMatches.CausesValidation = false; this.m_lvMatches.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.m_chLF, this.m_chCF, this.m_chAltFms, this.m_chGlosses }); this.m_lvMatches.FullRowSelect = true; this.m_lvMatches.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; this.m_lvMatches.HideSelection = false; this.m_lvMatches.MultiSelect = false; this.m_lvMatches.Name = "m_lvMatches"; this.m_lvMatches.OwnerDraw = true; this.m_lvMatches.UseCompatibleStateImageBehavior = false; this.m_lvMatches.View = System.Windows.Forms.View.Details; this.m_lvMatches.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(this.m_lvMatches_DrawItem); this.m_lvMatches.DoubleClick += new System.EventHandler(this.m_lvMatches_DoubleClick); this.m_lvMatches.SelectedIndexChanged += new System.EventHandler(this.m_lvMatches_SelectedIndexChanged); this.m_lvMatches.DrawSubItem += new System.Windows.Forms.DrawListViewSubItemEventHandler(this.m_lvMatches_DrawSubItem); this.m_lvMatches.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.m_lvMatches_DrawColumnHeader); // // m_chLF // resources.ApplyResources(this.m_chLF, "m_chLF"); // // m_chCF // resources.ApplyResources(this.m_chCF, "m_chCF"); // // m_chAltFms // resources.ApplyResources(this.m_chAltFms, "m_chAltFms"); // // m_chGlosses // resources.ApplyResources(this.m_chGlosses, "m_chGlosses"); // // m_ilEntries // this.m_ilEntries.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("m_ilEntries.ImageStream"))); this.m_ilEntries.TransparentColor = System.Drawing.Color.Fuchsia; this.m_ilEntries.Images.SetKeyName(0, ""); this.m_ilEntries.Images.SetKeyName(1, ""); this.m_ilEntries.Images.SetKeyName(2, ""); // // MatchingEntries // resources.ApplyResources(this, "$this"); this.Controls.Add(this.m_lvMatches); this.Name = "MatchingEntries"; this.Load += new System.EventHandler(this.MatchingEntries_Load); this.ResumeLayout(false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a new StyleListViewHelper for the given FwListView. /// </summary> /// <param name="listView">The given FwListView</param> /// <param name="styleColumn">The column that the style is shown in</param> /// ------------------------------------------------------------------------------------ public StyleListViewHelper(FwListView listView, int styleColumn) : base(listView) { m_styleColumn = styleColumn; listView.DrawSubItem += new DrawListViewSubItemEventHandler(CtrlDrawSubItem); listView.SelectedIndexChanged += new EventHandler(CtrlSelectedIndexChanged); }