protected override void Initialize(bool initData) { base.Initialize(initData); if (initData) { if (null == _groupStyles && null != _doc.ParentCollection) { _groupStyles = _doc.ParentCollection.GroupStyles; } var plotGroupController = new PlotGroupCollectionController(); plotGroupController.InitializeDocument(_groupStyles); plotGroupController.GroupStyleChanged += new WeakActionHandler(EhPlotGroupChanged, (handler) => plotGroupController.GroupStyleChanged -= handler); _plotGroupController = plotGroupController; // find the style collection controller _styleCollectionController = (IXYZPlotStyleCollectionController)Current.Gui.GetControllerAndControl(new object[] { _doc.Style }, typeof(IXYZPlotStyleCollectionController), UseDocument.Directly); _styleCollectionController.CollectionChangeCommit += new EventHandler(_styleCollectionController_CollectionChangeCommit); _styleCollectionController.StyleEditRequested += new Action <int>(_styleCollectionController_StyleEditRequested); // Initialize the data controller _dataController = (IPlotColumnDataController)Current.Gui.GetControllerAndControl(new object[] { _doc.DataObject, _doc }, typeof(IPlotColumnDataController), UseDocument.Directly); // Initialize the style controller list InitializeStyleControllerList(); } if (null != _view) { if (null == _plotGroupController.ViewObject) { Current.Gui.FindAndAttachControlTo(_plotGroupController); } _view.SetPlotGroupCollectionView(_plotGroupController.ViewObject); // add the style controller _view.SetPlotStyleView(_styleCollectionController.ViewObject); View_SetAllTabViews(); } }
public override IEnumerable <ControllerAndSetNullMethod> GetSubControllers() { yield return(new ControllerAndSetNullMethod(_plotGroupController, () => _plotGroupController = null)); yield return(new ControllerAndSetNullMethod(_dataController, () => _dataController = null)); yield return(new ControllerAndSetNullMethod(_styleCollectionController, () => { if (null != _styleCollectionController) { _styleCollectionController.CollectionChangeCommit -= _styleCollectionController_CollectionChangeCommit; _styleCollectionController.StyleEditRequested -= _styleCollectionController_StyleEditRequested; _styleCollectionController = null; } })); if (null != _styleControllerList) { foreach (var ctrl in _styleControllerList) { yield return(new ControllerAndSetNullMethod(ctrl, null)); } yield return(new ControllerAndSetNullMethod(null, () => _styleControllerList = null)); } if (null != _styleControllerDictionary) { foreach (var ctrl in _styleControllerDictionary.Values) { yield return(new ControllerAndSetNullMethod(ctrl, null)); } yield return(new ControllerAndSetNullMethod(null, () => _styleControllerDictionary = null)); } }