示例#1
0
        public RibbonEditor(PKM pk)
        {
            pkm = pk;
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            riblist = RibbonInfo.GetRibbonInfo(pkm);
            int vertScrollWidth = SystemInformation.VerticalScrollBarWidth;

            TLP_Ribbons.Padding = FLP_Ribbons.Padding = new Padding(0, 0, vertScrollWidth, 0);

            // Updating a Control display with autosized elements on every row addition is cpu intensive. Disable layout updates while populating.
            TLP_Ribbons.SuspendLayout();
            FLP_Ribbons.Scroll += WinFormsUtil.PanelScroll;
            TLP_Ribbons.Scroll += WinFormsUtil.PanelScroll;
            PopulateRibbons();
            TLP_Ribbons.ResumeLayout();

            if (pk is PK8 pk8)
            {
                var names  = Enum.GetNames(typeof(RibbonIndex));
                var values = (RibbonIndex[])Enum.GetValues(typeof(RibbonIndex));
                var items  = names.Select((z, i) => new ComboItem(RibbonStrings.GetName("Ribbon" + z), (int)values[i])).OrderBy(z => z.Text);
                var ds     = new List <ComboItem> {
                    new(GameInfo.GetStrings(Main.CurrentLanguage).Move[0], -1)
                };
                ds.AddRange(items.ToArray());
                CB_Affixed.InitializeBinding();
                CB_Affixed.DataSource    = ds;
                CB_Affixed.SelectedValue = (int)pk8.AffixedRibbon;
            }
            else
            {
                CB_Affixed.Visible = false;
            }
        }
示例#2
0
    private void InitializeAffixed(PKM pk)
    {
        if (pk is not IRibbonSetAffixed affixed)
        {
            CB_Affixed.Visible = false;
            return;
        }

        var ds = new List <ComboItem> {
            new(GameInfo.GetStrings(Main.CurrentLanguage).Move[0], -1)
        };
        var list = Enumerable.Range(0, (int)RibbonIndex.MAX_COUNT)
                   .Select(z => new ComboItem(RibbonStrings.GetName($"Ribbon{(RibbonIndex)z}"), z))
                   .OrderBy(z => z.Text);

        ds.AddRange(list);

        CB_Affixed.InitializeBinding();
        CB_Affixed.DataSource    = ds;
        CB_Affixed.SelectedValue = (int)affixed.AffixedRibbon;
    }