示例#1
0
 private void HrList_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "LastSelected")
     {
         // logger.DebugFormat("sel {0}\nlast {1}", HrList.SelectedHealthRecord, HrList.LastSelected);
         if (HrList.LastSelected != null)
         {
             if (editorWasOpened)
             {
                 HrEditor.Load(HrList.LastSelected.healthRecord);
             }
         }
         else if (HrList.preserveSelected.CanEnter)
         {
             editorWasOpened = HrEditor.HasHealthRecord;
             HrEditor.Unload();
         }
     }
     else if (e.PropertyName == "Sorting")
     {
         var doctor = AuthorityController.CurrentDoctor;
         doctor.Settings.HrListSorting = HrList.Sorting.ToString();
     }
     else if (e.PropertyName == "Grouping")
     {
         var doctor = AuthorityController.CurrentDoctor;
         doctor.Settings.HrListGrouping = HrList.Grouping.ToString();
     }
 }
示例#2
0
        /// <summary>
        /// Открывает/закрывает редактор для последней выбранной в списке записи.
        /// </summary>
        public void ToogleHrEditor()
        {
            Contract.Ensures(HrList.LastSelected == null ||
                             HrEditor.HasHealthRecord != Contract.OldValue(HrEditor.HasHealthRecord));

            if (HrList.LastSelected == null)
            {
                return;
            }

            // logger.DebugFormat("toggle hr editor from {0}", HrEditor.HasHealthRecord);
            if (HrEditor.HasHealthRecord)
            {
                // Contract.Assume(HrEditor.HealthRecord.healthRecord == HrList.LastSelected.healthRecord);
                HrEditor.Unload();
            }
            else
            {
                HrEditor.Load(HrList.LastSelected.healthRecord);
            }
        }
示例#3
0
        public CardViewModel(bool resetHistory = false)
        {
            if (IsInDesignMode)
            {
                return;
            }
            if (resetHistory || viewer == null)
            {
                ResetHistory();
            }

            Contract.Assume(AuthorityController.CurrentDoctor != null);

            _navigator = new CardNavigator(viewer);
            _hrEditor  = new HrEditorViewModel(Session);

            Navigator.CurrentChanged += (s, e) =>
            {
                // add to history

                // закрываем редактор при смене активной сущности
                HrEditor.Unload();

                var holder = e.arg != null ? (e.arg as CardItemViewModel).Holder : null;

                ShowHrsList(holder);
                ShowHeader(holder);
            };
            Navigator.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "CurrentTitle")
                {
                    Title = Navigator.CurrentTitle;
                }
            };

            HrEditor.Unloaded += (s, e) =>
            {
                // сохраняем запись
                var hr = e.hr as HealthRecord;
                if (hr.Doctor == AuthorityController.CurrentDoctor)  // добавлять только если врач редактировал свою запись?
                {
                    AuthorityController.CurrentDoctor.AddWords(hr.Words);
                }
                Session.DoSave(hr);
            };
            HrEditor.Closing += (s, e) =>
            {
                // закрыт по команде — переходим к списку записей
                // logger.DebugFormat("hreditor closed, listfocused = {0}", HrList.IsFocused);
                HrList.IsFocused = true;
                // restore selected?
            };

            emh.Add(new EventMessageHandler[] {
                this.Subscribe(Event.DeleteHolder, (e) =>
                {
                    var holder = e.GetValue <IHrsHolder>(MessageKeys.Holder);
                    DeleteHolder(holder);

                    Contract.Assume(HrList == null || HrList.holder != holder);
                }),
                this.Subscribe(Event.EntityDeleted, (e) =>
                {
                    var entity = e.GetValue <IEntity>(MessageKeys.Entity);
                    if (entity is IHrsHolder)
                    {
                        // дожидаемся конца транзации удаления перед тем как менять экран и сохранять врача
                        if (deletingHolder == null)
                        {
                            OnHolderDeleted(entity as IHrsHolder);
                        }
                        else
                        {
                            pendingAction = () => OnHolderDeleted(entity as IHrsHolder);
                        }
                    }
                }),
                this.Subscribe(Event.AddHr, (e) =>
                {
                    var holder    = e.GetValue <IHrsHolder>(MessageKeys.Holder);
                    var startEdit = e.GetValue <bool>(MessageKeys.Boolean);

                    AddHr(holder, startEdit);
                })
            }
                    );
        }