示例#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);
            });
        }
 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");
        }