示例#1
0
        public void RegisterRunSeatDispatcher(FrameworkElement el, Grid container, int rowPosition)
        {
            _buildSeatDispatcher = new Action <Reflector>(model =>
            {
                container.RowDefinitions[rowPosition].Height = new GridLength(_seatDispatcherHeight);
                View.SetModel(el, model.Target);

                model.SetProperty <System.Func <bool, Luna.Infrastructure.Domain.ISimpleEmployee, bool> >("TrySubmitChanged", (test, employee) =>
                {
                    if (test == false && IsDirty == false)
                    {
                        SubmitSeatChanges(new[] { _attendances.FirstOrDefault(o => o.Profile.Equals(employee)) }, false);
                    }
                    return(!IsDirty);  // IsDirty means can't call UpdateSchedule
                });
                model.SetProperty <Action <int> >("OccupationsChanged", (i) =>
                {
                    var index = i == -1 ? BindableAgents.IndexOf(SelectedAgent) : i;
                    AgentOccupations[index] = BindableAgents[index].SaftyGetProperty <IEnumerable, IWorkingAgent>(o => o.Occupations);
                    this.QuietlyReload(ref _agentOccupations, "AgentOccupations");
                });
                model.SetProperty <Action <IList <IEnumerable> > >("OccupationsReloaded", (list) =>
                {
                    AgentOccupations = (from IWorkingAgent a in BindableAgents where a.Occupations != null select(IEnumerable) a.Occupations).ToList();
                });
                _seatDispatcherPresenter = model;
            });
            _destroySeatDispatcher = new Action(() =>
            {
                _seatDispatcherHeight = container.RowDefinitions[rowPosition].ActualHeight;

                View.SetModel(el, null);
                container.RowDefinitions[rowPosition].Height = new GridLength(0);
            });
        }
示例#2
0
        public void ReloadAgents(IList affectedAgents, Exception ex)
        {
            var agents = (affectedAgents == null || affectedAgents.Count == 0) ? BindableAgents.ToList() : affectedAgents;
            var list   = ReAssignAgents(agents);

            QuietlyReloadAgents(list);
        }
 private Action RetainCurrentSelectedAgent()
 {
     if (BindableAgents != null && SelectedAgent != null)
     {
         var selectedIndex = BindableAgents.IndexOf(SelectedAgent);
         return(() => { SelectedAgent = selectedIndex == -1 ? null : _bindableAgents[selectedIndex] as IAgent; });
     }
     return(() => { });
 }
        public void NavigateTo(object item)
        {
            var result = default(IAgent);

            foreach (IAgent agent in BindableAgents)
            {
                if (agent.Profile.Equals(item))
                {
                    result = agent;
                    break;
                }
            }

            var index = BindableAgents.IndexOf(result);

            if (index == -1)
            {
                return;
            }
            CurrentIndex  = index;
            SelectedAgent = BindableAgents[CurrentIndex] as IAgent;
            this.NotifyOfPropertyChange("CurrentIndex");
        }
示例#5
0
 public IEnumerable GetSelectedAgent(bool?filterWithIsSelected)
 {
     if (filterWithIsSelected == true)
     {
         return(BindableAgents.Cast <ISelectable>().Where(x => x.IsSelected == true));
     }
     else
     {
         var list = SelectedAgent == null ? new IAgent[0] : new[] { SelectedAgent };
         if (filterWithIsSelected == false)
         {
             return(list);
         }
         else
         {
             var selectedItems = list.Union(BindableAgents.Cast <IAgent>().Where(x => ((ISelectable)x).IsSelected == true && !ReferenceEquals(x, SelectedAgent))).ToList();
             if (selectedItems.Count > 0)
             {
                 return(selectedItems);
             }
             return(list);
         }
     }
 }