Exemple #1
0
        public BlockLimitConfig(Dictionary <string, short> limits)
        {
            InitializeComponent();

            BlockLimits = limits;

            var blockTypeResources = new System.ComponentModel.ComponentResourceManager(typeof(BlockTypeList));

            blockTypeNames = blockTypeResources.GetString("textBox1.Text").Split(',').ToList();

            if (MyDefinitionManager.Static != null)
            {
                foreach (var def in MyDefinitionManager.Static.GetAllDefinitions())
                {
                    var cubeDef = def as MyCubeBlockDefinition;
                    if (cubeDef == null)
                    {
                        continue;
                    }
                    if (!cubeDef.Public)
                    {
                        continue;
                    }
                    string name = cubeDef.BlockPairName;
                    if (!blockTypeNames.Contains(name))
                    {
                        blockTypeNames.Add(name);
                    }
                }
            }
            blockTypeNames.Sort();
            TP_Block_Limits.RowStyles.Clear();
            bool first = true;

            foreach (var entry in BlockLimits.OrderBy(e => e.Key))
            {
                if (first)
                {
                    first = false;
                    TP_Block_Limits.RowCount = 1;
                    var fp = CreateRow(entry.Key, entry.Value);
                    TP_Block_Limits.Controls.Add(fp);
                    TP_Block_Limits.SetRow(fp, 0);
                    continue;
                }
                AddRow(CreateRow(entry.Key, entry.Value));
            }
        }
Exemple #2
0
 private void AddRow(FlowLayoutPanel fp)
 {
     TP_Block_Limits.RowCount++;
     TP_Block_Limits.Controls.Add(fp);
     TP_Block_Limits.SetRow(fp, TP_Block_Limits.RowCount - 1);
 }