private void Dashboard_Load(object sender, EventArgs e) { DonateCategory.Dock = DockStyle.Top; // Show buttons CommonActions.DisableContextMenu(); var openItem = new DashboardItem(Resources.IconRepoOpen, _openRepository.Text); openItem.Click += openItem_Click; CommonActions.AddItem(openItem); var cloneItem = new DashboardItem(Resources.IconCloneRepoGit, _cloneRepository.Text); cloneItem.Click += cloneItem_Click; CommonActions.AddItem(cloneItem); foreach (IRepositoryHostPlugin el in RepoHosts.GitHosters) { IRepositoryHostPlugin gitHoster = el; var di = new DashboardItem(Resources.IconCloneRepoGithub, string.Format(_cloneFork.Text, el.Description)); di.Click += (repoSender, eventArgs) => UICommands.StartCloneForkFromHoster(this, gitHoster, GitModuleChanged); CommonActions.AddItem(di); } var createItem = new DashboardItem(Resources.IconRepoCreate, _createRepository.Text); createItem.Click += createItem_Click; CommonActions.AddItem(createItem); DonateCategory.DisableContextMenu(); var gitHubItem = new DashboardItem(Resources.develop.ToBitmap(), _develop.Text); gitHubItem.Click += GitHubItem_Click; DonateCategory.AddItem(gitHubItem); var donateItem = new DashboardItem(Resources.dollar.ToBitmap(), _donate.Text); donateItem.Click += DonateItem_Click; DonateCategory.AddItem(donateItem); var translateItem = new DashboardItem(Resources.EditItem, _translate.Text); translateItem.Click += TranslateItem_Click; DonateCategory.AddItem(translateItem); var issuesItem = new DashboardItem(Resources.bug, _issues.Text); issuesItem.Click += IssuesItem_Click; DonateCategory.AddItem(issuesItem); // // create Show current branch menu item and add to Dashboard menu // var showCurrentBranchMenuItem = new ToolStripMenuItem(_showCurrentBranch.Text); showCurrentBranchMenuItem.Click += showCurrentBranchMenuItem_Click; showCurrentBranchMenuItem.Checked = AppSettings.DashboardShowCurrentBranch; var menuStrip = FindControl <MenuStrip>(Parent.Parent.Parent, p => true); // TODO: improve: Parent.Parent.Parent == FormBrowse var dashboardMenu = (ToolStripMenuItem)menuStrip.Items.Cast <ToolStripItem>().SingleOrDefault(p => p.Name == "dashboardToolStripMenuItem"); dashboardMenu.DropDownItems.Add(showCurrentBranchMenuItem); }
private void Dashboard_Load(object sender, EventArgs e) { DonateCategory.Dock = DockStyle.Top; //Show buttons CommonActions.DisableContextMenu(); var openItem = new DashboardItem(Resources.IconRepoOpen, openRepository.Text); openItem.Click += openItem_Click; CommonActions.AddItem(openItem); var cloneItem = new DashboardItem(Resources.IconCloneRepoGit, cloneRepository.Text); cloneItem.Click += cloneItem_Click; CommonActions.AddItem(cloneItem); var cloneSvnItem = new DashboardItem(Resources.IconCloneRepoSvn, cloneSvnRepository.Text); cloneSvnItem.Click += cloneSvnItem_Click; CommonActions.AddItem(cloneSvnItem); foreach (IRepositoryHostPlugin el in RepoHosts.GitHosters) { IRepositoryHostPlugin gitHoster = el; var di = new DashboardItem(Resources.IconCloneRepoGithub, string.Format(cloneFork.Text, el.Description)); di.Click += (repoSender, eventArgs) => UICommands.StartCloneForkFromHoster(this, gitHoster, GitModuleChanged); CommonActions.AddItem(di); } var createItem = new DashboardItem(Resources.IconRepoCreate, createRepository.Text); createItem.Click += createItem_Click; CommonActions.AddItem(createItem); DonateCategory.DisableContextMenu(); var GitHubItem = new DashboardItem(Resources.develop.ToBitmap(), develop.Text); GitHubItem.Click += GitHubItem_Click; DonateCategory.AddItem(GitHubItem); var DonateItem = new DashboardItem(Resources.dollar.ToBitmap(), donate.Text); DonateItem.Click += DonateItem_Click; DonateCategory.AddItem(DonateItem); var TranslateItem = new DashboardItem(Resources.EditItem, translate.Text); TranslateItem.Click += TranslateItem_Click; DonateCategory.AddItem(TranslateItem); var IssuesItem = new DashboardItem(Resources.bug, issues.Text); IssuesItem.Click += IssuesItem_Click; DonateCategory.AddItem(IssuesItem); }
public void RefreshContent() { InitDashboardLayout(); ApplyTheme(); userRepositoriesList.ShowRecentRepositories(); void ApplyTheme() { _selectedTheme = ColorHelper.IsLightTheme() ? DashboardTheme.Light : DashboardTheme.Dark; BackgroundImage = _selectedTheme.BackgroundImage; BackColor = _selectedTheme.Primary; pnlLogo.BackColor = _selectedTheme.PrimaryVeryDark; flpnlStart.BackColor = _selectedTheme.PrimaryLight; flpnlContribute.BackColor = _selectedTheme.PrimaryVeryLight; lblContribute.ForeColor = _selectedTheme.SecondaryHeadingText; userRepositoriesList.BranchNameColor = _selectedTheme.SecondaryText; userRepositoriesList.FavouriteColor = _selectedTheme.AccentedText; userRepositoriesList.ForeColor = _selectedTheme.PrimaryText; userRepositoriesList.HeaderColor = _selectedTheme.SecondaryHeadingText; userRepositoriesList.HeaderBackColor = _selectedTheme.PrimaryDark; userRepositoriesList.HoverColor = _selectedTheme.PrimaryLight; userRepositoriesList.MainBackColor = _selectedTheme.Primary; foreach (var item in flpnlContribute.Controls.OfType <LinkLabel>().Union(flpnlStart.Controls.OfType <LinkLabel>())) { item.LinkColor = _selectedTheme.PrimaryText; } Invalidate(true); } void InitDashboardLayout() { try { pnlLeft.SuspendLayout(); AddLinks(flpnlContribute, panel => { panel.Controls.Add(lblContribute); lblContribute.Font = new Font(AppSettings.Font.FontFamily, AppSettings.Font.SizeInPoints + 5.5f); CreateLink(panel, _develop.Text, Images.Develop.AdaptLightness(), GitHubItem_Click); CreateLink(panel, _donate.Text, Images.DollarSign, DonateItem_Click); CreateLink(panel, _translate.Text, Images.Translate.AdaptLightness(), TranslateItem_Click); var lastControl = CreateLink(panel, _issues.Text, Images.Bug, IssuesItem_Click); return(lastControl); }, (panel, lastControl) => { var height = lastControl.Location.Y + lastControl.Size.Height + panel.Padding.Bottom; panel.Height = height; panel.MinimumSize = new Size(0, height); }); AddLinks(flpnlStart, panel => { CreateLink(panel, _createRepository.Text, Images.RepoCreate, createItem_Click); CreateLink(panel, _openRepository.Text, Images.RepoOpen, openItem_Click); var lastControl = CreateLink(panel, _cloneRepository.Text, Images.CloneRepoGit, cloneItem_Click); foreach (var gitHoster in PluginRegistry.GitHosters) { lastControl = CreateLink(panel, string.Format(_cloneFork.Text, gitHoster.Description), Images.CloneRepoGitHub, (repoSender, eventArgs) => UICommands.StartCloneForkFromHoster(this, gitHoster, GitModuleChanged)); } return(lastControl); }, (panel, lastControl) => { var height = lastControl.Location.Y + lastControl.Size.Height + panel.Padding.Bottom; panel.MinimumSize = new Size(0, height); }); } finally { pnlLeft.ResumeLayout(false); pnlLeft.PerformLayout(); AutoScrollMinSize = new Size(0, pnlLogo.Height + flpnlStart.MinimumSize.Height + flpnlContribute.MinimumSize.Height); } void AddLinks(Panel panel, Func <Panel, Control> addLinks, Action <Panel, Control> onLayout) { panel.SuspendLayout(); panel.Controls.Clear(); var lastControl = addLinks(panel); panel.ResumeLayout(false); panel.PerformLayout(); onLayout(panel, lastControl); } Control CreateLink(Control container, string text, Image icon, EventHandler handler) { var padding24 = DpiUtil.Scale(24); var padding3 = DpiUtil.Scale(3); var linkLabel = new LinkLabel { AutoSize = true, AutoEllipsis = true, Font = AppSettings.Font, Image = DpiUtil.Scale(icon), ImageAlign = ContentAlignment.MiddleLeft, LinkBehavior = LinkBehavior.NeverUnderline, Margin = new Padding(padding3, 0, padding3, DpiUtil.Scale(8)), Padding = new Padding(padding24, padding3, padding3, padding3), TabStop = true, Text = text, TextAlign = ContentAlignment.MiddleLeft }; linkLabel.MouseHover += (s, e) => linkLabel.LinkColor = _selectedTheme.AccentedText; linkLabel.MouseLeave += (s, e) => linkLabel.LinkColor = _selectedTheme.PrimaryText; if (handler != null) { linkLabel.Click += handler; } container.Controls.Add(linkLabel); return(linkLabel); } } }