private void DoSetTemposLibrary(string[] tokens) { if (tokens.Length == 1) { PrintLine(ConfigurationManager.UseKeyboardHook ? Types.Strings.ShellKeyboardLockStatusOn : Types.Strings.ShellKeyboardLockStatusOff); return; } if ((tokens[1].ToLower().Equals("on")) || (tokens[1].ToLower().Equals("true"))) { if (!ConfigurationManager.UseKeyboardHook) { ConfigurationManager.SetUseKeyboardHook(true); UserControlManager.Enable(); } PrintLine(Types.Strings.ShellKeyboardLockStatusOn); } else if ((tokens[1].ToLower().Equals("off")) || (tokens[1].ToLower().Equals("false"))) { if (ConfigurationManager.UseKeyboardHook) { ConfigurationManager.SetUseKeyboardHook(false); UserControlManager.Disable(); } PrintLine(Types.Strings.ShellKeyboardLockStatusOff); } }
public static void ShutdownApplication(bool showTaskbar = true) { IsAppShuttingDown = true; LocalSetting.Update(); #if !DEMO if (LocalSetting.Values.String["StartBroadcastServer"] != null) { BroadcastServerSocket.Stop(); } BroadcastClientSocket.Stop(); #endif if (TaskManagerServiceHelper.IsStarted) { TaskManagerServiceHelper.IsTaskManagerDisabled = false; } if (ConfigurationManager.UseKeyboardHook) { UserControlManager.Disable(); } if (showTaskbar) { UserControlManager.ShowTaskbar(true); } Logger.WriteLog("Exiting application"); Logger.CloseLog(); TemPOS.MainWindow.Singleton.AllowClose = true; TemPOS.MainWindow.Singleton.Dispatcher.Invoke((Action)(() => { TemPOS.MainWindow.Singleton.Closed += SingletonClosed; TemPOS.MainWindow.Singleton.Close(); })); }
private void BadLicenseShutdown(bool showDialog = true) { if (showDialog) { PosDialogWindow.ShowDialog( Strings.YouHaveNotEnteredAValidCompanyNameAndorSerialNumber, Strings.Error); } UserControlManager.ShowTaskbar(true); Application.Current.Shutdown(); }
private void radioButtonIsNotKeyboardRestricted_SelectionGained(object sender, EventArgs e) { if (!IsInitialized) { return; } ConfigurationManager.SetUseKeyboardHook(false); #if !DEBUG UserControlManager.Disable(); UserControlManager.Enable(false); #endif radioButtonIsKeyboardRestricted.IsSelected = false; }
private void Startup() { #if !DEMO // Handle an invalid license if ((LocalSetting.Values.String["IsAuthorized"] == null) || !LocalSetting.Values.String["IsAuthorized"].Equals("Yes")) { // Display the Strings.LocalsettingEditor if (PromptForConnectionString(false)) { if (!string.IsNullOrEmpty(LocalSetting.CompanyName) && !string.IsNullOrEmpty(LocalSetting.ApplicationSerialNumber)) { // Check for access to the update server var client = new Srp6ClientSocket( LocalSetting.CompanyName, LocalSetting.ApplicationSerialNumber); client.ConnectFailed += client_ConnectFailed; client.Disconnected += client_Disconnected; client.Authenticated += client_Authenticated; client.Start(); return; } } BadLicenseShutdown(); } else #endif { #if !DEMO if ((App.StartupArgs.Length == 1) && App.StartupArgs[0].ToLower().Equals(@"/update")) { PosDialogWindow window = GeneralSettingsUpdateControl.CreateInDefaultWindow(); GeneralSettingsUpdateControl control = window.DockedControl as GeneralSettingsUpdateControl; Hide(); window.ShowDialog(); UserControlManager.ShowTaskbar(true); Application.Current.Shutdown(); return; } #endif PosDialogWindow.SetStartupWindow(this); BeginStartup(); } }
private void CheckDatabaseConnection() { if (!EnsureDatabaseConnection()) { Dispatcher.Invoke((Action)(() => { if (PromptForChanges()) { new Thread(CheckDatabaseConnection).Start(); } else { UserControlManager.ShowTaskbar(true); Application.Current.Shutdown(); } })); } else { Dispatcher.Invoke((Action)(DoFinishInstall)); } }
private void LogInButton_Click(object sender, EventArgs e) { try { Connection.Open(); SqlDataAdapter Adapter1 = new SqlDataAdapter(string.Format("Select Count(*) From LogInInfo Where Username COLLATE Latin1_General_CS_AS = '{0}' and Password COLLATE Latin1_General_CS_AS = '{1}'", UserNameTextBox.Text, PasswordTextBox.Text), Connection); DataTable LogInTable = new DataTable(); Adapter1.Fill(LogInTable); if (LogInTable.Rows[0][0].ToString() == "1") { Connection.Close(); try { Connection.Open(); string UserRole = ""; SqlDataAdapter Adapter2 = new SqlDataAdapter(string.Format("Select UserRole From UserInformation Where Username='******'", UserNameTextBox.Text), Connection); DataTable UserInfomationTable = new DataTable(); Adapter2.Fill(UserInfomationTable); // MessageBox.Show("ok"); foreach (DataRow row in UserInfomationTable.Rows) { UserRole = row["UserRole"].ToString(); } Connection.Close(); if (UserRole == "Global Admin") { this.Hide(); PopupNotifier popup = new PopupNotifier(); popup.Image = Properties.Resources.Successfull; popup.TitleText = "Log In"; popup.ContentText = "Successfully Loged In"; popup.ShowCloseButton = false; popup.Popup(); AdminControlManager adminControlManager = new AdminControlManager(UserNameTextBox.Text); adminControlManager.Show(); } else { this.Hide(); PopupNotifier popup = new PopupNotifier(); popup.Image = Properties.Resources.Successfull; popup.TitleText = "Log In"; popup.ContentText = "Successfully Loged In user"; popup.ShowCloseButton = false; popup.Popup(); UserControlManager userControlManager = new UserControlManager(); userControlManager.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Log In", MessageBoxButtons.OK, MessageBoxIcon.Error); Connection.Close(); } } else { MetroFramework.MetroMessageBox.Show(this, "Enter Your Username and Password Correctly", "Invalid Username/Password", MessageBoxButtons.OK, MessageBoxIcon.Error); Connection.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Log In", MessageBoxButtons.OK, MessageBoxIcon.Error); Connection.Close(); } }
/// <summary> /// Called when all startup conditions have been meet. The database is now /// accessible as well. /// </summary> private void FinalStartUp() { if ((_notification != null) && _notification.IsLoaded && _notification.IsVisible) { _notification.Close(); } // Disable AlwaysUseDefaults which was being used prior to this... ConfigurationManager.AlwaysUseDefaults = false; // Task Manager Protection // SettingManager.SetStoreSetting("DontDisableTaskManager", 0); int?isDisabled = SettingManager.GetInt32("DontDisableTaskManager"); if (isDisabled.HasValue && (isDisabled.Value == 1)) { BeginStartup(); return; } if (!TaskManagerServiceHelper.IsInstalled) { if (PosDialogWindow.ShowDialog(Types.Strings.DoYouWantToInstallTheTaskManagerAccessService, Types.Strings.InstallService, DialogButtons.YesNo, false) == DialogButton.Yes) { new Thread(TaskManagerServiceHelper.InstallThread).Start(); } } else if (!TaskManagerServiceHelper.IsStarted) { if (PosDialogWindow.ShowDialog(Types.Strings.DoYouWantToStartTheTaskManagerAccessService, Types.Strings.StartService, DialogButtons.YesNo, false) == DialogButton.Yes) { new Thread(TaskManagerServiceHelper.StartThread).Start(); } } else { TaskManagerServiceHelper.IsTaskManagerDisabled = true; } // Install the SQL Assembly (if one is pending installation) if (Updater.InstallSQLAssembly()) { #if DEBUG PosDialogWindow.ShowDialog("New SQL Assembly Installed", Types.Strings.Information); #endif } // Apply any required database patches at runtime SqlServerSetup.ApplyDatabasePatches(); // Check to make sure the model classes and the tables match if (!DataModelBase.ValidateDatabase()) { #if DEBUG string results = DataModelBase.InvalidDatabaseReport(); PosDialogWindow.ShowDialog( results, "Invalid Database Report"); #else PosDialogWindow.ShowDialog( Strings.TheDatabaseDesignCurrentlyBeingUsedIsIncorrectForThisVersionOfTempos, Strings.StartupError); #endif UserControlManager.ShowTaskbar(true); Application.Current.Shutdown(); return; } // Enable user control UserControlManager.Enable(ConfigurationManager.UseKeyboardHook); UserControlManager.ShowTaskbar(false); // Start-up MainWindow Show(); _mainWindow = new MainWindow(); _mainWindow.Show(); }
void Current_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { e.Handled = true; // Stop the auto-logoof timer LoginControl.StopAutoLogoutTimer(); // Close all database connections DataModelBase.CloseAll(); #if !DEMO // Send the exception to the upgrade server Updater.StartCrashReport(e.Exception); #endif // Save the exception, serialized to the AppData folder try { DateTime now = DateTime.Now; string rootDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + "TemPOS"; if (!Directory.Exists(rootDirectory)) { Directory.CreateDirectory(rootDirectory); } string path = rootDirectory + Path.DirectorySeparatorChar + "crashdata-" + now.Year + now.Month.ToString("D2") + now.Day.ToString("D2") + "-" + now.Hour.ToString("D2") + now.Minute.ToString("D2") + now.Second.ToString("D2") + ".bin"; using (FileStream fileStream = new FileStream(path, FileMode.CreateNew)) { byte[] serialData = e.Exception.SerializeObject(); using (BinaryWriter writer = new BinaryWriter(fileStream)) { writer.Write(serialData); } } } catch { } // Display the exception message DisplayExceptionDialog(e.Exception); // Remove employee table lock (that prevents simultaneous login) if (SessionManager.ActiveEmployee != null) { PosHelper.Unlock(TableName.Employee, SessionManager.ActiveEmployee.Id); } // Close this app if (_mainWindow != null) { _mainWindow.AllowClose = true; _mainWindow.Close(); } // Disable user control crap if (ConfigurationManager.UseKeyboardHook) { UserControlManager.Disable(); } UserControlManager.ShowTaskbar(true); #if !DEBUG if (PastRestartPoint) { // Restart application Process.Start(Application.ResourceAssembly.Location, "/RESTART"); App.SwitchToDefaultDesktopOnClose = false; } else { App.SwitchToDefaultDesktopOnClose = true; } #else App.SwitchToDefaultDesktopOnClose = true; #endif // Shutdown current application Application.Current.Shutdown(); Process.GetCurrentProcess().Kill(); }
void Start() { if (instance != null) { Debug.LogError("There should not be two mouse managers"); } instance = this; camCont = Camera.main.GetComponent <CameraControls> (); camAuto = Camera.main.GetComponent <CameraAutoMove> (); hexOutliner = Instantiate(UIHexBuilder.Instance.flatHexPrefab); hexOutliner.name = "Cursor"; hexOutliner.SetActive(false); hexOutliner.GetComponent <MeshRenderer> ().material.color = Color.green; //Control Modes controlModes = new ControlMode[6]; controlModes [(int)ControlModeEnum.Observe] = new ControlMode( type: ControlModeEnum.Observe, onMouseOver: (hex) => { }, onMouseNotOverMap: () => { }, onLeftClick: (hex) => { }, onRightClick: (hex) => { }, onTabPressed: () => { }, onEnteringMode: () => { }, onLeavingMode: () => { }, autoOnly: false ); controlModes [(int)ControlModeEnum.Move] = new ControlMode( type: ControlModeEnum.Move, onMouseOver: (hex) => { MovementMouseUI(hex); }, onMouseNotOverMap: () => { DisableMoveUI(); }, onLeftClick: (hex) => { SelectHex(hex); }, onRightClick: (hex) => { MoveSelectedToHex(hex); }, onTabPressed: () => { if (selected != null) { SelectNext(selected); } }, onEnteringMode: () => { SelectFirst(); }, onLeavingMode: () => { DisableMoveUI(); if (selected != null) { selected.HideMovementHexes(); } }, autoOnly: false ); //Placement PlacementMode pm = new PlacementMode(TeamManager.Instance.TeamsInMatch); controlModes [(int)ControlModeEnum.Placement] = new ControlMode( type: ControlModeEnum.Placement, onMouseOver: (hex) => { //if over valid hex, green & show ghost of model, else red pm.PlacementUI(hex); }, onMouseNotOverMap: () => { pm.DisablePlacementUI(); }, onLeftClick: (hex) => { pm.PlaceContestant(hex); //or pick up previously placed contestant }, onRightClick: (hex) => { //perhaps remove contestant? }, onTabPressed: () => { //cycle through contestants }, onEnteringMode: () => { //select first contestant - which is done by constructor }, onLeavingMode: () => { pm.EraseUI(); }, autoOnly: false ); }