- Automatically send windows to back

- Fix auto updater
This commit is contained in:
Stone-Red-Code
2021-09-14 21:27:08 +02:00
parent 7d2f68a66a
commit aed4b7de64
10 changed files with 31 additions and 17 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ namespace DesktopMagic
{ {
private Mutex _mutex; private Mutex _mutex;
#if DEBUG #if DEBUG
private readonly Updater updater = new Updater(TimeSpan.FromHours(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/develop/update/updateInfo.json"); private readonly Updater updater = new Updater(TimeSpan.FromDays(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/develop/update/updateInfo.json");
#else #else
private readonly Updater updater = new Updater(TimeSpan.FromHours(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json"); private readonly Updater updater = new Updater(TimeSpan.FromHours(1), "https://raw.githubusercontent.com/Stone-Red-Code/DesktopMagic/main/update/updateInfo.json");
#endif #endif
+2 -2
View File
@@ -92,12 +92,12 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
new WindowPos().SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
new WindowPos().SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
} }
if (MainWindow.GlobalFont != oldFont || MainWindow.GlobalColor != oldColor) if (MainWindow.GlobalFont != oldFont || MainWindow.GlobalColor != oldColor)
{ {
+2 -2
View File
@@ -73,12 +73,12 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
new WindowPos().SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
new WindowPos().SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
} }
textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont); textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont);
+2 -2
View File
@@ -60,12 +60,12 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
new WindowPos().SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
new WindowPos().SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
} }
textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont); textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont);
textBlock.Foreground = MainWindow.GlobalColor; textBlock.Foreground = MainWindow.GlobalColor;
+4 -2
View File
@@ -8,9 +8,11 @@
<ApplicationIcon>icon.ico</ApplicationIcon> <ApplicationIcon>icon.ico</ApplicationIcon>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<Authors>Stone_Red</Authors> <Authors>Stone_Red</Authors>
<Version>0.0.2.2</Version> <Version>0.0.2.3</Version>
<PackageProjectUrl>https://github.com/Stone-Red-Code/DesktopMagic</PackageProjectUrl> <PackageProjectUrl>https://github.com/Stone-Red-Code/DesktopMagic</PackageProjectUrl>
<RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl> <RepositoryUrl>https://github.com/Stone-Red-Code/DesktopMagic</RepositoryUrl>
<AssemblyVersion>0.0.2.3</AssemblyVersion>
<FileVersion>0.0.2.3</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -24,7 +26,7 @@
<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.55.0.2410" /> <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.1.0" /> <PackageReference Include="MaterialDesignThemes" Version="4.0.0" />
<PackageReference Include="NAudio" Version="2.0.1" /> <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" />
+12
View File
@@ -197,6 +197,11 @@ namespace DesktopMagic
{ {
EditMode = (bool)EditCheckBox.IsChecked; EditMode = (bool)EditCheckBox.IsChecked;
SaveLayout(); SaveLayout();
foreach (var item in Windows)
{
WindowPos.SendWpfWindowBack(item);
WindowPos.SendWpfWindowBack(item);
}
} }
private void CheckBox_Click(object sender, RoutedEventArgs e) private void CheckBox_Click(object sender, RoutedEventArgs e)
@@ -263,6 +268,7 @@ namespace DesktopMagic
window.ShowInTaskbar = false; window.ShowInTaskbar = false;
window.Show(); window.Show();
window.ContentRendered += PluginWindow_ContentRendered;
window.Closing += DisplayWindow_Closing; window.Closing += DisplayWindow_Closing;
Windows.Add(window); Windows.Add(window);
WindowNames.Add(window.Title); WindowNames.Add(window.Title);
@@ -283,6 +289,12 @@ namespace DesktopMagic
SaveLayout(); SaveLayout();
} }
private void PluginWindow_ContentRendered(object sender, EventArgs e)
{
WindowPos.SendWpfWindowBack(sender as Window);
WindowPos.SendWpfWindowBack(sender as Window);
}
private void DisplayWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) private void DisplayWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
e.Cancel = blockWindowsClosing; e.Cancel = blockWindowsClosing;
@@ -88,12 +88,12 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
new WindowPos().SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
new WindowPos().SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
} }
if (!this.IsLoaded) if (!this.IsLoaded)
{ {
+2 -2
View File
@@ -97,14 +97,14 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
new WindowPos().SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
tileBar.CaptionHeight = tileBar.CaptionHeight = this.ActualHeight - 10 < 0 ? 0 : this.ActualHeight - 10; tileBar.CaptionHeight = tileBar.CaptionHeight = this.ActualHeight - 10 < 0 ? 0 : this.ActualHeight - 10;
this.ResizeMode = ResizeMode.CanResize; this.ResizeMode = ResizeMode.CanResize;
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
new WindowPos().SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
tileBar.CaptionHeight = 0; tileBar.CaptionHeight = 0;
this.ResizeMode = ResizeMode.NoResize; this.ResizeMode = ResizeMode.NoResize;
} }
+2 -2
View File
@@ -60,12 +60,12 @@ namespace DesktopMagic
if (MainWindow.EditMode) if (MainWindow.EditMode)
{ {
panel.Visibility = Visibility.Visible; panel.Visibility = Visibility.Visible;
new WindowPos().SetIsLocked(this, false); WindowPos.SetIsLocked(this, false);
} }
else else
{ {
panel.Visibility = Visibility.Collapsed; panel.Visibility = Visibility.Collapsed;
new WindowPos().SetIsLocked(this, true); WindowPos.SetIsLocked(this, true);
} }
textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont); textBlock.FontFamily = new FontFamily(MainWindow.GlobalFont);
+2 -2
View File
@@ -40,7 +40,7 @@ namespace DesktopMagic
[DllImport("user32.dll")] [DllImport("user32.dll")]
private static extern int GetWindowRect(IntPtr hwnd, out Rectangle rect); private static extern int GetWindowRect(IntPtr hwnd, out Rectangle rect);
public void SendWpfWindowBack(Window window) public static void SendWpfWindowBack(Window window)
{ {
var hWnd = new WindowInteropHelper(window).Handle; var hWnd = new WindowInteropHelper(window).Handle;
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE1 | SWP_NOMOVE1); SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE1 | SWP_NOMOVE1);
@@ -51,7 +51,7 @@ namespace DesktopMagic
return (bool)obj.GetValue(IsLockedProperty); return (bool)obj.GetValue(IsLockedProperty);
} }
public void SetIsLocked(DependencyObject obj, bool value) public static void SetIsLocked(DependencyObject obj, bool value)
{ {
obj.SetValue(IsLockedProperty, value); obj.SetValue(IsLockedProperty, value);
} }