Toasts – Diff between revs 4 and 7
?pathlinks?
Rev 4 | Rev 7 | |||
---|---|---|---|---|
Line 35... | Line 35... | |||
35 | |
35 | |
|
Line 36... | Line 36... | |||
36 | #endregion |
36 | #endregion |
|
Line -... | Line 37... | |||
- | 37 | |
||
- | 38 | #region Constructors, Destructors and Finalizers |
||
- | 39 | |
||
- | 40 | private ToastForm() |
||
- | 41 | { |
||
37 | |
42 | InitializeComponent(); |
|
38 | #region Constructors, Destructors and Finalizers |
43 | } |
|
39 | |
44 | |
|
40 | /// <summary> |
45 | /// <summary> |
|
41 | /// </summary> |
46 | /// </summary> |
|
42 | /// <param name="title"></param> |
47 | /// <param name="title"></param> |
|
43 | /// <param name="body"></param> |
48 | /// <param name="body"></param> |
|
44 | /// <param name="duration"></param> |
49 | /// <param name="duration"></param> |
|
45 | /// <param name="image"></param> |
50 | /// <param name="image"></param> |
|
46 | /// <param name="animation"></param> |
51 | /// <param name="animation"></param> |
|
47 | /// <param name="direction"></param> |
52 | /// <param name="direction"></param> |
|
48 | public ToastForm(string title, string body, int duration, Image logo, Image background, |
- | ||
49 | FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) |
- | ||
50 | { |
53 | public ToastForm(string title, string body, int duration, Image logo, Image background, |
|
51 | InitializeComponent(); |
54 | FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) : this() |
|
52 | |
55 | { |
|
53 | lifeTimer.Interval = duration; |
56 | lifeTimer.Interval = duration; |
|
54 | labelTitle.Text = title; |
57 | labelTitle.Text = title; |
|
Line 60... | Line 63... | |||
60 | |
63 | |
|
61 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
64 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
|
Line 62... | Line 65... | |||
62 | } |
65 | } |
|
63 | |
66 | |
|
64 | public ToastForm(string title, string body, int duration, Image logo, |
67 | public ToastForm(string title, string body, int duration, Image logo, |
|
65 | FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) |
- | ||
66 | { |
- | ||
67 | InitializeComponent(); |
68 | FormAnimator.AnimationMethod animation, FormAnimator.AnimationDirection direction) : this() |
|
68 | |
69 | { |
|
69 | lifeTimer.Interval = duration; |
70 | lifeTimer.Interval = duration; |
|
70 | labelTitle.Text = title; |
71 | labelTitle.Text = title; |
|
Line 71... | Line 72... | |||
71 | labelBody.Text = body; |
72 | labelBody.Text = body; |
|
Line 72... | Line 73... | |||
72 | imageBox.Image = logo; |
73 | imageBox.Image = logo; |
|
73 | |
74 | |
|
Line 74... | Line 75... | |||
74 | _animator = new FormAnimator(this, animation, direction, 500); |
75 | _animator = new FormAnimator(this, animation, direction, 500); |
|
75 | |
76 | |
|
76 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
- | ||
77 | } |
- | ||
78 | |
77 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
|
79 | public ToastForm(string title, string body, int duration, Image logo) |
78 | } |
|
80 | { |
79 | |
|
81 | InitializeComponent(); |
80 | public ToastForm(string title, string body, int duration, Image logo) : this() |
|
Line 89... | Line 88... | |||
89 | 500); |
88 | 500); |
|
Line 90... | Line 89... | |||
90 | |
89 | |
|
91 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
90 | Region = Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, Width - 5, Height - 5, 20, 20)); |
|
Line -... | Line 91... | |||
- | 91 | } |
||
- | 92 | |
||
- | 93 | /// <summary> |
||
- | 94 | /// Clean up any resources being used. |
||
- | 95 | /// </summary> |
||
- | 96 | /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |
||
- | 97 | protected override void Dispose(bool disposing) |
||
- | 98 | { |
||
- | 99 | if (disposing && (components != null)) |
||
- | 100 | { |
||
- | 101 | components.Dispose(); |
||
- | 102 | } |
||
- | 103 | base.Dispose(disposing); |
||
92 | } |
104 | } |
|
Line 93... | Line 105... | |||
93 | |
105 | |
|
Line 94... | Line 106... | |||
94 | #endregion |
106 | #endregion |
|
Line 116... | Line 128... | |||
116 | { |
128 | { |
|
117 | if (openForm.InvokeRequired) |
129 | if (openForm.InvokeRequired) |
|
118 | { |
130 | { |
|
119 | Action action = delegate { openForm.Top -= Height; }; |
131 | Action action = delegate { openForm.Top -= Height; }; |
|
120 | openForm.Invoke(action); |
132 | openForm.Invoke(action); |
|
- | 133 | |
||
121 | return; |
134 | continue; |
|
122 | } |
135 | } |
|
Line 123... | Line 136... | |||
123 | |
136 | |
|
124 | openForm.Top -= Height; |
137 | openForm.Top -= Height; |
|
Line 130... | Line 143... | |||
130 | |
143 | |
|
131 | private void Notification_Activated(object sender, EventArgs e) |
144 | private void Notification_Activated(object sender, EventArgs e) |
|
132 | { |
145 | { |
|
133 | // Prevent the form taking focus when it is initially shown |
146 | // Prevent the form taking focus when it is initially shown |
|
- | 147 | if (!_allowFocus) |
||
134 | if (!_allowFocus) |
148 | { |
|
135 | // Activate the window that previously had focus |
149 | // Activate the window that previously had focus |
|
- | 150 | NativeMethods.SetForegroundWindow(_currentForegroundWindow); |
||
136 | NativeMethods.SetForegroundWindow(_currentForegroundWindow); |
151 | } |
|
Line 137... | Line 152... | |||
137 | } |
152 | } |
|
138 | |
153 | |
|
139 | private void Notification_Shown(object sender, EventArgs e) |
154 | private void Notification_Shown(object sender, EventArgs e) |
|
Line 153... | Line 168... | |||
153 | { |
168 | { |
|
154 | if (openForm == this) |
169 | if (openForm == this) |
|
155 | // Remaining forms are below this one |
170 | // Remaining forms are below this one |
|
156 | break; |
171 | break; |
|
Line -... | Line 172... | |||
- | 172 | |
||
- | 173 | if (openForm.InvokeRequired) |
||
- | 174 | { |
||
157 | |
175 | Action action = delegate { openForm.Top += Height; }; |
|
- | 176 | openForm.Invoke(action); |
||
- | 177 | |
||
- | 178 | continue; |
||
158 | openForm.Top += Height; |
179 | } |
|
Line 159... | Line 180... | |||
159 | } |
180 | } |
|
160 | |
181 | |