Skip to content

Commit 261cc69

Browse files
committed
* Added notifications when window is invisible and ram was cleared
1 parent 006cc5f commit 261cc69

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

MemPlus/Views/Windows/MainWindow.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
mc:Ignorable="d"
1010
UseLayoutRounding="True"
1111
TitleTextAlignment="Center"
12-
Title="MemPlus" Height="300" Width="500" WindowStartupLocation="CenterScreen" Icon="/Resources/Images/ram.png"
13-
Closing="MainWindow_OnClosing">
12+
Title="MemPlus" Height="300" Width="500" WindowStartupLocation="CenterScreen" Icon="/Resources/Images/ram.png">
1413
<Grid>
1514
<Grid.RowDefinitions>
1615
<RowDefinition Height="Auto" />

MemPlus/Views/Windows/MainWindow.xaml.cs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System;
2-
using System.ComponentModel;
32
using System.Reflection;
43
using System.Windows;
54
using System.Windows.Input;
65
using System.Windows.Media;
6+
using Hardcodet.Wpf.TaskbarNotification;
77
using MemPlus.Business.Classes.EXPORT;
88
using MemPlus.Business.Classes.GUI;
99
using MemPlus.Business.Classes.LOG;
@@ -621,16 +621,6 @@ private void ExportRamAnalyzerDataMenuItem_OnClick(object sender, RoutedEventArg
621621
}
622622
}
623623

624-
/// <summary>
625-
/// Method that is called when the MainWindow is closing
626-
/// </summary>
627-
/// <param name="sender">The object that called this method</param>
628-
/// <param name="e">The CancelEventArgs</param>
629-
private void MainWindow_OnClosing(object sender, CancelEventArgs e)
630-
{
631-
TbiIcon.Visibility = Visibility.Hidden;
632-
}
633-
634624
/// <summary>
635625
/// Method that is called when all logs should be exported
636626
/// </summary>
@@ -710,21 +700,28 @@ private async void ClearMemory(int index)
710700
}
711701

712702
double ramSavings = _ramController.RamSavings / 1024 / 1024;
703+
string message;
713704
if (ramSavings < 0)
714705
{
715706
ramSavings = Math.Abs(ramSavings);
716707
_logController.AddLog(new RamLog("RAM usage increase: " + ramSavings.ToString("F2") + " MB"));
717-
if (_statisticsMessage)
718-
{
719-
MessageBox.Show("Looks like your RAM usage has increased with " + ramSavings.ToString("F2") + " MB!", "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information);
720-
}
708+
message = "Looks like your RAM usage has increased with " + ramSavings.ToString("F2") + " MB!";
721709
}
722710
else
723711
{
724712
_logController.AddLog(new RamLog("RAM usage decrease: " + ramSavings.ToString("F2") + " MB"));
725-
if (_statisticsMessage)
713+
message = "You saved " + ramSavings.ToString("F2") + " MB of RAM!";
714+
}
715+
716+
if (_statisticsMessage)
717+
{
718+
if (Visibility == Visibility.Visible)
719+
{
720+
MessageBox.Show(message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information);
721+
}
722+
else if (Visibility == Visibility.Hidden && TbiIcon.Visibility == Visibility.Visible)
726723
{
727-
MessageBox.Show("You saved " + ramSavings.ToString("F2") + " MB of RAM!", "MemPlus", MessageBoxButton.OK, MessageBoxImage.Information);
724+
TbiIcon.ShowBalloonTip("MemPlus", message, BalloonIcon.Info);
728725
}
729726
}
730727

0 commit comments

Comments
 (0)