Пример #1
0
        private void AddOptions(TweakPage tweakPage, Control panel)
        {
            var categories = new Dictionary <string, List <object> >();

            foreach (var entry in tweakPage.Entries)
            {
                string categoryName = entry.GetAttribute <CategoryAttribute>()?.Category;

                if (categoryName == null)
                {
                    categoryName = "";
                }

                if (!categories.ContainsKey(categoryName))
                {
                    categories[categoryName] = new List <object>();
                }

                categories[categoryName].Add(entry);
            }

            if (categories.Count == 0)
            {
                //Fallback message for empty page
                panel.Controls.Add(new Label()
                {
                    Text      = "This page contains no tweaks.",
                    ForeColor = SystemColors.GrayText,
                    Dock      = DockStyle.Fill
                });
            }
            else
            {
                foreach (string category in categories.Keys)
                {
                    if (category != "")
                    {
                        panel.Controls.Add(new Label()
                        {
                            Text      = category,
                            Font      = Theme.CategoryFont,
                            AutoSize  = true,
                            Padding   = Constants.Design_Category_Padding,
                            Margin    = new Padding(0),
                            ForeColor = Theme.CategoryForeground
                        });
                    }

                    foreach (TweakEntry entry in categories[category])
                    {
                        if (!entry.Visible)
                        {
                            continue;
                        }

                        this.AddEntry(entry, panel);
                    }
                }
            }
        }
        private void AddSubPages(TweakPage tweakPage, Control panel)
        {
            //Skip if there are no sub-pages
            if (tweakPage.SubPages?.Count == 0)
            {
                return;
            }

            //Header
            panel.Controls.Add(new Label()
            {
                Text      = "Related Tweak Pages",
                Font      = Theme.CategoryFont,
                AutoSize  = true,
                Padding   = Constants.Design_Category_Padding,
                Margin    = new Padding(0),
                ForeColor = Theme.CategoryForeground
            });

            //Links
            foreach (TweakPage subPage in this.TweakPage.SubPages)
            {
                var label = new CommandControl()
                {
                    Text     = subPage.Name,
                    AutoSize = true
                };

                label.Click += (s, e) =>
                {
                    if (this.ParentForm is MainForm form)
                    {
                        form.Select(subPage);
                    }
                };

                panel.Controls.Add(label);
            }
        }
        public TweakPageView(TweakPage tweakPage)
        {
            this.TweakPage = tweakPage;

            this.InitializeComponent();
        }
Пример #4
0
 internal TweakOption(TweakPage tweakPage, FieldInfo fieldInfo) : base(tweakPage, reflectionInfo: fieldInfo)
 {
 }
Пример #5
0
 internal TweakOption(TweakPage tweakPage, PropertyInfo propertyInfo) : base(tweakPage, reflectionInfo: propertyInfo)
 {
 }
Пример #6
0
 internal TweakAction(TweakPage tweakPage, MethodInfo methodInfo) : base(tweakPage, reflectionInfo: methodInfo)
 {
 }