Ejemplo n.º 1
0
		public FilepathTextMatchFilter(ObjectListView olv, string text, MatchKind match) :
			base(olv, text, match, StringComparison.CurrentCultureIgnoreCase) {

			this.Columns = new OLVColumn[]{
				(OLVColumn)olv.Columns[1]
			};
		}
Ejemplo n.º 2
0
		static private void ReplaceColumns(ObjectListView olv, IList<OLVColumn> columns) {
			olv.Clear();
			olv.AllColumns.Clear();
			olv.PrimarySortColumn = null;
			olv.SecondarySortColumn = null;
			if (columns.Count > 0) {
				olv.AllColumns.AddRange(columns);
				olv.RebuildColumns();
			}
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Replace all columns of the given ObjectListView with columns generated
		/// from the first member of the given enumerable. If the enumerable is 
		/// empty or null, the ObjectListView will be cleared.
		/// </summary>
		/// <param name="olv">The ObjectListView to modify</param>
		/// <param name="enumerable">The collection whose first element will be used to generate columns.</param>
		static public void GenerateColumns(ObjectListView olv, IEnumerable enumerable) {
			// Generate columns based on the type of the first model in the collection and then quit
			if (enumerable != null) {
				foreach (object model in enumerable) {
					Generator.GenerateColumns(olv, model.GetType());
					return;
				}
			}

			// If we reach here, the collection was empty, so we clear the list
			Generator.ReplaceColumns(olv, new List<OLVColumn>());
		}
Ejemplo n.º 4
0
		/// <summary>
		/// Create a data object which operates on the given model objects 
		/// in the given ObjectListView
		/// </summary>
		/// <param name="olv">The source of the data object</param>
		/// <param name="modelObjects">The model objects to be put into the data object</param>
		public OLVDataObject(ObjectListView olv, IList modelObjects) {
			this.objectListView = olv;
			this.modelObjects = modelObjects;
			this.includeHiddenColumns = olv.IncludeHiddenColumnsInDataTransfer;
		}
Ejemplo n.º 5
0
		/// <summary>
		/// Insert a native group into the underlying Windows control,
		/// *without* using a ListViewGroup
		/// </summary>
		/// <param name="olv"></param>
		/// <remarks>This is used when creating virtual groups</remarks>
		public void InsertGroupNewStyle(ObjectListView olv) {
			this.ListView = olv;
			NativeMethods.InsertGroup(olv, this.AsNativeGroup(true));
			this.SetGroupSpacing();
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Create a TextFilter
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="text"></param>
		/// <param name="columns"></param>
		public TextMatchFilter(ObjectListView olv, string text, OLVColumn[] columns)
			: this(olv, text, columns, MatchKind.Text, StringComparison.InvariantCultureIgnoreCase) {
		}
Ejemplo n.º 7
0
		/// <summary>
		/// Create a TextFilter
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="text"></param>
		/// <param name="match"></param>
		public TextMatchFilter(ObjectListView olv, string text, MatchKind match)
			: this(olv, text, null, match, StringComparison.InvariantCultureIgnoreCase) {
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Create a TextFilter
		/// </summary>
		/// <param name="olv"></param>
		public TextMatchFilter(ObjectListView olv)
			: this(olv, null, null) {
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Draw the decoration
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="g"></param>
		/// <param name="r"></param>
		public override void Draw(ObjectListView olv, Graphics g, Rectangle r) {
			if (!olv.IsCellEditing)
				return;

			Rectangle bounds = olv.CellEditor.Bounds;
			if (bounds.IsEmpty)
				return;

			bounds.Inflate(this.BoundsPadding);
			GraphicsPath path = this.GetRoundedRect(bounds, this.CornerRounding);
			if (this.FillBrush != null) {
				if (this.UseLightbox) {
					using (Region newClip = new Region(r)) {
						newClip.Exclude(path);
						Region originalClip = g.Clip;
						g.Clip = newClip;
						g.FillRectangle(this.FillBrush, r);
						g.Clip = originalClip;
					}
				} else {
					g.FillPath(this.FillBrush, path);
				}
			}
			if (this.BorderPen != null)
				g.DrawPath(this.BorderPen, path);
		}
Ejemplo n.º 10
0
		/// <summary>
		/// Draw a filled border 
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="g"></param>
		/// <param name="r"></param>
		public override void Draw(ObjectListView olv, Graphics g, Rectangle r) {
			Rectangle bounds = this.CalculateBounds();
			if (!bounds.IsEmpty)
				this.DrawFilledBorder(g, bounds);
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Draw a slight colouring over our tinted column
		/// </summary>
		/// <remarks>
		/// This overlay only works when:
		/// - the list is in Details view
		/// - there is at least one row
		/// - there is a selected column (or a specified tint column)
		/// </remarks>
		/// <param name="olv"></param>
		/// <param name="g"></param>
		/// <param name="r"></param>
		public override void Draw(ObjectListView olv, Graphics g, Rectangle r) {

			if (olv.View != System.Windows.Forms.View.Details)
				return;

			if (olv.GetItemCount() == 0)
				return;

			OLVColumn column = this.ColumnToTint ?? olv.SelectedColumn;
			if (column == null)
				return;

			Point sides = NativeMethods.GetScrolledColumnSides(olv, column.Index);
			if (sides.X == -1)
				return;

			Rectangle columnBounds = new Rectangle(sides.X, r.Top, sides.Y - sides.X, r.Bottom);

			// Find the bottom of the last item. The tinting should extend only to there.
			OLVListItem lastItem = olv.GetLastItemInDisplayOrder();
			if (lastItem != null) {
				Rectangle lastItemBounds = lastItem.Bounds;
				if (!lastItemBounds.IsEmpty && lastItemBounds.Bottom < columnBounds.Bottom)
					columnBounds.Height = lastItemBounds.Bottom - columnBounds.Top;
			}
			g.FillRectangle(this.tintBrush, columnBounds);
		}
Ejemplo n.º 12
0
		/// <summary>
		/// Draw this overlay
		/// </summary>
		/// <param name="olv">The ObjectListView being decorated</param>
		/// <param name="g">The Graphics used for drawing</param>
		/// <param name="r">The bounds of the rendering</param>
		public override void Draw(ObjectListView olv, Graphics g, Rectangle r) {
			if (String.IsNullOrEmpty(this.Text))
				return;

			// Calculate the bounds of the text, and then move it to where it should be
			Rectangle textRect = this.CalculateTextBounds(g, r, this.Text);
			textRect.Location = this.Location;

			// Make sure the billboard is within the bounds of the List, as far as is possible
			if (textRect.Right > r.Width)
				textRect.X = Math.Max(r.Left, r.Width - textRect.Width);
			if (textRect.Bottom > r.Height)
				textRect.Y = Math.Max(r.Top, r.Height - textRect.Height);

			this.DrawBorderedText(g, textRect, this.Text, 255);
		}
Ejemplo n.º 13
0
		/// <summary>
		/// Draw this overlay
		/// </summary>
		/// <param name="olv">The ObjectListView being decorated</param>
		/// <param name="g">The Graphics used for drawing</param>
		/// <param name="r">The bounds of the rendering</param>
		public virtual void Draw(ObjectListView olv, Graphics g, Rectangle r) {
			Rectangle insetRect = r;
			insetRect.Inflate(-this.InsetX, -this.InsetY);
			// We hard code a transparency of 255 here since transparency is handled by the glass panel
			this.DrawText(g, insetRect, this.Text, 255);
		}
Ejemplo n.º 14
0
		/// <summary>
		/// Attach this form to the given ObjectListView
		/// </summary>        
		public void Bind(ObjectListView olv, IOverlay overlay) {
			if (this.objectListView != null)
				this.Unbind();

			this.objectListView = olv;
			this.Overlay = overlay;
			this.mdiClient = null;
			this.mdiOwner = null;

			// NOTE: If you listen to any events here, you *must* stop listening in Unbind()
			this.objectListView.Disposed += new EventHandler(objectListView_Disposed);
			this.objectListView.LocationChanged += new EventHandler(objectListView_LocationChanged);
			this.objectListView.SizeChanged += new EventHandler(objectListView_SizeChanged);
			this.objectListView.VisibleChanged += new EventHandler(objectListView_VisibleChanged);
			this.objectListView.ParentChanged += new EventHandler(objectListView_ParentChanged);

			Control parent = this.objectListView.Parent;
			while (parent != null) {
				parent.ParentChanged += new EventHandler(objectListView_ParentChanged);
				TabControl tabControl = parent as TabControl;
				if (tabControl != null) {
					tabControl.Selected += new TabControlEventHandler(tabControl_Selected);
				}
				parent = parent.Parent;
			}
			this.Owner = this.objectListView.FindForm();
			this.myOwner = this.Owner;
			if (this.Owner != null) {
				this.Owner.LocationChanged += new EventHandler(Owner_LocationChanged);
				this.Owner.SizeChanged += new EventHandler(Owner_SizeChanged);
				this.Owner.ResizeBegin += new EventHandler(Owner_ResizeBegin);
				this.Owner.ResizeEnd += new EventHandler(Owner_ResizeEnd);
				if (this.Owner.TopMost) {
					// We can't do this.TopMost = true; since that will activate the panel,
					// taking focus away from the owner of the listview
					NativeMethods.MakeTopMost(this);
				}

				// We need special code to handle MDI
				this.mdiOwner = this.Owner.MdiParent;
				if (this.mdiOwner != null) {
					this.mdiOwner.LocationChanged += new EventHandler(Owner_LocationChanged);
					this.mdiOwner.SizeChanged += new EventHandler(Owner_SizeChanged);
					this.mdiOwner.ResizeBegin += new EventHandler(Owner_ResizeBegin);
					this.mdiOwner.ResizeEnd += new EventHandler(Owner_ResizeEnd);

					// Find the MDIClient control, which houses all MDI children
					foreach (Control c in this.mdiOwner.Controls) {
						this.mdiClient = c as MdiClient;
						if (this.mdiClient != null) {
							break;
						}
					}
					if (this.mdiClient != null) {
						this.mdiClient.ClientSizeChanged += new EventHandler(myMdiClient_ClientSizeChanged);
					}
				}
			}

			this.UpdateTransparency();
		}
Ejemplo n.º 15
0
		/// <summary>
		/// Insert a native group into the underlying control via a ListViewGroup
		/// </summary>
		/// <param name="olv"></param>
		public void InsertGroupOldStyle(ObjectListView olv) {
			this.ListView = olv;
			if (this.ListViewGroup == null)
				this.ListViewGroup = new ListViewGroup();
			this.ListViewGroup.Header = this.Header;
			this.ListViewGroup.HeaderAlignment = this.HeaderAlignment;
			this.ListViewGroup.Name = this.Name;
			this.ListViewGroup.Tag = this.Tag;
			olv.Groups.Add(this.ListViewGroup);

			// Add any extra information
			NativeMethods.SetGroupInfo(olv, this.GroupId, this.AsNativeGroup(false));
			this.SetGroupSpacing();
		}
Ejemplo n.º 16
0
		/// <summary>
		/// See IDragSource documentation
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="button"></param>
		/// <param name="item"></param>
		/// <returns></returns>
		public virtual Object StartDrag(ObjectListView olv, MouseButtons button, OLVListItem item) {
			return null;
		}
Ejemplo n.º 17
0
		/// <summary>
		/// Create an AutoCompleteCellEditor
		/// </summary>
		/// <param name="lv"></param>
		/// <param name="column"></param>
		public AutoCompleteCellEditor(ObjectListView lv, OLVColumn column) {
			this.DropDownStyle = ComboBoxStyle.DropDown;

			Dictionary<String, bool> alreadySeen = new Dictionary<string, bool>();
			for (int i = 0; i < Math.Min(lv.GetItemCount(), 1000); i++) {
				String str = column.GetStringValue(lv.GetModelObject(i));
				if (!alreadySeen.ContainsKey(str)) {
					this.Items.Add(str);
					alreadySeen[str] = true;
				}
			}

			this.Sorted = true;
			this.AutoCompleteSource = AutoCompleteSource.ListItems;
			this.AutoCompleteMode = AutoCompleteMode.Append;
		}
Ejemplo n.º 18
0
		/// <summary>
		/// Draw a tint over everything in the ObjectListView except the 
		/// row under the mouse.
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="g"></param>
		/// <param name="r"></param>
		public override void Draw(ObjectListView olv, Graphics g, Rectangle r) {
			if (!r.Contains(olv.PointToClient(Cursor.Position)))
				return;

			Rectangle bounds = this.RowBounds;
			if (bounds.IsEmpty) {
				if (olv.View == View.Tile)
					g.FillRectangle(this.FillBrush, r);
				return;
			}

			using (Region newClip = new Region(r)) {
				bounds.Inflate(this.BoundsPadding);
				newClip.Exclude(this.GetRoundedRect(bounds, this.CornerRounding));
				Region originalClip = g.Clip;
				g.Clip = newClip;
				g.FillRectangle(this.FillBrush, r);
				g.Clip = originalClip;
			}
		}
Ejemplo n.º 19
0
		/// <summary>
		/// Generate columns into the given ObjectListView that come from the given 
		/// model object type. 
		/// </summary>
		/// <param name="olv">The ObjectListView to modify</param>
		/// <param name="type">The model type whose attributes will be considered.</param>
		static public void GenerateColumns(ObjectListView olv, Type type) {
			IList<OLVColumn> columns = Generator.GenerateColumns(type);
			Generator.ReplaceColumns(olv, columns);
		}
Ejemplo n.º 20
0
		/// <summary>
		/// Draw this decoration
		/// </summary>
		/// <param name="olv">The ObjectListView being decorated</param>
		/// <param name="g">The Graphics used for drawing</param>
		/// <param name="r">The bounds of the rendering</param>
		public virtual void Draw(ObjectListView olv, Graphics g, Rectangle r) {
			this.DrawText(g, this.CalculateItemBounds(this.ListItem, this.SubItem));
		}
Ejemplo n.º 21
0
		/// <summary>
		/// Draw the decoration
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="g"></param>
		/// <param name="r"></param>
		public virtual void Draw(ObjectListView olv, Graphics g, Rectangle r) {
		}
Ejemplo n.º 22
0
		/// <summary>
		/// Create a DataObject when the user does a left mouse drag operation.
		/// See IDragSource for further information.
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="button"></param>
		/// <param name="item"></param>
		/// <returns></returns>
		public virtual Object StartDrag(ObjectListView olv, MouseButtons button, OLVListItem item) {
			// We only drag on left mouse
			if (button != MouseButtons.Left)
				return null;

			return this.CreateDataObject(olv);
		}
Ejemplo n.º 23
0
		/// <summary>
		/// Create a TextFilter
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="text"></param>
		public TextMatchFilter(ObjectListView olv, string text)
			: this(olv, text, null) {
		}
Ejemplo n.º 24
0
		/// <summary>
		/// Create a data object that will be used to as the data object
		/// for the drag operation.
		/// </summary>
		/// <remarks>
		/// Subclasses can override this method add new formats to the data object.
		/// </remarks>
		/// <param name="olv">The ObjectListView that is the source of the drag</param>
		/// <returns>A data object for the drag</returns>
		protected virtual object CreateDataObject(ObjectListView olv) {
			OLVDataObject data = new OLVDataObject(olv);
			data.CreateTextFormats();
			return data;
		}
Ejemplo n.º 25
0
		/// <summary>
		/// Create a TextFilter
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="text"></param>
		/// <param name="match"></param>
		/// <param name="comparison"></param>
		public TextMatchFilter(ObjectListView olv, string text, MatchKind match, StringComparison comparison)
			: this(olv, text, null, match, comparison) {
		}
Ejemplo n.º 26
0
		/// <summary>
		/// Create a data object from the selected objects in the given ObjectListView
		/// </summary>
		/// <param name="olv">The source of the data object</param>
		public OLVDataObject(ObjectListView olv)
			: this(olv, olv.SelectedObjects) {
		}
Ejemplo n.º 27
0
		/// <summary>
		/// Create a TextFilter
		/// </summary>
		/// <param name="olv"></param>
		/// <param name="text"></param>
		/// <param name="columns"></param>
		/// <param name="matchKind"></param>
		/// <param name="comparison"></param>
		public TextMatchFilter(ObjectListView olv, string text, OLVColumn[] columns, MatchKind matchKind, StringComparison comparison) {
			this.ListView = olv;
			this.Text = text;
			this.Match = matchKind;
			this.StringComparison = comparison;
			this.Columns = columns;
		}
Ejemplo n.º 28
0
		/// <summary>
		/// Create a header control for the given ObjectListView.
		/// </summary>
		/// <param name="olv"></param>
		public HeaderControl(ObjectListView olv) {
			this.ListView = olv;
			this.AssignHandle(NativeMethods.GetHeaderControl(olv));
		}