/// <summary> /// Performs any processing or data setup needed before the module is /// started. /// </summary> /// <param name="showLoadingWindow">Whether the module should display a /// loading or splash screen while performing initialization.</param> /// <param name="isTouchScreen">Whether this module is running on a /// touchscreen-based device.</param> /// <param name="instanceId">The unique identifier of the running /// instance of this module.</param> /// <returns>true if the initialization was successful; otherwise, /// false.</returns> public bool Initialize(bool showLoadingWindow, bool isTouchScreen, int instanceId) { // Check to see if we are already initialized. if (IsInitialized) { return(IsInitialized); } InstanceId = instanceId; // Create a settings object with the default values. Settings = new SessionSummarySettings(); // Start COM interface to EliteMCP. EliteModuleComm modComm = null; int machineId = 0; int staffId = 0; try { modComm = new EliteModuleComm(); machineId = modComm.GetMachineId(); OperatorId = modComm.GetOperatorId(); staffId = modComm.GetStaffId(); } catch (Exception ex) { MessageBoxOptions options = 0; if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft) { options = MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign; } MessageBox.Show(string.Format(CultureInfo.CurrentCulture, Resources.GetDeviceInfoFailed, ex.Message), Resources.SessionSummaryName, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, options); return(IsInitialized); } // Session Summary always runs in windowed mode. Settings.DisplayMode = DisplayMode.Windowed; // Create and show the loading form. LoadingForm = new LoadingForm(Settings.DisplayMode); LoadingForm.ApplicationName = Resources.SessionSummaryName; LoadingForm.Version = EliteModule.GetVersion(Assembly.GetExecutingAssembly()); LoadingForm.Copyright = EliteModule.GetCopyright(Assembly.GetExecutingAssembly()); LoadingForm.Cursor = System.Windows.Forms.Cursors.WaitCursor; if (showLoadingWindow) { LoadingForm.Show(); } LoadingForm.Status = Resources.LoadingMachineInfo; CreateApplication(); if (!LoadSettings(OperatorId, machineId)) { return(IsInitialized); } if (!LoadOperatorData(OperatorId)) { return(IsInitialized); } if (!LoadStaff(staffId)) { return(IsInitialized); } if (!CreateLogger()) { return(IsInitialized); } // Check to see if we only want to display in English. if (Settings.ForceEnglish) { EliteModule.ForceEnglish(); Logger.Log("Forcing English.", LoggerLevel.Configuration); } if (!LoadCurrencies()) { return(IsInitialized); } if (!CreateControllers()) { return(IsInitialized); } if (!CreateReport()) { return(IsInitialized); } LoadingForm.Status = Resources.Starting; if (!CreateWindows()) { return(IsInitialized); } // Have the controller notified when the main window opens. MainWindow.Loaded += MainWindowLoaded; IsInitialized = true; Logger.Log("Session Summary initialized!", LoggerLevel.Debug); return(IsInitialized); }
/// <summary> /// Displays the specified view. /// </summary> /// <param name="view">The view to display.</param> /// <exception cref="System.ArgumentException">view is /// invalid.</exception> public void NavigateTo(SessionSummaryView view, NavigateToArgs e) { switch (view) { case SessionSummaryView.About: AboutWindow aboutWin = new AboutWindow(Settings.UseAcceleration, Resources.SessionSummaryName, EliteModule.GetVersion(Assembly.GetExecutingAssembly()), EliteModule.GetCopyright(Assembly.GetExecutingAssembly()), Resources.ModuleDescription); aboutWin.Owner = MainWindow; CurrentView = aboutWin; aboutWin.ShowDialog(); CurrentView = MainWindow; break; case SessionSummaryView.SessionCosts: { SessionCostsWindow sessionCostWin = new SessionCostsWindow(Settings.UseAcceleration); sessionCostWin.Owner = MainWindow; sessionCostWin.DataContext = new SessionCostsViewModel(SessionCostsController); CurrentView = sessionCostWin; sessionCostWin.ShowDialog(); ((IDisposable)sessionCostWin.DataContext).Dispose(); CurrentView = MainWindow; } break; case SessionSummaryView.SelectSessionCosts: { SelectSessionCostsWindow sessionCostWin = new SelectSessionCostsWindow(Settings.UseAcceleration); sessionCostWin.Owner = MainWindow; sessionCostWin.DataContext = new SelectSessionCostsViewModel(SessionCostsController, (Summary)e.Argument); CurrentView = sessionCostWin; sessionCostWin.ShowDialog(); ((IDisposable)sessionCostWin.DataContext).Dispose(); CurrentView = MainWindow; } break; case SessionSummaryView.Report: { if (m_reportWindow == null) { m_reportWindow = new SessionSummaryReportWindow(); m_reportWindow.Owner = MainWindow; m_reportWindow.Closed += ReportWindowClosed; m_reportWindow.Show(); } m_reportWindow.Focus(); ArrayList args = (ArrayList)e.Argument; DateTime date = (DateTime)args[0]; short session = (short)args[1]; RefreshSessionSummaryReport(date, session); m_reportWindow.DisplayReport(SessionSummaryReport); } break; case SessionSummaryView.ActualCashCalculator: { var calcWin = new ActualCashCalculatorWindow(Settings.UseAcceleration); calcWin.Owner = MainWindow; calcWin.DataContext = new ActualCashCalculatorViewModel(this, (Summary)e.Argument); CurrentView = calcWin; calcWin.ShowDialog(); var disposable = calcWin.DataContext as IDisposable; if (disposable != null) { disposable.Dispose(); } CurrentView = MainWindow; } break; case SessionSummaryView.SessionBankBreakdown: { var calcWin = new SessionBanksWindow(Settings.UseAcceleration); calcWin.Owner = MainWindow; calcWin.DataContext = new SessionBanksViewModel(this, (List <BasicBankInfo>)e.Argument); CurrentView = calcWin; calcWin.ShowDialog(); var disposable = calcWin.DataContext as IDisposable; if (disposable != null) { disposable.Dispose(); } CurrentView = MainWindow; } break; default: throw new ArgumentException(); } }