コード例 #1
0
        public override void Init()
        {
            dataGridViewSynthesis.MakeDoubleBuffered();
            dataGridViewSynthesis.DefaultCellStyle.WrapMode = DataGridViewTriState.False;
            dataGridViewSynthesis.RowTemplate.Height        = 26;

            Order = SQLiteDBClass.GetSettingString(DbOSave, "").RestoreArrayFromString(0, Recipes.SynthesisRecipes.Count);
            if (Order.Distinct().Count() != Order.Length)       // if not distinct..
            {
                for (int i = 0; i < Order.Length; i++)          // reset
                {
                    Order[i] = i;
                }
            }

            Wanted = SQLiteDBClass.GetSettingString(DbWSave, "").RestoreArrayFromString(0, Recipes.SynthesisRecipes.Count);

            var rcpes = Recipes.SynthesisRecipes.Select(r => r.name).Distinct().ToList();

            rcpes.Sort();
            rfs          = new RecipeFilterSelector(rcpes);
            rfs.Changed += FilterChanged;

            var lvls = Recipes.SynthesisRecipes.Select(r => r.level).Distinct().ToList();

            lvls.Sort();
            lfs          = new RecipeFilterSelector(lvls);
            lfs.Changed += FilterChanged;

            List <string> matShortNames = Recipes.SynthesisRecipes.SelectMany(r => r.ingredients).Distinct().ToList();

            matLookUp = matShortNames.Select(sn => Tuple.Create <string, string>(sn, MaterialCommodityData.GetCachedMaterialByShortName(sn).name)).ToList();

            List <string> matLongNames = matLookUp.Select(lu => lu.Item2).ToList();

            matLongNames.Sort();

            mfs          = new RecipeFilterSelector(matLongNames);
            mfs.Changed += FilterChanged;

            for (int i = 0; i < Recipes.SynthesisRecipes.Count; i++)         // pre-fill array.. preventing the crash on cell edit when you
            {
                int rno = Order[i];
                Recipes.SynthesisRecipe r = Recipes.SynthesisRecipes[rno];

                int rown = dataGridViewSynthesis.Rows.Add();

                using (DataGridViewRow row = dataGridViewSynthesis.Rows[rown])
                {
                    row.Cells[0].Value       = r.name; // debug rno + ":" + r.name;
                    row.Cells[1].Value       = r.level;
                    row.Cells[6].Value       = r.ingredientsstring;
                    row.Cells[6].ToolTipText = r.ingredientsstringlong;
                    row.Tag     = rno;
                    row.Visible = false;
                }
            }

            isHistoric = SQLiteDBClass.GetSettingBool(DbHistoricMatsSave, false);

            discoveryform.OnNewEntry += Discoveryform_OnNewEntry;
        }