private bool CheckSetPath(string chosenService) { if (customSetPath != String.Empty) { if (Directory.Exists(customSetPath)) { if (!customSetPath.Contains("AssistantComputerControl") && !customSetPath.Contains("assistantcomputercontrol")) { customSetPath = Path.Combine(customSetPath, "AssistantComputerControl"); MainProgram.DoDebug("Changed path to include 'AssistantComputerControl': " + customSetPath); if (!Directory.Exists(customSetPath)) { Directory.CreateDirectory(customSetPath); } } Properties.Settings.Default.ActionFilePath = customSetPath; Properties.Settings.Default.Save(); MainProgram.SetupListener(); return(true); } } else { string checkPath = MainProgram.GetCloudServicePath(chosenService); MainProgram.DoDebug("Checking: " + checkPath); if (!String.IsNullOrEmpty(checkPath)) { if (Directory.Exists(checkPath)) { if (!checkPath.Contains("AssistantComputerControl") && !checkPath.Contains("assistantcomputercontrol")) { checkPath = Path.Combine(checkPath, "AssistantComputerControl"); MainProgram.DoDebug("Changed path to include 'AssistantComputerControl': " + checkPath); if (!Directory.Exists(checkPath)) { Directory.CreateDirectory(checkPath); } } Properties.Settings.Default.ActionFilePath = checkPath; Properties.Settings.Default.Save(); MainProgram.SetupListener(); return(true); } } } return(false); }
public void CloudServiceChosen(string service = "") { switch (service) { case "dropbox": case "onedrive": case "googledrive": backgroundCheckerServiceName = service; break; default: return; } if (MainProgram.GetCloudServicePath(backgroundCheckerServiceName) != "") { //Cloud service found MainProgram.DoDebug("Cloud service " + backgroundCheckerServiceName + " is installed"); if (backgroundCheckerServiceName == "googledrive") { bool partial = MainProgram.GetGoogleDriveFolder() != String.Empty; if (theWebBrowser != null) { if (theWebBrowser.Handle != null) { theWebBrowser.Document.InvokeScript("CloudServiceInstalled", new Object[2] { true, partial }); } } if (partial) { CheckLocalGoogleDrive(); } } else { if (theWebBrowser != null) { if (theWebBrowser.Handle != null) { theWebBrowser.Document.InvokeScript("CloudServiceInstalled", new Object[1] { true }); } } } } else { //Not found new Thread(() => { Thread.CurrentThread.IsBackground = true; string checkValue = ""; stopCheck = false; MainProgram.DoDebug("Could not find cloud service. Running loop to check"); while (checkValue == "" && !stopCheck) { checkValue = MainProgram.GetCloudServicePath(backgroundCheckerServiceName); Thread.Sleep(1000); } if (stopCheck) { stopCheck = false; return; } //Cloud service has been installed since we last checked! MainProgram.DoDebug("Cloud service has been installed since last check. Proceed."); if (theWebBrowser != null) { if (theWebBrowser.Handle != null) { theWebBrowser.Invoke(new Action(() => { if (backgroundCheckerServiceName == "googledrive") { bool partial = MainProgram.GetGoogleDriveFolder() != String.Empty; theWebBrowser.Document.InvokeScript("CloudServiceInstalled", new Object[2] { true, partial }); if (partial) { CheckLocalGoogleDrive(); } } else { theWebBrowser.Document.InvokeScript("CloudServiceInstalled", new Object[1] { true }); } })); } } }).Start(); } }