private void okBtn_Click(object sender, EventArgs e) { _path = pathTBox.Text; _projectName = txtProjectName.Text; string strCaption = StringParserService.Parse("${res:SimplusD.name}"); ///检查输入值 if (string.IsNullOrEmpty(txtProjectName.Text.Trim())) { MessageBox.Show("项目名不能为空。", strCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); txtProjectName.Focus(); return; } if (string.IsNullOrEmpty(pathTBox.Text.Trim())) { MessageBox.Show("路径不能为空。"); pathTBox.Focus(); return; } if (pathTBox.Text.IndexOf(":") == -1) { MessageBox.Show("项目路径格式不正确:" + pathTBox.Text, strCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); pathTBox.Focus(); pathTBox.Select(); return; } string strRootPath = Directory.GetDirectoryRoot(pathTBox.Text); if (!Directory.Exists(strRootPath)) { MessageBox.Show("所指定的位置在无效或只读的磁盘上,或者包含为系统保留的设备名", strCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { if (Directory.Exists(pathTBox.Text)) { Directory.CreateDirectory(pathTBox.Text.Trim()); } } catch (NotSupportedException) { MessageBox.Show("项目路径格式不正确:" + pathTBox.Text, strCaption); pathTBox.Focus(); pathTBox.Select(); return; } catch (Exception ex) { Service.Exception.ShowException(ex); pathTBox.Focus(); pathTBox.Select(); return; } if (File.Exists( Path.Combine(Path.Combine(pathTBox.Text.Trim(), txtProjectName.Text.Trim()), txtProjectName.Text.Trim() + ".sdsite"))) { MessageBox.Show("项目已存在。", strCaption); txtProjectName.Focus(); txtProjectName.Select(); return; } if (this.selectListView.SelectedItems.Count > 0) { ((SiteType)this.selectListView.SelectedItems[0].Tag).GetSiteCreator(). CreateSite(pathTBox.Text, txtProjectName.Text); _projectFile = Path.Combine(pathTBox.Text, txtProjectName.Text + @"\" + txtProjectName.Text + ".sdsite"); this.DialogResult = DialogResult.OK; _isShowGuide = this.isStartupSiteWiz.Checked; this.Close(); ///记录下“网站路径” Service.RecentFiles.AddFilePath("recentCreateProjectFolder", pathTBox.Text); ///保存当前的图标显示状态 SoftwareOption.Site.ShowSmallIcon = smallIconToolStripButton.Checked; SoftwareOption.Site.UseSiteGuide = isStartupSiteWiz.Checked; SoftwareOption.Save(); } }
private void BtnCancel_Click(object sender, EventArgs e) { SoftwareOption.ReLoad(); _optionData.Load(); this.Close(); }
public void Save() { SoftwareOption.Save(); //_OptionXmlDocument.Save(PathService.Config_GlobalSetting); }
/// <summary> /// 初始化 /// </summary> public static void Initialize(string sdsite) { System.Windows.Forms.Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); _willOpenFile = sdsite; CssResources.Initialize(); //初始化的顺序是有一定规则的 Service.Util.Initialize(); Service.Property.Initialize(); PathService.Initialize(Application.StartupPath); Utility.Pinyin.Initialize(Path.Combine(PathService.SoftwarePath, "pinyin.mb")); ResourceService.Initialize(); StringParserService.Initialize(ResourceService.GetResourceText); SoftwareOption.Load(); ResourcesReader.InitializeResources("Configuration", SoftwareOption.General.ApplicationLanguage, null); Service.FileBinding.Initialize(); Service.DesignData.Load(PathService.Config_PadLayout); Service.RecentFiles.Initialize(); Service.SiteDataManager.Initialize(); Service.ListView.InitColumn(); SiteResourceService.Initialize(SelectResource, GetResourcePath, GetResourceAbsPath, GetResourceUrl, ImportResourceFile); AutoLayoutPanel.Initialize(PathService.CL_DataSources_Folder); LayoutConfiguration.LoadLayoutConfiguration(); _mainForm = new WorkbenchForm(); CssUtility.Initialize(_mainForm.SelectImageResource); ////初始化的顺序是有一定规则的 Service.User.Initialize(_mainForm.ShowLoginForm); Service.WebView.Initialize(_mainForm.SinglePagePublish); MessageService.Initialize(_mainForm); ToolbarManager.Initialize(_mainForm); MenuStripManager.Initialize(_mainForm); StatusBarManager.Initialize(_mainForm); FindAndReplaceForm.Initialize(_mainForm); //ResultsPad.Initialize(_mainForm); MenuStateManager.Initialize(); Service.StatusBar.Initialize(StatusBarManager.CurrentStatusStrip); Service.Workbench.Initialize( _mainForm, _mainForm.OpenWorkDocument, _mainForm.NavigationUrl, _mainForm.MainTreePad.TreeViewExPad.RefreshSiteTreeData, ShowDialogForCreateProject, ShowDialogForOpenProject, _mainForm.GotoTree, _mainForm.ActivateForm); ///监听项目的打开事件 Service.Project.ProjectOpened += new EventHandler(ProjectService_ProjectOpened); Service.Project.ProjectClosing += new EventHandler(ProjectService_ProjectClosing); Service.Project.ProjectClosed += new EventHandler(ProjectService_ProjectClosed); OnWorkbenchCreated(); _mainForm.OnActiveWorkspaceTypeChanged(new WorkspaceTypeEventArgs(WorkspaceType.Default)); _mainForm.MainDockPanel.ActiveDocumentChanged += new EventHandler(_mainForm.MainDockPanel_ActiveDocumentChanged); if (Initialized != null) { Initialized(null, EventArgs.Empty); } }