Exemplo n.º 1
0
        private bool ValidateAndImportLoLPath()
        {
            while (!LoLPathUtil.IsValidLeagueOfLegendsDirectory(Properties.Settings.Default.LoLDirectory))
            {
                string errMsg = "Your League of Legends path seems invalid.\n";
                errMsg += "Please set a valid path before proceeding.";

                DialogResult result = ShowWarningMessageBox("Invalid PLeague of Legends Path", errMsg);

                if (result == System.Windows.Forms.DialogResult.OK || result == System.Windows.Forms.DialogResult.Yes)
                {
                    bool importCompleted = AskUserToImportLoLPath();
                    if (!importCompleted)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        private bool AskUserToImportLoLPath()
        {
            // Ask user to browse League of Legends directory
            var folderBrowserDialog = new FolderBrowserDialog();

            DialogResult result = folderBrowserDialog.ShowDialog();

            bool hasContent = result == System.Windows.Forms.DialogResult.OK &&
                              !string.IsNullOrWhiteSpace(folderBrowserDialog.SelectedPath);

            if (hasContent)
            {
                string path = folderBrowserDialog.SelectedPath;
                txtLoLDirectory.Text = path;

                // Validate path
                bool isValidDirectory = LoLPathUtil.IsValidLeagueOfLegendsDirectory(path);
                Properties.Settings.Default.LoLDirectory = path;

                if (isValidDirectory)
                {
                    ChangeLoLStatusToFound();
                }
                else
                {
                    ChangeLoLStatusToNotFound();
                }

                Properties.Settings.Default.Save();
                return(true);
            }

            // Cancelled or invalid
            return(false);
        }
Exemplo n.º 3
0
        private async Task GenerateItemSetByChampion(ChampionViewModel champion, LoLMode mode, CancellationToken cancelToken)
        {
            // Create a unique instance of BuildSource to be thread safe
            // I'm afraid of having corruption with a shared "Document" property if I use a single shared instance
            IBuildSource buildSource = (T)Activator.CreateInstance(typeof(T));
            await buildSource.InitAsync(champion.Name, mode);

            if (!buildSource.IsValidContent())
            {
                throw new InvalidOperationException("Invalid content");
            }

            LoLItemSetViewModel itemSetViewModel = ItemSetUtil.CreateItemSetPerChampion(buildSource, champion, mode, Configuration.ShowSkillsOrder);

            if (itemSetViewModel == null)
            {
                throw new InvalidOperationException("LoLItemSetViewModel is null");
            }

            // Create Item set JSON file into LoL directory
            string itemSetDir = LoLPathUtil.CreateItemSetDirectory(Configuration.LoLDirectory, champion.Name);

            string itemSetFileName     = ItemSetUtil.GetFormattedItemSetFileName(buildSource, mode, Configuration.ApplicationPrefixName);
            string itemSetAbsolutePath = Path.Combine(itemSetDir, itemSetFileName);

            await FileUtil.CreateJsonFileAsync(itemSetAbsolutePath, itemSetViewModel, cancelToken);
        }
Exemplo n.º 4
0
        private void DeleteItemSets()
        {
            Log("Deleting existing item sets...");

            string appPrefix    = Properties.Settings.Default.AppPrefixName;
            string lolDirectory = Properties.Settings.Default.LoLDirectory;

            LoLPathUtil.DeleteItemSets(lolDirectory, appPrefix);

            Log("Finished deleting!");
        }
Exemplo n.º 5
0
        private void FillFormsWithUserSettings()
        {
            string lolDirectory = Properties.Settings.Default.LoLDirectory;

            txtLoLDirectory.Text = lolDirectory;

            // Check if LoL directory is valid
            if (LoLPathUtil.IsValidLeagueOfLegendsDirectory(lolDirectory))
            {
                ChangeLoLStatusToFound();
            }
            else
            {
                ChangeLoLStatusToNotFound();
            }
        }