Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Sentinel.Kiosk.Core;
- using Sentinel.Kiosk.Core.Classes;
- using Sentinel.Kiosk.Core.Configuration;
- using System.Diagnostics;
- using System.IO;
- using System.Windows;
- using Sentinel.Kiosk.Communication;
- using Sentinel.Core;
- using Sentinel.Kiosk.Core.Enums;
- namespace Sentinel.Kiosk
- {
- /// <summary>
- /// Interaction logic for App.xaml
- /// </summary>
- public partial class App : Application
- {
- #if DEBUG
- #region Development Settings
- enum DevelopmentModes : int
- {
- DevelopmentModeDefault = 0,
- DevelopmentModeArabic = 1,
- DevelopmentModeTestApplication = 2,
- DevelopmentModeEngineer = 3, // Sign In
- DevelopmentModeEngineer1 = 4, // Administrator
- DevelopmentModeEngineer2 = 5, // Engineer
- DevelopmentModeEngineer3 = 6, // CIT
- DevelopmentModeEngineerTestMode = 7,
- DevelopmentModeEngineerTestModeReplaceHardware = 8,
- DevelopmentModeEngineerTestModeReplaceConsumable = 9,
- }
- enum DevelopmentScreenModes : int
- {
- DevelopmentScreenModeDefault = 0,
- DevelopmentScreenModePortrait = 1,
- DevelopmentScreenModePrimary = 2,
- DevelopmentScreenModeSecondary = 3,
- DevelopmentScreenModeCustom = 4
- }
- bool ApplyDevelopmentMode()
- {
- // =============================================================================================
- // Modify
- // =============================================================================================
- DevelopmentModes dm = DevelopmentModes.DevelopmentModeEngineer1;
- DevelopmentScreenModes dsm = DevelopmentScreenModes.DevelopmentScreenModeSecondary;
- // ---------------------------------------------------------------------------------------------
- // Common Settings
- // ---------------------------------------------------------------------------------------------
- bool startupEnabled = false;
- bool timeoutEnabled = true;
- int timeoutInterval = 60;
- // ---------------------------------------------------------------------------------------------
- // Custom Screen Mode Settings
- // ---------------------------------------------------------------------------------------------
- double left = 1920; // 0 | 1920 | 2560 | -1920
- double top = 0;
- double width = 1920; // 1920 | 1080
- double height = 1080; // 1080 | 1920
- double designWidth = 1920; // 1920 | 1080
- double designHeight = 1080; // 1080 | 1920
- // =============================================================================================
- // Do Not Modify
- // =============================================================================================
- #region Do Not Modify
- bool retVal = false;
- // Set the Default Settings (See KioskConfiguration.cs for additional options)
- KioskHostController.Instance.KioskConfiguration = new KioskConfiguration
- {
- Version = 0,
- Description = "Sentinel.Kiosk Development Mode",
- DebugEnabled = true,
- TraceEnabled = true,
- ConsoleEnabled = true,
- Topmost = false,
- ShowInTaskbar = true,
- HideCursor = false,
- Stretch = System.Windows.Media.Stretch.Uniform,
- StartupEnabled = startupEnabled,
- StartupModule = @"{KioskApplicationsPath}Startup\Startup.dll",
- StartupAssembly = "Startup",
- StartupPage = "Pages/StartupPage.xaml",
- StartupData = null,
- StartupDelay = 3000,
- AdministrationEnabled = true,
- AdministrationModule = @"{KioskApplicationsPath}Engineer\Engineer.dll",
- AdministrationAssembly = "Engineer",
- AdministrationPage = "Pages/Engineer.xaml",
- AdministrationData = null,
- OfflineEnabled = true,
- OfflineModule = @"{KioskApplicationsPath}Offline\Offline.dll",
- OfflineAssembly = "Offline",
- OfflinePage = "Pages/OfflinePage.xaml",
- OfflineData = null,
- ClosedEnabled = true,
- ClosedModule = @"{KioskApplicationsPath}Closed\Closed.dll",
- ClosedAssembly = "Closed",
- ClosedPage = "Pages/ClosedPage.xaml",
- ClosedData = null,
- AttractLoopEnabled = true,
- AttractLoopModule = @"{KioskApplicationsPath}AttractLoop\AttractLoop.dll",
- AttractLoopAssembly = "AttractLoop",
- AttractLoopPage = "Pages/AttractLoopPage.xaml",
- AttractLoopData = null,
- HomeEnabled = true,
- HomeModule = @"{KioskApplicationsPath}DynamicDispatcher\DynamicDispatcher.dll",
- HomeAssembly = "DynamicDispatcher",
- HomePage = "Pages/DynamicDispatcherPage.xaml",
- HomeData = null,
- TimeoutEnabled = timeoutEnabled,
- TimeoutModule = @"{KioskApplicationsPath}Timeout\Timeout.dll",
- TimeoutAssembly = "Timeout",
- TimeoutPage = "Pages/TimeoutPage.xaml",
- TimeoutData = null,
- TimeoutInterval = timeoutInterval,
- TimeoutShowDialog = false,
- TransitionEnabled = true,
- TransitionType = TransitionTypes.Fade,
- OverlayTransitionType = TransitionTypes.Fade,
- TimeoutTransitionType = TransitionTypes.Fade
- };
- // Apply the Development Mode
- switch (dm)
- {
- case DevelopmentModes.DevelopmentModeArabic:
- KioskHostController.Instance.KioskConfiguration.DefaultLanguage = "ar-SA";
- KioskHostController.Instance.KioskConfiguration.DefaultFlowDirection = System.Windows.FlowDirection.RightToLeft;
- break;
- case DevelopmentModes.DevelopmentModeTestApplication:
- KioskHostController.Instance.KioskConfiguration.HomeModule = @"{KioskApplicationsPath}TestApplication1\TestApplication1.dll";
- KioskHostController.Instance.KioskConfiguration.HomeAssembly = "TestApplication1";
- KioskHostController.Instance.KioskConfiguration.HomePage = "Pages/HomePage.xaml";
- break;
- case DevelopmentModes.DevelopmentModeEngineer:
- KioskHostController.Instance.KioskConfiguration.StartupEnabled = false;
- KioskHostController.Instance.KioskConfiguration.HomeModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.HomeAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.HomePage = "Pages/Engineer.xaml";
- break;
- case DevelopmentModes.DevelopmentModeEngineer1:
- KioskHostController.Instance.KioskConfiguration.StartupEnabled = false;
- KioskHostController.Instance.KioskConfiguration.HomeModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.HomeAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.HomePage = "Pages/Engineer.xaml";
- KioskHostController.Instance.KioskConfiguration.HomeData = "BypassAuthentication1";
- break;
- case DevelopmentModes.DevelopmentModeEngineer2:
- KioskHostController.Instance.KioskConfiguration.StartupEnabled = false;
- KioskHostController.Instance.KioskConfiguration.HomeModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.HomeAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.HomePage = "Pages/Engineer.xaml";
- KioskHostController.Instance.KioskConfiguration.HomeData = "BypassAuthentication2";
- break;
- case DevelopmentModes.DevelopmentModeEngineer3:
- KioskHostController.Instance.KioskConfiguration.StartupEnabled = false;
- KioskHostController.Instance.KioskConfiguration.HomeModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.HomeAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.HomePage = "Pages/Engineer.xaml";
- KioskHostController.Instance.KioskConfiguration.HomeData = "BypassAuthentication3";
- break;
- case DevelopmentModes.DevelopmentModeEngineerTestMode:
- KioskHostController.Instance.KioskConfiguration.AttractLoopModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.AttractLoopAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.AttractLoopPage = "Pages/EngineerTestMode.xaml";
- KioskHostController.Instance.KioskConfiguration.HomeModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.HomeAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.HomePage = "Pages/Engineer.xaml";
- KioskHostController.Instance.KioskConfiguration.HomeData = null; // null | BypassAuthentication | TestReplaceHardware1 | TestReplaceConsumable1
- retVal = true;
- break;
- case DevelopmentModes.DevelopmentModeEngineerTestModeReplaceHardware:
- KioskHostController.Instance.KioskConfiguration.AttractLoopModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.AttractLoopAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.AttractLoopPage = "Pages/EngineerTestMode.xaml";
- KioskHostController.Instance.KioskConfiguration.HomeModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.HomeAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.HomePage = "Pages/Engineer.xaml";
- KioskHostController.Instance.KioskConfiguration.HomeData = "TestReplaceHardware1"; // BypassAuthentication | TestReplaceHardware1 | TestReplaceConsumable1
- retVal = true;
- break;
- case DevelopmentModes.DevelopmentModeEngineerTestModeReplaceConsumable:
- KioskHostController.Instance.KioskConfiguration.AttractLoopModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.AttractLoopAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.AttractLoopPage = "Pages/EngineerTestMode.xaml";
- KioskHostController.Instance.KioskConfiguration.HomeModule = @"{KioskApplicationsPath}Engineer\Engineer.dll";
- KioskHostController.Instance.KioskConfiguration.HomeAssembly = "Engineer";
- KioskHostController.Instance.KioskConfiguration.HomePage = "Pages/Engineer.xaml";
- KioskHostController.Instance.KioskConfiguration.HomeData = "TestReplaceConsumable1"; // BypassAuthentication | TestReplaceHardware1 | TestReplaceConsumable1
- retVal = true;
- break;
- default: // DevelopmentModes.DevelopmentModeDefault
- // Uses default constructor settings
- break;
- }
- // Apply the Development Screen Mode
- System.Drawing.Rectangle primaryWorkingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
- switch (dsm)
- {
- case DevelopmentScreenModes.DevelopmentScreenModePortrait:
- KioskHostController.Instance.KioskConfiguration.FullScreen = false;
- KioskHostController.Instance.KioskConfiguration.Left = left;
- KioskHostController.Instance.KioskConfiguration.Top = top;
- KioskHostController.Instance.KioskConfiguration.Width = 1080;
- KioskHostController.Instance.KioskConfiguration.Height = 1920;
- KioskHostController.Instance.KioskConfiguration.DesignWidth = 1080;
- KioskHostController.Instance.KioskConfiguration.DesignHeight = 1920;
- break;
- case DevelopmentScreenModes.DevelopmentScreenModePrimary:
- KioskHostController.Instance.KioskConfiguration.FullScreen = false;
- KioskHostController.Instance.KioskConfiguration.Left = primaryWorkingArea.X;
- KioskHostController.Instance.KioskConfiguration.Top = primaryWorkingArea.Y;
- KioskHostController.Instance.KioskConfiguration.Width = primaryWorkingArea.Width;
- KioskHostController.Instance.KioskConfiguration.Height = primaryWorkingArea.Height;
- KioskHostController.Instance.KioskConfiguration.DesignWidth = designWidth;
- KioskHostController.Instance.KioskConfiguration.DesignHeight = designHeight;
- break;
- case DevelopmentScreenModes.DevelopmentScreenModeSecondary:
- foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
- {
- if (!screen.Primary)
- {
- primaryWorkingArea = screen.WorkingArea;
- break;
- }
- }
- KioskHostController.Instance.KioskConfiguration.FullScreen = false;
- KioskHostController.Instance.KioskConfiguration.Left = primaryWorkingArea.X;
- KioskHostController.Instance.KioskConfiguration.Top = primaryWorkingArea.Y;
- KioskHostController.Instance.KioskConfiguration.Width = primaryWorkingArea.Width;
- KioskHostController.Instance.KioskConfiguration.Height = primaryWorkingArea.Height;
- KioskHostController.Instance.KioskConfiguration.DesignWidth = designWidth;
- KioskHostController.Instance.KioskConfiguration.DesignHeight = designHeight;
- break;
- case DevelopmentScreenModes.DevelopmentScreenModeCustom:
- KioskHostController.Instance.KioskConfiguration.FullScreen = false;
- KioskHostController.Instance.KioskConfiguration.Left = left;
- KioskHostController.Instance.KioskConfiguration.Top = top;
- KioskHostController.Instance.KioskConfiguration.Width = width;
- KioskHostController.Instance.KioskConfiguration.Height = height;
- KioskHostController.Instance.KioskConfiguration.DesignWidth = designWidth;
- KioskHostController.Instance.KioskConfiguration.DesignHeight = designHeight;
- break;
- default: // DevelopmentScreenModes.DevelopmentScreenModeDefault
- KioskHostController.Instance.KioskConfiguration.FullScreen = true;
- KioskHostController.Instance.KioskConfiguration.Left = 0;
- KioskHostController.Instance.KioskConfiguration.Top = 0;
- KioskHostController.Instance.KioskConfiguration.Width = 1920;
- KioskHostController.Instance.KioskConfiguration.Height = 1080;
- KioskHostController.Instance.KioskConfiguration.DesignWidth = 1920;
- KioskHostController.Instance.KioskConfiguration.DesignHeight = 1080;
- break;
- }
- // Save the Configuration: Default or Engineer Test Mode
- if (!retVal)
- // Default
- KioskHostController.Instance.KioskConfiguration.Save(Path.Combine(Paths.KioskDataPath, KioskConfiguration.CONFIGURATION_FILENAME));
- else
- // Engineer Test Mode
- KioskHostController.Instance.KioskConfiguration.Save(Path.Combine(Paths.KioskDataPath, KioskConfiguration.ENGINEER_TEST_MODE_CONFIGURATION_FILENAME));
- // Return
- return retVal;
- #endregion
- }
- #endregion
- #endif
- private void Application_Startup(object sender, StartupEventArgs e)
- {
- bool loadEngineerTestModeConfiguration = false;
- if (e.Args.Length > 0)
- {
- for (int i = 0; i != e.Args.Length; ++i)
- {
- if (e.Args[i] == "/EngineerTestMode")
- {
- loadEngineerTestModeConfiguration = true;
- }
- }
- }
- #if DEBUG
- loadEngineerTestModeConfiguration = ApplyDevelopmentMode();
- #endif
- // Set the Application in Engineer Test Mode
- if (loadEngineerTestModeConfiguration && File.Exists(Path.Combine(Paths.KioskDataPath, KioskConfiguration.ENGINEER_TEST_MODE_CONFIGURATION_FILENAME)))
- {
- // Add the Global Test Mode Variables
- GlobalVariables.Instance.Variables["Sentinel.Kiosk.EngineerTestMode"] = true;
- // Load the Test Mode Configuration
- KioskHostController.Instance.KioskConfiguration = KioskConfiguration.Load(Path.Combine(Paths.KioskDataPath, KioskConfiguration.ENGINEER_TEST_MODE_CONFIGURATION_FILENAME));
- }
- else
- {
- // Load the Runtime Configuration
- KioskHostController.Instance.KioskConfiguration = KioskConfiguration.Load(Path.Combine(Paths.KioskDataPath, KioskConfiguration.CONFIGURATION_FILENAME));
- }
- // Start the Message Server
- bool startServerRes = InterAppMsgServer.Instance.StartServer(KioskHostController.Instance.KioskConfiguration.CommunicationAddress);
- // Only let one instance of the application run?
- if (KioskHostController.Instance.KioskConfiguration.SingleInstance)
- if ((Process.GetProcessesByName(ResourceAssembly.GetName().Name).Length > 1))
- Current.Shutdown();
- // Ignore unhandled exceptions when the process terminates unexpectedly
- if (KioskHostController.Instance.KioskConfiguration.UnhandledExceptionFilterEnabled)
- ExceptionHandler.DisableExceptionReport();
- // Add the Kiosk Configuration
- GlobalVariables.Instance.Variables.Add("Sentinel.Kiosk.Configuration", KioskHostController.Instance.KioskConfiguration);
- KioskHostController.Instance.KioskConfiguration.PropertyChanged += KioskConfiguration_PropertyChanged;
- }
- private void KioskConfiguration_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- GlobalVariables.Instance.Variables.NotifyObserversOfChange("Sentinel.Kiosk.Configuration");
- }
- private void Application_Exit(object sender, ExitEventArgs e)
- {
- // N/A
- }
- private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
- {
- try
- {
- // Unexpected error, log this to the system
- LogController.Instance.LogSystemEvent(e.Exception);
- // Handle the Event
- e.Handled = KioskHostController.Instance.KioskConfiguration.IgnoreUnhandledExceptions;
- }
- catch (System.Exception)
- {
- // Handle the Event
- e.Handled = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement