private void InitTable()
        {
            _adapter = new TableLayoutAdapter <Control>(tableLayoutPanel1, false);

            foreach (var theme in _themes.ThemesList)
            {
                var label = new Label()
                {
                    Text      = theme.Title,
                    BackColor = theme.MainPanelBackgroundColor,
                    ForeColor = theme.SidePanelMainTextColor,
                    Margin    = new Padding(3, 3, 3, 3),
                    Dock      = DockStyle.Fill,
                    Height    = 45
                };

                label.Click += (sender, args) =>
                {
                    _dataProvider.Item.SelectedTheme = label.Text;
                    _dataProvider.Save();

                    FormsContext.Instance.CurrentTheme = ThemeFactory.GetCurrent();
                    SideMenuBuilder.GetInstance().ChangeTheme(FormsContext.Instance.CurrentTheme);

                    FormsContext.Instance.CurrentActiveForm?.Close();
                };

                _adapter.Add(label);
            }
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            _dataProvider = ThemeFactory.ThemesProvider;

            if (!_isEdit)
            {
                if (Instance.Title.Trim().ToLower() == "default")
                {
                    MessageBox.Show("You can't add a theme with a title of default");
                }

                Instance = new ThemeModel()
                {
                    Title = textBox1.Text,
                    SidePanelMainColorStr        = textBox2.Text,
                    SidePanelMainTextColorStr    = textBox3.Text,
                    SidePanelSubMenuColorStr     = textBox4.Text,
                    SidePanelSubMenuTextColorStr = textBox5.Text,
                    MainPanelBackgroundColorStr  = textBox6.Text
                };

                if (_dataProvider.Item == null)
                {
                    _dataProvider.Item = ThemeFactory.NewInstance();
                }

                _dataProvider.Item.ThemesList.Add(Instance);
            }

            else
            {
                var saved = _dataProvider.Item.ThemesList.FirstOrDefault(t => t.Title == EditInstance.Title);

                saved.SidePanelMainColorStr        = textBox2.Text;
                saved.SidePanelMainTextColorStr    = textBox3.Text;
                saved.SidePanelSubMenuColorStr     = textBox4.Text;
                saved.SidePanelSubMenuTextColorStr = textBox5.Text;
                saved.MainPanelBackgroundColorStr  = textBox6.Text;
            }

            _dataProvider.Save();

            Instance     = null;
            EditInstance = null;

            FormsContext.Instance.CurrentTheme = ThemeFactory.GetCurrent();
            SideMenuBuilder.GetInstance().ChangeTheme(FormsContext.Instance.CurrentTheme);
            this.Close();
        }
Exemple #3
0
        private void InitializePanel(Panel panel)
        {
            var modelsFactory = SubMenuItemFactory.Instance;
            var builder       = SideMenuBuilder.GetInstance();

            builder.MenuModels = new List <SubMenuModel>()
            {
                modelsFactory.CreateOpenFormMenuModel("My Notes", (() => new Form1()), panelChildForm),
                modelsFactory.CreateMainMenuModel("Settings", new List <SubMenuModel>()
                {
                    modelsFactory.CreateOpenFormMenuModel("General",
                                                          () => new SettingsForm(),
                                                          panelChildForm),

                    modelsFactory.CreateOpenFormMenuModel("Theme",
                                                          () => new ThemesIndexForm(),
                                                          panelChildForm),

                    modelsFactory.CreateOpenFormMenuModel(
                        "Create new",
                        () => new CreateThemeForm(false),
                        panelChildForm),

                    modelsFactory.CreateOpenFormMenuModel(
                        "Edit",
                        () =>
                    {
                        if (ThemeFactory.GetCurrent().Title.Trim().ToLower() != "default")
                        {
                            return(new CreateThemeForm(true));
                        }
                        MessageBox.Show("You cannot edit the default theme");
                        return(null);
                    },
                        panelChildForm),
                })
            };

            builder.Build(panel, panelChildForm);
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            _previewed = true;
            var instance = new ThemeModel()
            {
                Title = textBox1.Text,
                SidePanelMainColorStr        = textBox2.Text,
                SidePanelMainTextColorStr    = textBox3.Text,
                SidePanelSubMenuColorStr     = textBox4.Text,
                SidePanelSubMenuTextColorStr = textBox5.Text,
                MainPanelBackgroundColorStr  = textBox6.Text
            };

            if (_isEdit)
            {
                EditInstance = instance;
            }
            else
            {
                Instance = instance;
            }

            SideMenuBuilder.GetInstance().ChangeTheme(instance);
        }