main
1using System;
2using System.ComponentModel;
3using System.Windows.Forms;
4using momoney.presentation.views;
5using MoMoney.Presentation.Winforms.Helpers;
6using MoMoney.Presentation.Winforms.Resources;
7
8namespace MoMoney.Presentation.Winforms.Views
9{
10 public partial class ApplicationWindow : Form, IApplicationWindow
11 {
12 public ApplicationWindow()
13 {
14 InitializeComponent();
15 Icon = ApplicationIcons.Application;
16 //this.log().debug("created {0}", GetType());
17
18 activated = x => { };
19 deactivated = x => { };
20 closed = x => { };
21 closing = x => { };
22 }
23
24 public ControlAction<EventArgs> activated { get; set; }
25 public ControlAction<EventArgs> deactivated { get; set; }
26 public ControlAction<EventArgs> closed { get; set; }
27 public ControlAction<CancelEventArgs> closing { get; set; }
28
29 public IApplicationWindow create_tool_tip_for(string title, string caption, Control control)
30 {
31 var tip = new ToolTip {IsBalloon = true, ToolTipTitle = title};
32 tip.SetToolTip(control, caption);
33 control.Controls.Add(new ControlAdapter(tip));
34 return this;
35 }
36
37 public IApplicationWindow try_to_reduce_flickering()
38 {
39 base.DoubleBuffered = true;
40 SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
41 return this;
42 }
43
44 public IApplicationWindow top_most()
45 {
46 TopMost = true;
47 Focus();
48 BringToFront();
49 return this;
50 }
51
52 public IApplicationWindow titled(string title)
53 {
54 base.Text = "MoMoney (BETA) - " + title;
55 return this;
56 }
57
58 protected override void OnActivated(EventArgs e)
59 {
60 base.OnActivated(e);
61 activated(e);
62 }
63
64 protected override void OnDeactivate(EventArgs e)
65 {
66 base.OnDeactivate(e);
67 deactivated(e);
68 }
69
70 protected override void OnClosing(CancelEventArgs e)
71 {
72 base.OnClosing(e);
73 closing(e);
74 }
75
76 protected override void OnClosed(EventArgs e)
77 {
78 base.OnClosed(e);
79 closed(e);
80 }
81 }
82}