コード例 #1
0
        private async void RemoveButtonClick(object sender, RoutedEventArgs e)
        {
            var files = CodeFileList.GetFiles();

            if (files.Length == 0)
            {
                await this.ShowMessageAsync("Error", "No files to remove the license from.");
            }
            else
            {
                if (LicensePrinter.RemoveLicense(files))
                {
                    await this.ShowMessageAsync("Finished !", "We have successfully removed the license");
                }
                else
                {
                    await this.ShowMessageAsync("Error!", "The program encountered an error and hasnt removed the license.");
                }
            }
        }
コード例 #2
0
        private async void InsertLicenseClick(object sender, RoutedEventArgs e)
        {
            if (LicenseListComboBox.SelectedIndex != -1)
            {
                if (FileList.Items.Count > 0)
                {
                    var boxResult = await this.ShowMessageAsync("Are you sure?", "We will now insert the license into all the files listed, are you sure?", MessageDialogStyle.AffirmativeAndNegative);

                    if (boxResult != MessageDialogResult.Affirmative)
                    {
                        return;
                    }

                    var path = LicenseListComboBox.SelectedItem.ToString();

                    LicensePrinter.Email = EmailTextBlock.Text;
                    LicensePrinter.Name  = NameTextBlock.Text;
                    LicensePrinter.Date  = DateTextBlock.Text;

                    var success = LicensePrinter.PrintLicense(LicenseList.GetFullFilename(path), CodeFileList.GetFiles());

                    if (success)
                    {
                        await this.ShowMessageAsync("Finished!", "We have inserted the license into all source files!");
                    }
                    else
                    {
                        await this.ShowMessageAsync("Error!", "The program encountered an error and hasnt stamped the license.");
                    }
                }
                else
                {
                    await this.ShowMessageAsync("No Files!", "Please open some files to insert the license into.");
                }
            }
            else
            {
                await this.ShowMessageAsync("No License", "Please choose a license push it to your source files.");
            }
        }
コード例 #3
0
        private async void FindButtonClick(object sender, RoutedEventArgs e)
        {
            var files = CodeFileList.GetFiles();

            if (files.Length == 0)
            {
                await this.ShowMessageAsync("No Files", "No files to check");
            }
            else
            {
                var filesWithLicensesCount = LicensePrinter.HasLicenses(files);

                if (files.Length == filesWithLicensesCount)
                {
                    await this.ShowMessageAsync("Success", "We found a licence in all files");
                }
                else
                {
                    var body = "We found a licence in " + filesWithLicensesCount + " out of the " + files.Length + " files";

                    await this.ShowMessageAsync("Success", body);
                }
            }
        }