예제 #1
0
        public override void Execute(object parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }
            FileTemplateResult result = (FileTemplateResult)parameter;
            var openedFile            = result.NewOpenedFiles.Single();
            var wizardViewModel       = new ReportWizardContext();
            var reportWizard          = new ICSharpCode.Reporting.Addin.ReportWizard.Dialog.ReportWizard(wizardViewModel);

            reportWizard.ShowDialog();
            if (reportWizard.DialogResult.HasValue && reportWizard.DialogResult.Value)
            {
                LoggingService.Info("ReportWizard - CreateReport");
                var rg = new ReportGenerator();

                rg.Generate(wizardViewModel);
                string xml = CreateFormSheetFromModel.ToXml(rg.ReportModel).ToString();
                openedFile.SetData(Encoding.UTF8.GetBytes(xml));
                if (!openedFile.IsUntitled)
                {
                    openedFile.SaveToDisk();
                }
            }
            else
            {
                LoggingService.Info("ReportWizard canceled");
                // HACK: cancel opening the file by clearing the file list
                openedFile.CloseIfAllViewsClosed();
                result.NewOpenedFiles.Clear();
                result.NewFiles.Clear();
            }
        }
예제 #2
0
        void OpenEvent(object sender, EventArgs e)
        {
            if (categoryTreeView.SelectedNode != null)
            {
                PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked);
                PropertyService.Set("Dialogs.NewFileDialog.CategoryViewState", TreeViewHelper.GetViewStateString(categoryTreeView));
                PropertyService.Set("Dialogs.NewFileDialog.LastSelectedCategory", TreeViewHelper.GetPath(categoryTreeView.SelectedNode));
            }
            if (templateListView.SelectedItems.Count == 1)
            {
                TemplateItem item = (TemplateItem)templateListView.SelectedItems[0];

                PropertyService.Set("Dialogs.NewFileDialog.LastSelectedTemplate", item.Template.Name);

                string fileName;
                string standardNamespace = "DefaultNamespace";
                if (allowUntitledFiles)
                {
                    fileName = GenerateCurrentFileName();
                }
                else
                {
                    fileName = ControlDictionary["fileNameTextBox"].Text.Trim();
                    if (!FileUtility.IsValidPath(fileName) ||
                        fileName.IndexOf(Path.AltDirectorySeparatorChar) >= 0 ||
                        fileName.IndexOf(Path.DirectorySeparatorChar) >= 0)
                    {
                        MessageService.ShowError(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.SaveFile.InvalidFileNameError}", new StringTagPair("FileName", fileName)));
                        return;
                    }
                    if (Path.GetExtension(fileName).Length == 0)
                    {
                        fileName += Path.GetExtension(item.Template.SuggestFileName(null));
                    }
                    fileName = Path.Combine(basePath, fileName);
                    fileName = FileUtility.NormalizePath(fileName);
                    if (project != null)
                    {
                        standardNamespace = CustomToolsService.GetDefaultNamespace(project, fileName);
                    }
                }

                options                     = new FileTemplateOptions();
                options.ClassName           = GenerateValidClassOrNamespaceName(Path.GetFileNameWithoutExtension(fileName), false);
                options.FileName            = FileName.Create(fileName);
                options.IsUntitled          = allowUntitledFiles;
                options.Namespace           = standardNamespace;
                options.CustomizationObject = localizedTypeDescriptor;
                options.Project             = project;

                result       = SelectedTemplate.Create(options);
                DialogResult = DialogResult.OK;
                if (result != null)
                {
                    SelectedTemplate.RunActions(result);
                }
            }
        }
예제 #3
0
        protected IEnumerable <FileProjectItem> AddNewItems()
        {
            DirectoryNode node = ProjectBrowserPad.Instance.ProjectBrowserControl.SelectedDirectoryNode;

            if (node == null)
            {
                return(null);
            }
            node.Expand();
            node.Expanding();

            FileTemplateResult result = SD.UIService.ShowNewFileDialog(node.Project, node.Directory);

            if (result != null)
            {
                node.RecreateSubNodes();
                return(result.NewFiles.Select(node.Project.FindFile).Where(f => f != null).ToArray());
            }
            else
            {
                return(null);
            }
        }