commit acf49501a90b621e1bc0d3a1d4501204bed2fd6d
parent 3e2923ec8c64b5d0b40a3197a7d4eaebf9602144
Author: Minerva_juppiter <ryouturn@gmail.com>
Date: Fri, 22 Mar 2024 11:27:40 +0900
メインウィンドウが開いていたら、閉じないようにした。
Diffstat:
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/BusynessNotification.csproj b/BusynessNotification.csproj
@@ -41,7 +41,7 @@
</ItemGroup>
<ItemGroup>
<None Update="SettingJson.json">
- <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
@@ -178,7 +178,7 @@ namespace BusynessNotification
{
double value;
bool NormalizationCan = double.TryParse(input, out value);
- if(NormalizationCan == false || value <= 0 || value >= 100)
+ if(NormalizationCan == false || value < 0 || value > 100)
{
string messageBoxText = "Please enter up to 100";
string caption = "unexpected input";
diff --git a/ObserveUseage.cs b/ObserveUseage.cs
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
@@ -40,6 +41,10 @@ namespace BusynessNotification
Debug.WriteLine("Setting file have readed");
+ Debug.WriteLine("CheckCPU=" + CheckCPU + " CheckMemory=" + CheckMemory + " CheckDisk=" + CheckDisk);
+ Debug.WriteLine("SliderCPU=" + CPUSlider + " SliderMemory=" + MemorySlider + " SliderDisk=" + DiskSlider);
+ Debug.WriteLine("SecCPU=" + SecCPU + " SecMemory=" + SecMemory + " SecDisk=" + SecDisk);
+
///インスタンス
System.Diagnostics.PerformanceCounter cpuCounter = new System.Diagnostics.PerformanceCounter("Processor Information", "% Processor Utility", "_Total");
@@ -122,12 +127,26 @@ namespace BusynessNotification
.AddText("Byssyness Notification")
.AddText("This PC is now available")
.Show();
- Environment.Exit(0);
+
+ int processid;
+ [DllImport("user32.dll")]
+ static extern IntPtr GetForegroundWindow();
+
+ [DllImport("user32.dll", EntryPoint = "GetWindowText", CharSet = CharSet.Auto)]
+ static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
+
+ [DllImport("user32.dll")]
+ static extern uint GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
+
+ GetWindowThreadProcessId(GetForegroundWindow(), out processid);
+ Process p = Process.GetProcessById(processid);
+ if (p.MainModule.FileVersionInfo.ProductName == "BusynessNotification")
+ {
+ Environment.Exit(0);
+ }
}
};
timer = new System.Threading.Timer(timer_delegate,null,1000,1000);
-
-
}
}
}