コード例 #1
0
        public CurrentPanelPanel(WizardDialog wizard)
        {
            normalFont = WinFormsResourceService.LoadFont("SansSerif", 18, GraphicsUnit.World);

            this.wizard  = wizard;
            Size         = new Size(wizard.Width - 220, 30);
            ResizeRedraw = false;

            SetStyle(ControlStyles.UserPaint, true);
        }
コード例 #2
0
		public CurrentPanelPanel(WizardDialog wizard)
		{
			normalFont = WinFormsResourceService.LoadFont("SansSerif", 18, GraphicsUnit.World);

			this.wizard = wizard;
			Size = new Size(wizard.Width - 220, 30);
			ResizeRedraw  = false;
			
			SetStyle(ControlStyles.UserPaint, true);
		}
コード例 #3
0
ファイル: StatusPanel.cs プロジェクト: carlhuth/GenXSource
        public StatusPanel(WizardDialog wizard)
        {
            smallFont  = ResourceService.LoadFont("Tahoma", 14, GraphicsUnit.World);
            normalFont = ResourceService.LoadFont("Tahoma", 14, GraphicsUnit.World);
            boldFont   = ResourceService.LoadFont("Tahoma", 14, FontStyle.Bold, GraphicsUnit.World);

            this.wizard          = wizard;
            this.BackgroundImage = ResourceService.GetBitmap("GeneralWizardBackground");
            Size         = new Size(198, 400);
            ResizeRedraw = false;

            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
        }
コード例 #4
0
		public StatusPanel(WizardDialog wizard)
		{
			smallFont  = WinFormsResourceService.LoadFont("Tahoma",  14, GraphicsUnit.World);
			normalFont = WinFormsResourceService.LoadFont("Tahoma", 14, GraphicsUnit.World);
			boldFont   = WinFormsResourceService.LoadFont("Tahoma", 14, FontStyle.Bold, GraphicsUnit.World);
			
			this.wizard = wizard;
			this.BackgroundImage = WinFormsResourceService.GetBitmap("GeneralWizardBackground");
			Size = new Size(198, 400);
			ResizeRedraw  = false;
			
			SetStyle(ControlStyles.UserPaint, true);
			SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
			SetStyle(ControlStyles.AllPaintingInWmPaint, true);
		}
コード例 #5
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));
            }
            createdFiles.Clear();
            if (templateListView.SelectedItems.Count == 1)
            {
                if (!AllPropertiesHaveAValue)
                {
                    MessageService.ShowMessage("${res:Dialog.NewFile.FillOutFirstMessage}", "${res:Dialog.NewFile.FillOutFirstCaption}");
                    return;
                }
                TemplateItem item = (TemplateItem)templateListView.SelectedItems[0];

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

                string fileName;
                StringParser.Properties["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 string[, ] {
                            { "FileName", fileName }
                        }));
                        return;
                    }
                    if (Path.GetExtension(fileName).Length == 0)
                    {
                        fileName += Path.GetExtension(item.Template.DefaultName);
                    }
                    fileName = Path.Combine(basePath, fileName);
                    fileName = FileUtility.NormalizePath(fileName);
                    IProject project = ProjectService.CurrentProject;
                    if (project != null)
                    {
                        StringParser.Properties["StandardNamespace"] = CustomToolsService.GetDefaultNamespace(project, fileName);
                    }
                }
                StringParser.Properties["FullName"] = fileName;
                StringParser.Properties["FileName"] = Path.GetFileName(fileName);
                StringParser.Properties["FileNameWithoutExtension"] = Path.GetFileNameWithoutExtension(fileName);
                StringParser.Properties["Extension"] = Path.GetExtension(fileName);
                StringParser.Properties["Path"]      = Path.GetDirectoryName(fileName);

                StringParser.Properties["ClassName"] = GenerateValidClassOrNamespaceName(Path.GetFileNameWithoutExtension(fileName), false);

                // when adding a file to a project (but not when creating a standalone file while a project is open):
                if (ProjectService.CurrentProject != null && !this.allowUntitledFiles)
                {
                    // add required assembly references to the project
                    bool changes = false;
                    foreach (ReferenceProjectItem reference in item.Template.RequiredAssemblyReferences)
                    {
                        IEnumerable <ProjectItem> refs = ProjectService.CurrentProject.GetItemsOfType(ItemType.Reference);
                        if (!refs.Any(projItem => string.Equals(projItem.Include, reference.Include, StringComparison.OrdinalIgnoreCase)))
                        {
                            ReferenceProjectItem projItem = (ReferenceProjectItem)reference.CloneFor(ProjectService.CurrentProject);
                            ProjectService.AddProjectItem(ProjectService.CurrentProject, projItem);
                            changes = true;
                        }
                    }
                    if (changes)
                    {
                        ProjectService.CurrentProject.Save();
                    }
                }

                if (item.Template.WizardPath != null)
                {
                    Properties customizer = new Properties();
                    customizer.Set("Template", item.Template);
                    customizer.Set("Creator", this);
                    WizardDialog wizard = new WizardDialog("File Wizard", customizer, item.Template.WizardPath);
                    if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK)
                    {
                        DialogResult = DialogResult.OK;
                    }
                }
                else
                {
                    foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates)
                    {
                        if (!IsFilenameAvailable(StringParser.Parse(newfile.Name)))
                        {
                            MessageService.ShowError("Filename " + StringParser.Parse(newfile.Name) + " is in use.\nChoose another one");
                            return;
                        }
                    }
                    ScriptRunner scriptRunner = new ScriptRunner();

                    foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates)
                    {
                        if (newfile.ContentData != null)
                        {
                            SaveFile(newfile, null, newfile.ContentData);
                        }
                        else
                        {
                            SaveFile(newfile, scriptRunner.CompileScript(item.Template, newfile), null);
                        }
                    }
                    DialogResult = DialogResult.OK;

                    // raise FileCreated event for the new files.
                    foreach (KeyValuePair <string, FileDescriptionTemplate> entry in createdFiles)
                    {
                        FileService.FireFileCreated(entry.Key, false);
                    }
                }
            }
        }
コード例 #6
0
ファイル: NewFileDialog.cs プロジェクト: carlhuth/GenXSource
        void OpenEvent(object sender, EventArgs e)
        {
            if (((TreeView)ControlDictionary["categoryTreeView"]).SelectedNode != null)
            {
                PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked);
                PropertyService.Set("Dialogs.NewFileDialog.LastSelectedCategory", ((TreeView)ControlDictionary["categoryTreeView"]).SelectedNode.Text);
            }
            createdFiles.Clear();
            if (((ListView)ControlDictionary["templateListView"]).SelectedItems.Count == 1)
            {
                if (!AllPropertiesHaveAValue)
                {
                    MessageService.ShowMessage("${res:Dialog.NewFile.FillOutFirstMessage}", "${res:Dialog.NewFile.FillOutFirstCaption}");
                    return;
                }
                TemplateItem item = (TemplateItem)((ListView)ControlDictionary["templateListView"]).SelectedItems[0];
                string       fileName;
                StringParser.Properties["StandardNamespace"] = "DefaultNamespace";
                if (allowUntitledFiles)
                {
                    fileName = GenerateCurrentFileName();
                }
                else
                {
                    fileName = ControlDictionary["fileNameTextBox"].Text.Trim();
                    if (!FileUtility.IsValidFileName(fileName) ||
                        fileName.IndexOf(Path.AltDirectorySeparatorChar) >= 0 ||
                        fileName.IndexOf(Path.DirectorySeparatorChar) >= 0)
                    {
                        MessageService.ShowError(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.SaveFile.InvalidFileNameError}", new string[, ] {
                            { "FileName", fileName }
                        }));
                        return;
                    }
                    if (Path.GetExtension(fileName).Length == 0)
                    {
                        fileName += Path.GetExtension(item.Template.DefaultName);
                    }
                    fileName = Path.Combine(basePath, fileName);
                    fileName = Path.GetFullPath(fileName);
                    IProject project = ProjectService.CurrentProject;
                    if (project != null)
                    {
                        StringParser.Properties["StandardNamespace"] = CustomToolsService.GetDefaultNamespace(project, fileName);
                    }
                }
                StringParser.Properties["FullName"] = fileName;
                StringParser.Properties["FileName"] = Path.GetFileName(fileName);
                StringParser.Properties["FileNameWithoutExtension"] = Path.GetFileNameWithoutExtension(fileName);
                StringParser.Properties["Extension"] = Path.GetExtension(fileName);
                StringParser.Properties["Path"]      = Path.GetDirectoryName(fileName);

                StringParser.Properties["ClassName"] = GenerateValidClassName(Path.GetFileNameWithoutExtension(fileName));


                if (item.Template.WizardPath != null)
                {
                    Properties customizer = new Properties();
                    customizer.Set("Template", item.Template);
                    customizer.Set("Creator", this);
                    WizardDialog wizard = new WizardDialog("File Wizard", customizer, item.Template.WizardPath);
                    if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK)
                    {
                        DialogResult = DialogResult.OK;
                    }
                }
                else
                {
                    foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates)
                    {
                        if (!IsFilenameAvailable(StringParser.Parse(newfile.Name)))
                        {
                            MessageService.ShowError("Filename " + StringParser.Parse(newfile.Name) + " is in use.\nChoose another one");
                            return;
                        }
                    }
                    ScriptRunner scriptRunner = new ScriptRunner();

                    foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates)
                    {
                        if (newfile.ContentData != null)
                        {
                            SaveFile(newfile, null, newfile.ContentData);
                        }
                        else
                        {
                            SaveFile(newfile, scriptRunner.CompileScript(item.Template, newfile), null);
                        }
                    }
                    DialogResult = DialogResult.OK;

                    // raise FileCreated event for the new files
                    foreach (KeyValuePair <string, FileDescriptionTemplate> entry in createdFiles)
                    {
                        FileService.FireFileCreated(entry.Key);
                    }
                }
            }
        }
コード例 #7
0
//		string startupProject = null;

		public string CreateProject(ProjectCreateInformation projectCreateInformation)
		{
			LoggingService.Info("Creating project from template '" + this.Category + "/" + this.Subcategory + "/" + this.Name + "'");
			if (wizardpath != null) {
				Properties customizer = new Properties();
				customizer.Set("ProjectCreateInformation", projectCreateInformation);
				customizer.Set("ProjectTemplate", this);
				WizardDialog wizard = new WizardDialog("Project Wizard", customizer, wizardpath);
				if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) != DialogResult.OK) {
					return null;
				}
			}
			if (solutionDescriptor != null) {
				return solutionDescriptor.CreateSolution(projectCreateInformation, this.languagename);
			} else if (projectDescriptor != null) {
				bool createNewSolution = projectCreateInformation.Solution == null;
				if (createNewSolution) {
					projectCreateInformation.Solution = new Solution();
					projectCreateInformation.Solution.Name = projectCreateInformation.SolutionName;
					projectCreateInformation.Solution.FileName = Path.Combine(projectCreateInformation.SolutionPath, projectCreateInformation.SolutionName + ".sln");
				}
				IProject project = projectDescriptor.CreateProject(projectCreateInformation, this.languagename);
				if (project != null) {
					string solutionLocation = projectCreateInformation.Solution.FileName;
					if (createNewSolution) {
						projectCreateInformation.Solution.AddFolder(project);
						projectCreateInformation.Solution.Save();
						ProjectService.OnSolutionCreated(new SolutionEventArgs(projectCreateInformation.Solution));
						projectCreateInformation.Solution.Dispose();
					} else {
						project.Dispose();
					}
					return solutionLocation;
				} else {
					return null;
				}
			} else {
				return null;
			}
		}
コード例 #8
0
		void OpenEvent(object sender, EventArgs e)
		{
			if (((TreeView)ControlDictionary["categoryTreeView"]).SelectedNode != null) {
				
				PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked);
				PropertyService.Set("Dialogs.NewFileDialog.LastSelectedCategory", ((TreeView)ControlDictionary["categoryTreeView"]).SelectedNode.Text);
			}
			createdFiles.Clear();
			if (((ListView)ControlDictionary["templateListView"]).SelectedItems.Count == 1) {
				if (!AllPropertiesHaveAValue) {
					MessageService.ShowMessage("${res:Dialog.NewFile.FillOutFirstMessage}", "${res:Dialog.NewFile.FillOutFirstCaption}");
					return;
				}
				TemplateItem item = (TemplateItem)((ListView)ControlDictionary["templateListView"]).SelectedItems[0];
				string fileName;
				StringParser.Properties["StandardNamespace"] = "DefaultNamespace";
				if (allowUntitledFiles) {
					fileName = GenerateCurrentFileName();
				} else {
					fileName = ControlDictionary["fileNameTextBox"].Text.Trim();
					if (!FileUtility.IsValidFileName(fileName)
					    || fileName.IndexOf(Path.AltDirectorySeparatorChar) >= 0
					    || fileName.IndexOf(Path.DirectorySeparatorChar) >= 0)
					{
						MessageService.ShowError(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.SaveFile.InvalidFileNameError}", new string[,] {{"FileName", fileName}}));
						return;
					}
					if (Path.GetExtension(fileName).Length == 0) {
						fileName += Path.GetExtension(item.Template.DefaultName);
					}
					fileName = Path.Combine(basePath, fileName);
					fileName = Path.GetFullPath(fileName);
					IProject project = ProjectService.CurrentProject;
					if (project != null) {
						StringParser.Properties["StandardNamespace"] = CustomToolsService.GetDefaultNamespace(project, fileName);
					}
				}
				StringParser.Properties["FullName"]                 = fileName;
				StringParser.Properties["FileName"]                 = Path.GetFileName(fileName);
				StringParser.Properties["FileNameWithoutExtension"] = Path.GetFileNameWithoutExtension(fileName);
				StringParser.Properties["Extension"]                = Path.GetExtension(fileName);
				StringParser.Properties["Path"]                     = Path.GetDirectoryName(fileName);
				
				StringParser.Properties["ClassName"] = GenerateValidClassName(Path.GetFileNameWithoutExtension(fileName));
				
				
				if (item.Template.WizardPath != null) {
					Properties customizer = new Properties();
					customizer.Set("Template", item.Template);
					customizer.Set("Creator",  this);
					WizardDialog wizard = new WizardDialog("File Wizard", customizer, item.Template.WizardPath);
					if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
						DialogResult = DialogResult.OK;
					}
				} else {
					foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates) {
						if (!IsFilenameAvailable(StringParser.Parse(newfile.Name))) {
							MessageService.ShowError("Filename " + StringParser.Parse(newfile.Name) + " is in use.\nChoose another one");
							return;
						}
					}
					ScriptRunner scriptRunner = new ScriptRunner();
					
					foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates) {
						if (newfile.ContentData != null) {
							SaveFile(newfile, null, newfile.ContentData);
						} else {
							SaveFile(newfile, scriptRunner.CompileScript(item.Template, newfile), null);
						}
					}
					DialogResult = DialogResult.OK;
					
					// raise FileCreated event for the new files
					foreach (KeyValuePair<string, FileDescriptionTemplate> entry in createdFiles) {
						FileService.FireFileCreated(entry.Key);
					}
				}
			}
		}
コード例 #9
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));
			}
			createdFiles.Clear();
			if (templateListView.SelectedItems.Count == 1) {
				if (!AllPropertiesHaveAValue) {
					MessageService.ShowMessage("${res:Dialog.NewFile.FillOutFirstMessage}", "${res:Dialog.NewFile.FillOutFirstCaption}");
					return;
				}
				TemplateItem item = (TemplateItem)templateListView.SelectedItems[0];
				
				PropertyService.Set("Dialogs.NewFileDialog.LastSelectedTemplate", item.Template.Name);
				
				string fileName;
				StringParser.Properties["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 string[,] {{"FileName", fileName}}));
						return;
					}
					if (Path.GetExtension(fileName).Length == 0) {
						fileName += Path.GetExtension(item.Template.DefaultName);
					}
					fileName = Path.Combine(basePath, fileName);
					fileName = FileUtility.NormalizePath(fileName);
					IProject project = ProjectService.CurrentProject;
					if (project != null) {
						StringParser.Properties["StandardNamespace"] = CustomToolsService.GetDefaultNamespace(project, fileName);
					}
				}
				StringParser.Properties["FullName"]                 = fileName;
				StringParser.Properties["FileName"]                 = Path.GetFileName(fileName);
				StringParser.Properties["FileNameWithoutExtension"] = Path.GetFileNameWithoutExtension(fileName);
				StringParser.Properties["Extension"]                = Path.GetExtension(fileName);
				StringParser.Properties["Path"]                     = Path.GetDirectoryName(fileName);
				
				StringParser.Properties["ClassName"] = GenerateValidClassOrNamespaceName(Path.GetFileNameWithoutExtension(fileName), false);
				
				// when adding a file to a project (but not when creating a standalone file while a project is open):
				if (ProjectService.CurrentProject != null && !this.allowUntitledFiles) {
					// add required assembly references to the project
					bool changes = false;
					foreach (ReferenceProjectItem reference in item.Template.RequiredAssemblyReferences) {
						IEnumerable<ProjectItem> refs = ProjectService.CurrentProject.GetItemsOfType(ItemType.Reference);
						if (!refs.Any(projItem => string.Equals(projItem.Include, reference.Include, StringComparison.OrdinalIgnoreCase))) {
							ReferenceProjectItem projItem = (ReferenceProjectItem)reference.CloneFor(ProjectService.CurrentProject);
							ProjectService.AddProjectItem(ProjectService.CurrentProject, projItem);
							changes = true;
						}
					}
					if (changes) {
						ProjectService.CurrentProject.Save();
					}
				}
				
				if (item.Template.WizardPath != null) {
					Properties customizer = new Properties();
					customizer.Set("Template", item.Template);
					customizer.Set("Creator",  this);
					WizardDialog wizard = new WizardDialog("File Wizard", customizer, item.Template.WizardPath);
					if (wizard.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
						DialogResult = DialogResult.OK;
					}
				} else {
					foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates) {
						if (!IsFilenameAvailable(StringParser.Parse(newfile.Name))) {
							MessageService.ShowError("Filename " + StringParser.Parse(newfile.Name) + " is in use.\nChoose another one");
							return;
						}
					}
					ScriptRunner scriptRunner = new ScriptRunner();
					
					foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates) {
						if (newfile.ContentData != null) {
							SaveFile(newfile, null, newfile.ContentData);
						} else {
							SaveFile(newfile, scriptRunner.CompileScript(item.Template, newfile), null);
						}
					}
					DialogResult = DialogResult.OK;
					
					// raise FileCreated event for the new files.
					foreach (KeyValuePair<string, FileDescriptionTemplate> entry in createdFiles) {
						FileService.FireFileCreated(entry.Key, false);
					}
				}
			}
		}