Exemplo n.º 1
0
        public ApparelFilterMaterials(TabApparel tab)
        {
            InitializeComponent();

            DialogResult = DialogResult.Cancel;

            checkBox1.Checked = TabApparel.ShowDefStuff;
            // get materials list
            {
                var stuffs = tab.GetCachedList()
                             .Where(x => !String.IsNullOrEmpty(x.Material))
                             .Select(x => x.Material)
                             .OrderBy(x => x)
                             .Distinct();

                checkedListBox1.DataSource = stuffs.ToList();
                for (int i = 0; i < checkedListBox1.Items.Count; i++)
                {
                    string stuffName = (string)checkedListBox1.Items[i];
                    if (!TabApparel.StuffActiveState.TryGetValue(stuffName, out bool state))
                    {
                        TabApparel.StuffActiveState[stuffName] = state = true;
                    }
                    checkedListBox1.SetItemChecked(i, state);
                }
            }
        }
Exemplo n.º 2
0
        public ApparelFilterForm(TabApparel tab)
        {
            InitializeComponent();
            this.tab = tab;

            comboBox2.DataSource = typeof(Apparel).GetProperties().Where(x => x.PropertyType == typeof(float?)).Select(x =>
            {
                var localized = (LocalizedDisplayNameAttribute)x
                                .GetCustomAttributes(true)
                                .Where(a => a is LocalizedDisplayNameAttribute)
                                .FirstOrDefault();

                return(new ComboBoxColumn
                {
                    Name = x.Name,
                    DisplayName = localized?.DisplayName
                });
            }).ToList();

            string langName     = File.Exists("Language") ? File.ReadAllText("Language") : "English";
            string langFileName = $"Languages\\{langName}.xml";

            if (!Localization.TryLoadFromFile(langFileName, out Exception ex))
            {
                MessageBox.Show($"Error: {ex.Message}", langFileName);
                Environment.Exit(1);
            }

            comboBox1.Items.Add("Combo1_Item_WithRecipe".Translate());
            comboBox1.Items.Add("Combo1_Item_All".Translate());

            comboBox3.Items.Add("Combo2_Item_SortByDescending".Translate());
            comboBox3.Items.Add("Combo2_Item_SortByAscending".Translate());

            label2.Text = "Label_HasRecipe".Translate();
            label3.Text = "Label_FilterByParam".Translate();
            label4.Text = "Label_SortOrder".Translate();
            label1.Text = "Label_Depth".Translate();

            button1.Text = "Button_ApplyFilter".Translate();

            Localization.Finalize();

            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 0;
            comboBox3.SelectedIndex = 0;

            // get materials list
            {
                var stuffs = tab.GetCachedList()
                             .Where(x => !String.IsNullOrEmpty(x.Material))
                             .Select(x => x.Material)
                             .OrderBy(x => x)
                             .Distinct();

                checkedListBox1.DataSource = stuffs.ToList();
                for (int i = 0; i < checkedListBox1.Items.Count; i++)
                {
                    string stuffName = (string)checkedListBox1.Items[i];
                    if (!TabApparel.StuffActiveState.TryGetValue(stuffName, out bool state))
                    {
                        TabApparel.StuffActiveState[stuffName] = state = true;
                    }
                    checkedListBox1.SetItemChecked(i, state);
                }
            }
        }