Beispiel #1
0
        public void Open(string parameter)
        {
            string location = ActionChecker.GetSecondaryParam(parameter)[0], arguments = (ActionChecker.GetSecondaryParam(parameter).Length > 1 ? ActionChecker.GetSecondaryParam(parameter)[1] : null);
            string fileLocation = (!location.Contains(@":\") || !location.Contains(@":/")) ? Path.Combine(MainProgram.shortcutLocation, location) : location;

            if (File.Exists(fileLocation) || Directory.Exists(fileLocation) || Uri.IsWellFormedUriString(fileLocation, UriKind.Absolute))
            {
                if (!MainProgram.testingAction)
                {
                    try {
                        Process p = new Process();
                        p.StartInfo.FileName = fileLocation;
                        if (arguments != null)
                        {
                            p.StartInfo.Arguments = arguments;
                        }
                        p.Start();
                        successMessage = "OPEN: opened file/url; " + fileLocation;
                    } catch (Exception e) {
                        MainProgram.DoDebug("Failed to open file; " + e.Message);
                        Error("Failed to open file (" + fileLocation + ")");
                    }
                }
                else
                {
                    successMessage = "OPEN: simulated opening file; " + fileLocation;
                }
            }
            else
            {
                Error("File or directory doesn't exist (" + fileLocation + ")");
            }
        }
Beispiel #2
0
        public static string[] GetLanguages()
        {
            if (!String.IsNullOrEmpty(translationFolder))
            {
                List <string> stringList = new List <string>();
                DirectoryInfo d          = new DirectoryInfo(translationFolder);
                foreach (var file in d.GetFiles("*.json"))
                {
                    string fileContent = ReadLanguage(file.FullName);
                    if (fileContent != null)
                    {
                        try {
                            dynamic jsonTest = JsonConvert.DeserializeObject <dynamic>(fileContent);
                            if (jsonTest["translations"] != null)
                            {
                                stringList.Add(Path.GetFileNameWithoutExtension(file.FullName));
                            }
                            else
                            {
                                MainProgram.DoDebug("Invalid translation; " + (jsonTest));
                            }
                        } catch {
                            MainProgram.DoDebug("Could not validate language from file " + file.Name);
                        }
                    }
                }

                string[] theArr = stringList.ToArray <string>();
                return(theArr);
            }
            return(new string[0]);
        }
        public void OpenAll(string parameter)
        {
            string fileLocation = (!parameter.Contains(@":\") || !parameter.Contains(@":/")) ? Path.Combine(MainProgram.shortcutLocation, parameter) : parameter;

            if (Directory.Exists(fileLocation) || Uri.IsWellFormedUriString(fileLocation, UriKind.Absolute))
            {
                DirectoryInfo d = new DirectoryInfo(fileLocation);
                int           x = 0;
                foreach (var dirFile in d.GetFiles())
                {
                    if (!MainProgram.testingAction)
                    {
                        Process.Start(dirFile.FullName);
                    }
                    x++;
                }

                if (!MainProgram.testingAction)
                {
                    successMessage = "OPEN: opened " + x + " files in; " + fileLocation;
                }
                else
                {
                    successMessage = "OPEN: simulated opening " + x + " files in; " + fileLocation;
                }
            }
            else
            {
                MainProgram.DoDebug("ERROR: directory doesn't exist (" + fileLocation + ")");
                MainProgram.errorMessage = "Directory doesn't exist (" + fileLocation + ")";
            }
        }
        public void Music(string parameter)
        {
            switch (parameter)
            {
            case "previous":
                if (MainProgram.testingAction)
                {
                    successMessage = "MUSIC: Simulated going to previous track";
                }
                else
                {
                    keybd_event(VK_MEDIA_PREV_TRACK, 0, KEYEVENTF_EXTENTEDKEY, 0);
                    successMessage = "MUSIC: Skipped song";
                }
                break;

            case "previousx2":
                if (MainProgram.testingAction)
                {
                    successMessage = "MUSIC: Simulated double-previous track";
                }
                else
                {
                    keybd_event(VK_MEDIA_PREV_TRACK, 0, KEYEVENTF_EXTENTEDKEY, 0);
                    Thread.Sleep(100);
                    keybd_event(VK_MEDIA_PREV_TRACK, 0, KEYEVENTF_EXTENTEDKEY, 0);
                    successMessage = "MUSIC: Skipped song (x2)";
                }
                break;

            case "next":
                if (MainProgram.testingAction)
                {
                    successMessage = "MUSIC: Simulated going to next song";
                }
                else
                {
                    keybd_event(VK_MEDIA_NEXT_TRACK, 0, KEYEVENTF_EXTENTEDKEY, 0);
                    successMessage = "MUSIC: Next song";
                }
                break;

            case "play_pause":
                if (MainProgram.testingAction)
                {
                    successMessage = "MUSIC: Simulated play/pause";
                }
                else
                {
                    keybd_event(VK_MEDIA_PLAY_PAUSE, 0, KEYEVENTF_EXTENTEDKEY, 0);
                    successMessage = "MUSIC: Played/Paused";
                }
                break;

            default:
                MainProgram.DoDebug("ERROR: Unknown parameter");
                MainProgram.errorMessage = "Unknown parameter \"" + parameter + "\"";
                break;
            }
        }
Beispiel #5
0
        private void SetupDone()
        {
            //Start with Windows if user said so
            if (Properties.Settings.Default.StartWithWindows != startWithWindowsCheckbox.Checked)
            {
                Properties.Settings.Default.StartWithWindows = startWithWindowsCheckbox.Checked;
                MainProgram.SetStartup(startWithWindowsCheckbox.Checked);

                Properties.Settings.Default.Save();

                MainProgram.DoDebug("Starting with Windows now");
            }

            Properties.Settings.Default.AnalyticsInformed = true;
            if (Properties.Settings.Default.SendAnonymousAnalytics != analyticsEnabledBox.Checked)
            {
                MainProgram.UpdateAnalyticsSharing(analyticsEnabledBox.Checked);
            }

            MainProgram.DoDebug("Anonymous analyitcs " + (analyticsEnabledBox.Checked ? "IS" : "is NOT") + " enabled");

            MainProgram.DoDebug("Completed setup guide");
            Properties.Settings.Default.HasCompletedTutorial = true;
            Properties.Settings.Default.Save();
        }
        //Check mod folder and init mods
        public static void CheckMods()
        {
            try {
                modActions = new Dictionary <string, string>();
                string[] dirs = Directory.GetDirectories(MainProgram.actionModsPath, "*", SearchOption.TopDirectoryOnly);

                foreach (string dir in dirs)
                {
                    string theFile = Path.Combine(dir, "info.json");
                    if (File.Exists(theFile))
                    {
                        //Info file exists - read it
                        string fileContent = ReadInfoFile(theFile);
                        if (fileContent != null)
                        {
                            ValidateAddMod(fileContent, dir);
                        }
                        else
                        {
                            MainProgram.DoDebug("Failed to read info.json file at; " + dir);
                        }
                    }
                    else
                    {
                        MainProgram.DoDebug("Invalid folder in action mods; '" + dir + "'. Doesn't contain an info.json file.");
                    }
                }
            } catch (Exception e) {
                Console.WriteLine("The process failed: {0}", e.ToString());
            }
        }
Beispiel #7
0
        private void anonymousAnalyticsCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            bool theStatus = anonymousAnalyticsCheckbox.Checked;

            MainProgram.DoDebug("Send annonymous analytics; " + theStatus);
            MainProgram.UpdateAnalyticsSharing(theStatus);
        }
Beispiel #8
0
        private static void FileDownloadedCallback(object sender, AsyncCompletedEventArgs e)
        {
            if (MainProgram.updateProgressWindow != null)
            {
                MainProgram.updateProgressWindow.Close();
                MainProgram.updateProgressWindow = null;
            }

            MainProgram.DoDebug("Finished downloading");

            if (!e.Cancelled)
            {
                //Download success
                Process.Start(targetLocation);
                MainProgram.DoDebug("New installer successfully downloaded and opened.");
                Application.Exit();
            }
            else
            {
                MainProgram.DoDebug("Failed to download new version of ACC. Error; " + e.Error);
                MessageBox.Show("Failed to download new version. Try again later!", "Error | " + MainProgram.messageBoxTitle);
            }

            Thread.Sleep(500);
            Thread.CurrentThread.Abort();
        }
Beispiel #9
0
        private void BrowserDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //OneDrive business?
            bool hasWorkDrive = !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("OneDriveCommercial")) && !String.IsNullOrEmpty(Environment.GetEnvironmentVariable("OneDriveConsumer"));

            MainProgram.DoDebug("Has work OneDrive? " + hasWorkDrive);
            theWebBrowser.Document.InvokeScript("HasWorkOneDrive", new Object[1] {
                hasWorkDrive
            });
            theWebBrowser.Document.InvokeScript("SetAccVersionNum", new Object[1] {
                MainProgram.softwareVersion
            });

            /*if ((WebBrowser)sender != null) {
             * //Maybe add this to avoid errors - rarely happens though
             * }*/

            this.SetupDocumentLinks((sender as WebBrowser).Document.All);

            /* Translation stuff */
            var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            var json       = serializer.Serialize(Translator.languagesArray);

            theWebBrowser.Document.InvokeScript("SetLanguages", new Object[1] {
                json
            });
        }
Beispiel #10
0
            private void CheckLocalGoogleDrive()
            {
                new Thread(() => {
                    Thread.CurrentThread.IsBackground = true;
                    stopCheck = false;

                    MainProgram.DoDebug("Starting loop to check for Google Drive folder locally");
                    while (backgroundCheckerServiceName == "googledrive" && CloudServiceFunctions.GetGoogleDriveFolder() == String.Empty && !stopCheck)
                    {
                        Thread.Sleep(1000);
                    }
                    if (stopCheck)
                    {
                        stopCheck = false;
                        return;
                    }

                    if (backgroundCheckerServiceName == "googledrive")
                    {
                        //Cloud service has been installed since we last checked!
                        MainProgram.DoDebug("Google Drive has been added to local PC. Proceed.");
                        theWebBrowser.Invoke(new Action(() => {
                            theWebBrowser.Document.InvokeScript("CloudServiceInstalled", new Object[2] {
                                true, false
                            });
                        }));
                    }
                    else
                    {
                        MainProgram.DoDebug("Service has since been changed. Stopping the search for Google Drive.");
                    }
                }).Start();
            }
 public void SetVolume(string parameter)
 {
     if (double.TryParse(parameter, out double volumeLevel))
     {
         if (volumeLevel >= 0 && volumeLevel <= 100)
         {
             if (!MainProgram.testingAction)
             {
                 if (Properties.Settings.Default.UnmuteOnVolumeChange)
                 {
                     try {
                         //Sometimes fails - sentry @833243007
                         AudioManager.SetMasterVolumeMute(false);
                     } catch {
                         MainProgram.DoDebug("Failed to unmute PC. Exception caught.");
                         MainProgram.errorMessage = "Failed to unmute PC";
                     }
                 }
                 try {
                     AudioManager.SetMasterVolume((float)volumeLevel);
                 } catch {
                     //Might not have an audio device...
                     MainProgram.DoDebug("Failed to set PC volume. Exception caught.");
                     MainProgram.errorMessage = "Failed to set PC volume";
                 }
             }
             if (!MainProgram.testingAction)
             {
                 try {
                     if ((int)AudioManager.GetMasterVolume() != (int)volumeLevel)
                     {
                         //Something went wrong... Audio not set to parameter-level
                         MainProgram.DoDebug("ERROR: Volume was not set properly. Master volume is " + AudioManager.GetMasterVolume() + ", not " + volumeLevel);
                         MainProgram.errorMessage = "Something went wrong when setting the volume";
                     }
                     else
                     {
                         successMessage = "Set volume to " + volumeLevel + "%";
                     }
                 } catch {
                     MainProgram.errorMessage = "Failed to check volume";
                 }
             }
             else
             {
                 successMessage = "Simulated setting system volume to " + volumeLevel + "%";
             }
         }
         else
         {
             MainProgram.DoDebug("ERROR: Parameter is an invalid number, range; 0-100 (" + volumeLevel + ")");
             MainProgram.errorMessage = "Can't set volume to " + volumeLevel + "%, has to be a number from 0-100";
         }
     }
     else
     {
         MainProgram.DoDebug("ERROR: Parameter (" + parameter + ") not convertable to double");
         MainProgram.errorMessage = "Not a valid parameter (has to be a number)";
     }
 }
        private bool Check()
        {
            if (EmptyCheck())
            {
                DirectoryInfo di = new DirectoryInfo(MainProgram.CheckPath(true));

                int numFiles = 0;

                try {
                    foreach (string file in Directory.GetFiles(MainProgram.CheckPath(true), "*." + Properties.Settings.Default.ActionFileExtension))
                    {
                        //if (cleanedFiles.Contains(file)) continue;

                        bool hidden = (File.GetAttributes(file) & FileAttributes.Hidden) == FileAttributes.Hidden;
                        if (!hidden)
                        {
                            File.SetAttributes(file, FileAttributes.Hidden);
                        }

                        string tmpFolder = Path.Combine(Path.GetTempPath(), "AssistantComputerControl");
                        if (!Directory.Exists(tmpFolder))
                        {
                            Directory.CreateDirectory(tmpFolder);
                        }

                        //string newFilename = Path.Combine(Path.GetDirectoryName(file), "action_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() + "_" + Guid.NewGuid() + "." + Properties.Settings.Default.ActionFileExtension);
                        //string newFilename = Path.Combine(tmpFolder, "action_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() + "_" + Guid.NewGuid() + "." + Properties.Settings.Default.ActionFileExtension);
                        //string newFilename = Path.Combine(Path.Combine(MainProgram.CheckPath(true), "used_actions"), "action_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() + "_" + Guid.NewGuid() + "." + Properties.Settings.Default.ActionFileExtension);
                        //File.Move(file, newFilename);
                        //File.Delete(newFilename);
                        File.Delete(file);
                        //cleanedFiles.Add(newFilename);
                        numFiles++;
                    }
                } catch (Exception e) {
                    MainProgram.DoDebug("[CLEANUP] Failed to rename a file in action folder; " + e.Message + ". Successfully renamed and hid " + numFiles.ToString() + " files");
                    return(false);
                }

                if (numFiles > 0)
                {
                    Thread.Sleep(1000);
                }

                return(true);

                /*if (!EmptyCheck()) {
                 *  MainProgram.DoDebug("[CLEANUP] All action folder files successfully renamed and hid (" + numFiles.ToString() + " files)");
                 *  return true;
                 * } else {
                 *  MainProgram.DoDebug("[CLEANUP] Folder wasn't cleared");
                 * }*/
            }
            else
            {
                MainProgram.DoDebug("[CLEANUP] Check done - action folder is empty");
            }

            return(false);
        }
Beispiel #13
0
 public void CheckManualPath(string path)
 {
     MainProgram.DoDebug("Checking manually-entered path...");
     try {
         Path.GetFullPath(path);
     } catch {
         MainProgram.DoDebug("Path not good");
         theWebBrowser.Document.InvokeScript("ManualPathValidated", new Object[1] {
             false
         });
         return;
     }
     if (Directory.Exists(path))
     {
         //Good
         theWebBrowser.Document.InvokeScript("ManualPathValidated", new Object[1] {
             true
         });
         MainProgram.DoDebug("Path good");
         customSetPath = path;
     }
     else
     {
         theWebBrowser.Document.InvokeScript("ManualPathValidated", new Object[1] {
             false
         });
         MainProgram.DoDebug("Path not good");
     }
 }
Beispiel #14
0
        public static void DownloadFile(string url)
        {
            if (RemoteFileExists(url))
            {
                MainProgram.DoDebug("Downloading file...");
                WebClient client = new WebClient();
                Uri       uri    = new Uri(url);

                MainProgram.updateProgressWindow = new UpdateProgress();
                MainProgram.updateProgressWindow.Show();

                client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
                client.DownloadFileCompleted   += new AsyncCompletedEventHandler(FileDownloadedCallback);

                targetLocation = Path.Combine(Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "Downloads"), "ACCsetup.exe");
                if (File.Exists(targetLocation))
                {
                    try {
                        File.Delete(targetLocation);
                    } catch (Exception ex) {
                        MainProgram.DoDebug("Failed to delete file at " + targetLocation);
                        MainProgram.DoDebug("Error; " + ex);
                    }
                }
                client.DownloadFileAsync(uri, targetLocation);

                Application.Run();
            }
            else
            {
                MainProgram.DoDebug("Failed to update, installation URL does not exist (" + url + ").");
                MessageBox.Show("Couldn't find the new version online. Please try again later.", "Error | " + MainProgram.messageBoxTitle);
            }
        }
Beispiel #15
0
        public void Check()
        {
            string latest_version;

            using (WebClient client = new WebClient()) {
                latest_version = client.DownloadString("http://gh.albe.pw/acc/releases/latest/version.txt");
            }
            if (latest_version != MainProgram.softwareVersion)
            {
                //New version available
                MainProgram.DoDebug("New software version found (" + latest_version + ")");
                DialogResult dialogResult = MessageBox.Show("A new version of " + MainProgram.messageBoxTitle + " is available (v" + latest_version + "), do you wish to install it?", "New update found | " + MainProgram.messageBoxTitle, MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    MainProgram.DoDebug("User chose \"yes\" to install update");
                    Install();
                }
                else if (dialogResult == DialogResult.No)
                {
                    MainProgram.DoDebug("User did not want to install update");
                }
            }
            else
            {
                MainProgram.DoDebug("Software up to date");
            }
            if (File.Exists(Path.Combine(MainProgram.dataFolderLocation, "updated.txt")))
            {
                File.Delete("updated.txt");
            }
        }
        private bool DoValidate(string configKey, validateTypes type, Nullable <int> min = null, Nullable <int> max = null)
        {
            string configValue = config(configKey);
            string debugStart  = "Config key \"" + configKey + "\"";

            ConfigurationManager.OpenExeConfiguration("");

            if (!String.IsNullOrEmpty(configValue))
            {
                //Value is not empty
                switch (type)
                {
                case validateTypes.integer:
                    int n;
                    if (int.TryParse(configValue, out n))
                    {
                        bool proceed = true;
                        if (min != null)
                        {
                            if (!(n > min))
                            {
                                //n is less than min
                                proceed = false;
                                MainProgram.DoDebug(debugStart + "value" + n + " is not larger than " + min);
                            }
                        }
                        if (max != null)
                        {
                            if (!(n < max))
                            {
                                //n is more than max
                                proceed = false;
                                MainProgram.DoDebug(debugStart + "value" + n + " is more than " + max);
                            }
                        }

                        if (proceed)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        MainProgram.DoDebug(debugStart + "is not a valid integer (whole number)");
                    }
                    break;

                default:
                    //requires no additional checks
                    return(true);
                }
            }
            else
            {
                MainProgram.DoDebug("Config key \"" + configKey + "\" is empty/null");
            }

            return(false);
        }
Beispiel #17
0
 private static void PressKey(char c)
 {
     try {
         SendKeys.SendWait(c.ToString());
     } catch (Exception e) {
         MainProgram.DoDebug("Failed to press key \"" + c.ToString() + "\", exception; " + e);
     }
 }
Beispiel #18
0
        private static void SetupDone()
        {
            MainProgram.testingAction = false;
            isConfiguringActions      = false;

            MainProgram.DoDebug("Completed setup guide");
            Properties.Settings.Default.HasCompletedTutorial = true;
            Properties.Settings.Default.Save();
        }
Beispiel #19
0
        private static void CheckAction(string theLine)
        {
            string action = theLine
            , parameter   = null
            , fullContent = null;

            action      = theLine;
            fullContent = theLine;
            string assistantParam = null;

            //Whether it's Google Assistant or Amazon Alexa (included in the default IFTTT applets)
            if (theLine.Contains("[") && theLine.Contains("]"))
            {
                action         = theLine.Split('[')[0];
                assistantParam = theLine.Split('[')[1];
                assistantParam = assistantParam.Split(']')[0];

                MainProgram.DoDebug("Executing using; " + assistantParam);
            }

            if (action.Contains(":"))
            {
                //Contains a parameter
                string[] splitAction = action.Split(':');
                parameter = splitAction[1];
                action    = splitAction[0];
                if (splitAction.Length > 1)
                {
                    int i = 0;
                    foreach (string moreParam in splitAction)
                    {
                        if (i != 0 && i != 1)
                        {
                            parameter += ":" + moreParam;
                        }
                        i++;
                    }
                }
                if (parameter == "")
                {
                    parameter = null;
                }
            }

            if (MainProgram.testingAction)
            {
                MainProgram.DoDebug("Test went through: " + action);
            }

            MainProgram.DoDebug("Action: " + action);
            MainProgram.DoDebug("Parameter: " + parameter);
            MainProgram.DoDebug("Full line: " + theLine);
            ExecuteAction(action, theLine, parameter, assistantParam);
        }
Beispiel #20
0
            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 = CloudServiceFunctions.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);
            }
Beispiel #21
0
 public static void AddCount(int action)
 {
     if (actions[action] != null)
     {
         Properties.Settings.Default.TotalActionsExecuted[action]++;
         Properties.Settings.Default.Save();
     }
     else
     {
         MainProgram.DoDebug("Could not find action with index \"" + action + "\" in action-array (analytics)");
     }
 }
 private static bool requireParameter(string param)
 {
     if (param != null)
     {
         return(true);
     }
     else
     {
         MainProgram.DoDebug("ERROR: Parameter not set");
         MainProgram.errorMessage = "Parameter not set";
     }
     return(false);
 }
        //public static List<string> cleanedFiles = new List<string>();

        public void Start()
        {
            new Thread(() => {
                Thread.CurrentThread.IsBackground = true;
                MainProgram.DoDebug("[CLEANUP] Service started");
                Thread.Sleep(150);

                if (isCleaning)
                {
                    MainProgram.DoDebug("[CLEANUP] Another cleanup service in progress. Waiting...");
                    while (isCleaning)
                    {
                        Thread.Sleep(200);
                    }
                    MainProgram.DoDebug("[CLEANUP] Other cleanup service done - starting check...");
                }
                isCleaning = true;

                if (AllHiddenCheck() != 0 && EmptyCheck())
                {
                    int tries = 0;
                    while (!Check() && tries <= 10)
                    {
                        tries++;
                        Thread.Sleep(1000);
                    }

                    if (tries >= 10)
                    {
                        MainProgram.DoDebug("[CLEANUP] Timeout. Failed to remove files in action folder.");
                    }
                    else
                    {
                        int filesAmount = AllHiddenCheck();
                        if (filesAmount != 0)
                        {
                            MainProgram.DoDebug("[CLEANUP] Did not timeout, but action folder is still not empty (" + filesAmount.ToString() + " non-hidden files in folder) - not supposed to happen Emtpy check returns " + (EmptyCheck() ? "true" : "false"));
                        }
                        else
                        {
                            MainProgram.DoDebug("[CLEANUP] Successful");
                        }
                    }
                }
                else
                {
                    MainProgram.DoDebug("[CLEANUP] Action folder is completely empty");
                }
                isCleaning = false;
            }).Start();
        }
Beispiel #24
0
        private void expertDoneButton_Click(object sender, EventArgs e)
        {
            var theUrl = "https://assistantcomputercontrol.com/integrated_action_grid.php?lang=" + Properties.Settings.Default.ActiveLanguage + "&max_version_number=" + MainProgram.softwareVersion + "&cloud_service=none";

            MainProgram.DoDebug(theUrl);
            theDoneActionViewBrowser.Url = new Uri(theUrl);

            thisForm.Size      = new Size(thisForm.Size.Width, thisForm.Size.Height + 150);
            theTabControl.Size = new Size(theTabControl.Size.Width, theTabControl.Size.Height + 150);
            theWebBrowser.Size = new Size(theWebBrowser.Size.Width, theWebBrowser.Size.Height + 150);

            theTabControl.SelectTab(3);
            SetupDone();
        }
        private void anonymousAnalyticsCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            bool theStatus = anonymousAnalyticsCheckbox.Checked;

            MainProgram.DoDebug("Send annonymous analytics; " + theStatus);

            Properties.Settings.Default.SendAnonymousAnalytics = theStatus;
            Properties.Settings.Default.Save();

            if (theStatus)
            {
                AnalyticsSettings.SetupAnalyticsAsync();
            }
        }
Beispiel #26
0
            public void AllDone(string chosenService)
            {
                MainProgram.DoDebug("'AllDone' pressed");
                if (CheckSetPath(chosenService))
                {
                    theTabControl.SelectTab(3);

                    MainProgram.SetRegKey("ActionFolder", MainProgram.CheckPath());
                }
                else
                {
                    theWebBrowser.Document.InvokeScript("DoneError");
                }
            }
 public static bool FileInUse(string file)
 {
     try {
         using (Stream stream = new FileStream(file, FileMode.Open)) {
             // File/Stream manipulating code here
             MainProgram.DoDebug("Can read file");
             return(false);
         }
     } catch {
         MainProgram.DoDebug("File is in use, retrying");
         Thread.Sleep(50);
         return(true);
     }
 }
 public void Lock(string parameter)
 {
     if (MainProgram.testingAction)
     {
         successMessage = "Simulated PC lock";
     }
     else
     {
         MainProgram.DoDebug("Locking computer...");
         wasFatal = true;
         LockWorkStation();
         successMessage = "Locked pc";
     }
 }
 public void Logout(string parameter)
 {
     if (MainProgram.testingAction)
     {
         successMessage = "Simulated logout";
     }
     else
     {
         MainProgram.DoDebug("Logging out of user...");
         successMessage = "Logged out of user";
         wasFatal       = true;
         ExitWindowsEx(0, 0);
     }
 }
Beispiel #30
0
        public static void AddCount(string action)
        {
            int pos = Array.IndexOf(actions, action);

            if (pos > -1)
            {
                Properties.Settings.Default.TotalActionsExecuted[pos]++;
                Properties.Settings.Default.Save();
            }
            else
            {
                MainProgram.DoDebug("Could not find action \"" + action + "\" in action-array (analytics)");
            }
        }