GetColumn() public method

Return the column at the given index
public GetColumn ( int index ) : OLVColumn
index int Index of the column to be returned
return OLVColumn
        public static void TimedFilter(ObjectListView olv, string txt, TextMatchFilter.MatchKind matchKind = TextMatchFilter.MatchKind.Text)
        {
            TextMatchFilter filter = null;
            if (!String.IsNullOrEmpty(txt))
                filter = new TextMatchFilter(olv, txt, matchKind);

            // Setup a default renderer to draw the filter matches
            olv.DefaultRenderer = filter == null ? null : new HighlightTextRenderer(filter);

            // Some lists have renderers already installed
            var highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer;
            if (highlightingRenderer != null)
                highlightingRenderer.Filter = filter;

            olv.ModelFilter = filter;
        }
Beispiel #2
0
        void TimedFilter(ObjectListView olv, string txt)
        {
            TextMatchFilter filter = null;
            if (!String.IsNullOrEmpty(txt))
            {
                filter = TextMatchFilter.Contains(olv, txt);
            }
            // Setup a default renderer to draw the filter matches
            if (filter == null)
                olv.DefaultRenderer = null;
            else
            {
                HighlightTextRenderer htr = new HighlightTextRenderer(filter);
                htr.FillBrush = Brushes.AliceBlue;
                olv.DefaultRenderer = htr; //new HighlightTextRenderer(filter);

                // Uncomment this line to see how the GDI+ rendering looks
                //olv.DefaultRenderer = new HighlightTextRenderer { Filter = filter, UseGdiTextRendering = false };
            }

            // Some lists have renderers already installed
            HighlightTextRenderer highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer;
            if (highlightingRenderer != null)
                highlightingRenderer.Filter = filter;

            CompositeAllFilter currentFilter = null;

            if (filter != null)
            {
                // Get the existing model filters, if any, remove any existing TextMatchFilters,
                // then add the new TextMatchFilter
                if (olv.ModelFilter == null)  // easy, just add the new one
                {
                    List<IModelFilter> listOfFilters = new List<IModelFilter>();
                    listOfFilters.Add(filter);  //add the TextMatchFilter
                    CompositeAllFilter compositeFilter = new CompositeAllFilter(listOfFilters);
                    olv.ModelFilter = compositeFilter;
                }
                else  //need to remove existing TextMatchFilters, if any, than add the new one
                {
                    currentFilter = (CompositeAllFilter)olv.ModelFilter;
                    //find the first existing TextMatchFilter (should be at most one) and remove it
                    foreach (IModelFilter m in currentFilter.Filters)
                    {
                        if (m is TextMatchFilter)
                        {
                            currentFilter.Filters.Remove(m);
                            break;
                        }
                    }

                    //add the new TextMatchFilter
                    if (olv.ModelFilter != null)
                    {
                        (olv.ModelFilter as CompositeAllFilter).Filters.Add(filter);
                    }
                    else
                    {
                        List<IModelFilter> listOfFilters = new List<IModelFilter>();
                        listOfFilters.Add(filter);  //add the TextMatchFilter
                        CompositeAllFilter compositeFilter = new CompositeAllFilter(listOfFilters);
                        olv.ModelFilter = compositeFilter;
                    }
                }
            }
            else //remove text filter
            {
                if (olv.ModelFilter != null)
                {
                    currentFilter = (CompositeAllFilter)olv.ModelFilter;
                    //find and remove the first existing TextMatchFilter if any
                    foreach (IModelFilter m in currentFilter.Filters)
                    {
                        if (m is TextMatchFilter)
                        {
                            currentFilter.Filters.Remove(m);
                            break;
                        }
                    }
                    if (currentFilter.Filters.Count == 0)
                    {
                        fastDataListView1.ModelFilter = null;
                    }
                }
            }

            if (currentFilter != null)
                fastDataListView1.ModelFilter = currentFilter;

            updateStatusLine(fastDataListView1);
        }
 /// <summary>
 /// Create a decoration that will draw an animation around a cell of the given model
 /// </summary>
 /// <param name="ModelObject"></param>
 public AnimatedDecoration(ObjectListView olv, OLVListItem item, OLVListSubItem subItem)
     : this(olv) {
     this.ModelObject = item.RowObject;
     this.Column = olv.GetColumn(item.SubItems.IndexOf(subItem));
 }
        public void DrawBusinessCard(Graphics g, Rectangle itemBounds, object rowObject, ObjectListView olv, OLVListItem item)
        {
            try
            {
                const int spacing = 8;

                // Allow a border around the card
                itemBounds.Inflate(-2, -2);

                // Draw card background
                const int rounding = 20;
                GraphicsPath path = this.GetRoundedRect(itemBounds, rounding);
                g.FillPath(this.BackBrush, path);
                g.DrawPath(this.BorderPen, path);

                g.Clip = new Region(itemBounds);

                // Draw the photo
                Rectangle photoRect = itemBounds;
                photoRect.Inflate(-spacing, -spacing);
                Movie movie = rowObject as Movie;
                if (movie != null)
                {
                    photoRect.Width = 200;
                    if (!File.Exists(movie.ImagePath))
                        DownloadImage(movie);

                    if (IsFileExists(movie.ImagePath))
                    {
                        try
                        {
                            using (var photo = Image.FromFile(movie.ImagePath))
                            {
                                if (photo.Width > photoRect.Width)
                                    photoRect.Height = (int)(photo.Height * ((float)photoRect.Width / photo.Width));
                                else
                                    photoRect.Height = photo.Height;
                                g.DrawImage(photo, photoRect);
                            }
                        }
                        catch
                        {
                            g.DrawRectangle(Pens.DarkGray, photoRect);
                            File.Delete(movie.ImagePath);
                        }

                    }
                    else
                    {
                        g.DrawRectangle(Pens.DarkGray, photoRect);
                    }
                }

                // Now draw the text portion
                RectangleF textBoxRect = photoRect;
                textBoxRect.X += (photoRect.Width + spacing);
                textBoxRect.Width = itemBounds.Right - textBoxRect.X - spacing;

                using (StringFormat fmt = new StringFormat())
                {
                    fmt.Trimming = StringTrimming.EllipsisCharacter;
                    fmt.Alignment = StringAlignment.Center;
                    fmt.LineAlignment = StringAlignment.Near;
                    String txt = item.Text;

                    using (Font font = new Font("Tahoma", 11))
                    {
                        // Measure the height of the title
                        SizeF size = g.MeasureString(txt, font, (int)textBoxRect.Width, fmt);
                        // Draw the title
                        RectangleF r3 = textBoxRect;
                        r3.Height = size.Height;
                        path = this.GetRoundedRect(r3, 15);
                        g.FillPath(this.HeaderBackBrush, path);
                        g.DrawString(txt, font, this.HeaderTextBrush, textBoxRect, fmt);
                        textBoxRect.Y += size.Height + spacing;
                    }

                    // Draw the other bits of information
                    using (Font font = new Font("Tahoma", 8))
                    {
                        for (int i = 0; i < olv.Columns.Count; i++)
                        {
                            OLVColumn column = olv.GetColumn(i);
                            if (column.IsTileViewColumn)
                            {
                                SizeF size = g.MeasureString(column.GetStringValue(movie), font, (int)textBoxRect.Width, fmt);
                                textBoxRect.Height = size.Height;
                                fmt.Alignment = StringAlignment.Near;
                                txt = column.GetStringValue(rowObject);
                                g.DrawString(txt, font, this.TextBrush, textBoxRect, fmt);
                                textBoxRect.Y += size.Height ;
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { Debug.WriteLine("This exception: " + ex.Message); }
        }
 /// <summary>
 /// Create a decoration that will draw an animation around a cell of the given model
 /// </summary>
 /// <param name="ModelObject"></param>
 public AnimatedDecoration(ObjectListView olv, OLVListItem item, OLVListSubItem subItem)
     : this(olv) {
     this.ModelObject = item.RowObject;
     this.Column      = olv.GetColumn(item.SubItems.IndexOf(subItem));
 }
Beispiel #6
0
        /// <summary>
        /// Filter list by text
        /// </summary>
        /// <param name="olv"></param>
        /// <param name="txt"></param>
        void ResultTextFilter(ObjectListView olv, string txt)
        {
            TextMatchFilter filter = null;
            if (!String.IsNullOrEmpty(txt))
                filter = new TextMatchFilter(olv, txt);

            // Setup a default renderer to draw the filter matches
            if (filter == null)
                olv.DefaultRenderer = null;
            else
                olv.DefaultRenderer = new HighlightTextRenderer(txt);

            // Some lists have renderers already installed
            HighlightTextRenderer highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer;
            if (highlightingRenderer != null)
                highlightingRenderer.TextToHighlight = txt;

            olv.ModelFilter = filter;
            /*
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            olv.ModelFilter = filter;
            stopWatch.Stop();

            IList objects = olv.Objects as IList;
            if (objects == null)
                this.toolStripStatusLabel1.Text =
                    String.Format("Filtered in {0}ms", stopWatch.ElapsedMilliseconds);
            else
                this.toolStripStatusLabel1.Text =
                    String.Format("Filtered {0} items down to {1} items in {2}ms",
                                  objects.Count,
                                  olv.Items.Count,
                                  stopWatch.ElapsedMilliseconds);
             */
            //GC.Collect();//Melek
        }
        //--------------------------------------------------------------------------------------
        // Accessors

        /// <summary>
        /// Return a typed wrapper around the column at the given index
        /// </summary>
        /// <param name="i">The index of the column</param>
        /// <returns>A typed column or null</returns>
        public virtual TypedColumn <T> GetColumn(int i)
        {
            return(new TypedColumn <T>(olv.GetColumn(i)));
        }
		void TimedFilter(ObjectListView olv, string txt, int matchKind) {
			TextMatchFilter filter = null;
			if (!String.IsNullOrEmpty(txt)) {
				switch (matchKind) {
					case 0:
					default:
						filter = TextMatchFilter.Contains(olv, txt);
						break;
					case 1:
						filter = TextMatchFilter.Prefix(olv, txt);
						break;
					case 2:
						filter = TextMatchFilter.Regex(olv, txt);
						break;
				}
			}
			// Setup a default renderer to draw the filter matches
			if (filter == null) {
				olv.DefaultRenderer = null;
			}  else {
				olv.DefaultRenderer = new HighlightTextRenderer(filter);
				// Uncomment this line to see how the GDI+ rendering looks
				//olv.DefaultRenderer = new HighlightTextRenderer { Filter = filter, UseGdiTextRendering = false };
			}

			// Some lists have renderers already installed
			HighlightTextRenderer highlightingRenderer = olv.GetColumn(0).Renderer as HighlightTextRenderer;
			if (highlightingRenderer != null) {
				highlightingRenderer.Filter = filter;
			}
			Stopwatch stopWatch = new Stopwatch();
			stopWatch.Start();
			olv.AdditionalFilter = filter;
			olv.Invalidate();
			stopWatch.Stop();

			IList objects = olv.Objects as IList;
			if (objects == null) {
				string msg = String.Format("Filtered in {0}ms", stopWatch.ElapsedMilliseconds);
				this.toolTip1.SetToolTip(this.textBoxFilterTree, msg);
			} else {
				string msg = String.Format("Filtered {0} items down to {1} items in {2}ms",
				                           objects.Count,
				                           olv.Items.Count,
				                           stopWatch.ElapsedMilliseconds);
				this.toolTip1.SetToolTip(this.textBoxFilterTree, msg);
			}
		}