protected virtual void ShowViewVariantParameterDialog(SingleChoiceActionExecuteEventArgs e, string mode)
        {
            string viewCaption = string.Empty;
            ViewVariantParameterObject parameter = new ViewVariantParameterObject(rootModelViewVariants);

            if (mode == STR_NewViewVariant_Id)
            {
                parameter.Caption = string.Format("{0}_{1:g}", View.Caption, DateTime.Now);
                viewCaption       = CaptionHelper.GetLocalizedText("Texts", "NewViewVariantParameterCaption");
            }
            if (mode == STR_EditViewVariant_Id && (changeVariantController != null) && changeVariantController.ChangeVariantAction.SelectedItem != null)
            {
                parameter.Caption = changeVariantController.ChangeVariantAction.SelectedItem.Caption;
                viewCaption       = CaptionHelper.GetLocalizedText("Texts", "EditViewVariantParameterCaption");
            }
            DialogController dialogController = Application.CreateController <DialogController>();

            dialogController.Accepting += dialogController_Accepting;
            dialogController.Tag        = mode;
            DetailView dv = Application.CreateDetailView(ObjectSpaceInMemory.CreateNew(), parameter, false);

            dv.ViewEditMode = ViewEditMode.Edit;
            dv.Caption      = viewCaption;
            e.ShowViewParameters.CreatedView = dv;
            e.ShowViewParameters.Controllers.Add(dialogController);
            e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
        }
        protected virtual void EditViewVariant(ViewVariantParameterObject parameter)
        {
            VariantsInfo variantsInfo = GetVariantsInfo();

            if (variantsInfo != null)
            {
                rootModelViewVariants[variantsInfo.CurrentVariantId].Caption = parameter.Caption;
            }
            if (changeVariantController != null)
            {
                changeVariantController.CurrentFrameViewVariantsManager.RefreshVariants();
            }
        }
        protected void dialogController_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            DialogController dialogController = (DialogController)sender;

            dialogController.Accepting -= dialogController_Accepting;
            string data = Convert.ToString(dialogController.Tag);
            ViewVariantParameterObject parameter = dialogController.Window.View.CurrentObject as ViewVariantParameterObject;

            if (data == STR_NewViewVariant_Id)
            {
                NewViewVariant(parameter);
            }
            else if (data == STR_EditViewVariant_Id)
            {
                EditViewVariant(parameter);
            }
        }
        protected virtual void NewViewVariant(ViewVariantParameterObject parameter)
        {
            View.SaveModel();                                                                                                           //It is necessary to save the current View settings into the application model before copying them.
            string        newViewVariantId    = String.Format("{0}_{1}", GetRootViewId(), Guid.NewGuid());                              //Identifier of a new view variant will be based on the identifier of the root view variant.
            IModelVariant newModelViewVariant = ((ModelNode)rootModelViewVariants).AddNode <IModelVariant>(newViewVariantId);           // Adds a new child node of the IModelVariant type with a specific identifier to the parent IModelViewVariants node.

            newModelViewVariant.View    = ((ModelNode)modelViews).AddClonedNode((ModelNode)View.Model, newViewVariantId) as IModelView; // Creates a new node of the IModelView type by cloning the settings of the current View and then sets the clone to the View property of the view variant created above. Beware of the specificity described at Q411979.
            newModelViewVariant.Caption = parameter.Caption;                                                                            //Sets the Caption property of the view variant created above to the caption specified by an end-user in the dialog.
            if (rootModelViewVariants.Count == 1)                                                                                       //It is necessary to add a default view variant node for the current View for correct operation of the Change Variant Action.
            {
                IModelVariant currentModelViewVariant = ((ModelNode)rootModelViewVariants).AddNode <IModelVariant>(View.Id);
                currentModelViewVariant.Caption = CaptionHelper.GetLocalizedText("Texts", "DefaultViewVariantCaption");
                currentModelViewVariant.View    = View.Model;
            }
            if (changeVariantController != null)
            {
                changeVariantController.CurrentFrameViewVariantsManager.RefreshVariants(); //Updates the Change Variant Action structure based on the model customizations above.
            }
            UpdateCurrentViewVariant(newViewVariantId);                                    //Sets the current view variant to the newly created one.
            UpdateUserViewVariantsAction();                                                //Updates the items of our User View Variant Action based on the current the Change Variant Action structure.
        }