- Add GitHub and Download plugins button

- Add auto updater
- Disable calender
This commit is contained in:
Stone-Red-Code
2021-09-14 19:03:36 +02:00
parent 6e4757adea
commit 7d2f68a66a
10 changed files with 77 additions and 24 deletions
+34 -2
View File
@@ -1,4 +1,6 @@
using System; using AlwaysUpToDate;
using System;
using System.Diagnostics;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
@@ -10,6 +12,11 @@ namespace DesktopMagic
public partial class App : Application public partial class App : Application
{ {
private Mutex _mutex; private Mutex _mutex;
#if DEBUG
private readonly Updater updater = new Updater(TimeSpan.FromHours(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/develop/update/updateInfo.json");
#else
private readonly Updater updater = new Updater(TimeSpan.FromHours(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json");
#endif
public App() public App()
{ {
@@ -25,11 +32,36 @@ namespace DesktopMagic
} }
else else
{ {
// Add Event handler to exit event.
Exit += CloseMutexHandler; Exit += CloseMutexHandler;
updater.ProgressChanged += Updater_ProgressChanged;
updater.OnException += Updater_OnException;
updater.NoUpdateAvailible += Updater_NoUpdateAvailible;
updater.UpdateAvailible += Updater_UpdateAvailible;
updater.Start();
} }
} }
private void Updater_UpdateAvailible(string version, string additionalInformation)
{
updater.Update();
}
private void Updater_NoUpdateAvailible()
{
Debug.WriteLine("No update avalible.");
}
private void Updater_OnException(Exception exception)
{
Debug.WriteLine("Update exception: " + exception);
}
private void Updater_ProgressChanged(long? totalFileSize, long totalBytesDownloaded, double? progressPercentage)
{
Debug.WriteLine($"{progressPercentage}% {totalBytesDownloaded}/{totalFileSize}");
}
protected virtual void CloseMutexHandler(object sender, EventArgs e) protected virtual void CloseMutexHandler(object sender, EventArgs e)
{ {
_mutex?.Close(); _mutex?.Close();
+3 -13
View File
@@ -5,6 +5,7 @@ using Google.Apis.Services;
using Google.Apis.Util.Store; using Google.Apis.Util.Store;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
@@ -21,14 +22,11 @@ namespace DesktopMagic
List<string> upcomingEventNames = new List<string>(); List<string> upcomingEventNames = new List<string>();
List<string> upcomingEventTimes = new List<string>(); List<string> upcomingEventTimes = new List<string>();
UserCredential credential; UserCredential credential;
Console.WriteLine("1");
if (!File.Exists("credentials.json")) if (!File.Exists("credentials.json"))
return (new(), new()); return (new(), new());
using (var stream = using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{ {
Console.WriteLine("2");
// The file token.json stores the user's access and refresh tokens, and is created // The file token.json stores the user's access and refresh tokens, and is created
// automatically when the authorization flow completes for the first time. // automatically when the authorization flow completes for the first time.
string credPath = "token.json"; string credPath = "token.json";
@@ -38,9 +36,8 @@ namespace DesktopMagic
"user", "user",
CancellationToken.None, CancellationToken.None,
new FileDataStore(credPath, true)).Result; new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath); Debug.WriteLine("Credential file saved to: " + credPath);
} }
Console.WriteLine("3");
// Create Google Calendar API service. // Create Google Calendar API service.
var service = new CalendarService(new BaseClientService.Initializer() var service = new CalendarService(new BaseClientService.Initializer()
@@ -49,8 +46,6 @@ namespace DesktopMagic
ApplicationName = ApplicationName, ApplicationName = ApplicationName,
}); });
Console.WriteLine("4");
// Define parameters of request. // Define parameters of request.
EventsResource.ListRequest request = service.Events.List("primary"); EventsResource.ListRequest request = service.Events.List("primary");
request.TimeMin = DateTime.Now; request.TimeMin = DateTime.Now;
@@ -59,11 +54,8 @@ namespace DesktopMagic
request.MaxResults = 10; request.MaxResults = 10;
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
Console.WriteLine("5");
// List events. // List events.
Events events = request.Execute(); Events events = request.Execute();
Console.WriteLine("6");
Console.WriteLine("Upcoming events:");
if (events.Items != null && events.Items.Count > 0) if (events.Items != null && events.Items.Count > 0)
{ {
foreach (var eventItem in events.Items) foreach (var eventItem in events.Items)
@@ -80,8 +72,6 @@ namespace DesktopMagic
} }
} }
} }
Console.WriteLine("7");
return (upcomingEventNames, upcomingEventTimes); return (upcomingEventNames, upcomingEventTimes);
} }
} }
+4 -3
View File
@@ -20,11 +20,12 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AlwaysUpToDate" Version="1.0.0.4" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.1.0" /> <PackageReference Include="Extended.Wpf.Toolkit" Version="4.1.0" />
<PackageReference Include="Google.Apis.Calendar.v3" Version="1.51.0.2312" /> <PackageReference Include="Google.Apis.Calendar.v3" Version="1.55.0.2410" />
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" /> <PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
<PackageReference Include="MaterialDesignThemes" Version="4.0.0" /> <PackageReference Include="MaterialDesignThemes" Version="4.1.0" />
<PackageReference Include="NAudio" Version="2.0.0" /> <PackageReference Include="NAudio" Version="2.0.1" />
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.2.1" /> <PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.2.1" />
<PackageReference Include="System.Management" Version="5.0.0" /> <PackageReference Include="System.Management" Version="5.0.0" />
</ItemGroup> </ItemGroup>
+9 -4
View File
@@ -9,9 +9,9 @@
Background="{DynamicResource MaterialDesignPaper}" Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}" FontFamily="{DynamicResource MaterialDesignFont}"
Height="520" Height="520"
Width="550" Width="570"
MinHeight="520" MinHeight="520"
MinWidth="500" MinWidth="570"
WindowState="Minimized" WindowState="Minimized"
StateChanged="Window_StateChanged" StateChanged="Window_StateChanged"
Loaded="Window_Loaded"> Loaded="Window_Loaded">
@@ -38,7 +38,7 @@
<CheckBox x:Name="TimeCb" Content="{DynamicResource time}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" /> <CheckBox x:Name="TimeCb" Content="{DynamicResource time}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<CheckBox x:Name="DateCb" Content="{DynamicResource date}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" /> <CheckBox x:Name="DateCb" Content="{DynamicResource date}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<CheckBox x:Name="CpuUsageCb" Content="{DynamicResource cpuUsage}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" /> <CheckBox x:Name="CpuUsageCb" Content="{DynamicResource cpuUsage}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
<CheckBox x:Name="CalendarCb" Content="{DynamicResource googleCalendar}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" /> <CheckBox x:Name="CalendarCb" Content="{DynamicResource googleCalendar}" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" Visibility="Collapsed"/> <!--Currently disabled because it's not working-->
<CheckBox x:Name="MusicVisualizerCb" Content="{DynamicResource musicVisualizer}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" /> <CheckBox x:Name="MusicVisualizerCb" Content="{DynamicResource musicVisualizer}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="CheckBox_Click" Style="{StaticResource MaterialDesignDarkCheckBox}" />
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
@@ -104,15 +104,20 @@
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition /> <ColumnDefinition />
<ColumnDefinition /> <ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Rectangle Fill="#FFC5C5C5" Stroke="#FFC5C5C5" Grid.ColumnSpan="2" /> <Rectangle Fill="#FFC5C5C5" Stroke="#FFC5C5C5" Grid.ColumnSpan="3" />
<StackPanel Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom"> <StackPanel Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom">
<ComboBox x:Name="layoutsComboBox" HorizontalAlignment="Left" Margin="0,0,0,5" Width="170" Height="20" SelectionChanged="LayoutsComboBox_SelectionChanged" /> <ComboBox x:Name="layoutsComboBox" HorizontalAlignment="Left" Margin="0,0,0,5" Width="170" Height="20" SelectionChanged="LayoutsComboBox_SelectionChanged" />
<Button x:Name="newLayoutButton" Content="{DynamicResource newLayout}" Margin="0,0,0,5" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="170" Click="NewLayoutButton_Click" FontWeight="Regular" /> <Button x:Name="newLayoutButton" Content="{DynamicResource newLayout}" Margin="0,0,0,5" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="170" Click="NewLayoutButton_Click" FontWeight="Regular" />
<Button x:Name="removeLayoutButton" Content="{DynamicResource deleteLayout}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="170" Click="RemoveLayoutButton_Click" FontWeight="Regular" /> <Button x:Name="removeLayoutButton" Content="{DynamicResource deleteLayout}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="170" Click="RemoveLayoutButton_Click" FontWeight="Regular" />
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom"> <StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom">
<Button x:Name="downloadPluginsButton" Content="{DynamicResource downloadPlugins}" Margin="0,0,0,5" HorizontalAlignment="Center" Width="170" Click="DownloadPluginsButton_Click" FontWeight="Regular" Cursor="Hand" />
<Button x:Name="githubButton" Content="GitHub" HorizontalAlignment="Center" Width="170" Click="GithubButton_Click" FontWeight="Regular" Cursor="Hand" />
</StackPanel>
<StackPanel Grid.Column="2" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom">
<Button x:Name="updatePluginsButton" Content="{DynamicResource updatePlugins}" Margin="0,0,0,5" HorizontalAlignment="Right" Width="170" Click="UpdatePluginsButton_Click" FontWeight="Regular" /> <Button x:Name="updatePluginsButton" Content="{DynamicResource updatePlugins}" Margin="0,0,0,5" HorizontalAlignment="Right" Width="170" Click="UpdatePluginsButton_Click" FontWeight="Regular" />
<Button x:Name="openPluginsFolderButton" Content="{DynamicResource openPluginsFolder}" HorizontalAlignment="Right" Width="170" Click="OpenPluginsFolderButton_Click" FontWeight="Regular" /> <Button x:Name="openPluginsFolderButton" Content="{DynamicResource openPluginsFolder}" HorizontalAlignment="Right" Width="170" Click="OpenPluginsFolderButton_Click" FontWeight="Regular" />
</StackPanel> </StackPanel>
+20 -1
View File
@@ -10,6 +10,7 @@ using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Text.Json; using System.Text.Json;
using Stone_Red_Utilities.Logging; using Stone_Red_Utilities.Logging;
using System.Diagnostics;
namespace DesktopMagic namespace DesktopMagic
{ {
@@ -984,7 +985,7 @@ namespace DesktopMagic
private void SetLanguageDictionary() private void SetLanguageDictionary()
{ {
ResourceDictionary dict = new ResourceDictionary(); ResourceDictionary dict = new ResourceDictionary();
string currentCulture = Thread.CurrentThread.CurrentCulture.ToString(); string currentCulture = Thread.CurrentThread.CurrentUICulture.ToString();
if (currentCulture.Contains("de")) if (currentCulture.Contains("de"))
{ {
@@ -996,5 +997,23 @@ namespace DesktopMagic
} }
this.Resources.MergedDictionaries.Add(dict); this.Resources.MergedDictionaries.Add(dict);
} }
private void GithubButton_Click(object sender, RoutedEventArgs e)
{
string uri = "https://github.com/Stone-Red-Code/DesktopMagic";
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = uri;
_ = Process.Start(psi);
}
private void DownloadPluginsButton_Click(object sender, RoutedEventArgs e)
{
string uri = "https://github.com/Stone-Red-Code/DesktopMagic-Plugins";
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = true;
psi.FileName = uri;
_ = Process.Start(psi);
}
} }
} }
@@ -7,6 +7,7 @@
<system:String x:Key="mirrorPlugine">Spiegeln</system:String> <system:String x:Key="mirrorPlugine">Spiegeln</system:String>
<system:String x:Key="updatePlugins">Plugins Neu Laden</system:String> <system:String x:Key="updatePlugins">Plugins Neu Laden</system:String>
<system:String x:Key="openPluginsFolder">Plugins Ordner Öffnen</system:String> <system:String x:Key="openPluginsFolder">Plugins Ordner Öffnen</system:String>
<system:String x:Key="downloadPlugins">Plugins Herunterladen</system:String>
<system:String x:Key="color">Farbe:</system:String> <system:String x:Key="color">Farbe:</system:String>
<system:String x:Key="default">Standard</system:String> <system:String x:Key="default">Standard</system:String>
<system:String x:Key="wantToCloseProgram">Wollen sie das Programm wirklich schließen?</system:String> <system:String x:Key="wantToCloseProgram">Wollen sie das Programm wirklich schließen?</system:String>
@@ -7,6 +7,7 @@
<system:String x:Key="mirrorPlugine">Mirror</system:String> <system:String x:Key="mirrorPlugine">Mirror</system:String>
<system:String x:Key="updatePlugins">Reload Plugins</system:String> <system:String x:Key="updatePlugins">Reload Plugins</system:String>
<system:String x:Key="openPluginsFolder">Open Plugins Folder</system:String> <system:String x:Key="openPluginsFolder">Open Plugins Folder</system:String>
<system:String x:Key="downloadPlugins">Download Plugins</system:String>
<system:String x:Key="color">Color:</system:String> <system:String x:Key="color">Color:</system:String>
<system:String x:Key="default">Default</system:String> <system:String x:Key="default">Default</system:String>
<system:String x:Key="wantToCloseProgram">Do you really want to close the program?</system:String> <system:String x:Key="wantToCloseProgram">Do you really want to close the program?</system:String>
+1 -1
View File
@@ -38,9 +38,9 @@ namespace DesktopMagicPlugin.Test
{ {
try try
{ {
info.Value = "Loading...";
if (File.Exists(input.Value)) if (File.Exists(input.Value))
{ {
info.Value = "Loading...";
Image gif = Image.FromFile(input.Value); Image gif = Image.FromFile(input.Value);
PropertyItem item = gif.GetPropertyItem(0x5100); // FrameDelay in libgdiplus PropertyItem item = gif.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
Binary file not shown.
+4
View File
@@ -0,0 +1,4 @@
{
"Version":"0.0.2.2",
"FileUrl":"http://github.com/Stone-Red-Code/DesktopMagic/blob/main/update/DesktopMagic.zip?raw=true"
}