Exemplo n.º 1
0
        private void Scheduler_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e)
        {
            AppointmentViewInfo aptViewInfo = e.ObjectInfo as AppointmentViewInfo;

            if (aptViewInfo == null)
            {
                return;
            }

            if (EventList.CurrentEvent == null)
            {
                return;
            }

            if ((Guid)aptViewInfo.Appointment.CustomFields["event_id"] == EventList.CurrentEvent.EventId)
            {
                Rectangle r  = e.Bounds;
                Brush     br = e.Cache.GetSolidBrush(Color.LightPink);
                using (Region rgn = new Region(Utils.CreateRoundedRectPath(r, 5)))
                {
                    e.Graphics.FillRegion(br, rgn);
                }
                r.Inflate(-5, -5);
                br = e.Cache.GetSolidBrush(aptViewInfo.Appearance.BackColor);
                using (Region rgn = new Region(Utils.CreateRoundedRectPath(r, 5)))
                {
                    e.Graphics.FillRegion(br, rgn);
                }
            }
            else
            {
                e.DrawDefault();
            }
            e.Handled = true;
        }
Exemplo n.º 2
0
        void scheduler_AppointmentViewInfoCustomizing(object sender, DevExpress.Xpf.Scheduler.AppointmentViewInfoCustomizingEventArgs e)
        {
            AppointmentViewInfo viewInfo = e.ViewInfo;

            if (chkCustomText.IsChecked.GetValueOrDefault())
            {
                UpdateText(viewInfo);
            }
            CustomAppointmentData data = new CustomAppointmentData();

            data.Filtered           = false;
            data.ShowImages         = chkCustomImage.IsChecked.GetValueOrDefault();
            viewInfo.CustomViewInfo = data;

            if (!IsEmptyFilter(cbSearch.Text))
            {
                string searchText = cbSearch.Text.ToUpper();
                if (IsAppointmentFiltered(searchText, e.ViewInfo.Appointment))
                {
                    data.Filtered = true;
                }
            }

            if (!data.Filtered)
            {
                IAppointmentLabel label = this.scheduler.Storage.AppointmentStorage.Labels.CreateNewLabel(string.Empty);
                label.SetColor(Colors.LightGray);
                viewInfo.Label = label;
                IAppointmentStatus status = this.scheduler.Storage.AppointmentStorage.Statuses.CreateNewStatus(string.Empty, string.Empty);
                status.Type = AppointmentStatusType.Custom;
                status.SetBrush(new SolidColorBrush(Colors.LightGray));
                viewInfo.Status = status;
            }
        }
Exemplo n.º 3
0
        private void toolTipController1_BeforeShow(object sender, DevExpress.Utils.ToolTipControllerShowEventArgs e)
        {
            // Get the ToolTipController.
            ToolTipController controller = sender as ToolTipController;

            // Check, if it's an appointment or not.
            // If it's not an appointment, then exit.
            AppointmentViewInfo aptViewInfo = controller.ActiveObject as AppointmentViewInfo;

            if (aptViewInfo == null)
            {
                return;
            }

            // Set a custom icon for a tooltip.
            e.IconType = ToolTipIconType.Information;

            // Set a custom title for a tooltip.
            e.Title = aptViewInfo.Appointment.Description;

            // Set a custom text for a tooltip.
            e.ToolTip = aptViewInfo.Appointment.Subject + " (" + aptViewInfo.Appointment.Location + ")"
                        + Environment.NewLine +
                        aptViewInfo.Appointment.Start.ToShortTimeString() + " - " + aptViewInfo.Appointment.End.ToShortTimeString();
        }
        void schedulerControl1_CustomDrawAppointment(object sender, CustomDrawObjectEventArgs e)
        {
            SchedulerControl scheduler = (SchedulerControl)sender;

            if (scheduler.ActiveViewType == SchedulerViewType.Day)
            {
                AppointmentViewInfo aptViewInfo = (AppointmentViewInfo)e.ObjectInfo;
                if (aptViewInfo.Selected)
                {
                    Appointment apt                       = aptViewInfo.Appointment;
                    SolidBrush  brush                     = new SolidBrush((drag ? Color.FromArgb(32, 0, 0, 0) : Color.FromArgb(16, 0, 0, 0)));
                    TimeSpan    timeScale                 = scheduler.DayView.TimeScale;
                    DateTime    safeIntervalStart         = (DateTime)apt.CustomFields["SafeIntervalStartCF"];
                    DateTime    safeIntervalEnd           = (DateTime)apt.CustomFields["SafeIntervalEndCF"];
                    int         cellsCount                = (int)((safeIntervalEnd - safeIntervalStart).Ticks / timeScale.Ticks);
                    SchedulerViewCellBaseCollection cells = scheduler.DayView.ViewInfo.CellContainers[0].Cells;
                    Rectangle        topBounds            = Rectangle.Empty;
                    Rectangle        bottomBounds         = Rectangle.Empty;
                    List <Rectangle> secondaryBounds      = new List <Rectangle>();
                    Rectangle        generalBounds        = Rectangle.Empty;
                    InitializeBoundsInfo(safeIntervalStart, safeIntervalEnd, cells, ref topBounds, ref bottomBounds, secondaryBounds, ref generalBounds, aptViewInfo.Bounds);
                    Draw(e, brush, ref topBounds, ref bottomBounds, secondaryBounds, ref generalBounds);
                }
            }
        }
 private void schedulerControl1_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         SchedulerViewInfoBase viewInfo = schedulerControl1.ActiveView.ViewInfo;
         SchedulerHitInfo      hitInfo  = viewInfo.CalcHitInfo(e.Location, false);
         if (hitInfo.HitTest == SchedulerHitTest.AppointmentContent)
         {
             AppointmentViewInfo info = (AppointmentViewInfo)hitInfo.ViewInfo;
             foreach (ViewInfoItem item in info.Items)
             {
                 ViewInfoImageItem imageItemInfo = item as ViewInfoImageItem;
                 if (imageItemInfo == null)
                 {
                     continue;
                 }
                 Rectangle itemBounds = info.ConvertToVisualBounds(item.Bounds);
                 if (itemBounds.Contains(e.Location))
                 {
                     MyMessageBox mb = new MyMessageBox(((ViewInfoImageItem)item).Image, "Got it!");
                     mb.ShowDialog();
                 }
             }
         }
     }
 }
        private void toolTipController1_BeforeShow(object sender, ToolTipControllerShowEventArgs e)
        {
            ToolTipController   controller  = sender as ToolTipController;
            AppointmentViewInfo aptViewInfo = controller.ActiveObject as AppointmentViewInfo;

            if (aptViewInfo == null)
            {
                return;
            }

            if (toolTipController1.ToolTipType == ToolTipType.Standard)
            {
                e.IconType = ToolTipIconType.Information;
                e.ToolTip  = aptViewInfo.Description;
            }

            if (toolTipController1.ToolTipType == ToolTipType.SuperTip)
            {
                SuperToolTip          SuperTip = new SuperToolTip();
                SuperToolTipSetupArgs args     = new SuperToolTipSetupArgs();
                args.Title.Text    = "Info";
                args.Title.Font    = new Font("Times New Roman", 14);
                args.Contents.Text = aptViewInfo.Description;
                //args.Contents.Image = resImage;
                args.ShowFooterSeparator = true;
                args.Footer.Font         = new Font("Comic Sans MS", 8);
                args.Footer.Text         = "SuperTip";
                SuperTip.Setup(args);
                e.SuperTip = SuperTip;
            }
        }
Exemplo n.º 7
0
        private void dayViewTimeCells1_CustomDrawAppointment(object sender, CustomDrawObjectEventArgs e)
        {
            AppointmentViewInfo vi = (AppointmentViewInfo)e.ObjectInfo;
            // The DevExpress.XtraScheduler.Native.RectUtils is a helper object for managing rectangles.
            Rectangle imgRect = DevExpress.XtraScheduler.Native.RectUtils.CutFromLeft(vi.InnerBounds, vi.InnerBounds.Width - 18);

            imgRect = DevExpress.XtraScheduler.Native.RectUtils.AlignRectangle(new Rectangle(0, 0, 16, 16), imgRect, ContentAlignment.MiddleCenter);
            // carUsageImages is a collecion of images (DevExpress.Utils.ImageCollection) created from application resources.
            e.Cache.Paint.DrawImage(e.Graphics, carUsageImages.Images[Convert.ToInt32(vi.Appointment.StatusKey)], imgRect);
            Rectangle textRect = DevExpress.XtraScheduler.Native.RectUtils.CutFromRight(vi.InnerBounds, 18);

            using (StringFormat sf = new StringFormat())
            {
                Brush brush     = e.Cache.GetSolidBrush(vi.Appearance.ForeColor);
                Font  fntBold   = e.Cache.GetFont(vi.Appearance.Font, FontStyle.Bold);
                Font  fntItalic = e.Cache.GetFont(vi.Appearance.Font, FontStyle.Italic);
                if (vi.Appointment.LongerThanADay)
                {
                    Rectangle[] rowRects = DevExpress.XtraScheduler.Native.RectUtils.SplitHorizontally(textRect, 2);
                    string      hours    = String.Format(" [{0:F2} h]", vi.AppointmentInterval.Duration.TotalHours);
                    e.Cache.DrawString(vi.DisplayText + hours, fntBold, brush, textRect, sf);
                }
                else
                {
                    Rectangle[] rects = DevExpress.XtraScheduler.Native.RectUtils.SplitVertically(textRect, 3);
                    e.Cache.DrawString(vi.Interval.Start.ToShortTimeString() + " " +
                                       vi.Interval.End.ToShortTimeString(), vi.Appearance.Font, brush, rects[0], sf);
                    e.Cache.DrawString(String.Format("{0}", vi.Appointment.Subject), fntBold, brush, rects[1], sf);
                    e.Cache.DrawString(vi.Description, fntItalic, brush, rects[2], sf);
                }
            }
            e.Handled = true;
        }
Exemplo n.º 8
0
        private void ToolTipController_BeforeShow(object sender, ToolTipControllerShowEventArgs e)
        {
            ToolTipController   controller  = sender as ToolTipController;
            AppointmentViewInfo aptViewInfo = controller.ActiveObject as AppointmentViewInfo;

            if (aptViewInfo == null)
            {
                return;
            }

            if (toolTipController.ToolTipType == ToolTipType.SuperTip)
            {
                var selectedObject = e.SelectedObject as TimeLineAppointmentViewInfo;
                var appointment    = selectedObject.Appointment;

                SuperToolTip          SuperTip = new SuperToolTip();
                SuperToolTipSetupArgs args     = new SuperToolTipSetupArgs();
                var font = new Font("Tahoma", 10);
                args.Title.Text          = appointment.Start.ToString("g") + " - " + appointment.End.ToString("g");
                args.Title.Font          = font;
                args.Contents.Text       = aptViewInfo.DisplayText + Environment.NewLine + aptViewInfo.Description + Environment.NewLine + "Кол-во:" + appointment.CustomFields["PassengersCount"]?.ToString();
                args.Contents.Font       = font;
                args.Contents.Image      = Properties.Resources.info_32x32;
                args.ShowFooterSeparator = true;
                args.Footer.Font         = font;
                args.Footer.Text         = appointment.CustomFields["TripTypeName"]?.ToString();
                SuperTip.Setup(args);
                e.SuperTip = SuperTip;
            }
        }
Exemplo n.º 9
0
        public void BindView(View view, ItemViewInfo viewInfo, ItemViewModel viewModel)
        {
            CustomAppointmentView appointmentView     = (CustomAppointmentView)view;
            AppointmentViewInfo   appointmentViewInfo = (AppointmentViewInfo)viewInfo;

            appointmentView.SetBackgroundColor(new Color(viewInfo.BackColor));
            appointmentView.SubjectView.Text     = appointmentViewInfo.TextElementInfo.Text;
            appointmentView.SubjectView.Typeface = appointmentViewInfo.TextElementInfo.Typeface;
            appointmentView.SubjectView.SetTextSize(ComplexUnitType.Px, appointmentViewInfo.TextElementInfo.TextSize);
            appointmentView.SubjectView.SetTextColor(new Color(appointmentViewInfo.TextElementInfo.TextColor));
        }
Exemplo n.º 10
0
        void UpdateText(AppointmentViewInfo viewInfo)
        {
            Appointment appointment = viewInfo.Appointment;
            string      description = viewInfo.Description;

            if (appointment.IsRecurring)
            {
                description = String.Format("{0}\r\nOccurs on {1}", description, RecurrenceInfo.GetDescription(appointment, DateTimeHelper.ConvertFirstDayOfWeek(scheduler.OptionsView.FirstDayOfWeek)));
            }
            viewInfo.Description = description;
            viewInfo.Location    = (String.IsNullOrEmpty(viewInfo.Appointment.Location)) ? String.Empty : String.Format("- [{0}]", viewInfo.Appointment.Location);
        }
Exemplo n.º 11
0
        private void dayViewTimeCells1_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e)
        {
            e.DrawDefault();
            AppointmentViewInfo vi   = (AppointmentViewInfo)e.ObjectInfo;
            Rectangle           rect = vi.Bounds;

            rect.Inflate(-vi.LeftBorderBounds.Width, -vi.TopBorderBounds.Height);
            Brush brush = e.Cache.GetGradientBrush(rect, Color.White, vi.Appearance.BackColor,
                                                   System.Drawing.Drawing2D.LinearGradientMode.Vertical);

            e.Cache.FillRectangle(brush, rect);
            e.Handled = true;
        }
        private void OnDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e)
        {
            AppointmentViewInfo viewInfo = e.ObjectInfo as AppointmentViewInfo;

            if (viewInfo != null)
            {
                Color color = Color.Black;
                try {
                    switch ((Model.Appointment.ItemCode)viewInfo.Appointment.CustomFields["ItemType"])
                    {
                    case Model.Appointment.ItemCode.Appointment:
                        color = Color.FromArgb(0xF7, 0xB4, 0x7F);
                        break;

                    case Model.Appointment.ItemCode.Meeting:
                        color = Color.FromArgb(0xB3, 0xD4, 0x97);
                        break;

                    case Model.Appointment.ItemCode.Event:
                        color = Color.FromArgb(0x8B, 0x9E, 0xBF);
                        break;

                    case Model.Appointment.ItemCode.Task:
                        color = Color.FromArgb(0xD7, 0xE2, 0xF3);
                        break;

                    case Model.Appointment.ItemCode.Project:
                        color = Color.FromArgb(0xBE, 0x86, 0xA1);
                        break;

                    default:
                        return;
                    }
                } catch {
                    color = Color.FromArgb(0xF7, 0xB4, 0x7F);
                }

                Rectangle r = e.Bounds;

                if (viewInfo.Selected)
                {
                    e.DrawDefault();
                    r.Inflate(-2, -2);
                }

                Brush br = e.Cache.GetSolidBrush(color);
                e.Graphics.FillRectangle(br, r);

                e.Handled = true;
            }
        }
Exemplo n.º 13
0
        public static void scheduler_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e)
        {
            AppointmentViewInfo viewInfo = e.ObjectInfo as AppointmentViewInfo;
            // Specify the ratio of a completed task to the entire task.
            double completenessRatio = 0.25 * ((int)(viewInfo.Appointment.ResourceId) % 4);

            // Draw an appointment as usual.
            e.DrawDefault();
            // Draw a background rectangle.
            Rectangle bounds = CalculateEntireAppointmentBounds(viewInfo);

            DrawBackGroundCore(e.Cache, bounds, completenessRatio);
            // Indicate that no default drawing is required.
            e.Handled = true;
        }
Exemplo n.º 14
0
        private void toolTipController_BeforeShow(object sender, DevExpress.Utils.ToolTipControllerShowEventArgs e)
        {
            ToolTipController controller = sender as ToolTipController;


            AppointmentViewInfo aptViewInfo = controller.ActiveObject as AppointmentViewInfo;

            if (aptViewInfo == null)
            {
                return;
            }

            e.Title   = aptViewInfo.Appointment.Subject;
            e.ToolTip = string.Format("{0}", aptViewInfo.Appointment.Description);
        }
        private void schedulerControl1_CustomDrawAppointment(object sender, DevExpress.XtraScheduler.CustomDrawObjectEventArgs e)
        {
            if (((SchedulerControl)sender).ActiveView is DayView)
            {
                AppointmentViewInfo viewInfo = e.ObjectInfo as AppointmentViewInfo;
                // Get DevExpress images.
                //Image im = DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/add_16x16.png");

                //Rectangle imageBounds = new Rectangle(viewInfo.InnerBounds.X, viewInfo.InnerBounds.Y, im.Width, im.Height);
                //Rectangle mainContentBounds = new Rectangle(viewInfo.InnerBounds.X, viewInfo.InnerBounds.Y + im.Width + 1,
                //viewInfo.InnerBounds.Width, viewInfo.InnerBounds.Height - im.Height - 1);
                //// Draw image in the appointment.
                //e.Cache.Graphics.DrawImage(im, imageBounds);
            }
        }
Exemplo n.º 16
0
        public static void scheduler_CustomDrawAppointment(object sender, CustomDrawObjectEventArgs e)
        {
            if (((SchedulerControl)sender).ActiveView is DayView)
            {
                AppointmentViewInfo viewInfo = e.ObjectInfo as AppointmentViewInfo;
                // Get DevExpress images.
                Image     im                = DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/add_16x16.png");
                Rectangle imageBounds       = new Rectangle(viewInfo.InnerBounds.X, viewInfo.InnerBounds.Y, im.Width, im.Height);
                Rectangle mainContentBounds = new Rectangle(viewInfo.InnerBounds.X, viewInfo.InnerBounds.Y + im.Width + 1,
                                                            viewInfo.InnerBounds.Width, viewInfo.InnerBounds.Height - im.Height - 1);
                // Draw image in the appointment.
                e.Cache.DrawImage(im, imageBounds);

                int statusDelta = 0;
                for (int i = 0; i < viewInfo.StatusItems.Count; i++)
                {
                    AppointmentViewInfoStatusItem statusItem = viewInfo.StatusItems[i] as AppointmentViewInfoStatusItem;
                    // Fill the status bar.
                    e.Cache.FillRectangle(statusItem.BackgroundViewInfo.Brush, statusItem.BackgroundViewInfo.Bounds);
                    e.Cache.FillRectangle(statusItem.ForegroundViewInfo.Brush, statusItem.ForegroundViewInfo.Bounds);
                    // Draw the status bar rectangle.
                    using (var _pen = new Pen(statusItem.ForegroundViewInfo.BorderColor)) {
                        e.Cache.DrawRectangle(_pen, statusItem.BackgroundViewInfo.Bounds);
                        e.Cache.DrawRectangle(_pen, statusItem.ForegroundViewInfo.Bounds);
                    }
                    statusDelta = Math.Max(statusDelta, statusItem.Bounds.Width);
                }
                // Draw the appointment caption text.
                e.Cache.DrawString(viewInfo.DisplayText.Trim(), viewInfo.Appearance.Font,
                                   viewInfo.Appearance.GetForeBrush(e.Cache), mainContentBounds, StringFormat.GenericDefault);
                SizeF subjSize      = e.Graphics.MeasureString(viewInfo.DisplayText.Trim(), viewInfo.Appearance.Font, mainContentBounds.Width);
                int   lineYposition = (int)subjSize.Height;

                Rectangle descriptionLocation = new Rectangle(mainContentBounds.X, mainContentBounds.Y + lineYposition,
                                                              mainContentBounds.Width, mainContentBounds.Height - lineYposition);
                if (viewInfo.Appointment.Description.Trim() != "")
                {
                    // Draw the line above the appointment description.
                    e.Cache.DrawLine(viewInfo.Appearance.GetForePen(e.Cache), descriptionLocation.Location,
                                     new Point(descriptionLocation.X + descriptionLocation.Width, descriptionLocation.Y));
                    // Draw the appointment description text.
                    e.Cache.DrawString(viewInfo.Appointment.Description.Trim(), viewInfo.Appearance.Font,
                                       viewInfo.Appearance.GetForeBrush(e.Cache), descriptionLocation, StringFormat.GenericTypographic);
                }
                e.Handled = true;
            }
        }
        public static void scheduler_CustomDrawAppointmentBackground_3(object sender, CustomDrawObjectEventArgs e)
        {
            AppointmentViewInfo aptViewInfo = e.ObjectInfo as AppointmentViewInfo;

            if (aptViewInfo == null)
            {
                return;
            }
            if (aptViewInfo.Selected)
            {
                e.DrawDefault();
                Rectangle r      = e.Bounds;
                Brush     brRect = aptViewInfo.Status.GetBrush();
                e.Graphics.DrawRectangle(new Pen(Color.Lime, 4), r);
                e.Handled = true;
            }
        }
Exemplo n.º 18
0
        private void schedulerControl1_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e)
        {
            AppointmentViewInfo aptViewInfo = e.ObjectInfo as AppointmentViewInfo;

            if (aptViewInfo == null)
            {
                return;
            }
            if (aptViewInfo.Selected)
            {
                Rectangle r      = e.Bounds;
                Brush     brRect = aptViewInfo.Status.GetBrush();
                e.Cache.FillRectangle(brRect, r);
                e.Cache.DrawRectangle(Pens.Blue, r);
                e.Handled = true;
            }
        }
Exemplo n.º 19
0
        public static void scheduler_CustomDrawAppointmentBackground_1(object sender, CustomDrawObjectEventArgs e)
        {
            AppointmentViewInfo aptViewInfo = e.ObjectInfo as AppointmentViewInfo;

            if (aptViewInfo == null)
            {
                return;
            }
            if (aptViewInfo.Selected)
            {
                e.DrawDefault();
                Rectangle r = e.Bounds;
                using (var _pen = new Pen(Color.Lime, 4))
                    e.Cache.DrawRectangle(_pen, r);
                e.Handled = true;
            }
        }
Exemplo n.º 20
0
        private void schedulerControl1_AppointmentViewInfoCustomizing(object sender, AppointmentViewInfoCustomizingEventArgs e)
        {
            try
            {
                AppointmentViewInfo aptViewInfo = e.ViewInfo;
                Appointment         apt         = aptViewInfo.Appointment;

                Assignment ass = apt.GetSourceObject(schedulerStorage1) as Assignment;

                if (ass.Booking.ColorBookings)
                {
                    aptViewInfo.Appearance.BackColor = Color.FromArgb(ass.Booking.Color);
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 21
0
        Rectangle CalculateEntireAppointmentBounds(AppointmentViewInfo viewInfo)
        {
            int    leftOffset  = 0;
            int    rightOffset = 0;
            double scale       = viewInfo.Bounds.Width / viewInfo.Interval.Duration.TotalMilliseconds;

            if (!viewInfo.HasLeftBorder)
            {
                double hidden = (viewInfo.Interval.Start - viewInfo.AppointmentInterval.Start).TotalMilliseconds;
                leftOffset = (int)(hidden * scale);
            }
            if (!viewInfo.HasRightBorder)
            {
                double hidden = (viewInfo.AppointmentInterval.End - viewInfo.Interval.End).TotalMilliseconds;
                rightOffset = (int)(hidden * scale);
            }
            Rectangle bounds = viewInfo.Bounds;

            return(Rectangle.FromLTRB(bounds.Left - leftOffset, bounds.Y, bounds.Right + rightOffset, bounds.Bottom));
        }
Exemplo n.º 22
0
        private void schedulerControl1_AppointmentViewInfoCustomizing(object sender,
                                                                      AppointmentViewInfoCustomizingEventArgs e)
        {
            AppointmentViewInfo viewInfo = e.ViewInfo;
            Resource            resource = schedulerControl1.Storage.ResourceStorage.
                                           GetResourceById(viewInfo.Appointment.ResourceId);

            if (resource == Resource.Empty || resource.Image == null)
            {
                viewInfo.CustomViewInfo = null;
            }
            else
            {
                if (!this.resourceImages.ContainsKey(resource))
                {
                    this.resourceImages[resource] = resource.Image.Source as BitmapImage;
                }
                viewInfo.CustomViewInfo = this.resourceImages[resource];
            }
        }
Exemplo n.º 23
0
        private void timelineCells1_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e)
        {
            e.DrawDefault();
            AppointmentViewInfo vi  = (AppointmentViewInfo)e.ObjectInfo;
            Appointment         apt = vi.Appointment;

            Assignment ass = apt.GetSourceObject(this.schedulerControlPrintAdapter1.SchedulerControl.Storage) as Assignment;

            //vi.Appearance.BackColor = Color.FromArgb(ass.Booking.Color);

            Rectangle rect = vi.Bounds;

            rect.Inflate(-vi.LeftBorderBounds.Width, -vi.TopBorderBounds.Height);

            Brush brush = e.Cache.GetGradientBrush(rect, Color.FromArgb(ass.Booking.Color), Color.FromArgb(ass.Booking.Color), LinearGradientMode.Vertical);

            e.Cache.FillRectangle(brush, rect);
            // e.Handled = true;

            e.Handled = ass.Booking.ColorBookings;
        }
Exemplo n.º 24
0
        /// <summary>
        /// init tooltip
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolTipController_BeforeShow(object sender, ToolTipControllerShowEventArgs e)
        {
            ToolTipController   controller  = sender as ToolTipController;
            AppointmentViewInfo aptViewInfo = controller.ActiveObject as AppointmentViewInfo;

            if (aptViewInfo == null)
            {
                return;
            }
            toolTipController.ToolTipType = ToolTipType.SuperTip;

            if (toolTipController.ToolTipType == ToolTipType.SuperTip)
            {
                SuperToolTip          SuperTip = new SuperToolTip();
                SuperToolTipSetupArgs args     = new SuperToolTipSetupArgs();
                args.Contents.Text       = aptViewInfo.Description;
                args.ShowFooterSeparator = true;
                args.Footer.Text         = aptViewInfo.Appointment.Start.ToShortTimeString() + " ~ " + aptViewInfo.Appointment.End.ToShortTimeString();//"SuperTip";
                SuperTip.Setup(args);
                e.SuperTip = SuperTip;
            }
        }
Exemplo n.º 25
0
        void schedulerControl_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e)
        {
            SchedulerControl    schedulerControl = sender as SchedulerControl;
            AppointmentViewInfo info             = e.ObjectInfo as AppointmentViewInfo;
            string tabResourceName         = (schedulerControl.Parent as XtraTabPage).Text;
            string appointmentResourceName = String.Empty;

            if (!(info.Appointment.ResourceId is EmptyResourceId))
            {
                appointmentResourceName = schedulerStorage.Resources[(int)info.Appointment.ResourceId].Caption;
            }
            e.DrawDefault();
            if (appointmentResourceName != tabResourceName)
            {
                Color     color      = schedulerStorage.Appointments.Labels.GetById(info.Appointment.LabelKey).Color;
                Color     lightColor = ControlPaint.LightLight(color);
                Rectangle rect       = new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width - 4, e.Bounds.Height - 4);
                e.Graphics.FillRectangle(new SolidBrush(lightColor), rect);
            }

            e.Handled = true;
        }
Exemplo n.º 26
0
        private static void scheduler_CustomDrawAppointmentBackground(object sender, CustomDrawObjectEventArgs e)
        {
            SchedulerControl               scheduler       = sender as SchedulerControl;
            AppointmentViewInfo            viewInfo        = (e.ObjectInfo as DevExpress.XtraScheduler.Drawing.AppointmentViewInfo);
            Appointment                    apt             = viewInfo.Appointment;
            AppointmentBaseCollection      allAppointments = scheduler.ActiveView.GetAppointments();
            AppointmentConflictsCalculator aCalculator     = new AppointmentConflictsCalculator(allAppointments);
            TimeInterval                   visibleInterval = scheduler.ActiveView.GetVisibleIntervals().Interval;
            bool isConflict = aCalculator.CalculateConflicts(apt, visibleInterval).Count != 0;

            // Paint conflict appointments with a red and white hatch brush.
            if (isConflict)
            {
                Rectangle rect  = e.Bounds;
                Brush     brush = e.Cache.GetSolidBrush(scheduler.DataStorage.Appointments.Labels.GetById(apt.LabelKey).GetColor());
                e.Cache.FillRectangle(brush, rect);
                rect.Inflate(-3, -3);
                using (var _hatchBrush = new HatchBrush(HatchStyle.WideUpwardDiagonal, Color.Red, Color.White))
                    e.Cache.FillRectangle(_hatchBrush, rect);
                e.Handled = true;
            }
        }
Exemplo n.º 27
0
        private void scheduler_AppointmentViewInfoCustomizing(object sender, AppointmentViewInfoCustomizingEventArgs e)
        {
            if (!chkAppointmentToolTip.IsChecked.GetValueOrDefault() == true)
            {
                return;
            }

            AppointmentViewInfo viewInfo = e.ViewInfo;
            Resource            resource = scheduler.Storage.ResourceStorage.GetResourceById(viewInfo.Appointment.ResourceId);

            if (Object.Equals(resource.Id, EmptyResourceId.Id) || resource.ImageBytes == null)
            {
                viewInfo.CustomViewInfo = null;
            }
            else
            {
                if (!this.resourceImages.ContainsKey(resource))
                {
                    this.resourceImages[resource] = resource.GetImage() as BitmapImage;
                }
                viewInfo.CustomViewInfo = this.resourceImages[resource];
            }
        }
Exemplo n.º 28
0
        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);
                    }
                }
            }
        }