private void CB_Property_SelectedIndexChanged(object sender, EventArgs e)
 {
     L_PropType.Text  = getPropertyType(CB_Property.Text);
     L_PropValue.Text = pkm.GetType().HasProperty(CB_Property.Text)
         ? ReflectUtil.GetValue(pkm, CB_Property.Text).ToString()
         : "";
 }
Beispiel #2
0
        private void PopulateRegimens(string Type, TableLayoutPanel TLP, List <RegimenInfo> list)
        {
            // Get a list of all Regimen Attregutes in the PKM
            var RegimenNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), Type);

            list.AddRange(from RegimenName in RegimenNames
                          let RegimenValue = ReflectUtil.GetValue(pkm, RegimenName)
                                             where RegimenValue is bool
                                             select new RegimenInfo(RegimenName, (bool)RegimenValue));
            TLP.ColumnCount = 1;
            TLP.RowCount    = 0;

            // Add Regimens
            foreach (var reg in list)
            {
                AddRegimenChoice(reg, TLP);
            }

            // Force auto-size
            foreach (RowStyle style in TLP.RowStyles)
            {
                style.SizeType = SizeType.AutoSize;
            }
            foreach (ColumnStyle style in TLP.ColumnStyles)
            {
                style.SizeType = SizeType.AutoSize;
            }
        }
Beispiel #3
0
        private void LoadSettings(IReadOnlyList <string> blacklist)
        {
            var type  = SettingsObject.GetType();
            var props = ReflectUtil.GetPropertiesCanWritePublicDeclared(type);

            if (ModifierKeys != Keys.Control)
            {
                props = props.Except(blacklist);
            }
            foreach (var p in props)
            {
                var state = ReflectUtil.GetValue(Settings.Default, p);
                switch (state)
                {
                case bool b:
                    var chk = GetCheckBox(p, b);
                    FLP_Settings.Controls.Add(chk);
                    FLP_Settings.SetFlowBreak(chk, true);
                    if (blacklist.Contains(p))
                    {
                        chk.ForeColor = Color.Red;
                    }
                    continue;
                }
            }
        }
Beispiel #4
0
        private static IEnumerable <RegimenInfo> GetBooleanRegimenNames(ISuperTrain pkm, string propertyPrefix)
        {
            var names = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), propertyPrefix);

            foreach (var name in names)
            {
                var value = ReflectUtil.GetValue(pkm, name);
                if (value is bool state)
                {
                    yield return(new RegimenInfo(name, state));
                }
            }
        }
Beispiel #5
0
    public IEnumerable <FlagPairG1Detail> GetFlagPairs()
    {
        var pz = ReflectUtil.GetPropertiesStartWithPrefix(GetType(), FlagPropertyPrefix);

        foreach (var pair in pz)
        {
            if (ReflectUtil.GetValue(this, pair) is not FlagPairG1 p)
            {
                continue;
            }
            yield return(new FlagPairG1Detail(p, pair, EventFlags, SpawnFlags));
        }
    }
Beispiel #6
0
 private void CB_Property_SelectedIndexChanged(object sender, EventArgs e)
 {
     L_PropType.Text = getPropertyType(CB_Property.Text);
     if (pkmref.GetType().HasProperty(CB_Property.Text))
     {
         L_PropValue.Text     = ReflectUtil.GetValue(pkmref, CB_Property.Text).ToString();
         L_PropType.ForeColor = L_PropValue.ForeColor; // reset color
     }
     else // no property, flag
     {
         L_PropValue.Text     = string.Empty;
         L_PropType.ForeColor = Color.Red;
     }
 }
Beispiel #7
0
        private void LoadSettings(IEnumerable <string> blacklist)
        {
            var type  = SettingsObject.GetType();
            var props = ReflectUtil.GetPropertiesCanWritePublicDeclared(type).Except(blacklist);

            foreach (var p in props)
            {
                var state = ReflectUtil.GetValue(Settings.Default, p);
                switch (state)
                {
                case bool b:
                    var chk = GetCheckBox(p, b);
                    FLP_Settings.Controls.Add(chk);
                    FLP_Settings.SetFlowBreak(chk, true);
                    continue;
                }
            }
        }
Beispiel #8
0
        private void LoadSettings(object obj)
        {
            var type  = obj.GetType();
            var props = ReflectUtil.GetPropertiesCanWritePublicDeclared(type);

            foreach (var p in props)
            {
                var state = ReflectUtil.GetValue(obj, p);
                if (state is null)
                {
                    continue;
                }

                var tab = new TabPage(p);
                var pg  = new PropertyGrid {
                    SelectedObject = state, Dock = DockStyle.Fill
                };
                tab.Controls.Add(pg);
                tabControl1.TabPages.Add(tab);
            }
        }
Beispiel #9
0
        private void PopulateRibbons()
        {
            // Get a list of all Ribbon Attributes in the PKM
            var RibbonNames = ReflectUtil.GetPropertiesStartWithPrefix(pkm.GetType(), "Ribbon").Distinct();

            foreach (var RibbonName in RibbonNames)
            {
                object RibbonValue = ReflectUtil.GetValue(pkm, RibbonName);
                if (RibbonValue is int x)
                {
                    riblist.Add(new RibbonInfo(RibbonName, x));
                }
                if (RibbonValue is bool b)
                {
                    riblist.Add(new RibbonInfo(RibbonName, b));
                }
            }
            TLP_Ribbons.ColumnCount = 2;
            TLP_Ribbons.RowCount    = 0;

            // Add Ribbons
            foreach (var rib in riblist)
            {
                AddRibbonSprite(rib);
            }
            foreach (var rib in riblist.OrderBy(z => RibbonStrings.GetName(z.Name)))
            {
                AddRibbonChoice(rib);
            }

            // Force auto-size
            foreach (RowStyle style in TLP_Ribbons.RowStyles)
            {
                style.SizeType = SizeType.AutoSize;
            }
            foreach (ColumnStyle style in TLP_Ribbons.ColumnStyles)
            {
                style.SizeType = SizeType.AutoSize;
            }
        }
Beispiel #10
0
    private static bool GetIncorrectRibbonsEgg(PKM pk, IEncounterTemplate enc)
    {
        var names = ReflectUtil.GetPropertiesStartWithPrefix(pk.GetType(), RibbonInfo.PropertyPrefix);

        if (enc is IRibbonSetEvent3 event3)
        {
            names = names.Except(event3.RibbonNames());
        }
        if (enc is IRibbonSetEvent4 event4)
        {
            names = names.Except(event4.RibbonNames());
        }

        foreach (var value in names.Select(name => ReflectUtil.GetValue(pk, name)))
        {
            if (value is null)
            {
                continue;
            }
            if (HasFlag(value) || HasCount(value))
            {
                return(true);
            }
Beispiel #11
0
        private static IEnumerable <string> DumpStrings(Type t)
        {
            var props = ReflectUtil.GetPropertiesStartWithPrefix(t, string.Empty);

            return(props.Select(p => $"{p}{TranslationSplitter}{ReflectUtil.GetValue(t, p)}"));
        }