private void AddProfile_MouseDown(object sender, MouseButtonEventArgs e) { Microsoft.Win32.OpenFileDialog exe_filedlg = new Microsoft.Win32.OpenFileDialog(); exe_filedlg.DefaultExt = ".exe"; exe_filedlg.Filter = "Executable Files (*.exe)|*.exe;"; Nullable <bool> result = exe_filedlg.ShowDialog(); if (result.HasValue && result == true) { string filename = System.IO.Path.GetFileName(exe_filedlg.FileName.ToLowerInvariant()); if (Global.LightingStateManager.Events.ContainsKey(filename)) { if (Global.LightingStateManager.Events[filename] is GameEvent_Aurora_Wrapper) { Global.LightingStateManager.Events.Remove(filename); } else { MessageBox.Show("Profile for this application already exists."); return; } } GenericApplication gen_app_pm = new GenericApplication(filename); gen_app_pm.Initialize(); ((GenericApplicationSettings)gen_app_pm.Settings).ApplicationName = Path.GetFileNameWithoutExtension(filename); System.Drawing.Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(exe_filedlg.FileName.ToLowerInvariant()); if (!System.IO.Directory.Exists(gen_app_pm.GetProfileFolderPath())) { System.IO.Directory.CreateDirectory(gen_app_pm.GetProfileFolderPath()); } using (var icon_asbitmap = ico.ToBitmap()) { icon_asbitmap.Save(Path.Combine(gen_app_pm.GetProfileFolderPath(), "icon.png"), System.Drawing.Imaging.ImageFormat.Png); } ico.Dispose(); Global.LightingStateManager.RegisterEvent(gen_app_pm); ConfigManager.Save(Global.Configuration); GenerateProfileStack(filename); } }
private void AddProfile_MouseDown(object sender, MouseButtonEventArgs e) { Window_ProcessSelection dialog = new Window_ProcessSelection { CheckCustomPathExists = true, ButtonLabel = "Add Profile", Title = "Add Profile" }; if (dialog.ShowDialog() == true && !string.IsNullOrWhiteSpace(dialog.ChosenExecutablePath)) // do not need to check if dialog is already in excluded_programs since it is a Set and only contains unique items by definition { string filename = Path.GetFileName(dialog.ChosenExecutablePath.ToLowerInvariant()); if (Global.LightingStateManager.Events.ContainsKey(filename)) { if (Global.LightingStateManager.Events[filename] is GameEvent_Aurora_Wrapper) { Global.LightingStateManager.Events.Remove(filename); } else { MessageBox.Show("Profile for this application already exists."); return; } } GenericApplication gen_app_pm = new GenericApplication(filename); gen_app_pm.Initialize(); ((GenericApplicationSettings)gen_app_pm.Settings).ApplicationName = Path.GetFileNameWithoutExtension(filename); System.Drawing.Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(dialog.ChosenExecutablePath.ToLowerInvariant()); if (!Directory.Exists(gen_app_pm.GetProfileFolderPath())) { Directory.CreateDirectory(gen_app_pm.GetProfileFolderPath()); } using (var icon_asbitmap = ico.ToBitmap()) { icon_asbitmap.Save(Path.Combine(gen_app_pm.GetProfileFolderPath(), "icon.png"), System.Drawing.Imaging.ImageFormat.Png); } ico.Dispose(); Global.LightingStateManager.RegisterEvent(gen_app_pm); ConfigManager.Save(Global.Configuration); GenerateProfileStack(filename); } }
public void RemoveGenericProfile(string key) { if (Events.ContainsKey(key)) { if (!(Events[key] is GenericApplication)) { return; } GenericApplication profile = (GenericApplication)Events[key]; string path = profile.GetProfileFolderPath(); if (Directory.Exists(path)) { Directory.Delete(path, true); } Events.Remove(key); Global.Configuration.ProfileOrder.Remove(key); //SaveSettings(); } }
public GenericController(GenericApplication <Rest, Dto> application) { this.Application = application; }