-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+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
- Loading branch information
Showing
28 changed files
with
2,042 additions
and
502 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
Oops, something went wrong.