/// <summary> /// 在工作区打开一个文档。如果已经打开,则激活 /// </summary> static public Form OpenWorkDocument(WorkDocumentType type, string id, string ownerId) { Debug.Assert(type != WorkDocumentType.None); Debug.Assert(!string.IsNullOrEmpty(id)); Debug.Assert(_isInited); Debug.Assert(_openHandle != null); string keyId = GetKey(id, type); Form form = null; if (_dicIdAndView.TryGetValue(keyId, out form)) { _activateForm(form); } else { form = _openHandle(type, id, ownerId); FormData formData = new FormData(type, id, ownerId, form); form.Tag = formData; _dicIdAndView.Add(keyId, form); form.FormClosed += delegate { _dicIdAndView.Remove(keyId); }; ///触发WorkDocumentNewOpened事件 OnWorkDocumentNewOpened(new EventArgs <FormData>(formData)); } return(form); }
public FormData(WorkDocumentType type, string id, string ownerId, Form form) { _workDocumentType = type; _id = id; _ownerId = ownerId; _form = form; }
/// <summary> /// 新建页面 /// </summary> /// <param name="m_tree"></param> /// <param name="myType"></param> public void NewPage(FolderXmlElement parentEle, PageType myType) { if (myType != PageType.Home) { NewPageForm newPage = new NewPageForm(parentEle, myType); if (newPage.ShowDialog() == DialogResult.OK) { ///建完页面后打开页面 WorkDocumentType workDocumentType = WorkDocumentType.None; if (myType == PageType.General) { workDocumentType = WorkDocumentType.HtmlDesigner; } else { workDocumentType = WorkDocumentType.Edit; } Service.Workbench.OpenWorkDocument(workDocumentType, newPage.NewPageId); } } else { NewHomePageForm newPage = new NewHomePageForm(parentEle, myType); if (newPage.ShowDialog() == DialogResult.OK) { ///建完页面后打开页面 Service.Workbench.OpenWorkDocument(WorkDocumentType.HomePage, newPage.NewPageId); } } }
/// <summary> /// 关闭一个窗口且没有保存提示 /// </summary> static public Form CloseWorkDocumentWithoutSave(string id, WorkDocumentType type) { Debug.Assert(!string.IsNullOrEmpty(id)); if (string.IsNullOrEmpty(id)) { return(null); } Form form; string key = GetKey(id, type); if (_dicIdAndView.TryGetValue(key, out form)) { ///利用关闭所有窗口时的选项:"全否" try { CloseAllWindowData.BeginCloseAllWindow(); CloseAllWindowData.Option = CloseAllWindowOption.AllNoSave; form.Close(); } finally { CloseAllWindowData.EndCloseAllWindow(); } } return(form); }
static public Form GetWorkDocumentById(string id, WorkDocumentType type) { Debug.Assert(!string.IsNullOrEmpty(id)); Form form = null; string key = GetKey(id, type); _dicIdAndView.TryGetValue(key, out form); return(form); }
static public Form ActiveWorkDocument(string id, WorkDocumentType type) { Debug.Assert(!string.IsNullOrEmpty(id)); if (string.IsNullOrEmpty(id)) { return(null); } return(ActiveWorkDocument(GetKey(id, type))); }
static public Form ActiveWorkDocument(string id, WorkDocumentType type) { Debug.Assert(!string.IsNullOrEmpty(id)); if (string.IsNullOrEmpty(id)) { return(null); } Form form; string key = GetKey(id, type); if (_dicIdAndView.TryGetValue(key, out form)) { _activateForm(form); } return(form); }
static public void SetActiveWorkDocument(WorkDocumentType type, string id, Form activeForm) { Service.Workbench.SetActiveWorkDocument(type, id, activeForm); }
public WorkDocumentEventArgs(WorkDocumentType type, string id) { _type = type; _id = id; }
/// <summary> /// 从XmlElement数据里载入窗体列表 /// </summary> static public void LoadFormListFromXml(XmlElement ele) { try { if (ele == null) { return; } ///snip窗体最后打开(必须在snip打开前先打开tmplt窗体) List <XmlElement> snips = new List <XmlElement>(); foreach (XmlNode node in ele.ChildNodes) { if (node.NodeType == XmlNodeType.Element) { XmlElement eleForm = (XmlElement)node; ///窗体类型 WorkDocumentType type = (WorkDocumentType)Enum.Parse(typeof(WorkDocumentType), eleForm.GetAttribute("type"), true); if (type == WorkDocumentType.SnipDesigner) { snips.Add(eleForm); } else { ///id和ownerId string id = eleForm.GetAttribute("id"); string owner = eleForm.GetAttribute("ownerId"); OpenWorkDocument(type, id, owner); } } } ///最后处理snip foreach (XmlElement snip in snips) { ///id和ownerId string id = snip.GetAttribute("id"); string owner = snip.GetAttribute("ownerId"); OpenWorkDocument(WorkDocumentType.SnipDesigner, id, owner); } string defaultFormKeyId = ele.GetAttribute("defaultForm"); if (!string.IsNullOrEmpty(defaultFormKeyId)) { ActiveWorkDocument(defaultFormKeyId, WorkDocumentType.None); } } #if DEBUG #else ///在设计器让此异常抛出。但在正式版则忽略此异常。 catch (Exception) { } #endif finally { } }
/// <summary> /// 不建议调用,仅供内部调用 /// </summary> static internal void SetActiveWorkDocument(WorkDocumentType type, string id) { _activeWorkDocumentType = type; _activeId = id; }
static private string GetKey(string id, WorkDocumentType type) { Debug.Assert(!string.IsNullOrEmpty(id)); return(id + "&" + type); }
/// <summary> /// 在工作区打开一个文档。如果已经打开,则激活 /// </summary> static public Form OpenWorkDocument(WorkDocumentType type, string id) { return(OpenWorkDocument(type, id, "")); }
/// <summary> /// 初始化工具箱中的工具组与工具 /// </summary> /// <param name="isOnlyHasBase">是否仅载入基础的工具组</param> /// <param name="type">当前WorkDocument的类型</param> private void InitToolBox(bool isOnlyHasBase, WorkDocumentType type) { if (this.IsDisposed) { return; } _toolBox.Nodes.Clear(); //_toolBox.Nodes.Add(this.BuildBaseTreeNode());//"常规"工具组 if (isOnlyHasBase) { return;//仅载入基础的工具组 } switch (Service.Workbench.ActiveWorkDocumentType) { case WorkDocumentType.SnipDesigner: #region 创建页面片的基本工具组和扩展工具组 { MdiSnipDesignerForm form = WorkbenchForm.MainForm.ActiveView as MdiSnipDesignerForm; //增加基本的页面片工具箱中的工具 _toolBox.Nodes.Add(BuildSnipBaseTreeNode()); //根据定制特性增加扩展的页面片工具箱中的工具 TmpltXmlDocument tmpltDoc = form.SnipElement.OwnerAnyDocument as TmpltXmlDocument; if (form.SnipElement.SnipType != PageSnipType.Content) { return; } if (tmpltDoc.TmpltType != TmpltType.Home) { Type pageType = null; switch (tmpltDoc.TmpltType) { case TmpltType.General: pageType = typeof(GeneralPageXmlDocument); break; case TmpltType.Product: pageType = typeof(ProductXmlDocument); break; case TmpltType.Project: pageType = typeof(ProjectXmlDocument); break; case TmpltType.InviteBidding: pageType = typeof(InviteBiddingXmlDocument); break; case TmpltType.Knowledge: pageType = typeof(KnowledgeXmlDocument); break; case TmpltType.Hr: pageType = typeof(HrXmlDocument); break; default: Debug.Fail("TmpltType is Fail!!!!!!"); break; } ToolBox.VSTreeNode node = BuildSnipAttributeTreeNode(pageType.GetProperties(), pageType); _toolBox.Nodes.Add(node); } break; } #endregion case WorkDocumentType.TmpltDesigner: #region 创建模板下的工具集 { //MdiTmpltDesignForm form = WorkbenchForm.MainForm.ActiveView as MdiTmpltDesignForm; //_toolBox.Nodes.Add(BuildRectBaseTreeNode()); break; } #endregion default: break; } }
/// <summary> /// 初始化工具箱中的工具组与工具 /// </summary> private void InitToolBox(WorkDocumentType type) { this.InitToolBox(false, type); _toolBox.ExpandAll(); }
/// <summary> /// 不建议调用,仅供内部调用 /// </summary> static internal void SetActiveWorkDocument(WorkDocumentType type, string id, Form activeForm) { _activeWorkDocumentType = type; _activeId = id; ActiveForm = activeForm; }
/// <summary> /// 返回目标窗口是否在已经打开窗口的结果,在返回TRUE 反之FALSE /// add by fenggy 2008-06-16 /// </summary> /// <param name="id"></param> /// <param name="ownerId"></param> /// <returns></returns> static public bool GetResultKeyID(WorkDocumentType type, string id) { string keyId = GetKey(id, type); return(_dicIdAndView.ContainsKey(keyId)); }
Form OpenWorkDocument(WorkDocumentType type, string id, string ownerId) { Debug.Assert(!string.IsNullOrEmpty(id)); Form returnForm = null; switch (type) { case WorkDocumentType.TmpltDesigner: { MdiTmpltDesignForm form = new MdiTmpltDesignForm(id); form.Owner = WorkbenchForm.MainForm; form.Show(MainDockPanel, DockState.Document); returnForm = form; break; } case WorkDocumentType.HomePage: { MdiHomePageDesignForm form = new MdiHomePageDesignForm(id); form.Owner = WorkbenchForm.MainForm; form.Show(MainDockPanel, DockState.Document); returnForm = form; break; } case WorkDocumentType.HtmlDesigner: { MdiHtmlDesignForm form = new MdiHtmlDesignForm(id); form.Owner = WorkbenchForm.MainForm; form.Show(MainDockPanel, DockState.Document); returnForm = form; break; } case WorkDocumentType.SnipDesigner: { MdiSnipDesignerForm form = new MdiSnipDesignerForm(ownerId, id); form.Owner = WorkbenchForm.MainForm; form.Show(MainDockPanel, DockState.Document); returnForm = form; break; } case WorkDocumentType.WebBrowser: { returnForm = NavigationUrl(id); break; } //TODO:管理页面合一 Lisuye case WorkDocumentType.Manager: { MdiBaseListViewForm form = new MdiBaseListViewForm(id); form.Owner = WorkbenchForm.MainForm; form.Show(WorkbenchForm.MainForm.MainDockPanel, DockState.Document); returnForm = form; break; } case WorkDocumentType.Edit: { MdiBaseEditViewForm form = new MdiBaseEditViewForm(id); form.Owner = WorkbenchForm.MainForm; form.Show(WorkbenchForm.MainForm.MainDockPanel, DockState.Document); returnForm = form; break; } case WorkDocumentType.StartupPage: { MdiWelComePageForm form = new MdiWelComePageForm(); form.Show(MainDockPanel, DockState.Document); returnForm = form; break; } case WorkDocumentType.SiteProperty: { SitePropertyForm form = new SitePropertyForm(id); form.Show(MainDockPanel, DockState.Document); returnForm = form; break; } default: break; } return(returnForm); }