Skip to content

Commit

Permalink
Updated Source Code to Version v0.3
Browse files Browse the repository at this point in the history
v0.3
+Added tooltip messages to system tray icon
+Leftclick on icon opens settingsform
+Some GUI updates
+Code improvements
+Better user experience
  • Loading branch information
flobaader committed Feb 10, 2016
1 parent 8548e32 commit f9298b4
Show file tree
Hide file tree
Showing 23 changed files with 4,062 additions and 430 deletions.
8 changes: 5 additions & 3 deletions SourceCode/InputMonitor.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "stdafx.h"
#include "InputMonitor.h"

#include "standbye_main.h" //Is needed here to prevent cross including

#define TO_MILLISECONDS(X) ((X) * 1000)

InputMonitor::InputMonitor(SettingsProvider* s, void(*f)()) {
InputMonitor::InputMonitor(mainApplication^ parent, SettingsProvider* s) {
aborted = false;
OnFinished = f;
this->parent = parent;
settings_provider = s;
Start();
}
Expand All @@ -24,7 +26,7 @@ void InputMonitor::Monitor() {

if (SystemAccess::GetLastInputTime() > wait_time) {
DEBUG("Wait Time is over!");
OnFinished();
parent->CheckUsage();
}
//Sleep only 10 milliseconds at once to handle to Close() Event
for (int x = 0; x < wait_time; x = x + 10) {
Expand Down
6 changes: 4 additions & 2 deletions SourceCode/InputMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
#include "SystemMetricWatcher.h"
#include "SystemAccess.h"

ref class mainApplication;

ref class InputMonitor {
private:
void(*OnFinished)();
int wait_time;
bool aborted;
mainApplication^ parent;
ThreadStart^ thread_start;
Thread^ watcher;
SettingsProvider* settings_provider;

public:
InputMonitor(SettingsProvider* s, void(*f)());
InputMonitor(mainApplication^ parent, SettingsProvider* s);
~InputMonitor();

void Reset();
Expand Down
23 changes: 23 additions & 0 deletions SourceCode/MessageWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "stdafx.h"
#include "MessageWindow.h"
using namespace StandBye;

System::Void MessageWindow::TimeoutWindow_Load(System::Object^, System::EventArgs^) {
this->ControlBox = true;
this->MaximizeBox = false;
this->MinimizeBox = false;

//Gets the Working Space
Drawing::Rectangle WorkArea = Screen::PrimaryScreen->WorkingArea;
this->Location = Point((WorkArea.Width - this->Size.Width) / 2, (WorkArea.Height - this->Size.Height) / 2);
this->Update();
System::Media::SystemSounds::Asterisk->Play();
}
System::Void MessageWindow::metroButtonOK_Click(System::Object^ sender, System::EventArgs^ e) {
this->DialogResult = Windows::Forms::DialogResult::OK;
this->Close();
}
System::Void MessageWindow::metroButtonCancel_Click(System::Object^ sender, System::EventArgs^ e) {
this->DialogResult = Windows::Forms::DialogResult::Cancel;
this->Close();
}
125 changes: 125 additions & 0 deletions SourceCode/MessageWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#pragma once
#include "stdafx.h"

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Threading;

/// <summary>
/// Summary for TimeoutWindow
/// </summary>
namespace StandBye {
public ref class MessageWindow : public MetroFramework::Forms::MetroForm
{
private: MetroFramework::Controls::MetroButton^ metroButtonCancel;

private: MetroFramework::Controls::MetroLabel^ metroLabel1;

private: MetroFramework::Controls::MetroButton^ metroButtonOK;
public:
MessageWindow(String^ text) {
InitializeComponent();
metroLabel1->Text = text;
}

protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MessageWindow()
{
if (components)
{
delete components;
}
}

protected:

private: System::ComponentModel::IContainer^ components;

private:
/// <summary>
/// Required designer variable.
/// </summary>

#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MessageWindow::typeid));
this->metroButtonCancel = (gcnew MetroFramework::Controls::MetroButton());
this->metroButtonOK = (gcnew MetroFramework::Controls::MetroButton());
this->metroLabel1 = (gcnew MetroFramework::Controls::MetroLabel());
this->SuspendLayout();
//
// metroButtonCancel
//
this->metroButtonCancel->Location = System::Drawing::Point(167, 154);
this->metroButtonCancel->Name = L"metroButtonCancel";
this->metroButtonCancel->Size = System::Drawing::Size(92, 35);
this->metroButtonCancel->TabIndex = 3;
this->metroButtonCancel->Text = L"No";
this->metroButtonCancel->UseSelectable = true;
this->metroButtonCancel->Click += gcnew System::EventHandler(this, &MessageWindow::metroButtonCancel_Click);
//
// metroButtonOK
//
this->metroButtonOK->Location = System::Drawing::Point(276, 154);
this->metroButtonOK->Name = L"metroButtonOK";
this->metroButtonOK->Size = System::Drawing::Size(92, 35);
this->metroButtonOK->TabIndex = 4;
this->metroButtonOK->Text = L"Yes";
this->metroButtonOK->UseSelectable = true;
this->metroButtonOK->Click += gcnew System::EventHandler(this, &MessageWindow::metroButtonOK_Click);
//
// metroLabel1
//
this->metroLabel1->AutoSize = true;
this->metroLabel1->FontSize = MetroFramework::MetroLabelSize::Tall;
this->metroLabel1->Location = System::Drawing::Point(39, 72);
this->metroLabel1->Name = L"metroLabel1";
this->metroLabel1->Size = System::Drawing::Size(103, 25);
this->metroLabel1->TabIndex = 6;
this->metroLabel1->Text = L"metroLabel1";
this->metroLabel1->WrapToLine = true;
//
// MessageWindow
//
this->AeroWindowSnapActive = false;
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(255)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->BackImage = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"$this.BackImage")));
this->BackImagePadding = System::Windows::Forms::Padding(0, 10, 0, 0);
this->BackMaxSize = 50;
this->ClientSize = System::Drawing::Size(400, 200);
this->ControlBox = false;
this->Controls->Add(this->metroLabel1);
this->Controls->Add(this->metroButtonOK);
this->Controls->Add(this->metroButtonCancel);
this->Location = System::Drawing::Point(100, 100);
this->Name = L"MessageWindow";
this->Resizable = false;
this->StartPosition = System::Windows::Forms::FormStartPosition::Manual;
this->Style = MetroFramework::MetroColorStyle::Green;
this->Text = L" Stand-Bye!";
this->TopMost = true;
this->Load += gcnew System::EventHandler(this, &MessageWindow::TimeoutWindow_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void MessageWindow::TimeoutWindow_Load(System::Object^, System::EventArgs^);
private: System::Void metroButtonOK_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void metroButtonCancel_Click(System::Object^ sender, System::EventArgs^ e);
};
}
Loading

0 comments on commit f9298b4

Please sign in to comment.