/// <summary> /// Makes the specified view visible /// </summary> /// <param name="index">Index of the view</param> /// <param name="focus">Specify true to bring input focus to the view</param> public void ShowList(int index, bool focus) { if (index != _ActiveList.Index) { //_ActiveList.ListView.Hide(); //_ActiveList = entries[index]; //_ActiveList.ListView.Visible = true; Host.SelectedTab = entries[index].TabPage; _ActiveList = entries[index]; if (focus) { _ActiveList.ListView.Focus(); } } }
/// <summary> /// Removes all views from UI /// </summary> internal void ClearLists() { _ActiveList = null; for (int i = 0; i < entries.Count; i++) { ViewEventArgs eventArgs = new ViewEventArgs(entries[i].ListView); ViewRemoving.Raise(this, eventArgs); Host.TabPages.Remove(entries[i].TabPage); entries[i].TabPage.Dispose(); ViewRemoved.Raise(this, eventArgs); } entries.Clear(); }
/// <summary> /// Adds a view with the specified data /// </summary> /// <param name="columns">Header names</param> /// <param name="values">Data values</param> /// <returns>Index of the added list</returns> public int AddList(IList <string> columns, RomDataCategory values) { if (Host == null) { throw new InvalidOperationException("ListManager must be hosted before adding lists"); } TabPage newpage = new TabPage(); newpage.Text = values.Name; ListView newView = new ListView(); newView.View = View.Details; newView.FullRowSelect = true; newView.Dock = DockStyle.Fill; newView.Resize += delegate(object o, EventArgs e) { if (newView.Columns.Count > 0) { newView.Columns[newView.Columns.Count - 1].Width = -2; } }; for (int i = 0; i < columns.Count; i++) { var header = new ColumnHeader() { Text = columns[i], Width = 150 }; newView.Columns.Add(header); } for (int i = 0; i < values.Count; i++) { var item = values[i]; ListViewItem lvItem = new ListViewItem(); lvItem.Text = item.Name; //for (int iSubItem = 1; iSubItem < item.Count; iSubItem++) { // lvItem.SubItems.Add(item[i]); // } lvItem.SubItems.Add(item.Value); if (IsImportantItem(values.Name, item.Name)) { lvItem.Font = new System.Drawing.Font(lvItem.Font, System.Drawing.FontStyle.Bold); } newView.Items.Add(lvItem); } var newList = new DisplayList(this, newView, newpage); entries.Add(newList); if (_ActiveList != null) { //_ActiveList.ListView.Visible = false; } _ActiveList = newList; newpage.Controls.Add(newView); _Host.Controls.Add(newpage); newView.BringToFront(); ViewAdded.Raise(this, new ViewEventArgs(newView)); return(entries.Count - 1); }