private void SchedulerControl_MouseMove(object sender, MouseEventArgs e)
        {
            // Obtain hit information under the test point.
            SchedulerControlHitInfo hitInfo = schedulerControl1.ActiveView.CalcHitInfo(e);
            StringBuilder           builder = new StringBuilder();

            // Check whether the scheduler element is located at the test point.
            switch (hitInfo.HitTest)
            {
            case SchedulerHitTest.AllDayArea:
                builder.AppendLine("All-Day Area");
                break;

            case SchedulerHitTest.AppointmentContent:
                builder.AppendLine("Appointment");
                IAppointmentView appView = hitInfo.ViewInfo as IAppointmentView;
                if (appView != null)
                {
                    builder.AppendLine("Subject: " + appView.Appointment.Subject);
                    builder.AppendLine("Start: " + appView.Appointment.Start.ToString());
                    builder.AppendLine("End: " + appView.Appointment.End.ToString());
                }
                break;

            case SchedulerHitTest.Cell:
                builder.AppendLine("Time Cell");
                break;
            }

            if (builder.Length > 0)
            {
                builder.AppendLine("Interval: " + hitInfo.ViewInfo.Interval.ToString());
                builder.AppendLine("Is Selected? " + hitInfo.ViewInfo.Selected.ToString());
                lbl1.Content = string.Format("Hit test results:\n" + builder.ToString());
            }
            else
            {
                lbl1.Content = "Move the mouse pointer over the scheduler\n to get information on the element which is hovered over.";
            }
        }
    public static HitTimeCellInfo CreateHitTimeCellInfo(SchedulerControl control, Point mousePosition)
    {
        SchedulerControlHitInfo hitInfo     = control.ActiveView.CalcHitInfo(mousePosition);
        SchedulerHitInfo        cellHitInfo = hitInfo.FindHitInfo(SchedulerHitTest.Cell) as SchedulerHitInfo;

        if (cellHitInfo == null)
        {
            return(null);
        }
        UIElement cell = cellHitInfo.VisualHit;

        if (cell == null)
        {
            return(null);
        }

        //--First method
        //GeneralTransform positionTransform = cell.TransformToAncestor(control);
        //Point areaPosition = positionTransform.Transform(new Point());

        //--Second method
        Point areaPosition   = control.PointFromScreen(cell.PointToScreen(new Point()));
        Rect  timeCellBounds = new Rect(areaPosition, cell.RenderSize);

        double percent = 0d;

        if (control.ActiveViewType == DevExpress.XtraScheduler.SchedulerViewType.Timeline)
        {
            percent = (timeCellBounds.Width != 0) ? (double)(mousePosition.X - timeCellBounds.X) / (double)timeCellBounds.Width : 0;
        }
        else
        {
            percent = (timeCellBounds.Height != 0) ? (double)(mousePosition.Y - timeCellBounds.Y) / (double)timeCellBounds.Height : 0;
        }

        TimeSpan timeShift = TimeSpan.FromMinutes(cellHitInfo.ViewInfo.Interval.Duration.TotalMinutes * percent);

        return(new HitTimeCellInfo(cellHitInfo.ViewInfo, timeShift, timeCellBounds));
    }
Пример #3
0
    protected ISelectableIntervalViewInfo GetSelectableIntervalViewInfo()
    {
        SchedulerControlHitInfo hitInfo = control.ActiveView.CalcHitInfo(MousePosition);

        return((hitInfo.HitTest == SchedulerHitTest.Cell) ? (ISelectableIntervalViewInfo)hitInfo.ViewInfo : null);
    }
Пример #4
0
    protected IAppointmentView  GetAppointmentViewInfo()
    {
        SchedulerControlHitInfo hitInfo = control.ActiveView.CalcHitInfo(MousePosition);

        return((hitInfo.HitTest == SchedulerHitTest.AppointmentContent) ? (IAppointmentView )hitInfo.ViewInfo : null);
    }