Exemplo n.º 1
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.");
            }
        }