Example #1
0
        private void CreateModelEditorController(string aspect)
        {
            var allLayers = CurrentObject.GetAllLayers(_masterModel).ToList();

            _currentObjectModel = allLayers.Single(@base => @base.Id == CurrentObject.Name);
            _masterModel        = _modelLoader.ReCreate();
//            foreach (var layer in allLayers)
//                ModelApplicationHelper.RemoveLayer(layer);
            foreach (var layer in allLayers)
            {
                ModelApplicationHelper.AddLayer(_masterModel, layer);
            }

            RuntimeMemberBuilder.AddFields((IModelApplication)_masterModel, XpandModuleBase.Dictiorary);

            DisposeController();

            _modelEditorViewController = new ModelEditorViewController((IModelApplication)_masterModel, null);
            _modelEditorViewController.SetControl(Control);
            _modelEditorViewController.LoadSettings();

            if (aspect != CaptionHelper.DefaultLanguage)
            {
                _masterModel.CurrentAspectProvider.CurrentAspect = aspect;
            }

            _modelEditorViewController.CurrentAspectChanged        += ModelEditorViewControllerOnCurrentAspectChanged;
            _modelEditorViewController.SaveAction.ExecuteCompleted += SaveActionOnExecuteCompleted;
            _modelEditorViewController.Modifying += Model_Modifying;
            _modelEditorViewController.ChangeAspectAction.ExecuteCompleted += ChangeAspectActionOnExecuteCompleted;
        }
        private void CreateModelEditorController(string aspect)
        {
            var allLayers = CurrentObject.GetAllLayers(MasterModel).ToList();

            _currentObjectModel = allLayers.First(@base => @base.Id == $"{CurrentObject.Name}-{CurrentObject.DeviceCategory}");
            MasterModel         = GetMasterModel(true);
            foreach (var layer in allLayers)
            {
                ModelApplicationHelper.AddLayer(MasterModel, layer);
            }
            ModelApplicationBases[MasterModel].AssignAsInstance();
            RuntimeMemberBuilder.CreateRuntimeMembers((IModelApplication)MasterModel);
            TypeInfo.AssignAsInstance();

            DisposeController();

            _modelEditorViewController = new ExpressApp.Win.ModelEditorViewController((IModelApplication)MasterModel,
                                                                                      null);
            if (Control != null)
            {
                _modelEditorViewController.SetControl(Control);
                _modelEditorViewController.LoadSettings();
            }

            if (aspect != CaptionHelper.DefaultLanguage)
            {
                MasterModel.CurrentAspectProvider.CurrentAspect = aspect;
            }

            _modelEditorViewController.CurrentAspectChanged += ModelEditorViewControllerOnCurrentAspectChanged;
            _modelEditorViewController.Modifying            += Model_Modifying;
            _modelEditorViewController.ChangeAspectAction.ExecuteCompleted += ChangeAspectActionOnExecuteCompleted;
            _modelEditorViewController.ModelAttributesPropertyEditorController.PropertyChanged += ModelAttributesPropertyEditorControllerOnPropertyChanged;
        }