82 lines
2.1 KiB
C#
82 lines
2.1 KiB
C#
using System;
|
|
using System.CodeDom.Compiler;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Markup;
|
|
using System.Windows.Media;
|
|
using Crysome.Server.ViewModel;
|
|
using Microsoft.Win32;
|
|
using Wpf.Ui.Controls;
|
|
|
|
namespace Crysome.Server;
|
|
|
|
public class MainWindow : FluentWindow, IComponentConnector
|
|
{
|
|
private bool _contentLoaded;
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
if (IsWindows11OrNewer())
|
|
{
|
|
((FluentWindow)this).ExtendsContentIntoTitleBar = true;
|
|
((FluentWindow)this).WindowBackdropType = (WindowBackdropType)2;
|
|
}
|
|
else
|
|
{
|
|
((Control)this).Background = new SolidColorBrush(Color.FromRgb(32, 32, 32));
|
|
if (((ContentControl)this).Content is Panel panel)
|
|
{
|
|
panel.Background = new SolidColorBrush(Color.FromRgb(32, 32, 32));
|
|
}
|
|
}
|
|
((FrameworkElement)this).DataContext = new MainViewModel();
|
|
((Window)this).Title = "CRYSOME | t.me/CuriousCracks";
|
|
}
|
|
|
|
private static bool IsWindows11OrNewer()
|
|
{
|
|
try
|
|
{
|
|
using RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
|
|
if (registryKey?.GetValue("CurrentBuild") is string s && int.TryParse(s, out var result))
|
|
{
|
|
return result >= 22000;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return false;
|
|
}
|
|
|
|
[DebuggerNonUserCode]
|
|
[GeneratedCode("PresentationBuildTasks", "9.0.14.0")]
|
|
public void InitializeComponent()
|
|
{
|
|
if (!_contentLoaded)
|
|
{
|
|
_contentLoaded = true;
|
|
Uri resourceLocator = new Uri("/Crysome.Server;component/view/mainwindow.xaml", UriKind.Relative);
|
|
Application.LoadComponent(this, resourceLocator);
|
|
}
|
|
}
|
|
|
|
[DebuggerNonUserCode]
|
|
[GeneratedCode("PresentationBuildTasks", "9.0.14.0")]
|
|
internal Delegate _CreateDelegate(Type delegateType, string handler)
|
|
{
|
|
return Delegate.CreateDelegate(delegateType, this, handler);
|
|
}
|
|
|
|
[DebuggerNonUserCode]
|
|
[GeneratedCode("PresentationBuildTasks", "9.0.14.0")]
|
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
|
void IComponentConnector.Connect(int connectionId, object target)
|
|
{
|
|
_contentLoaded = true;
|
|
}
|
|
}
|