commit 63c919d57fd9202da0dccfb66f27d0b1606ffa83
parent 289716ef546f69886939b91c4a1f26033c2a28d8
Author: Minerva_juppiter <ryouturn@gmail.com>
Date: Sat, 16 Mar 2024 16:58:40 +0900
デバイスの監視プログラムの追加
Diffstat:
5 files changed, 101 insertions(+), 8 deletions(-)
diff --git a/.filenesting.json b/.filenesting.json
@@ -1,3 +0,0 @@
-{
- "help":"https://go.microsoft.com/fwlink/?linkid=866610"
-}-
\ No newline at end of file
diff --git a/App.xaml b/App.xaml
@@ -2,8 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.modernwpf.com/2019"
- xmlns:local="clr-namespace:BusynessNotification"
- StartupUri="MainWindow.xaml">
+ xmlns:local="clr-namespace:BusynessNotification">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
diff --git a/App.xaml.cs b/App.xaml.cs
@@ -12,6 +12,7 @@ namespace BusynessNotification
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
+ ///ここにスタートアップ時の処理を記述
}
}
diff --git a/ObserveUseage.cs b/ObserveUseage.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Threading;
+
+namespace BusynessNotification
+{
+ internal class ObserveUseage
+ {
+
+
+ public async void Controller()
+ {
+ ///設定から数値を取得
+ bool CheckCPU = Properties.Settings.Default.CheckCPU;
+ bool CheckMemory = Properties.Settings.Default.CheckMemory;
+ bool CheckDisk = Properties.Settings.Default.CheckDisk;
+
+ double CPUSlider = Properties.Settings.Default.SliderCPU;
+ double MemorySlider = Properties.Settings.Default.SliderMemory;
+ double DiskSlider = Properties.Settings.Default.SliderDisk;
+
+ int SecCPU = Properties.Settings.Default.SecCPU;
+ int SecMemory = Properties.Settings.Default.SecMemory;
+ int SecDisk = Properties.Settings.Default.SecDisk;
+
+ int flagCPU = 0;
+ int flagMemory = 0;
+ int flagDisk = 0;
+
+ ///インスタンス
+ System.Diagnostics.PerformanceCounter cpuCounter = new System.Diagnostics.PerformanceCounter("Processor Information", "% Processor Utility", "_Total");
+
+ PerformanceCounter performanceCounterRAM = new PerformanceCounter();
+ performanceCounterRAM.CounterName = "% Committed Bytes In Use";
+ performanceCounterRAM.CategoryName = "Memory";
+
+ PerformanceCounter Disc1 = new PerformanceCounter();
+ Disc1.CategoryName = "LogicalDisk";
+ Disc1.CounterName = "Disk Transfers/sec";
+ Disc1.InstanceName = "C:";
+
+ Timer timer = null;
+
+ TimerCallback timer_delegate = async state =>
+ {
+ if (CheckCPU)
+ {
+ await Task.Run(() =>
+ {
+ if (cpuCounter.NextValue() >= CPUSlider)
+ {
+ flagCPU++;
+ }
+ });
+ }
+ if (CheckMemory)
+ {
+ await Task.Run(() =>
+ {
+ if (performanceCounterRAM.NextValue() >= MemorySlider)
+ {
+ flagMemory++;
+ }
+ });
+ }
+ if (CheckDisk)
+ {
+ await Task.Run(() =>
+ {
+ if (Disc1.NextValue() >= DiskSlider)
+ {
+ flagDisk++;
+ }
+ });
+ }
+
+
+ if(flagCPU >= CPUSlider && flagMemory >= MemorySlider && flagDisk >= DiskSlider)
+ {
+ timer.Dispose();
+ }
+ };
+ timer = new Timer(timer_delegate,null,1000,1000);
+
+
+ }
+ }
+}
diff --git a/README.md b/README.md
@@ -9,8 +9,10 @@ to ModernWpfUI
SystemCPUuseage
SystemMemoryUseage
from Windows.System.Diagnostics
+https://windev.just4fun.biz/?.NET/CPU%E4%BD%BF%E7%94%A8%E7%8E%87%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B
and Disk activeTime
+https://codezine.jp/article/detail/3238?p=4
e[}̓[U[windows̃e[}IɓK܂B
@@ -18,4 +20,8 @@ and Disk activeTime
https://qiita.com/TiggeZaki/items/aa17edbef0cc5f4736d9
ݒt@Ĉ͂
-https://learn.microsoft.com/ja-jp/dotnet/desktop/winforms/advanced/how-to-write-user-settings-at-run-time-with-csharp?view=netframeworkdesktop-4.8-
\ No newline at end of file
+https://learn.microsoft.com/ja-jp/dotnet/desktop/winforms/advanced/how-to-write-user-settings-at-run-time-with-csharp?view=netframeworkdesktop-4.8
+
+timer.thread.timer
+https://atmarkit.itmedia.co.jp/ait/articles/0511/11/news118.html
+