public bool DoDefaultEdit() { if (this.ArchiveDetailForm == null) { MessageForm.ShowError("您只能通过表格来修改数据!"); return(false); } IControlManagerContainer cmc = this.ArchiveDetailForm as IControlManagerContainer; if (cmc == null) { MessageForm.ShowError("您不能通过此按钮来修改数据!"); return(false); } if (DoEditS(cmc.ControlManager, this.MasterGrid.GridName)) { ShowArchiveDetailForm(); return(true); } else { return(false); } }
public static void SetMenuState(this IChildMdiForm menuWindow) { if (menuWindow == null) { return; } IList <IButton> tsbs = menuWindow.GetCustomProperty(s_windowMenuButtonName) as IList <IButton>; if (tsbs != null) { IControlManagerContainer cmContainer = menuWindow as IControlManagerContainer; if (cmContainer != null) { if (cmContainer != null && cmContainer.ControlManager != null) { foreach (IButton tsb in tsbs) { SetTsbState(tsb, cmContainer.ControlManager); } } } else { IDisplayManagerContainer dmContainer = menuWindow as IDisplayManagerContainer; if (dmContainer != null && dmContainer.DisplayManager != null) { foreach (IButton tsb in tsbs) { SetTsbState(tsb, dmContainer.DisplayManager); } } } } }
/// <summary> /// /// </summary> /// <returns></returns> public bool DoDefaultAdd() { if (this.ArchiveDetailForm == null) { MessageForm.ShowError("您只能通过表格添加行来添加数据!"); return(false); } IControlManagerContainer cmc = this.ArchiveDetailForm as IControlManagerContainer; if (cmc == null) { MessageForm.ShowError("您不能通过此按钮来添加数据!"); return(false); } if (DoAddS(cmc.ControlManager)) { ShowArchiveDetailForm(); return(true); } else { return(false); } }
internal static void OnButtonClick(WindowMenuInfo windowMenuInfo, System.Windows.Forms.Form parentForm) { IArchiveDetailFormWithDetailGrids addg = parentForm as IArchiveDetailFormWithDetailGrids; if (addg != null) { foreach (IBoundGrid i in addg.DetailGrids) { MyGrid.CancelEditCurrentDataRow(i); } } IGridContainer agf = parentForm as IGridContainer; if (agf != null) { MyGrid.CancelEditCurrentDataRow(agf.MasterGrid); } IControlManagerContainer cmc = parentForm as IControlManagerContainer; if (cmc != null) { InternalExecuteWindowMenu(cmc.ControlManager, windowMenuInfo, parentForm); } else { IDisplayManagerContainer dmc = parentForm as IDisplayManagerContainer; if (dmc != null) { InternalExecuteWindowMenu(dmc.DisplayManager, windowMenuInfo, parentForm); //InternalExecuteWindowMenu((parentForm as ArchiveDetailForm).ParentArchiveForm, windowMenuInfo); } } }
private static void ControlManager_EditEnded(this IControlManagerContainer cmContainer, object sender, EventArgs e) { // Todo: Maybe should in ControlManager if (cmContainer.ControlManager.DisplayManager.InBatchOperation) { return; } IControlManager cm = sender as IControlManager; if (cm == cmContainer.ControlManager) { SetMenuState(cmContainer as IChildMdiForm); } }
private static void ControlManager_StateChanged(this IControlManagerContainer cmContainer, object sender, EventArgs e) { IControlManager cm = sender as IControlManager; if (cm == cmContainer.ControlManager) { SetMenuState(cmContainer as IChildMdiForm); } //if (this.ArchiveDetailForm != null && cm == this.ArchiveDetailForm.ControlManager) //{ // foreach (IButton tsb in m_tsbsDetail) // { // SetTsbState(tsb, this.ArchiveDetailForm.ControlManager); // } //} }
public static void DisposeWindowMenu(this IChildMdiForm menuWindow) { IList <IButton> tsbs = menuWindow.GetCustomProperty(s_windowMenuButtonName) as IList <IButton>; if (tsbs != null) { foreach (IButton tsb in tsbs) { tsb.Click -= new EventHandler(tsb_Click); } tsbs.Clear(); } ToolStrip toolStrip = menuWindow.GetCustomProperty("WindowMenuGeneratedToolStrip") as ToolStrip; if (toolStrip != null) { menuWindow.RevertMergeToolStrip(toolStrip); } IControlManagerContainer cmContainer = menuWindow as IControlManagerContainer; if (cmContainer != null && cmContainer.ControlManager != null) { cmContainer.ControlManager.DisplayManager.PositionChanged -= new EventHandler(cmContainer.ControlManager_PositionChanged); cmContainer.ControlManager.EditEnded -= new EventHandler(cmContainer.ControlManager_EditEnded); cmContainer.ControlManager.StateChanged -= new EventHandler(cmContainer.ControlManager_StateChanged); } else { IDisplayManagerContainer dmContainer = menuWindow as IDisplayManagerContainer; if (dmContainer != null && dmContainer.DisplayManager != null) { dmContainer.DisplayManager.PositionChanged -= new EventHandler(dmContainer.DisplayManager_PositionChanged); } } }
public static void GenerateWindowMenu(this IChildMdiForm menuWindow, IList <WindowMenuInfo> windowMenuInfos) { // WindowMenu if (windowMenuInfos != null && windowMenuInfos.Count > 0) { IList <IButton> tsbs = new List <IButton>(); ToolStrip toolStripDetail = GenerateWindowMenu(windowMenuInfos, tsbs, GetExistToolStripItems(menuWindow.ToolStrip)); menuWindow.MergeToolStrip(toolStripDetail); menuWindow.SetCustomProperty(s_windowMenuButtonName, tsbs); menuWindow.SetCustomProperty("WindowMenuGeneratedToolStrip", toolStripDetail); IControlManagerContainer cmContainer = menuWindow as IControlManagerContainer; if (cmContainer != null && cmContainer.ControlManager != null) { cmContainer.ControlManager.DisplayManager.PositionChanged -= new EventHandler(cmContainer.ControlManager_PositionChanged); cmContainer.ControlManager.EditEnded -= new EventHandler(cmContainer.ControlManager_EditEnded); cmContainer.ControlManager.StateChanged -= new EventHandler(cmContainer.ControlManager_StateChanged); cmContainer.ControlManager.DisplayManager.PositionChanged += new EventHandler(cmContainer.ControlManager_PositionChanged); cmContainer.ControlManager.EditEnded += new EventHandler(cmContainer.ControlManager_EditEnded); cmContainer.ControlManager.StateChanged += new EventHandler(cmContainer.ControlManager_StateChanged); } else { IDisplayManagerContainer dmContainer = menuWindow as IDisplayManagerContainer; if (dmContainer != null && dmContainer.DisplayManager != null) { // only one. DetailWindow.DisplayManager = MasterWindow.DisplayManager. 当时也可能不一致,-=无效。 // // 可能和MasterWindow不是同一个ControlManager dmContainer.DisplayManager.PositionChanged -= new EventHandler(dmContainer.DisplayManager_PositionChanged); dmContainer.DisplayManager.PositionChanged += new EventHandler(dmContainer.DisplayManager_PositionChanged); } } } }