mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 00:46:12 +02:00
- Add GitHub and Download plugins button
- Add auto updater - Disable calender
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using AlwaysUpToDate;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
|
||||
@@ -10,6 +12,11 @@ namespace DesktopMagic
|
||||
public partial class App : Application
|
||||
{
|
||||
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()
|
||||
{
|
||||
@@ -25,11 +32,36 @@ namespace DesktopMagic
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add Event handler to exit event.
|
||||
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)
|
||||
{
|
||||
_mutex?.Close();
|
||||
|
||||
@@ -5,6 +5,7 @@ using Google.Apis.Services;
|
||||
using Google.Apis.Util.Store;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
@@ -21,14 +22,11 @@ namespace DesktopMagic
|
||||
List<string> upcomingEventNames = new List<string>();
|
||||
List<string> upcomingEventTimes = new List<string>();
|
||||
UserCredential credential;
|
||||
Console.WriteLine("1");
|
||||
|
||||
if (!File.Exists("credentials.json"))
|
||||
return (new(), new());
|
||||
using (var stream =
|
||||
new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
|
||||
using (var stream = 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
|
||||
// automatically when the authorization flow completes for the first time.
|
||||
string credPath = "token.json";
|
||||
@@ -38,9 +36,8 @@ namespace DesktopMagic
|
||||
"user",
|
||||
CancellationToken.None,
|
||||
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.
|
||||
var service = new CalendarService(new BaseClientService.Initializer()
|
||||
@@ -49,8 +46,6 @@ namespace DesktopMagic
|
||||
ApplicationName = ApplicationName,
|
||||
});
|
||||
|
||||
Console.WriteLine("4");
|
||||
|
||||
// Define parameters of request.
|
||||
EventsResource.ListRequest request = service.Events.List("primary");
|
||||
request.TimeMin = DateTime.Now;
|
||||
@@ -59,11 +54,8 @@ namespace DesktopMagic
|
||||
request.MaxResults = 10;
|
||||
request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;
|
||||
|
||||
Console.WriteLine("5");
|
||||
// List events.
|
||||
Events events = request.Execute();
|
||||
Console.WriteLine("6");
|
||||
Console.WriteLine("Upcoming events:");
|
||||
if (events.Items != null && events.Items.Count > 0)
|
||||
{
|
||||
foreach (var eventItem in events.Items)
|
||||
@@ -80,8 +72,6 @@ namespace DesktopMagic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("7");
|
||||
return (upcomingEventNames, upcomingEventTimes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,12 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AlwaysUpToDate" Version="1.0.0.4" />
|
||||
<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="MaterialDesignThemes" Version="4.0.0" />
|
||||
<PackageReference Include="NAudio" Version="2.0.0" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.1.0" />
|
||||
<PackageReference Include="NAudio" Version="2.0.1" />
|
||||
<PackageReference Include="Stone_Red-C-Sharp-Utilities" Version="1.0.2.1" />
|
||||
<PackageReference Include="System.Management" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
FontFamily="{DynamicResource MaterialDesignFont}"
|
||||
Height="520"
|
||||
Width="550"
|
||||
Width="570"
|
||||
MinHeight="520"
|
||||
MinWidth="500"
|
||||
MinWidth="570"
|
||||
WindowState="Minimized"
|
||||
StateChanged="Window_StateChanged"
|
||||
Loaded="Window_Loaded">
|
||||
@@ -38,7 +38,7 @@
|
||||
<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="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}" />
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
@@ -104,15 +104,20 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Rectangle Fill="#FFC5C5C5" Stroke="#FFC5C5C5" Grid.ColumnSpan="2" />
|
||||
<Rectangle Fill="#FFC5C5C5" Stroke="#FFC5C5C5" Grid.ColumnSpan="3" />
|
||||
<StackPanel Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom">
|
||||
<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="removeLayoutButton" Content="{DynamicResource deleteLayout}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="170" Click="RemoveLayoutButton_Click" FontWeight="Regular" />
|
||||
</StackPanel>
|
||||
<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="openPluginsFolderButton" Content="{DynamicResource openPluginsFolder}" HorizontalAlignment="Right" Width="170" Click="OpenPluginsFolderButton_Click" FontWeight="Regular" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Text.Json;
|
||||
using Stone_Red_Utilities.Logging;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace DesktopMagic
|
||||
{
|
||||
@@ -984,7 +985,7 @@ namespace DesktopMagic
|
||||
private void SetLanguageDictionary()
|
||||
{
|
||||
ResourceDictionary dict = new ResourceDictionary();
|
||||
string currentCulture = Thread.CurrentThread.CurrentCulture.ToString();
|
||||
string currentCulture = Thread.CurrentThread.CurrentUICulture.ToString();
|
||||
|
||||
if (currentCulture.Contains("de"))
|
||||
{
|
||||
@@ -996,5 +997,23 @@ namespace DesktopMagic
|
||||
}
|
||||
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="updatePlugins">Plugins Neu Laden</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="default">Standard</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="updatePlugins">Reload Plugins</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="default">Default</system:String>
|
||||
<system:String x:Key="wantToCloseProgram">Do you really want to close the program?</system:String>
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace DesktopMagicPlugin.Test
|
||||
{
|
||||
try
|
||||
{
|
||||
info.Value = "Loading...";
|
||||
if (File.Exists(input.Value))
|
||||
{
|
||||
info.Value = "Loading...";
|
||||
Image gif = Image.FromFile(input.Value);
|
||||
|
||||
PropertyItem item = gif.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"Version":"0.0.2.2",
|
||||
"FileUrl":"http://github.com/Stone-Red-Code/DesktopMagic/blob/main/update/DesktopMagic.zip?raw=true"
|
||||
}
|
||||
Reference in New Issue
Block a user