Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="group">CollectionViewGroup or CollectionViewGroup.Name.</param>
        private void SetGroupObject(ShortHealthRecordViewModel vm, object group)
        {
            if (group == null)
            {
                return;
            }
            if (group is CollectionViewGroup)
            {
                group = ((CollectionViewGroup)group).Name;
            }

            switch (Grouping)
            {
            case HrViewColumn.Category:
                // перенос в другую группу меняет категорию
                Contract.Assume(group is HrCategory);
                vm.healthRecord.Category = group as HrCategory;
                break;

            case HrViewColumn.CreatedAt:
            // нет переноса в другую группу
            default:
                break;
            }
        }
Esempio n. 2
0
        private ShortHealthRecordViewModel CreateViewModel(HealthRecord hr)
        {
            hr.PropertyChanged += hr_PropertyChanged;
            var vm = new ShortHealthRecordViewModel(hr);

            vm.PropertyChanged += onHrVmPropChanged;
            return(vm);
        }
Esempio n. 3
0
 private void SimulateLiveshaping(ShortHealthRecordViewModel hrvm)
 {
     using (preserveSelected.Enter(SelectedHealthRecords)) // fix selection after CommitEdit when view grouping
     {
         SetHrExtra(hrvm.ToEnumerable());
         view.EditItem(hrvm);
         view.CommitEdit();
         //  logger.DebugFormat("commit {0}", hrvm);
     }
 }
Esempio n. 4
0
        private void OnHrvmIsSelectedChanged(ShortHealthRecordViewModel hrvm)
        {
            // simulate IsSynchronizedWithCurrentItem for Extended mode
            // SelectedHealthRecord points to last IsSelected without unselect prev
            // select may be by IsSelected (rect), so need to set SelectedHealthRecord
            if (hrvm.IsSelected)
            {
                if (!selectedOrder.Contains(hrvm))
                {
                    selectedOrder.Add(hrvm);
                }
                else
                {
                    logger.DebugFormat("selectedOrder contains {0}", hrvm);
                }

                using (unselectPrev.Join())
                {
                    if (SelectedHealthRecords.Count() > 1)
                    {
                        // dont's notify SelectedChanged to save selection
                        using (doNotNotifySelectedChanged.Join())
                        {
                            SelectedHealthRecord = hrvm;
                        }
                    }
                    else
                    {
                        SelectedHealthRecord = hrvm;
                    }
                }
                //logger.DebugFormat("select {0}", hrvm);
            }
            else if (!inRemoveDup)
            {
                selectedOrder.Remove(hrvm);
                //logger.DebugFormat("unselect {0}", hrvm);

                // Сняли выделение, фокус остался — enter будет открывать этот элемент, а выделен другой. Это ок.
                // Выбранным становится последний.

                if (SelectedHealthRecord == hrvm)
                {
                    using (doNotNotifySelectedChanged.Join())
                    {
                        SelectedHealthRecord = LastSelected;
                    }
                }
            }
            if (doNotNotifyLastSelectedChanged.CanEnter)
            {
                OnPropertyChanged(() => LastSelected);
                //logger.DebugFormat("selected in order\n{0}", string.Join("\n", selectedOrder));
            }
        }
Esempio n. 5
0
        internal object GetGroupObject(ShortHealthRecordViewModel vm)
        {
            switch (Grouping)
            {
            case HrViewColumn.Category:
                return(vm.Category);

            case HrViewColumn.CreatedAt:
                return(vm.GroupingCreatedAt);

            default:
                break;
            }
            return(null);
        }
Esempio n. 6
0
 public void UnselectExcept(ShortHealthRecordViewModel vm)
 {
     UnselectExcept(vm.ToEnumerable());
 }
Esempio n. 7
0
 public DropTargetHandler(ShortHealthRecordViewModel master)
 {
     this.master = master;
 }