Skip to content

Commit

Permalink
Rlease 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammedTsmu committed Nov 21, 2024
1 parent 8821a90 commit 12f5abb
Show file tree
Hide file tree
Showing 8 changed files with 1,099 additions and 24 deletions.
978 changes: 978 additions & 0 deletions SleepScheduler-installer/SleepScheduler-installer.vdproj

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions SleepSchedulerApp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.11.35431.28
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SleepSchedulerApp", "SleepSchedulerApp\SleepSchedulerApp.csproj", "{6E2D45A3-901C-4773-810A-28C74510F861}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "SleepScheduler-installer", "SleepScheduler-installer\SleepScheduler-installer.vdproj", "{0B7719F6-A89E-4C9C-86F4-96CBDF3E6491}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,8 @@ Global
{6E2D45A3-901C-4773-810A-28C74510F861}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E2D45A3-901C-4773-810A-28C74510F861}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E2D45A3-901C-4773-810A-28C74510F861}.Release|Any CPU.Build.0 = Release|Any CPU
{0B7719F6-A89E-4C9C-86F4-96CBDF3E6491}.Debug|Any CPU.ActiveCfg = Debug
{0B7719F6-A89E-4C9C-86F4-96CBDF3E6491}.Release|Any CPU.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions SleepSchedulerApp/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<setting name="LastKnownTimeZoneId" serializeAs="String">
<value />
</setting>
<setting name="IsFirstRun" serializeAs="String">
<value>True</value>
</setting>
<setting name="runNumber" serializeAs="String">
<value>0</value>
</setting>
</SleepSchedulerApp.Properties.Settings>
</userSettings>
</configuration>
54 changes: 38 additions & 16 deletions SleepSchedulerApp/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public partial class Form1 : Form
private bool isRestoringWindow = false; // Flag to prevent recursive calls
private bool isCountdownActive = false; // Flag to track if a countdown is active

private bool isFirstRun = Properties.Settings.Default.IsFirstRun; // Load the first-run flag
private int runNumber = Properties.Settings.Default.runNumber; // Load the run-count number flag

public Form1()
{
InitializeComponent();
Expand Down Expand Up @@ -98,6 +101,32 @@ public Form1()
//trayIcon.Text = "Sleep Scheduler 1.0.0";
trayIcon.Text = "Sleep Scheduler - Settings [double click]\nVersion: 1.0.0";

// Show the system tray notification if it's the first time running
if (isFirstRun || runNumber <= 7)
{
int remainingNotifications = 7 - runNumber;

// Show a balloon tip for 10 seconds
trayIcon.ShowBalloonTip(10000, "Sleep Scheduler Running",
$"The application is now running in the system tray. You can access it by clicking the tray icon. " +
$"{(remainingNotifications > 0 ? $"This alert will be shown {remainingNotifications} more time(s)." : "This is the last alert.")}",
ToolTipIcon.Info);

// Update the first run flag and run number
if (isFirstRun)
{
Properties.Settings.Default.IsFirstRun = false;
}

runNumber++;
Properties.Settings.Default.runNumber = runNumber;

// Save updated settings
Properties.Settings.Default.Save();
}



CheckSleepTime();
}

Expand All @@ -120,25 +149,17 @@ private void buttonSaveSettings_Click(object sender, EventArgs e)
// Adjust validation to handle overnight sleep times
if (selectedEndTime <= selectedStartTime && selectedEndTime.TimeOfDay <= selectedStartTime.TimeOfDay)
{
MessageBox.Show("يجب أن يكون وقت انتهاء النوم بعد وقت بدء النوم.", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
// This validation works if the end time is on the same day and earlier than the start time.
// We need to adjust it to handle the scenario where the sleep end time is logically on the next day.

// Check if the restriction period has passed
DateTime lastChange = Properties.Settings.Default.LastSettingsChangeTime;
int savedRestrictionHours = Properties.Settings.Default.RestrictionPeriod;
// Calculate today and the next day end time scenario
DateTime todayStart = DateTime.Today.Add(selectedStartTime.TimeOfDay);
DateTime nextDayEnd = DateTime.Today.AddDays(1).Add(selectedEndTime.TimeOfDay);

if (savedRestrictionHours > 0 && lastChange > DateTime.MinValue)
{
DateTime restrictionEndTime = lastChange.AddHours(savedRestrictionHours);

if (DateTime.Now < restrictionEndTime)
// If the end time is on the next day, the logic should accept it
if (nextDayEnd <= todayStart)
{
TimeSpan timeLeft = restrictionEndTime - DateTime.Now;

MessageBox.Show($"لا يمكنك تغيير إعدادات النوم حتى {restrictionEndTime}.\n" +
$"الوقت المتبقي: {timeLeft.Hours} ساعة و {timeLeft.Minutes} دقيقة.",
"قيود التغيير نشطة", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show("يجب أن يكون وقت انتهاء النوم بعد وقت بدء النوم، أو في اليوم التالي بشكل صحيح.", "خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
Expand Down Expand Up @@ -200,6 +221,7 @@ private void buttonSaveSettings_Click(object sender, EventArgs e)
SetRestrictionTimer();
}


private void CheckSleepTime()
{
// Dispose existing timers to avoid overlaps
Expand Down
14 changes: 8 additions & 6 deletions SleepSchedulerApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
using System.Reflection;
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 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: AssemblyTitle("SleepSchedulerApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("SleepScheduler")]
[assembly: AssemblyDescription("application designed to help users maintain healthy sleep habits by managing reminders and automatic shutdowns.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SleepSchedulerApp")]
[assembly: AssemblyCompany("Dr. Mohammed Studio")]
[assembly: AssemblyProduct("SleepScheduler")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
[assembly: ComVisible(true)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6e2d45a3-901c-4773-810a-28c74510f861")]
Expand All @@ -31,3 +32,4 @@
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("ar")]
26 changes: 25 additions & 1 deletion SleepSchedulerApp/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions SleepSchedulerApp/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@
<Setting Name="LastKnownTimeZoneId" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="IsFirstRun" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="runNumber" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
</Settings>
</SettingsFile>
35 changes: 34 additions & 1 deletion SleepSchedulerApp/SleepSchedulerApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,26 @@
<ProjectGuid>{6E2D45A3-901C-4773-810A-28C74510F861}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>SleepSchedulerApp</RootNamespace>
<AssemblyName>SleepSchedulerApp</AssemblyName>
<AssemblyName>SleepScheduler</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -32,6 +47,12 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\sleep.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Win32.TaskScheduler, Version=2.11.0.0, Culture=neutral, PublicKeyToken=e25603a88b3aa7da, processorArchitecture=MSIL">
<HintPath>..\packages\TaskScheduler.2.11.0\lib\net48\Microsoft.Win32.TaskScheduler.dll</HintPath>
Expand Down Expand Up @@ -97,5 +118,17 @@
<ItemGroup>
<None Include="Resources\sleep.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 12f5abb

Please sign in to comment.