private void Initialize() { changeVariantController = Frame.GetController <ChangeVariantController>(); if (changeVariantController != null) { changeVariantController.ChangeVariantAction.Executed += ChangeVariantAction_ExecutedCompleted; } modelViews = (IModelList <IModelView>)View.Model.Application.Views; variantsProvider = Application.Modules.FindModule <ViewVariantsModule>().VariantsProvider; rootModelViewVariants = (IModelList <IModelVariant>)((IModelViewVariants)modelViews[GetRootViewId()]).Variants; }
protected override void Dispose(bool disposing) // It is important to release references here and not within the overridden OnDeactivated method, because this Controller is deactivated when changing the current View variant. { if (disposing) { UnsubscribeFromEvents(); changeVariantController = null; variantsProvider = null; rootModelViewVariants = null; modelViews = null; } base.Dispose(disposing); }
protected override void OnViewControllersActivated() { base.OnViewControllersActivated(); _viewVariantsModule = Application.FindModule <ViewVariantsModule>(); _isViewClonable = ((IModelListViewViewClonable)View.Model).IsViewClonable; _modifyVariantsAction.Active[IsClonable] = _isViewClonable; if (_isViewClonable) { _changeVariantController = Frame.GetController <ChangeVariantController>(); _rootListView = FindRootListView(); _changeVariantController.ChangeVariantAction.SelectedItemChanged += ChangeVariantActionOnSelectedItemChanged; if (_changeVariantController.ChangeVariantAction.Items.Count == 0) { UpdateActionState(); } } }
protected override void OnViewControllersActivated() { base.OnViewControllersActivated(); _viewVariantsModule = Application.FindModule <ViewVariantsModule>(); _isViewClonable = ((IModelListViewViewClonable)View.Model).IsViewClonable; _viewVariantsChoiceAction.Active[IsClonable] = _isViewClonable; if (_isViewClonable) { _changeVariantController = Frame.GetController <ChangeVariantController>(); _rootListView = FindRootListView(); _changeVariantController.ChangeVariantAction.SelectedItemChanged += ChangeVariantActionOnSelectedItemChanged; if (_changeVariantController.ChangeVariantAction.Items.Count == 0) { foreach (var item in _viewVariantsChoiceAction.Items.Where(item => ReferenceEquals(item.Data, Delete))) { item.Enabled[DefaultVariantId] = false; } } } }
private ListViewInfoNodeWrapper GetCurrentVariant(ChangeVariantController changeVariantController, ApplicationNodeWrapper wrapper) { var node1 = new ListViewInfoNodeWrapper(wrapper.Views.FindViewById(Application.FindListViewId(View.ObjectTypeInfo.Type)).Node); changeVariantController.ChangeVariantAction.Items.Remove( changeVariantController.ChangeVariantAction.SelectedItem); changeVariantController.ChangeVariantAction.SelectedItem = (from item in changeVariantController.ChangeVariantAction.Items where item.Caption == node1.Node.FindChildNode("Variants").ChildNodes[0].KeyAttribute.Value select item).Single(); return node1; }