|
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Threading.Tasks; |
4 | 4 | using System.Timers; |
| 5 | +using System.Windows; |
| 6 | +using Hardcodet.Wpf.TaskbarNotification; |
5 | 7 | using MemPlus.Business.LOG; |
6 | 8 | using MemPlus.Views.Windows; |
7 | 9 | using Microsoft.VisualBasic.Devices; |
@@ -190,7 +192,7 @@ internal void EnableMonitor() |
190 | 192 |
|
191 | 193 | _ramTimer.Enabled = true; |
192 | 194 | RamMonitorEnabled = true; |
193 | | - |
| 195 | + |
194 | 196 | UpdateRamUsage(); |
195 | 197 | UpdateGuiControls(); |
196 | 198 |
|
@@ -271,6 +273,8 @@ await Task.Run(async () => |
271 | 273 | RamSavings = oldUsage - newUsage; |
272 | 274 | }); |
273 | 275 |
|
| 276 | + ClearingStatistcs(); |
| 277 | + |
274 | 278 | _logController.AddLog(new ApplicationLog("Done clearing RAM memory")); |
275 | 279 | } |
276 | 280 |
|
@@ -300,6 +304,8 @@ await Task.Run(async () => |
300 | 304 | RamSavings = oldUsage - newUsage; |
301 | 305 | }); |
302 | 306 |
|
| 307 | + ClearingStatistcs(); |
| 308 | + |
303 | 309 | _logController.AddLog(new ApplicationLog("Done clearing process working sets")); |
304 | 310 | } |
305 | 311 |
|
@@ -327,9 +333,45 @@ await Task.Run(() => |
327 | 333 | RamSavings = oldUsage - newUsage; |
328 | 334 | }); |
329 | 335 |
|
| 336 | + ClearingStatistcs(); |
| 337 | + |
330 | 338 | _logController.AddLog(new ApplicationLog("Done clearing FileSystem cache")); |
331 | 339 | } |
332 | 340 |
|
| 341 | + /// <summary> |
| 342 | + /// Display a message about the last RAM Optimizer clearing statistics |
| 343 | + /// </summary> |
| 344 | + private void ClearingStatistcs() |
| 345 | + { |
| 346 | + double ramSavings = RamSavings / 1024 / 1024; |
| 347 | + string message; |
| 348 | + if (ramSavings < 0) |
| 349 | + { |
| 350 | + ramSavings = Math.Abs(ramSavings); |
| 351 | + _logController.AddLog(new RamLog("RAM usage increase: " + ramSavings.ToString("F2") + " MB")); |
| 352 | + message = "Looks like your RAM usage has increased with " + ramSavings.ToString("F2") + " MB!"; |
| 353 | + } |
| 354 | + else |
| 355 | + { |
| 356 | + _logController.AddLog(new RamLog("RAM usage decrease: " + ramSavings.ToString("F2") + " MB")); |
| 357 | + message = "You saved " + ramSavings.ToString("F2") + " MB of RAM!"; |
| 358 | + } |
| 359 | + |
| 360 | + if (ShowStatistics) |
| 361 | + { |
| 362 | + // ReSharper disable once SwitchStatementMissingSomeCases |
| 363 | + switch (_mainWindow.Visibility) |
| 364 | + { |
| 365 | + default: |
| 366 | + MessageBox.Show(message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information); |
| 367 | + break; |
| 368 | + case Visibility.Hidden when _mainWindow.TbiIcon.Visibility == Visibility.Visible: |
| 369 | + _mainWindow.TbiIcon.ShowBalloonTip("MemPlus", message, BalloonIcon.Info); |
| 370 | + break; |
| 371 | + } |
| 372 | + } |
| 373 | + } |
| 374 | + |
333 | 375 | /// <summary> |
334 | 376 | /// Update RAM usage statistics |
335 | 377 | /// </summary> |
|
0 commit comments