main
1using System.Collections.Generic;
2using momoney.presentation.model.menu.file;
3using MoMoney.Presentation.Model.Projects;
4using MoMoney.Presentation.Winforms.Keyboard;
5using MoMoney.Presentation.Winforms.Resources;
6
7namespace MoMoney.Presentation.Model.Menu.File
8{
9 public interface IFileMenu : ISubMenu
10 {
11 }
12
13 public class FileMenu : SubMenu, IFileMenu
14 {
15 readonly IProjectController project;
16
17 public FileMenu(IProjectController project)
18 {
19 this.project = project;
20 }
21
22 public override string name
23 {
24 get { return "&File"; }
25 }
26
27 public override IEnumerable<IMenuItem> all_menu_items()
28 {
29 yield return Create
30 .a_menu_item()
31 .named("&New")
32 .that_executes<INewCommand>()
33 .represented_by(ApplicationIcons.NewProject)
34 .can_be_accessed_with(ShortcutKeys.control.and(ShortcutKeys.N))
35 .build();
36
37 yield return Create
38 .a_menu_item()
39 .named("&Open")
40 .that_executes<IOpenCommand>()
41 .represented_by(ApplicationIcons.OpenProject)
42 .can_be_accessed_with(ShortcutKeys.control.and(ShortcutKeys.O))
43 .build();
44
45 yield return Create
46 .a_menu_item()
47 .named("&Save")
48 .that_executes<ISaveCommand>()
49 .represented_by(ApplicationIcons.SaveProject)
50 .can_be_clicked_when(() => project.has_unsaved_changes())
51 .can_be_accessed_with(ShortcutKeys.control.and(ShortcutKeys.S))
52 .build();
53
54 yield return Create
55 .a_menu_item()
56 .named("Save &As...")
57 .that_executes<ISaveAsCommand>()
58 .can_be_clicked_when(() => project.has_unsaved_changes())
59 .represented_by(ApplicationIcons.SaveProjectAs)
60 .build();
61
62 yield return Create
63 .a_menu_item()
64 .named("&Close")
65 .can_be_clicked_when(() => project.is_open())
66 .represented_by(ApplicationIcons.CloseProject)
67 .that_executes<ICloseCommand>()
68 .build();
69
70 yield return Create.a_menu_item_separator();
71
72 yield return Create
73 .a_menu_item()
74 .named("E&xit")
75 .that_executes<IExitCommand>()
76 .represented_by(ApplicationIcons.ExitApplication)
77 .build();
78 }
79 }
80}