Пример #1
0
        protected override async void SetActionCommandsAsync()
        {
            if (this.CanEdit)
            {
                if (this._CurrentEnumStep == EnumSteps.Start)
                {
                    this.ActionCommands = new ObservableCollection<ActionCommand>
                    {
                        new ActionCommand { Parameter = EnumSteps.Add.ToString(), Command = new Add() },
                    };
                }
                else if (this._CurrentEnumStep == EnumSteps.SelectGroup)
                {
                    if (this.SelectedGroup == null || this.SelectedGroup.IsNewGroup)
                    {
                        this.ActionCommands = new ObservableCollection<ActionCommand>
                        {
                            new ActionCommand { Parameter = EnumSteps.Add.ToString(), Command = new Add() },
                        };
                    }
                    else
                    {
                        this.ActionCommands = new ObservableCollection<ActionCommand>
                        {
                            new ActionCommand { Parameter = EnumSteps.Add.ToString(), Command = new Add() },
                            new ActionCommand { Parameter = EnumSteps.Edit.ToString(), Command = new Edit() },
                            new ActionCommand { Parameter = EnumSteps.Copy.ToString(), Command = new Copy() },
                        };
                    }
                }
                if (this.Edit.IsCheckedOut)
                {
                    if (CurrentStep != EnumSteps.PermissionsState)
                    {

                        ActionCommand cmd = this.Edit.ActionCommands.FirstOrDefault(d => d.Parameter == EditGroupViewModel.EnumSteps.ResetPermissions.ToString());
                        this.Edit.ActionCommands.Remove(cmd);
                    }
                    else
                    {
                        ActionCommand cmd = this.Edit.ActionCommands.FirstOrDefault(d => d.Parameter == EditGroupViewModel.EnumSteps.ResetPermissions.ToString());
                        ActionCommand cmdError = this.Edit.ActionCommands.FirstOrDefault(d => d.Parameter == EditGroupViewModel.EnumSteps.Error.ToString());
                        ActionCommand cmd1 = new ActionCommand { Parameter = EditGroupViewModel.EnumSteps.ResetPermissions.ToString(), Command = new ResetPermissions() };
                        if (cmd == null)
                        {
                            int position = this.Edit.ActionCommands.IndexOf(cmdError);
                            if (position != -1)
                            {
                                this.Edit.ActionCommands.Insert(position, cmd1);
                            }
                            else
                            {
                                this.Edit.ActionCommands.Add(cmd1);
                            }
                        }
                    }
                }
            }
        }
        protected override async void SetActionCommandsAsync()
        {
            if (this._CurrentEnumStep == EnumSteps.Start)
            {
                AssignmentToolbar assignmentFilter = new AssignmentToolbar();
                assignmentFilter.DataContext = this.ActiveViewModel;
                assignmentFilter.SetSelectedItem = ItemsAssignmentFilter.FirstOrDefault(d => d.Id == (int)EnumQueueFilter.None);
                _currentAssignmentFilterCommand = new ActionCommand
                {
                    Parameter = EnumSteps.AssignmentFilter.ToString(),
                    Command = assignmentFilter,
                    CommandType = ActionCommadType.Custom
                };
                this.ActionCommands = new ObservableCollection<ActionCommand>
                {
                    new ActionCommand { Parameter = EnumSteps.Refresh.ToString(), Command = new Refresh() },
                    _currentAssignmentFilterCommand
                };
            }
            else
            {
                if (this.CanEdit)
                {
                    //var permission = Security.Authorisation.GetPermission(Components.Collections, Forms.CollectionsQueueAssignment);
                    switch (this._CurrentEnumStep)
                    {
                        case EnumSteps.SelectQueue:
                            this.ActionCommands = new ObservableCollection<ActionCommand>
                            {
                                new ActionCommand { Parameter = EnumSteps.Edit.ToString(), Command = new Edit()},
                                new ActionCommand { Parameter = EnumSteps.Previous.ToString(), Command = new Previous()},
                                new ActionCommand { Parameter = EnumSteps.Next.ToString(), Command = new Next() }
                            };

                            int index = this.FilteredItems.IndexOf(this.SelectedQueue);

                            // Hidden Previous command when selected Item is the first item.
                            if (index == 0)
                            {
                                var previous = this.ActionCommands.Where(item => string.Equals(item.Parameter, EnumSteps.Previous.ToString())).Select(item => item).FirstOrDefault();
                                if (previous != null)
                                {
                                    this.ActionCommands.Remove(previous);
                                }
                            }

                            // Hidden Next command when selected Item is the last item.
                            if (index == this.FilteredItems.Count - 1)
                            {
                                var next = this.ActionCommands.Where(item => string.Equals(item.Parameter, EnumSteps.Next.ToString())).Select(item => item).FirstOrDefault();
                                if (next != null)
                                {
                                    this.ActionCommands.Remove(next);
                                }
                            }

                            break;
                    }
                }
                else
                {
                    switch (this._CurrentEnumStep)
                    {
                        case EnumSteps.SelectQueue:
                            this.ActionCommands = new ObservableCollection<ActionCommand>();
                            break;
                    }
                }
            }
        }