//Show and load Settings window information async Task ShowLoadSettingsPopup() { try { //Set and load the quick launch application name try { DataBindApp QuickLaunchApp = CombineAppLists(false, false, false).Where(x => x.QuickLaunch).FirstOrDefault(); btn_Settings_AppQuickLaunch_TextBlock.Text = "Change quick launch app: " + QuickLaunchApp.Name; } catch { btn_Settings_AppQuickLaunch_TextBlock.Text = "Change the quick launch app"; } //Set the available monitor amount try { slider_SettingsDisplayMonitor.Maximum = Screen.AllScreens.Count(); } catch { } //Show the settings popup await Popup_Show(grid_Popup_Settings, null); //Focus on settings tab await Listbox_Settings_SingleTap(); } catch { } }
//Handle app list right click async Task lb_AppList_RightClick(object sender) { try { ListBox listboxSender = (ListBox)sender; int listboxSelectedIndex = listboxSender.SelectedIndex; if (listboxSender.SelectedItems.Count > 0 && listboxSelectedIndex != -1) { DataBindApp selectedItem = (DataBindApp)listboxSender.SelectedItem; if (selectedItem.Category == AppCategory.Process) { await RightClickProcess(listboxSender, listboxSelectedIndex, selectedItem); } else if (selectedItem.Category == AppCategory.Shortcut) { await RightClickShortcut(listboxSender, listboxSelectedIndex, selectedItem); } else if (selectedItem.Category == AppCategory.Launcher) { await RightClickLauncher(listboxSender, listboxSelectedIndex, selectedItem); } else { await RightClickList(listboxSender, listboxSelectedIndex, selectedItem); } } } catch { } }
//Enable monitor HDR async Task EnableHDRDatabindAuto(DataBindApp dataBindApp) { try { //Check executable name string executableName = string.Empty; string executableNameRaw = string.Empty; if (string.IsNullOrWhiteSpace(dataBindApp.NameExe)) { executableName = Path.GetFileNameWithoutExtension(dataBindApp.PathExe).ToLower(); executableNameRaw = dataBindApp.PathExe.ToLower(); } else { executableName = Path.GetFileNameWithoutExtension(dataBindApp.NameExe).ToLower(); executableNameRaw = dataBindApp.NameExe.ToLower(); } //Enable monitor HDR bool enabledHDR = vCtrlHDRProcessName.Any(x => x.String1.ToLower() == executableName || x.String1.ToLower() == executableNameRaw); if (enabledHDR) { await AllMonitorSwitchHDR(true, true); } } catch { } }
//Hide the launcher app async Task HideLauncherApp(ListBox listboxSender, int listboxSelectedIndex, DataBindApp dataBindApp) { try { await Notification_Send_Status("Hide", "Hiding launcher " + dataBindApp.Name); Debug.WriteLine("Hiding launcher by name: " + dataBindApp.Name); //Create new profile shared ProfileShared profileShared = new ProfileShared(); profileShared.String1 = dataBindApp.Name; //Add shortcut file to the ignore list vCtrlIgnoreLauncherName.Add(profileShared); JsonSaveObject(vCtrlIgnoreLauncherName, "CtrlIgnoreLauncherName"); //Remove application from the list await RemoveAppFromList(dataBindApp, false, false, true); //Select the previous index await ListboxFocusIndex(listboxSender, false, false, listboxSelectedIndex, vProcessCurrent.MainWindowHandle); } catch (Exception ex) { await Notification_Send_Status("Hide", "Failed hiding"); Debug.WriteLine("Failed hiding launcher: " + ex.Message); } }
//Launch a Win32 application from databindapp async Task <bool> PrepareProcessLauncherWin32Async(DataBindApp dataBindApp, string launchArgument, bool silent, bool allowMinimize, bool runAsAdmin, bool createNoWindow, bool launchKeyboard) { try { //Set the app title string appTitle = dataBindApp.Name; //Check the launch argument if (string.IsNullOrWhiteSpace(launchArgument)) { launchArgument = dataBindApp.Argument; } else { //Update the app title if (dataBindApp.Category == AppCategory.Emulator) { appTitle += " with rom"; } else if (dataBindApp.LaunchFilePicker) { appTitle += " with file"; } } return(await PrepareProcessLauncherWin32Async(appTitle, dataBindApp.PathExe, dataBindApp.PathLaunch, launchArgument, silent, allowMinimize, runAsAdmin, createNoWindow, launchKeyboard, false)); } catch { } return(false); }
async Task MoveApplicationList_Right() { try { //Sort the lists by number await SortAppListsByNumber(true); //Get the target application IEnumerable <DataBindApp> combinedApps = CombineAppLists(false, false, false).Where(x => x.Category == vMoveAppDataBind.Category); DataBindApp targetAppDataBind = combinedApps.OrderBy(x => x.Number).Where(x => x.Number > vMoveAppDataBind.Number).FirstOrDefault(); int selectedNumber = vMoveAppDataBind.Number; int targetNumber = targetAppDataBind.Number; Debug.WriteLine("Current number: " + selectedNumber + " / New number: " + targetNumber); //Update the application number vMoveAppDataBind.Number = targetNumber; targetAppDataBind.Number = selectedNumber; //Sort the lists by number await SortAppListsByNumber(true); await Notification_Send_Status("Sorting", "Moving app right"); //Save json applist JsonSaveApplications(); } catch { } }
//Launch a Win32 application from databindapp async Task <bool> PrepareProcessLauncherWin32Async(DataBindApp dataBindApp, string launchArgument, bool silent, bool allowMinimize, bool runAsAdmin, bool createNoWindow, bool launchKeyboard) { bool appLaunched = false; try { //Set the app title string appTitle = dataBindApp.Name; //Check the launch argument if (string.IsNullOrWhiteSpace(launchArgument)) { launchArgument = dataBindApp.Argument; } else { //Update the app title if (dataBindApp.Category == AppCategory.Emulator) { appTitle += " with rom"; } else if (dataBindApp.LaunchFilePicker) { appTitle += " with file"; } } //Chromium DPI launch argument string processName = Path.GetFileNameWithoutExtension(dataBindApp.PathExe); if (vCtrlChromiumBrowsers.Any(x => x.String1 == processName)) { //Get the current active screen int monitorNumber = Convert.ToInt32(Setting_Load(vConfigurationCtrlUI, "DisplayMonitor")); DisplayMonitor displayMonitorSettings = GetSingleMonitorEnumDisplay(monitorNumber); //Get the current screen dpi double screenDPI = displayMonitorSettings.DpiScaleHorizontal; double chromiumDPI = Convert.ToDouble(Setting_Load(vConfigurationCtrlUI, "AdjustChromiumDpi")); //Update the launch argument string stringDPI = (screenDPI + chromiumDPI).ToString(vAppCultureInfo); launchArgument += " -force-device-scale-factor=" + stringDPI; Debug.WriteLine("Chromium dpi scale factor: " + stringDPI); } //Launch the application appLaunched = await PrepareProcessLauncherWin32Async(appTitle, dataBindApp.PathExe, dataBindApp.PathLaunch, launchArgument, silent, allowMinimize, runAsAdmin, createNoWindow, launchKeyboard, false); //Update last launch date if (appLaunched) { dataBindApp.LastLaunch = DateTime.Now.ToString(vAppCultureInfo); //Debug.WriteLine("Updated last launch date: " + dataBindApp.LastLaunch); JsonSaveApplications(); } } catch { } return(appLaunched); }
//Launch the set quick launch app async Task LaunchQuickLaunchApp() { try { //Get the current quick launch application DataBindApp quickLaunchApp = CombineAppLists(false, false, false).Where(x => x.QuickLaunch).FirstOrDefault(); //Quick launch application if (quickLaunchApp != null) { //Check which launch method needs to be used await LaunchProcessSelector(quickLaunchApp); } else { await Notification_Send_Status("AppLaunch", "Please set a quick launch app"); Debug.WriteLine("Please set a quick launch app"); } } catch { await Notification_Send_Status("AppLaunch", "Please set a quick launch app"); Debug.WriteLine("Please set a quick launch app"); } }
//Show the quick launch prompt async Task QuickLaunchPrompt() { try { //Get the current quick launch application DataBindApp quickLaunchApp = CombineAppLists(false, false, false).Where(x => x.QuickLaunch).FirstOrDefault(); //Prompt user to quick launch application List <DataBindString> Answers = new List <DataBindString>(); DataBindString AnswerLaunch = new DataBindString(); AnswerLaunch.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/AppLaunch.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0); AnswerLaunch.Name = "Launch application"; Answers.Add(AnswerLaunch); DataBindString messageResult = await Popup_Show_MessageBox("Quick launch", "* You can change the quick launch application in the CtrlUI settings.", "Do you want to launch " + quickLaunchApp.Name + "?", Answers); if (messageResult != null) { if (messageResult == AnswerLaunch) { await LaunchQuickLaunchApp(); } } } catch { await Notification_Send_Status("AppLaunch", "Please set a quick launch app"); Debug.WriteLine("Please set a quick launch app"); } }
//Restart the process async Task RestartProcessAuto(ProcessMulti processMulti, DataBindApp dataBindApp, bool useLaunchArgument) { try { //Check the application category if (!useLaunchArgument && dataBindApp.Category != AppCategory.Process) { await CloseSingleProcessAuto(processMulti, dataBindApp, true, false); await LaunchProcessDatabindAuto(dataBindApp); return; } //Check keyboard controller launch string fileNameNoExtension = Path.GetFileNameWithoutExtension(dataBindApp.NameExe); bool keyboardProcess = vCtrlKeyboardProcessName.Any(x => x.String1.ToLower() == fileNameNoExtension.ToLower() || x.String1.ToLower() == dataBindApp.PathExe.ToLower()); bool keyboardLaunch = (keyboardProcess || dataBindApp.LaunchKeyboard) && vControllerAnyConnected(); //Restart the process if (processMulti.Type == ProcessType.UWP) { await PrepareRestartProcessUwp(dataBindApp, processMulti, useLaunchArgument, keyboardLaunch); } else if (processMulti.Type == ProcessType.Win32Store) { await PrepareRestartProcessWin32Store(dataBindApp, processMulti, useLaunchArgument, keyboardLaunch); } else { await PrepareRestartProcessWin32(dataBindApp, processMulti, useLaunchArgument, keyboardLaunch); } } catch { } }
//Close single process Win32 and Win32Store async Task <bool> CloseSingleProcessWin32AndWin32Store(DataBindApp dataBindApp, ProcessMulti processMulti, bool resetProcess, bool removeProcess) { try { await Notification_Send_Status("AppClose", "Closing " + dataBindApp.Name); Debug.WriteLine("Closing Win32 and Win32Store process: " + dataBindApp.Name); //Close the process by id or name bool closedProcess = false; if (processMulti.Identifier > 0) { closedProcess = CloseProcessById(processMulti.Identifier); } else if (!string.IsNullOrWhiteSpace(dataBindApp.NameExe)) { closedProcess = CloseProcessesByNameOrTitle(Path.GetFileNameWithoutExtension(dataBindApp.NameExe), false); } else { closedProcess = CloseProcessesByNameOrTitle(Path.GetFileNameWithoutExtension(dataBindApp.PathExe), false); } //Check if process closed if (closedProcess) { await Notification_Send_Status("AppClose", "Closed " + dataBindApp.Name); Debug.WriteLine("Closed Win32 and Win32Store process: " + dataBindApp.Name); //Reset the process running status if (resetProcess) { dataBindApp.StatusRunning = Visibility.Collapsed; dataBindApp.StatusSuspended = Visibility.Collapsed; dataBindApp.RunningProcessCount = string.Empty; dataBindApp.RunningTimeLastUpdate = 0; dataBindApp.ProcessMulti.Clear(); } //Remove the process from the list if (removeProcess) { await RemoveAppFromList(dataBindApp, false, false, true); } return(true); } else { await Notification_Send_Status("AppClose", "Failed to close the app"); Debug.WriteLine("Failed to close the application."); return(false); } } catch { } return(false); }
async Task BethesdaAddApplication(string appId, string appName, string appIcon, string installDir) { try { //Check if application name is ignored string appNameLower = appName.ToLower(); if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower)) { //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName); await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower); return; } //Check if application is installed if (!Directory.Exists(installDir)) { Debug.WriteLine("Bethesda game is not installed: " + appId); return; } //Get launch argument string runCommand = "bethesdanet://run/" + appId; vLauncherAppAvailableCheck.Add(runCommand); //Check if application is already added DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault(); if (launcherExistCheck != null) { //Debug.WriteLine("Bethesda app already in list: " + appId); return; } //Get application image BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, appIcon, "Bethesda" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0); //Add the application to the list DataBindApp dataBindApp = new DataBindApp() { Category = AppCategory.Launcher, Launcher = AppLauncher.Bethesda, Name = appName, ImageBitmap = iconBitmapImage, PathExe = runCommand, PathLaunch = installDir, StatusLauncher = vImagePreloadBethesda }; await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false); //Debug.WriteLine("Added Bethesda app: " + appName); } catch { Debug.WriteLine("Failed adding Bethesda app: " + appId); } }
//Launch an UWP or Win32Store application from databindapp async Task <bool> PrepareProcessLauncherUwpAndWin32StoreAsync(DataBindApp dataBindApp, bool silent, bool allowMinimize, bool launchKeyboard) { try { return(await PrepareProcessLauncherUwpAndWin32StoreAsync(dataBindApp.Name, dataBindApp.PathExe, dataBindApp.Argument, silent, allowMinimize, launchKeyboard)); } catch { } return(false); }
async Task UwpAddApplication(Package appPackage, AppxDetails appxDetails) { try { //Get application name string appName = appxDetails.DisplayName; //Check if application name is ignored string appNameLower = appName.ToLower(); if (vCtrlIgnoreLauncherName.Any(x => x.String1.ToLower() == appNameLower)) { //Debug.WriteLine("Launcher is on the blacklist skipping: " + appName); await ListBoxRemoveAll(lb_Launchers, List_Launchers, x => x.Name.ToLower() == appNameLower); return; } //Get basic application information string runCommand = appPackage.Id.FamilyName; vLauncherAppAvailableCheck.Add(runCommand); //Check if application is already added DataBindApp launcherExistCheck = List_Launchers.Where(x => x.PathExe.ToLower() == runCommand.ToLower()).FirstOrDefault(); if (launcherExistCheck != null) { //Debug.WriteLine("UWP app already in list: " + appIds); return; } //Load the application image BitmapImage iconBitmapImage = FileToBitmapImage(new string[] { appName, appxDetails.SquareLargestLogoPath, appxDetails.WideLargestLogoPath, "Microsoft" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 90, 0); //Add the application to the list DataBindApp dataBindApp = new DataBindApp() { Type = ProcessType.UWP, Launcher = AppLauncher.UWP, Category = AppCategory.Launcher, Name = appName, ImageBitmap = iconBitmapImage, PathExe = runCommand, StatusLauncher = vImagePreloadMicrosoft }; await ListBoxAddItem(lb_Launchers, List_Launchers, dataBindApp, false, false); //Debug.WriteLine("Added UWP app: " + appName); } catch { Debug.WriteLine("Failed adding UWP app: " + appxDetails.DisplayName); } }
//Rename the shortcut file async Task RenameShortcutFile(DataBindApp dataBindApp) { try { await Notification_Send_Status("Rename", "Renaming shortcut"); Debug.WriteLine("Renaming shortcut: " + dataBindApp.Name + " path: " + dataBindApp.ShortcutPath); //Show the text input popup string textInputString = await Popup_ShowHide_TextInput("Rename shortcut", dataBindApp.Name, "Rename the shortcut file", false); //Check if file name changed if (textInputString == dataBindApp.Name) { await Notification_Send_Status("Rename", "File name not changed"); Debug.WriteLine("The file name did not change."); return; } //Check the changed file name if (!string.IsNullOrWhiteSpace(textInputString)) { string shortcutDirectory = Path.GetDirectoryName(dataBindApp.ShortcutPath); string fileExtension = Path.GetExtension(dataBindApp.ShortcutPath); string newFilePath = Path.Combine(shortcutDirectory, textInputString + fileExtension); bool fileRenamed = File_Move(dataBindApp.ShortcutPath, newFilePath, true); if (fileRenamed) { dataBindApp.Name = textInputString; dataBindApp.ShortcutPath = newFilePath; await Notification_Send_Status("Rename", "Renamed shortcut"); Debug.WriteLine("Renamed shortcut file to: " + textInputString); } else { await Notification_Send_Status("Rename", "Failed renaming"); Debug.WriteLine("Failed renaming shortcut."); } } } catch (Exception ex) { await Notification_Send_Status("Rename", "Failed renaming"); Debug.WriteLine("Failed renaming shortcut: " + ex.Message); } }
//Launch databind process async Task LaunchProcessDatabindAuto(DataBindApp dataBindApp) { try { //Check keyboard controller launch string fileNameNoExtension = Path.GetFileNameWithoutExtension(dataBindApp.NameExe); bool keyboardProcess = vCtrlKeyboardProcessName.Any(x => x.String1.ToLower() == fileNameNoExtension.ToLower() || x.String1.ToLower() == dataBindApp.PathExe.ToLower()); bool keyboardLaunch = (keyboardProcess || dataBindApp.LaunchKeyboard) && vControllerAnyConnected(); //Check if databind paths are available if (!await CheckDatabindPathAuto(dataBindApp)) { return; } //Launch the databind process if (dataBindApp.Type == ProcessType.UWP || dataBindApp.Type == ProcessType.Win32Store) { await EnableHDRDatabindAuto(dataBindApp); await PrepareProcessLauncherUwpAndWin32StoreAsync(dataBindApp, false, true, keyboardLaunch); } else if (dataBindApp.LaunchFilePicker) { string launchArgument = await GetLaunchArgumentFilePicker(dataBindApp); if (launchArgument == "Cancel") { return; } await EnableHDRDatabindAuto(dataBindApp); await PrepareProcessLauncherWin32Async(dataBindApp, launchArgument, false, true, false, false, keyboardLaunch); } else if (dataBindApp.Category == AppCategory.Emulator && !dataBindApp.LaunchSkipRom) { string launchArgument = await GetLaunchArgumentEmulator(dataBindApp); if (launchArgument == "Cancel") { return; } await EnableHDRDatabindAuto(dataBindApp); await PrepareProcessLauncherWin32Async(dataBindApp, launchArgument, false, true, false, false, keyboardLaunch); } else { await EnableHDRDatabindAuto(dataBindApp); await PrepareProcessLauncherWin32Async(dataBindApp, string.Empty, false, true, false, false, keyboardLaunch); } } catch { } }
//Show the application move popup async Task Popup_Show_AppMove(DataBindApp dataBindApp) { try { //Set the move application variable vMoveAppDataBind = dataBindApp; //Set the application image image_MoveAppIcon.Source = dataBindApp.ImageBitmap; //Show the move popup await Popup_Show(grid_Popup_MoveApplication, btn_MoveAppLeft); } catch { } }
//Close all processes async Task CloseAllProcessesAuto(ProcessMulti processMulti, DataBindApp dataBindApp, bool resetProcess, bool removeProcess) { try { if (processMulti.Type == ProcessType.UWP) { await CloseAllProcessesUwp(dataBindApp, resetProcess, removeProcess); } else { await CloseAllProcessesWin32AndWin32Store(dataBindApp, resetProcess, removeProcess); } } catch { } }
//Close single process async Task CloseSingleProcessAuto(ProcessMulti processMulti, DataBindApp dataBindApp, bool resetProcess, bool removeProcess) { try { if (processMulti.Type == ProcessType.UWP) { await CloseSingleProcessUwp(dataBindApp, processMulti, resetProcess, removeProcess); } else if (processMulti.Type == ProcessType.Win32 || processMulti.Type == ProcessType.Win32Store) { await CloseSingleProcessWin32AndWin32Store(dataBindApp, processMulti, resetProcess, removeProcess); } } catch { } }
//Close all processes UWP async Task <bool> CloseAllProcessesUwp(DataBindApp dataBindApp, bool resetProcess, bool removeProcess) { try { //Get the multi process ProcessMulti processMulti = dataBindApp.ProcessMulti.FirstOrDefault(); await Notification_Send_Status("AppClose", "Closing " + dataBindApp.Name); Debug.WriteLine("Closing all UWP processes: " + dataBindApp.Name + " / " + processMulti.Identifier); //Close the process bool closedProcess = CloseProcessById(processMulti.Identifier); if (closedProcess) { await Notification_Send_Status("AppClose", "Closed " + dataBindApp.Name); Debug.WriteLine("Closed all UWP processes: " + dataBindApp.Name); //Reset the process running status if (resetProcess) { dataBindApp.StatusRunning = Visibility.Collapsed; dataBindApp.StatusSuspended = Visibility.Collapsed; dataBindApp.RunningProcessCount = string.Empty; dataBindApp.RunningTimeLastUpdate = 0; dataBindApp.ProcessMulti.Clear(); } //Remove the process from the list if (removeProcess) { await RemoveAppFromList(dataBindApp, false, false, true); } return(true); } else { await Notification_Send_Status("AppClose", "Failed to close the app"); Debug.WriteLine("Failed to close the application."); return(false); } } catch { } return(false); }
//Check process windows async Task <IntPtr> CheckProcessWindowsAuto(DataBindApp dataBindApp, ProcessMulti processMulti) { try { if (processMulti.Type == ProcessType.UWP) { return(processMulti.WindowHandle); } else if (processMulti.Type == ProcessType.Win32 || processMulti.Type == ProcessType.Win32Store) { return(await CheckProcessWindowsWin32AndWin32Store(dataBindApp, processMulti)); } } catch { } return(IntPtr.Zero); }
//Close single UWP process async Task <bool> CloseSingleProcessUwp(DataBindApp dataBindApp, ProcessMulti processMulti, bool resetProcess, bool removeProcess) { try { await Notification_Send_Status("AppClose", "Closing " + dataBindApp.Name); Debug.WriteLine("Closing UWP process: " + dataBindApp.Name); //Close the process bool closedProcess = await CloseProcessUwpByWindowHandleOrProcessId(dataBindApp.Name, processMulti.Identifier, processMulti.WindowHandle); if (closedProcess) { await Notification_Send_Status("AppClose", "Closed " + dataBindApp.Name); Debug.WriteLine("Closed UWP process: " + dataBindApp.Name); //Reset the process running status if (resetProcess) { dataBindApp.StatusRunning = Visibility.Collapsed; dataBindApp.StatusSuspended = Visibility.Collapsed; dataBindApp.RunningProcessCount = string.Empty; dataBindApp.RunningTimeLastUpdate = 0; dataBindApp.ProcessMulti.Clear(); } //Remove the process from the list if (removeProcess) { await RemoveAppFromList(dataBindApp, false, false, true); } return(true); } else { await Notification_Send_Status("AppClose", "Failed to close the app"); Debug.WriteLine("Failed to close the application."); return(false); } } catch { } return(false); }
async Task <bool> LaunchProcessUrlProtocol(DataBindApp dataBindApp) { try { await Notification_Send_Status("AppLaunch", "Launching " + dataBindApp.Name); Debug.WriteLine("Launching url protocol: " + dataBindApp.PathExe + " / " + dataBindApp.PathLaunch); Process LaunchProcess = new Process(); LaunchProcess.StartInfo.FileName = dataBindApp.PathExe; LaunchProcess.StartInfo.WorkingDirectory = dataBindApp.PathLaunch; LaunchProcess.Start(); return(true); } catch { } return(false); }
async Task <bool> PrepareRestartProcessUwp(DataBindApp dataBindApp, ProcessMulti processMulti, bool useLaunchArgument, bool launchKeyboard) { try { if (string.IsNullOrWhiteSpace(dataBindApp.PathExe)) { await Notification_Send_Status("Close", "Failed restarting " + dataBindApp.Name); Debug.WriteLine("Failed to restart process: " + dataBindApp.Name); return(false); } await Notification_Send_Status("AppRestart", "Restarting " + dataBindApp.Name); Debug.WriteLine("Restarting UWP application: " + dataBindApp.Name + " / " + processMulti.Identifier + " / " + processMulti.WindowHandle); //Set the launch argument string launchArgument = string.Empty; if (useLaunchArgument) { Debug.WriteLine("Setting restart argument: " + processMulti.Argument); launchArgument = processMulti.Argument; } //Restart the process Process restartProcess = await RestartProcessUwp(dataBindApp.Name, dataBindApp.PathExe, processMulti.Identifier, processMulti.WindowHandle, launchArgument); if (restartProcess == null) { await Notification_Send_Status("Close", "Failed restarting " + dataBindApp.Name); Debug.WriteLine("Failed to restart process: " + dataBindApp.Name); return(false); } //Launch the keyboard controller if (launchKeyboard) { await KeyboardControllerHideShow(true); } } catch { } return(false); }
//Handle app list left click async Task lb_AppList_LeftClick(object sender) { try { ListBox ListboxSender = (ListBox)sender; if (ListboxSender.SelectedItems.Count > 0 && ListboxSender.SelectedIndex != -1) { //Check which launch method needs to be used DataBindApp SelectedItem = (DataBindApp)ListboxSender.SelectedItem; await LaunchProcessSelector(SelectedItem); } } catch { await Notification_Send_Status("Close", "Failed to launch or show app"); Debug.WriteLine("Failed launching or showing the application."); } }
//Launch an UWP or Win32Store application from databindapp async Task <bool> PrepareProcessLauncherUwpAndWin32StoreAsync(DataBindApp dataBindApp, bool silent, bool allowMinimize, bool launchKeyboard) { bool appLaunched = false; try { //Launch the application appLaunched = await PrepareProcessLauncherUwpAndWin32StoreAsync(dataBindApp.Name, dataBindApp.PathExe, dataBindApp.Argument, silent, allowMinimize, launchKeyboard); //Update last launch date if (appLaunched) { dataBindApp.LastLaunch = DateTime.Now.ToString(vAppCultureInfo); //Debug.WriteLine("Updated last launch date: " + dataBindApp.LastLaunch); JsonSaveApplications(); } } catch { } return(appLaunched); }
async void Grid_Popup_Welcome_button_Battle_Click(object sender, RoutedEventArgs e) { try { Button ButtonSender = (sender as Button); vFilePickerFilterIn = new List <string> { "battle.net.exe" }; vFilePickerFilterOut = new List <string>(); vFilePickerTitle = "Battle.net"; vFilePickerDescription = "Please select the Battle.net executable:"; vFilePickerShowNoFile = false; vFilePickerShowRoms = false; vFilePickerShowFiles = true; vFilePickerShowDirectories = true; grid_Popup_FilePicker_stackpanel_Description.Visibility = Visibility.Collapsed; await Popup_Show_FilePicker("PC", -1, false, grid_Popup_Welcome_button_Start); while (vFilePickerResult == null && !vFilePickerCancelled && !vFilePickerCompleted) { await Task.Delay(500); } if (vFilePickerCancelled) { return; } //Add application to the list DataBindApp dataBindApp = new DataBindApp() { Type = ProcessType.Win32, Category = AppCategory.Game, Name = "Battle.net", PathExe = vFilePickerResult.PathFile, PathLaunch = Path.GetDirectoryName(vFilePickerResult.PathFile) }; await AddAppToList(dataBindApp, true, true); //Disable the icon after selection ButtonSender.IsEnabled = false; ButtonSender.Opacity = 0.40; } catch { } }
//Add process to the search list async Task AddSearchProcess(DataBindApp dataBindApp) { try { await AVActions.ActionDispatcherInvokeAsync(async delegate { string searchString = grid_Popup_Search_textbox.Text; string placeholderString = (string)grid_Popup_Search_textbox.GetValue(TextboxPlaceholder.PlaceholderProperty); if (searchString != placeholderString && dataBindApp.Name.ToLower().Contains(searchString.ToLower())) { //Add search process await ListBoxAddItem(lb_Search, List_Search, dataBindApp, false, false); //Update the search results count UpdateSearchResults(); Debug.WriteLine("Added search process: " + searchString); } }); } catch { } }
//Get launch argument for emulator async Task <string> GetLaunchArgumentEmulator(DataBindApp dataBindApp) { try { //Select a file from list to launch vFilePickerFilterIn = new List <string>(); vFilePickerFilterOut = new List <string> { "jpg", "png" }; vFilePickerTitle = "Rom Selection"; vFilePickerDescription = "Please select a rom file to load in " + dataBindApp.Name + ":"; vFilePickerShowNoFile = false; vFilePickerShowRoms = true; vFilePickerShowFiles = true; vFilePickerShowDirectories = true; grid_Popup_FilePicker_stackpanel_Description.Visibility = Visibility.Collapsed; await Popup_Show_FilePicker(dataBindApp.PathRoms, -1, false, null); while (vFilePickerResult == null && !vFilePickerCancelled && !vFilePickerCompleted) { await Task.Delay(500); } if (vFilePickerCancelled) { return("Cancel"); } string launchArgument = string.Empty; if (!string.IsNullOrWhiteSpace(vFilePickerResult.PathFile)) { launchArgument = dataBindApp.Argument + " \"" + vFilePickerResult.PathFile + "\""; } Debug.WriteLine("Set launch argument to: " + launchArgument); return(launchArgument); } catch { } return("Cancel"); }
//Remove shortcut file prompt async Task RemoveShortcutFilePrompt(DataBindApp dataBindApp) { try { List <DataBindString> Answers = new List <DataBindString>(); DataBindString AnswerRemove = new DataBindString(); AnswerRemove.ImageBitmap = FileToBitmapImage(new string[] { "Assets/Default/Icons/Remove.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0); AnswerRemove.Name = "Move shortcut file to recycle bin"; Answers.Add(AnswerRemove); DataBindString messageResult = await Popup_Show_MessageBox("Shortcut target path no longer exists", string.Empty, "Would you like to remove the shortcut file?", Answers); if (messageResult != null) { if (messageResult == AnswerRemove) { await RemoveShortcutFile(lb_Shortcuts, lb_Shortcuts.SelectedIndex, dataBindApp, true); } } } catch { } }