protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();

            ViewItem item = View.FindItem("Label");
            SchedulerLabelPropertyEditor editor = item != null ? item as SchedulerLabelPropertyEditor : null;

            if (editor != null && editor.Control != null)
            {
                ISchedulerStorage        storage      = ((AppointmentLabelEdit)editor.Control).Storage;
                IAppointmentLabelStorage labelStorage = storage.Appointments.Labels;
                labelStorage.Clear();
                int i = 0;
                IAppointmentLabel label = labelStorage.CreateNewLabel(i, "Нет", "Нет");
                label.SetColor(Color.White);
                labelStorage.Add(label);
                i++;
                using (IObjectSpace os = Application.CreateObjectSpace())
                {
                    IList <DoctorEventLabel> labels = os.GetObjects <DoctorEventLabel>();
                    foreach (var doctorEventLabel in labels)
                    {
                        label = labelStorage.CreateNewLabel(i, doctorEventLabel.Name, doctorEventLabel.Name);
                        label.SetColor(doctorEventLabel.Color);
                        labelStorage.Add(label);
                        i++;
                    }
                }
            }
        }
Esempio n. 2
0
        static void CustomLabelsAndStatusesAction(SchedulerControl scheduler)
        {
            #region #CustomLabelsAndStatuses
            scheduler.Storage.Appointments.Clear();

            string[] IssueList            = { "Consultation", "Treatment", "X-Ray" };
            Color[]  IssueColorList       = { Color.Ivory, Color.Pink, Color.Plum };
            string[] PaymentStatuses      = { "Paid", "Unpaid" };
            Color[]  PaymentColorStatuses = { Color.Green, Color.Red };


            IAppointmentLabelStorage labelStorage = scheduler.Storage.Appointments.Labels;
            labelStorage.Clear();
            int count = IssueList.Length;
            for (int i = 0; i < count; i++)
            {
                IAppointmentLabel label = labelStorage.CreateNewLabel(i, IssueList[i]);
                label.SetColor(IssueColorList[i]);
                labelStorage.Add(label);
            }
            AppointmentStatusCollection statusColl = scheduler.Storage.Appointments.Statuses;
            statusColl.Clear();
            count = PaymentStatuses.Length;
            for (int i = 0; i < count; i++)
            {
                AppointmentStatus status = statusColl.CreateNewStatus(i, PaymentStatuses[i], PaymentStatuses[i]);
                status.SetBrush(new SolidBrush(PaymentColorStatuses[i]));
                statusColl.Add(status);
            }
            #endregion #CustomLabelsAndStatuses
        }
Esempio n. 3
0
        public AppoitmentSynchronizer(IAppointmentLabelStorage labels, IAppointmentStatusStorage statuses, IModelListViewOptionsScheduler modelListViewOptionsScheduler) : base(null, modelListViewOptionsScheduler)
        {
            var appointmentsModel = modelListViewOptionsScheduler.OptionsScheduler.GetNode("Storage").GetNode("Appointments");

            ModelSynchronizerList.Add(new AppoitmentLabelsSynchronizer(labels, (IModelAppoitmentLabels)appointmentsModel.GetNode("Labels")));
            ModelSynchronizerList.Add(new AppoitmentStatusSynchronizer(statuses, (IModelAppoitmentStatuses)appointmentsModel.GetNode("Statuses")));
        }
Esempio n. 4
0
        static void CustomLabelsAndStatusesAction(SchedulerControl scheduler)
        {
            #region #CustomLabelsAndStatuses
            scheduler.Storage.AppointmentStorage.Clear();

            string[] IssueList            = { "Consultation", "Treatment", "X-Ray" };
            Color[]  IssueColorList       = { Colors.Ivory, Colors.Pink, Colors.Plum };
            string[] PaymentStatuses      = { "Paid", "Unpaid" };
            Color[]  PaymentColorStatuses = { Colors.Green, Colors.Red };


            IAppointmentLabelStorage labelStorage = scheduler.Storage.AppointmentStorage.Labels;
            labelStorage.Clear();
            int count = IssueList.Length;
            for (int i = 0; i < count; i++)
            {
                IAppointmentLabel label = labelStorage.CreateNewLabel(i, IssueList[i]);
                label.SetColor(IssueColorList[i]);
                labelStorage.Add(label);
            }
            IAppointmentStatusStorage statusStorage = scheduler.Storage.AppointmentStorage.Statuses;
            statusStorage.Clear();
            count = PaymentStatuses.Length;
            for (int i = 0; i < count; i++)
            {
                IAppointmentStatus status = statusStorage.CreateNewStatus(i, PaymentStatuses[i], PaymentStatuses[i]);
                status.SetBrush(new SolidColorBrush(PaymentColorStatuses[i]));
                statusStorage.Add(status);
            }

            // Create a new appointment.
            Appointment apt = scheduler.Storage.CreateAppointment(AppointmentType.Normal);
            apt.Subject    = "Test";
            apt.Start      = DateTime.Now;
            apt.End        = DateTime.Now.AddHours(2);
            apt.ResourceId = scheduler.Storage.ResourceStorage[0].Id;
            apt.LabelKey   = labelStorage.GetByIndex(2).Id;
            scheduler.Storage.AppointmentStorage.Add(apt);

            #endregion #CustomLabelsAndStatuses
        }
Esempio n. 5
0
 static void ChangingLabelColorSchemeAction(SchedulerControl scheduler)
 {
     #region #ChangingLabelColorScheme
     IAppointmentLabelStorage labelStorage = scheduler.Storage.Appointments.Labels;
     foreach (IAppointmentLabel label in labelStorage)
     {
         AppointmentLabel appLabel = label as AppointmentLabel;
         if (appLabel != null)
         {
             string skinElemName = AppointmentLabel.GetSkinElementName(appLabel.ColorId);
             Color  skinColor    = DevExpress.Skins.SkinManager.Default.Skins["Office 2016 Colorful"].GetSkin(DevExpress.Skins.SkinProductId.Scheduler).Colors.GetPrimaryColor(skinElemName, Color.Empty);
             if (skinColor == Color.Empty)
             {
                 skinColor = AppointmentLabel.GetDefaultColorByStringId(appLabel.ColorId);
             }
             appLabel.SetColor(skinColor);
         }
         scheduler.ActiveView.LayoutChanged();
     }
     #endregion #ChangingLabelColorScheme
 }
        private void FillLabelStorage(IAppointmentLabelStorage labelStorage)
        {
            labelStorage.Clear();
            int i = 0;

            using (IObjectSpace os = Application.CreateObjectSpace())
            {
                IAppointmentLabel label = labelStorage.CreateNewLabel(i, "Нет", "Нет");
                label.SetColor(Color.White);
                labelStorage.Add(label);
                i++;

                IList <DoctorEventLabel> labels = os.GetObjects <DoctorEventLabel>();
                foreach (var doctorEventLabel in labels)
                {
                    label = labelStorage.CreateNewLabel(i, doctorEventLabel.Name, doctorEventLabel.Name);
                    label.SetColor(doctorEventLabel.Color);
                    labelStorage.Add(label);
                    i++;
                }
            }
        }
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();

            ListView   listView   = View as ListView;
            DetailView detailView = View as DetailView;

            if (listView != null)
            {
                IObjectSpace os = Application.CreateObjectSpace();
                listView.CollectionSource.CriteriaApplied += (o, e) =>
                {
                    // Предварительная загрузка расписаний докторов
                    var collectionSB = (CollectionSourceBase)o;
                    if (collectionSB.Criteria != null)
                    {
                        var events = new List <DoctorEvent>(os.GetObjects <DoctorEvent>(collectionSB.Criteria[FILTERKEY]));
                        eventsDict = events.ToDictionary(de => de.Oid, de => de);
                    }
                };

                SchedulerListEditor listEditor = ((ListView)View).Editor as SchedulerListEditor;
                if (listEditor != null)
                {
                    SchedulerControl scheduler = listEditor.SchedulerControl;
                    if (scheduler != null)
                    {
                        // Кастомизация надписи в расписании доктора
                        scheduler.InitAppointmentDisplayText += (o, e) =>
                        {
                            Guid guid = (Guid)e.Appointment.Id;
                            if (eventsDict.ContainsKey(guid))
                            {
                                var doctorEvent = eventsDict[guid];
                                e.Text = doctorEvent != null && doctorEvent.Pacient != null ? doctorEvent.Pacient.FullName : string.Empty;
                            }
                        };

                        #region Кастомизация Тултипа расписания доктора

                        // https://documentation.devexpress.com/WindowsForms/118551/Controls-and-Libraries/Scheduler/Visual-Elements/Scheduler-Control/Appointment-Flyout
                        scheduler.OptionsView.ToolTipVisibility = ToolTipVisibility.Always;
                        scheduler.OptionsCustomization.AllowDisplayAppointmentFlyout = false;
                        scheduler.ToolTipController             = new ToolTipController();
                        scheduler.ToolTipController.ToolTipType = ToolTipType.SuperTip;
                        scheduler.ToolTipController.BeforeShow += (o, e) =>
                        {
                            var toolTipController           = (ToolTipController)o;
                            AppointmentViewInfo aptViewInfo = null;
                            try
                            {
                                aptViewInfo = (AppointmentViewInfo)toolTipController.ActiveObject;
                            }
                            catch
                            {
                                return;
                            }

                            if (aptViewInfo == null)
                            {
                                return;
                            }

                            Guid guid = (Guid)aptViewInfo.Appointment.Id;
                            if (!eventsDict.ContainsKey(guid))
                            {
                                // В словаре нет ключа т.к. расписание было только что создано
                                var events = new List <DoctorEvent>(ObjectSpace.GetObjects <DoctorEvent>(listView.CollectionSource.Criteria[FILTERKEY]));
                                eventsDict = events.ToDictionary(de => de.Oid, de => de);
                            }
                            DoctorEvent doctorEvent = eventsDict[guid];
                            // Вид талона (метка)
                            AppointmentLabel label = scheduler.Storage.Appointments.Labels.GetById(doctorEvent.Label);
                            StringBuilder    sb    = new StringBuilder();
                            sb.AppendLine(string.Format("Время: с {0:HH:mm} по {1:HH:mm}", doctorEvent.StartOn, doctorEvent.EndOn));
                            sb.AppendLine(string.Format("Пациент: {0}", doctorEvent.Pacient != null ? doctorEvent.Pacient.FullName : null));
                            sb.AppendLine(string.Format("Кем создано: {0}", doctorEvent.CreatedBy != null ? doctorEvent.CreatedBy.FullName : null));
                            sb.AppendLine(string.Format("Кто записал: {0}", doctorEvent.EditedBy != null ? doctorEvent.EditedBy.FullName : null));
                            sb.AppendLine(string.Format("Вид талона: {0}", label.DisplayName));
                            if (doctorEvent.Pacient != null)
                            {
                                sb.AppendLine(string.Format("Источник записи: {0}", CaptionHelper.GetDisplayText(doctorEvent.SourceType)));
                            }

                            SuperToolTip          SuperTip = new SuperToolTip();
                            SuperToolTipSetupArgs args     = new SuperToolTipSetupArgs();
                            args.Contents.Text = sb.ToString();
                            args.Contents.Font = new Font("Times New Roman", 11);
                            SuperTip.Setup(args);
                            e.SuperTip = SuperTip;
                        };

                        #endregion

                        // Кастомизация коллекции меток
                        var storage = scheduler.Storage;
                        IAppointmentLabelStorage labelStorage = storage.Appointments.Labels;
                        FillLabelStorage(labelStorage);

                        #region Кастомизация всплывающего меню на расписании врача
                        DoctorEvent recordedEvent = null;
                        VisitCase   visitCase     = null;

                        // Всплывающее меню на расписании врача
                        scheduler.PopupMenuShowing += (o, e) =>
                        {
                            Pacient pacient = listView.Tag as Pacient;
                            AppointmentBaseCollection appoinments = (o as SchedulerControl).SelectedAppointments;
                            Appointment appoinment = appoinments.Count == 1 ? appoinments[0] : null;
                            if (appoinment == null)
                            {
                                return;
                            }

                            Guid        key    = (Guid)appoinment.Id;
                            DoctorEvent dEvent = appoinment != null && eventsDict.ContainsKey(key) ? eventsDict[key] : null;

                            if (e.Menu.Id != DevExpress.XtraScheduler.SchedulerMenuItemId.AppointmentMenu)
                            {
                                return;
                            }
                            if (pacient != null && dEvent.Pacient == null & recordedEvent == null && dEvent.StartOn > DateTime.Now)
                            {
                                e.Menu.Items.Insert(0, new SchedulerMenuItem("Записать пациента", (o_, e_) =>
                                {
                                    IObjectSpace dEventObjectSpace = XPObjectSpace.FindObjectSpaceByObject(dEvent);
                                    dEvent.Pacient = dEventObjectSpace.GetObject(pacient);
                                    dEventObjectSpace.CommitChanges();
                                    // Обновление списочного представления
                                    listView.CollectionSource.Reload();
                                    // Расписание на которое записан пациент
                                    recordedEvent = dEvent;
                                    // Создание посещения для пациента
                                    visitCase = VisitCase.CreateVisitCase(dEventObjectSpace,
                                                                          dEventObjectSpace.GetObject(pacient),
                                                                          dEvent.AssignedTo, dEvent.StartOn);
                                    dEventObjectSpace.CommitChanges();
                                }));
                            }
                            else if (dEvent != null && dEvent.Pacient != null)
                            {
                                e.Menu.Items.Insert(0, new SchedulerMenuItem("Отменить запись", (o_, e_) =>
                                {
                                    IObjectSpace dEventObjectSpace = XPObjectSpace.FindObjectSpaceByObject(dEvent);
                                    dEvent.Pacient = null;
                                    dEventObjectSpace.CommitChanges();
                                    // Обновление списочного представления
                                    listView.CollectionSource.Reload();
                                    // Отмена записи пациента на выбранное расписание
                                    if (recordedEvent != null && recordedEvent.Oid == dEvent.Oid)
                                    {
                                        recordedEvent = null;
                                    }
                                    if (visitCase != null)
                                    {
                                        dEventObjectSpace.Delete(visitCase);
                                        dEventObjectSpace.CommitChanges();
                                    }
                                }));
                            }
                        };

                        #endregion

                        // Кастомизация цвета фона расписания:
                        // Если выбранный пациент уже записан, то цвет расписания окрашивается в светло-розовый.
                        // Если в расписании записан другой пациент, то цвет расписания окрашивается в морковный.
                        scheduler.AppointmentViewInfoCustomizing += (o_, e_) =>
                        {
                            Pacient pacient = listView.Tag as Pacient;
                            if (pacient != null)
                            {
                                Guid guid = (Guid)e_.ViewInfo.Appointment.Id;
                                if (eventsDict.ContainsKey(guid) && eventsDict[guid].Pacient != null)
                                {
                                    e_.ViewInfo.Appearance.BackColor = eventsDict[guid].Pacient.Oid == pacient.Oid ?
                                                                       Color.FromArgb(255, 192, 192) : Color.FromArgb(255, 128, 0);
                                }
                            }
                        };
                    }
                }
            }
            else if (detailView != null)
            {
                // Кастомизация коллекции меток
                foreach (SchedulerLabelPropertyEditor pe in ((DetailView)View).GetItems <SchedulerLabelPropertyEditor>())
                {
                    if (pe.Control != null)
                    {
                        ISchedulerStorage        storage      = ((AppointmentLabelEdit)pe.Control).Storage;
                        IAppointmentLabelStorage labelStorage = storage.Appointments.Labels;
                        FillLabelStorage(labelStorage);
                    }
                }
            }
        }
Esempio n. 8
0
        public SchedulerListEditorModelSynchronizer(IInnerSchedulerControlOwner control, IModelListViewOptionsScheduler model, IAppointmentLabelStorage labels, IAppointmentStatusStorage statuses)
            : base(control, model)
        {
            ModelSynchronizerList.Add(new SchedulerControlSynchronizer(control, model));

            var appoitmentSynchronizer = new AppoitmentSynchronizer(labels, statuses, model);

            ModelSynchronizerList.Add(appoitmentSynchronizer);
        }