Ejemplo n.º 1
0
        public HeaderViewModel(IHrsHolder holder)
        {
            Contract.Requires(holder != null);
            this.holder = holder;
            HolderVm    = new HolderViewModel(holder);

            if (holder is Patient)
            {
            }
            else if (holder is Course)
            {
                var course = holder as Course;
                course.Patient.CoursesChanged += Patient_CoursesChanged;
                ShowCourses();
            }
            else if (holder is Appointment)
            {
                var app = holder as Appointment;
                app.Course.AppointmentsChanged += Course_AppointmentsChanged;

                ShowApps();
            }

            ((INotifyPropertyChanged)holder).PropertyChanged += Holder_PropertyChanged;
        }
Ejemplo n.º 2
0
        public HrListViewModel(IHrsHolder holder, ISession session, HrViewColumn sorting = HrViewColumn.Ord, HrViewColumn grouping = HrViewColumn.Category)
        {
            Contract.Requires(holder != null);
            Contract.Requires(session != null);
            this.session = session;
            this.holder  = holder;

            HolderVm = new HolderViewModel(holder);

            doNotNotifyLastSelectedChanged = new FlagActionWrapper(() =>
            {
                OnPropertyChanged(() => LastSelected);
                logger.DebugFormat("(bulk) selected in order\n{0}", string.Join("\n", selectedOrder));
            });

            preserveSelected = new FlagActionWrapper <IList <ShortHealthRecordViewModel> >((hrs) =>
            {
                hrs.ForEach(vm => vm.IsSelected = true);
                // fix new selected item appears in listbox after movement hrs from diff categories in grouped by category
                // TODO fix when diff createdAt
                HealthRecords.Except(hrs).ForEach(x => x.IsSelected = false);
            });

            handler = this.Subscribe(Event.NewSession, (e) =>
            {
                var s = e.GetValue <ISession>(MessageKeys.Session);
                ReplaceSession(s);
            });

            hrManager = new HealthRecordManager(holder, OnHrVmPropChanged);
            hrManager.DeletedHealthRecords.CollectionChangedWrapper += DeletedHrsCollectionChanged;
            hrManager.HealthRecords.CollectionChangedWrapper        += HrsCollectionChanged;

            view = (ListCollectionView)CollectionViewSource.GetDefaultView(HealthRecords);

            DropHandler = new DropTargetHandler(this);
            DragHandler = new DragSourceHandler();

            IsDragSourceEnabled = true;
            IsDropTargetEnabled = true;
            IsRectSelectEnabled = true;

            Grouping = grouping;
            Sorting  = sorting;
            SetHrExtra(HealthRecords);
        }
Ejemplo n.º 3
0
        public CardItemViewModel(IHrsHolder holder)
        {
            this.holder = holder;

            HolderVm = new HolderViewModel(holder, true);
            if (holder is Patient)
            {
                var patient   = holder as Patient;
                var courseVMs = patient.GetOrderedCourses()
                                .Reverse()
                                .Select(i => new CardItemViewModel(i.Actual as Course))
                                .ToList();
                foreach (var item in courseVMs)
                {
                    Children.Add(item);
                }
                patient.CoursesChanged += nested_IHrsHolders_Changed;
            }
            else if (holder is Course)
            {
                var course = holder as Course;

                var appVMs = course.GetOrderedAppointments()
                             .Select(app => new CardItemViewModel(app.Actual as Appointment))
                             .ToList();

                foreach (var item in appVMs)
                {
                    Children.Add(item);
                }

                CorrectAppTimeVisibilty();

                course.AppointmentsChanged += nested_IHrsHolders_Changed;
            }

            holder.PropertyChanged += holder_PropertyChanged;
        }