예제 #1
0
        protected override void OnViewControllersActivated()
        {
            base.OnViewControllersActivated();
            var modelActions      = Application.Model.ActionDesign.Actions.Cast <IModelActionItemsFromModel>().Where(model => model.ItemsFromModel);
            var choiceActionItems = modelActions.Where(model => model.ChoiceActionItems != null).SelectMany(model => model.ChoiceActionItems);
            var actions           = Frame.Actions <SingleChoiceAction>(choiceActionItems).ToDictionary(@base => @base.Id, @base => @base);

            if (actions.Any())
            {
                foreach (var choiceActionItem in choiceActionItems)
                {
                    var key = choiceActionItem.GetParent <IModelAction>().Id;
                    if (actions.ContainsKey(key))
                    {
                        var singleChoiceAction = actions[key];
                        if (singleChoiceAction.Items.FindItemByID(choiceActionItem.Id) == null)
                        {
                            var actionItem = new ChoiceActionItem(choiceActionItem);
                            OnCustomizeActionItem(new CustomizeActionItemArgs(actionItem));
                            singleChoiceAction.Items.Add(actionItem);
                        }
                    }
                }
            }
        }
 protected override void OnDeactivated()
 {
     base.OnDeactivated();
     foreach (var action in Frame.Actions <SingleChoiceAction>())
     {
         action.ItemsChanged -= SingleChoiceActionOnItemsChanged;
     }
 }
예제 #3
0
 private void FrameOnDisposing(object sender, EventArgs eventArgs)
 {
     Application.DetailViewCreating -= ApplicationOnDetailViewCreating;
     Frame.Disposing -= FrameOnDisposing;
     foreach (var action in Frame.Actions())
     {
         action.Executed -= ActionOnExecuted;
     }
 }
예제 #4
0
 protected override void OnFrameAssigned()
 {
     base.OnFrameAssigned();
     Application.DetailViewCreating += ApplicationOnDetailViewCreating;
     Frame.Disposing += FrameOnDisposing;
     foreach (var action in Frame.Actions())
     {
         action.Executed += ActionOnExecuted;
     }
 }
 protected override void OnViewControlsCreated()
 {
     base.OnViewControlsCreated();
     foreach (var action in Frame.Actions <SingleChoiceAction>())
     {
         action.ItemsChanged += SingleChoiceActionOnItemsChanged;
         foreach (var item in action.Items)
         {
             UpdateItem(item, action);
         }
     }
 }
예제 #6
0
 protected override void OnFrameAssigned()
 {
     base.OnFrameAssigned();
     foreach (var action in Frame.Actions <SimpleAction>())
     {
         var modelActionClientScript = ((IModelActionClientScript)action.Model());
         if (!string.IsNullOrEmpty(modelActionClientScript.ClientScript))
         {
             modelActionClientScript.Script = modelActionClientScript.ClientScript;
         }
     }
 }
예제 #7
0
        public static IEnumerable <TAction> Actions <TAction>(this Frame frame, IEnumerable <IModelNode> items) where TAction : ActionBase
        {
            var choiceActions = frame.Actions <TAction>().ToArray();

            if (choiceActions.Any())
            {
                return(items.GroupBy(model => model.GetParent <IModelAction>())
                       .Where(nodes => choiceActions.Select(action => action.Id).Any(s => s == nodes.Key.Id))
                       .Select(group => choiceActions.First(action => action.Id == group.Key.Id)).Distinct());
            }
            return(Enumerable.Empty <TAction>());
        }
예제 #8
0
 protected override void OnActivated()
 {
     base.OnActivated();
     if (Enabled)
     {
         Validator.RuleSet.ValidationCompleted += RuleSetOnValidationCompleted;
         _actionBases = Frame.Actions().Where(@base => !new[] { "Save", "Delete", "Validate" }.Contains(@base.Id)).ToArray();
         foreach (var actionBase in _actionBases)
         {
             actionBase.Executing += ActionBaseOnExecuting;
         }
     }
 }
예제 #9
0
        IEnumerable <ActionBase> GetActions(IActionStateRule rule)
        {
            var actionBases = Frame.Actions();

            if (!string.IsNullOrEmpty(rule.Module))
            {
                return(GetModuleActions(rule, actionBases));
            }
            var contextIds = GetActionContextIds(((ActionStateRule)rule).ActionContext);
            var ids = new[] { rule.ActionId }.Concat(contextIds).ToArray();

            return(actionBases.Where(@base => ids.Contains(@base.Id)));
        }
예제 #10
0
        protected override void OnActivated()
        {
            base.OnActivated();
            var modelChoiceActionItems = Application.Model.ActionDesign.Actions.Where(action
                                                                                      => action.ChoiceActionItems != null && action.ChoiceActionItems.Any()).SelectMany(action => action.ChoiceActionItems);
            var items = GetModelChoiceActionItemModifyModels(modelChoiceActionItems);

            _singleChoiceActions = Frame.Actions <SingleChoiceAction>(items).ToList();
            foreach (var singleChoiceAction in _singleChoiceActions)
            {
                singleChoiceAction.Execute += SingleChoiceActionOnExecute;
            }
        }
 protected override void OnFrameAssigned()
 {
     base.OnFrameAssigned();
     ApplyDefaultValue();
     Frame.Disposing += FrameOnDisposing;
     _actions         = Frame.Actions().ToArray();
     foreach (var action in _actions)
     {
         var actionDefaultValueHelper = new ActionDefaultValueHelper(action);
         _defaultValueHelpers.Add(action, actionDefaultValueHelper);
         action.Enabled.ResultValueChanged += actionDefaultValueHelper.ResultValueChanged;
         action.Active.ResultValueChanged  += actionDefaultValueHelper.ResultValueChanged;
     }
 }
예제 #12
0
 protected override void OnFrameAssigned()
 {
     base.OnFrameAssigned();
     Frame.Disposing += FrameOnDisposing;
     _eventHandlers   = new Dictionary <ActionBase, EventHandler <BoolValueChangedEventArgs> >();
     EventHandler <BoolValueChangedEventArgs>[] eventHandlers = { null };
     foreach (var action in Frame.Actions())
     {
         eventHandlers[0] = (sender, args) => { UpdateAvailableList(action); };
         _eventHandlers.Add(action, eventHandlers[0]);
         action.Active.ResultValueChanged  += eventHandlers[0];
         action.Enabled.ResultValueChanged += eventHandlers[0];
         UpdateAvailableList(action);
     }
 }
예제 #13
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            XafCallbackManager callbackManager = ((ICallbackManagerHolder)WebWindow.CurrentRequestPage).CallbackManager;

            callbackManager.RegisterHandler(GetType().FullName, this);
            foreach (var action in Frame.Actions <SimpleAction>())
            {
                var modelActionClientScript = ((IModelActionClientScript)action.Model());
                if (!string.IsNullOrEmpty(modelActionClientScript?.ConfirmationMsg))
                {
                    var clientScript = callbackManager.GetScript(GetType().FullName, "ret +';" + action.Id + "'");
                    modelActionClientScript.Script = "var ret= confirm('" + modelActionClientScript.ConfirmationMsg + "'); " + clientScript;
                }
            }
        }
예제 #14
0
        protected override void OnFrameAssigned()
        {
            base.OnFrameAssigned();
            foreach (var variable in Application.Modules.SelectMany(m => m.GetControllerTypes()))
            {
                Application.TypesInfo.RegisterEntity(variable);
            }

            var modelActionStates = Application.Model.ActionDesign.Actions.Cast <IModelActionState>();

            foreach (var modelActionState in modelActionStates.Where(state => !state.Active))
            {
                var actionBase = Frame.Actions().FirstOrDefault(a => a.Id == modelActionState.Id);
                if (actionBase != null)
                {
                    actionBase.Active.BeginUpdate();
                    actionBase.Active[ModelActiveAttribute] = false;
                    actionBase.Active.EndUpdate();
                }
            }
        }
예제 #15
0
 public static IEnumerable <ActionBase> Actions(this Frame frame)
 {
     return(frame.Actions <ActionBase>());
 }
 protected virtual IEnumerable <ActionBase> GetActions(Frame frame)
 {
     return(frame.Actions());
 }
예제 #17
0
 public static ActionBase Action(this Frame frame, string id)
 => frame.Actions(id).FirstOrDefault();
예제 #18
0
 public static IEnumerable <ActionBase> Actions(this Frame frame, params string[] actiondIds)
 => frame.Actions <ActionBase>(actiondIds);
예제 #19
0
 public static ActionBase ToAction(this IModelAction modelAction, Frame frame)
 {
     return(frame.Actions().First(@base => @base.Model.Id == modelAction.Id));
 }
 IEnumerable <ActionBase> GetActions()
 {
     return(Frame.Actions().Where(@base => @base.Active && @base.Enabled && Frame.Application.Model.ActionDesign.Actions[@base.Id] != null));
 }