示例#1
0
        private void CustomGroupings_Load(object sender, EventArgs e)
        {
            Text = Translations.TranslationGet("STR_CUSTGROUPINGS", "DE", "Custom Groupings");
            HTML_GROUPNAME.Text = Translations.TranslationGet("HTML_GROUPNAME", "DE", "Group Name");
            BTN_SAVE.Text       = Translations.TranslationGet("BTN_SAVE", "DE", "Save");
            BTN_CLOSE.Text      = Translations.TranslationGet("BTN_CLOSE", "DE", "Close");

            FormHelpers.ResizeLables(this.Controls);

            txtGroupName.Left = HTML_GROUPNAME.Left + HTML_GROUPNAME.Width + 5;
            if (this.ClientRectangle.Width - (HTML_GROUPNAME.Left + HTML_GROUPNAME.Width + 10) < txtGroupName.Width)
            {
                txtGroupName.Width = this.ClientRectangle.Width - (HTML_GROUPNAME.Left + HTML_GROUPNAME.Width + 10);
            }

            imageList1.ColorDepth = ColorDepth.Depth32Bit;
            imageList1.ImageSize  = new Size(50, 24);

            foreach (KeyValuePair <int, string> country in _cDescription)
            {
                tankListView.Groups.Add(new ListViewGroup(country.Key.ToString(), country.Value)
                {
                    HeaderAlignment = HorizontalAlignment.Center
                });
            }


            foreach (KeyValuePair <TankKey, TankValue> tank in _tDescription.OrderBy(x => x.Value.Tier).ThenBy(y => y.Value.TankType).Where(z => z.Value.Active == true))
            {
                ListViewItem newListViewItem = new ListViewItem(tank.Value.Description, 0, tankListView.Groups[tank.Key.CountryID.ToString()]);
                newListViewItem.Name = tank.Key.CountryID + "_" + tank.Key.TankID;
                ListViewItem.ListViewSubItem subItem1 = new ListViewItem.ListViewSubItem(newListViewItem, _typeDescription.Description(tank.Value.TankType));
                ListViewItem.ListViewSubItem subItem2 = new ListViewItem.ListViewSubItem(newListViewItem, tank.Value.Tier.ToString());
                newListViewItem.SubItems.Add(subItem1);
                newListViewItem.SubItems.Add(subItem2);

                try
                {
                    if (!imageList1.Images.ContainsKey(String.Format("{0}_{1}", tank.Key.CountryID, tank.Key.TankID)))
                    {
                        imageList1.Images.Add(String.Format("{0}_{1}", tank.Key.CountryID, tank.Key.TankID), Image.FromFile(String.Format(@"{0}", WOTHelper.GetImagePath(tank.Key.CountryID + "_" + tank.Key.TankID + "_Large.png"))));
                    }

                    newListViewItem.ImageKey = String.Format("{0}_{1}", tank.Key.CountryID, tank.Key.TankID);
                }
                catch { }
                tankListView.Items.Add(newListViewItem);
            }


            if (_ID != "")
            {
                List <string> list = _customGrouping.Values(_ID).Split('|').ToList <string>();

                foreach (string item in list)
                {
                    if (tankListView.Items[item] != null)
                    {
                        tankListView.Items[item].Checked = true;
                    }
                }
            }


            tankListView.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            tankListView.Columns[1].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
            tankListView.Columns[2].AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
        }