From 7f166744cc7ed0ddae7cb116faa2901cc296f5f4 Mon Sep 17 00:00:00 2001 From: Florian Baader Date: Sun, 21 Feb 2016 15:37:56 +0100 Subject: [PATCH] Updated Source Code to v4.3 +Added sound detection (audio peak measurement) +Added Option to cancel shutdown while sound is playing +Added debug window to show detailed information +Implemented Log System +Fixed some bugs +Code improvements and code commenting +Improved exception handling --- SourceCode/AssemblyInfo.cpp | 38 ++ SourceCode/BasicFunc.cpp | 79 ++- SourceCode/BasicFunc.h | 24 +- SourceCode/DebugForm.cpp | 136 ++++ SourceCode/DebugForm.h | 962 ++++++++++++++++++++++++++++ SourceCode/DebugForm.resx | 126 ++++ SourceCode/InputMonitor.cpp | 4 +- SourceCode/InputMonitor.h | 3 +- SourceCode/MessageWindow.cpp | 4 +- SourceCode/MetroSettingsForm.cpp | 79 ++- SourceCode/MetroSettingsForm.h | 774 ++++++++++++---------- SourceCode/ProcessItem.cpp | 5 +- SourceCode/ProcessSelectionForm.cpp | 8 +- SourceCode/ProcessSelectionForm.h | 2 +- SourceCode/Setting.h | 5 +- SourceCode/SettingsProvider.cpp | 46 +- SourceCode/SettingsProvider.h | 7 +- SourceCode/SmartLogout.rc | Bin 0 -> 5356 bytes SourceCode/SystemAccess.h | 24 +- SourceCode/SystemMetricWatcher.cpp | 8 +- SourceCode/SystemMetricWatcher.h | 2 +- SourceCode/Systemaccess.cpp | 82 ++- SourceCode/TimeoutWindow.cpp | 6 +- SourceCode/TimeoutWindow.h | 2 +- SourceCode/setting.cpp | 2 +- SourceCode/standbye_main.cpp | 98 ++- SourceCode/standbye_main.h | 13 +- SourceCode/stdafx.h | 5 +- 28 files changed, 2042 insertions(+), 502 deletions(-) create mode 100644 SourceCode/AssemblyInfo.cpp create mode 100644 SourceCode/DebugForm.cpp create mode 100644 SourceCode/DebugForm.h create mode 100644 SourceCode/DebugForm.resx create mode 100644 SourceCode/SmartLogout.rc diff --git a/SourceCode/AssemblyInfo.cpp b/SourceCode/AssemblyInfo.cpp new file mode 100644 index 0000000..4e64070 --- /dev/null +++ b/SourceCode/AssemblyInfo.cpp @@ -0,0 +1,38 @@ +#include "stdafx.h" + +using namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitleAttribute(L"Stand-Bye!")]; +[assembly:AssemblyDescriptionAttribute(L"An enhancement of the windows standby")]; +[assembly:AssemblyConfigurationAttribute(L"")]; +[assembly:AssemblyCompanyAttribute(L"Florian Baader, Stephan Le, Matthias Weirich")]; +[assembly:AssemblyProductAttribute(L"Stand-Bye!")]; +[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2016 Florian Baader, Stephan Le, Matthias Weirich")]; +[assembly:AssemblyTrademarkAttribute(L"")]; +[assembly:AssemblyCultureAttribute(L"")]; + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersionAttribute("0.4.0")]; + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; \ No newline at end of file diff --git a/SourceCode/BasicFunc.cpp b/SourceCode/BasicFunc.cpp index 8a6377a..4d7abfc 100644 --- a/SourceCode/BasicFunc.cpp +++ b/SourceCode/BasicFunc.cpp @@ -25,22 +25,85 @@ int BasicFunc::StringToInt(std::string str) { return result; } -void BasicFunc::Print(std::string str) { - //OutputDebugString(_T(str.c_str())); - //DEBUG(str); -} - -System::Drawing::Font^ BasicFunc::getMetroFont(int size) { +System::Drawing::Font^ BasicFunc::getMetroFont(float size) { return gcnew System::Drawing::Font(L"Microsoft Sans Serif", size); } -boolean BasicFunc::VectorContains(std::vector list, std::string text) +bool BasicFunc::VectorContains(std::vector list, std::string text) { - boolean result = false; + bool result = false; for each(std::string s in list) { if (s == text) { result = true; } } return result; +} + +System::String ^ BasicFunc::getLogFilePath() +{ + using namespace System::IO; + using namespace System::Diagnostics; + + //Startup Time + DateTime^ starttime = Process::GetCurrentProcess()->StartTime; + + //Path + String^ mainFolder = System::IO::Directory::GetCurrentDirectory(); + String^ log_folder = Path::Combine(mainFolder, "logs"); + String^ current_date_folder = Path::Combine(log_folder, starttime->ToString("yyyy_MM_dd")); + String^ file_path = Path::Combine(current_date_folder, starttime->ToString("HH_mm") + ".txt"); + + //Creates Directory if necessary + System::IO::Directory::CreateDirectory(current_date_folder); + + return file_path; +} + +void BasicFunc::Log(System::String^ text) +{ + //Prints message on Debug-Console + System::Diagnostics::Debug::WriteLine(text); + + using namespace System::IO; + using namespace System::Diagnostics; + + //Line + String^ line = DateTime::Now.ToString("HH:mm:ss:FFF") + "\t" + text; + + //Open Stream + StreamWriter^ sw; + try { + sw = File::AppendText(BasicFunc::getLogFilePath()); + } + catch (System::Exception^) { + //Could not find / open the file + return; + } + + //Appends Text + try { + sw->WriteLine(line); + } + finally + { + if (sw) + delete (IDisposable^)sw; + } +} + +bool BasicFunc::isNumerique(std::string text) +{ + char* p; + strtol(text.c_str(), &p, 10); + return *p == 0; +} +bool BasicFunc::isNumerique(System::String ^ text) +{ + return isNumerique(BasicFunc::StringToString(text)); +} + +void BasicFunc::Log(std::string text) +{ + Log(gcnew String(text.c_str())); } \ No newline at end of file diff --git a/SourceCode/BasicFunc.h b/SourceCode/BasicFunc.h index 5973328..03bcf83 100644 --- a/SourceCode/BasicFunc.h +++ b/SourceCode/BasicFunc.h @@ -2,12 +2,12 @@ #include #include //Converting System::String to std::string #include -using namespace System; using std::vector; using std::string; namespace BasicFunc { + using namespace System; ///Converts a System::String to a std::string string StringToString(System::String^ str); @@ -17,10 +17,24 @@ namespace BasicFunc { ///Converts a std::string to an int int StringToInt(string str); - ///Prints an std::string - void Print(string str); + ///Returns an metro font with specified size in points + System::Drawing::Font^ getMetroFont(float size); - System::Drawing::Font^ getMetroFont(int size); + ///Returns if an vector of std::string contains a specified std::string + bool VectorContains(std::vector list, std::string text); - boolean VectorContains(std::vector list, std::string text); + ///Returns the log file path and ensures that the file is accessible + System::String^ getLogFilePath(); + + ///Logs an specified statement or event. + void Log(std::string text); + + ///Logs an specified statement or event. + void Log(System::String^ text); + + ///Checks if string only contains numerique characters + bool isNumerique(std::string text); + + ///Checks if string only contains numerique characters + bool isNumerique(System::String^ text); } diff --git a/SourceCode/DebugForm.cpp b/SourceCode/DebugForm.cpp new file mode 100644 index 0000000..87b31e3 --- /dev/null +++ b/SourceCode/DebugForm.cpp @@ -0,0 +1,136 @@ +#include "stdafx.h" +#include "DebugForm.h" +using namespace StandBye; + +System::Void StandBye::DebugForm::DebugForm_Load(System::Object ^, System::EventArgs ^) +{ + RefreshUISlow(); +} + +System::Void StandBye::DebugForm::buttonSettingsForm_Click(System::Object ^, System::EventArgs ^) +{ + MetroSettingsForm^ form = gcnew MetroSettingsForm(system_watcher, settings_prov); + form->ShowDialog(); +} + +System::Void StandBye::DebugForm::buttonProcessForm_Click(System::Object ^, System::EventArgs ^) +{ + ProcessSelectionForm^ form = gcnew ProcessSelectionForm(); + form->ShowDialog(); +} + +System::Void StandBye::DebugForm::buttonMessageWnd_Click(System::Object ^, System::EventArgs ^) +{ + MessageWindow^ wnd = gcnew MessageWindow("This is a test"); + wnd->ShowDialog(); +} + +System::Void StandBye::DebugForm::buttonTimeWnd_Click(System::Object ^, System::EventArgs ^) +{ + TimeoutWindow^ wnd = gcnew TimeoutWindow(15, settings_prov); + wnd->ShowDialog(); +} + +System::String ^ StandBye::DebugForm::getLogText() +{ + using namespace System; + using namespace System::IO; + + String^ return_string = ""; + StreamReader^ sr; + + try { + sr = gcnew StreamReader(BasicFunc::getLogFilePath()); + while (sr->Peek() >= 0) { + return_string += sr->ReadLine() + "\n"; + } + } + catch (System::IO::IOException^) { + //File is opened from an other process + return ""; + } + finally{ + delete sr; + } + + return return_string; + +} + +void DebugForm::OnTick(System::Object ^, System::EventArgs ^) +{ + RefreshUIRealTime(); +} + +void DebugForm::RefreshUISlow() +{ + //ListView Settings + for each(Setting* setting in settings_prov->getAllSettings()) { + String^ name = gcnew String(setting->GetNameAsString().c_str()); + string std_value; + + //Adds all values to an single String^ + for each(string single_value in setting->GetValue()) { + std_value += single_value; + } + String^ value = gcnew String(std_value.c_str()); + + listViewSettings->Items->Add(name)->SubItems->Add(value); + } + + //ListView Processes + //Prepare ListView + listViewProc->View = Windows::Forms::View::Details; + ImageList^ imglistSmall = gcnew ImageList, ^imglistLarge = gcnew ImageList; + imglistSmall->ImageSize = Drawing::Size(24, 24); + imglistLarge->ImageSize = Drawing::Size(50, 50); + listViewProc->SmallImageList = imglistSmall; + listViewProc->LargeImageList = imglistLarge; + + for each(std::string path in SystemAccess::GetRunningProccesses()) { + listViewProc->Items->Add(gcnew ProcessItem(path, listViewProc)); + } +} + +void StandBye::DebugForm::RefreshUIRealTime() +{ + //Buffered Values + labelBuffCPU->Text = String::Format("{0:00.0} %", system_watcher->GetSystemMetric(SystemAccess::SystemMetric::CPU)); + labelBuffRAM->Text = String::Format("{0:00.0} %", system_watcher->GetSystemMetric(SystemAccess::SystemMetric::RAM)); + labelBuffHDD->Text = String::Format("{0:00.0} kBit/s", system_watcher->GetSystemMetric(SystemAccess::SystemMetric::HDD)); + labelBuffNET->Text = String::Format("{0:00.0} kBit/s", system_watcher->GetSystemMetric(SystemAccess::SystemMetric::NETWORK)); + + //Real-Time Values + labelRTCPU->Text = String::Format("{0:00.0} %", system_access->GetMetric(SystemAccess::SystemMetric::CPU)); + labelRTRAM->Text = String::Format("{0:00.0} %", system_access->GetMetric(SystemAccess::SystemMetric::RAM)); + labelRTHDD->Text = String::Format("{0:00.0} kBit/s", system_access->GetMetric(SystemAccess::SystemMetric::HDD)); + labelRTNET->Text = String::Format("{0:00.0} kBit/s", system_access->GetMetric(SystemAccess::SystemMetric::NETWORK)); + + //Input Info + int lastinput = (int)system_access->GetLastInputTime(); + labelInputTime->Text = String::Format("{0} ms", lastinput); + + if ((lastinput / 1000) > settings_prov->getThreshold(SettingName::WAIT_TIME)) { + labelWAITReached->Text = "YES"; + } + else { + labelWAITReached->Text = "NO"; + } + + //Sound input + labelSoundPeak->Text = String::Format("{0:0.00}", system_access->getAudioPeak()); + + if (system_access->getAudioPeak() > 0) { + labelSoundOverLimit->Text = "YES"; + } + else { + labelSoundOverLimit->Text = "NO"; + } + + //Log + if ((textBoxLog->Text != getLogText()) && getLogText() != "") { + textBoxLog->Text = getLogText(); + textBoxLog->SelectionStart = textBoxLog->TextLength - 1; + textBoxLog->ScrollToCaret(); + } +} \ No newline at end of file diff --git a/SourceCode/DebugForm.h b/SourceCode/DebugForm.h new file mode 100644 index 0000000..944f631 --- /dev/null +++ b/SourceCode/DebugForm.h @@ -0,0 +1,962 @@ +#pragma once +#include "standbye_main.h" + +namespace StandBye { + using namespace System; + using namespace System::ComponentModel; + using namespace System::Collections; + using namespace System::Windows::Forms; + using namespace System::Data; + using namespace System::Drawing; + + /// + /// Form to present debug information + /// + public ref class DebugForm : public System::Windows::Forms::Form + { + //attributes + SystemMetricWatcher^ system_watcher; + InputMonitor^ input_monitor; + SettingsProvider* settings_prov; + mainApplication^ parent; + private: System::Windows::Forms::RichTextBox^ textBoxLog; + private: System::Windows::Forms::GroupBox^ groupBox7; + SystemAccess^ system_access; + + public: + DebugForm(mainApplication^ sender, SettingsProvider* set_prov, InputMonitor^ mon, SystemMetricWatcher^ watcher) + { + parent = sender; + settings_prov = set_prov; + input_monitor = mon; + system_watcher = watcher; + system_access = gcnew SystemAccess(settings_prov); + + //Initialize Components + InitializeComponent(); + + //Starts Timer + timerRefresh->Tick += gcnew System::EventHandler(this, &StandBye::DebugForm::OnTick); + timerRefresh->Start(); + } + + protected: + /// + /// Clean up any resources being used. + /// + ~DebugForm() + { + if (components) + { + delete components; + } + } + + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel6; + private: System::Windows::Forms::GroupBox^ groupBox8; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel7; + private: System::Windows::Forms::Label^ labelSoundOverLimit; + private: System::Windows::Forms::Label^ labelSoundPeak; + private: System::Windows::Forms::Label^ label11; + private: System::Windows::Forms::Label^ label12; + private: System::Windows::Forms::Label^ label13; + private: System::ComponentModel::IContainer^ components; + private: System::Windows::Forms::Button^ buttonMessageWnd; + private: System::Windows::Forms::Button^ buttonProcessForm; + private: System::Windows::Forms::Button^ buttonSettingsForm; + private: System::Windows::Forms::Button^ buttonTimeWnd; + private: System::Windows::Forms::ColumnHeader^ columnHeader1; + private: System::Windows::Forms::ColumnHeader^ columnHeader2; + private: System::Windows::Forms::ColumnHeader^ columnHeader3; + private: System::Windows::Forms::ColumnHeader^ columnHeader4; + private: System::Windows::Forms::GroupBox^ groupBox1; + private: System::Windows::Forms::GroupBox^ groupBox2; + private: System::Windows::Forms::GroupBox^ groupBox3; + private: System::Windows::Forms::GroupBox^ groupBox4; + private: System::Windows::Forms::GroupBox^ groupBox5; + private: System::Windows::Forms::GroupBox^ groupBox6; + + private: System::Windows::Forms::Label^ label14; + private: System::Windows::Forms::Label^ label15; + private: System::Windows::Forms::Label^ label16; + private: System::Windows::Forms::Label^ label17; + private: System::Windows::Forms::Label^ label18; + private: System::Windows::Forms::Label^ label1; + private: System::Windows::Forms::Label^ label2; + private: System::Windows::Forms::Label^ label3; + private: System::Windows::Forms::Label^ label4; + private: System::Windows::Forms::Label^ label5; + private: System::Windows::Forms::Label^ label6; + private: System::Windows::Forms::Label^ label7; + private: System::Windows::Forms::Label^ label8; + private: System::Windows::Forms::Label^ labelBuffCPU; + private: System::Windows::Forms::Label^ labelBuffHDD; + private: System::Windows::Forms::Label^ labelBuffNET; + private: System::Windows::Forms::Label^ labelBuffRAM; + private: System::Windows::Forms::Label^ labelInputTime; + private: System::Windows::Forms::Label^ labelRTCPU; + private: System::Windows::Forms::Label^ labelRTHDD; + private: System::Windows::Forms::Label^ labelRTNET; + private: System::Windows::Forms::Label^ labelRTRAM; + private: System::Windows::Forms::Label^ labelWAITReached; + private: System::Windows::Forms::ListView^ listViewProc; + private: System::Windows::Forms::ListView^ listViewSettings; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel1; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel2; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel3; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel4; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel5; + private: System::Windows::Forms::Timer^ timerRefresh; + + protected: + + private: + /// + /// Required designer variable. + /// + +#pragma region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + void InitializeComponent(void) + { + this->components = (gcnew System::ComponentModel::Container()); + this->tableLayoutPanel1 = (gcnew System::Windows::Forms::TableLayoutPanel()); + this->groupBox3 = (gcnew System::Windows::Forms::GroupBox()); + this->tableLayoutPanel3 = (gcnew System::Windows::Forms::TableLayoutPanel()); + this->labelRTNET = (gcnew System::Windows::Forms::Label()); + this->labelRTHDD = (gcnew System::Windows::Forms::Label()); + this->labelRTRAM = (gcnew System::Windows::Forms::Label()); + this->labelRTCPU = (gcnew System::Windows::Forms::Label()); + this->label14 = (gcnew System::Windows::Forms::Label()); + this->label15 = (gcnew System::Windows::Forms::Label()); + this->label16 = (gcnew System::Windows::Forms::Label()); + this->label17 = (gcnew System::Windows::Forms::Label()); + this->label18 = (gcnew System::Windows::Forms::Label()); + this->groupBox2 = (gcnew System::Windows::Forms::GroupBox()); + this->tableLayoutPanel2 = (gcnew System::Windows::Forms::TableLayoutPanel()); + this->labelBuffNET = (gcnew System::Windows::Forms::Label()); + this->labelBuffHDD = (gcnew System::Windows::Forms::Label()); + this->labelBuffRAM = (gcnew System::Windows::Forms::Label()); + this->labelBuffCPU = (gcnew System::Windows::Forms::Label()); + this->label5 = (gcnew System::Windows::Forms::Label()); + this->label1 = (gcnew System::Windows::Forms::Label()); + this->label2 = (gcnew System::Windows::Forms::Label()); + this->label3 = (gcnew System::Windows::Forms::Label()); + this->label4 = (gcnew System::Windows::Forms::Label()); + this->groupBox1 = (gcnew System::Windows::Forms::GroupBox()); + this->listViewSettings = (gcnew System::Windows::Forms::ListView()); + this->columnHeader1 = (gcnew System::Windows::Forms::ColumnHeader()); + this->columnHeader2 = (gcnew System::Windows::Forms::ColumnHeader()); + this->groupBox5 = (gcnew System::Windows::Forms::GroupBox()); + this->listViewProc = (gcnew System::Windows::Forms::ListView()); + this->columnHeader3 = (gcnew System::Windows::Forms::ColumnHeader()); + this->columnHeader4 = (gcnew System::Windows::Forms::ColumnHeader()); + this->tableLayoutPanel6 = (gcnew System::Windows::Forms::TableLayoutPanel()); + this->groupBox8 = (gcnew System::Windows::Forms::GroupBox()); + this->tableLayoutPanel7 = (gcnew System::Windows::Forms::TableLayoutPanel()); + this->labelSoundOverLimit = (gcnew System::Windows::Forms::Label()); + this->labelSoundPeak = (gcnew System::Windows::Forms::Label()); + this->label11 = (gcnew System::Windows::Forms::Label()); + this->label12 = (gcnew System::Windows::Forms::Label()); + this->label13 = (gcnew System::Windows::Forms::Label()); + this->groupBox4 = (gcnew System::Windows::Forms::GroupBox()); + this->tableLayoutPanel5 = (gcnew System::Windows::Forms::TableLayoutPanel()); + this->labelWAITReached = (gcnew System::Windows::Forms::Label()); + this->labelInputTime = (gcnew System::Windows::Forms::Label()); + this->label7 = (gcnew System::Windows::Forms::Label()); + this->label6 = (gcnew System::Windows::Forms::Label()); + this->label8 = (gcnew System::Windows::Forms::Label()); + this->groupBox6 = (gcnew System::Windows::Forms::GroupBox()); + this->tableLayoutPanel4 = (gcnew System::Windows::Forms::TableLayoutPanel()); + this->buttonTimeWnd = (gcnew System::Windows::Forms::Button()); + this->buttonMessageWnd = (gcnew System::Windows::Forms::Button()); + this->buttonProcessForm = (gcnew System::Windows::Forms::Button()); + this->buttonSettingsForm = (gcnew System::Windows::Forms::Button()); + this->textBoxLog = (gcnew System::Windows::Forms::RichTextBox()); + this->timerRefresh = (gcnew System::Windows::Forms::Timer(this->components)); + this->groupBox7 = (gcnew System::Windows::Forms::GroupBox()); + this->tableLayoutPanel1->SuspendLayout(); + this->groupBox3->SuspendLayout(); + this->tableLayoutPanel3->SuspendLayout(); + this->groupBox2->SuspendLayout(); + this->tableLayoutPanel2->SuspendLayout(); + this->groupBox1->SuspendLayout(); + this->groupBox5->SuspendLayout(); + this->tableLayoutPanel6->SuspendLayout(); + this->groupBox8->SuspendLayout(); + this->tableLayoutPanel7->SuspendLayout(); + this->groupBox4->SuspendLayout(); + this->tableLayoutPanel5->SuspendLayout(); + this->groupBox6->SuspendLayout(); + this->tableLayoutPanel4->SuspendLayout(); + this->groupBox7->SuspendLayout(); + this->SuspendLayout(); + // + // tableLayoutPanel1 + // + this->tableLayoutPanel1->ColumnCount = 5; + this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 20))); + this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 20))); + this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 20))); + this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 20))); + this->tableLayoutPanel1->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 20))); + this->tableLayoutPanel1->Controls->Add(this->groupBox3, 2, 0); + this->tableLayoutPanel1->Controls->Add(this->groupBox2, 1, 0); + this->tableLayoutPanel1->Controls->Add(this->groupBox1, 0, 0); + this->tableLayoutPanel1->Controls->Add(this->tableLayoutPanel6, 3, 0); + this->tableLayoutPanel1->Controls->Add(this->groupBox6, 4, 0); + this->tableLayoutPanel1->Controls->Add(this->groupBox5, 1, 1); + this->tableLayoutPanel1->Controls->Add(this->groupBox7, 3, 1); + this->tableLayoutPanel1->Dock = System::Windows::Forms::DockStyle::Fill; + this->tableLayoutPanel1->Location = System::Drawing::Point(0, 0); + this->tableLayoutPanel1->Name = L"tableLayoutPanel1"; + this->tableLayoutPanel1->RowCount = 2; + this->tableLayoutPanel1->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 37.5F))); + this->tableLayoutPanel1->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 62.5F))); + this->tableLayoutPanel1->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute, 20))); + this->tableLayoutPanel1->Size = System::Drawing::Size(998, 432); + this->tableLayoutPanel1->TabIndex = 0; + // + // groupBox3 + // + this->groupBox3->Controls->Add(this->tableLayoutPanel3); + this->groupBox3->Dock = System::Windows::Forms::DockStyle::Fill; + this->groupBox3->Location = System::Drawing::Point(401, 3); + this->groupBox3->Name = L"groupBox3"; + this->groupBox3->Size = System::Drawing::Size(193, 156); + this->groupBox3->TabIndex = 2; + this->groupBox3->TabStop = false; + this->groupBox3->Text = L"Real-Time Usage"; + // + // tableLayoutPanel3 + // + this->tableLayoutPanel3->CellBorderStyle = System::Windows::Forms::TableLayoutPanelCellBorderStyle::Single; + this->tableLayoutPanel3->ColumnCount = 2; + this->tableLayoutPanel3->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 50))); + this->tableLayoutPanel3->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 50))); + this->tableLayoutPanel3->Controls->Add(this->labelRTNET, 1, 4); + this->tableLayoutPanel3->Controls->Add(this->labelRTHDD, 1, 3); + this->tableLayoutPanel3->Controls->Add(this->labelRTRAM, 1, 2); + this->tableLayoutPanel3->Controls->Add(this->labelRTCPU, 1, 1); + this->tableLayoutPanel3->Controls->Add(this->label14, 0, 4); + this->tableLayoutPanel3->Controls->Add(this->label15, 0, 0); + this->tableLayoutPanel3->Controls->Add(this->label16, 0, 1); + this->tableLayoutPanel3->Controls->Add(this->label17, 0, 2); + this->tableLayoutPanel3->Controls->Add(this->label18, 0, 3); + this->tableLayoutPanel3->Dock = System::Windows::Forms::DockStyle::Fill; + this->tableLayoutPanel3->Location = System::Drawing::Point(3, 16); + this->tableLayoutPanel3->Name = L"tableLayoutPanel3"; + this->tableLayoutPanel3->RowCount = 5; + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel3->Size = System::Drawing::Size(187, 137); + this->tableLayoutPanel3->TabIndex = 1; + // + // labelRTNET + // + this->labelRTNET->AutoSize = true; + this->labelRTNET->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelRTNET->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->labelRTNET->Location = System::Drawing::Point(97, 109); + this->labelRTNET->Name = L"labelRTNET"; + this->labelRTNET->Size = System::Drawing::Size(86, 27); + this->labelRTNET->TabIndex = 8; + this->labelRTNET->Text = L"0.0"; + this->labelRTNET->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + // + // labelRTHDD + // + this->labelRTHDD->AutoSize = true; + this->labelRTHDD->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelRTHDD->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->labelRTHDD->Location = System::Drawing::Point(97, 82); + this->labelRTHDD->Name = L"labelRTHDD"; + this->labelRTHDD->Size = System::Drawing::Size(86, 26); + this->labelRTHDD->TabIndex = 7; + this->labelRTHDD->Text = L"0.0"; + this->labelRTHDD->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + // + // labelRTRAM + // + this->labelRTRAM->AutoSize = true; + this->labelRTRAM->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelRTRAM->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->labelRTRAM->Location = System::Drawing::Point(97, 55); + this->labelRTRAM->Name = L"labelRTRAM"; + this->labelRTRAM->Size = System::Drawing::Size(86, 26); + this->labelRTRAM->TabIndex = 6; + this->labelRTRAM->Text = L"0.0"; + this->labelRTRAM->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + // + // labelRTCPU + // + this->labelRTCPU->AutoSize = true; + this->labelRTCPU->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelRTCPU->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->labelRTCPU->Location = System::Drawing::Point(97, 28); + this->labelRTCPU->Name = L"labelRTCPU"; + this->labelRTCPU->Size = System::Drawing::Size(86, 26); + this->labelRTCPU->TabIndex = 5; + this->labelRTCPU->Text = L"0.0"; + this->labelRTCPU->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + // + // label14 + // + this->label14->AutoSize = true; + this->label14->Dock = System::Windows::Forms::DockStyle::Fill; + this->label14->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->label14->Location = System::Drawing::Point(4, 109); + this->label14->Name = L"label14"; + this->label14->Size = System::Drawing::Size(86, 27); + this->label14->TabIndex = 4; + this->label14->Text = L"NET"; + this->label14->TextAlign = System::Drawing::ContentAlignment::MiddleRight; + // + // label15 + // + this->label15->AutoSize = true; + this->tableLayoutPanel3->SetColumnSpan(this->label15, 2); + this->label15->Dock = System::Windows::Forms::DockStyle::Fill; + this->label15->Location = System::Drawing::Point(4, 1); + this->label15->Name = L"label15"; + this->label15->Size = System::Drawing::Size(179, 26); + this->label15->TabIndex = 0; + this->label15->Text = L"Real Time Usage got by Performance Counters"; + this->label15->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // label16 + // + this->label16->AutoSize = true; + this->label16->Dock = System::Windows::Forms::DockStyle::Fill; + this->label16->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->label16->Location = System::Drawing::Point(4, 28); + this->label16->Name = L"label16"; + this->label16->Size = System::Drawing::Size(86, 26); + this->label16->TabIndex = 1; + this->label16->Text = L"CPU"; + this->label16->TextAlign = System::Drawing::ContentAlignment::MiddleRight; + // + // label17 + // + this->label17->AutoSize = true; + this->label17->Dock = System::Windows::Forms::DockStyle::Fill; + this->label17->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->label17->Location = System::Drawing::Point(4, 55); + this->label17->Name = L"label17"; + this->label17->Size = System::Drawing::Size(86, 26); + this->label17->TabIndex = 2; + this->label17->Text = L"RAM"; + this->label17->TextAlign = System::Drawing::ContentAlignment::MiddleRight; + // + // label18 + // + this->label18->AutoSize = true; + this->label18->Dock = System::Windows::Forms::DockStyle::Fill; + this->label18->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->label18->Location = System::Drawing::Point(4, 82); + this->label18->Name = L"label18"; + this->label18->Size = System::Drawing::Size(86, 26); + this->label18->TabIndex = 3; + this->label18->Text = L"HDD"; + this->label18->TextAlign = System::Drawing::ContentAlignment::MiddleRight; + // + // groupBox2 + // + this->groupBox2->Controls->Add(this->tableLayoutPanel2); + this->groupBox2->Dock = System::Windows::Forms::DockStyle::Fill; + this->groupBox2->Location = System::Drawing::Point(202, 3); + this->groupBox2->Name = L"groupBox2"; + this->groupBox2->Size = System::Drawing::Size(193, 156); + this->groupBox2->TabIndex = 1; + this->groupBox2->TabStop = false; + this->groupBox2->Text = L"Buffered Usage"; + // + // tableLayoutPanel2 + // + this->tableLayoutPanel2->CellBorderStyle = System::Windows::Forms::TableLayoutPanelCellBorderStyle::Single; + this->tableLayoutPanel2->ColumnCount = 2; + this->tableLayoutPanel2->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 50))); + this->tableLayoutPanel2->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 50))); + this->tableLayoutPanel2->Controls->Add(this->labelBuffNET, 1, 4); + this->tableLayoutPanel2->Controls->Add(this->labelBuffHDD, 1, 3); + this->tableLayoutPanel2->Controls->Add(this->labelBuffRAM, 1, 2); + this->tableLayoutPanel2->Controls->Add(this->labelBuffCPU, 1, 1); + this->tableLayoutPanel2->Controls->Add(this->label5, 0, 4); + this->tableLayoutPanel2->Controls->Add(this->label1, 0, 0); + this->tableLayoutPanel2->Controls->Add(this->label2, 0, 1); + this->tableLayoutPanel2->Controls->Add(this->label3, 0, 2); + this->tableLayoutPanel2->Controls->Add(this->label4, 0, 3); + this->tableLayoutPanel2->Dock = System::Windows::Forms::DockStyle::Fill; + this->tableLayoutPanel2->Location = System::Drawing::Point(3, 16); + this->tableLayoutPanel2->Name = L"tableLayoutPanel2"; + this->tableLayoutPanel2->RowCount = 5; + this->tableLayoutPanel2->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel2->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel2->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel2->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel2->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 20))); + this->tableLayoutPanel2->Size = System::Drawing::Size(187, 137); + this->tableLayoutPanel2->TabIndex = 0; + // + // labelBuffNET + // + this->labelBuffNET->AutoSize = true; + this->labelBuffNET->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelBuffNET->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->labelBuffNET->Location = System::Drawing::Point(97, 109); + this->labelBuffNET->Name = L"labelBuffNET"; + this->labelBuffNET->Size = System::Drawing::Size(86, 27); + this->labelBuffNET->TabIndex = 8; + this->labelBuffNET->Text = L"0.0"; + this->labelBuffNET->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + // + // labelBuffHDD + // + this->labelBuffHDD->AutoSize = true; + this->labelBuffHDD->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelBuffHDD->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->labelBuffHDD->Location = System::Drawing::Point(97, 82); + this->labelBuffHDD->Name = L"labelBuffHDD"; + this->labelBuffHDD->Size = System::Drawing::Size(86, 26); + this->labelBuffHDD->TabIndex = 7; + this->labelBuffHDD->Text = L"0.0"; + this->labelBuffHDD->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + // + // labelBuffRAM + // + this->labelBuffRAM->AutoSize = true; + this->labelBuffRAM->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelBuffRAM->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->labelBuffRAM->Location = System::Drawing::Point(97, 55); + this->labelBuffRAM->Name = L"labelBuffRAM"; + this->labelBuffRAM->Size = System::Drawing::Size(86, 26); + this->labelBuffRAM->TabIndex = 6; + this->labelBuffRAM->Text = L"0.0"; + this->labelBuffRAM->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + // + // labelBuffCPU + // + this->labelBuffCPU->AutoSize = true; + this->labelBuffCPU->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelBuffCPU->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->labelBuffCPU->Location = System::Drawing::Point(97, 28); + this->labelBuffCPU->Name = L"labelBuffCPU"; + this->labelBuffCPU->Size = System::Drawing::Size(86, 26); + this->labelBuffCPU->TabIndex = 5; + this->labelBuffCPU->Text = L"0.0"; + this->labelBuffCPU->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + // + // label5 + // + this->label5->AutoSize = true; + this->label5->Dock = System::Windows::Forms::DockStyle::Fill; + this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->label5->Location = System::Drawing::Point(4, 109); + this->label5->Name = L"label5"; + this->label5->Size = System::Drawing::Size(86, 27); + this->label5->TabIndex = 4; + this->label5->Text = L"NET"; + this->label5->TextAlign = System::Drawing::ContentAlignment::MiddleRight; + // + // label1 + // + this->label1->AutoSize = true; + this->tableLayoutPanel2->SetColumnSpan(this->label1, 2); + this->label1->Dock = System::Windows::Forms::DockStyle::Fill; + this->label1->Location = System::Drawing::Point(4, 1); + this->label1->Name = L"label1"; + this->label1->Size = System::Drawing::Size(179, 26); + this->label1->TabIndex = 0; + this->label1->Text = L"The values are sampled 2 / sec and stored over 30 seconds"; + this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // label2 + // + this->label2->AutoSize = true; + this->label2->Dock = System::Windows::Forms::DockStyle::Fill; + this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->label2->Location = System::Drawing::Point(4, 28); + this->label2->Name = L"label2"; + this->label2->Size = System::Drawing::Size(86, 26); + this->label2->TabIndex = 1; + this->label2->Text = L"CPU"; + this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleRight; + // + // label3 + // + this->label3->AutoSize = true; + this->label3->Dock = System::Windows::Forms::DockStyle::Fill; + this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->label3->Location = System::Drawing::Point(4, 55); + this->label3->Name = L"label3"; + this->label3->Size = System::Drawing::Size(86, 26); + this->label3->TabIndex = 2; + this->label3->Text = L"RAM"; + this->label3->TextAlign = System::Drawing::ContentAlignment::MiddleRight; + // + // label4 + // + this->label4->AutoSize = true; + this->label4->Dock = System::Windows::Forms::DockStyle::Fill; + this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, + static_cast(0))); + this->label4->Location = System::Drawing::Point(4, 82); + this->label4->Name = L"label4"; + this->label4->Size = System::Drawing::Size(86, 26); + this->label4->TabIndex = 3; + this->label4->Text = L"HDD"; + this->label4->TextAlign = System::Drawing::ContentAlignment::MiddleRight; + // + // groupBox1 + // + this->groupBox1->Controls->Add(this->listViewSettings); + this->groupBox1->Dock = System::Windows::Forms::DockStyle::Fill; + this->groupBox1->Location = System::Drawing::Point(3, 3); + this->groupBox1->Name = L"groupBox1"; + this->tableLayoutPanel1->SetRowSpan(this->groupBox1, 2); + this->groupBox1->Size = System::Drawing::Size(193, 426); + this->groupBox1->TabIndex = 0; + this->groupBox1->TabStop = false; + this->groupBox1->Text = L"Settings"; + // + // listViewSettings + // + this->listViewSettings->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(2) { + this->columnHeader1, + this->columnHeader2 + }); + this->listViewSettings->Dock = System::Windows::Forms::DockStyle::Fill; + this->listViewSettings->Location = System::Drawing::Point(3, 16); + this->listViewSettings->Name = L"listViewSettings"; + this->listViewSettings->Size = System::Drawing::Size(187, 407); + this->listViewSettings->TabIndex = 0; + this->listViewSettings->UseCompatibleStateImageBehavior = false; + this->listViewSettings->View = System::Windows::Forms::View::Details; + // + // columnHeader1 + // + this->columnHeader1->Text = L"Name"; + this->columnHeader1->Width = 80; + // + // columnHeader2 + // + this->columnHeader2->Text = L"Value"; + this->columnHeader2->Width = 104; + // + // groupBox5 + // + this->tableLayoutPanel1->SetColumnSpan(this->groupBox5, 2); + this->groupBox5->Controls->Add(this->listViewProc); + this->groupBox5->Location = System::Drawing::Point(202, 165); + this->groupBox5->Name = L"groupBox5"; + this->groupBox5->Size = System::Drawing::Size(392, 264); + this->groupBox5->TabIndex = 4; + this->groupBox5->TabStop = false; + this->groupBox5->Text = L"Running Processes"; + // + // listViewProc + // + this->listViewProc->Columns->AddRange(gcnew cli::array< System::Windows::Forms::ColumnHeader^ >(2) { + this->columnHeader3, + this->columnHeader4 + }); + this->listViewProc->Dock = System::Windows::Forms::DockStyle::Fill; + this->listViewProc->FullRowSelect = true; + this->listViewProc->GridLines = true; + this->listViewProc->HeaderStyle = System::Windows::Forms::ColumnHeaderStyle::Nonclickable; + this->listViewProc->Location = System::Drawing::Point(3, 16); + this->listViewProc->Name = L"listViewProc"; + this->listViewProc->Size = System::Drawing::Size(386, 245); + this->listViewProc->Sorting = System::Windows::Forms::SortOrder::Ascending; + this->listViewProc->TabIndex = 1; + this->listViewProc->UseCompatibleStateImageBehavior = false; + this->listViewProc->View = System::Windows::Forms::View::Details; + // + // columnHeader3 + // + this->columnHeader3->Text = L"Name"; + // + // columnHeader4 + // + this->columnHeader4->Text = L"Path"; + this->columnHeader4->Width = 216; + // + // tableLayoutPanel6 + // + this->tableLayoutPanel6->ColumnCount = 1; + this->tableLayoutPanel6->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 100))); + this->tableLayoutPanel6->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Absolute, + 20))); + this->tableLayoutPanel6->Controls->Add(this->groupBox8, 0, 1); + this->tableLayoutPanel6->Controls->Add(this->groupBox4, 0, 0); + this->tableLayoutPanel6->Dock = System::Windows::Forms::DockStyle::Fill; + this->tableLayoutPanel6->Location = System::Drawing::Point(600, 3); + this->tableLayoutPanel6->Name = L"tableLayoutPanel6"; + this->tableLayoutPanel6->RowCount = 2; + this->tableLayoutPanel6->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50))); + this->tableLayoutPanel6->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50))); + this->tableLayoutPanel6->Size = System::Drawing::Size(193, 156); + this->tableLayoutPanel6->TabIndex = 7; + // + // groupBox8 + // + this->groupBox8->Controls->Add(this->tableLayoutPanel7); + this->groupBox8->Dock = System::Windows::Forms::DockStyle::Fill; + this->groupBox8->Location = System::Drawing::Point(3, 81); + this->groupBox8->Name = L"groupBox8"; + this->groupBox8->Size = System::Drawing::Size(187, 72); + this->groupBox8->TabIndex = 4; + this->groupBox8->TabStop = false; + this->groupBox8->Text = L"Sound detection"; + // + // tableLayoutPanel7 + // + this->tableLayoutPanel7->ColumnCount = 2; + this->tableLayoutPanel7->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle())); + this->tableLayoutPanel7->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 100))); + this->tableLayoutPanel7->Controls->Add(this->labelSoundOverLimit, 1, 2); + this->tableLayoutPanel7->Controls->Add(this->labelSoundPeak, 1, 1); + this->tableLayoutPanel7->Controls->Add(this->label11, 0, 1); + this->tableLayoutPanel7->Controls->Add(this->label12, 0, 0); + this->tableLayoutPanel7->Controls->Add(this->label13, 0, 2); + this->tableLayoutPanel7->Dock = System::Windows::Forms::DockStyle::Fill; + this->tableLayoutPanel7->Location = System::Drawing::Point(3, 16); + this->tableLayoutPanel7->Name = L"tableLayoutPanel7"; + this->tableLayoutPanel7->RowCount = 3; + this->tableLayoutPanel7->RowStyles->Add((gcnew System::Windows::Forms::RowStyle())); + this->tableLayoutPanel7->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50))); + this->tableLayoutPanel7->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50))); + this->tableLayoutPanel7->Size = System::Drawing::Size(181, 53); + this->tableLayoutPanel7->TabIndex = 0; + // + // labelSoundOverLimit + // + this->labelSoundOverLimit->AutoSize = true; + this->labelSoundOverLimit->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelSoundOverLimit->Location = System::Drawing::Point(62, 33); + this->labelSoundOverLimit->Name = L"labelSoundOverLimit"; + this->labelSoundOverLimit->Size = System::Drawing::Size(116, 20); + this->labelSoundOverLimit->TabIndex = 4; + this->labelSoundOverLimit->Text = L"Yes / No"; + this->labelSoundOverLimit->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // labelSoundPeak + // + this->labelSoundPeak->AutoSize = true; + this->labelSoundPeak->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelSoundPeak->Location = System::Drawing::Point(62, 13); + this->labelSoundPeak->Name = L"labelSoundPeak"; + this->labelSoundPeak->Size = System::Drawing::Size(116, 20); + this->labelSoundPeak->TabIndex = 3; + this->labelSoundPeak->Text = L"0.0"; + this->labelSoundPeak->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // label11 + // + this->label11->AutoSize = true; + this->label11->Dock = System::Windows::Forms::DockStyle::Fill; + this->label11->Location = System::Drawing::Point(3, 13); + this->label11->Name = L"label11"; + this->label11->Size = System::Drawing::Size(53, 20); + this->label11->TabIndex = 1; + this->label11->Text = L"Peak"; + this->label11->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // label12 + // + this->label12->AutoSize = true; + this->tableLayoutPanel7->SetColumnSpan(this->label12, 2); + this->label12->Dock = System::Windows::Forms::DockStyle::Fill; + this->label12->Location = System::Drawing::Point(3, 0); + this->label12->Name = L"label12"; + this->label12->Size = System::Drawing::Size(175, 13); + this->label12->TabIndex = 0; + this->label12->Text = L"Gets sound peak information"; + this->label12->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // label13 + // + this->label13->AutoSize = true; + this->label13->Dock = System::Windows::Forms::DockStyle::Fill; + this->label13->Location = System::Drawing::Point(3, 33); + this->label13->Name = L"label13"; + this->label13->Size = System::Drawing::Size(53, 20); + this->label13->TabIndex = 2; + this->label13->Text = L"Over limit:"; + this->label13->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // groupBox4 + // + this->groupBox4->Controls->Add(this->tableLayoutPanel5); + this->groupBox4->Dock = System::Windows::Forms::DockStyle::Fill; + this->groupBox4->Location = System::Drawing::Point(3, 3); + this->groupBox4->Name = L"groupBox4"; + this->groupBox4->Size = System::Drawing::Size(187, 72); + this->groupBox4->TabIndex = 3; + this->groupBox4->TabStop = false; + this->groupBox4->Text = L"Input Monitor"; + // + // tableLayoutPanel5 + // + this->tableLayoutPanel5->ColumnCount = 2; + this->tableLayoutPanel5->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle())); + this->tableLayoutPanel5->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 100))); + this->tableLayoutPanel5->Controls->Add(this->labelWAITReached, 1, 2); + this->tableLayoutPanel5->Controls->Add(this->labelInputTime, 1, 1); + this->tableLayoutPanel5->Controls->Add(this->label7, 0, 1); + this->tableLayoutPanel5->Controls->Add(this->label6, 0, 0); + this->tableLayoutPanel5->Controls->Add(this->label8, 0, 2); + this->tableLayoutPanel5->Dock = System::Windows::Forms::DockStyle::Fill; + this->tableLayoutPanel5->Location = System::Drawing::Point(3, 16); + this->tableLayoutPanel5->Name = L"tableLayoutPanel5"; + this->tableLayoutPanel5->RowCount = 3; + this->tableLayoutPanel5->RowStyles->Add((gcnew System::Windows::Forms::RowStyle())); + this->tableLayoutPanel5->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50))); + this->tableLayoutPanel5->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 50))); + this->tableLayoutPanel5->Size = System::Drawing::Size(181, 53); + this->tableLayoutPanel5->TabIndex = 0; + // + // labelWAITReached + // + this->labelWAITReached->AutoSize = true; + this->labelWAITReached->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelWAITReached->Location = System::Drawing::Point(113, 33); + this->labelWAITReached->Name = L"labelWAITReached"; + this->labelWAITReached->Size = System::Drawing::Size(65, 20); + this->labelWAITReached->TabIndex = 4; + this->labelWAITReached->Text = L"Yes / No"; + this->labelWAITReached->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // labelInputTime + // + this->labelInputTime->AutoSize = true; + this->labelInputTime->Dock = System::Windows::Forms::DockStyle::Fill; + this->labelInputTime->Location = System::Drawing::Point(113, 13); + this->labelInputTime->Name = L"labelInputTime"; + this->labelInputTime->Size = System::Drawing::Size(65, 20); + this->labelInputTime->TabIndex = 3; + this->labelInputTime->Text = L"0.0"; + this->labelInputTime->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // label7 + // + this->label7->AutoSize = true; + this->label7->Dock = System::Windows::Forms::DockStyle::Fill; + this->label7->Location = System::Drawing::Point(3, 13); + this->label7->Name = L"label7"; + this->label7->Size = System::Drawing::Size(104, 20); + this->label7->TabIndex = 1; + this->label7->Text = L"Time since last Input"; + this->label7->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // label6 + // + this->label6->AutoSize = true; + this->tableLayoutPanel5->SetColumnSpan(this->label6, 2); + this->label6->Dock = System::Windows::Forms::DockStyle::Fill; + this->label6->Location = System::Drawing::Point(3, 0); + this->label6->Name = L"label6"; + this->label6->Size = System::Drawing::Size(175, 13); + this->label6->TabIndex = 0; + this->label6->Text = L"Gets user input information"; + this->label6->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // label8 + // + this->label8->AutoSize = true; + this->label8->Dock = System::Windows::Forms::DockStyle::Fill; + this->label8->Location = System::Drawing::Point(3, 33); + this->label8->Name = L"label8"; + this->label8->Size = System::Drawing::Size(104, 20); + this->label8->TabIndex = 2; + this->label8->Text = L"Waittime reached"; + this->label8->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // groupBox6 + // + this->groupBox6->Controls->Add(this->tableLayoutPanel4); + this->groupBox6->Dock = System::Windows::Forms::DockStyle::Fill; + this->groupBox6->Location = System::Drawing::Point(799, 3); + this->groupBox6->Name = L"groupBox6"; + this->groupBox6->Size = System::Drawing::Size(196, 156); + this->groupBox6->TabIndex = 5; + this->groupBox6->TabStop = false; + this->groupBox6->Text = L"Controls"; + // + // tableLayoutPanel4 + // + this->tableLayoutPanel4->ColumnCount = 1; + this->tableLayoutPanel4->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 100))); + this->tableLayoutPanel4->Controls->Add(this->buttonTimeWnd, 0, 3); + this->tableLayoutPanel4->Controls->Add(this->buttonMessageWnd, 0, 2); + this->tableLayoutPanel4->Controls->Add(this->buttonProcessForm, 0, 1); + this->tableLayoutPanel4->Controls->Add(this->buttonSettingsForm, 0, 0); + this->tableLayoutPanel4->Dock = System::Windows::Forms::DockStyle::Fill; + this->tableLayoutPanel4->Location = System::Drawing::Point(3, 16); + this->tableLayoutPanel4->Name = L"tableLayoutPanel4"; + this->tableLayoutPanel4->RowCount = 4; + this->tableLayoutPanel4->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 25))); + this->tableLayoutPanel4->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 25))); + this->tableLayoutPanel4->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 25))); + this->tableLayoutPanel4->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 25))); + this->tableLayoutPanel4->Size = System::Drawing::Size(190, 137); + this->tableLayoutPanel4->TabIndex = 0; + // + // buttonTimeWnd + // + this->buttonTimeWnd->Dock = System::Windows::Forms::DockStyle::Fill; + this->buttonTimeWnd->Location = System::Drawing::Point(7, 109); + this->buttonTimeWnd->Margin = System::Windows::Forms::Padding(7); + this->buttonTimeWnd->Name = L"buttonTimeWnd"; + this->buttonTimeWnd->Size = System::Drawing::Size(176, 21); + this->buttonTimeWnd->TabIndex = 3; + this->buttonTimeWnd->Text = L"Open TimeoutWindow"; + this->buttonTimeWnd->UseVisualStyleBackColor = true; + this->buttonTimeWnd->Click += gcnew System::EventHandler(this, &DebugForm::buttonTimeWnd_Click); + // + // buttonMessageWnd + // + this->buttonMessageWnd->Dock = System::Windows::Forms::DockStyle::Fill; + this->buttonMessageWnd->Location = System::Drawing::Point(7, 75); + this->buttonMessageWnd->Margin = System::Windows::Forms::Padding(7); + this->buttonMessageWnd->Name = L"buttonMessageWnd"; + this->buttonMessageWnd->Size = System::Drawing::Size(176, 20); + this->buttonMessageWnd->TabIndex = 2; + this->buttonMessageWnd->Text = L"Open MessageWindow"; + this->buttonMessageWnd->UseVisualStyleBackColor = true; + this->buttonMessageWnd->Click += gcnew System::EventHandler(this, &DebugForm::buttonMessageWnd_Click); + // + // buttonProcessForm + // + this->buttonProcessForm->Dock = System::Windows::Forms::DockStyle::Fill; + this->buttonProcessForm->Location = System::Drawing::Point(7, 41); + this->buttonProcessForm->Margin = System::Windows::Forms::Padding(7); + this->buttonProcessForm->Name = L"buttonProcessForm"; + this->buttonProcessForm->Size = System::Drawing::Size(176, 20); + this->buttonProcessForm->TabIndex = 1; + this->buttonProcessForm->Text = L"Open ProcessSelectionForm"; + this->buttonProcessForm->UseVisualStyleBackColor = true; + this->buttonProcessForm->Click += gcnew System::EventHandler(this, &DebugForm::buttonProcessForm_Click); + // + // buttonSettingsForm + // + this->buttonSettingsForm->Dock = System::Windows::Forms::DockStyle::Fill; + this->buttonSettingsForm->Location = System::Drawing::Point(7, 7); + this->buttonSettingsForm->Margin = System::Windows::Forms::Padding(7); + this->buttonSettingsForm->Name = L"buttonSettingsForm"; + this->buttonSettingsForm->Size = System::Drawing::Size(176, 20); + this->buttonSettingsForm->TabIndex = 0; + this->buttonSettingsForm->Text = L"Open MetroSettingsForm"; + this->buttonSettingsForm->UseVisualStyleBackColor = true; + this->buttonSettingsForm->Click += gcnew System::EventHandler(this, &DebugForm::buttonSettingsForm_Click); + // + // textBoxLog + // + this->textBoxLog->Dock = System::Windows::Forms::DockStyle::Fill; + this->textBoxLog->Location = System::Drawing::Point(3, 16); + this->textBoxLog->Name = L"textBoxLog"; + this->textBoxLog->Size = System::Drawing::Size(389, 245); + this->textBoxLog->TabIndex = 8; + this->textBoxLog->Text = L""; + // + // timerRefresh + // + this->timerRefresh->Enabled = true; + // + // groupBox7 + // + this->tableLayoutPanel1->SetColumnSpan(this->groupBox7, 2); + this->groupBox7->Controls->Add(this->textBoxLog); + this->groupBox7->Dock = System::Windows::Forms::DockStyle::Fill; + this->groupBox7->Location = System::Drawing::Point(600, 165); + this->groupBox7->Name = L"groupBox7"; + this->groupBox7->Size = System::Drawing::Size(395, 264); + this->groupBox7->TabIndex = 9; + this->groupBox7->TabStop = false; + this->groupBox7->Text = L"Log File"; + // + // DebugForm + // + this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); + this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; + this->ClientSize = System::Drawing::Size(998, 432); + this->Controls->Add(this->tableLayoutPanel1); + this->DoubleBuffered = true; + this->Name = L"DebugForm"; + this->Text = L"DebugForm"; + this->Load += gcnew System::EventHandler(this, &DebugForm::DebugForm_Load); + this->tableLayoutPanel1->ResumeLayout(false); + this->groupBox3->ResumeLayout(false); + this->tableLayoutPanel3->ResumeLayout(false); + this->tableLayoutPanel3->PerformLayout(); + this->groupBox2->ResumeLayout(false); + this->tableLayoutPanel2->ResumeLayout(false); + this->tableLayoutPanel2->PerformLayout(); + this->groupBox1->ResumeLayout(false); + this->groupBox5->ResumeLayout(false); + this->tableLayoutPanel6->ResumeLayout(false); + this->groupBox8->ResumeLayout(false); + this->tableLayoutPanel7->ResumeLayout(false); + this->tableLayoutPanel7->PerformLayout(); + this->groupBox4->ResumeLayout(false); + this->tableLayoutPanel5->ResumeLayout(false); + this->tableLayoutPanel5->PerformLayout(); + this->groupBox6->ResumeLayout(false); + this->tableLayoutPanel4->ResumeLayout(false); + this->groupBox7->ResumeLayout(false); + this->ResumeLayout(false); + + } +#pragma endregion + //Load + System::Void DebugForm_Load(System::Object^ sender, System::EventArgs^ e); + + //Button Actions + System::Void buttonSettingsForm_Click(System::Object^, System::EventArgs^); + System::Void buttonProcessForm_Click(System::Object^, System::EventArgs^); + System::Void buttonMessageWnd_Click(System::Object^, System::EventArgs^); + System::Void buttonTimeWnd_Click(System::Object^, System::EventArgs^); + + //Logs + System::String^ getLogText(); + + //UI + void OnTick(System::Object ^sender, System::EventArgs ^e); + void RefreshUISlow(); + void RefreshUIRealTime(); + }; +} diff --git a/SourceCode/DebugForm.resx b/SourceCode/DebugForm.resx new file mode 100644 index 0000000..86f7a8f --- /dev/null +++ b/SourceCode/DebugForm.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 45 + + \ No newline at end of file diff --git a/SourceCode/InputMonitor.cpp b/SourceCode/InputMonitor.cpp index 3bced30..218450e 100644 --- a/SourceCode/InputMonitor.cpp +++ b/SourceCode/InputMonitor.cpp @@ -21,11 +21,11 @@ InputMonitor::~InputMonitor() void InputMonitor::Monitor() { while (aborted == false) { if (SystemAccess::GetLastInputTime() == 0) { - DEBUG("LastInputTime == 0 milliseconds"); + LOG("LastInputTime == 0 milliseconds"); } if (SystemAccess::GetLastInputTime() > wait_time) { - DEBUG("Wait Time is over!"); + LOG("Wait Time is over!"); parent->CheckUsage(); } //Sleep only 10 milliseconds at once to handle to Close() Event diff --git a/SourceCode/InputMonitor.h b/SourceCode/InputMonitor.h index 83210be..cf46f24 100644 --- a/SourceCode/InputMonitor.h +++ b/SourceCode/InputMonitor.h @@ -1,12 +1,11 @@ #pragma once #include "stdafx.h" -#include "BasicFunc.h" #include "SystemMetricWatcher.h" #include "SystemAccess.h" ref class mainApplication; -ref class InputMonitor { +public ref class InputMonitor { private: int wait_time; bool aborted; diff --git a/SourceCode/MessageWindow.cpp b/SourceCode/MessageWindow.cpp index a848c44..c2ef49d 100644 --- a/SourceCode/MessageWindow.cpp +++ b/SourceCode/MessageWindow.cpp @@ -13,11 +13,11 @@ System::Void MessageWindow::TimeoutWindow_Load(System::Object^, System::EventArg this->Update(); System::Media::SystemSounds::Asterisk->Play(); } -System::Void MessageWindow::metroButtonOK_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MessageWindow::metroButtonOK_Click(System::Object^, System::EventArgs^) { this->DialogResult = Windows::Forms::DialogResult::OK; this->Close(); } -System::Void MessageWindow::metroButtonCancel_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MessageWindow::metroButtonCancel_Click(System::Object^, System::EventArgs^) { this->DialogResult = Windows::Forms::DialogResult::Cancel; this->Close(); } \ No newline at end of file diff --git a/SourceCode/MetroSettingsForm.cpp b/SourceCode/MetroSettingsForm.cpp index 7fbbc90..21fe8c4 100644 --- a/SourceCode/MetroSettingsForm.cpp +++ b/SourceCode/MetroSettingsForm.cpp @@ -5,7 +5,7 @@ using namespace StandBye; void MetroSettingsForm::forceRefreshUI() { timerUIRefresh_Tick(gcnew System::Object, gcnew System::EventArgs); } -System::Void MetroSettingsForm::MetroSettingsForm_Load(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::MetroSettingsForm_Load(System::Object^, System::EventArgs^) { //Focus on first tabPage metroTabControl1->SelectedTab = metroTabPage1; @@ -14,11 +14,13 @@ System::Void MetroSettingsForm::MetroSettingsForm_Load(System::Object^ sender, metroTrackBarRAM->Value = settings_provider->getThreshold(SettingName::MAX_RAM); setTextBoxValue(metroTextBoxNET, (double)settings_provider->getThreshold(SettingName::MAX_NET) / 1000); setTextBoxValue(metroTextBoxHDD, (double)settings_provider->getThreshold(SettingName::MAX_HDD) / 1000); - setTextBoxValue(metroTextBoxWAITTIME, settings_provider->getThreshold(SettingName::WAIT_TIME) / 60); + setTextBoxValue(metroTextBoxTimeMIN, Math::Floor(settings_provider->getThreshold(SettingName::WAIT_TIME) / 60)); + setTextBoxValue(metroTextBoxTimeSEC, settings_provider->getThreshold(SettingName::WAIT_TIME) - Math::Floor(settings_provider->getThreshold(SettingName::WAIT_TIME) / 60) * 60); metroToggleCPU->Checked = settings_provider->isActive(SettingName::USE_CPU); metroToggleHDD->Checked = settings_provider->isActive(SettingName::USE_HDD); metroToggleNET->Checked = settings_provider->isActive(SettingName::USE_NET); metroToggleRAM->Checked = settings_provider->isActive(SettingName::USE_RAM); + metroToggleSOUND->Checked = settings_provider->isActive(SettingName::CHECK_SOUND); //Load AutoStart Setting metroToggleAutoStart->Checked = SystemAccess::IsInAutoStart(); @@ -41,11 +43,6 @@ System::Void MetroSettingsForm::MetroSettingsForm_Load(System::Object^ sender, timerRefresh->Start(); forceRefreshUI(); } -bool MetroSettingsForm::isNumber(std::string line) { - char* p; - strtol(line.c_str(), &p, 10); - return *p == 0; -} double MetroSettingsForm::getTextBoxValueAsDouble(MetroFramework::Controls::MetroTextBox^ box) { box->Text = box->Text->Replace(",", "."); @@ -55,15 +52,15 @@ double MetroSettingsForm::getTextBoxValueAsDouble(MetroFramework::Controls::Metr } void MetroSettingsForm::setTextBoxValue(MetroFramework::Controls::MetroTextBox^ box, double value) { - box->Text = String::Format("{0:00.0}", value); -} - -System::Void MetroSettingsForm::metroTextBoxWAITTIME_TextChanged(System::Object^ sender, System::EventArgs^ e) { - if (isNumber(BasicFunc::StringToString(metroTextBoxWAITTIME->Text)) == false) { - metroTextBoxWAITTIME->Text = ""; + if (Math::Floor(value) == value) { + //Number has no comma + box->Text = String::Format("{0:00}", value); + } + else { + box->Text = String::Format("{0:00.0}", value); } - forceRefreshUI(); } + void MetroSettingsForm::changeLabelBackgroundColor(MetroFramework::Controls::MetroLabel^ label, double SettingsValue, double readValue) { if (SettingsValue > readValue) { label->BackColor = lightGreen; @@ -73,7 +70,7 @@ void MetroSettingsForm::changeLabelBackgroundColor(MetroFramework::Controls::Met } } -System::Void MetroSettingsForm::timerUIRefresh_Tick(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::timerUIRefresh_Tick(System::Object^, System::EventArgs^) { float curCPU, curRAM, curHDD, curNET; //gets current system Usage curCPU = system_watcher->GetSystemMetric(SystemAccess::SystemMetric::CPU); @@ -98,17 +95,21 @@ System::Void MetroSettingsForm::timerUIRefresh_Tick(System::Object^ sender, Sys metroToolTip1->SetToolTip(metroLabelCurRAM, String::Format("Now: {0:00.00} % ", system_access->GetMetric(SystemAccess::SystemMetric::RAM))); metroToolTip1->SetToolTip(metroLabelCurHDD, String::Format("Now: {0:00.00} MBit/s", system_access->GetMetric(SystemAccess::SystemMetric::HDD) / 1000)); metroToolTip1->SetToolTip(metroLabelCurNET, String::Format("Now: {0:00.00} MBit/s", system_access->GetMetric(SystemAccess::SystemMetric::NETWORK) / 1000)); + + //Gets Focus + this->Focus(); } -System::Void MetroSettingsForm::metroButtonOK_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroButtonOK_Click(System::Object^, System::EventArgs^) { settings_provider->setSetting(SettingName::MAX_CPU, Decimal::ToInt32(metroTrackBarCPU->Value)); settings_provider->setSetting(SettingName::MAX_RAM, Decimal::ToInt32(metroTrackBarRAM->Value)); settings_provider->setSetting(SettingName::MAX_HDD, (int)(getTextBoxValueAsDouble(metroTextBoxHDD) * 1000)); settings_provider->setSetting(SettingName::MAX_NET, (int)(getTextBoxValueAsDouble(metroTextBoxNET) * 1000)); - settings_provider->setSetting(SettingName::WAIT_TIME, getTextBoxValueAsDouble(metroTextBoxWAITTIME) * 60); + settings_provider->setSetting(SettingName::WAIT_TIME, (int)getTextBoxValueAsDouble(metroTextBoxTimeMIN) * 60 + (int)getTextBoxValueAsDouble(metroTextBoxTimeSEC)); settings_provider->setActiveState(SettingName::USE_CPU, metroToggleCPU->Checked); settings_provider->setActiveState(SettingName::USE_HDD, metroToggleHDD->Checked); settings_provider->setActiveState(SettingName::USE_RAM, metroToggleRAM->Checked); settings_provider->setActiveState(SettingName::USE_NET, metroToggleNET->Checked); + settings_provider->setActiveState(SettingName::CHECK_SOUND, metroToggleSOUND->Checked); for each(ListViewItem^ l in listViewProc->Items) { ProcessItem^ p = (ProcessItem^)l; @@ -121,11 +122,11 @@ System::Void MetroSettingsForm::metroButtonOK_Click(System::Object^ sender, Sys this->DialogResult = Windows::Forms::DialogResult::OK; this->Hide(); } -System::Void MetroSettingsForm::metroButtonCancel_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroButtonCancel_Click(System::Object^, System::EventArgs^) { this->DialogResult = Windows::Forms::DialogResult::Cancel; this->Hide(); } -System::Void MetroSettingsForm::metroButtonAddFromFile_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroButtonAddFromFile_Click(System::Object^, System::EventArgs^) { OpenFileDialog^ ofd = gcnew OpenFileDialog(); ofd->InitialDirectory = "C:\\"; ofd->Filter = "exe files(*.exe)|*.exe"; @@ -138,7 +139,7 @@ System::Void MetroSettingsForm::metroButtonAddFromFile_Click(System::Object^ se } } } -System::Void MetroSettingsForm::metroButtonAddFromList_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroButtonAddFromList_Click(System::Object^, System::EventArgs^) { using namespace StandBye; ProcessSelectionForm^ ProcForm = gcnew ProcessSelectionForm; if (ProcForm->ShowDialog() == Windows::Forms::DialogResult::OK) { @@ -148,16 +149,16 @@ System::Void MetroSettingsForm::metroButtonAddFromList_Click(System::Object^ se } delete ProcForm; } -System::Void MetroSettingsForm::metroButtonRemove_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroButtonRemove_Click(System::Object^, System::EventArgs^) { ProcessItem^ proc = (ProcessItem^)listViewProc->SelectedItems[0]; settings_provider->removeProcessFromProcessList(BasicFunc::StringToString(proc->GetPath())); delete proc; refreshIcons(); } -System::Void MetroSettingsForm::listViewProc_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::listViewProc_SelectedIndexChanged(System::Object^, System::EventArgs^) { metroButtonRemove->Enabled = (listViewProc->SelectedItems->Count > 0); } -System::Void MetroSettingsForm::metroToggleView_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroToggleView_CheckedChanged(System::Object^, System::EventArgs^) { if (metroToggleView->Checked) { listViewProc->View = Windows::Forms::View::Details; } @@ -179,33 +180,45 @@ void MetroSettingsForm::refreshIcons() { p->addIconToLists(listViewProc); } } -System::Void MetroSettingsForm::metroTrackBarRAM_Scroll(System::Object^ sender, System::Windows::Forms::ScrollEventArgs^ e) { - metroLabelRAMPer->Text = String::Format("{0} %", metroTrackBarRAM->Value); +System::Void MetroSettingsForm::metroTrackBarRAM_Scroll(System::Object^, System::Windows::Forms::ScrollEventArgs^) { + if (metroLabelRAMPer->Text != String::Format("{0} %", metroTrackBarRAM->Value)) { + metroLabelRAMPer->Text = String::Format("{0} %", metroTrackBarRAM->Value); + } } -System::Void MetroSettingsForm::metroTrackBarCPU_Scroll(System::Object^ sender, System::Windows::Forms::ScrollEventArgs^ e) { - metroLabelCPUPer->Text = String::Format("{0} %", metroTrackBarCPU->Value); +System::Void MetroSettingsForm::metroTrackBarCPU_Scroll(System::Object^, System::Windows::Forms::ScrollEventArgs^) { + if (metroLabelCPUPer->Text != String::Format("{0} %", metroTrackBarCPU->Value)) { + metroLabelCPUPer->Text = String::Format("{0} %", metroTrackBarCPU->Value); + } } -System::Void MetroSettingsForm::metroToggleAutoStart_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroToggleAutoStart_CheckedChanged(System::Object^, System::EventArgs^) { SystemAccess::SetAutoStart(metroToggleAutoStart->Checked); } -System::Void MetroSettingsForm::metroTileHomepage_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroTileHomepage_Click(System::Object^, System::EventArgs^) { ShellExecute(0, 0, "http://www.stand-bye.de", 0, 0, SW_SHOW); } -System::Void MetroSettingsForm::metroTileGithub_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroTileGithub_Click(System::Object^, System::EventArgs^) { ShellExecute(0, 0, "https://github.com/flobaader/Stand-Bye", 0, 0, SW_SHOW); } -System::Void MetroSettingsForm::metroLinkHomepage_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void MetroSettingsForm::metroLinkHomepage_Click(System::Object^, System::EventArgs^) { ShellExecute(0, 0, "http://www.stand-bye.de", 0, 0, SW_SHOW); } System::Void MetroSettingsForm::ReformatTextBoxValueOnReturn(System::Object ^sender, System::Windows::Forms::KeyEventArgs ^e) { using MetroFramework::Controls::MetroTextBox; if (e->KeyCode == Windows::Forms::Keys::Return) { MetroTextBox^ txt = (MetroTextBox^)sender; - if (getTextBoxValueAsDouble(txt) == -1) { + double value = getTextBoxValueAsDouble(txt); + if (value == -1) { + //Could not convert txt->Text = ""; } else { - txt->Text = String::Format("{0:00.0}", getTextBoxValueAsDouble(txt)); + if (Math::Floor(value) == value) { + //Number has no comma + txt->Text = String::Format("{0:00}", value); + } + else { + txt->Text = String::Format("{0:00.0}", value); + } } forceRefreshUI(); } diff --git a/SourceCode/MetroSettingsForm.h b/SourceCode/MetroSettingsForm.h index 6bfc9f4..6167908 100644 --- a/SourceCode/MetroSettingsForm.h +++ b/SourceCode/MetroSettingsForm.h @@ -1,10 +1,7 @@ #pragma once -#include "BasicFunc.h" #include "SystemMetricWatcher.h" #include "SettingsProvider.h" -#include "ProcessItem.h" #include "ProcessSelectionForm.h" -#include using namespace System; using namespace System::ComponentModel; using namespace System::Collections; @@ -24,72 +21,78 @@ namespace StandBye { SystemMetricWatcher^ system_watcher; Drawing::Color lightGreen, darkGreen, lightRed, darkRed; - private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel2; - - private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel3; + private: MetroFramework::Components::MetroStyleExtender^ metroStyleExtender1; + private: MetroFramework::Components::MetroStyleManager^ metroStyleManager1; + private: MetroFramework::Components::MetroToolTip^ metroToolTip1; + private: MetroFramework::Controls::MetroButton^ metroButtonAddFromFile; + private: MetroFramework::Controls::MetroButton^ metroButtonAddFromList; + private: MetroFramework::Controls::MetroButton^ metroButtonCancel; + private: MetroFramework::Controls::MetroButton^ metroButtonOK; + private: MetroFramework::Controls::MetroButton^ metroButtonRemove; + private: MetroFramework::Controls::MetroLabel^ metroLabel10; + private: MetroFramework::Controls::MetroLabel^ metroLabel11; + private: MetroFramework::Controls::MetroLabel^ metroLabel12; + private: MetroFramework::Controls::MetroLabel^ metroLabel13; + private: MetroFramework::Controls::MetroLabel^ metroLabel14; + private: MetroFramework::Controls::MetroLabel^ metroLabel15; + private: MetroFramework::Controls::MetroLabel^ metroLabel16; + private: MetroFramework::Controls::MetroLabel^ metroLabel17; + private: MetroFramework::Controls::MetroLabel^ metroLabel18; + private: MetroFramework::Controls::MetroLabel^ metroLabel19; private: MetroFramework::Controls::MetroLabel^ metroLabel1; private: MetroFramework::Controls::MetroLabel^ metroLabel2; - + private: MetroFramework::Controls::MetroLabel^ metroLabel3; private: MetroFramework::Controls::MetroLabel^ metroLabel4; private: MetroFramework::Controls::MetroLabel^ metroLabel5; private: MetroFramework::Controls::MetroLabel^ metroLabel6; private: MetroFramework::Controls::MetroLabel^ metroLabel7; private: MetroFramework::Controls::MetroLabel^ metroLabel8; - - private: MetroFramework::Controls::MetroLabel^ metroLabel10; + private: MetroFramework::Controls::MetroLabel^ metroLabel9; private: MetroFramework::Controls::MetroLabel^ metroLabelCPUPer; - private: MetroFramework::Controls::MetroLabel^ metroLabelRAMPer; - private: MetroFramework::Controls::MetroLabel^ metroLabel13; - private: MetroFramework::Controls::MetroLabel^ metroLabel14; private: MetroFramework::Controls::MetroLabel^ metroLabelCurCPU; - private: MetroFramework::Controls::MetroLabel^ metroLabelCurRAM; private: MetroFramework::Controls::MetroLabel^ metroLabelCurHDD; private: MetroFramework::Controls::MetroLabel^ metroLabelCurNET; - - private: MetroFramework::Controls::MetroTrackBar^ metroTrackBarCPU; - private: MetroFramework::Controls::MetroTrackBar^ metroTrackBarRAM; + private: MetroFramework::Controls::MetroLabel^ metroLabelCurRAM; + private: MetroFramework::Controls::MetroLabel^ metroLabelRAMPer; + private: MetroFramework::Controls::MetroLabel^ metroLabelView; + private: MetroFramework::Controls::MetroLink^ metroLinkHomepage; + private: MetroFramework::Controls::MetroTabControl^ metroTabControl1; + private: MetroFramework::Controls::MetroTabPage^ metroTabPage1; + private: MetroFramework::Controls::MetroTabPage^ metroTabPage2; + private: MetroFramework::Controls::MetroTabPage^ metroTabPage3; + private: MetroFramework::Controls::MetroTabPage^ metroTabPage4; private: MetroFramework::Controls::MetroTextBox^ metroTextBoxHDD; private: MetroFramework::Controls::MetroTextBox^ metroTextBoxNET; + private: MetroFramework::Controls::MetroTextBox^ metroTextBoxTimeMIN; + private: MetroFramework::Controls::MetroTextBox^ metroTextBoxTimeSEC; + private: MetroFramework::Controls::MetroTile^ metroTileGithub; + private: MetroFramework::Controls::MetroTile^ metroTileHomepage; + private: MetroFramework::Controls::MetroToggle^ metroToggleAutoStart; private: MetroFramework::Controls::MetroToggle^ metroToggleCPU; - private: MetroFramework::Controls::MetroToggle^ metroToggleRAM; private: MetroFramework::Controls::MetroToggle^ metroToggleHDD; private: MetroFramework::Controls::MetroToggle^ metroToggleNET; - private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel5; - private: System::Windows::Forms::ListView^ listViewProc; - - private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel6; - private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel7; - private: MetroFramework::Controls::MetroButton^ metroButtonRemove; - private: MetroFramework::Controls::MetroButton^ metroButtonAddFromList; - private: MetroFramework::Controls::MetroButton^ metroButtonAddFromFile; - private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel8; + private: MetroFramework::Controls::MetroToggle^ metroToggleRAM; + private: MetroFramework::Controls::MetroToggle^ metroToggleSOUND; + private: MetroFramework::Controls::MetroToggle^ metroToggleTutorial; private: MetroFramework::Controls::MetroToggle^ metroToggleView; - private: MetroFramework::Controls::MetroLabel^ metroLabelView; + private: MetroFramework::Controls::MetroTrackBar^ metroTrackBarCPU; + private: MetroFramework::Controls::MetroTrackBar^ metroTrackBarRAM; + private: System::ComponentModel::IContainer^ components; private: System::Windows::Forms::ColumnHeader^ columnHeader1; private: System::Windows::Forms::ColumnHeader^ columnHeader2; - - private: MetroFramework::Components::MetroStyleManager^ metroStyleManager1; - private: MetroFramework::Components::MetroStyleExtender^ metroStyleExtender1; - private: MetroFramework::Controls::MetroTile^ metroTileGithub; - - private: MetroFramework::Controls::MetroTile^ metroTileHomepage; - - private: MetroFramework::Controls::MetroLabel^ metroLabel3; - private: MetroFramework::Components::MetroToolTip^ metroToolTip1; - private: MetroFramework::Controls::MetroTabPage^ metroTabPage4; + private: System::Windows::Forms::ListView^ listViewProc; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel10; private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel11; - private: MetroFramework::Controls::MetroLabel^ metroLabel11; - private: MetroFramework::Controls::MetroToggle^ metroToggleAutoStart; - private: MetroFramework::Controls::MetroLabel^ metroLabel12; - private: MetroFramework::Controls::MetroLabel^ metroLabel15; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel1; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel2; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel3; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel4; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel5; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel6; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel7; + private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel8; private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel9; - private: MetroFramework::Controls::MetroLabel^ metroLabel16; - private: MetroFramework::Controls::MetroLabel^ metroLabel17; - private: MetroFramework::Controls::MetroLabel^ metroLabel18; - private: MetroFramework::Controls::MetroToggle^ metroToggleTutorial; - private: MetroFramework::Controls::MetroLink^ metroLinkHomepage; - - private: MetroFramework::Controls::MetroTextBox^ metroTextBoxWAITTIME; + private: System::Windows::Forms::Timer^ timerRefresh; public: MetroSettingsForm(SystemMetricWatcher^ smw, SettingsProvider* pro) @@ -115,20 +118,6 @@ namespace StandBye { delete components; } } - private: MetroFramework::Controls::MetroTabControl^ metroTabControl1; - protected: - private: MetroFramework::Controls::MetroTabPage^ metroTabPage1; - private: MetroFramework::Controls::MetroTabPage^ metroTabPage2; - private: MetroFramework::Controls::MetroTabPage^ metroTabPage3; - - private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel1; - private: System::Windows::Forms::TableLayoutPanel^ tableLayoutPanel4; - private: MetroFramework::Controls::MetroButton^ metroButtonOK; - private: MetroFramework::Controls::MetroButton^ metroButtonCancel; - private: System::Windows::Forms::Timer^ timerRefresh; - - private: System::ComponentModel::IContainer^ components; - private: #pragma region Windows Form Designer generated code void InitializeComponent(void) @@ -140,31 +129,36 @@ namespace StandBye { this->tableLayoutPanel2 = (gcnew System::Windows::Forms::TableLayoutPanel()); this->tableLayoutPanel3 = (gcnew System::Windows::Forms::TableLayoutPanel()); this->metroLabel1 = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabel2 = (gcnew MetroFramework::Controls::MetroLabel()); this->metroLabel4 = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabel5 = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabel6 = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabel7 = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroToggleHDD = (gcnew MetroFramework::Controls::MetroToggle()); + this->metroToggleRAM = (gcnew MetroFramework::Controls::MetroToggle()); + this->metroToggleCPU = (gcnew MetroFramework::Controls::MetroToggle()); this->metroLabel8 = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabel10 = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabelCPUPer = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabelRAMPer = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroLabel7 = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroLabel6 = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroLabel5 = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroTextBoxNET = (gcnew MetroFramework::Controls::MetroTextBox()); + this->metroTextBoxHDD = (gcnew MetroFramework::Controls::MetroTextBox()); + this->metroTrackBarRAM = (gcnew MetroFramework::Controls::MetroTrackBar()); + this->metroTrackBarCPU = (gcnew MetroFramework::Controls::MetroTrackBar()); this->metroLabel13 = (gcnew MetroFramework::Controls::MetroLabel()); this->metroLabel14 = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabelCurCPU = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabelCurRAM = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroLabelCurHDD = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroLabelCPUPer = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroLabelRAMPer = (gcnew MetroFramework::Controls::MetroLabel()); this->metroLabelCurNET = (gcnew MetroFramework::Controls::MetroLabel()); - this->metroTrackBarCPU = (gcnew MetroFramework::Controls::MetroTrackBar()); - this->metroTrackBarRAM = (gcnew MetroFramework::Controls::MetroTrackBar()); - this->metroTextBoxHDD = (gcnew MetroFramework::Controls::MetroTextBox()); - this->metroTextBoxNET = (gcnew MetroFramework::Controls::MetroTextBox()); - this->metroToggleCPU = (gcnew MetroFramework::Controls::MetroToggle()); - this->metroToggleRAM = (gcnew MetroFramework::Controls::MetroToggle()); - this->metroToggleHDD = (gcnew MetroFramework::Controls::MetroToggle()); - this->metroToggleNET = (gcnew MetroFramework::Controls::MetroToggle()); - this->metroTextBoxWAITTIME = (gcnew MetroFramework::Controls::MetroTextBox()); + this->metroLabelCurHDD = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroLabelCurRAM = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroLabelCurCPU = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroLabel2 = (gcnew MetroFramework::Controls::MetroLabel()); this->metroLabel3 = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroToggleSOUND = (gcnew MetroFramework::Controls::MetroToggle()); + this->metroLabel9 = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroToggleNET = (gcnew MetroFramework::Controls::MetroToggle()); + this->tableLayoutPanel10 = (gcnew System::Windows::Forms::TableLayoutPanel()); + this->metroLabel10 = (gcnew MetroFramework::Controls::MetroLabel()); + this->metroTextBoxTimeMIN = (gcnew MetroFramework::Controls::MetroTextBox()); + this->metroTextBoxTimeSEC = (gcnew MetroFramework::Controls::MetroTextBox()); + this->metroLabel19 = (gcnew MetroFramework::Controls::MetroLabel()); this->metroLabel16 = (gcnew MetroFramework::Controls::MetroLabel()); this->metroTabPage2 = (gcnew MetroFramework::Controls::MetroTabPage()); this->tableLayoutPanel5 = (gcnew System::Windows::Forms::TableLayoutPanel()); @@ -205,6 +199,7 @@ namespace StandBye { this->metroTabPage1->SuspendLayout(); this->tableLayoutPanel2->SuspendLayout(); this->tableLayoutPanel3->SuspendLayout(); + this->tableLayoutPanel10->SuspendLayout(); this->metroTabPage2->SuspendLayout(); this->tableLayoutPanel5->SuspendLayout(); this->tableLayoutPanel6->SuspendLayout(); @@ -285,43 +280,47 @@ namespace StandBye { this->tableLayoutPanel3->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Absolute, 120))); this->tableLayoutPanel3->Controls->Add(this->metroLabel1, 0, 0); - this->tableLayoutPanel3->Controls->Add(this->metroLabel2, 0, 2); this->tableLayoutPanel3->Controls->Add(this->metroLabel4, 2, 1); - this->tableLayoutPanel3->Controls->Add(this->metroLabel5, 2, 3); - this->tableLayoutPanel3->Controls->Add(this->metroLabel6, 2, 4); - this->tableLayoutPanel3->Controls->Add(this->metroLabel7, 2, 5); - this->tableLayoutPanel3->Controls->Add(this->metroLabel8, 2, 6); - this->tableLayoutPanel3->Controls->Add(this->metroLabel10, 4, 1); - this->tableLayoutPanel3->Controls->Add(this->metroLabelCPUPer, 4, 3); - this->tableLayoutPanel3->Controls->Add(this->metroLabelRAMPer, 4, 4); - this->tableLayoutPanel3->Controls->Add(this->metroLabel13, 4, 5); - this->tableLayoutPanel3->Controls->Add(this->metroLabel14, 4, 6); - this->tableLayoutPanel3->Controls->Add(this->metroLabelCurCPU, 5, 3); - this->tableLayoutPanel3->Controls->Add(this->metroLabelCurRAM, 5, 4); - this->tableLayoutPanel3->Controls->Add(this->metroLabelCurHDD, 5, 5); - this->tableLayoutPanel3->Controls->Add(this->metroLabelCurNET, 5, 6); - this->tableLayoutPanel3->Controls->Add(this->metroTrackBarCPU, 3, 3); - this->tableLayoutPanel3->Controls->Add(this->metroTrackBarRAM, 3, 4); - this->tableLayoutPanel3->Controls->Add(this->metroTextBoxHDD, 3, 5); - this->tableLayoutPanel3->Controls->Add(this->metroTextBoxNET, 3, 6); - this->tableLayoutPanel3->Controls->Add(this->metroToggleCPU, 1, 3); - this->tableLayoutPanel3->Controls->Add(this->metroToggleRAM, 1, 4); - this->tableLayoutPanel3->Controls->Add(this->metroToggleHDD, 1, 5); - this->tableLayoutPanel3->Controls->Add(this->metroToggleNET, 1, 6); - this->tableLayoutPanel3->Controls->Add(this->metroTextBoxWAITTIME, 3, 1); - this->tableLayoutPanel3->Controls->Add(this->metroLabel3, 5, 2); + this->tableLayoutPanel3->Controls->Add(this->metroToggleHDD, 1, 7); + this->tableLayoutPanel3->Controls->Add(this->metroToggleRAM, 1, 6); + this->tableLayoutPanel3->Controls->Add(this->metroToggleCPU, 1, 5); + this->tableLayoutPanel3->Controls->Add(this->metroLabel8, 2, 8); + this->tableLayoutPanel3->Controls->Add(this->metroLabel7, 2, 7); + this->tableLayoutPanel3->Controls->Add(this->metroLabel6, 2, 6); + this->tableLayoutPanel3->Controls->Add(this->metroLabel5, 2, 5); + this->tableLayoutPanel3->Controls->Add(this->metroTextBoxNET, 3, 8); + this->tableLayoutPanel3->Controls->Add(this->metroTextBoxHDD, 3, 7); + this->tableLayoutPanel3->Controls->Add(this->metroTrackBarRAM, 3, 6); + this->tableLayoutPanel3->Controls->Add(this->metroTrackBarCPU, 3, 5); + this->tableLayoutPanel3->Controls->Add(this->metroLabel13, 4, 8); + this->tableLayoutPanel3->Controls->Add(this->metroLabel14, 4, 7); + this->tableLayoutPanel3->Controls->Add(this->metroLabelCurNET, 5, 8); + this->tableLayoutPanel3->Controls->Add(this->metroLabelCurHDD, 5, 7); + this->tableLayoutPanel3->Controls->Add(this->metroLabelCurRAM, 5, 6); + this->tableLayoutPanel3->Controls->Add(this->metroLabelCurCPU, 5, 5); + this->tableLayoutPanel3->Controls->Add(this->metroLabel2, 0, 4); + this->tableLayoutPanel3->Controls->Add(this->metroLabel3, 5, 4); + this->tableLayoutPanel3->Controls->Add(this->metroToggleSOUND, 1, 2); + this->tableLayoutPanel3->Controls->Add(this->metroLabel9, 2, 2); + this->tableLayoutPanel3->Controls->Add(this->metroToggleNET, 1, 8); + this->tableLayoutPanel3->Controls->Add(this->tableLayoutPanel10, 3, 1); + this->tableLayoutPanel3->Controls->Add(this->metroLabelCPUPer, 4, 5); + this->tableLayoutPanel3->Controls->Add(this->metroLabelRAMPer, 4, 6); this->tableLayoutPanel3->Dock = System::Windows::Forms::DockStyle::Fill; this->tableLayoutPanel3->Location = System::Drawing::Point(10, 50); this->tableLayoutPanel3->Margin = System::Windows::Forms::Padding(10); this->tableLayoutPanel3->Name = L"tableLayoutPanel3"; - this->tableLayoutPanel3->RowCount = 7; - this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 14.28571F))); - this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 14.28571F))); - this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 14.28571F))); - this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 14.28571F))); - this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 14.28571F))); - this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 14.28571F))); - this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 14.28571F))); + this->tableLayoutPanel3->RowCount = 9; + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 11.11111F))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 11.11111F))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 11.11111F))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 11.11111F))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 11.11111F))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 11.11111F))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 11.11111F))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 11.11111F))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 11.11111F))); + this->tableLayoutPanel3->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute, 20))); this->tableLayoutPanel3->Size = System::Drawing::Size(696, 212); this->tableLayoutPanel3->TabIndex = 1; // @@ -333,120 +332,164 @@ namespace StandBye { this->metroLabel1->FontWeight = MetroFramework::MetroLabelWeight::Regular; this->metroLabel1->Location = System::Drawing::Point(3, 0); this->metroLabel1->Name = L"metroLabel1"; - this->metroLabel1->Size = System::Drawing::Size(299, 30); + this->metroLabel1->Size = System::Drawing::Size(305, 23); this->metroLabel1->TabIndex = 0; this->metroLabel1->Text = L"Program Settings"; this->metroLabel1->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // - // metroLabel2 - // - this->metroLabel2->AutoSize = true; - this->tableLayoutPanel3->SetColumnSpan(this->metroLabel2, 3); - this->metroLabel2->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel2->FontWeight = MetroFramework::MetroLabelWeight::Regular; - this->metroLabel2->Location = System::Drawing::Point(3, 60); - this->metroLabel2->Name = L"metroLabel2"; - this->metroLabel2->Size = System::Drawing::Size(299, 30); - this->metroLabel2->TabIndex = 1; - this->metroLabel2->Text = L"System Usage Thresholds"; - this->metroLabel2->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; - // // metroLabel4 // this->metroLabel4->AutoSize = true; this->metroLabel4->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel4->Location = System::Drawing::Point(169, 30); + this->metroLabel4->Location = System::Drawing::Point(169, 23); this->metroLabel4->Name = L"metroLabel4"; - this->metroLabel4->Size = System::Drawing::Size(133, 30); + this->metroLabel4->Size = System::Drawing::Size(139, 23); this->metroLabel4->TabIndex = 3; - this->metroLabel4->Text = L"activate standby after"; + this->metroLabel4->Text = L"Activate Standby After"; this->metroLabel4->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // - // metroLabel5 + // metroToggleHDD // - this->metroLabel5->AutoSize = true; - this->metroLabel5->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel5->Location = System::Drawing::Point(169, 90); - this->metroLabel5->Name = L"metroLabel5"; - this->metroLabel5->Size = System::Drawing::Size(133, 30); - this->metroLabel5->TabIndex = 4; - this->metroLabel5->Text = L"CPU Threshold"; - this->metroLabel5->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + this->metroToggleHDD->AutoSize = true; + this->metroToggleHDD->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroToggleHDD->Location = System::Drawing::Point(83, 164); + this->metroToggleHDD->Name = L"metroToggleHDD"; + this->metroToggleHDD->Size = System::Drawing::Size(80, 17); + this->metroToggleHDD->TabIndex = 48; + this->metroToggleHDD->Text = L"Aus"; + this->metroToggleHDD->UseSelectable = true; // - // metroLabel6 + // metroToggleRAM // - this->metroLabel6->AutoSize = true; - this->metroLabel6->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel6->Location = System::Drawing::Point(169, 120); - this->metroLabel6->Name = L"metroLabel6"; - this->metroLabel6->Size = System::Drawing::Size(133, 30); - this->metroLabel6->TabIndex = 5; - this->metroLabel6->Text = L"RAM Threshold"; - this->metroLabel6->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + this->metroToggleRAM->AutoSize = true; + this->metroToggleRAM->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroToggleRAM->Location = System::Drawing::Point(83, 141); + this->metroToggleRAM->Name = L"metroToggleRAM"; + this->metroToggleRAM->Size = System::Drawing::Size(80, 17); + this->metroToggleRAM->TabIndex = 47; + this->metroToggleRAM->Text = L"Aus"; + this->metroToggleRAM->UseSelectable = true; // - // metroLabel7 + // metroToggleCPU // - this->metroLabel7->AutoSize = true; - this->metroLabel7->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel7->Location = System::Drawing::Point(169, 150); - this->metroLabel7->Name = L"metroLabel7"; - this->metroLabel7->Size = System::Drawing::Size(133, 30); - this->metroLabel7->TabIndex = 6; - this->metroLabel7->Text = L"HDD Threshold"; - this->metroLabel7->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + this->metroToggleCPU->AutoSize = true; + this->metroToggleCPU->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroToggleCPU->Location = System::Drawing::Point(83, 118); + this->metroToggleCPU->Name = L"metroToggleCPU"; + this->metroToggleCPU->Size = System::Drawing::Size(80, 17); + this->metroToggleCPU->TabIndex = 46; + this->metroToggleCPU->Text = L"Aus"; + this->metroToggleCPU->UseSelectable = true; // // metroLabel8 // this->metroLabel8->AutoSize = true; this->metroLabel8->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel8->Location = System::Drawing::Point(169, 180); + this->metroLabel8->Location = System::Drawing::Point(169, 184); this->metroLabel8->Name = L"metroLabel8"; - this->metroLabel8->Size = System::Drawing::Size(133, 32); - this->metroLabel8->TabIndex = 7; + this->metroLabel8->Size = System::Drawing::Size(139, 28); + this->metroLabel8->TabIndex = 33; this->metroLabel8->Text = L"Network Threshold"; this->metroLabel8->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; // - // metroLabel10 + // metroLabel7 // - this->metroLabel10->AutoSize = true; - this->metroLabel10->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel10->Location = System::Drawing::Point(499, 30); - this->metroLabel10->Name = L"metroLabel10"; - this->metroLabel10->Size = System::Drawing::Size(74, 30); - this->metroLabel10->TabIndex = 9; - this->metroLabel10->Text = L"min"; - this->metroLabel10->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + this->metroLabel7->AutoSize = true; + this->metroLabel7->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabel7->Location = System::Drawing::Point(169, 161); + this->metroLabel7->Name = L"metroLabel7"; + this->metroLabel7->Size = System::Drawing::Size(139, 23); + this->metroLabel7->TabIndex = 32; + this->metroLabel7->Text = L"HDD Threshold"; + this->metroLabel7->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; // - // metroLabelCPUPer + // metroLabel6 // - this->metroLabelCPUPer->AutoSize = true; - this->metroLabelCPUPer->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabelCPUPer->Location = System::Drawing::Point(499, 90); - this->metroLabelCPUPer->Name = L"metroLabelCPUPer"; - this->metroLabelCPUPer->Size = System::Drawing::Size(74, 30); - this->metroLabelCPUPer->TabIndex = 10; - this->metroLabelCPUPer->Text = L"%"; - this->metroLabelCPUPer->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + this->metroLabel6->AutoSize = true; + this->metroLabel6->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabel6->Location = System::Drawing::Point(169, 138); + this->metroLabel6->Name = L"metroLabel6"; + this->metroLabel6->Size = System::Drawing::Size(139, 23); + this->metroLabel6->TabIndex = 31; + this->metroLabel6->Text = L"RAM Threshold"; + this->metroLabel6->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; // - // metroLabelRAMPer + // metroLabel5 // - this->metroLabelRAMPer->AutoSize = true; - this->metroLabelRAMPer->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabelRAMPer->Location = System::Drawing::Point(499, 120); - this->metroLabelRAMPer->Name = L"metroLabelRAMPer"; - this->metroLabelRAMPer->Size = System::Drawing::Size(74, 30); - this->metroLabelRAMPer->TabIndex = 11; - this->metroLabelRAMPer->Text = L"%"; - this->metroLabelRAMPer->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + this->metroLabel5->AutoSize = true; + this->metroLabel5->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabel5->Location = System::Drawing::Point(169, 115); + this->metroLabel5->Name = L"metroLabel5"; + this->metroLabel5->Size = System::Drawing::Size(139, 23); + this->metroLabel5->TabIndex = 30; + this->metroLabel5->Text = L"CPU Threshold"; + this->metroLabel5->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + // + // metroTextBoxNET + // + this->metroTextBoxNET->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroTextBoxNET->Lines = gcnew cli::array< System::String^ >(1) { L" " }; + this->metroTextBoxNET->Location = System::Drawing::Point(313, 186); + this->metroTextBoxNET->Margin = System::Windows::Forms::Padding(2); + this->metroTextBoxNET->MaxLength = 32767; + this->metroTextBoxNET->Name = L"metroTextBoxNET"; + this->metroTextBoxNET->PasswordChar = '\0'; + this->metroTextBoxNET->ScrollBars = System::Windows::Forms::ScrollBars::None; + this->metroTextBoxNET->SelectedText = L""; + this->metroTextBoxNET->Size = System::Drawing::Size(181, 24); + this->metroTextBoxNET->TabIndex = 45; + this->metroTextBoxNET->Text = L" "; + this->metroTextBoxNET->TextAlign = System::Windows::Forms::HorizontalAlignment::Right; + this->metroTextBoxNET->UseSelectable = true; + this->metroTextBoxNET->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &MetroSettingsForm::ReformatTextBoxValueOnReturn); + // + // metroTextBoxHDD + // + this->metroTextBoxHDD->Lines = gcnew cli::array< System::String^ >(1) { L" " }; + this->metroTextBoxHDD->Location = System::Drawing::Point(313, 163); + this->metroTextBoxHDD->Margin = System::Windows::Forms::Padding(2); + this->metroTextBoxHDD->MaxLength = 32767; + this->metroTextBoxHDD->Name = L"metroTextBoxHDD"; + this->metroTextBoxHDD->PasswordChar = '\0'; + this->metroTextBoxHDD->ScrollBars = System::Windows::Forms::ScrollBars::None; + this->metroTextBoxHDD->SelectedText = L""; + this->metroTextBoxHDD->Size = System::Drawing::Size(181, 16); + this->metroTextBoxHDD->TabIndex = 44; + this->metroTextBoxHDD->Text = L" "; + this->metroTextBoxHDD->TextAlign = System::Windows::Forms::HorizontalAlignment::Right; + this->metroTextBoxHDD->UseSelectable = true; + this->metroTextBoxHDD->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &MetroSettingsForm::ReformatTextBoxValueOnReturn); + // + // metroTrackBarRAM + // + this->metroTrackBarRAM->BackColor = System::Drawing::Color::Transparent; + this->metroTrackBarRAM->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroTrackBarRAM->Location = System::Drawing::Point(314, 141); + this->metroTrackBarRAM->Name = L"metroTrackBarRAM"; + this->metroTrackBarRAM->Size = System::Drawing::Size(179, 17); + this->metroTrackBarRAM->TabIndex = 43; + this->metroTrackBarRAM->Text = L"metroTrackBar2"; + this->metroTrackBarRAM->Scroll += gcnew System::Windows::Forms::ScrollEventHandler(this, &MetroSettingsForm::metroTrackBarRAM_Scroll); + // + // metroTrackBarCPU + // + this->metroTrackBarCPU->BackColor = System::Drawing::Color::Transparent; + this->metroTrackBarCPU->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroTrackBarCPU->Location = System::Drawing::Point(314, 118); + this->metroTrackBarCPU->Name = L"metroTrackBarCPU"; + this->metroTrackBarCPU->Size = System::Drawing::Size(179, 17); + this->metroTrackBarCPU->TabIndex = 42; + this->metroTrackBarCPU->Text = L"metroTrackBar1"; + this->metroTrackBarCPU->Scroll += gcnew System::Windows::Forms::ScrollEventHandler(this, &MetroSettingsForm::metroTrackBarCPU_Scroll); // // metroLabel13 // this->metroLabel13->AutoSize = true; this->metroLabel13->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel13->Location = System::Drawing::Point(499, 150); + this->metroLabel13->Location = System::Drawing::Point(499, 184); this->metroLabel13->Name = L"metroLabel13"; - this->metroLabel13->Size = System::Drawing::Size(74, 30); - this->metroLabel13->TabIndex = 12; + this->metroLabel13->Size = System::Drawing::Size(74, 28); + this->metroLabel13->TabIndex = 36; this->metroLabel13->Text = L"MBit/s"; this->metroLabel13->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // @@ -454,199 +497,233 @@ namespace StandBye { // this->metroLabel14->AutoSize = true; this->metroLabel14->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel14->Location = System::Drawing::Point(499, 180); + this->metroLabel14->Location = System::Drawing::Point(499, 161); this->metroLabel14->Name = L"metroLabel14"; - this->metroLabel14->Size = System::Drawing::Size(74, 32); - this->metroLabel14->TabIndex = 13; + this->metroLabel14->Size = System::Drawing::Size(74, 23); + this->metroLabel14->TabIndex = 37; this->metroLabel14->Text = L"MBit/s"; this->metroLabel14->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // - // metroLabelCurCPU - // - this->metroLabelCurCPU->AutoSize = true; - this->metroLabelCurCPU->BackColor = System::Drawing::SystemColors::Control; - this->metroLabelCurCPU->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabelCurCPU->ForeColor = System::Drawing::SystemColors::ControlText; - this->metroLabelCurCPU->Location = System::Drawing::Point(579, 90); - this->metroLabelCurCPU->Name = L"metroLabelCurCPU"; - this->metroLabelCurCPU->Size = System::Drawing::Size(114, 30); - this->metroLabelCurCPU->TabIndex = 14; - this->metroLabelCurCPU->Text = L"-"; - this->metroLabelCurCPU->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; - this->metroLabelCurCPU->UseCustomBackColor = true; - this->metroLabelCurCPU->UseCustomForeColor = true; - // - // metroLabelCurRAM + // metroLabelCPUPer // - this->metroLabelCurRAM->AutoSize = true; - this->metroLabelCurRAM->BackColor = System::Drawing::SystemColors::Control; - this->metroLabelCurRAM->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabelCurRAM->Location = System::Drawing::Point(579, 120); - this->metroLabelCurRAM->Name = L"metroLabelCurRAM"; - this->metroLabelCurRAM->Size = System::Drawing::Size(114, 30); - this->metroLabelCurRAM->TabIndex = 15; - this->metroLabelCurRAM->Text = L"-"; - this->metroLabelCurRAM->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; - this->metroLabelCurRAM->UseCustomBackColor = true; - this->metroLabelCurRAM->UseCustomForeColor = true; + this->metroLabelCPUPer->AutoSize = true; + this->metroLabelCPUPer->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabelCPUPer->Location = System::Drawing::Point(499, 115); + this->metroLabelCPUPer->Name = L"metroLabelCPUPer"; + this->metroLabelCPUPer->Size = System::Drawing::Size(74, 23); + this->metroLabelCPUPer->TabIndex = 34; + this->metroLabelCPUPer->Text = L"%"; + this->metroLabelCPUPer->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // - // metroLabelCurHDD + // metroLabelRAMPer // - this->metroLabelCurHDD->AutoSize = true; - this->metroLabelCurHDD->BackColor = System::Drawing::SystemColors::Control; - this->metroLabelCurHDD->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabelCurHDD->Location = System::Drawing::Point(579, 150); - this->metroLabelCurHDD->Name = L"metroLabelCurHDD"; - this->metroLabelCurHDD->Size = System::Drawing::Size(114, 30); - this->metroLabelCurHDD->TabIndex = 16; - this->metroLabelCurHDD->Text = L"-"; - this->metroLabelCurHDD->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; - this->metroLabelCurHDD->UseCustomBackColor = true; - this->metroLabelCurHDD->UseCustomForeColor = true; + this->metroLabelRAMPer->AutoSize = true; + this->metroLabelRAMPer->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabelRAMPer->Location = System::Drawing::Point(499, 138); + this->metroLabelRAMPer->Name = L"metroLabelRAMPer"; + this->metroLabelRAMPer->Size = System::Drawing::Size(74, 23); + this->metroLabelRAMPer->TabIndex = 35; + this->metroLabelRAMPer->Text = L"%"; + this->metroLabelRAMPer->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // // metroLabelCurNET // this->metroLabelCurNET->AutoSize = true; this->metroLabelCurNET->BackColor = System::Drawing::SystemColors::Control; this->metroLabelCurNET->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabelCurNET->Location = System::Drawing::Point(579, 180); + this->metroLabelCurNET->Location = System::Drawing::Point(579, 184); this->metroLabelCurNET->Name = L"metroLabelCurNET"; - this->metroLabelCurNET->Size = System::Drawing::Size(114, 32); - this->metroLabelCurNET->TabIndex = 17; + this->metroLabelCurNET->Size = System::Drawing::Size(114, 28); + this->metroLabelCurNET->TabIndex = 41; this->metroLabelCurNET->Text = L"-"; this->metroLabelCurNET->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; this->metroLabelCurNET->UseCustomBackColor = true; this->metroLabelCurNET->UseCustomForeColor = true; // - // metroTrackBarCPU - // - this->metroTrackBarCPU->BackColor = System::Drawing::Color::Transparent; - this->metroTrackBarCPU->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroTrackBarCPU->Location = System::Drawing::Point(308, 93); - this->metroTrackBarCPU->Name = L"metroTrackBarCPU"; - this->metroTrackBarCPU->Size = System::Drawing::Size(185, 24); - this->metroTrackBarCPU->TabIndex = 19; - this->metroTrackBarCPU->Text = L"metroTrackBar1"; - this->metroTrackBarCPU->Scroll += gcnew System::Windows::Forms::ScrollEventHandler(this, &MetroSettingsForm::metroTrackBarCPU_Scroll); - // - // metroTrackBarRAM - // - this->metroTrackBarRAM->BackColor = System::Drawing::Color::Transparent; - this->metroTrackBarRAM->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroTrackBarRAM->Location = System::Drawing::Point(308, 123); - this->metroTrackBarRAM->Name = L"metroTrackBarRAM"; - this->metroTrackBarRAM->Size = System::Drawing::Size(185, 24); - this->metroTrackBarRAM->TabIndex = 20; - this->metroTrackBarRAM->Text = L"metroTrackBar2"; - this->metroTrackBarRAM->Scroll += gcnew System::Windows::Forms::ScrollEventHandler(this, &MetroSettingsForm::metroTrackBarRAM_Scroll); + // metroLabelCurHDD // - // metroTextBoxHDD + this->metroLabelCurHDD->AutoSize = true; + this->metroLabelCurHDD->BackColor = System::Drawing::SystemColors::Control; + this->metroLabelCurHDD->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabelCurHDD->Location = System::Drawing::Point(579, 161); + this->metroLabelCurHDD->Name = L"metroLabelCurHDD"; + this->metroLabelCurHDD->Size = System::Drawing::Size(114, 23); + this->metroLabelCurHDD->TabIndex = 40; + this->metroLabelCurHDD->Text = L"-"; + this->metroLabelCurHDD->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + this->metroLabelCurHDD->UseCustomBackColor = true; + this->metroLabelCurHDD->UseCustomForeColor = true; // - this->metroTextBoxHDD->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroTextBoxHDD->Lines = gcnew cli::array< System::String^ >(1) { L" " }; - this->metroTextBoxHDD->Location = System::Drawing::Point(307, 152); - this->metroTextBoxHDD->Margin = System::Windows::Forms::Padding(2); - this->metroTextBoxHDD->MaxLength = 32767; - this->metroTextBoxHDD->Name = L"metroTextBoxHDD"; - this->metroTextBoxHDD->PasswordChar = '\0'; - this->metroTextBoxHDD->ScrollBars = System::Windows::Forms::ScrollBars::None; - this->metroTextBoxHDD->SelectedText = L""; - this->metroTextBoxHDD->Size = System::Drawing::Size(187, 26); - this->metroTextBoxHDD->TabIndex = 21; - this->metroTextBoxHDD->Text = L" "; - this->metroTextBoxHDD->TextAlign = System::Windows::Forms::HorizontalAlignment::Right; - this->metroTextBoxHDD->UseSelectable = true; - this->metroTextBoxHDD->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &MetroSettingsForm::ReformatTextBoxValueOnReturn); + // metroLabelCurRAM // - // metroTextBoxNET + this->metroLabelCurRAM->AutoSize = true; + this->metroLabelCurRAM->BackColor = System::Drawing::SystemColors::Control; + this->metroLabelCurRAM->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabelCurRAM->Location = System::Drawing::Point(579, 138); + this->metroLabelCurRAM->Name = L"metroLabelCurRAM"; + this->metroLabelCurRAM->Size = System::Drawing::Size(114, 23); + this->metroLabelCurRAM->TabIndex = 39; + this->metroLabelCurRAM->Text = L"-"; + this->metroLabelCurRAM->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + this->metroLabelCurRAM->UseCustomBackColor = true; + this->metroLabelCurRAM->UseCustomForeColor = true; // - this->metroTextBoxNET->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroTextBoxNET->Lines = gcnew cli::array< System::String^ >(1) { L" " }; - this->metroTextBoxNET->Location = System::Drawing::Point(307, 182); - this->metroTextBoxNET->Margin = System::Windows::Forms::Padding(2); - this->metroTextBoxNET->MaxLength = 32767; - this->metroTextBoxNET->Name = L"metroTextBoxNET"; - this->metroTextBoxNET->PasswordChar = '\0'; - this->metroTextBoxNET->ScrollBars = System::Windows::Forms::ScrollBars::None; - this->metroTextBoxNET->SelectedText = L""; - this->metroTextBoxNET->Size = System::Drawing::Size(187, 28); - this->metroTextBoxNET->TabIndex = 22; - this->metroTextBoxNET->Text = L" "; - this->metroTextBoxNET->TextAlign = System::Windows::Forms::HorizontalAlignment::Right; - this->metroTextBoxNET->UseSelectable = true; - this->metroTextBoxNET->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &MetroSettingsForm::ReformatTextBoxValueOnReturn); + // metroLabelCurCPU // - // metroToggleCPU + this->metroLabelCurCPU->AutoSize = true; + this->metroLabelCurCPU->BackColor = System::Drawing::SystemColors::Control; + this->metroLabelCurCPU->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabelCurCPU->ForeColor = System::Drawing::SystemColors::ControlText; + this->metroLabelCurCPU->Location = System::Drawing::Point(579, 115); + this->metroLabelCurCPU->Name = L"metroLabelCurCPU"; + this->metroLabelCurCPU->Size = System::Drawing::Size(114, 23); + this->metroLabelCurCPU->TabIndex = 38; + this->metroLabelCurCPU->Text = L"-"; + this->metroLabelCurCPU->TextAlign = System::Drawing::ContentAlignment::MiddleCenter; + this->metroLabelCurCPU->UseCustomBackColor = true; + this->metroLabelCurCPU->UseCustomForeColor = true; // - this->metroToggleCPU->Anchor = static_cast((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)); - this->metroToggleCPU->AutoSize = true; - this->metroToggleCPU->Location = System::Drawing::Point(83, 93); - this->metroToggleCPU->Name = L"metroToggleCPU"; - this->metroToggleCPU->Size = System::Drawing::Size(80, 24); - this->metroToggleCPU->TabIndex = 23; - this->metroToggleCPU->Text = L"Aus"; - this->metroToggleCPU->UseSelectable = true; + // metroLabel2 // - // metroToggleRAM + this->metroLabel2->AutoSize = true; + this->tableLayoutPanel3->SetColumnSpan(this->metroLabel2, 3); + this->metroLabel2->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabel2->FontWeight = MetroFramework::MetroLabelWeight::Regular; + this->metroLabel2->Location = System::Drawing::Point(3, 92); + this->metroLabel2->Name = L"metroLabel2"; + this->metroLabel2->Size = System::Drawing::Size(305, 23); + this->metroLabel2->TabIndex = 29; + this->metroLabel2->Text = L"System Usage Thresholds"; + this->metroLabel2->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // - this->metroToggleRAM->Anchor = static_cast((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)); - this->metroToggleRAM->AutoSize = true; - this->metroToggleRAM->Location = System::Drawing::Point(83, 123); - this->metroToggleRAM->Name = L"metroToggleRAM"; - this->metroToggleRAM->Size = System::Drawing::Size(80, 24); - this->metroToggleRAM->TabIndex = 24; - this->metroToggleRAM->Text = L"Aus"; - this->metroToggleRAM->UseSelectable = true; + // metroLabel3 // - // metroToggleHDD + this->metroLabel3->AutoSize = true; + this->metroLabel3->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabel3->FontWeight = MetroFramework::MetroLabelWeight::Regular; + this->metroLabel3->Location = System::Drawing::Point(579, 92); + this->metroLabel3->Name = L"metroLabel3"; + this->metroLabel3->Size = System::Drawing::Size(114, 23); + this->metroLabel3->TabIndex = 50; + this->metroLabel3->Text = L"Average Usage:"; + this->metroLabel3->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // - this->metroToggleHDD->Anchor = static_cast((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)); - this->metroToggleHDD->AutoSize = true; - this->metroToggleHDD->Location = System::Drawing::Point(83, 153); - this->metroToggleHDD->Name = L"metroToggleHDD"; - this->metroToggleHDD->Size = System::Drawing::Size(80, 24); - this->metroToggleHDD->TabIndex = 25; - this->metroToggleHDD->Text = L"Aus"; - this->metroToggleHDD->UseSelectable = true; + // metroToggleSOUND + // + this->metroToggleSOUND->Anchor = static_cast((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)); + this->metroToggleSOUND->AutoSize = true; + this->metroToggleSOUND->Location = System::Drawing::Point(83, 49); + this->metroToggleSOUND->Name = L"metroToggleSOUND"; + this->metroToggleSOUND->Size = System::Drawing::Size(80, 17); + this->metroToggleSOUND->TabIndex = 51; + this->metroToggleSOUND->Text = L"Aus"; + this->metroToggleSOUND->UseSelectable = true; + // + // metroLabel9 + // + this->metroLabel9->AutoSize = true; + this->tableLayoutPanel3->SetColumnSpan(this->metroLabel9, 2); + this->metroLabel9->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroLabel9->Location = System::Drawing::Point(169, 46); + this->metroLabel9->Name = L"metroLabel9"; + this->metroLabel9->Size = System::Drawing::Size(324, 23); + this->metroLabel9->TabIndex = 52; + this->metroLabel9->Text = L"Cancel Standby while Sound is Playing"; + this->metroLabel9->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // // metroToggleNET // - this->metroToggleNET->Anchor = static_cast((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)); this->metroToggleNET->AutoSize = true; - this->metroToggleNET->Location = System::Drawing::Point(83, 183); + this->metroToggleNET->Location = System::Drawing::Point(83, 189); + this->metroToggleNET->Margin = System::Windows::Forms::Padding(3, 5, 3, 3); this->metroToggleNET->Name = L"metroToggleNET"; - this->metroToggleNET->Size = System::Drawing::Size(80, 26); - this->metroToggleNET->TabIndex = 26; + this->metroToggleNET->Size = System::Drawing::Size(80, 17); + this->metroToggleNET->TabIndex = 49; this->metroToggleNET->Text = L"Aus"; this->metroToggleNET->UseSelectable = true; // - // metroTextBoxWAITTIME - // - this->metroTextBoxWAITTIME->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroTextBoxWAITTIME->Lines = gcnew cli::array< System::String^ >(0); - this->metroTextBoxWAITTIME->Location = System::Drawing::Point(307, 32); - this->metroTextBoxWAITTIME->Margin = System::Windows::Forms::Padding(2); - this->metroTextBoxWAITTIME->MaxLength = 32767; - this->metroTextBoxWAITTIME->Name = L"metroTextBoxWAITTIME"; - this->metroTextBoxWAITTIME->PasswordChar = '\0'; - this->metroTextBoxWAITTIME->ScrollBars = System::Windows::Forms::ScrollBars::None; - this->metroTextBoxWAITTIME->SelectedText = L""; - this->metroTextBoxWAITTIME->Size = System::Drawing::Size(187, 26); - this->metroTextBoxWAITTIME->TabIndex = 27; - this->metroTextBoxWAITTIME->TextAlign = System::Windows::Forms::HorizontalAlignment::Right; - this->metroTextBoxWAITTIME->UseSelectable = true; + // tableLayoutPanel10 + // + this->tableLayoutPanel10->ColumnCount = 4; + this->tableLayoutPanel3->SetColumnSpan(this->tableLayoutPanel10, 2); + this->tableLayoutPanel10->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 25))); + this->tableLayoutPanel10->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 25))); + this->tableLayoutPanel10->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 25))); + this->tableLayoutPanel10->ColumnStyles->Add((gcnew System::Windows::Forms::ColumnStyle(System::Windows::Forms::SizeType::Percent, + 25))); + this->tableLayoutPanel10->Controls->Add(this->metroLabel10, 0, 0); + this->tableLayoutPanel10->Controls->Add(this->metroTextBoxTimeMIN, 0, 0); + this->tableLayoutPanel10->Controls->Add(this->metroTextBoxTimeSEC, 2, 0); + this->tableLayoutPanel10->Controls->Add(this->metroLabel19, 3, 0); + this->tableLayoutPanel10->Dock = System::Windows::Forms::DockStyle::Fill; + this->tableLayoutPanel10->Location = System::Drawing::Point(311, 23); + this->tableLayoutPanel10->Margin = System::Windows::Forms::Padding(0); + this->tableLayoutPanel10->Name = L"tableLayoutPanel10"; + this->tableLayoutPanel10->RowCount = 1; + this->tableLayoutPanel10->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Percent, 100))); + this->tableLayoutPanel10->RowStyles->Add((gcnew System::Windows::Forms::RowStyle(System::Windows::Forms::SizeType::Absolute, + 23))); + this->tableLayoutPanel10->Size = System::Drawing::Size(265, 23); + this->tableLayoutPanel10->TabIndex = 53; // - // metroLabel3 + // metroLabel10 // - this->metroLabel3->AutoSize = true; - this->metroLabel3->Dock = System::Windows::Forms::DockStyle::Fill; - this->metroLabel3->FontWeight = MetroFramework::MetroLabelWeight::Regular; - this->metroLabel3->Location = System::Drawing::Point(579, 60); - this->metroLabel3->Name = L"metroLabel3"; - this->metroLabel3->Size = System::Drawing::Size(114, 30); - this->metroLabel3->TabIndex = 28; - this->metroLabel3->Text = L"Average Usage:"; - this->metroLabel3->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + this->metroLabel10->AutoSize = true; + this->metroLabel10->Location = System::Drawing::Point(69, 0); + this->metroLabel10->Name = L"metroLabel10"; + this->metroLabel10->Size = System::Drawing::Size(31, 19); + this->metroLabel10->TabIndex = 48; + this->metroLabel10->Text = L"min"; + this->metroLabel10->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; + // + // metroTextBoxTimeMIN + // + this->metroTextBoxTimeMIN->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroTextBoxTimeMIN->Lines = gcnew cli::array< System::String^ >(1) { L" " }; + this->metroTextBoxTimeMIN->Location = System::Drawing::Point(2, 2); + this->metroTextBoxTimeMIN->Margin = System::Windows::Forms::Padding(2); + this->metroTextBoxTimeMIN->MaxLength = 32767; + this->metroTextBoxTimeMIN->Name = L"metroTextBoxTimeMIN"; + this->metroTextBoxTimeMIN->PasswordChar = '\0'; + this->metroTextBoxTimeMIN->ScrollBars = System::Windows::Forms::ScrollBars::None; + this->metroTextBoxTimeMIN->SelectedText = L""; + this->metroTextBoxTimeMIN->Size = System::Drawing::Size(62, 19); + this->metroTextBoxTimeMIN->TabIndex = 46; + this->metroTextBoxTimeMIN->Text = L" "; + this->metroTextBoxTimeMIN->TextAlign = System::Windows::Forms::HorizontalAlignment::Right; + this->metroTextBoxTimeMIN->UseSelectable = true; + this->metroTextBoxTimeMIN->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &MetroSettingsForm::ReformatTextBoxValueOnReturn); + // + // metroTextBoxTimeSEC + // + this->metroTextBoxTimeSEC->Dock = System::Windows::Forms::DockStyle::Fill; + this->metroTextBoxTimeSEC->Lines = gcnew cli::array< System::String^ >(1) { L" " }; + this->metroTextBoxTimeSEC->Location = System::Drawing::Point(134, 2); + this->metroTextBoxTimeSEC->Margin = System::Windows::Forms::Padding(2); + this->metroTextBoxTimeSEC->MaxLength = 32767; + this->metroTextBoxTimeSEC->Name = L"metroTextBoxTimeSEC"; + this->metroTextBoxTimeSEC->PasswordChar = '\0'; + this->metroTextBoxTimeSEC->ScrollBars = System::Windows::Forms::ScrollBars::None; + this->metroTextBoxTimeSEC->SelectedText = L""; + this->metroTextBoxTimeSEC->Size = System::Drawing::Size(62, 19); + this->metroTextBoxTimeSEC->TabIndex = 47; + this->metroTextBoxTimeSEC->Text = L" "; + this->metroTextBoxTimeSEC->TextAlign = System::Windows::Forms::HorizontalAlignment::Right; + this->metroTextBoxTimeSEC->UseSelectable = true; + this->metroTextBoxTimeSEC->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &MetroSettingsForm::ReformatTextBoxValueOnReturn); + // + // metroLabel19 + // + this->metroLabel19->AutoSize = true; + this->metroLabel19->Location = System::Drawing::Point(201, 0); + this->metroLabel19->Name = L"metroLabel19"; + this->metroLabel19->Size = System::Drawing::Size(14, 19); + this->metroLabel19->TabIndex = 49; + this->metroLabel19->Text = L"s"; + this->metroLabel19->TextAlign = System::Drawing::ContentAlignment::MiddleLeft; // // metroLabel16 // @@ -1158,6 +1235,8 @@ namespace StandBye { this->tableLayoutPanel2->PerformLayout(); this->tableLayoutPanel3->ResumeLayout(false); this->tableLayoutPanel3->PerformLayout(); + this->tableLayoutPanel10->ResumeLayout(false); + this->tableLayoutPanel10->PerformLayout(); this->metroTabPage2->ResumeLayout(false); this->tableLayoutPanel5->ResumeLayout(false); this->tableLayoutPanel6->ResumeLayout(false); @@ -1183,7 +1262,6 @@ namespace StandBye { System::Void MetroSettingsForm_Load(System::Object^ sender, System::EventArgs^ e); System::Void metroTrackBarRAM_Scroll(System::Object^ sender, System::Windows::Forms::ScrollEventArgs^ e); System::Void metroTrackBarCPU_Scroll(System::Object^ sender, System::Windows::Forms::ScrollEventArgs^ e); - System::Void metroTextBoxWAITTIME_TextChanged(System::Object^ sender, System::EventArgs^ e); System::Void metroButtonOK_Click(System::Object^ sender, System::EventArgs^ e); System::Void metroButtonCancel_Click(System::Object^ sender, System::EventArgs^ e); @@ -1206,13 +1284,11 @@ namespace StandBye { System::Void metroTileHomepage_Click(System::Object^ sender, System::EventArgs^ e); System::Void metroTileGithub_Click(System::Object^ sender, System::EventArgs^ e); System::Void metroLinkHomepage_Click(System::Object^ sender, System::EventArgs^ e); + void changeLabelBackgroundColor(MetroFramework::Controls::MetroLabel^ label, double SettingsValue, double readValue); - bool isNumber(std::string text); + //Formatters double getTextBoxValueAsDouble(MetroFramework::Controls::MetroTextBox^ box); void setTextBoxValue(MetroFramework::Controls::MetroTextBox^ box, double value); - - void changeLabelBackgroundColor(MetroFramework::Controls::MetroLabel^ label, double SettingsValue, double readValue); - System::Void ReformatTextBoxValueOnReturn(System::Object ^sender, System::Windows::Forms::KeyEventArgs ^e); }; } diff --git a/SourceCode/ProcessItem.cpp b/SourceCode/ProcessItem.cpp index 7266e43..517534e 100644 --- a/SourceCode/ProcessItem.cpp +++ b/SourceCode/ProcessItem.cpp @@ -3,12 +3,13 @@ ProcessItem::ProcessItem(const string settings_value, Windows::Forms::ListView^ list) { path = gcnew String(settings_value.c_str()); - SHFILEINFO* stFileInfo = new SHFILEINFO; + SHFILEINFO* stFileInfo = new SHFILEINFO(); SHGetFileInfo(settings_value.c_str(), FILE_ATTRIBUTE_NORMAL, stFileInfo, sizeof(stFileInfo), SHGFI_ICON | SHGFI_LARGEICON); try { icon = Bitmap::FromHicon((IntPtr)stFileInfo->hIcon); } - catch (System::ArgumentException^ e) { + catch (System::ArgumentException^) { + //Icon loaded failed } addIconToLists(list); this->Text = IO::Path::GetFileNameWithoutExtension(path); diff --git a/SourceCode/ProcessSelectionForm.cpp b/SourceCode/ProcessSelectionForm.cpp index aa0d071..ef37fbf 100644 --- a/SourceCode/ProcessSelectionForm.cpp +++ b/SourceCode/ProcessSelectionForm.cpp @@ -2,7 +2,7 @@ #include "ProcessSelectionForm.h" using namespace StandBye; -System::Void ProcessSelectionForm::ProcessSelectionForm_Load(System::Object^ sender, System::EventArgs^ e) { +System::Void ProcessSelectionForm::ProcessSelectionForm_Load(System::Object^, System::EventArgs^) { tableLayoutPanel1->Visible = false; listViewProc->Font = BasicFunc::getMetroFont(9); @@ -14,7 +14,7 @@ System::Void ProcessSelectionForm::ProcessSelectionForm_Load(System::Object^ se listViewProc->LargeImageList = imglistLarge; } -System::Void ProcessSelectionForm::metroButtonOK_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void ProcessSelectionForm::metroButtonOK_Click(System::Object^, System::EventArgs^) { if (listViewProc->SelectedItems->Count > 0) { ProcessItem^ p = (ProcessItem^)listViewProc->SelectedItems[0]; selectedProcessPath = p->GetPath(); @@ -25,11 +25,11 @@ System::Void ProcessSelectionForm::metroButtonOK_Click(System::Object^ sender, } this->Close(); } -System::Void ProcessSelectionForm::metroButtonCancel_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void ProcessSelectionForm::metroButtonCancel_Click(System::Object^, System::EventArgs^) { this->DialogResult = Windows::Forms::DialogResult::Cancel; this->Close(); } -System::Void ProcessSelectionForm::ProcessSelectioNForm_OnShown(System::Object ^sender, System::EventArgs ^e) { +System::Void ProcessSelectionForm::ProcessSelectioNForm_OnShown(System::Object ^, System::EventArgs ^) { for each(std::string path in SystemAccess::GetRunningProccesses()) { listViewProc->Items->Add(gcnew ProcessItem(path, listViewProc)); Application::DoEvents(); diff --git a/SourceCode/ProcessSelectionForm.h b/SourceCode/ProcessSelectionForm.h index 930c518..6802567 100644 --- a/SourceCode/ProcessSelectionForm.h +++ b/SourceCode/ProcessSelectionForm.h @@ -1,5 +1,5 @@ #pragma once -#include "BasicFunc.h" +#include "stdafx.h" #include "SystemAccess.h" #include "ProcessItem.h" diff --git a/SourceCode/Setting.h b/SourceCode/Setting.h index 159bb7d..ecb267b 100644 --- a/SourceCode/Setting.h +++ b/SourceCode/Setting.h @@ -1,6 +1,5 @@ #pragma once #include "stdafx.h" -#include "BasicFunc.h" #include #include @@ -8,12 +7,12 @@ using std::string; using std::vector; enum class SettingName { - MAX_CPU, MAX_HDD, MAX_NET, MAX_RAM, WAIT_TIME, PROC_EXCP, NET_ADAPT, USE_CPU, USE_HDD, USE_NET, USE_RAM + MAX_CPU, MAX_HDD, MAX_NET, MAX_RAM, WAIT_TIME, PROC_EXCP, NET_ADAPT, USE_CPU, USE_HDD, USE_NET, USE_RAM, CHECK_SOUND }; class Setting { private: - const vector NAME_STRINGS = { "MAX_CPU", "MAX_HDD", "MAX_NET", "MAX_RAM", "WAIT_TIME", "PROC_EXCP", "NET_ADAPT", "USE_CPU", "USE_HDD", "USE_NET", "USE_RAM" }; + const vector NAME_STRINGS = { "MAX_CPU", "MAX_HDD", "MAX_NET", "MAX_RAM", "WAIT_TIME", "PROC_EXCP", "NET_ADAPT", "USE_CPU", "USE_HDD", "USE_NET", "USE_RAM", "CHECK_SOUND" }; string ConvertSettingNameToString(SettingName n); vector value; SettingName name; diff --git a/SourceCode/SettingsProvider.cpp b/SourceCode/SettingsProvider.cpp index 99608c2..3f502d5 100644 --- a/SourceCode/SettingsProvider.cpp +++ b/SourceCode/SettingsProvider.cpp @@ -9,10 +9,10 @@ SettingsProvider::SettingsProvider() { //Load settings if (loadSettings() == false || ((int)SettingsList.size() != SETTINGS_COUNT)) { //File does not exists or has not excepted number of settings - DEBUG("Settings file could not be loaded or configuration is corrupt!"); + LOG("Settings file could not be loaded or configuration is corrupt!"); repairFile(); if (loadSettings() == false) { - DEBUG("Settings could not be repaired!"); + LOG("Settings could not be repaired!"); } }; }; @@ -30,8 +30,8 @@ string SettingsProvider::getRawSetting(SettingName name) { return SettingsProvider::getSettingbyName(name)->GetValue().at(0); } catch (Exception^ e) { - DEBUG("Could not get Raw Setting!"); - DEBUG(e->Data + "\n" + e->InnerException + "\n" + e->Message); + LOG("Could not get Raw Setting!"); + LOG(e->Data + "\n" + e->InnerException + "\n" + e->Message); return ""; } } @@ -41,9 +41,8 @@ int SettingsProvider::getThreshold(SettingName name) { return BasicFunc::StringToInt(SettingsProvider::getRawSetting(name)); } else { + LOG("The number of the enumerator should be between 0 and 4"); throw("No Threshold with this name could be found!"); - BasicFunc::Print("The number of the enumerator should be between 0 and 4"); - return 0; } }; @@ -52,9 +51,8 @@ bool SettingsProvider::isActive(SettingName name) { return (SettingsProvider::getRawSetting(name) == "TRUE"); } else { + LOG("The name should be greater than 6!"); throw("No valid name entered! Could not convert to boolean!"); - BasicFunc::Print("The name should be greater than 6!"); - return NULL; } } @@ -87,7 +85,7 @@ void SettingsProvider::addProcessToProcessList(const string process) { getSettingbyName(SettingName::PROC_EXCP)->AddValue(process); } else { - DEBUG("Process already added"); + LOG("Process already added"); } }; @@ -98,15 +96,16 @@ void SettingsProvider::removeProcessFromProcessList(const string process) { bool SettingsProvider::reset() { //Resets to DEFAULT values SettingsList.clear(); + SettingsList.push_back(new Setting(SettingName::WAIT_TIME, WAIT_TIME_DEFAULT)); SettingsList.push_back(new Setting(SettingName::USE_CPU, "TRUE")); SettingsList.push_back(new Setting(SettingName::MAX_CPU, MAX_CPU_DEFAULT)); + SettingsList.push_back(new Setting(SettingName::USE_RAM, "TRUE")); + SettingsList.push_back(new Setting(SettingName::MAX_RAM, MAX_RAM_DEFAULT)); SettingsList.push_back(new Setting(SettingName::USE_HDD, "TRUE")); SettingsList.push_back(new Setting(SettingName::MAX_HDD, MAX_HDD_DEFAULT)); SettingsList.push_back(new Setting(SettingName::USE_NET, "TRUE")); SettingsList.push_back(new Setting(SettingName::MAX_NET, MAX_NET_DEFAULT)); - SettingsList.push_back(new Setting(SettingName::USE_RAM, "TRUE")); - SettingsList.push_back(new Setting(SettingName::MAX_RAM, MAX_RAM_DEFAULT)); - SettingsList.push_back(new Setting(SettingName::WAIT_TIME, WAIT_TIME_DEFAULT)); + SettingsList.push_back(new Setting(SettingName::CHECK_SOUND, "TRUE")); SettingsList.push_back(new Setting(SettingName::PROC_EXCP, PROC_EXCP_DEFAULT)); return writeSettingsFile(); } @@ -114,7 +113,12 @@ bool SettingsProvider::reset() { bool SettingsProvider::saveSettingsToFile() { return writeSettingsFile(); -}; +} +vector SettingsProvider::getAllSettings() +{ + return SettingsList; +} +; bool SettingsProvider::repairFile() { std::ifstream sFile(SettingsProvider::getSettingsFilePath()); @@ -126,7 +130,7 @@ bool SettingsProvider::repairFile() { else { //Folder does not exist --> Creating Folder string StandByeFolderPath = SettingsProvider::getStandByeFolderPath(); - _mkdir(StandByeFolderPath.c_str()); + System::IO::Directory::CreateDirectory(gcnew String(StandByeFolderPath.c_str())); return SettingsProvider::reset(); } return false; @@ -146,7 +150,7 @@ bool SettingsProvider::writeSettingsFile() { if (all_values == "") { all_values = "''"; } - BasicFunc::Print("Written Setting ['" + set->GetNameAsString() + "'] with value [" + all_values + "]" + "\n"); + LOG("Written Setting ['" + set->GetNameAsString() + "'] with value [" + all_values + "]"); sFile << set->GetNameAsString() << "=" << all_values << std::endl; } sFile.close(); @@ -154,7 +158,7 @@ bool SettingsProvider::writeSettingsFile() { } else { //SettingsFile could not be opened! - BasicFunc::Print("SettingsFile could not be opened to write Settings!"); + LOG("SettingsFile could not be opened to write Settings!"); throw("SettingsFile could not be opened to write Settings!"); return false; } @@ -178,7 +182,7 @@ bool SettingsProvider::loadSettings() { } else { repairFile(); - BasicFunc::Print("Loading settings failed! Resetting File to Standard"); + LOG("Loading settings failed! Resetting File to Standard"); return loadSettings(); } @@ -189,14 +193,14 @@ bool SettingsProvider::loadSettings() { // Creates new Setting SettingsList.push_back(new Setting(name, value)); - BasicFunc::Print("Loaded Setting ['" + name + "'] with value ['" + raw_values + "']\n"); + LOG("Loaded Setting ['" + name + "'] with value ['" + raw_values + "']"); } sFile.close(); return true; } else { //File could not be opened! - BasicFunc::Print("SettingsFile could not be opened!"); + LOG("SettingsFile could not be opened!"); return false; } }; @@ -231,7 +235,7 @@ Setting* SettingsProvider::getSettingbyName(SettingName name) { return SettingsProvider::getSettingbyName(name); } - DEBUG("Invalid settingName entered!"); - DEBUG("Could not get Setting!"); + LOG("Invalid settingName entered!"); + LOG("Could not get Setting!"); return nullptr; }; \ No newline at end of file diff --git a/SourceCode/SettingsProvider.h b/SourceCode/SettingsProvider.h index a08ce6b..82539cd 100644 --- a/SourceCode/SettingsProvider.h +++ b/SourceCode/SettingsProvider.h @@ -1,13 +1,11 @@ #pragma once #include "stdafx.h" #include "Setting.h" -#include "BasicFunc.h" #include #include #include //To delete ' in strings #include #include -#include // For creating folders #define MAX_CPU_DEFAULT "30" /*in percent*/ #define MAX_HDD_DEFAULT "2000" /*in kBytes/s*/ @@ -15,7 +13,7 @@ #define MAX_RAM_DEFAULT "20" /*in percent*/ #define WAIT_TIME_DEFAULT "300" /*in seconds*/ #define PROC_EXCP_DEFAULT "" /*paths to exception processes*/ -#define SETTINGS_COUNT 10 /*to check amount of settings in file*/ +#define SETTINGS_COUNT 11 /*to check amount of settings in file*/ using namespace System; using namespace System::ComponentModel; @@ -78,6 +76,9 @@ class SettingsProvider { ///Saves settings to the save file bool saveSettingsToFile(); + ///Returns all currently loaded settings + vector getAllSettings(); + private: bool writeSettingsFile(); diff --git a/SourceCode/SmartLogout.rc b/SourceCode/SmartLogout.rc new file mode 100644 index 0000000000000000000000000000000000000000..62085b4cb04bdc6cb36bb3cd19fb41c3a6817df4 GIT binary patch literal 5356 zcmdUzS#Kgo5Xb8|Qochke#t7EwefnB=jAX$!NxL}B$6eI7#~PBSR5N$%4bjV`*+jK z!GL9w2cp){)7^DfbyW?2|Fv)X=Iq3Vc5M?I+mz?lX6*IYo7&v^_Q0xY-!q)u*^P~O zChX6c2kcFlg*WHzns>)a)Q0v1%t!myzJbfWpZC}uaryxCz{8eS@XO%bTgk%yp?aU z)7T!-e};8rhb~(G%5M{`tLQ0v)Y(7e$@}DWFZ|){8}PFB-#v>(i9&SDv6W)!7QMHN zjcEBucemy!U5JYbG0;b2XW#iaiR%}8U*Pv?>J|;Xh2CXu(*P=8?3g$Tx2VI7x!^uk ziKHvysl^c8KN)T{r z(m!}w8m#xU?m-Xve}-4>e|P7LZ*%m0v_TnL6+=3&aRuEQJ|hUjEylVWdua!YJX^HYmz0tML}S zv|ITjEsZ49I?j$*xu&j+mOE)3l2hlssLJE0-D6g&`RWsz#ErABzE7C@y7UA@-**D) z4pg@%3)mT$&RbZWg=&oh@`>>P)HUxjW=Z4xIxSbIY07=-Af`YBxu>ipi7KY#3E1jd z)VECSWpVn*9IBusZj!5-WI1&Vx>K7*gxds@J}WI{S0^LA#;I;5&s}$I)7YN-VFCB( z_jF9`&U=(D&gw$dYs$yzScoy&qi$RQQ>XfL@Ta^fzn)Uj+E_Jv68DAefM`;0>Nyxk zM*Lt$Jcm4={jG5Ho9EE0QKPEl#Vplgj7a_1*R%%Gsn&I6Puz=^r>>ltRJBk+ zD{yKoc&}0l6v|8d8zOy*ow9l*oCEwp3SRw^xMnfh$QNLbkWu4kfsh_S%_V!+BJ~5Z$PtgS$>%poFTW`-PneaDU$f3fV4r!4y;E$V7VvkTx;*iO zjTJq2)T!Ch3#%vUovXgDJtP{+_9MPLM#8bj4&8MHs(s&WPP{i2nKy8_XIJ$}oYlFW zu%0pQ;oHYc&VJ!UHBXs8e#b`X^K&+u+6(Cw|FT&0zgC;$Y8%^~!EKC&bL5=8>K(hVM^(p+1ADimn=`FVrFLiuVURk^i?KMs3JCc}s+K)*e|2w~x=HyNz5|cd~h? zhs7sL`)`whvYK?Erns46nWW1JcTDvlISZStn`_1&ueL5N?5Z~0Q( zon9a>iS$iBp>A&a@?Y)G^E7v7EzKlNod4~AK>A+V{2x%X #include #include @@ -8,29 +7,32 @@ #include //To get Processes #include //To get Processes +using namespace System::Diagnostics; +using namespace System::Collections::Generic; using System::Windows::Forms::Timer; using System::Windows::Forms::Application; using System::Windows::Forms::PowerState; -using namespace System::Diagnostics; -using namespace System::Collections::Generic; +struct IAudioMeterInformation; //To avoid cross linking public ref class SystemAccess { private: + //Attributes PerformanceCounter^ perfCPU; PerformanceCounter^ perfHDD; List^ perfNETs; - SettingsProvider* setprov; - float getCpuUsage(); - float getRamUsage(); - float getNetworkUsage(); - float getHddUsage(); + + //Methods + float getCPUUsage(); + float getRAMUsage(); + float getNETUsage(); + float getHDDUsage(); public: SystemAccess(SettingsProvider* p); ~SystemAccess(); - enum class SystemMetric : char { CPU, RAM, NETWORK, HDD }; + enum class SystemMetric : char { CPU, RAM, NETWORK, HDD, SOUND }; float GetMetric(SystemMetric s); @@ -46,5 +48,7 @@ public ref class SystemAccess { static void SetAutoStart(boolean value); - static boolean IsInAutoStart(); + static bool IsInAutoStart(); + + static float getAudioPeak(); }; diff --git a/SourceCode/SystemMetricWatcher.cpp b/SourceCode/SystemMetricWatcher.cpp index d0be361..2890f6c 100644 --- a/SourceCode/SystemMetricWatcher.cpp +++ b/SourceCode/SystemMetricWatcher.cpp @@ -13,7 +13,7 @@ SystemMetricWatcher::SystemMetricWatcher(SettingsProvider* prov, int frequenzy, cpu_buffer = gcnew AverageBuffer(size); hdd_buffer = gcnew AverageBuffer(size); network_buffer = gcnew AverageBuffer(size); - + sound_buffer = gcnew AverageBuffer(size); system_access = gcnew SystemAccess(prov); } @@ -31,7 +31,7 @@ void SystemMetricWatcher::Stop() { void SystemMetricWatcher::Loop() { while (true) { - Sleep(float(1000.0f / frequenzy)); + Sleep((DWORD)float(1000.0f / frequenzy)); ReadValues(); } } @@ -46,6 +46,8 @@ float SystemMetricWatcher::GetSystemMetric(SystemAccess::SystemMetric s) { return ram_buffer->GetAverage(); case SystemAccess::SystemMetric::NETWORK: return network_buffer->GetAverage(); + case SystemAccess::SystemMetric::SOUND: + return sound_buffer->GetAverage(); default: return 0.0f; } @@ -59,4 +61,6 @@ void SystemMetricWatcher::ReadValues() { hdd_buffer->Put(system_access->GetMetric(SystemAccess::SystemMetric::HDD)); network_buffer->Put(system_access->GetMetric(SystemAccess::SystemMetric::NETWORK)); + + sound_buffer->Put(system_access->GetMetric(SystemAccess::SystemMetric::SOUND)); } \ No newline at end of file diff --git a/SourceCode/SystemMetricWatcher.h b/SourceCode/SystemMetricWatcher.h index 5dfccf9..4ee5884 100644 --- a/SourceCode/SystemMetricWatcher.h +++ b/SourceCode/SystemMetricWatcher.h @@ -16,7 +16,7 @@ public ref class SystemMetricWatcher { private: Thread^ background_thread; - AverageBuffer^ cpu_buffer, ^network_buffer, ^hdd_buffer, ^ram_buffer; + AverageBuffer^ cpu_buffer, ^network_buffer, ^hdd_buffer, ^ram_buffer, ^sound_buffer; SystemAccess^ system_access; void ReadValues(); int frequenzy; diff --git a/SourceCode/Systemaccess.cpp b/SourceCode/Systemaccess.cpp index 63d9571..fc9e077 100644 --- a/SourceCode/Systemaccess.cpp +++ b/SourceCode/Systemaccess.cpp @@ -1,13 +1,30 @@ #include "stdafx.h" + +//Has to be here! +#include // To get audio volume +#include // To get audio volume #include "SystemAccess.h" -float SystemAccess::getCpuUsage() { +#define EXIT_ON_ERROR(hr) \ +if (FAILED(hr)){LOG("AUDIO LEVEL DETECTION FAILED"); return 0.0f;} + +SystemAccess::SystemAccess(SettingsProvider* p) +{ + setprov = p; + perfCPU = gcnew PerformanceCounter("Processor", "% Processor Time", "_Total"); + perfHDD = gcnew PerformanceCounter("PhysicalDisk", "Disk Bytes/sec", "_Total"); + perfNETs = gcnew List; + for each(std::string name in SystemAccess::GetNetAdapterNames()) { + perfNETs->Add(gcnew PerformanceCounter("Network Interface", "Bytes Total/sec", gcnew String(name.c_str()))); + } +} +float SystemAccess::getCPUUsage() { //Note: performance counters need administrator privileges at Windows Vista float cpuUsage_percent = perfCPU->NextValue(); return cpuUsage_percent; } -float SystemAccess::getRamUsage() +float SystemAccess::getRAMUsage() { MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); @@ -17,7 +34,7 @@ float SystemAccess::getRamUsage() return (float)(100.0 * usedPhysMem / totalPhysMem); } -float SystemAccess::getNetworkUsage() { +float SystemAccess::getNETUsage() { float kbytes_per_sec = 0; for each(PerformanceCounter^ perf in *perfNETs) { kbytes_per_sec += perf->NextValue() / 1000; @@ -25,23 +42,12 @@ float SystemAccess::getNetworkUsage() { return kbytes_per_sec; } -float SystemAccess::getHddUsage() +float SystemAccess::getHDDUsage() { float kbytes_per_sec = perfHDD->NextValue() / 1000; return kbytes_per_sec; } -SystemAccess::SystemAccess(SettingsProvider* p) -{ - setprov = p; - perfCPU = gcnew PerformanceCounter("Processor", "% Processor Time", "_Total"); - perfHDD = gcnew PerformanceCounter("PhysicalDisk", "Disk Bytes/sec", "_Total"); - perfNETs = gcnew List; - for each(std::string name in SystemAccess::GetNetAdapterNames()) { - perfNETs->Add(gcnew PerformanceCounter("Network Interface", "Bytes Total/sec", gcnew String(name.c_str()))); - } -} - SystemAccess::~SystemAccess() { perfCPU->Close(); perfHDD->Close(); @@ -54,25 +60,27 @@ float SystemAccess::GetMetric(SystemMetric s) { try { switch (s) { case SystemMetric::CPU: - return getCpuUsage(); + return getCPUUsage(); case SystemMetric::RAM: - return getRamUsage(); + return getRAMUsage(); case SystemMetric::NETWORK: - return getNetworkUsage(); + return getNETUsage(); case SystemMetric::HDD: - return getHddUsage(); + return getHDDUsage(); + case SystemMetric::SOUND: + return getAudioPeak(); } } catch (Exception^ ex) { - DEBUG("Could not get Metric!"); - DEBUG("Error Details: " + ex->Message + "\n" + ex->Data + "\n" + ex->Source); + LOG("Could not get Metric!"); + LOG("Error Details: " + ex->Message + "\n" + ex->Data + "\n" + ex->Source); } return 0.0f; } void SystemAccess::StartESM() { - DEBUG("ESM will start now"); + LOG("ESM will start now"); /* Different Power-save modes: -Hibernate @@ -114,10 +122,10 @@ std::vector SystemAccess::GetRunningProccesses() { void SystemAccess::SetPresentationMode(boolean state) { if (state) { - SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED); + SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED); //Application requires screen and system online } else { - SetThreadExecutionState(ES_CONTINUOUS); + SetThreadExecutionState(ES_CONTINUOUS); //reset the requirements } } @@ -135,7 +143,7 @@ void SystemAccess::SetAutoStart(boolean value) { } } -boolean SystemAccess::IsInAutoStart() { +bool SystemAccess::IsInAutoStart() { String^ path = "\"" + Application::ExecutablePath + "\""; using namespace Microsoft::Win32; RegistryKey^ rk; @@ -153,6 +161,30 @@ boolean SystemAccess::IsInAutoStart() { } } +float SystemAccess::getAudioPeak() +{ + //Requires Win Vista, , and ole32.lib, needs to be in method to convert MeterInformation to void** + float peak = 0; + HRESULT hr; + IMMDeviceEnumerator *pEnumerator = NULL; + IMMDevice *pDevice = NULL; //Get Audio Interface + IAudioMeterInformation *pMeterInfo = NULL; + hr = CoInitialize(NULL); + // Get enumerator for audio endpoint devices. + hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), + NULL, CLSCTX_INPROC_SERVER, + __uuidof(IMMDeviceEnumerator), + (void**)&pEnumerator); + EXIT_ON_ERROR(hr); + hr = pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pDevice); + EXIT_ON_ERROR(hr); + hr = pDevice->Activate(__uuidof(IAudioMeterInformation), + CLSCTX_ALL, NULL, (void**)&pMeterInfo); + EXIT_ON_ERROR(hr); + pMeterInfo->GetPeakValue(&peak); //Gets peak value + return peak; +} + std::vector SystemAccess::GetNetAdapterNames() { System::String ^filter = gcnew System::String("MS TCP Loopback interface"); std::vector *nics = new std::vector(); diff --git a/SourceCode/TimeoutWindow.cpp b/SourceCode/TimeoutWindow.cpp index 1b2b9e4..9e4f575 100644 --- a/SourceCode/TimeoutWindow.cpp +++ b/SourceCode/TimeoutWindow.cpp @@ -36,7 +36,7 @@ System::Void TimeoutWindow::RefreshUI(System::Object^, System::EventArgs^) { if (past_millis < delay) { metroButtonCancel->Text = "Cancel [" + Math::Truncate((delay - past_millis) / 1000).ToString() + "]"; this->metroLabelTime->Text = String::Format("{0:0.00}s", (double)(delay - past_millis) / 1000); - metroProgressBar1->Value = 100 - Math::Truncate(((double)past_millis / (double)delay) * 100); + metroProgressBar1->Value = 100 - (int)Math::Truncate(((double)past_millis / (double)delay) * 100); counter++; this->BringToFront(); } @@ -45,11 +45,11 @@ System::Void TimeoutWindow::RefreshUI(System::Object^, System::EventArgs^) { this->Close(); } } -System::Void TimeoutWindow::metroButtonOK_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void TimeoutWindow::metroButtonOK_Click(System::Object^, System::EventArgs^) { this->DialogResult = Windows::Forms::DialogResult::OK; this->Close(); } -System::Void TimeoutWindow::metroButtonCancel_Click(System::Object^ sender, System::EventArgs^ e) { +System::Void TimeoutWindow::metroButtonCancel_Click(System::Object^, System::EventArgs^) { this->DialogResult = Windows::Forms::DialogResult::Cancel; this->Close(); } \ No newline at end of file diff --git a/SourceCode/TimeoutWindow.h b/SourceCode/TimeoutWindow.h index 7ef7927..548cee5 100644 --- a/SourceCode/TimeoutWindow.h +++ b/SourceCode/TimeoutWindow.h @@ -19,7 +19,7 @@ namespace StandBye { public ref class TimeoutWindow : public MetroFramework::Forms::MetroForm { int delay; // in milliseconds - double startTime; //in milliseconds + int startTime; //in milliseconds System::Windows::Forms::Timer^ timer; SettingsProvider* settings_provider; int counter; diff --git a/SourceCode/setting.cpp b/SourceCode/setting.cpp index 2887d1e..91320d0 100644 --- a/SourceCode/setting.cpp +++ b/SourceCode/setting.cpp @@ -18,7 +18,7 @@ SettingName Setting::ConvertStringToSettingName(string name) { counter++; } //The name was not valid - BasicFunc::Print("No valid name entered!"); + LOG("No valid name entered!"); throw("Failed to convert string to SettingName. No valid string entered!"); } diff --git a/SourceCode/standbye_main.cpp b/SourceCode/standbye_main.cpp index 3665e6d..740582e 100644 --- a/SourceCode/standbye_main.cpp +++ b/SourceCode/standbye_main.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "standbye_main.h" +#include "DebugForm.h" //Has to be here --> cross linking #define threshold(X) settings_provider->getThreshold(SettingName::X) #define active(X) settings_provider->isActive(SettingName::X) @@ -9,6 +10,7 @@ using namespace StandBye; [STAThread] //Because of FileDialog --> Application is single threaded - Windows needs that int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR, int) { mainApplication^ standbye = gcnew mainApplication(hInstance); + delete standbye; } NotifyIconAppContext::NotifyIconAppContext(mainApplication^ app, HINSTANCE hinst) { @@ -17,21 +19,30 @@ NotifyIconAppContext::NotifyIconAppContext(mainApplication^ app, HINSTANCE hinst void mainApplication::OpenSettings(Object^, System::EventArgs^) { using namespace StandBye; + LOG("Open Settings..."); if (settingsForm->Visible) { return; } if (settingsForm->ShowDialog() == ::DialogResult::OK) { input_monitor->Reset(); + LOG("SettingsForm returned OK"); + } + else { + LOG("SettingsForm returned Cancel"); } //Recreates SettingsForm settingsForm = gcnew MetroSettingsForm(system_watcher, settings_provider); settingsForm->Visible = false; + LOG("Reloaded SettingsForm (invisible)"); } void mainApplication::Quit(Object^, System::EventArgs^) { + LOG("Application starts quitting..."); onExit = true; input_monitor->Stop(); + LOG("Stopped InputMonitor"); delete system_watcher, input_monitor, settings_provider; + LOG("ByeBye..."); System::Windows::Forms::Application::Exit(); } @@ -40,11 +51,13 @@ void mainApplication::SetPresentationMode(Object^ s, System::EventArgs ^) MenuItem^ item = (MenuItem^)s; if (item->Checked == false) { SystemAccess::SetPresentationMode(true); + LOG("Presentation mode enabled"); item->Checked = true; trayicon->ShowBalloonTip(3000, "Stand-Bye!", "The Presentation mode has been activated!", System::Windows::Forms::ToolTipIcon::Info); } else { SystemAccess::SetPresentationMode(false); + LOG("Presentation mode disabled"); trayicon->ShowBalloonTip(3000, "Stand-Bye!", "The Presentation mode has been deactivated!", System::Windows::Forms::ToolTipIcon::Info); item->Checked = false; } @@ -52,8 +65,9 @@ void mainApplication::SetPresentationMode(Object^ s, System::EventArgs ^) } void mainApplication::CheckUsage() { + //Checks if the application is in presentation mode if (inPresentationMode) { - DEBUG("Application in presentation mode! \n Canceled Sleep mode!"); + LOG("Application in presentation mode! \n Canceled Sleep mode!"); return; } //Check if an exception process is running @@ -66,26 +80,58 @@ void mainApplication::CheckUsage() { } if (exception_process_running) { - DEBUG("An exception process is running! \n Canceled Sleep mode!"); + LOG("An exception process is running! \n Canceled Sleep mode!"); return; } + //Check if sound is playing + if ((bool)active(CHECK_SOUND)) { + if (sysMetric(SOUND) > 0.1) { + LOG("SOUND level too high - standby canceled"); + return; + } + } + //Check Thresholds + //CPU + if ((bool)active(USE_CPU)) { + if (threshold(MAX_CPU) < sysMetric(CPU)) { + LOG("CPU Usage too high - standby canceled"); + return; + } + + } + //RAM + if ((bool)active(USE_RAM)) { + if (threshold(MAX_RAM) < sysMetric(RAM)) { + LOG("RAM Usage too high - standby canceled"); + return; + } + } + //HDD + if ((bool)active(USE_HDD)) { + if (threshold(MAX_HDD) < sysMetric(HDD)) { + LOG("HDD Usage too high - standby canceled"); + return; + } + } + //NET + if ((bool)active(USE_NET)) { + if (threshold(MAX_NET) < sysMetric(NETWORK)) { + LOG("NETWORK Usage too high - standby canceled"); return; + } + } - if (((bool)active(USE_HDD) ? threshold(MAX_HDD) < sysMetric(HDD) : false))return; - if (((bool)active(USE_CPU) ? threshold(MAX_CPU) < sysMetric(CPU) : false))return; - if (((bool)active(USE_RAM) ? threshold(MAX_RAM) < sysMetric(RAM) : false))return; - if (((bool)active(USE_NET) ? threshold(MAX_NET) < sysMetric(NETWORK) : false)) return; + //If the method has reached this point, the standby can be started TimeoutWindow^ msgWnd = gcnew TimeoutWindow(15, settings_provider); - - if ((msgWnd->ShowDialog()) == (::DialogResult::OK)) { - DEBUG("Going to Sleep mode!"); + LOG("Preparing the TimeoutWindow"); + if (msgWnd->ShowDialog() == DialogResult::OK) { + LOG("Going to Sleep mode!"); SystemAccess::StartESM(); } else { - DEBUG("The User has canceled the MessageWindow!"); - + LOG("The User has canceled the MessageWindow!"); //Asks User if he wants to enable presentation mode MessageWindow^ msgPres = gcnew MessageWindow("Do you like to enable the presentation mode?" + "\n" + "There will be no more interruptions!"); if (msgPres->ShowDialog() == DialogResult::OK) { @@ -113,12 +159,17 @@ ContextMenu^ mainApplication::GetContextMenu() { PresentationModeItem->Checked = false; PresentationModeItem->Click += gcnew System::EventHandler(this, &mainApplication::SetPresentationMode); + MenuItem^ debuggig = gcnew MenuItem(); + debuggig->Text = "&Debugging\0"; + debuggig->Click += gcnew System::EventHandler(this, &mainApplication::OpenDebugForm); + MenuItem^ exitItem = gcnew MenuItem(); exitItem->Text = "&Exit\0"; exitItem->Click += gcnew System::EventHandler(this, &mainApplication::Quit); contextMenu->MenuItems->Add(settingsItem); contextMenu->MenuItems->Add(PresentationModeItem); + contextMenu->MenuItems->Add(debuggig); contextMenu->MenuItems->Add(exitItem); return contextMenu; @@ -136,33 +187,50 @@ NotifyIcon^ mainApplication::GenerateIcon(HINSTANCE hInstance) { return trayicon; } -void mainApplication::OnThreadException(System::Object ^ sender, System::Threading::ThreadExceptionEventArgs ^ args) { - //TODO: Implement on exception --> Log system +void mainApplication::OnThreadException(System::Object ^, System::Threading::ThreadExceptionEventArgs ^e) { + LOG(e->Exception->Message + "\n"+ + e->Exception->Data + "\n" + + e->Exception->StackTrace + "\n" + + e->Exception->InnerException + + e->Exception->HelpLink + "\n"); } mainApplication::mainApplication(HINSTANCE hInstance) { + LOG("Stand-Bye starts now!"); Application::ThreadException += gcnew System::Threading::ThreadExceptionEventHandler(this, &mainApplication::OnThreadException); - //Application::SetUnhandledExceptionMode(ThrowException) + Application::SetUnhandledExceptionMode(UnhandledExceptionMode::CatchException); onExit = false; while (onExit == false) { settings_provider = new SettingsProvider(); + LOG("Loaded settingsProvider"); system_watcher = gcnew SystemMetricWatcher(settings_provider, 2, 30);//Sample 2 times/second, space for 30 samples, average over 15 seconds system_watcher->Start(); + LOG("Loaded and Started SystemMetricWatcher"); input_monitor = gcnew InputMonitor(this, settings_provider); + LOG("Loaded InputMonitor"); settingsForm = gcnew MetroSettingsForm(system_watcher, settings_provider); settingsForm->Visible = false; + LOG("Loaded invisible SettingsForm"); using System::Windows::Forms::Application; ApplicationContext^ context = gcnew NotifyIconAppContext(this, hInstance); Application::ApplicationExit += gcnew System::EventHandler(this, &mainApplication::Quit); Application::Run(context); //Synchronous + LOG("!!Application exited"); } } -void mainApplication::OnMouseClick(System::Object ^sender, System::Windows::Forms::MouseEventArgs ^e) +void mainApplication::OnMouseClick(System::Object ^, System::Windows::Forms::MouseEventArgs ^e) { if (e->Button == Windows::Forms::MouseButtons::Left) { mainApplication::OpenSettings(nullptr, nullptr); } +} + +void mainApplication::OpenDebugForm(System::Object ^, System::EventArgs ^) +{ + LOG("Open DEBUG Form"); + DebugForm^ debug_form = gcnew DebugForm(this, settings_provider, input_monitor, system_watcher); + debug_form->Show(); } \ No newline at end of file diff --git a/SourceCode/standbye_main.h b/SourceCode/standbye_main.h index b3b7601..59281e2 100644 --- a/SourceCode/standbye_main.h +++ b/SourceCode/standbye_main.h @@ -1,26 +1,23 @@ #pragma once #include "stdafx.h" #include "resource1.h" -#include -#include #include "TimeoutWindow.h" #include "SystemAccess.h" #include "SystemMetricWatcher.h" #include "MetroSettingsForm.h" #include "MessageWindow.h" #include "InputMonitor.h" -using namespace StandBye; int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow); - -ref class mainApplication { +using namespace StandBye; +public ref class mainApplication { private: - MetroSettingsForm^ settingsForm; NotifyIcon^ trayicon; MenuItem^ PresentationModeItem; //Has to be accessed - + MetroSettingsForm^ settingsForm; SystemMetricWatcher^ system_watcher; SettingsProvider* settings_provider; + SystemAccess^ system_access; InputMonitor^ input_monitor; bool inPresentationMode; @@ -30,6 +27,7 @@ ref class mainApplication { mainApplication(HINSTANCE hInstance); NotifyIcon^ GenerateIcon(HINSTANCE hInstance); void CheckUsage(); + private: void OpenSettings(Object^ s, System::EventArgs^ event_args); void Quit(Object^ s, System::EventArgs^ event_args); @@ -37,6 +35,7 @@ ref class mainApplication { ContextMenu^ GetContextMenu(); void OnThreadException(System::Object^ sender, System::Threading::ThreadExceptionEventArgs^ args); void OnMouseClick(System::Object ^sender, System::Windows::Forms::MouseEventArgs ^e); + void OpenDebugForm(System::Object ^sender, System::EventArgs ^e); }; ref class NotifyIconAppContext : System::Windows::Forms::ApplicationContext { diff --git a/SourceCode/stdafx.h b/SourceCode/stdafx.h index 181d85a..0f79532 100644 --- a/SourceCode/stdafx.h +++ b/SourceCode/stdafx.h @@ -1,8 +1,9 @@ #pragma once //#include #include +#include "BasicFunc.h" #define TRAY_ICON_MSG (WM_USER + 1) -#ifndef DEBUG -#define DEBUG(s) System::Diagnostics::Debug::WriteLine(s); +#ifndef LOG +#define LOG(s) BasicFunc::Log(s) #define APPLICATION_NAME "Stand-Bye!" #endif // !DEBUG(s)