public void ColorFilter(object modelObject, OLVListItem item) { var row = ((T)modelObject); foreach (var qFilter in _filter.QuickFilters) { if (!qFilter.ColorFilter) { continue; } bool qFound = false; var regex = new Regex(Regex.Escape(qFilter.FilterValue), RegexOptions.IgnoreCase); if (!_headers.ContainsKey(qFilter.ColumnName)) { continue; } var stuff = _headers[qFilter.ColumnName].AspectGetter.Invoke(row); if (stuff == null) { continue; } if (regex.Matches(stuff).Count > 0) { qFound = true; } if (qFound) { item.BackColor = qFilter.RowColor; return; } } }
public int Compare(object x, object y) { if (sortOrder == SortOrder.None) { return(0); } OLVListItem itemX = x as OLVListItem; OLVListItem itemY = y as OLVListItem; var objValueX = itemX.GetSubItem(column.Index).ModelValue; var objValueY = itemY.GetSubItem(column.Index).ModelValue; long res = 0; if (objValueX is string || objValueY is string) { res = string.Compare((string)objValueX, (string)objValueY); } if (objValueX is long || objValueY is long) { long valueX = objValueX != null ? (long)objValueX : 0; long valueY = objValueY != null ? (long)objValueY : 0; res = sortMode == DumpDiffModule.SortMode.AbsValue ? Math.Abs(valueX) - Math.Abs(valueY) : valueX - valueY; } return(sortOrder == SortOrder.Ascending ? (int)res : -(int)res); }
private void OnSelectCastMemberButtonClick(Object sender , EventArgs e) { if (SearchResultsView.SelectedIndex != -1) { OLVListItem row = (OLVListItem)(SearchResultsView.Items[SearchResultsView.SelectedIndex]); SearchResult result = row.RowObject as SearchResult; if (result != null) { m_CastMember.CastId = result.CastId; m_CastMember.FirstName = result.FirstName; m_CastMember.MiddleName = result.MiddleName; m_CastMember.LastName = result.LastName; DialogResult = DialogResult.OK; Close(); } else { MessageBox.Show("Please select a cast row."); } } else { MessageBox.Show("Please select a row."); } }
private void LogRowFormat(OLVListItem item) { try { var log = (LogInfo)item.RowObject; if (log == null) { return; } if (log.Color.HasValue) { item.ForeColor = log.Color.Value; } if (log.Error) { item.ForeColor = Color.DarkRed; } } catch { // ignored } }
public Color print_bg_color(OLVListItem item, text_part print) { match_item i = item.RowObject as match_item; bool is_sel = !ignore_selection?parent_sel.Contains(item.Index) : false; Color default_bg = i.bg(parent_); Color bg = print.bg != util.transparent ? print.bg : default_bg; if (bg == util.transparent) { bg = app.inst.bg; } // selection needs a bit of dark if (is_sel) { bg = sel_bg_color(bg); } if (print.is_typed_search && !print.is_find_search) { // 1.7.22 - don't use the overridden background - we want to have the same background for all finds bg = util.darker_color(default_bg); } return(bg); }
private void ItemRowFormatter(OLVListItem item) { item.UseItemStyleForSubItems = false; var loan = (Item)item.RowObject; if (loan.Selected) { var selectedBackColor = Color.FromArgb(210, 241, 255); item.SubItems[0].BackColor = selectedBackColor; item.SubItems[1].BackColor = selectedBackColor; item.SubItems[2].BackColor = selectedBackColor; item.SubItems[3].BackColor = selectedBackColor; item.SubItems[4].BackColor = selectedBackColor; item.SubItems[5].BackColor = selectedBackColor; } if (loan == _totalItem) { item.Font = new Font(item.Font, FontStyle.Bold); item.SubItems[1].Font = item.Font; item.SubItems[2].Font = item.Font; item.SubItems[3].Font = item.Font; item.SubItems[4].Font = item.Font; item.SubItems[5].Font = item.Font; } }
public override object StartDrag(ObjectListView olv, MouseButtons button, OLVListItem item) { var rowObject = item.RowObject;//get the dragged object if (olv.SelectedObjects.Count > 1) { rowObject = olv.SelectedObjects.Cast <object>().ToArray(); } if (rowObject != null) { //get the drag operation data object olv does var toReturn = (OLVDataObject)base.StartDrag(olv, button, item); //can we process it into a command? ICombineToMakeCommand command = _commandFactory.Create(toReturn); if (command == null) { return(null);//it couldn't become a command so leave it as a model object } //yes, lets hot swap the data object in the drag command, that couldn't possibly go wrong right? toReturn.ModelObjects.Clear(); toReturn.ModelObjects.Add(command); return(toReturn); } return(base.StartDrag(olv, button, item)); }
private static void FormatRow(OLVListItem item) { var installment = (Installment)item.RowObject; if (installment == null) { return; } if (installment.IsPending) { item.BackColor = Color.Orange; } if (installment.IsRepaid) { item.BackColor = Color.FromArgb(61, 153, 57); } if (installment.IsPending || installment.IsRepaid) { item.ForeColor = Color.White; } if (installment.LateDays > 0 && !(installment.IsPending || installment.IsRepaid)) { item.ForeColor = Color.Red; } }
/// <summary> /// Handles a drop event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void watchDataGridView_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false)) { object data = e.Data.GetData("WindowsForms10PersistentObject"); BaseTreeNode sourceNode = data as BaseTreeNode; if (sourceNode != null) { IVariable variable = sourceNode.Model as IVariable; if (variable == null) { Shortcut shortCut = sourceNode.Model as Shortcut; if (shortCut != null) { variable = shortCut.GetReference() as IVariable; } } if (variable != null) { AddVariable(variable); } } OLVListItem item = data as OLVListItem; if (item != null) { IVariable variable = item.RowObject as IVariable; if (variable != null) { AddVariable(variable); } } } }
private string GetDataAsSring() { string output = ""; for (int i = 0; i < fastDataListView1.Columns.Count; i++) { String headerName = fastDataListView1.GetColumn(i).ToString(); int pos = headerName.LastIndexOf(":"); headerName = headerName.Substring(pos + 1).Trim(); output += headerName + "\t"; } output += Environment.NewLine; for (int i = 0; i < fastDataListView1.GetItemCount(); i++) { OLVListItem OLVListItem = fastDataListView1.GetItem(0); PatientCohortMember patientCohortMember = (PatientCohortMember)OLVListItem.RowObject; for (int j = 0; j < fastDataListView1.Columns.Count; j++) { OLVColumn OLVColumn = fastDataListView1.GetColumn(j); String aspectName = OLVColumn.AspectName; String value = patientCohortMember.GetType().GetField(aspectName).GetValue(patientCohortMember).ToString(); output += value + "\t"; } output += Environment.NewLine; } return(output); }
public void UpdateMovieNode(OLVListItem nodeMovie, Movie movie) { try { var rowMovie = ((Movie)nodeMovie.RowObject); //var movie = CollectAndAddMovieToDb(rowMovie, Browser.DocumentText, false); if (movie == null) { return; } if (!movie.IsVirtual) { movie.FilePath = rowMovie.FilePath; movie.FilePath = ChangeFolderName(movie); } rowMovie.CopyFromMovie(movie); InvokeOnNotificationFired("Movie: " + rowMovie.Title + " is updated."); } catch (Exception exception) { Logger.Exception(exception, 2); } }
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); }
private JsonNetDemo GetSelectJsonNetDemo() { OLVListItem item = olvFast.SelectedItem; JsonNetDemo demo = item.RowObject as JsonNetDemo; return(demo); }
private static void FormatRow(OLVListItem item) { var installment = (Installment)item.RowObject; if (installment == null) { return; } if (installment.IsPending) { item.BackColor = Color.Orange; } if (installment.IsRepaid) { item.BackColor = Color.FromArgb(61, 153, 57); } if (installment.IsPending || installment.IsRepaid) { item.ForeColor = Color.White; } if (installment.Number == -1) { item.Font = new Font(item.Font, FontStyle.Bold); } }
public void TestHyperlinks() { this.olv.UseHyperlinks = true; this.olv.HyperlinkStyle = new HyperlinkStyle(); this.olv.HyperlinkStyle.Normal.ForeColor = Color.Thistle; this.olv.HyperlinkStyle.Normal.BackColor = Color.SpringGreen; this.olv.HyperlinkStyle.Normal.FontStyle = FontStyle.Bold; foreach (OLVColumn column in this.olv.Columns) { column.Hyperlink = (column.Index < 2); } this.olv.SetObjects(PersonDb.All); for (int j = 0; j < this.olv.GetItemCount(); j++) { OLVListItem item = this.olv.GetItem(j); for (int i = 0; i < this.olv.Columns.Count; i++) { OLVColumn column = this.olv.GetColumn(i); if (column.Hyperlink) { Assert.AreEqual(this.olv.HyperlinkStyle.Normal.ForeColor, item.SubItems[i].ForeColor); Assert.AreEqual(this.olv.HyperlinkStyle.Normal.BackColor, item.SubItems[i].BackColor); Assert.IsTrue(item.SubItems[i].Font.Bold); } else { Assert.AreEqual(this.olv.ForeColor, item.SubItems[i].ForeColor); Assert.AreEqual(this.olv.BackColor, item.SubItems[i].BackColor); Assert.IsFalse(item.SubItems[i].Font.Bold); } } } }
private void ColorListViewItemIfModified(OLVListItem item) { if (IsListViewItemModified(item)) { item.BackColor = Color.Tomato; } }
public override void Draw(ObjectListView olv, Graphics g, Rectangle r) { if (olv.HotRowIndex < 0) { return; } if (olv.View == View.Tile) { return; } OLVListItem item = olv.GetItem(olv.HotRowIndex); if (item == null) { return; } Size cardSize = new Size(400, 250); Rectangle cardBounds = new Rectangle( r.Right - cardSize.Width - 8, r.Bottom - cardSize.Height - 20, cardSize.Width, cardSize.Height); businessCardRenderer.DrawBusinessCard(g, cardBounds, item.RowObject, olv, item); }
private void recycleBinList_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (recycleBinList.SelectedItems.Count > 0) { lblXStatus.Text = recycleBinList.SelectedItems.Count + (recycleBinList.SelectedItems.Count == 1 ? " item" : " items") + " selected."; biRestoreItem.Enabled = true; if (recycleBinList.SelectedItems.Count > 1) { biRestoreItem.Text = "Restore Items"; } else { OLVListItem item = (OLVListItem)recycleBinList.SelectedItems[0]; RecycleBinEntry entry = (RecycleBinEntry)item.RowObject; if (entry.EntryType == RecycleBinEntryType.File) { biRestoreItem.Text = "Restore File"; } else { biRestoreItem.Text = "Restore Folder"; } } } else { lblXStatus.Text = "No items selected."; biRestoreItem.Text = "<i>No items selected.</i>"; biRestoreItem.Enabled = false; } lblXStatus.Refresh(); biRestoreItem.Refresh(); itemContainer1.Refresh(); }
protected override Control GetCellEditor(OLVListItem item, int subItemIndex) { var column = GetColumn(subItemIndex); var rowObject = item.RowObject as RowObject; if (rowObject != null) { if (column == mFieldValues && !rowObject.IsInsertionRow) { if (rowObject.Value.IsProtected) { return(new ProtectedFieldEditor { Value = rowObject.Value, HidePassword = rowObject.HideValue && !rowObject.RevealValue }); } else { return(new UnprotectedFieldEditor { Value = rowObject.Value }); } } else if (column == mFieldNames) { return(GetFieldNameEditor(rowObject)); } } return(base.GetCellEditor(item, subItemIndex)); }
public void FormatRow(OLVListItem r, PacketInfo.Daemon src, PacketInfo.Daemon dst) { var p = Pairs[new Key(src, dst)]; r.ForeColor = p.Item1; r.BackColor = p.Item2; }
private void RowFormatter(OLVListItem olvItem) { if (olvItem.RowObject is JoinableCollectionNode || olvItem.RowObject is CohortIdentificationHeader) { olvItem.BackColor = Color.Black; olvItem.ForeColor = Color.White; } var compileable = olvItem.RowObject as Compileable; var selectedContainer = tlvConfiguration.SelectedObject as AggregationContainerTask; //show disabled tasks in gray if (compileable != null && !compileable.IsEnabled()) { olvItem.BackColor = Color.Gray; return; } if (compileable != null && selectedContainer != null && compileable.ParentContainerIfAny != null) { if (compileable.ParentContainerIfAny.Equals(selectedContainer.Container)) { olvItem.BackColor = Color.LightCyan; } } }
private void objectListViewBets_ItemChecked(object sender, ItemCheckedEventArgs e) { OLVListItem eOlv = (OLVListItem)e.Item; LotteryWinningBet bet = (LotteryWinningBet)eOlv.RowObject; e.Item.Tag = (eOlv.Checked == bet.IsClaimed()) ? null : MODIFIED_TAG; ColorListViewItemIfModified((OLVListItem)e.Item); }
public void SearchMovieTree(string address, OLVListItem movie) { try { SearchMovie(address, (Movie)movie.RowObject); } catch (Exception exception) { Logger.Exception(exception, 134); } }
private void RowFormatter(OLVListItem olvItem) { var advertised = (AdvertisedPipelineComponentTypeUnderContext)olvItem.RowObject; if (!advertised.IsCompatible()) { olvItem.ForeColor = Color.Red; } }
private static void CollectAndUpdate(OLVListItem selectedItem, string html = null, Movie movie = null, bool fetchKeywords = true) { var information = new CollectInformation { MovieController = new MovieBrowserController(), MovieNode = selectedItem, Html = html, ParsedMovie = movie, FetchKeyword = fetchKeywords }; var thread = new Thread(information.Collect); thread.Start(); }
// Control.ProcessDialogKey Method is completely supressed in 3ds Max. // For this reason when editing a cell an override is requried to add an EventHandler. // This EventHandler then manually calls the ProcessDialogKey Method. // We also need to disable accellerators in 3ds Max. protected override Control GetCellEditor(OLVListItem item, int subItemIndex) { Control editor = base.GetCellEditor(item, subItemIndex); editor.KeyDown += new KeyEventHandler(CellEditKeyDown); editor.LostFocus += new EventHandler(CellEditLostFocus); GlobalInterface.Instance.DisableAccelerators(); return(editor); }
private void RowFormatter(OLVListItem olvItem) { var col = olvItem.RowObject as IColumn; if (col != null) { olvItem.BackColor = col is AggregateCountColumn ? Color.Wheat : Color.White; olvItem.ForeColor = _availableColumns.Contains(col) ? Color.Gray : Color.Black; } }
/// <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)); }
private static OLVListItem NewItem(string first, string second) { OLVListItem result = new OLVListItem(first); //result.SubItems.Add(); OLVListSubItem newSub = new OLVListSubItem(); newSub.Text = second; result.SubItems.Add(newSub); return(result); }
/// <summary> /// Start editing the indicated cell if that cell is not already being edited /// </summary> /// <param name="olvi">The row to edit</param> /// <param name="subItemIndex">The cell within that row to edit</param> protected void StartCellEditIfDifferent(OLVListItem olvi, int subItemIndex) { if (this.ItemBeingEdited == olvi && this.SubItemIndexBeingEdited == subItemIndex) { return; } this.ListView.EnsureVisible(olvi.Index); this.ListView.StartCellEdit(olvi, subItemIndex); }
/// <summary> /// Gets the adjacent item to the given item in the given direction. /// If that item is disabled, continue in that direction until an enabled item is found. /// </summary> /// <param name="olvi">The row whose neighbour is sought</param> /// <param name="up">The direction of the adjacentness</param> /// <returns>An OLVListView adjacent to the given item, or null if there are no more enabled items in that direction.</returns> protected OLVListItem GetAdjacentItemOrNull(OLVListItem olvi, bool up) { OLVListItem item = up ? this.ListView.GetPreviousItem(olvi) : this.ListView.GetNextItem(olvi); while (item != null && !item.Enabled) { item = up ? this.ListView.GetPreviousItem(item) : this.ListView.GetNextItem(item); } return(item); }
/// <summary> /// Create an event args /// </summary> /// <param name="column"></param> /// <param name="control"></param> /// <param name="r"></param> /// <param name="item"></param> /// <param name="subItemIndex"></param> public CellEditEventArgs(OLVColumn column, Control control, Rectangle r, OLVListItem item, int subItemIndex) { this.Control = control; this.column = column; this.cellBounds = r; this.listViewItem = item; this.rowObject = item.RowObject; this.subItemIndex = subItemIndex; this.value = column.GetValue(item.RowObject); }
/// <summary> /// Handle a HitTest request after all state information has been initialized /// </summary> /// <param name="g"></param> /// <param name="cellBounds"></param> /// <param name="item"></param> /// <param name="subItemIndex"></param> /// <returns></returns> protected virtual Rectangle HandleGetEditRectangle(Graphics g, Rectangle cellBounds, OLVListItem item, int subItemIndex) { // MAINTAINER NOTE: This type testing is wrong (design-wise). The base class should return cell bounds, // and a more specialized class should return StandardGetEditRectangle(). But BaseRenderer is used directly // to draw most normal cells, as well as being directly subclassed for user implemented renderers. And this // method needs to return different bounds in each of those cases. We should have a StandardRenderer and make // BaseRenderer into an ABC -- but that would break too much existing code. And so we have this hack :( // If we are a standard renderer, return the position of the text, otherwise, use the whole cell. if (this.GetType() == typeof(BaseRenderer)) return this.StandardGetEditRectangle(g, cellBounds); else return cellBounds; }
/// <summary> /// Calculate the edit rectangle /// </summary> /// <param name="g"></param> /// <param name="cellBounds"></param> /// <param name="item"></param> /// <param name="subItemIndex"></param> /// <returns></returns> public override Rectangle GetEditRectangle(Graphics g, Rectangle cellBounds, OLVListItem item, int subItemIndex) { this.ClearState(); this.ListView = (ObjectListView)item.ListView; this.ListItem = item; this.SubItem = item.GetSubItem(subItemIndex); this.Column = this.ListView.GetColumn(subItemIndex); this.RowObject = item.RowObject; this.IsItemSelected = this.ListItem.Selected; this.Bounds = cellBounds; return this.HandleGetEditRectangle(g, cellBounds, item, subItemIndex); }
/// <summary> /// Handle the GetEditRectangle request /// </summary> /// <param name="g"></param> /// <param name="cellBounds"></param> /// <param name="item"></param> /// <param name="subItemIndex"></param> /// <returns></returns> protected override Rectangle HandleGetEditRectangle(Graphics g, Rectangle cellBounds, OLVListItem item, int subItemIndex) { return cellBounds; }
/// <summary> /// When the value in the given cell is to be edited, where should the edit rectangle be placed? /// </summary> /// <param name="g"></param> /// <param name="cellBounds"></param> /// <param name="item"></param> /// <param name="subItemIndex"></param> /// <returns></returns> public virtual Rectangle GetEditRectangle(Graphics g, Rectangle cellBounds, OLVListItem item, int subItemIndex) { return cellBounds; }
/// <summary> /// Calculate the target rectangle when the given item (and possible subitem) /// is the target of the drop. /// </summary> /// <param name="item"></param> /// <param name="subItem"></param> /// <returns></returns> protected virtual Rectangle CalculateDropTargetRectangle(OLVListItem item, int subItem) { if (subItem > 0) return item.SubItems[subItem].Bounds; Rectangle r = this.ListView.CalculateCellTextBounds(item, subItem); // Allow for indent if (item.IndentCount > 0) { int indentWidth = this.ListView.SmallImageSize.Width; r.X += (indentWidth * item.IndentCount); r.Width -= (indentWidth * item.IndentCount); } return r; }
/// <summary> /// Given the item and the subitem, calculate its bounds. /// </summary> /// <param name="item"></param> /// <param name="subItem"></param> /// <returns></returns> public Rectangle CalculateItemBounds(OLVListItem item, OLVListSubItem subItem) { if (item == null) return Rectangle.Empty; if (subItem == null) return item.Bounds; else return item.GetSubItemBounds(item.SubItems.IndexOf(subItem)); }
/// <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; }
/// <summary> /// Refresh the given item in the list /// </summary> /// <param name="olvi">The item to refresh</param> public override void RefreshItem(OLVListItem olvi) { this.ClearCachedInfo(); this.RedrawItems(olvi.Index, olvi.Index, false); }
/// <summary> /// Create a OLVListItem for given row index /// </summary> /// <param name="itemIndex">The index of the row that is needed</param> /// <returns>An OLVListItem</returns> public virtual OLVListItem MakeListViewItem(int itemIndex) { OLVListItem olvi = new OLVListItem(this.GetModelObject(itemIndex)); this.FillInValues(olvi, olvi.RowObject); this.PostProcessOneRow(itemIndex, this.GetItemIndexInDisplayOrder(itemIndex), olvi); if (this.HotRowIndex == itemIndex) this.UpdateHotRow(olvi); return olvi; }