コード例 #1
0
        // This function adds a course to the Calendar UI
        private void addToCalendar(Course course)
        {
            Tuple <int, int, int, int> course_time = course.getTimeHourMinute();

            if (course_time.Item1 == -1 || !course.getDay().Contains(true))  // Course does not have a time or doesn't have a day
            {
                return;
            }

            Calendar.Appointment m_course;

            for (int day = 0; day < 5; day++)
            {
                if (course.getDay()[day])
                {
                    m_course           = new Calendar.Appointment();
                    m_course.StartDate = new DateTime(2010, 2, 1 + day, course_time.Item1, course_time.Item2, 0);
                    m_course.EndDate   = new DateTime(2010, 2, 1 + day, course_time.Item3, course_time.Item4, 0);
                    m_course.Title     = course.getCourseCode() + " " + course.getLongName();
                    m_course.CourseID  = course.getCourseID();
                    m_course.Locked    = true;
                    m_Courses.Add(m_course);
                }
            }

            updateConflictMarkers();
        }
コード例 #2
0
        protected override void DrawAppointment(Graphics g, Rectangle rect, Calendar.Appointment appointment, bool isSelected, Rectangle gripRect)
        {
            // Our custom gripper bar
            gripRect = rect;
            gripRect.Inflate(-2, -2);
            gripRect.Width = 5;

            // If the start date precedes the start of the week then extend the
            // draw rect to the left so the edge is clipped and likewise for the right.
            if (appointment.StartDate < StartDate)
            {
                rect.X     -= 4;
                rect.Width += 4;

                gripRect.X     = rect.X;
                gripRect.Width = 0;
            }

            if (appointment.EndDate >= EndDate)
            {
                rect.Width += 5;
            }

            m_Renderer.DrawAppointment(g, rect, appointment, isSelected, gripRect);
        }
コード例 #3
0
ファイル: TDLDayView.cs プロジェクト: simryang/ToDoList_Dev
        bool WantDrawAppointmentSelected(Calendar.Appointment appointment)
        {
            // When a real or future task item is selected we want
            // all the other related tasks to also appear selected
            if (m_SelectedTaskID == appointment.Id)
            {
                return(true);
            }

            var selTaskID = GetSelectedTaskID();

            if (selTaskID == appointment.Id)
            {
                return(true);
            }

            // If the argument is a future item, check to see
            // if its real task ID matches the selected task
            var futureItem = (appointment as CalendarFutureItem);

            if (futureItem != null)
            {
                if (selTaskID == futureItem.RealTaskId)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #4
0
        private void OnDayViewMouseClick(object sender, MouseEventArgs e)
        {
            if (m_DayView.ReadOnly)
            {
                return;
            }

            Calendar.Appointment appointment = m_DayView.GetAppointmentAt(e.Location.X, e.Location.Y);

            if (appointment == null)
            {
                return;
            }

            var taskItem = (appointment as CalendarItem);

            if ((taskItem == null) || taskItem.IsLocked)
            {
                return;
            }

            if (taskItem.IconRect.Contains(e.Location))
            {
                var notify = new UIExtension.ParentNotify(m_HwndParent);

                notify.NotifyEditIcon();
            }
        }
コード例 #5
0
        private UInt32 GetRealTaskId(Calendar.Appointment appt)
        {
            if (appt is CalendarFutureItem)
            {
                return((appt as CalendarFutureItem).RealTaskId);
            }

            return(appt.Id);
        }
コード例 #6
0
        public UInt32 HitTestTask(Int32 xScreen, Int32 yScreen)
        {
            System.Drawing.Point pt          = PointToClient(new System.Drawing.Point(xScreen, yScreen));
            Calendar.Appointment appointment = GetAppointmentAt(pt.X, pt.Y);

            if (appointment != null)
            {
                return(appointment.Id);
            }

            return(0);
        }
コード例 #7
0
        protected override void DrawAppointment(Graphics g, Rectangle rect, Calendar.Appointment appointment, bool isSelected, Rectangle gripRect)
        {
            // Allow selection to be drawn even when a
            // selection rect is active
            isSelected = (appointment.Id == m_SelectedTaskID);

            // Our custom gripper bar
            gripRect = rect;
            gripRect.Inflate(-2, -2);
            gripRect.Width = 5;

            // If the start date precedes the start of the week then extend the
            // draw rect to the left so the edge is clipped and likewise for the right.
            CalendarItem taskItem = (appointment as CalendarItem);
            bool         longAppt = taskItem.IsLongAppt();

            if (longAppt)
            {
                if (appointment.StartDate < StartDate)
                {
                    rect.X     -= 4;
                    rect.Width += 4;

                    gripRect.X     = rect.X;
                    gripRect.Width = 0;
                }
                else if (appointment.StartDate > StartDate)
                {
                    rect.X++;
                    rect.Width--;

                    gripRect.X++;
                }

                if (appointment.EndDate >= EndDate)
                {
                    rect.Width += 5;
                }
            }
            else // day appointment
            {
                if (taskItem.StartDate.TimeOfDay.TotalHours == 0.0)
                {
                    rect.Y++;
                    rect.Height--;
                }

                rect.Width -= 1;
            }

            m_Renderer.DrawAppointment(g, rect, appointment, isSelected, gripRect);
        }
コード例 #8
0
 private void dayView1_NewAppointment(object sender, Calendar.NewAppointmentEventArgs e)
 {
     Calendar.Appointment appt = new Calendar.Appointment();
     appt.StartDate = e.StartDate;
     appt.EndDate   = e.EndDate;
     appt.Title     = e.Title;
     appt.ID        = _appointments.Count;
     appt.Color     = Color.BlanchedAlmond;
     appt.Column    = e.Column;
     appt.Object    = lstPeople.CheckedItems[e.Column];
     _appointments.Add(appt);
     ForceRefresh();
 }
コード例 #9
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            var selTool = ActiveTool as Calendar.SelectionTool;

            if (selTool == null)
            {
                selTool = new Calendar.SelectionTool();
            }

            if (selTool.IsResizing())
            {
                if (ReadOnly)
                {
                    return;
                }
            }
            else // Extra-over cursor handling
            {
                Calendar.Appointment appointment = GetAppointmentAt(e.Location.X, e.Location.Y);
                Cursor = Cursors.Default;

                if (!ReadOnly && (appointment != null))
                {
                    selTool.DayView = this;
                    selTool.UpdateCursor(e, appointment);

                    var taskItem = (appointment as CalendarItem);

                    if (taskItem != null)
                    {
                        Cursor temp = null;

                        if (taskItem.IsLocked)
                        {
                            temp = UIExtension.AppCursor(UIExtension.AppCursorType.LockedTask);
                        }
                        else if (taskItem.IconRect.Contains(e.Location))
                        {
                            temp = UIExtension.HandCursor();
                        }

                        if (temp != null)
                        {
                            Cursor = temp;
                        }
                    }
                }
            }

            base.OnMouseMove(e);
        }
コード例 #10
0
        private void CreateRandomAppointments()
        {
            //allday appointments
            for (int i = 0; i < 2; ++i)
            {
                Calendar.Appointment appt = new Calendar.Appointment();
                appt.AllDayEvent = true;
                appt.Color       = Color.BurlyWood;
                DateTime date = DateTime.Now.Date;
                appt.StartDate = date;
                appt.EndDate   = date.AddDays(i);
                appt.Title     = String.Format("All Day Appointment {0}", i);
                _appointments.Add(appt);
            }

            Random rnd = new Random();

            foreach (string person in lstPeople.Items)
            {
                for (int i = 2; i < 5; i++)           // four each
                {
                    for (int day = 0; day < 7; ++day) //per day
                    {
                        Calendar.Appointment appt = new Calendar.Appointment();
                        appt.Object = person;
                        appt.Color  = Color.BlanchedAlmond; // dont ask me why I chose this color?
                        DateTime date = DateTime.Now.Date.AddDays(day).AddHours(rnd.Next(10, 17));
                        appt.StartDate = date;
                        appt.EndDate   = date.AddMinutes(i * 15);
                        appt.Title     = String.Format("Test Appointment {0}", i);
                        _appointments.Add(appt);
                    }
                }
            }

            // overlapped appointments
            string firstPerson = (string)lstPeople.Items[0];

            for (int i = 0; i < _overlappedAppointments.Length; i++)
            {
                Calendar.Appointment appt = new Calendar.Appointment();
                appt.Object = firstPerson;
                appt.Color  = Color.BlanchedAlmond; // dont ask me why I chose this color?
                DateTime date = DateTime.Now.Date.AddMinutes(_overlappedAppointments[i]);
                appt.StartDate = date;
                appt.EndDate   = date.AddMinutes(_overlapDurations[i]);
                appt.Title     = String.Format("Overlap {0}", i);
                _appointments.Add(appt);
            }
        }
コード例 #11
0
        public override bool EnsureVisible(Calendar.Appointment appt, bool partialOK)
        {
            if ((appt == null) && (m_SelectedTaskID != 0))
            {
                CalendarItem item;

                if (m_Items.TryGetValue(m_SelectedTaskID, out item))
                {
                    appt = item;
                }
            }

            return(base.EnsureVisible(appt, partialOK));
        }
コード例 #12
0
        protected override void DrawAppointment(Graphics g, Rectangle rect, Calendar.Appointment appointment, bool isSelected, Rectangle gripRect)
        {
            isSelected = WantDrawAppointmentSelected(appointment);

            // Our custom gripper bar
            gripRect = rect;
            gripRect.Inflate(-2, -2);
            gripRect.Width = 5;

            // If the start date precedes the start of the week then extend the
            // draw rect to the left so the edge is clipped and likewise for the right.
            bool longAppt = IsLongAppt(appointment);

            if (longAppt)
            {
                if (appointment.StartDate < StartDate)
                {
                    rect.X     -= 4;
                    rect.Width += 4;

                    gripRect.X     = rect.X;
                    gripRect.Width = 0;
                }
                else if (appointment.StartDate > StartDate)
                {
                    rect.X++;
                    rect.Width--;

                    gripRect.X++;
                }

                if (appointment.EndDate >= EndDate)
                {
                    rect.Width += 5;
                }
            }
            else // day appointment
            {
                if (appointment.StartDate.TimeOfDay.TotalHours == 0.0)
                {
                    rect.Y++;
                    rect.Height--;
                }

                rect.Width -= 1;
            }

            m_Renderer.DrawAppointment(g, rect, appointment, longAppt, isSelected, gripRect);
        }
コード例 #13
0
        private void createAppointmentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Calendar.Appointment appt = new Calendar.Appointment();
            appt.ID    = _appointments.Count;
            appt.Title = "New Appointment";

            dayView1.GetColumnFromMousePosition(out int column, out DateTime date);

            appt.StartDate = dayView1.SelectionStart;
            appt.EndDate   = dayView1.SelectionEnd;
            appt.Object    = lstPeople.CheckedItems[column];
            appt.Column    = column;
            _appointments.Add(appt);
            dayView1.Invalidate();
        }
コード例 #14
0
        public UIExtension.HitResult HitTest(Int32 xScreen, Int32 yScreen)
        {
            System.Drawing.Point pt          = PointToClient(new System.Drawing.Point(xScreen, yScreen));
            Calendar.Appointment appointment = GetAppointmentAt(pt.X, pt.Y);

            if (appointment != null)
            {
                return(UIExtension.HitResult.Task);
            }
            else if (GetTrueRectangle().Contains(pt))
            {
                return(UIExtension.HitResult.Tasklist);
            }

            // else
            return(UIExtension.HitResult.Nowhere);
        }
コード例 #15
0
        private Calendar.SelectionTool.Mode GetMode(Calendar.Appointment appointment, Point mousePos)
        {
            if (ReadOnly || (appointment == null))
            {
                return(Calendar.SelectionTool.Mode.None);
            }

            var selTool = (ActiveTool as Calendar.SelectionTool);

            if (selTool == null)
            {
                selTool         = new Calendar.SelectionTool();
                selTool.DayView = this;
            }

            return(selTool.GetMode(mousePos, appointment));
        }
コード例 #16
0
ファイル: TDLDayView.cs プロジェクト: simryang/ToDoList_Dev
        public Calendar.Appointment GetRealAppointment(Calendar.Appointment appt)
        {
            if (appt != null)
            {
                CalendarFutureItem futureItem;

                if (m_FutureItems.TryGetValue(appt.Id, out futureItem))
                {
                    CalendarItem taskItem;

                    if (m_Items.TryGetValue(futureItem.RealTaskId, out taskItem))
                    {
                        return(taskItem);
                    }
                }
            }

            return(appt);
        }
コード例 #17
0
        private bool IsItemWithinRange(Calendar.Appointment appt, DateTime startDate, DateTime endDate)
        {
            // sanity check
            if (!appt.HasValidDates())
            {
                return(false);
            }

            // Task must at least intersect the range
            if ((appt.StartDate >= endDate) || (appt.EndDate <= startDate))
            {
                return(false);
            }

            if (!DisplayTasksContinuous)
            {
                if ((appt.StartDate < startDate) && (appt.EndDate > endDate))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #18
0
        public override void DrawAppointment(Graphics g, Rectangle rect, Calendar.Appointment appointment, bool isLong, bool isSelected, Rectangle gripRect)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment");
            }

            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (rect.Width != 0 && rect.Height != 0)
            {
                CalendarItem taskItem = (appointment as CalendarItem);

                UInt32 taskId     = taskItem.Id;
                UInt32 realTaskId = GetRealTaskId(taskItem);

                bool isFutureItem = (taskId != realTaskId);

                // Recalculate colours
                Color textColor = taskItem.TaskTextColor;
                Color fillColor = DrawingColor.SetLuminance(textColor, 0.95f);

                if (isFutureItem)
                {
                    fillColor = SystemColors.Window;

                    float textLum = DrawingColor.GetLuminance(textColor);
                    textColor = DrawingColor.SetLuminance(textColor, Math.Min(textLum + 0.2f, 0.7f));
                }

                Color borderColor = textColor;
                Color barColor    = textColor;

                if (taskItem.HasTaskTextColor)
                {
                    if (isSelected)
                    {
                        textColor = DrawingColor.SetLuminance(textColor, 0.3f);
                    }
                    else if (TaskColorIsBackground && !taskItem.IsDoneOrGoodAsDone && !isFutureItem)
                    {
                        barColor  = textColor;
                        fillColor = textColor;

                        borderColor = DrawingColor.AdjustLighting(textColor, -0.5f, true);
                        textColor   = DrawingColor.GetBestTextColor(textColor);
                    }
                }

                // Draw the background of the appointment
                g.SmoothingMode = SmoothingMode.None;

                if (isSelected)
                {
                    if (isLong)
                    {
                        rect.Height++;
                    }

                    if (isFutureItem)
                    {
                        UIExtension.SelectionRect.Draw(m_hWnd,
                                                       g,
                                                       rect.Left,
                                                       rect.Top,
                                                       rect.Width,
                                                       rect.Height,
                                                       UIExtension.SelectionRect.Style.DropHighlighted,
                                                       false);                                                          // opaque
                    }
                    else
                    {
                        UIExtension.SelectionRect.Draw(m_hWnd,
                                                       g,
                                                       rect.Left,
                                                       rect.Top,
                                                       rect.Width,
                                                       rect.Height,
                                                       false);                                                          // opaque
                    }
                }
                else
                {
                    using (SolidBrush brush = new SolidBrush(fillColor))
                        g.FillRectangle(brush, rect);

                    if (taskItem.DrawBorder)
                    {
                        if (!isLong)
                        {
                            rect.Height--;                             // drawing with pen adds 1 to height
                            rect.Width--;
                        }


                        using (Pen pen = new Pen(borderColor, 1))
                        {
                            if (isFutureItem)
                            {
                                pen.DashStyle = DashStyle.Dash;
                            }

                            g.DrawRectangle(pen, rect);
                        }
                    }
                }

                // Draw appointment icon
                bool hasIcon = false;
                taskItem.IconRect = Rectangle.Empty;

                if (TaskHasIcon(taskItem))
                {
                    Rectangle rectIcon;
                    int       imageSize = DPIScaling.Scale(16);

                    if (isLong)
                    {
                        int yCentre = ((rect.Top + rect.Bottom + 1) / 2);
                        rectIcon = new Rectangle((rect.Left + TextPadding), (yCentre - (imageSize / 2)), imageSize, imageSize);
                    }
                    else
                    {
                        rectIcon = new Rectangle(rect.Left + TextPadding, rect.Top + TextPadding, imageSize, imageSize);
                    }

                    if (g.IsVisible(rectIcon) && m_TaskIcons.Get(realTaskId))
                    {
                        if (isLong)
                        {
                            rectIcon.X = (gripRect.Right + TextPadding);
                        }
                        else
                        {
                            gripRect.Y      += (imageSize + TextPadding);
                            gripRect.Height -= (imageSize + TextPadding);
                        }

                        var clipRgn = g.Clip;

                        if (rect.Bottom < (rectIcon.Y + imageSize))
                        {
                            g.Clip = new Region(RectangleF.Intersect(rect, g.ClipBounds));
                        }

                        m_TaskIcons.Draw(g, rectIcon.X, rectIcon.Y);

                        g.Clip = clipRgn;

                        hasIcon           = true;
                        taskItem.IconRect = rectIcon;

                        rect.Width -= (rectIcon.Right - rect.Left);
                        rect.X      = rectIcon.Right;
                    }
                }

                // Draw gripper bar
                if (gripRect.Width > 0)
                {
                    using (SolidBrush brush = new SolidBrush(barColor))
                        g.FillRectangle(brush, gripRect);

                    if (!isLong)
                    {
                        gripRect.Height--; // drawing with pen adds 1 to height
                    }
                    // Draw gripper border
                    using (Pen pen = new Pen(DrawingColor.AdjustLighting(barColor, -0.5f, true), 1))
                        g.DrawRectangle(pen, gripRect);

                    if (!hasIcon)
                    {
                        rect.X      = gripRect.Right;
                        rect.Width -= (gripRect.Width + (TextPadding * 2));
                    }
                }

                // draw appointment text
                using (StringFormat format = new StringFormat())
                {
                    format.Alignment     = StringAlignment.Near;
                    format.LineAlignment = (isLong ? StringAlignment.Center : StringAlignment.Near);

                    rect.Y += 3;

                    if (isLong)
                    {
                        rect.Height = m_BaseFont.Height;
                    }
                    else
                    {
                        rect.Height -= 3;
                    }

                    taskItem.TextRect   = rect;
                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    using (SolidBrush brush = new SolidBrush(textColor))
                    {
                        if (taskItem.IsDone && StrikeThruDoneTasks)
                        {
                            using (Font font = new Font(this.BaseFont, FontStyle.Strikeout))
                            {
                                g.DrawString(appointment.Title, font, brush, rect, format);
                            }
                        }
                        else
                        {
                            g.DrawString(appointment.Title, this.BaseFont, brush, rect, format);
                        }
                    }

                    g.TextRenderingHint = TextRenderingHint.SystemDefault;
                }
            }
        }
コード例 #19
0
        public override void DrawAppointment(System.Drawing.Graphics g, System.Drawing.Rectangle rect, Calendar.Appointment appointment, bool isSelected, System.Drawing.Rectangle gripRect)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment");
            }

            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            if (rect.Width != 0 && rect.Height != 0)
            {
                CalendarItem taskItem = (appointment as CalendarItem);
                bool         longAppt = taskItem.IsLongAppt();

                if (!longAppt && (taskItem.StartDate.TimeOfDay.TotalHours == 0.0))
                {
                    rect.Y++;
                    rect.Height--;
                }

                rect.Width--;

                // Recalculate colours
                Color textColor   = taskItem.TaskTextColor;
                Color borderColor = taskItem.TaskTextColor;
                Color fillColor   = DrawingColor.SetLuminance(taskItem.TaskTextColor, 0.95f);
                Color barColor    = taskItem.TaskTextColor;

                if (taskItem.HasTaskTextColor)
                {
                    if (isSelected)
                    {
                        textColor = DrawingColor.SetLuminance(taskItem.TaskTextColor, 0.3f);
                    }
                    else if (m_TaskColorIsBkgnd && !taskItem.IsDone)
                    {
                        textColor   = DrawingColor.GetBestTextColor(taskItem.TaskTextColor);
                        borderColor = DrawingColor.AdjustLighting(taskItem.TaskTextColor, -0.5f, true);
                        barColor    = taskItem.TaskTextColor;
                        fillColor   = taskItem.TaskTextColor;
                    }
                }

                using (StringFormat format = new StringFormat())
                {
                    format.Alignment     = StringAlignment.Near;
                    format.LineAlignment = (longAppt ? StringAlignment.Center : StringAlignment.Near);

                    // Draw the background of the appointment
                    if (isSelected)
                    {
                        m_SelectionRect.Draw(m_hWnd, g, rect.Left, rect.Top, rect.Width, rect.Height);
                    }
                    else
                    {
                        using (SolidBrush brush = new SolidBrush(fillColor))
                            g.FillRectangle(brush, rect);
                    }

                    //  Draw appointment border if needed
                    if (!isSelected && taskItem.DrawBorder)
                    {
                        using (Pen pen = new Pen(borderColor, 1))
                            g.DrawRectangle(pen, rect);
                    }

                    // Draw appointment icon
                    bool hasIcon = false;
                    taskItem.IconRect = Rectangle.Empty;

                    if (TaskHasIcon(taskItem))
                    {
                        Rectangle rectIcon;
                        int       imageSize = DPIScaling.Scale(16);

                        if (taskItem.IsLongAppt())
                        {
                            int yCentre = ((rect.Top + rect.Bottom + 1) / 2);
                            rectIcon = new Rectangle((rect.Left + 2), (yCentre - (imageSize / 2)), imageSize, imageSize);
                        }
                        else
                        {
                            rectIcon = new Rectangle(rect.Left + 2, rect.Top + 2, imageSize, imageSize);
                        }

                        if (Rectangle.Round(g.VisibleClipBounds).Contains(rectIcon) && m_TaskIcons.Get(taskItem.Id))
                        {
                            if (longAppt)
                            {
                                rectIcon.X = (gripRect.Right + 2);
                            }
                            else
                            {
                                gripRect.Y      += (imageSize + 2);
                                gripRect.Height -= (imageSize + 2);
                            }

                            m_TaskIcons.Draw(g, rectIcon.X, rectIcon.Y);

                            hasIcon           = true;
                            taskItem.IconRect = rectIcon;

                            rect.Width -= (rectIcon.Right - rect.Left);
                            rect.X      = rectIcon.Right;
                        }
                    }

                    // Draw gripper bar
                    if (gripRect.Width > 0)
                    {
                        using (SolidBrush brush = new SolidBrush(barColor))
                            g.FillRectangle(brush, gripRect);

                        // Draw gripper border
                        using (Pen pen = new Pen(DrawingColor.AdjustLighting(barColor, -0.5f, true), 1))
                            g.DrawRectangle(pen, gripRect);

                        if (!hasIcon)
                        {
                            rect.X      = gripRect.Right;
                            rect.Width -= (gripRect.Width + 4);
                        }
                    }

                    // draw appointment text
                    rect.Y += 3;

                    if (longAppt)
                    {
                        rect.Height = m_BaseFont.Height;
                    }
                    else
                    {
                        rect.Height -= 3;
                    }

                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    using (SolidBrush brush = new SolidBrush(textColor))
                        g.DrawString(appointment.Title, this.BaseFont, brush, rect, format);

                    g.TextRenderingHint = TextRenderingHint.SystemDefault;
                }
            }
        }
コード例 #20
0
        public UInt32 ToolHitTest(Point ptScreen, ref String tipText, ref Rectangle toolRect, ref bool multiLine)
        {
            if (IsResizingAppointment())
            {
                return(0);
            }

            var pt = PointToClient(ptScreen);

            Calendar.Appointment appointment = GetAppointmentAt(pt.X, pt.Y);

            if (appointment == null)
            {
                return(0);
            }

            var taskItem = appointment as CalendarItem;

            if ((taskItem == null) || !taskItem.TextRect.Contains(pt))
            {
                return(0);
            }

            toolRect = taskItem.TextRect;
            toolRect.Inflate(m_Renderer.TextPadding, m_Renderer.TextPadding);

            if (appointment.IsLongAppt())
            {
                // single line tooltips
                if (m_LabelTip.CalcTipHeight(taskItem.Title, toolRect.Width) <= toolRect.Height)
                {
                    return(0);
                }

                multiLine = false;                 // always
            }
            else
            {
                var availRect = GetTrueRectangle();

                if (taskItem.TextRect.Top < availRect.Top)
                {
                    // If the top of the text rectangle is hidden we always
                    // need a label tip so we just clip to the avail space
                    toolRect.Intersect(availRect);
                }
                else
                {
                    // Determine if text will fit in what's visible of the task
                    toolRect.Intersect(availRect);

                    if (m_LabelTip.CalcTipHeight(taskItem.Title, toolRect.Width) < toolRect.Height)
                    {
                        return(0);
                    }
                }

                multiLine = true;                 // always
            }

            tipText = taskItem.Title;

            return(taskItem.Id);
        }
コード例 #21
0
        public override void DrawAppointment(System.Drawing.Graphics g, System.Drawing.Rectangle rect, Calendar.Appointment appointment, bool isSelected, System.Drawing.Rectangle gripRect)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment");
            }

            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            /*
             * Logic for drawing the appointment:
             * 1) Do something messy with the colours
             *
             * 2) Determine background pattern
             * 2.1) App is locked -> HatchBrush
             * 2.2) Normal app -> Nothing
             *
             * 3) Draw the background of appointment
             *
             * 4) Draw the edges of appointment
             * 4.1) If app is selected -> just draw the selection rectangle
             * 4.2) If not -> draw the gripper, border (if required) and shadows
             */

            if (rect.Width != 0 && rect.Height != 0)
            {
                rect.Width--;

                using (StringFormat format = new StringFormat())
                {
                    format.Alignment     = StringAlignment.Near;
                    format.LineAlignment = StringAlignment.Near;

                    // Draw the background of the appointment
                    if (isSelected)
                    {
                        g.FillRectangle(System.Drawing.Brushes.White, rect);
                        ExplorerSelection.DrawBackground(g, rect);
                        ExplorerSelection.DrawBackground(g, rect);
                    }
                    else
                    {
                        using (SolidBrush brush = new SolidBrush(appointment.FillColor))
                            g.FillRectangle(brush, rect);
                    }

                    // Draw gripper bar
                    gripRect = rect;
                    gripRect.Inflate(-2, -2);
                    gripRect.Width = 5;
                    gripRect.Height--;

                    using (SolidBrush brush = new SolidBrush(appointment.BarColor))
                        g.FillRectangle(brush, gripRect);

                    // Draw gripper border
                    using (Pen m_Pen = new Pen(ColorUtil.DarkerDrawing(appointment.BarColor, 0.5f), 1))
                        g.DrawRectangle(m_Pen, gripRect);

                    //  Draw appointment border if needed
                    if (!isSelected && appointment.DrawBorder)
                    {
                        using (Pen pen = new Pen(appointment.BorderColor, 1))
                            g.DrawRectangle(pen, rect.Left, rect.Top, rect.Width - 1, rect.Height - 1);
                    }

                    // draw appointment text
                    rect.X = gripRect.Right /* + 2*/;
                    rect.Y++;

                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    Color textColor = (isSelected ? ColorUtil.DarkerDrawing(appointment.TextColor, 0.5f) : appointment.TextColor);

                    using (SolidBrush brush = new SolidBrush(textColor))
                        g.DrawString(appointment.Title, this.BaseFont, brush, rect, format);

                    g.TextRenderingHint = TextRenderingHint.SystemDefault;
                }
            }
        }
コード例 #22
0
        public List<Calendar.Appointment> fillCalenderAppointments(DateTime startDate, DateTime endDate, int docID = -1)
        {
            List<Calendar.Appointment> appList = new List<Calendar.Appointment>();
            appointment[] appointmentsArray;
            if (docID == -1)
            {
                appointmentsArray = getAppointmentsAsArray(startDate, endDate);
            }
            else
            {
                appointmentsArray = getAppointmentsAsArray(startDate, endDate, docID);
            }

            if (appointmentsArray != null)
            {
                foreach (Database.appointment app in appointmentsArray)
                {
                    String docName = String.Empty;
                    // Prevent crash if doctor is missing from database
                    if (app.doctor != null)
                    {
                        docName = app.doctor.docFullName;
                    }

                    Calendar.Appointment calApp = new Calendar.Appointment();
                    calApp.StartDate = app.appDate;
                    calApp.EndDate = app.appDate.AddMinutes(app.appDuration); // End date is start date + duration
                    if (app.appDuration <= 15)
                    {
                        calApp.Title = "Patient: " + app.patient.FullName + " Doctor: " + docName;
                    }
                    else
                    {
                        calApp.Title = "Patient: " + app.patient.FullName + "\nDoctor: " + docName;
                    }
                    calApp.AppointmentID = app.appID;

                    calApp.Color = ColorTranslator.FromHtml(app.appColour);
                    calApp.DrawBorder = true;
                    switch (app.appStatusID)
                    {
                        case 0:
                            calApp.BorderColor = Color.Blue;
                            break;
                        case 1:
                            calApp.BorderColor = Color.ForestGreen;
                            break;
                        case 2:
                            calApp.BorderColor = Color.White;
                            break;
                        case 3:
                            calApp.BorderColor = Color.Red;
                            break;
                        default:
                            calApp.BorderColor = Color.Black;
                            break;
                    }
                    // add new appointment to the list that is used to populate the calendar view
                    appList.Add(calApp);
                }
            }
            return appList;
        }