DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,495 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using DevComponents.Schedule.Model;
|
||||
using System.Drawing;
|
||||
using DevComponents.WinForms.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class AppointmentHView : AppointmentView
|
||||
{
|
||||
#region Private variables
|
||||
private eViewEnds _ViewEnds = eViewEnds.Complete;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="baseView"></param>
|
||||
/// <param name="appointment"></param>
|
||||
public AppointmentHView(BaseView baseView, Appointment appointment)
|
||||
: base(baseView, appointment)
|
||||
{
|
||||
}
|
||||
|
||||
#region Private properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the appointment is mutable
|
||||
/// </summary>
|
||||
private bool IsMutable
|
||||
{
|
||||
get
|
||||
{
|
||||
return (IsSelected == true &&
|
||||
Appointment.Locked == false &&
|
||||
Appointment.IsRecurringInstance == false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected properties
|
||||
|
||||
protected eViewEnds ViewEnds
|
||||
{
|
||||
get { return (_ViewEnds); }
|
||||
set { _ViewEnds = value; }
|
||||
}
|
||||
|
||||
protected virtual Rectangle ParentBounds
|
||||
{
|
||||
get { return (Bounds); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start/End TimeChanged event handling
|
||||
|
||||
/// <summary>
|
||||
/// Handles StartTime value changes
|
||||
/// </summary>
|
||||
/// <param name="sender">CalendarItem</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
protected override void AppointmentView_StartTimeChanged(object sender, EventArgs e)
|
||||
{
|
||||
base.AppointmentView_StartTimeChanged(sender, e);
|
||||
|
||||
SetViewEnds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles EndTime value changes
|
||||
/// </summary>
|
||||
/// <param name="sender">CalendarItem</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
protected override void AppointmentView_EndTimeChanged(object sender, EventArgs e)
|
||||
{
|
||||
base.AppointmentView_EndTimeChanged(sender, e);
|
||||
|
||||
SetViewEnds();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetViewEnds
|
||||
|
||||
/// <summary>
|
||||
/// Sets the view display end types
|
||||
/// </summary>
|
||||
protected virtual void SetViewEnds()
|
||||
{
|
||||
_ViewEnds = eViewEnds.Complete;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Appointment rendering
|
||||
|
||||
/// <summary>
|
||||
/// Paint processing
|
||||
/// </summary>
|
||||
/// <param name="e">ItemPaintArgs</param>
|
||||
public override void Paint(ItemPaintArgs e)
|
||||
{
|
||||
SetViewEnds();
|
||||
|
||||
AppointmentColor.SetColorTable();
|
||||
|
||||
int n = (Bounds.Width < 20) ? 0 : 5;
|
||||
|
||||
CornerRadius cornerRadius = new CornerRadius(n);
|
||||
Rectangle r = GetViewRect(ref cornerRadius);
|
||||
|
||||
if (r.Width > 1 && r.Height > 0)
|
||||
{
|
||||
if (EffectiveStyle == eDotNetBarStyle.Office2010 || StyleManager.IsMetro(EffectiveStyle))
|
||||
DrawMetroAppointment(e, r);
|
||||
else
|
||||
DrawDefaultAppointment(e, r, n, cornerRadius);
|
||||
|
||||
if (IsMutable == true)
|
||||
DrawGribits(e, r);
|
||||
}
|
||||
}
|
||||
|
||||
#region DrawMetroAppointment
|
||||
|
||||
private void DrawMetroAppointment(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
using (Brush br = BackBrush(r))
|
||||
e.Graphics.FillRectangle(br, r);
|
||||
|
||||
if (BaseView.CalendarView.DoAppointmentViewPreRender(this, g, r, null) == false)
|
||||
{
|
||||
DrawContent(e, r);
|
||||
|
||||
BaseView.CalendarView.DoAppointmentViewPostRender(this, g, r, null);
|
||||
}
|
||||
|
||||
DrawMetroBorder(e, r);
|
||||
}
|
||||
|
||||
#region DrawMetroBorder
|
||||
|
||||
private void DrawMetroBorder(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialLeft) != eViewEnds.PartialLeft)
|
||||
{
|
||||
if (r.Width > 10)
|
||||
DrawTimeMarker(g, r, 0);
|
||||
}
|
||||
|
||||
if (IsSelected == true)
|
||||
{
|
||||
if (r.Width > 10)
|
||||
{
|
||||
using (Pen pen = new Pen(Color.Black, 2))
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawRectangle(Pens.Black, r);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Pen pen = BorderPen)
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawDefaultAppointment
|
||||
|
||||
private void DrawDefaultAppointment(ItemPaintArgs e,
|
||||
Rectangle r, int n, CornerRadius cornerRadius)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
using (GraphicsPath path = GetItemPath(r, n * 2, cornerRadius))
|
||||
{
|
||||
using (Brush br = BackBrush(r))
|
||||
g.FillPath(br, path);
|
||||
|
||||
if (BaseView.CalendarView.DoAppointmentViewPreRender(this, g, r, path) == false)
|
||||
{
|
||||
DrawContent(e, r);
|
||||
|
||||
BaseView.CalendarView.DoAppointmentViewPostRender(this, g, r, path);
|
||||
}
|
||||
|
||||
DrawDefaultBorder(e, r, path, n);
|
||||
}
|
||||
}
|
||||
|
||||
#region DrawDefaultBorder
|
||||
|
||||
private void DrawDefaultBorder(ItemPaintArgs e,
|
||||
Rectangle r, GraphicsPath path, int n)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialLeft) != eViewEnds.PartialLeft)
|
||||
{
|
||||
if (r.Width > 10)
|
||||
DrawTimeMarker(g, r, n);
|
||||
}
|
||||
|
||||
if (IsSelected == true)
|
||||
{
|
||||
if (r.Width > 10)
|
||||
{
|
||||
using (Pen pen = SelectedBorderPen)
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawPath(Pens.Black, path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Pen pen = BorderPen)
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawContent
|
||||
|
||||
private void DrawContent(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
Image image = Image;
|
||||
|
||||
Rectangle rText = r;
|
||||
rText.X += 4;
|
||||
rText.Width -= 6;
|
||||
|
||||
if (Appointment.TimeMarkedAs != null)
|
||||
{
|
||||
rText.X += 4;
|
||||
rText.Width -= 4;
|
||||
}
|
||||
|
||||
Rectangle rImage = GetItemBounds(rText, ref rText, image);
|
||||
|
||||
DrawContentImage(e, r, rImage, image);
|
||||
DrawContentText(e, rText);
|
||||
}
|
||||
|
||||
#region DrawContentText
|
||||
|
||||
/// <summary>
|
||||
/// DrawContentText
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="r"></param>
|
||||
private void DrawContentText(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
// Format the appointment text
|
||||
|
||||
if (DisplayTemplateText(e, r) == false)
|
||||
{
|
||||
string s = (Appointment.IsMultiDayOrAllDayEvent)
|
||||
? Appointment.Subject
|
||||
: String.Format("{0} {1}", Appointment.StartTime.ToShortTimeString(), Appointment.Subject);
|
||||
|
||||
// Output the appointment text and
|
||||
// appropriately weighted bounding path
|
||||
|
||||
Font font = Font ?? e.Font;
|
||||
const eTextFormat tf = eTextFormat.VerticalCenter |
|
||||
eTextFormat.EndEllipsis | eTextFormat.NoPadding | eTextFormat.NoPrefix;
|
||||
|
||||
if (r.Width > 10)
|
||||
TextDrawing.DrawString(g, s, font, TextColor, r, tf);
|
||||
|
||||
Size size = TextDrawing.MeasureString(g, s, font, r.Width, tf);
|
||||
|
||||
IsTextClipped = (r.Width < size.Width || r.Height < size.Height);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetViewRect
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view rect for the appointment
|
||||
/// </summary>
|
||||
/// <param name="cornerRadius">Corner radius</param>
|
||||
/// <returns>View rect</returns>
|
||||
private Rectangle GetViewRect(ref CornerRadius cornerRadius)
|
||||
{
|
||||
Rectangle r = DisplayRectangle;
|
||||
|
||||
r.Intersect(ParentBounds);
|
||||
|
||||
if (r.Left == ParentBounds.Left)
|
||||
{
|
||||
r.X++;
|
||||
r.Width--;
|
||||
}
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialLeft) == eViewEnds.PartialLeft)
|
||||
cornerRadius.TopLeft = cornerRadius.BottomLeft = 0;
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialRight) == eViewEnds.PartialRight)
|
||||
cornerRadius.TopRight = cornerRadius.BottomRight = 0;
|
||||
|
||||
// If the view is selected, then allow
|
||||
// for a thicker selection rect
|
||||
|
||||
if (IsSelected == true)
|
||||
r.Height--;
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetItemPath
|
||||
|
||||
/// <summary>
|
||||
/// Gets a path defining the item
|
||||
/// </summary>
|
||||
/// <param name="viewRect"></param>
|
||||
/// <param name="radius"></param>
|
||||
/// <param name="cornerRadius"></param>
|
||||
/// <returns></returns>
|
||||
private GraphicsPath GetItemPath(Rectangle viewRect, int radius, CornerRadius cornerRadius)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
Rectangle r = viewRect;
|
||||
|
||||
Rectangle ar = new
|
||||
Rectangle(r.Right - radius, r.Bottom - radius, radius, radius);
|
||||
|
||||
if (cornerRadius.BottomRight > 0)
|
||||
path.AddArc(ar, 0, 90);
|
||||
else
|
||||
path.AddLine(r.Right, r.Bottom, r.Right, r.Bottom);
|
||||
|
||||
ar.X = r.X;
|
||||
|
||||
if (cornerRadius.BottomLeft > 0)
|
||||
path.AddArc(ar, 90, 90);
|
||||
else
|
||||
path.AddLine(r.Left, r.Bottom, r.Left, r.Bottom);
|
||||
|
||||
ar.Y = r.Y;
|
||||
|
||||
if (cornerRadius.TopLeft > 0)
|
||||
path.AddArc(ar, 180, 90);
|
||||
else
|
||||
path.AddLine(r.Left, r.Top, r.Left, r.Top);
|
||||
|
||||
ar.X = r.Right - radius;
|
||||
|
||||
if (cornerRadius.TopRight > 0)
|
||||
path.AddArc(ar, 270, 90);
|
||||
else
|
||||
path.AddLine(r.Right, r.Top, r.Right, r.Top);
|
||||
|
||||
path.CloseAllFigures();
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawGribits
|
||||
|
||||
/// <summary>
|
||||
/// Draws the resize gribits for the view
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="r">View rectangle</param>
|
||||
private void DrawGribits(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
if (r.Width >= 8)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
Rectangle r2 =
|
||||
new Rectangle(r.X, r.Y + (r.Height / 2) - 2, 5, 5);
|
||||
|
||||
// Left gribit
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialLeft) == 0)
|
||||
{
|
||||
r2.X = r.X - 3;
|
||||
|
||||
g.FillRectangle(Brushes.White, r2);
|
||||
g.DrawRectangle(Pens.Black, r2);
|
||||
}
|
||||
|
||||
// Right gribit
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialRight) == 0)
|
||||
{
|
||||
r2.X = r.Right - 2;
|
||||
|
||||
g.FillRectangle(Brushes.White, r2);
|
||||
g.DrawRectangle(Pens.Black, r2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse processing
|
||||
|
||||
/// <summary>
|
||||
/// Handles mouseDown processing
|
||||
/// </summary>
|
||||
/// <param name="objArg">MouseEventArgs</param>
|
||||
public override void InternalMouseMove(MouseEventArgs objArg)
|
||||
{
|
||||
HitArea = GetHitArea(objArg);
|
||||
|
||||
base.InternalMouseMove(objArg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HitArea from the current
|
||||
/// mouse position
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
/// <returns></returns>
|
||||
private eHitArea GetHitArea(MouseEventArgs objArg)
|
||||
{
|
||||
if (IsMutable == true)
|
||||
{
|
||||
CornerRadius cornerRadius = new CornerRadius(5);
|
||||
Rectangle r = GetViewRect(ref cornerRadius);
|
||||
|
||||
//if (r.Width > 10)
|
||||
{
|
||||
Rectangle r2 =
|
||||
new Rectangle(r.X, r.Y + (r.Height / 2) - 2, 5, 5);
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialLeft) == 0)
|
||||
{
|
||||
r2.X = r.X - 3;
|
||||
|
||||
r2.Inflate(2, 2);
|
||||
|
||||
if (r2.Contains(objArg.Location))
|
||||
return (eHitArea.LeftResize);
|
||||
}
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialRight) == 0)
|
||||
{
|
||||
r2.X = r.Right - 2;
|
||||
|
||||
r2.Inflate(2, 2);
|
||||
|
||||
if (r2.Contains(objArg.Location))
|
||||
return (eHitArea.RightResize);
|
||||
}
|
||||
}
|
||||
|
||||
// By default we are in the move area
|
||||
|
||||
return (eHitArea.Move);
|
||||
}
|
||||
|
||||
return (eHitArea.None);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,81 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using DevComponents.Schedule.Model;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class AppointmentMonthView : AppointmentHView
|
||||
{
|
||||
#region Constants
|
||||
private const int DaysInWeek = 7;
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
private MonthWeek _MonthWeek;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="baseView"></param>
|
||||
/// <param name="appointment"></param>
|
||||
public AppointmentMonthView(BaseView baseView, Appointment appointment)
|
||||
: base(baseView, appointment)
|
||||
{
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets View MonthWeek
|
||||
/// </summary>
|
||||
public MonthWeek MonthWeek
|
||||
{
|
||||
get { return (_MonthWeek); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_MonthWeek != value)
|
||||
{
|
||||
_MonthWeek = value;
|
||||
|
||||
SetViewEnds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetViewEnds
|
||||
|
||||
/// <summary>
|
||||
/// Sets the view display end types
|
||||
/// </summary>
|
||||
protected override void SetViewEnds()
|
||||
{
|
||||
if (_MonthWeek != null)
|
||||
{
|
||||
DateTime start = _MonthWeek.FirstDayOfWeek;
|
||||
DateTime end = start.AddDays(DaysInWeek);
|
||||
|
||||
ViewEnds = eViewEnds.Complete;
|
||||
|
||||
// Check to see if we can only display
|
||||
// a partial representation for the view
|
||||
|
||||
if (EndTime >= start && StartTime < end)
|
||||
{
|
||||
if (StartTime < start)
|
||||
ViewEnds |= eViewEnds.PartialLeft;
|
||||
|
||||
if (EndTime > end)
|
||||
ViewEnds |= eViewEnds.PartialRight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,81 @@
|
||||
#if FRAMEWORK20
|
||||
using DevComponents.Schedule.Model;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class AppointmentTimeLineView : AppointmentHView
|
||||
{
|
||||
#region Private variables
|
||||
private TimeLineView _TimeLineView;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="baseView"></param>
|
||||
/// <param name="appointment"></param>
|
||||
public AppointmentTimeLineView(BaseView baseView, Appointment appointment)
|
||||
: base(baseView, appointment)
|
||||
{
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
public TimeLineView TimeLineView
|
||||
{
|
||||
get { return (_TimeLineView); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TimeLineView != value)
|
||||
{
|
||||
_TimeLineView = value;
|
||||
|
||||
if (_TimeLineView != null)
|
||||
SetViewEnds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetViewEnds
|
||||
|
||||
/// <summary>
|
||||
/// Sets the view display end types
|
||||
/// </summary>
|
||||
protected override void SetViewEnds()
|
||||
{
|
||||
ViewEnds = eViewEnds.Complete;
|
||||
|
||||
Rectangle r = DisplayRectangle;
|
||||
Rectangle p = ParentBounds;
|
||||
|
||||
if (r.Left < p.Left)
|
||||
ViewEnds |= eViewEnds.PartialLeft;
|
||||
|
||||
if (r.Right > p.Right)
|
||||
ViewEnds |= eViewEnds.PartialRight;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected properties
|
||||
|
||||
protected override Rectangle ParentBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_TimeLineView != null)
|
||||
return (_TimeLineView.ClientRect);
|
||||
|
||||
return (base.ParentBounds);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,804 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using DevComponents.DotNetBar.TextMarkup;
|
||||
using DevComponents.Schedule.Model;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class AppointmentView : CalendarItem
|
||||
{
|
||||
#region enums
|
||||
|
||||
[Flags]
|
||||
public enum eViewEnds // View display ends
|
||||
{
|
||||
Complete = 0,
|
||||
PartialLeft = 1,
|
||||
PartialRight = 2
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static variables
|
||||
|
||||
static private AppointmentColor _appointmentColor = new AppointmentColor();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private Font _Font;
|
||||
private BaseView _BaseView;
|
||||
private Appointment _Appointment;
|
||||
private bool _IsTextClipped;
|
||||
private int _BorderWidth;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="baseView"></param>
|
||||
/// <param name="appointment"></param>
|
||||
public AppointmentView(BaseView baseView, Appointment appointment)
|
||||
{
|
||||
_BaseView = baseView;
|
||||
_Appointment = appointment;
|
||||
|
||||
MouseUpNotification = true;
|
||||
|
||||
StartTime = appointment.StartTime;
|
||||
EndTime = appointment.EndTime;
|
||||
ModelItem = appointment;
|
||||
|
||||
IsRecurring = (appointment.IsRecurringInstance == true ||
|
||||
appointment.Recurrence != null);
|
||||
|
||||
RootItem = (appointment.IsRecurringInstance == true) ?
|
||||
appointment.RootAppointment : appointment;
|
||||
|
||||
StartTimeChanged += AppointmentView_StartTimeChanged;
|
||||
EndTimeChanged += AppointmentView_EndTimeChanged;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Appointment
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the view Appointment
|
||||
/// </summary>
|
||||
public Appointment Appointment
|
||||
{
|
||||
get { return (_Appointment); }
|
||||
set { _Appointment = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AppointmentColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the appointment color
|
||||
/// </summary>
|
||||
public AppointmentColor AppointmentColor
|
||||
{
|
||||
get { return (_appointmentColor); }
|
||||
set { _appointmentColor = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BorderWidth
|
||||
|
||||
public int BorderWidth
|
||||
{
|
||||
get { return (_BorderWidth); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_BorderWidth != value)
|
||||
{
|
||||
_BorderWidth = value;
|
||||
|
||||
Invalidate(_BaseView.CalendarView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Font
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the view font
|
||||
/// </summary>
|
||||
public Font Font
|
||||
{
|
||||
get { return (_Font); }
|
||||
set { _Font = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsTextClipped
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the Appointment display Text is clipped
|
||||
/// </summary>
|
||||
public bool IsTextClipped
|
||||
{
|
||||
get { return (_IsTextClipped); }
|
||||
internal set { _IsTextClipped = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region BaseView
|
||||
|
||||
/// <summary>
|
||||
/// BaseView
|
||||
/// </summary>
|
||||
internal BaseView BaseView
|
||||
{
|
||||
get { return (_BaseView); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Image
|
||||
|
||||
/// <summary>
|
||||
/// Image
|
||||
/// </summary>
|
||||
internal Image Image
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(Appointment.ImageKey) == true)
|
||||
return (null);
|
||||
|
||||
ImageList images;
|
||||
|
||||
switch (_BaseView.CalendarView.ImageSize)
|
||||
{
|
||||
case eBarImageSize.Medium:
|
||||
images = _BaseView.CalendarView.ImagesMedium;
|
||||
break;
|
||||
|
||||
case eBarImageSize.Large:
|
||||
images = _BaseView.CalendarView.ImagesLarge;
|
||||
break;
|
||||
|
||||
default:
|
||||
images = _BaseView.CalendarView.Images;
|
||||
break;
|
||||
}
|
||||
|
||||
return (images != null ?
|
||||
images.Images[Appointment.ImageKey] : null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start/End TimeChanged event handling
|
||||
|
||||
/// <summary>
|
||||
/// Handles StartTime value changes
|
||||
/// </summary>
|
||||
/// <param name="sender">CalendarItem</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
protected virtual void AppointmentView_StartTimeChanged(object sender, EventArgs e)
|
||||
{
|
||||
_Appointment.StartTime = StartTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles EndTime value changes
|
||||
/// </summary>
|
||||
/// <param name="sender">CalendarItem</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
protected virtual void AppointmentView_EndTimeChanged(object sender, EventArgs e)
|
||||
{
|
||||
_Appointment.EndTime = EndTime;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DisplayTemplateText
|
||||
|
||||
/// <summary>
|
||||
/// DisplayTemplateText
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="r"></param>
|
||||
/// <returns>true is displayed</returns>
|
||||
internal bool DisplayTemplateText(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
if (_BaseView.CalendarView.EnableMarkup == true)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Appointment.DisplayTemplate) == false)
|
||||
{
|
||||
Text = GetDisplayTemplateText(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
string text = Appointment.Subject;
|
||||
|
||||
if (IsUsingTextMarkup)
|
||||
{
|
||||
if (Appointment.IsMultiDayOrAllDayEvent == false)
|
||||
text += "<br/>" + Appointment.Description;
|
||||
}
|
||||
|
||||
Text = text;
|
||||
}
|
||||
|
||||
if (IsUsingTextMarkup)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
MarkupDrawContext d =
|
||||
new MarkupDrawContext(g, Font ?? e.Font, TextColor, true);
|
||||
|
||||
Size size = new Size(5000, 5000);
|
||||
|
||||
TextMarkupBodyMeasure(size, d);
|
||||
|
||||
d.RightToLeft = false;
|
||||
|
||||
r.Y += 3;
|
||||
r.Height -= 3;
|
||||
|
||||
TextMarkupBodyArrange(new Rectangle(r.Location, TextMarkupBodyBounds.Size), d);
|
||||
|
||||
_IsTextClipped = (TextMarkupBodyBounds.Size.Width > r.Width ||
|
||||
TextMarkupBodyBounds.Size.Height > r.Height);
|
||||
|
||||
Region oldClip = g.Clip;
|
||||
Rectangle clipRect = r;
|
||||
|
||||
g.SetClip(clipRect, CombineMode.Intersect);
|
||||
|
||||
TextMarkupBodyRender(d);
|
||||
|
||||
g.Clip = oldClip;
|
||||
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDisplayTemplateText
|
||||
|
||||
/// <summary>
|
||||
/// GetDisplayTemplateText
|
||||
/// </summary>
|
||||
/// <param name="r"></param>
|
||||
/// <returns>Templatized text</returns>
|
||||
private string GetDisplayTemplateText(Rectangle r)
|
||||
{
|
||||
string s = Appointment.DisplayTemplate;
|
||||
|
||||
if (String.IsNullOrEmpty(s) == true)
|
||||
return (s);
|
||||
|
||||
Regex reg = new Regex("\\[\\w+\\]");
|
||||
MatchCollection mc = reg.Matches(s);
|
||||
|
||||
int index = 0;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.Append("<p width=\"" + r.Width.ToString() + "\">");
|
||||
|
||||
for (int i = 0; i < mc.Count; i++)
|
||||
{
|
||||
Match ma = mc[i];
|
||||
|
||||
if (ma.Index > index)
|
||||
sb.Append(s.Substring(index, ma.Index - index));
|
||||
|
||||
switch (ma.Value)
|
||||
{
|
||||
case "[StartTime]":
|
||||
sb.Append(Appointment.StartTime.ToString("t",
|
||||
_BaseView.CalendarView.Is24HourFormat ? DateTimeFormatInfo.InvariantInfo : null));
|
||||
break;
|
||||
|
||||
case "[StartDate]":
|
||||
sb.Append(Appointment.StartTime.ToShortDateString());
|
||||
break;
|
||||
|
||||
case "[EndTime]":
|
||||
sb.Append(Appointment.EndTime.ToString("t",
|
||||
_BaseView.CalendarView.Is24HourFormat ? DateTimeFormatInfo.InvariantInfo : null));
|
||||
break;
|
||||
|
||||
case "[EndDate]":
|
||||
sb.Append(Appointment.EndTime.ToShortDateString());
|
||||
break;
|
||||
|
||||
case "[Subject]":
|
||||
sb.Append(Appointment.Subject);
|
||||
break;
|
||||
|
||||
case "[Description]":
|
||||
sb.Append(Appointment.Description);
|
||||
break;
|
||||
|
||||
case "[Id]":
|
||||
sb.Append(Appointment.Id);
|
||||
break;
|
||||
|
||||
case "[Tag]":
|
||||
sb.Append(Appointment.Tag.ToString());
|
||||
break;
|
||||
|
||||
default:
|
||||
sb.Append(_BaseView.CalendarView.DoGetDisplayTemplateText(this, ma.Value, ma.Value));
|
||||
break;
|
||||
}
|
||||
|
||||
index = ma.Index + ma.Length;
|
||||
}
|
||||
|
||||
if (s.Length > index)
|
||||
sb.Append(s.Substring(index));
|
||||
|
||||
sb.Append("</p>");
|
||||
|
||||
return (sb.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint
|
||||
|
||||
/// <summary>
|
||||
/// Paint processing
|
||||
/// </summary>
|
||||
/// <param name="e">ItemPaintArgs</param>
|
||||
public override void Paint(ItemPaintArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
#region GetItemBounds
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item text and image bounds
|
||||
/// </summary>
|
||||
/// <param name="r"></param>
|
||||
/// <param name="rText"></param>
|
||||
/// <param name="image"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual Rectangle GetItemBounds(Rectangle r, ref Rectangle rText, Image image)
|
||||
{
|
||||
Rectangle ri = r;
|
||||
|
||||
if (Image != null)
|
||||
{
|
||||
const int vpad = 2;
|
||||
const int hpad = 3;
|
||||
|
||||
ri.Inflate(0, -vpad);
|
||||
|
||||
switch (Appointment.ImageAlign)
|
||||
{
|
||||
case eImageContentAlignment.TopLeft:
|
||||
rText.X += (image.Size.Width + hpad);
|
||||
rText.Width -= (image.Size.Width + hpad);
|
||||
break;
|
||||
|
||||
case eImageContentAlignment.TopRight:
|
||||
ri.X = rText.Right - image.Size.Width;
|
||||
rText.Width -= image.Size.Width;
|
||||
break;
|
||||
|
||||
case eImageContentAlignment.TopCenter:
|
||||
ri.X += (ri.Width - image.Size.Width) / 2;
|
||||
rText.Y += (image.Size.Height + hpad);
|
||||
rText.Height -= (image.Size.Height + hpad);
|
||||
break;
|
||||
|
||||
case eImageContentAlignment.MiddleLeft:
|
||||
ri.Y += (ri.Height - image.Size.Height) / 2;
|
||||
rText.X += (image.Size.Width + hpad);
|
||||
rText.Width -= (image.Size.Width + hpad);
|
||||
break;
|
||||
|
||||
case eImageContentAlignment.MiddleRight:
|
||||
ri.X = ri.Right - image.Size.Width;
|
||||
ri.Y += (ri.Height - image.Size.Height) / 2;
|
||||
rText.Width -= (image.Size.Width + hpad);
|
||||
break;
|
||||
|
||||
case eImageContentAlignment.MiddleCenter:
|
||||
ri.X = ri.X + (ri.Width - image.Size.Width) / 2;
|
||||
ri.Y += (ri.Height - image.Size.Height) / 2;
|
||||
break;
|
||||
|
||||
case eImageContentAlignment.BottomLeft:
|
||||
ri.Y = ri.Bottom - image.Size.Height;
|
||||
rText.X += (image.Size.Width + hpad);
|
||||
rText.Width -= (image.Size.Width + hpad);
|
||||
break;
|
||||
|
||||
case eImageContentAlignment.BottomRight:
|
||||
ri.X = ri.Right - image.Size.Width;
|
||||
ri.Y = ri.Bottom - image.Size.Height;
|
||||
rText.Width -= (image.Size.Width - hpad);
|
||||
break;
|
||||
|
||||
default:
|
||||
ri.X = ri.X + (ri.Width - image.Size.Width) / 2;
|
||||
ri.Y = ri.Bottom - image.Size.Height;
|
||||
break;
|
||||
}
|
||||
|
||||
ri.Size = image.Size;
|
||||
|
||||
if (ri.X < r.X)
|
||||
ri.X = r.X;
|
||||
|
||||
if (ri.Y < r.Y + vpad)
|
||||
ri.Y = r.Y + vpad;
|
||||
}
|
||||
|
||||
return (ri);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawContentImage
|
||||
|
||||
/// <summary>
|
||||
/// DrawContentImage
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="r"></param>
|
||||
/// <param name="rImage"></param>
|
||||
/// <param name="image"></param>
|
||||
protected virtual void DrawContentImage(
|
||||
ItemPaintArgs e, Rectangle r, Rectangle rImage, Image image)
|
||||
{
|
||||
if (image != null)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
rImage.Intersect(r);
|
||||
g.DrawImageUnscaledAndClipped(image, rImage);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawTimeMarker
|
||||
|
||||
#region DrawTimeMarker
|
||||
|
||||
/// <summary>
|
||||
/// Initiates the drawing of the appointment Time Marker
|
||||
/// </summary>
|
||||
/// <param name="g">Graphics</param>
|
||||
/// <param name="r">Appointment rectangle</param>
|
||||
/// <param name="corner">Corner radius</param>
|
||||
protected virtual void DrawTimeMarker(Graphics g, Rectangle r, int corner)
|
||||
{
|
||||
if (Appointment.TimeMarkedAs != null)
|
||||
{
|
||||
if (Appointment.TimeMarkedAs.Equals(Appointment.TimerMarkerTentative))
|
||||
{
|
||||
using (HatchBrush br =
|
||||
new HatchBrush(HatchStyle.WideUpwardDiagonal, BorderColor, Color.White))
|
||||
{
|
||||
g.RenderingOrigin = new Point(r.X, r.Y);
|
||||
|
||||
RenderMarker(g, br, r, corner);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Brush br = TimeMarkerBrush(r))
|
||||
{
|
||||
if (br != null)
|
||||
RenderMarker(g, br, r, corner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderMarker
|
||||
|
||||
/// <summary>
|
||||
/// RenderMarker
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="br">Brush</param>
|
||||
/// <param name="r">Rectangle</param>
|
||||
/// <param name="corner">Corner</param>
|
||||
private void RenderMarker(Graphics g, Brush br, Rectangle r, int corner)
|
||||
{
|
||||
using (Pen pen = BorderPen)
|
||||
{
|
||||
if (corner > 0)
|
||||
{
|
||||
using (GraphicsPath path = GetLeftRoundedRectanglePath(r, corner))
|
||||
{
|
||||
g.FillPath(br, path);
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int x = Math.Min(5, r.Height / 2);
|
||||
x = Math.Min(x, r.Width / 2);
|
||||
|
||||
r.Width = x;
|
||||
|
||||
g.FillRectangle(br, r);
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetLeftRoundedRectanglePath
|
||||
|
||||
/// <summary>
|
||||
/// Creates a left rounded rectangle path to be
|
||||
/// used for the Time Marker
|
||||
/// </summary>
|
||||
/// <param name="r">Appointment rectangle</param>
|
||||
/// <param name="corner">Corner radius</param>
|
||||
/// <returns>Graphics path</returns>
|
||||
private GraphicsPath GetLeftRoundedRectanglePath(Rectangle r, int corner)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
ElementStyleDisplay.AddCornerArc(path, r, corner, eCornerArc.TopLeft);
|
||||
path.AddLine(r.X + corner, r.Y, r.X + corner, r.Bottom);
|
||||
ElementStyleDisplay.AddCornerArc(path, r, corner, eCornerArc.BottomLeft);
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Color support
|
||||
|
||||
#region BackBrush
|
||||
|
||||
/// <summary>
|
||||
/// Gets the appointment BackGround brush
|
||||
/// </summary>
|
||||
/// <param name="r">Bounding rectangle</param>
|
||||
/// <returns></returns>
|
||||
protected Brush BackBrush(Rectangle r)
|
||||
{
|
||||
string category = _Appointment.CategoryColor;
|
||||
|
||||
if (category != null)
|
||||
{
|
||||
// Check to see if we have any user defined
|
||||
// AppointmentCategoryColors
|
||||
|
||||
if (_BaseView.CalendarView.HasCategoryColors == true)
|
||||
{
|
||||
AppointmentCategoryColor acc =
|
||||
_BaseView.CalendarView.CategoryColors[category];
|
||||
|
||||
if (acc != null)
|
||||
return (_appointmentColor.BrushPart(acc.BackColor, r));
|
||||
}
|
||||
|
||||
// Just use the default color set
|
||||
|
||||
if (category.StartsWith("#") == true)
|
||||
return (new SolidBrush(ColorFactory.Empty.GetColor(category.Substring(1))));
|
||||
|
||||
if (category.Equals(Appointment.CategoryBlue))
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.BlueBackground, r));
|
||||
|
||||
if (category.Equals(Appointment.CategoryGreen))
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.GreenBackground, r));
|
||||
|
||||
if (category.Equals(Appointment.CategoryOrange))
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.OrangeBackground, r));
|
||||
|
||||
if (category.Equals(Appointment.CategoryPurple))
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.PurpleBackground, r));
|
||||
|
||||
if (category.Equals(Appointment.CategoryRed))
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.RedBackground, r));
|
||||
|
||||
if (category.Equals(Appointment.CategoryYellow))
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.YellowBackground, r));
|
||||
}
|
||||
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.DefaultBackground, r));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BorderColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets the border color for the Category
|
||||
/// </summary>
|
||||
protected Color BorderColor
|
||||
{
|
||||
get
|
||||
{
|
||||
string category = _Appointment.CategoryColor;
|
||||
|
||||
if (category != null)
|
||||
{
|
||||
// Check to see if we have any user defined
|
||||
// AppointmentCategoryColors
|
||||
|
||||
if (_BaseView.CalendarView.HasCategoryColors == true)
|
||||
{
|
||||
AppointmentCategoryColor acc =
|
||||
_BaseView.CalendarView.CategoryColors[category];
|
||||
|
||||
if (acc != null)
|
||||
return (acc.BorderColor);
|
||||
}
|
||||
|
||||
// Just use the default color set
|
||||
|
||||
if (category.Equals(Appointment.CategoryBlue))
|
||||
return (_appointmentColor.GetColor((int)eAppointmentPart.BlueBorder));
|
||||
|
||||
if (category.Equals(Appointment.CategoryGreen))
|
||||
return (_appointmentColor.GetColor((int)eAppointmentPart.GreenBorder));
|
||||
|
||||
if (category.Equals(Appointment.CategoryOrange))
|
||||
return (_appointmentColor.GetColor((int)eAppointmentPart.OrangeBorder));
|
||||
|
||||
if (category.Equals(Appointment.CategoryPurple))
|
||||
return (_appointmentColor.GetColor((int)eAppointmentPart.PurpleBorder));
|
||||
|
||||
if (category.Equals(Appointment.CategoryRed))
|
||||
return (_appointmentColor.GetColor((int)eAppointmentPart.RedBorder));
|
||||
|
||||
if (category.Equals(Appointment.CategoryYellow))
|
||||
return (_appointmentColor.GetColor((int)eAppointmentPart.YellowBorder));
|
||||
}
|
||||
|
||||
return (_appointmentColor.GetColor((int)eAppointmentPart.DefaultBorder));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BorderPen
|
||||
|
||||
/// <summary>
|
||||
/// Gets the border pen
|
||||
/// </summary>
|
||||
protected Pen BorderPen
|
||||
{
|
||||
get
|
||||
{
|
||||
int n = (_BorderWidth > 0) ?
|
||||
_BorderWidth : _BaseView.CalendarView.AppointmentBorderWidth;
|
||||
|
||||
return (new Pen(BorderColor, n));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectedBorderPen
|
||||
|
||||
/// <summary>
|
||||
/// Gets the selected border pen
|
||||
/// </summary>
|
||||
protected Pen SelectedBorderPen
|
||||
{
|
||||
get
|
||||
{
|
||||
int n = (_BorderWidth > 0) ?
|
||||
_BorderWidth : _BaseView.CalendarView.AppointmentBorderWidth;
|
||||
|
||||
return (new Pen(Color.Black, n + 1));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Text color for the Category
|
||||
/// </summary>
|
||||
protected Color TextColor
|
||||
{
|
||||
get
|
||||
{
|
||||
string category = _Appointment.CategoryColor;
|
||||
|
||||
// Check to see if we have any user defined
|
||||
// AppointmentCategoryColors
|
||||
|
||||
if (category != null)
|
||||
{
|
||||
if (_BaseView.CalendarView.HasCategoryColors == true)
|
||||
{
|
||||
AppointmentCategoryColor acc =
|
||||
_BaseView.CalendarView.CategoryColors[category];
|
||||
|
||||
if (acc != null)
|
||||
return (acc.TextColor);
|
||||
}
|
||||
}
|
||||
|
||||
return (Color.Black);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TimeMarkerBrush
|
||||
|
||||
/// <summary>
|
||||
/// Gets the appointment TimeMarkerBrush
|
||||
/// </summary>
|
||||
/// <param name="r">Bounding rectangle</param>
|
||||
/// <returns></returns>
|
||||
protected Brush TimeMarkerBrush(Rectangle r)
|
||||
{
|
||||
string timeMarkedAs = _Appointment.TimeMarkedAs;
|
||||
|
||||
if (timeMarkedAs != null)
|
||||
{
|
||||
if (timeMarkedAs.StartsWith("#") == true)
|
||||
return (new SolidBrush(ColorFactory.Empty.GetColor(timeMarkedAs.Substring(1))));
|
||||
|
||||
if (timeMarkedAs.Equals(Appointment.TimerMarkerFree))
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.FreeTimeMarker, r));
|
||||
|
||||
if (timeMarkedAs.Equals(Appointment.TimerMarkerBusy))
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.BusyTimeMarker, r));
|
||||
|
||||
if (timeMarkedAs.Equals(Appointment.TimerMarkerOutOfOffice))
|
||||
return (_appointmentColor.BrushPart((int)eAppointmentPart.OutOfOfficeTimeMarker, r));
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,527 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.Schedule.Model;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class AppointmentWeekDayView : AppointmentView
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private DayColumn _DayColumn;
|
||||
private AllDayPanel _AllDayPanel;
|
||||
private eViewEnds _ViewEnds = eViewEnds.Complete;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="baseView"></param>
|
||||
/// <param name="appointment"></param>
|
||||
public AppointmentWeekDayView(BaseView baseView, Appointment appointment)
|
||||
: base(baseView, appointment)
|
||||
{
|
||||
SetViewEnds();
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets View DayColumn
|
||||
/// </summary>
|
||||
public DayColumn DayColumn
|
||||
{
|
||||
get { return (_DayColumn); }
|
||||
set { _DayColumn = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets View AllDayPanel
|
||||
/// </summary>
|
||||
public AllDayPanel AllDayPanel
|
||||
{
|
||||
get { return (_AllDayPanel); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_AllDayPanel != value)
|
||||
{
|
||||
_AllDayPanel = value;
|
||||
|
||||
SetViewEnds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default horizontal padding
|
||||
/// </summary>
|
||||
private int HorizontalPadding
|
||||
{
|
||||
get { return (6); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the appointment is mutable
|
||||
/// </summary>
|
||||
private bool IsMutable
|
||||
{
|
||||
get
|
||||
{
|
||||
WeekDayView wv = (WeekDayView)BaseView;
|
||||
|
||||
return (IsSelected == true &&
|
||||
wv.IsAllDayItem(this) == false &&
|
||||
Appointment.Locked == false &&
|
||||
Appointment.IsRecurringInstance == false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start/End TimeChanged event handling
|
||||
|
||||
/// <summary>
|
||||
/// Handles StartTime value changes
|
||||
/// </summary>
|
||||
/// <param name="sender">CalendarItem</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
protected override void AppointmentView_StartTimeChanged(object sender, EventArgs e)
|
||||
{
|
||||
base.AppointmentView_StartTimeChanged(sender, e);
|
||||
|
||||
SetViewEnds();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles EndTime value changes
|
||||
/// </summary>
|
||||
/// <param name="sender">CalendarItem</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
protected override void AppointmentView_EndTimeChanged(object sender, EventArgs e)
|
||||
{
|
||||
base.AppointmentView_EndTimeChanged(sender, e);
|
||||
|
||||
SetViewEnds();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetViewEnds
|
||||
|
||||
/// <summary>
|
||||
/// Sets the view display end types
|
||||
/// </summary>
|
||||
private void SetViewEnds()
|
||||
{
|
||||
if (_AllDayPanel != null)
|
||||
{
|
||||
_ViewEnds = eViewEnds.Complete;
|
||||
|
||||
int col, n;
|
||||
|
||||
DateTime start = GetDateCol(StartTime, out col, out n);
|
||||
DateTime end = start.AddDays(n);
|
||||
|
||||
// Check to see if we can only display
|
||||
// a partial representation for the view
|
||||
|
||||
if (col > 0 || start > StartTime)
|
||||
_ViewEnds |= eViewEnds.PartialLeft;
|
||||
|
||||
TimeSpan ts = new TimeSpan(24, 0, 0);
|
||||
|
||||
if (end > EndTime || EndTime - end > ts)
|
||||
_ViewEnds |= eViewEnds.PartialRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ViewEnds = eViewEnds.PartialLeft | eViewEnds.PartialRight;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the initial starting DayColumn col and max col
|
||||
/// for the given date
|
||||
/// </summary>
|
||||
/// <param name="selDate">Selection date</param>
|
||||
/// <param name="col">Column</param>
|
||||
/// <param name="n">Max col</param>
|
||||
/// <returns></returns>
|
||||
private DateTime GetDateCol(DateTime selDate, out int col, out int n)
|
||||
{
|
||||
DayColumn[] dayColumns = _AllDayPanel.WeekDayView.DayColumns;
|
||||
|
||||
// Loop through each column
|
||||
|
||||
col = 0;
|
||||
n = 0;
|
||||
|
||||
for (int i = 0; i < dayColumns.Length; i++)
|
||||
{
|
||||
DateTime date = dayColumns[i].Date;
|
||||
|
||||
// If we have found our containing column, then
|
||||
// calculate the absolute slice value and return it
|
||||
|
||||
if (date.Year >= selDate.Year ||
|
||||
date.Month >= selDate.Month || date.Day >= selDate.Day)
|
||||
{
|
||||
col = i;
|
||||
n = dayColumns.Length - col - 1;
|
||||
|
||||
return (date);
|
||||
}
|
||||
}
|
||||
|
||||
return (selDate);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Appointment rendering
|
||||
|
||||
/// <summary>
|
||||
/// Paint processing
|
||||
/// </summary>
|
||||
/// <param name="e">ItemPaintArgs</param>
|
||||
public override void Paint(ItemPaintArgs e)
|
||||
{
|
||||
AppointmentColor.SetColorTable();
|
||||
|
||||
Rectangle r = GetViewRect();
|
||||
|
||||
if (r.Width > 1 && r.Height > 0)
|
||||
{
|
||||
if (EffectiveStyle == eDotNetBarStyle.Office2010 || StyleManager.IsMetro(EffectiveStyle))
|
||||
DrawMetroAppointment(e, r);
|
||||
else
|
||||
DrawDefaultAppointment(e, r);
|
||||
|
||||
if (IsMutable == true)
|
||||
DrawResizeHandles(e, r);
|
||||
}
|
||||
}
|
||||
|
||||
#region DrawDefaultAppointment
|
||||
|
||||
private void DrawDefaultAppointment(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
int top = Math.Min(Math.Min(r.Width / 2, r.Height / 2), 5);
|
||||
int bot = top;
|
||||
|
||||
if (DayColumn != null)
|
||||
{
|
||||
if (StartTime.Date < DayColumn.Date.Date)
|
||||
top = 0;
|
||||
|
||||
if (EndTime.Date > DayColumn.Date.Date.AddDays(1))
|
||||
bot = 0;
|
||||
}
|
||||
|
||||
using (GraphicsPath path = DisplayHelp.GetRoundedRectanglePath(r, top, top, bot, bot))
|
||||
{
|
||||
using (Brush br = BackBrush(r))
|
||||
g.FillPath(br, path);
|
||||
|
||||
if (BaseView.CalendarView.DoAppointmentViewPreRender(this, g, r, path) == false)
|
||||
{
|
||||
DrawContent(e, r);
|
||||
|
||||
BaseView.CalendarView.DoAppointmentViewPostRender(this, g, r, path);
|
||||
}
|
||||
|
||||
DrawDefaultBorder(g, top, bot, r, path);
|
||||
}
|
||||
}
|
||||
|
||||
#region DrawDefaultBorder
|
||||
|
||||
private void DrawDefaultBorder(Graphics g,
|
||||
int top, int bot, Rectangle r, GraphicsPath path)
|
||||
{
|
||||
DrawTimeMarker(g, r, top);
|
||||
|
||||
if (IsSelected == true)
|
||||
{
|
||||
using (Pen pen = SelectedBorderPen)
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Pen pen = BorderPen)
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawMetroAppointment
|
||||
|
||||
private void DrawMetroAppointment(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
using (Brush br = BackBrush(r))
|
||||
g.FillRectangle(br, r);
|
||||
|
||||
if (BaseView.CalendarView.DoAppointmentViewPreRender(this, g, r, null) == false)
|
||||
{
|
||||
DrawContent(e, r);
|
||||
|
||||
BaseView.CalendarView.DoAppointmentViewPostRender(this, g, r, null);
|
||||
}
|
||||
|
||||
DrawMetroBorder(g, r);
|
||||
}
|
||||
|
||||
#region DrawMetroBorder
|
||||
|
||||
private void DrawMetroBorder(Graphics g, Rectangle r)
|
||||
{
|
||||
DrawTimeMarker(g, r, 0);
|
||||
|
||||
if (IsSelected == true)
|
||||
{
|
||||
using (Pen pen = new Pen(Color.Black, 2))
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Pen pen = BorderPen)
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetViewRect
|
||||
|
||||
/// <summary>
|
||||
/// Gets the view rect for the appointment
|
||||
/// </summary>
|
||||
/// <returns>View rect</returns>
|
||||
private Rectangle GetViewRect()
|
||||
{
|
||||
Rectangle r = DisplayRectangle;
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialLeft) != eViewEnds.PartialLeft)
|
||||
{
|
||||
r.X += HorizontalPadding;
|
||||
r.Width -= HorizontalPadding;
|
||||
}
|
||||
|
||||
if ((_ViewEnds & eViewEnds.PartialRight) != eViewEnds.PartialRight)
|
||||
r.Width -= HorizontalPadding;
|
||||
|
||||
// If the view is selected, then allow
|
||||
// for a thicker selection rect
|
||||
|
||||
if (IsSelected == true && Appointment.IsMultiDayOrAllDayEvent == false)
|
||||
r.Height -= 1;
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawContent
|
||||
|
||||
/// <summary>
|
||||
/// DrawContent
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="r"></param>
|
||||
private void DrawContent(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
Image image = Image;
|
||||
|
||||
Rectangle rText = r;
|
||||
rText.X += 4;
|
||||
rText.Width -= 6;
|
||||
|
||||
if (Appointment.TimeMarkedAs != null)
|
||||
{
|
||||
rText.X += 4;
|
||||
rText.Width -= 4;
|
||||
}
|
||||
|
||||
Rectangle rImage = GetItemBounds(rText, ref rText, image);
|
||||
|
||||
DrawContentImage(e, r, rImage, image);
|
||||
DrawContentText(e, rText);
|
||||
}
|
||||
|
||||
#region DrawContentText
|
||||
|
||||
/// <summary>
|
||||
/// Draws the content text
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="r"></param>
|
||||
private void DrawContentText(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
if (DisplayTemplateText(e, r) == false)
|
||||
{
|
||||
string s = Appointment.Subject;
|
||||
|
||||
eTextFormat tf = eTextFormat.NoPadding | eTextFormat.NoPrefix;
|
||||
WeekDayView wv = BaseView as WeekDayView;
|
||||
|
||||
if (wv != null && wv.IsAllDayItem(Appointment) == false)
|
||||
{
|
||||
s += "\n" + Appointment.Description;
|
||||
|
||||
r.Y += 3;
|
||||
r.Height -= 3;
|
||||
|
||||
tf |= eTextFormat.WordBreak;
|
||||
}
|
||||
else
|
||||
{
|
||||
tf |= eTextFormat.VerticalCenter;
|
||||
}
|
||||
|
||||
Font font = Font ?? e.Font;
|
||||
|
||||
if (r.Width > 4)
|
||||
TextDrawing.DrawString(g, s, font, TextColor, r, tf);
|
||||
|
||||
Size size = TextDrawing.MeasureString(g, s, font, r.Width, tf);
|
||||
|
||||
IsTextClipped = (r.Width < size.Width || r.Height < size.Height);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawResizeHandles
|
||||
|
||||
/// <summary>
|
||||
/// Draws the resize handles for the view
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="r">View rectangle</param>
|
||||
private void DrawResizeHandles(ItemPaintArgs e, Rectangle r)
|
||||
{
|
||||
if (r.Width > 6)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
Rectangle r2 =
|
||||
new Rectangle(r.X + (r.Width / 2) - 2, r.Y - 3, 5, 5);
|
||||
|
||||
if (DayColumn != null)
|
||||
{
|
||||
// Top handle
|
||||
|
||||
if (StartTime >= DayColumn.Date)
|
||||
{
|
||||
g.FillRectangle(Brushes.White, r2);
|
||||
g.DrawRectangle(Pens.Black, r2);
|
||||
}
|
||||
|
||||
// Bottom handle
|
||||
|
||||
if (EndTime <= DayColumn.Date.AddDays(1))
|
||||
{
|
||||
r2.Y = r.Bottom - 2;
|
||||
|
||||
g.FillRectangle(Brushes.White, r2);
|
||||
g.DrawRectangle(Pens.Black, r2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse processing
|
||||
|
||||
#region MouseMove processing
|
||||
|
||||
/// <summary>
|
||||
/// Handles mouseDown processing
|
||||
/// </summary>
|
||||
/// <param name="objArg">MouseEventArgs</param>
|
||||
public override void InternalMouseMove(MouseEventArgs objArg)
|
||||
{
|
||||
HitArea = GetHitArea(objArg);
|
||||
|
||||
base.InternalMouseMove(objArg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the HitArea from the current
|
||||
/// mouse position
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
/// <returns>eHitArea</returns>
|
||||
private eHitArea GetHitArea(MouseEventArgs objArg)
|
||||
{
|
||||
if (IsMutable == true)
|
||||
{
|
||||
Rectangle r = GetViewRect();
|
||||
|
||||
Rectangle r2 =
|
||||
new Rectangle(r.X + (r.Width / 2) - 7, r.Y - 7, 14, 14);
|
||||
|
||||
if (DayColumn != null)
|
||||
{
|
||||
// See if we are in the top resize area
|
||||
|
||||
if (StartTime >= DayColumn.Date)
|
||||
{
|
||||
if (r2.Contains(objArg.Location))
|
||||
return (eHitArea.TopResize);
|
||||
}
|
||||
|
||||
// See if we are in the bottom resize area
|
||||
|
||||
if (EndTime <= DayColumn.Date.AddDays(1))
|
||||
{
|
||||
r2.Y = r.Bottom - 10;
|
||||
|
||||
if (r2.Contains(objArg.Location))
|
||||
return (eHitArea.BottomResize);
|
||||
}
|
||||
}
|
||||
|
||||
// By default we are in the move area
|
||||
|
||||
return (eHitArea.Move);
|
||||
}
|
||||
|
||||
// No valid area to report
|
||||
|
||||
return (eHitArea.None);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user