Exemplo n.º 1
0
        public static async Task <bool> CheckCreateFile(string fileName, string folderName = null)
        {
            bool didntExist = false;

            if (folderName != null)
            {
                if (!Directory.Exists(folderName))
                {
                    Directory.CreateDirectory(folderName);
                    didntExist = true;
                }
            }
            if (fileName != null)
            {
                if (!File.Exists(ConfigControl.appFolder + fileName))
                {
                    if (ConfigControl.appFolder + fileName == ConfigControl.appFolder + ConfigControl.config)
                    {
                        ConfigControl.CreateConfig(ConfigControl.appFolder + fileName);
                    }
                    else
                    {
                        var newFile = File.Create(ConfigControl.appFolder + fileName);
                        newFile.Close();
                    }
                    didntExist = true;
                }
            }
            return(didntExist);
        }
Exemplo n.º 2
0
        private void b_Other_ChangeDir_Click(object sender, EventArgs e)
        {
            bool confirm = Tools.ShowPopup("Moving the directory will reset app configuration AND WILL ALSO DELETE ALL FILES WITHIN THE OLD APP FOLDER!\nYou will have the option to save these files.\nAre you sure you want to continue?", "Warning", null, false);

            if (confirm)
            {
                bool   moveFiles    = Tools.ShowPopup("Would you like to move all current directory files to the new directory too?", "Move files?", null, false);
                string oldAppFolder = ConfigControl.appFolder;

                FileStuff.ChooseNewDirectory();
                ConfigControl.SetToDefaults();
                FileStuff.CreateConfigFiles();

                if (oldAppFolder != ConfigControl.appFolder && oldAppFolder != ConfigControl.appFolder + @"SSUtility\")
                {
                    if (moveFiles)
                    {
                        Tools.CopyFiles(ConfigControl.appFolder, Directory.GetFiles(oldAppFolder));
                    }

                    Tools.DeleteDirectory(oldAppFolder);
                }
                MessageBox.Show("Finished changing directories!");
            }

            l_Other_Dir.Text = "Current Directory: " + ConfigControl.appFolder;
            MainForm.m.col.recentSavedLocations.Clear();
            MainForm.m.col.AddDefaultSavedLocations();
        }
Exemplo n.º 3
0
        public static async Task ImportConfig(string name, bool dragdrop)
        {
            try {
                MainForm.m.finishedLoading = false;
                string configFile = ConfigControl.appFolder + ConfigControl.config;
                if (name != configFile)
                {
                    ResetFile(configFile);

                    string[] lines   = File.ReadAllLines(name);
                    bool     isValid = false;
                    foreach (string line in lines)
                    {
                        string val = line.ToLower();
                        if (val.Contains("ssutility2.0") && val.Contains("config"))
                        {
                            isValid = true;
                            break;
                        }
                    }

                    if (!isValid)
                    {
                        MessageBox.Show("Text file is not a config file!");
                        MainForm.m.finishedLoading = true;
                        return;
                    }
                    else if (dragdrop && !ShowPopup("Config file detected!\n(" + name + ")\nImport new settings, replacing current config?", "New Config Detected!", "", false))
                    {
                        MainForm.m.finishedLoading = true;
                        return;
                    }

                    foreach (string line in lines)
                    {
                        File.AppendAllText(configFile, line + "\n");
                    }

                    RTSPPresets.Reload(true);
                    ConfigControl.SetToDefaults();
                    await ConfigControl.SearchForVarsAsync(ConfigControl.appFolder + ConfigControl.config);

                    MainForm.m.setPage.LoadSettings();
                    MessageBox.Show("Updated config file!\n(" + configFile + ")");
                    MainForm.m.AttachPlayers();
                }
                else
                {
                    if (name == configFile)
                    {
                        MessageBox.Show("Please don't try to replace the config file with itself!");
                    }
                }
            } catch (Exception e) {
                ShowPopup("Failed to import config!\nShow more?", "Error Occurred!", e.ToString());
            }

            MainForm.m.finishedLoading = true;
        }
Exemplo n.º 4
0
        private void b_Settings_Default_Click(object sender, EventArgs e)
        {
            DialogResult d = MessageBox.Show("Are you sure you want to reset all settings?",
                                             "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (d == DialogResult.Yes)
            {
                ConfigControl.SetToDefaults();
                LoadSettings();
                MainForm.m.mainPlayer.DestroyAll();
            }
        }
Exemplo n.º 5
0
        public static void CopySingleFile(string destination, string sourceFile, bool copyingDirectory = false)
        {
            string curFile     = string.Empty;
            string newLocation = string.Empty;

            try {
                string name = sourceFile.Substring(sourceFile.LastIndexOf("\\") + 1);
                curFile     = sourceFile;
                newLocation = destination + name;

                destination.Replace("//", "/");
                destination.Replace("\\\\", "\\");

                if (copyingDirectory)
                {
                    if (!destination.EndsWith(@"\"))
                    {
                        destination += @"\";
                    }

                    string tempFile = destination + @"CopiedFile";

                    if (!File.Exists(newLocation))
                    {
                        if (name == ConfigControl.config)
                        {
                            ConfigControl.portableMode.UpdateValue("true");
                            ConfigControl.CreateConfig(destination + @"\" + ConfigControl.config);
                            ConfigControl.portableMode.UpdateValue("false");
                        }
                        else
                        {
                            File.Copy(sourceFile, tempFile, true);
                            File.Move(tempFile, destination + @"\" + name); //renames file
                        }
                    }
                }
                else
                {
                    File.Copy(sourceFile, PathNoOverwrite(destination), true);
                }
            } catch (Exception e) {
                ShowPopup("Couldn't copy individual file to new directory!\nShow more info?",
                          "Copy failed!", "File: " + curFile + "\nfailed to copy to:\n" + newLocation +
                          "\n\nError: " + e.ToString());
            }
        }
Exemplo n.º 6
0
        public static async Task <bool> FileWork()
        {
            try {
                bool firstTime = CheckForNewDir();
                if (!firstTime)
                {
                    CheckForMultipleConfigs();
                }

                ConfigControl.SetToDefaults();

                CreateConfigFiles();

                await ConfigControl.SearchForVarsAsync(ConfigControl.appFolder + ConfigControl.config);

                MainForm.m.custom.HideButtons();

                if (ConfigControl.portableMode.boolVal)
                {
                    MainForm.m.Menu_Final.Dispose();
                }

                if (AppDomain.CurrentDomain.FriendlyName.ToLower().Contains("lite"))
                {
                    return(true);
                }

                if (firstTime)
                {
                    FirstTimeSetup();
                }

                return(false);
            } catch (Exception e) {
                Tools.ShowPopup("File work error occurred!\nShow more?", "Error Occurred!", e.ToString());
                return(false);
            }
        }
Exemplo n.º 7
0
 private async Task ApplyAll()
 {
     ConfigControl.CreateConfig(ConfigControl.appFolder + ConfigControl.config);
 }