From b2220452b2dccf240a4fb4935326672011282acc Mon Sep 17 00:00:00 2001 From: "PAL\\cbo" Date: Tue, 7 Feb 2023 11:52:39 +0100 Subject: [PATCH] SplashScreen --- wpf_ax_utility/App.xaml.cs | 54 +++++++++++++------- wpf_ax_utility/AxUtilitySplashScreen.xaml | 33 ++++++++++++ wpf_ax_utility/AxUtilitySplashScreen.xaml.cs | 27 ++++++++++ 3 files changed, 96 insertions(+), 18 deletions(-) create mode 100644 wpf_ax_utility/AxUtilitySplashScreen.xaml create mode 100644 wpf_ax_utility/AxUtilitySplashScreen.xaml.cs diff --git a/wpf_ax_utility/App.xaml.cs b/wpf_ax_utility/App.xaml.cs index f79062c..b263966 100644 --- a/wpf_ax_utility/App.xaml.cs +++ b/wpf_ax_utility/App.xaml.cs @@ -4,6 +4,8 @@ using System.Windows; using System.Security.Principal; using Serilog; using Serilog.Sinks.Graylog; +using DevExpress.Mvvm; +using DevExpress.Xpf.Core; namespace wpf_ax_utility { @@ -15,24 +17,7 @@ namespace wpf_ax_utility public static string userName { get { return WindowsIdentity.GetCurrent().Name.Replace("PAL\\", ""); } } public App() { - Log.Logger = new LoggerConfiguration().WriteTo.Graylog(new GraylogSinkOptions - { - HostnameOrAddress = "palgraylog01.pal.it", - Port = 12202, - MinimumLogEventLevel = Serilog.Events.LogEventLevel.Verbose, - Facility = "(WPF) AX Utility" - }).CreateLogger(); - - var userGroups = GetGroups(userName); - - var uriString = "/wpf_ax_utility;component/UserWindow.xaml"; - - if (userGroups.Contains("PAL\\BRAIN FORCE - AX DEV ADMINS") || userGroups.Contains("PAL\\PAL GG IT")) - { - uriString = "/wpf_ax_utility;component/MainWindow.xaml"; - } - - this.StartupUri = new Uri(uriString, UriKind.Relative); + BeforeStart(); } private List GetGroups(string userName) @@ -54,5 +39,38 @@ namespace wpf_ax_utility result.Sort(); return result; } + + private void BeforeStart() + { + //SplashScreen + var splashScreenViewModel = new DXSplashScreenViewModel() { + Title = "PAL Ax Utility", + Copyright = "", + Logo = new Uri("res/pallogo.png", UriKind.Relative), + + }; + SplashScreenManager.Create(() => new AxUtilitySplashScreen(), splashScreenViewModel).ShowOnStartup(); + + //Log Endpoint + Log.Logger = new LoggerConfiguration().WriteTo.Graylog(new GraylogSinkOptions + { + HostnameOrAddress = "palgraylog01.pal.it", + Port = 12202, + MinimumLogEventLevel = Serilog.Events.LogEventLevel.Verbose, + Facility = "(WPF) AX Utility" + }).CreateLogger(); + + //View selection with group filter + var userGroups = GetGroups(userName); + + var uriString = "/wpf_ax_utility;component/AppUserWindow.xaml"; + + if (userGroups.Contains("PAL\\BRAIN FORCE - AX DEV ADMINS") || userGroups.Contains("PAL\\PAL GG IT")) + { + uriString = "/wpf_ax_utility;component/AppMainWindow.xaml"; + } + + this.StartupUri = new Uri(uriString, UriKind.Relative); + } } } diff --git a/wpf_ax_utility/AxUtilitySplashScreen.xaml b/wpf_ax_utility/AxUtilitySplashScreen.xaml new file mode 100644 index 0000000..a0bcea4 --- /dev/null +++ b/wpf_ax_utility/AxUtilitySplashScreen.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/wpf_ax_utility/AxUtilitySplashScreen.xaml.cs b/wpf_ax_utility/AxUtilitySplashScreen.xaml.cs new file mode 100644 index 0000000..2b90f03 --- /dev/null +++ b/wpf_ax_utility/AxUtilitySplashScreen.xaml.cs @@ -0,0 +1,27 @@ +using DevExpress.Xpf.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace wpf_ax_utility +{ + /// + /// Interaction logic for AxUtilitySplashScreen.xaml + /// + public partial class AxUtilitySplashScreen : SplashScreenWindow + { + public AxUtilitySplashScreen() + { + InitializeComponent(); + } + } +}