예제 #1
0
        /// <summary>
        /// Sets the current view and updates the viewsitepanel
        /// </summary>
        /// <param name="page">current WizardPage</param>
        private void UpdateCurrentView(XafWizardPage page)
        {
            var xafWizardPage = page;
            var wizardPage    = xafWizardPage;

            wizardPage.View.SaveModel();
            ((Control)((IViewSiteTemplate)Frame.Template).ViewSiteControl).Parent = page;
            Frame.SetFieldValue("view", null);
            Frame.SetView(wizardPage.View, true, Frame, false);
            if (!View.ErrorMessages.IsEmpty)
            {
                wizardPage.View.ErrorMessages.LoadMessages(View.ErrorMessages);
            }
        }
예제 #2
0
        private void CreateWizardPage(IModelDetailViewWizardPage page, CompletionWizardPage finishPage)
        {
            OnWizardPageDetailViewCreating();
            var detailView = Application.CreateDetailView(ObjectSpace, page.DetailView, false);

            OnWizardPageDetailViewCreated();
            detailView.CurrentObject = View.CurrentObject;

            var wizardPage = new XafWizardPage {
                View            = detailView,
                Text            = page.Caption,
                DescriptionText = page.Description
            };

            _wizardForm.WizardControl.Pages.Insert(finishPage, wizardPage);
        }
예제 #3
0
        /// <summary>
        /// Occours when activating the controller
        /// </summary>
        protected override void OnActivated()
        {
            base.OnActivated();

            if (Frame.Template != null && Frame.Template is WizardDetailViewForm)
            {
                var modelWizard = (IModelDetailViewWizard)((DetailView)View).Model;
                _WizardForm = Frame.Template as WizardDetailViewForm;

                _WizardForm.WizardControl.CancelClick          += WizardControl_CancelClick;
                _WizardForm.WizardControl.FinishClick          += WizardControl_FinishClick;
                _WizardForm.WizardControl.NextClick            += WizardControl_NextClick;
                _WizardForm.WizardControl.SelectedPageChanged  += WizardControl_SelectedPageChanged;
                _WizardForm.WizardControl.SelectedPageChanging += WizardControl_SelectedPageChanging;
                _WizardForm.WizardControl.BeginUpdate();

                try {
                    var finishPage = _WizardForm.WizardControl.Pages[0] as CompletionWizardPage;
                    foreach (IModelDetailViewWizardPage page in modelWizard.Wizard)
                    {
                        OnWizardPageDetailViewCreating();
                        var detailView = Application.CreateDetailView(ObjectSpace, page.DetailView, false);
                        OnWizardPageDetailViewCreated();
                        detailView.CurrentObject = View.CurrentObject;

                        var wizardPage = new XafWizardPage {
                            View            = detailView,
                            Text            = page.Caption,
                            DescriptionText = page.Description
                        };
                        _WizardForm.WizardControl.Pages.Insert(finishPage, wizardPage);
                    }

                    if (!modelWizard.Wizard.ShowCompletionWizardPage)
                    {
                        _WizardForm.WizardControl.Pages.Remove(finishPage);
                    }
                } finally {
                    _WizardForm.WizardControl.EndUpdate();
                }
            }
        }
예제 #4
0
        private IList ModifiedObjects(XafWizardPage page)
        {
            IList modifiedObjects;

            if (page.View.ObjectTypeInfo.IsPersistent)
            {
                modifiedObjects = ObjectSpace.ModifiedObjects;
                if (modifiedObjects.Count == 0)
                {
                    modifiedObjects.Add(page.View.CurrentObject);
                }
            }
            else
            {
                modifiedObjects =
                    new List <object> {
                    page.View.CurrentObject
                }
            };
            return(modifiedObjects);
        }
예제 #5
0
        /// <summary>
        /// Occours when activating the controller
        /// </summary>
        protected override void OnActivated() {
            base.OnActivated();

            if (Frame.Template != null && Frame.Template is WizardDetailViewForm) {
                var modelWizard = (IModelDetailViewWizard)((DetailView)View).Model;
                _WizardForm = Frame.Template as WizardDetailViewForm;

                _WizardForm.WizardControl.CancelClick += WizardControl_CancelClick;
                _WizardForm.WizardControl.FinishClick += WizardControl_FinishClick;
                _WizardForm.WizardControl.NextClick += WizardControl_NextClick;
                _WizardForm.WizardControl.SelectedPageChanged += WizardControl_SelectedPageChanged;
                _WizardForm.WizardControl.SelectedPageChanging += WizardControl_SelectedPageChanging;
                _WizardForm.WizardControl.BeginUpdate();

                try {
                    var finishPage = _WizardForm.WizardControl.Pages[0] as CompletionWizardPage;
                    foreach (IModelDetailViewWizardPage page in modelWizard.Wizard) {
                        OnWizardPageDetailViewCreating();
                        var detailView = Application.CreateDetailView(ObjectSpace, page.DetailView, false);
                        OnWizardPageDetailViewCreated();
                        detailView.CurrentObject = View.CurrentObject;

                        var wizardPage = new XafWizardPage {
                            View = detailView,
                            Text = page.Caption,
                            DescriptionText = page.Description
                        };
                        _WizardForm.WizardControl.Pages.Insert(finishPage, wizardPage);
                    }

                    if (!modelWizard.Wizard.ShowCompletionWizardPage) {
                        _WizardForm.WizardControl.Pages.Remove(finishPage);
                    }
                } finally {
                    _WizardForm.WizardControl.EndUpdate();
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Fires after the next button has been clicked
        /// </summary>
        private bool Validate(XafWizardPage page) {
            RuleValidationResult result;
            var validationResults = new RuleSetValidationResult();
            var usedProperties = new List<string>();
            var resultsHighlightControllers = new List<ResultsHighlightController> { Frame.GetController<ResultsHighlightController>() };

            foreach (var item in page.View.GetItems<PropertyEditor>()) {
                if (item.Control != null && ((Control)item.Control).Visible) {
                    usedProperties.Add(item.PropertyName);
                    if (item is ListPropertyEditor) {
                        usedProperties.AddRange(((ListPropertyEditor)item).ListView.Editor.RequiredProperties.Select(property => property.TrimEnd('!')));

                        var nestedController = ((ListPropertyEditor)item).Frame.GetController<ResultsHighlightController>();
                        if (nestedController != null) {
                            resultsHighlightControllers.Add(nestedController);
                        }
                    }
                }
            }

            var modifiedObjects = page.View.ObjectTypeInfo.IsPersistent ? ObjectSpace.ModifiedObjects : new List<object> { page.View.CurrentObject };
            foreach (var obj in modifiedObjects) {
                IList<IRule> rules = Validator.RuleSet.GetRules(obj, ContextIdentifier.Save);
                foreach (IRule rule in rules) {
                    bool ruleInUse = rule.UsedProperties.Any(property => usedProperties.Contains(property) || !string.IsNullOrEmpty(usedProperties.Where(p => p.EndsWith(String.Format(".{0}", property))).FirstOrDefault()));

                    string reason;
                    if (ruleInUse && RuleSet.NeedToValidateRule(rule, obj, out reason)) {
                        result = rule.Validate(obj);

                        if (result.State == ValidationState.Invalid) {
                            validationResults.AddResult(new RuleSetValidationResultItem(obj, ContextIdentifier.Save, rule, result));
                        }
                    }
                }
            }

            foreach (ResultsHighlightController resultsHighlightController in resultsHighlightControllers) {
                resultsHighlightController.ClearHighlighting();
                if (validationResults.State == ValidationState.Invalid) {
                    resultsHighlightController.HighlightResults(validationResults);
                }
            }

            return validationResults.State == ValidationState.Valid;
        }
예제 #7
0
        /// <summary>
        /// Fires after the next button has been clicked
        /// </summary>
        private bool Validate(XafWizardPage page)
        {
            RuleValidationResult result;
            var validationResults           = new RuleSetValidationResult();
            var usedProperties              = new List <string>();
            var resultsHighlightControllers = new List <ResultsHighlightController> {
                Frame.GetController <ResultsHighlightController>()
            };

            foreach (var item in page.View.GetItems <PropertyEditor>())
            {
                if (item.Control != null && ((Control)item.Control).Visible)
                {
                    usedProperties.Add(item.PropertyName);
                    if (item is ListPropertyEditor)
                    {
                        usedProperties.AddRange(((ListPropertyEditor)item).ListView.Editor.RequiredProperties.Select(property => property.TrimEnd('!')));

                        var nestedController = ((ListPropertyEditor)item).Frame.GetController <ResultsHighlightController>();
                        if (nestedController != null)
                        {
                            resultsHighlightControllers.Add(nestedController);
                        }
                    }
                }
            }

            var modifiedObjects = page.View.ObjectTypeInfo.IsPersistent ? ObjectSpace.ModifiedObjects : new List <object> {
                page.View.CurrentObject
            };

            foreach (var obj in modifiedObjects)
            {
                IList <IRule> rules = Validator.RuleSet.GetRules(obj, ContextIdentifier.Save);
                foreach (IRule rule in rules)
                {
                    bool ruleInUse = rule.UsedProperties.Any(property => usedProperties.Contains(property) || !string.IsNullOrEmpty(usedProperties.Where(p => p.EndsWith(String.Format(".{0}", property))).FirstOrDefault()));

                    string reason;
                    if (ruleInUse && RuleSet.NeedToValidateRule(rule, obj, out reason))
                    {
                        result = rule.Validate(obj);

                        if (result.State == ValidationState.Invalid)
                        {
                            validationResults.AddResult(new RuleSetValidationResultItem(obj, ContextIdentifier.Save, rule, result));
                        }
                    }
                }
            }

            foreach (ResultsHighlightController resultsHighlightController in resultsHighlightControllers)
            {
                resultsHighlightController.ClearHighlighting();
                if (validationResults.State == ValidationState.Invalid)
                {
                    resultsHighlightController.HighlightResults(validationResults);
                }
            }

            return(validationResults.State == ValidationState.Valid);
        }
예제 #8
0
 private IList ModifiedObjects(XafWizardPage page){
     IList modifiedObjects;
     if (page.View.ObjectTypeInfo.IsPersistent){
         modifiedObjects = ObjectSpace.ModifiedObjects;
         if (modifiedObjects.Count == 0)
             modifiedObjects.Add(page.View.CurrentObject);
     }
     else
         modifiedObjects =
             new List<object>{page.View.CurrentObject};
     return modifiedObjects;
 }
예제 #9
0
        /// <summary>
        /// Fires after the next button has been clicked
        /// </summary>
        private bool Validate(XafWizardPage page)
        {
            if (page == null)
            {
                return(true);
            }
            var validationResults = new RuleSetValidationResult();
            var usedProperties = new List <string>();
            var resultsHighlightControllers = new List <ResultsHighlightController> {
                Frame.GetController <ResultsHighlightController>()
            }.Where(controller => controller != null).ToList();

            foreach (var item in page.View.GetItems <PropertyEditor>())
            {
                if (item.Control != null && ((Control)item.Control).Visible)
                {
                    usedProperties.Add(item.PropertyName);
                    var editor = item as ListPropertyEditor;
                    if (editor != null)
                    {
                        usedProperties.AddRange(editor.ListView.Editor.RequiredProperties.Select(property => property.TrimEnd('!')));

                        var nestedController = editor.Frame.GetController <ResultsHighlightController>();
                        if (nestedController != null)
                        {
                            resultsHighlightControllers.Add(nestedController);
                        }
                    }
                }
            }

            var modifiedObjects = ModifiedObjects(page);

            foreach (var obj in modifiedObjects)
            {
                IList <IRule> rules = Validator.RuleSet.GetRules(obj, ContextIdentifier.Save);
                foreach (IRule rule in rules)
                {
                    bool ruleInUse = rule.UsedProperties.Any(property => usedProperties.Contains(property) || !string.IsNullOrEmpty(usedProperties.FirstOrDefault(p => p.EndsWith(
                                                                                                                                                                      $".{property}"))));
                    string reason;
                    if (ruleInUse && RuleSet.NeedToValidateRule(ObjectSpace, rule, obj, out reason))
                    {
                        var objectSpaceLink = rule as IObjectSpaceLink;
                        if (objectSpaceLink != null)
                        {
                            objectSpaceLink.ObjectSpace = ObjectSpace;
                        }
                        RuleValidationResult result = rule.Validate(obj);
                        if (result.State == ValidationState.Invalid)
                        {
                            validationResults.AddResult(new RuleSetValidationResultItem(obj, ContextIdentifier.Save, rule, result));
                        }
                    }
                }
            }

            foreach (ResultsHighlightController resultsHighlightController in resultsHighlightControllers)
            {
                resultsHighlightController.ClearHighlighting();
                if (validationResults.State == ValidationState.Invalid)
                {
                    resultsHighlightController.HighlightResults(validationResults);
                }
            }

            return(validationResults.State != ValidationState.Invalid);
        }