main
1using System.Collections.Generic;
2using System.Windows.Forms;
3using gorilla.commons.utility;
4using MoMoney.Presentation.Core;
5using MoMoney.Presentation.Model.Menu;
6using momoney.presentation.model.menu.file;
7using MoMoney.Presentation.Model.Projects;
8using momoney.presentation.views;
9using MoMoney.Presentation.Winforms.Resources;
10
11namespace momoney.presentation.presenters
12{
13 public interface IToolbarPresenter : IPresenter
14 {
15 }
16
17 public class ToolBarPresenter : IToolbarPresenter
18 {
19 readonly IRegionManager shell;
20 readonly IProjectController project;
21
22 public ToolBarPresenter(IRegionManager shell, IProjectController project)
23 {
24 this.shell = shell;
25 this.project = project;
26 }
27
28 public void run()
29 {
30 shell.region<ToolStrip>(x => buttons().each(y => y.add_to(x)));
31 }
32
33 IEnumerable<IToolbarButton> buttons()
34 {
35 yield return Create
36 .a_tool_bar_item()
37 .with_tool_tip_text_as("New")
38 .when_clicked_executes<INewCommand>()
39 .displays_icon(ApplicationIcons.NewProject)
40 .button();
41 yield return Create
42 .a_tool_bar_item()
43 .with_tool_tip_text_as("Open")
44 .when_clicked_executes<IOpenCommand>()
45 .displays_icon(ApplicationIcons.OpenProject)
46 .button();
47 yield return Create
48 .a_tool_bar_item()
49 .with_tool_tip_text_as("Save")
50 .when_clicked_executes<ISaveCommand>()
51 .can_be_clicked_when(() => project.has_unsaved_changes())
52 .displays_icon(ApplicationIcons.SaveProject)
53 .button();
54 }
55 }
56}