Skip to content

Commit

Permalink
Merge pull request #8 from HICalSoft/dst-timechange-support
Browse files Browse the repository at this point in the history
Dst timechange support
  • Loading branch information
iysaleh authored Apr 17, 2024
2 parents 23013b0 + d1735c2 commit 14ae015
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 49 deletions.
6 changes: 3 additions & 3 deletions OpenAdhanForWindowsX/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>
4 changes: 3 additions & 1 deletion OpenAdhanForWindowsX/OpenAdhanForWindowsX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<OutputType>WinExe</OutputType>
<RootNamespace>OpenAdhanForWindowsX</RootNamespace>
<AssemblyName>OpenAdhanForWindows</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -85,6 +86,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Settings.resx">
<DependentUpon>Settings.cs</DependentUpon>
Expand Down
25 changes: 23 additions & 2 deletions OpenAdhanForWindowsX/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@ static void Main()
// Register the PowerModeChanged event (for waking up from sleep -- https://github.com/HICalSoft/OpenAdhan/issues/1)
SystemEvents.PowerModeChanged += OnPowerChange;


RegistrySettingsHandler rsh = new RegistrySettingsHandler(false);

// This should handle DST changes (untested :P ) https://github.com/HICalSoft/OpenAdhan/issues/6
// Add condition only if automatic DST adjustment is enabled
if (rsh.SafeLoadBoolRegistryValue(RegistrySettingsHandler.automaticDaylightSavingsAdjustmentKey))
{
SystemEvents.TimeChanged += OnTimeChange;
}


if (rsh.SafeLoadBoolRegistryValue(RegistrySettingsHandler.minimizeOnStartupKey) &&
!rsh.SafeLoadBoolRegistryValue(RegistrySettingsHandler.initialInstallFlagKey))
{
Expand All @@ -44,11 +54,22 @@ private static void OnPowerChange(object s, PowerModeChangedEventArgs e)
{
case PowerModes.Resume:
// The computer has woken up from sleep.
// Run scheduleAdhans() here.
prayerTimesControl.scheduleAdhans(form);
refreshPrayerTimes();
break;
}
}

private static void OnTimeChange(object s, EventArgs e)
{
refreshPrayerTimes();
}

private static void refreshPrayerTimes()
{
prayerTimesControl.calculatePrayerTimes();
prayerTimesControl.scheduleAdhans(form);
form.updatePrayerTimesDisplay();
}
}

public sealed class PrayerTimesControl
Expand Down
44 changes: 18 additions & 26 deletions OpenAdhanForWindowsX/Properties/Resources.Designer.cs

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

22 changes: 9 additions & 13 deletions OpenAdhanForWindowsX/Properties/Settings.Designer.cs

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

6 changes: 3 additions & 3 deletions OpenAdhanRegistrySetupApp/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>
</configuration>
3 changes: 2 additions & 1 deletion OpenAdhanRegistrySetupApp/OpenAdhanRegistrySetupApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<OutputType>Exe</OutputType>
<RootNamespace>OpenAdhanRegistrySetupApp</RootNamespace>
<AssemblyName>OpenAdhanRegistrySetupApp</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down

0 comments on commit 14ae015

Please sign in to comment.