/// <summary> /// Create an exact clone of this item /// </summary> /// <returns>An exact clone of this item</returns> public ManagedListViewItem Clone() { ManagedListViewItem newItem = new ManagedListViewItem(); newItem.Color = this.Color; newItem.CustomFont = this.CustomFont; newItem.CustomFontEnabled = this.CustomFontEnabled; newItem.DrawMode = this.DrawMode; newItem.ImageIndex = this.ImageIndex; newItem.IsSpecialItem = this.IsSpecialItem; newItem.Selected = this.Selected; newItem.Tag = this.Tag; newItem.Text = this.Text; newItem.SubItems = new List <ManagedListViewSubItem>(); foreach (ManagedListViewSubItem sub in this.SubItems) { newItem.SubItems.Add(sub.Clone()); } return(newItem); }
/// <summary> /// Scroll view port into item /// </summary> /// <param name="item">The item to scroll into</param> public void ScrollToItem(ManagedListViewItem item) { ScrollToItem(ManagedListViewPanel1.items.IndexOf(item)); }
/// <summary> /// Create an exact clone of this item /// </summary> /// <returns>An exact clone of this item</returns> public ManagedListViewItem Clone() { ManagedListViewItem newItem = new ManagedListViewItem(); newItem.Color = this.Color; newItem.CustomFont = this.CustomFont; newItem.CustomFontEnabled = this.CustomFontEnabled; newItem.DrawMode = this.DrawMode; newItem.ImageIndex = this.ImageIndex; newItem.IsSpecialItem = this.IsSpecialItem; newItem.Selected = this.Selected; newItem.Tag = this.Tag; newItem.Text = this.Text; newItem.SubItems = new List<ManagedListViewSubItem>(); foreach (ManagedListViewSubItem sub in this.SubItems) newItem.SubItems.Add(sub.Clone()); return newItem; }
/// <summary> /// Arguments for subitem draw events. /// </summary> /// <param name="id">The column id which this subitem belongs to.</param> /// <param name="itemIndex">The parent item index.</param> /// <param name="theItem">The item</param> public ManagedListViewSubItemDrawArgs(string id, int itemIndex, ManagedListViewItem theItem) { this.itemIndex = itemIndex; this.id = id; this.theItem = theItem; }
// For debug purpose. private void toolStripButton6_Click(object sender, EventArgs e) { FormDetectSelection frm = new FormDetectSelection(); if (frm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { // Get the dataset of GAMES table DataSet ds = MyNesDB.GetDataSet(frm.MODE.ToString()); if (ds == null) return; // Set columns if (ds.Tables[0].Rows.Count > 0) { managedListView1.Items.Clear(); managedListView1.Columns.Clear(); for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { ManagedListViewColumn col = new ManagedListViewColumn(); col.HeaderText = col.ID = ds.Tables[0].Columns[i].ToString(); managedListView1.Columns.Add(col); } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { // Reached here means we can add the item ManagedListViewItem item = new ManagedListViewItem(); // Put the id in the tag item.Tag = ds.Tables[0].Rows[i]["Id"].ToString(); // Add subitems depending on columns foreach (ManagedListViewColumn col in managedListView1.Columns) { ManagedListViewSubItem sub = new ManagedListViewSubItem(); sub.ColumnID = col.ID; sub.Text = ds.Tables[0].Rows[i][col.ID].ToString(); item.SubItems.Add(sub); } managedListView1.Items.Add(item); } } } }
private void RefreshEntries() { managedListView1.Items.Clear(); bool checkPath = false; bool fileMustExist = false; // Get the dataset of GAMES table DataSet ds = null; switch (mode) { case DBMode.ALL: { if (!doSort) ds = MyNesDB.GetDataSet("GAMES"); else { ds = MyNesDB.GetDataSet("GAMES", sortColumnName, sortAZ); } break; } case DBMode.DATABASE: { if (!doSort) ds = MyNesDB.GetDataSet("GAMES", "IsDB", true); else ds = MyNesDB.GetDataSet("GAMES", "IsDB", true, sortColumnName, sortAZ); break; } case DBMode.NOTDB: { if (!doSort) ds = MyNesDB.GetDataSet("GAMES", "IsDB", false); else ds = MyNesDB.GetDataSet("GAMES", "IsDB", false, sortColumnName, sortAZ); break; } case DBMode.FILES: { checkPath = true; fileMustExist = true; if (!doSort) ds = MyNesDB.GetDataSet("GAMES"); else { ds = MyNesDB.GetDataSet("GAMES", sortColumnName, sortAZ); } break; } case DBMode.MISSING: { checkPath = true; fileMustExist = false; if (!doSort) ds = MyNesDB.GetDataSet("GAMES"); else { ds = MyNesDB.GetDataSet("GAMES", sortColumnName, sortAZ); } break; } } doSort = false; if (ds == null) return; // Get columns collection MyNesDBColumn[] columns = MyNesDB.GetColumns(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string path = ds.Tables[0].Rows[i]["Path"].ToString().Replace("'", "'"); if (path.StartsWith("(")) { // Decode path = GetFilePathFromArchivePath(path); } if (checkPath) { if (fileMustExist) { if (!File.Exists(path)) continue; } else { if (File.Exists(path)) continue; } } // Quick search ? if (performQuickSearch) { if (quickSearchText.Length > 0) { if (!ds.Tables[0].Rows[i]["Name"].ToString().Replace("'", "'").ToLower(). Contains(quickSearchText.ToLower())) continue; } } else if (performSearch) { if (!FilterGame(ds.Tables[0].Rows[i])) continue; } // Reached here means we can add the item ManagedListViewItem item = new ManagedListViewItem(); // Put the id in the tag item.Tag = ds.Tables[0].Rows[i]["Id"].ToString(); // Add subitems depending on columns foreach (MyNesDBColumn k in columns) { if (k.Name == "Rating") { ManagedListViewRatingSubItem rat = new ManagedListViewRatingSubItem(); rat.ColumnID = k.Name; int val = 0; int.TryParse(ds.Tables[0].Rows[i][k.Name].ToString(), out val); rat.Rating = val; rat.RatingChanged += rat_RatingChanged; item.SubItems.Add(rat); } else if (k.Name == "Played") { ManagedListViewSubItem sub = new ManagedListViewSubItem(); sub.ColumnID = k.Name; string played = ds.Tables[0].Rows[i][k.Name].ToString(); if (played == "0") sub.Text = Program.ResourceManager.GetString("Text_NeverPlayed"); else if (played == "1") sub.Text = Program.ResourceManager.GetString("Text_OneTime"); else sub.Text = played + " " + Program.ResourceManager.GetString("Text_Times"); item.SubItems.Add(sub); } else if (k.Name == "Play Time") { ManagedListViewSubItem sub = new ManagedListViewSubItem(); sub.ColumnID = k.Name; string played = ds.Tables[0].Rows[i][k.Name].ToString(); if (played == "0") sub.Text = Program.ResourceManager.GetString("Text_NeverPlayed"); else { int val = 0; int.TryParse(played, out val); sub.Text = TimeSpan.FromSeconds(val).ToString(); } item.SubItems.Add(sub); } else if (k.Name == "Last Played") { ManagedListViewSubItem sub = new ManagedListViewSubItem(); sub.ColumnID = k.Name; DateTime time = (DateTime)ds.Tables[0].Rows[i][k.Name]; if (time != DateTime.MinValue) sub.Text = time.ToLocalTime().ToString(); else sub.Text = Program.ResourceManager.GetString("Text_NeverPlayed"); item.SubItems.Add(sub); } else if (k.Name == "Size") { ManagedListViewSubItem sub = new ManagedListViewSubItem(); sub.ColumnID = k.Name; int val = 0; int.TryParse(ds.Tables[0].Rows[i]["Size"].ToString(), out val); sub.Text = GetSize(val); item.SubItems.Add(sub); } else { ManagedListViewSubItem sub = new ManagedListViewSubItem(); sub.ColumnID = k.Name; if (k.Name == "Name") { sub.DrawMode = ManagedListViewItemDrawMode.TextAndImage; sub.ImageIndex = File.Exists(path) ? 1 : 0; } sub.Text = ds.Tables[0].Rows[i][k.Name].ToString().Replace("'", "'"); item.SubItems.Add(sub); } } managedListView1.Items.Add(item); } performQuickSearch = false; quickSearchText = ""; performSearch = false; }
/// <summary> /// Scroll view port into item /// </summary> /// <param name="item">The item to scroll into</param> public void ScrollToItem(ManagedListViewItem item) { ScrollToItem(ManagedListViewPanel1.items.IndexOf(item)); }
/// <summary> /// Arguments for subitem draw events. /// </summary> /// <param name="id">The column id which this subitem belongs to.</param> /// <param name="itemIndex">The parent item index.</param> /// <param name="theItem">The item</param> public ManagedListViewSubItemDrawArgs(string id, int itemIndex, ManagedListViewItem theItem) { this.itemIndex = itemIndex; this.id = id; this.theItem = theItem; }