private void AddLocationButton_Click(object sender, EventArgs e) { var path = LocationFolderBrowserDialog.SelectedPath; if (string.IsNullOrEmpty(path)) { path = GameScanLocationsListBox.Text; } if (string.IsNullOrEmpty(path)) { path = System.IO.Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); } LocationFolderBrowserDialog.SelectedPath = path; LocationFolderBrowserDialog.Description = "Browse for Scan Location"; var result = LocationFolderBrowserDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { // Don't allow to add windows folder. var winFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows); if (LocationFolderBrowserDialog.SelectedPath.StartsWith(winFolder, StringComparison.OrdinalIgnoreCase)) { MessageBoxForm.Show("Windows folders are not allowed.", "Windows Folder", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (!Contains(LocationFolderBrowserDialog.SelectedPath)) { SettingsManager.Options.GameScanLocations.Add(LocationFolderBrowserDialog.SelectedPath); // Change selected index for change event to fire. GameScanLocationsListBox.SelectedItem = LocationFolderBrowserDialog.SelectedPath; } } } }
public void AddNewGame() { var fullPath = ""; var row = GamesDataGridView.SelectedRows.Cast <DataGridViewRow>().FirstOrDefault(); if (row != null) { var item = (x360ce.Engine.Data.UserGame)row.DataBoundItem; fullPath = item.FullPath; } var path = ""; AddGameOpenFileDialog.DefaultExt = ".exe"; if (!string.IsNullOrEmpty(fullPath)) { var fi = new System.IO.FileInfo(fullPath); if (string.IsNullOrEmpty(path)) { path = fi.Directory.FullName; } AddGameOpenFileDialog.FileName = fi.Name; } AddGameOpenFileDialog.Filter = EngineHelper.GetFileDescription(".exe") + " (*.exe)|*.exe|All files (*.*)|*.*"; AddGameOpenFileDialog.FilterIndex = 1; AddGameOpenFileDialog.RestoreDirectory = true; if (string.IsNullOrEmpty(path)) { path = System.IO.Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); } AddGameOpenFileDialog.InitialDirectory = path; AddGameOpenFileDialog.Title = "Browse for Executable"; var result = AddGameOpenFileDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { // Don't allow to add windows folder. var winFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows); if (AddGameOpenFileDialog.FileName.StartsWith(winFolder, StringComparison.OrdinalIgnoreCase)) { MessageBoxForm.Show("Windows folders are not allowed.", "Windows Folder", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ScanStarted = DateTime.Now; var success = System.Threading.ThreadPool.QueueUserWorkItem(ScanGames, AddGameOpenFileDialog.FileName); if (!success) { ScanProgressLevel0Label.Text = "Scan failed!"; ScanProgressLevel1Label.Text = ""; } } } }
private void LoginButton_Click(object sender, EventArgs e) { // Secure login over insecure web services. if (LoginButton.Text == "Log In") { var o = SettingsManager.Options; var saveOptions = false; if (o.CheckAndFixUserRsaKeys()) { SettingsManager.OptionsData.Save(); } var ws = new WebServiceClient(); var url = MainForm.Current.OptionsPanel.InternetDatabaseUrlComboBox.Text; ws.Url = url; CloudMessage results; // If cloud RSA keys are missing then... if (string.IsNullOrEmpty(o.CloudRsaPublicKey)) { // Step 1: Get Server's Public RSA key for encryption. var msg = new CloudMessage(CloudAction.GetPublicRsaKey); CloudHelper.ApplySecurity(msg); msg.Values.Add(CloudKey.RsaPublicKey, o.UserRsaPublicKey); // Retrieve public RSA key. results = ws.Execute(msg); if (results.ErrorCode == 0) { o.CloudRsaPublicKey = results.Values.GetValue <string>(CloudKey.RsaPublicKey); saveOptions = true; } } if (saveOptions) { SettingsManager.OptionsData.Save(); } var cmd2 = new CloudMessage(CloudAction.LogIn); CloudHelper.ApplySecurity(cmd2, o.UserRsaPublicKey, o.CloudRsaPublicKey, UsernameTextBox.Text, PasswordTextBox.Text); cmd2.Values.Add(CloudKey.ComputerId, o.ComputerId, true); cmd2.Values.Add(CloudKey.ProfileId, o.ProfileId, true); results = ws.Execute(cmd2); if (results.ErrorCode > 0) { MessageBoxForm.Show(results.ErrorMessage, string.Format("{0} Result", CloudAction.LogIn), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBoxForm.Show(string.Format("Authorized: {0}", results.ErrorMessage), string.Format("{0} Result", CloudAction.LogIn), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { } }
void AddNewGame() { var fullPath = ""; var row = GamesDataGridView.SelectedRows.Cast <DataGridViewRow>().FirstOrDefault(); if (row != null) { var item = (x360ce.Engine.Data.Game)row.DataBoundItem; fullPath = item.FullPath; } var path = ""; AddGameOpenFileDialog.DefaultExt = ".exe"; if (!string.IsNullOrEmpty(fullPath)) { var fi = new System.IO.FileInfo(fullPath); if (string.IsNullOrEmpty(path)) { path = fi.Directory.FullName; } AddGameOpenFileDialog.FileName = fi.Name; } AddGameOpenFileDialog.Filter = EngineHelper.GetFileDescription(".exe") + " (*.exe)|*.exe|All files (*.*)|*.*"; AddGameOpenFileDialog.FilterIndex = 1; AddGameOpenFileDialog.RestoreDirectory = true; if (string.IsNullOrEmpty(path)) { path = System.IO.Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); } AddGameOpenFileDialog.InitialDirectory = path; AddGameOpenFileDialog.Title = "Browse for Executable"; var result = AddGameOpenFileDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { // Don't allow to add windows folder. var winFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows); if (AddGameOpenFileDialog.FileName.StartsWith(winFolder)) { MessageBoxForm.Show("Windows folders are not allowed.", "Windows Folder", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ProcessExecutable(AddGameOpenFileDialog.FileName); GamesDataGridView.ClearSelection(); RebindGames(System.IO.Path.GetFileName(AddGameOpenFileDialog.FileName)); } } }
private void DevicesDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } var grid = (DataGridView)sender; var row = grid.Rows[e.RowIndex]; var item = (Engine.Data.UserDevice)row.DataBoundItem; // If user clicked on the CheckBox column then... if (e.ColumnIndex == grid.Columns[IsEnabledColumn.Name].Index) { // Changed check (enabled state) of the current item. item.IsEnabled = !item.IsEnabled; } else if (e.ColumnIndex == grid.Columns[IsHiddenColumn.Name].Index) { //var guardianHardwareId = ViGEm.HidGuardianHelper.GetHardwareId(item.HidDevicePath); var guardianHardwareId = item.HidDeviceId; if (!string.IsNullOrEmpty(guardianHardwareId)) { var canModify = ViGEm.HidGuardianHelper.CanModifyAffectedDevices(true); if (canModify) { item.IsHidden = !item.IsHidden; if (item.IsHidden) { ViGEm.HidGuardianHelper.InsertToAffected(guardianHardwareId); } else { ViGEm.HidGuardianHelper.RemoveFromAffected(guardianHardwareId); } } else { MessageBoxForm.Show("Can't modify registry. Please run as Aministrator.", "Permission Denied", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } }
private void BrowseButton_Click(object sender, EventArgs e) { var path = ""; GameApplicationOpenFileDialog.DefaultExt = ".exe"; if (!string.IsNullOrEmpty(GameApplicationLocationTextBox.Text)) { var fi = new System.IO.FileInfo(GameApplicationLocationTextBox.Text); if (string.IsNullOrEmpty(path)) { path = fi.Directory.FullName; } GameApplicationOpenFileDialog.FileName = fi.Name; } GameApplicationOpenFileDialog.Filter = Helper.GetFileDescription(".exe") + " (*.exe)|*.exe|All files (*.*)|*.*"; GameApplicationOpenFileDialog.FilterIndex = 1; GameApplicationOpenFileDialog.RestoreDirectory = true; if (string.IsNullOrEmpty(path)) { path = System.IO.Path.GetPathRoot(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); } GameApplicationOpenFileDialog.InitialDirectory = path; GameApplicationOpenFileDialog.Title = "Browse for Executable"; var result = GameApplicationOpenFileDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { // Don't allow to add windows folder. var winFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.Windows); if (GameApplicationOpenFileDialog.FileName.StartsWith(winFolder)) { MessageBoxForm.Show("Windows folders are not allowed.", "Windows Folder", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { GameApplicationLocationTextBox.Text = GameApplicationOpenFileDialog.FileName; ProcessExecutable(GameApplicationOpenFileDialog.FileName); } } }
private void TasksDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex < 0 || e.RowIndex < 0) { return; } var item = TasksDataGridView.SelectedRows.Cast <DataGridViewRow>().Select(x => (CloudItem)x.DataBoundItem).FirstOrDefault(); if (item == null) { return; } var error = item.Error; if (error == null) { return; } var message = JocysCom.ClassLibrary.Runtime.LogHelper.ExceptionToText(error); MessageBoxForm.Show(message, error.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); }