Exemplo n.º 1
0
        /// <summary>
        /// Adds the specified RomDataCategory to the extended data.
        /// </summary>
        /// <param name="category">Is that spelled right?</param>
        /// <exception cref="ArgumentException">Thrown if a category is added with an invalid or duplicate name.</exception>
        public void AddExDataCategory(RomDataCategory category)
        {
            if (string.IsNullOrEmpty(category.Name))
            {
                throw new ArgumentException("Category name is invalid.");
            }
            if (GetExDataCategory(category.Name) != null)
            {
                throw new ArgumentException("Category name already exists");
            }

            _ExtendedData.Add(category);
        }
Exemplo n.º 2
0
        /// <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);
        }