Beispiel #1
0
        private void addRecipeToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                using (AddTemplateDialog dialog = new AddTemplateDialog())
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        if (dialog.Template == null)
                        {
                            MessageBox.Show("No template returned from the dialog", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);

                            return;
                        }

                        if (_customTemplatesDocument == null)
                        {
                            _customTemplatesDocument = new TemplateDocument();
                        }

                        _customTemplatesDocument.AddTemplate(dialog.Template);
                        _customTemplatesDocument.Save();

                        LoadTemplates();

                        MessageBox.Show(
                            string.Format(@"The template '{0}' has been successfully created!", dialog.Template.Name) + Environment.NewLine + Environment.NewLine +
                            @"The custom templates are persisted in %APPDATA%\AzureResourceManagerClient\Templates.txt", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void viewModel_OnSave(object sender, EventArgs e)
 {
     TemplateDocument.Save(_viewModel.Templates.ToList());
     Close();
 }