Skip to content

Commit

Permalink
Fix bugs because I was stupid
Browse files Browse the repository at this point in the history
Update to v1.10.1
  • Loading branch information
GetGet99 committed May 9, 2022
1 parent 50791b2 commit 31e155c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 31 deletions.
37 changes: 18 additions & 19 deletions Mica Discord/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public partial class MainWindow : Window
{
#if WINDOWS10_0_17763_0_OR_GREATER
static UISettings UISettings { get; } = new();
public static bool IsNewTitleBarSupported => AppWindowTitleBar.IsCustomizationSupported();
#else
public static bool IsNewTitleBarSupported => false;
#endif
public static string DefinedCSS
#if DEBUG
Expand All @@ -52,8 +55,8 @@ public static string DefinedJavascript
public static bool NotSupportedBuild => Environment.OSVersion.Version.Build < 22523;
public static bool IsWin11 => Environment.OSVersion.Version.Build > 22000;
public static bool IsWin7 => Environment.OSVersion.Version.Major < 8 && Environment.OSVersion.Version.Major >= 7;

bool DiscordEffectApplied = false;
bool NewSDKTitleBar = false;
bool _Dark = true;
Action? ThemeChanged = null;
bool Dark
Expand All @@ -68,11 +71,10 @@ bool Dark

void OnLoaded(object sender, RoutedEventArgs e)
{
NewSDKTitleBar = false;
ThemeChanged += () => (Resources["Color"] as SolidColorBrush ?? throw new NullReferenceException()).Color = Dark ? Colors.White : Colors.Black;
#if WINDOWS10_0_17763_0_OR_GREATER
Dark = IsDarkBackground(UISettings.GetColorValue(UIColorType.Background));
if (IsWin11)
if (IsNewTitleBarSupported)
{
AppWindow = AppWindow.GetFromWindowId(WindowId);
var AppTitleBar = AppWindow.TitleBar;
Expand Down Expand Up @@ -145,7 +147,6 @@ void UpdateDragRectangles()
UpdateDragRectangles();
};
UpdateDragRectangles();
NewSDKTitleBar = true;
goto SetWindowChromeComplete;
}
#endif
Expand Down Expand Up @@ -174,20 +175,20 @@ void RefreshFrame()
goto End;
}
#endif
if (!IsWin7)
if (!IsNewTitleBarSupported)
{
WindowChrome.GlassFrameThickness = new Thickness(0);
WindowChrome.UseAeroCaptionButtons = false;
mainWindowSrc.CompositionTarget.BackgroundColor = Dark ? Color.FromArgb(255, 52, 52, 52) :
Color.FromArgb(255, 250, 250, 250);
}

WindowChrome.CaptionHeight = 32;
goto End;
End:
;
}


SizeChanged += (_, _) => RefreshFrame();
IsVisibleChanged += (_, _) => RefreshFrame();
Expand All @@ -207,15 +208,14 @@ static bool IsDarkBackground(WinUIColor color)
//RefreshDarkMode(dark: Dark);
SetBackdrop((CustomPInvoke.BackdropType)Enum.Parse(typeof(CustomPInvoke.BackdropType), Settings.Default.BackdropType, ignoreCase: true));
#else

if (!IsWin7)
ThemeChanged += RefreshFrame;
#endif
if (!IsNewTitleBarSupported)
{
TitleBarCaptionButtons.Visibility = Visibility.Visible;
foreach (var child in TitleBarCaptionButtons.Children)
WindowChrome.SetIsHitTestVisibleInChrome(child as IInputElement, true);
}
ThemeChanged += RefreshFrame;
#endif
// Just to make everything updated again
var d = Dark;
Dark = d;
Expand Down Expand Up @@ -453,7 +453,7 @@ private void Minimize(object sender, RoutedEventArgs e)

private void Maximize(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Maximized;
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
}

private void Close(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -505,14 +505,13 @@ public MainWindow()
{
if (WebView.CanGoForward) WebView.GoForward();
};
SizeChanged += (_, _) =>
if (!IsNewTitleBarSupported)
SizeChanged += (_, _) =>
{
if (!NewSDKTitleBar)
{
var a = WindowState == WindowState.Maximized ? 7.5 : 0;
TitleBar.Margin = new Thickness(a, a, 0, 0);
WebView.Margin = new Thickness(7.5, 0, 7.5, 7.5);
}
var a = WindowState == WindowState.Maximized ? 7.5 : 0;
TitleBar.Margin = new Thickness(a, a, 0, 0);
TitleBarCaptionButtons.Margin = new Thickness(0, 0, 7.5, 0);
WebView.Margin = new Thickness(7.5, 0, 7.5, 7.5);
};
}
WindowChrome WindowChrome { get; } = new WindowChrome
Expand Down
4 changes: 2 additions & 2 deletions Mica Discord/Mica Discord WPF.csproj.user
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>D:\Programming\VS\Mica Discord\Mica Discord\Properties\PublishProfiles\ClickOnce Windows 7.pubxml</_LastSelectedProfileId>
<ActiveDebugFramework>net6.0-windows10.0.22000.0</ActiveDebugFramework>
<_LastSelectedProfileId>D:\Programming\VS\Mica Discord\Mica Discord\Properties\PublishProfiles\ClickONce Windows 10.pubxml</_LastSelectedProfileId>
<ActiveDebugFramework>net6.0-windows10.0.17763.0</ActiveDebugFramework>
</PropertyGroup>
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>1.10.0.*</ApplicationVersion>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.10.1.*</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateWebPageOnPublish>False</CreateWebPageOnPublish>
Expand All @@ -25,11 +25,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<SelfContained>False</SelfContained>
<SignatureAlgorithm>(none)</SignatureAlgorithm>
<SignManifests>False</SignManifests>
<TargetFramework>net6.0-windows7.0</TargetFramework>
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
<UpdateEnabled>False</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateRequired>False</UpdateRequired>
<WebPageFileName>Publish.html</WebPageFileName>
<History>True|2022-05-09T02:55:14.4291313Z;True|2022-05-09T09:54:02.4047097+07:00;</History>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2022-05-09T03:01:31.8714154Z;True|2022-05-09T09:55:14.4291313+07:00;True|2022-05-09T09:54:02.4047097+07:00;</History>
<History>True|2022-05-09T03:33:01.9180060Z;</History>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>1.10.0.*</ApplicationVersion>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.10.1.0</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<CreateWebPageOnPublish>False</CreateWebPageOnPublish>
<GenerateManifests>True</GenerateManifests>
<Install>True</Install>
<InstallFrom>Disk</InstallFrom>
<IsRevisionIncremented>True</IsRevisionIncremented>
<IsRevisionIncremented>False</IsRevisionIncremented>
<IsWebBootstrapper>False</IsWebBootstrapper>
<MapFileExtensions>True</MapFileExtensions>
<OpenBrowserOnPublish>False</OpenBrowserOnPublish>
Expand All @@ -30,6 +30,5 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<UpdateMode>Foreground</UpdateMode>
<UpdateRequired>False</UpdateRequired>
<WebPageFileName>Publish.html</WebPageFileName>
<History>True|2022-05-09T02:55:00.7361137Z;</History>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2022-05-09T03:02:10.1784420Z;True|2022-05-09T09:55:00.7361137+07:00;</History>
<History>True|2022-05-09T03:32:26.4535440Z;</History>
</PropertyGroup>
</Project>

0 comments on commit 31e155c

Please sign in to comment.