DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,613 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class AllDayPanel : BaseItem
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private WeekDayView _WeekDayView; // Assoc WeekDayView
|
||||
|
||||
private List<CalendarItem> // CalendarItems list
|
||||
_CalendarItems = new List<CalendarItem>();
|
||||
|
||||
private VScrollBarAdv _VScrollBar; // Vertical scroll bar
|
||||
private int _VScrollPos; // Vertical scrollbar pos
|
||||
|
||||
private int _PanelHeight; // Panel height (current)
|
||||
private int _MaximumPanelHeight; // Panel height (max)
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="weekDayView">WeekDayView</param>
|
||||
public AllDayPanel(WeekDayView weekDayView)
|
||||
{
|
||||
// Save the provided weekDayView and
|
||||
// tell the system we are a container
|
||||
|
||||
_WeekDayView = weekDayView;
|
||||
|
||||
SetIsContainer(true);
|
||||
|
||||
SubItems.AllowParentRemove = false;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the panel bounding rectangle
|
||||
/// </summary>
|
||||
public override Rectangle Bounds
|
||||
{
|
||||
get { return (base.Bounds); }
|
||||
|
||||
set
|
||||
{
|
||||
base.Bounds = value;
|
||||
|
||||
UpdateVScrollBar();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DayPanel Height
|
||||
/// </summary>
|
||||
public int PanelHeight
|
||||
{
|
||||
get { return (_PanelHeight); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the panel's CalendarItem list
|
||||
/// </summary>
|
||||
public List<CalendarItem> CalendarItems
|
||||
{
|
||||
get { return (_CalendarItems); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets WeekDayView
|
||||
/// </summary>
|
||||
public WeekDayView WeekDayView
|
||||
{
|
||||
get { return (_WeekDayView); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private properties
|
||||
|
||||
/// <summary>
|
||||
/// gets the Fixed AllDayPanel height
|
||||
/// </summary>
|
||||
private int FixedAllDayPanelHeight
|
||||
{
|
||||
get { return (_WeekDayView.CalendarView.FixedAllDayPanelHeight); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gets the Maximum AllDayPanel height
|
||||
/// </summary>
|
||||
private int MaximumAllDayPanelHeight
|
||||
{
|
||||
get { return (_WeekDayView.CalendarView.MaximumAllDayPanelHeight); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Appointment height
|
||||
/// </summary>
|
||||
private int AppointmentPadding
|
||||
{
|
||||
get { return (6); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the width of a vertical scrollbar
|
||||
/// </summary>
|
||||
private int VsWidth
|
||||
{
|
||||
get { return (SystemInformation.VerticalScrollBarWidth); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecalcSize
|
||||
|
||||
/// <summary>
|
||||
/// Performs panel recalc support
|
||||
/// </summary>
|
||||
public override void RecalcSize()
|
||||
{
|
||||
// Reset our panel heights
|
||||
|
||||
_PanelHeight = 0;
|
||||
_MaximumPanelHeight = 0;
|
||||
|
||||
if (_CalendarItems.Count > 0)
|
||||
{
|
||||
// Sort the items
|
||||
|
||||
List<CalendarItem> items = SortCalendarItems();
|
||||
|
||||
// Go through our CalendarItems on a per column basis
|
||||
// accumulating extended appointment data
|
||||
|
||||
ulong[] acc = new ulong[DaysInWeek];
|
||||
|
||||
int maxAcc = -1;
|
||||
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
int freeAcc = CalcAppointmentBounds(items[i], acc);
|
||||
|
||||
if (freeAcc > maxAcc)
|
||||
maxAcc = freeAcc;
|
||||
}
|
||||
|
||||
// Determine our current panel height from our processed data
|
||||
|
||||
if (_WeekDayView.CalendarView.IsMultiCalendar == false)
|
||||
{
|
||||
_MaximumPanelHeight = (maxAcc + 1) * _WeekDayView.AppointmentHeight;
|
||||
|
||||
// Set out current and maximum panel heights
|
||||
|
||||
_MaximumPanelHeight += AppointmentPadding;
|
||||
_PanelHeight = _MaximumPanelHeight;
|
||||
|
||||
if (_PanelHeight > MaximumAllDayPanelHeight)
|
||||
_PanelHeight = MaximumAllDayPanelHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// Take into account the FixedAllDayPanelHeight setting
|
||||
|
||||
if (_WeekDayView.CalendarView.IsMultiCalendar == true)
|
||||
{
|
||||
_PanelHeight = (FixedAllDayPanelHeight >= 0) ? FixedAllDayPanelHeight : 50;
|
||||
_MaximumPanelHeight = _PanelHeight;
|
||||
}
|
||||
else if (FixedAllDayPanelHeight >= 0)
|
||||
{
|
||||
_PanelHeight = FixedAllDayPanelHeight;
|
||||
}
|
||||
|
||||
HeightInternal = _PanelHeight;
|
||||
|
||||
base.RecalcSize();
|
||||
}
|
||||
|
||||
#region SortCalendarItems
|
||||
|
||||
/// <summary>
|
||||
/// Sorts the CalendarItems
|
||||
/// </summary>
|
||||
private List<CalendarItem> SortCalendarItems()
|
||||
{
|
||||
List<CalendarItem> items =
|
||||
new List<CalendarItem>(_CalendarItems.Count);
|
||||
|
||||
items.AddRange(_CalendarItems);
|
||||
|
||||
items.Sort(
|
||||
|
||||
delegate(CalendarItem c1, CalendarItem c2)
|
||||
{
|
||||
if (c1.StartTime > c2.StartTime)
|
||||
return (1);
|
||||
|
||||
if (c1.StartTime < c2.StartTime)
|
||||
return (-1);
|
||||
|
||||
if (c1.EndTime > c2.EndTime)
|
||||
return (-1);
|
||||
|
||||
if (c1.EndTime < c2.EndTime)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
);
|
||||
|
||||
return (items);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcAppointmentBounds
|
||||
|
||||
const int DaysInWeek = 7;
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the display bounds for the AppointmentView
|
||||
/// </summary>
|
||||
/// <param name="item">CalendarItem</param>
|
||||
/// <param name="acc">Row accumulator</param>
|
||||
private int CalcAppointmentBounds(CalendarItem item, ulong[] acc)
|
||||
{
|
||||
// Determine the starting day index for
|
||||
// the given appointment
|
||||
|
||||
int ns = GetDayIndex(item);
|
||||
|
||||
// Calculate the top and height for the item
|
||||
|
||||
Rectangle r = _WeekDayView.DayColumns[ns].Bounds;
|
||||
|
||||
r.Width = 0;
|
||||
|
||||
r.Y = _WeekDayView.ClientRect.Y + _WeekDayView.DayOfWeekHeaderHeight + _VScrollPos + 2;
|
||||
r.Height = _WeekDayView.AppointmentHeight;
|
||||
|
||||
int maxAcc = -1;
|
||||
|
||||
// Determine the ending day index
|
||||
|
||||
DateTime st = _WeekDayView.DayColumns[ns].Date;
|
||||
|
||||
int ne = ns + (item.EndTime - st).Days;
|
||||
|
||||
if (item.EndTime.Hour > 0 || item.EndTime.Minute > 0 || item.EndTime.Second > 0)
|
||||
ne++;
|
||||
|
||||
if (ne > DaysInWeek)
|
||||
ne = DaysInWeek;
|
||||
|
||||
int freeAcc = GetFreeAcc(ns, ne, acc);
|
||||
|
||||
if (freeAcc >= 0)
|
||||
{
|
||||
ulong u = (1ul << freeAcc);
|
||||
|
||||
for (int i = ns; i < ne; i++)
|
||||
{
|
||||
if (i < _WeekDayView.NumberOfColumns)
|
||||
r.Width += _WeekDayView.DayColumns[i].Bounds.Width;
|
||||
|
||||
acc[i] |= u;
|
||||
}
|
||||
|
||||
r.Y += (freeAcc * _WeekDayView.AppointmentHeight);
|
||||
|
||||
if (freeAcc > maxAcc)
|
||||
maxAcc = freeAcc;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.Y = _WeekDayView.DayColumns[0].Bounds.Bottom;
|
||||
}
|
||||
|
||||
DateTime start = _WeekDayView.DayColumns[0].Date;
|
||||
DateTime end = _WeekDayView.DayColumns[_WeekDayView.DayColumns.Length - 1].Date;
|
||||
|
||||
// Check to see if we can only display
|
||||
// a partial representation for the view
|
||||
|
||||
if (item.EndTime >= start && item.StartTime < end)
|
||||
{
|
||||
int hpad = 4;
|
||||
|
||||
if (item.StartTime >= start)
|
||||
{
|
||||
r.X += hpad;
|
||||
r.Width -= hpad;
|
||||
}
|
||||
|
||||
if (item.EndTime <= end)
|
||||
r.Width -= hpad;
|
||||
}
|
||||
|
||||
// Now that we have calculated the items height and
|
||||
// width, invoke a Recalc on the item
|
||||
|
||||
item.WidthInternal = r.Width;
|
||||
item.HeightInternal = r.Height - 1;
|
||||
|
||||
item.RecalcSize();
|
||||
|
||||
// Set our bounds for the item
|
||||
|
||||
r.Width = item.WidthInternal;
|
||||
r.Height = item.HeightInternal;
|
||||
|
||||
item.Bounds = r;
|
||||
|
||||
// Set it's display state
|
||||
|
||||
item.Displayed = true;
|
||||
|
||||
return (maxAcc);
|
||||
}
|
||||
|
||||
#region GetFreeAcc
|
||||
|
||||
private int GetFreeAcc(int ns, int ne, ulong[] acc)
|
||||
{
|
||||
for (int i = 0; i < sizeof(ulong) * 8; i++)
|
||||
{
|
||||
if (CheckFreeAcc(ns, ne, acc, i) == true)
|
||||
return (i);
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#region CheckFreeAcc
|
||||
|
||||
private bool CheckFreeAcc(int ns, int ne, ulong[] acc, int n)
|
||||
{
|
||||
for (int i = ns; i < ne; i++)
|
||||
{
|
||||
ulong u = acc[i];
|
||||
|
||||
if ((u & (1ul << n)) != 0)
|
||||
return (false);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDayIndex
|
||||
|
||||
/// <summary>
|
||||
/// Gets the starting day index for the given appointment
|
||||
/// </summary>
|
||||
/// <returns>Day of week index (0-6)</returns>
|
||||
private int GetDayIndex(CalendarItem item)
|
||||
{
|
||||
DateTime date = _WeekDayView.DayColumns[0].Date;
|
||||
|
||||
for (int i = 0; i < _WeekDayView.DayColumns.Length; i++)
|
||||
{
|
||||
date = date.AddDays(1);
|
||||
|
||||
if (date > item.StartTime)
|
||||
return (i);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Scrollbar routines
|
||||
|
||||
#region UpdateVScrollBar
|
||||
|
||||
/// <summary>
|
||||
/// Updates our vertical scrollbar
|
||||
/// </summary>
|
||||
private void UpdateVScrollBar()
|
||||
{
|
||||
if (_PanelHeight > 0 && _PanelHeight < _MaximumPanelHeight)
|
||||
{
|
||||
// If we don't have one already, allocate it
|
||||
|
||||
if (_VScrollBar == null)
|
||||
{
|
||||
_VScrollBar = new VScrollBarAdv();
|
||||
_VScrollBar.Width = VsWidth;
|
||||
|
||||
Control c = (Control)this.GetContainerControl(true);
|
||||
|
||||
if (c != null)
|
||||
c.Controls.Add(_VScrollBar);
|
||||
|
||||
_VScrollBar.ValueChanged += _VExtScrollBar_ValueChanged;
|
||||
}
|
||||
|
||||
// Initialize the scrollbar
|
||||
|
||||
_VScrollBar.Location = new Point(Bounds.Right + 1, Bounds.Y);
|
||||
_VScrollBar.Height = _PanelHeight;
|
||||
|
||||
_VScrollBar.SmallChange = _PanelHeight / 2;
|
||||
_VScrollBar.LargeChange = _WeekDayView.AppointmentHeight * 2;
|
||||
|
||||
_VScrollBar.Maximum = _MaximumPanelHeight -
|
||||
_VScrollBar.Height + _VScrollBar.LargeChange;
|
||||
|
||||
if (_VScrollBar.Visible == false)
|
||||
{
|
||||
_VScrollPos = 0;
|
||||
_VScrollBar.Value = 0;
|
||||
|
||||
_VScrollBar.Show();
|
||||
_VScrollBar.BringToFront();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_VScrollBar.Value > _VScrollBar.Maximum - _VScrollBar.LargeChange)
|
||||
_VScrollBar.Value = _VScrollBar.Maximum - _VScrollBar.LargeChange;
|
||||
}
|
||||
|
||||
_VScrollBar.Refresh();
|
||||
}
|
||||
else if (_VScrollBar != null)
|
||||
{
|
||||
_VScrollPos = 0;
|
||||
|
||||
_VScrollBar.ValueChanged -= _VExtScrollBar_ValueChanged;
|
||||
|
||||
_VScrollBar.Dispose();
|
||||
_VScrollBar = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region _VExtScrollBar_ValueChanged
|
||||
|
||||
/// <summary>
|
||||
/// Processes Extended appointments scrollBar changes
|
||||
/// </summary>
|
||||
/// <param name="sender">object</param>
|
||||
/// <param name="e">EventArgs</param>
|
||||
void _VExtScrollBar_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
int vdelta = -_VScrollBar.Value - _VScrollPos;
|
||||
|
||||
if (vdelta != 0)
|
||||
{
|
||||
_VScrollPos = -_VScrollBar.Value;
|
||||
|
||||
// Now that we have calculated the items height and
|
||||
// width, invoke a Recalc on the item
|
||||
|
||||
for (int i = 0; i < _CalendarItems.Count; i++)
|
||||
{
|
||||
CalendarItem item = _CalendarItems[i];
|
||||
|
||||
Rectangle r = item.Bounds;
|
||||
r.Y += vdelta;
|
||||
|
||||
item.Bounds = r;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Reset / update view
|
||||
|
||||
/// <summary>
|
||||
/// Resets the AllDayPanel view
|
||||
/// </summary>
|
||||
public void ResetView()
|
||||
{
|
||||
_VScrollPos = 0;
|
||||
|
||||
if (_VScrollBar != null)
|
||||
{
|
||||
_VScrollBar.ValueChanged -= _VExtScrollBar_ValueChanged;
|
||||
_VScrollBar.Dispose();
|
||||
_VScrollBar = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the AllDayPanel view
|
||||
/// </summary>
|
||||
public void UpdateView()
|
||||
{
|
||||
if (_WeekDayView.IsViewSelected == true)
|
||||
{
|
||||
if (_VScrollBar != null)
|
||||
_VScrollBar.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_VScrollBar != null)
|
||||
_VScrollBar.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint processing
|
||||
|
||||
/// <summary>
|
||||
/// Draws extended appointments
|
||||
/// </summary>
|
||||
/// <param name="e">ItemPaintArgs</param>
|
||||
public override void Paint(ItemPaintArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
if (e.ClipRectangle.IntersectsWith(Bounds))
|
||||
{
|
||||
Region regSave = g.Clip;
|
||||
g.SetClip(Bounds, CombineMode.Intersect);
|
||||
|
||||
using (Brush br =
|
||||
_WeekDayView.WeekDayColor.BrushPart(
|
||||
(int) eCalendarWeekDayPart.DayAllDayEventBackground, Bounds))
|
||||
{
|
||||
g.FillRectangle(br, Bounds);
|
||||
}
|
||||
|
||||
using (Pen pen = new Pen(
|
||||
_WeekDayView.WeekDayColor.GetColor((int) eCalendarWeekDayPart.DayViewBorder)))
|
||||
{
|
||||
g.DrawLine(pen, Bounds.X, Bounds.Y, Bounds.X, Bounds.Bottom);
|
||||
g.DrawLine(pen, Bounds.Right - 1, Bounds.Y, Bounds.Right - 1, Bounds.Bottom);
|
||||
}
|
||||
|
||||
// Loop through each day in each week, displaying
|
||||
// the associated day content
|
||||
|
||||
int selItem = -1;
|
||||
|
||||
for (int i = 0; i < _CalendarItems.Count; i++)
|
||||
{
|
||||
// Initiate the paint
|
||||
|
||||
if (_CalendarItems[i].Displayed == true)
|
||||
{
|
||||
if (_CalendarItems[i].IsSelected == true)
|
||||
selItem = i;
|
||||
else
|
||||
_CalendarItems[i].Paint(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (selItem >= 0)
|
||||
_CalendarItems[selItem].Paint(e);
|
||||
|
||||
// Restore the original clip region
|
||||
|
||||
g.Clip = regSave;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy implementation
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of the item.
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
AllDayPanel objCopy = new AllDayPanel(WeekDayView);
|
||||
CopyToItem(objCopy);
|
||||
|
||||
return (objCopy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the AllDayPanel specific properties to new instance of the item.
|
||||
/// </summary>
|
||||
/// <param name="copy">New AllDayPanel instance</param>
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
AllDayPanel objCopy = copy as AllDayPanel;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,319 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DevComponents.Schedule.Model;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class ColumnList
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private List<List<SlotItem>> _SList = new List<List<SlotItem>>();
|
||||
private int _Id;
|
||||
|
||||
#endregion
|
||||
|
||||
public ColumnList()
|
||||
{
|
||||
}
|
||||
|
||||
public ColumnList(int id)
|
||||
{
|
||||
_Id = id;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the column slot Id
|
||||
/// </summary>
|
||||
public int Id
|
||||
{
|
||||
get { return (_Id); }
|
||||
set { _Id = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the column slot list
|
||||
/// </summary>
|
||||
public List<List<SlotItem>> SList
|
||||
{
|
||||
get { return (_SList); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
#region AddColumnSlot
|
||||
|
||||
/// <summary>
|
||||
/// Adds a CalendarItem to the running slot list
|
||||
/// </summary>
|
||||
/// <param name="item">CalendarItem to add</param>
|
||||
/// <param name="n">Slot level to add the item to</param>
|
||||
/// <returns>The added slot item</returns>
|
||||
public SlotItem AddColumnSlot(CalendarItem item, int n)
|
||||
{
|
||||
// Add a new SlotItem list if we have exceeded
|
||||
// the current list count
|
||||
|
||||
if (n >= _SList.Count)
|
||||
_SList.Add(new List<SlotItem>());
|
||||
|
||||
// Determine whether this item can fit in the
|
||||
// the slot list at the current level
|
||||
|
||||
SlotItem si = GetColumnSlot(item, n);
|
||||
|
||||
if (si != null)
|
||||
{
|
||||
// The item won't fit, so allocate a new slot
|
||||
// item and add it to the list
|
||||
|
||||
si.AddPeerSlot(
|
||||
AddColumnSlot(item, n + 1), n + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The item will fit, so add it to the list
|
||||
|
||||
si = new SlotItem(item);
|
||||
|
||||
_SList[n].Add(si);
|
||||
|
||||
// Look ahead to see it we have a peer slot
|
||||
// in a future slot list
|
||||
|
||||
while (n + 1 < _SList.Count)
|
||||
{
|
||||
n++;
|
||||
|
||||
SlotItem ni = GetColumnSlot(item, n);
|
||||
|
||||
if (ni != null)
|
||||
{
|
||||
si.AddPeerSlot(ni, n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the added slot item
|
||||
|
||||
return (si);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the SlotItem (if present) in the given list for
|
||||
/// the CalendarItem in question
|
||||
/// </summary>
|
||||
/// <param name="item">CalendarItem</param>
|
||||
/// <param name="n">Slot level to scan</param>
|
||||
/// <returns>SlotItem, if found</returns>
|
||||
private SlotItem GetColumnSlot(CalendarItem item, int n)
|
||||
{
|
||||
if (n < _SList.Count)
|
||||
{
|
||||
// Loop through each SlotItem at the given
|
||||
// level, looking for an intersection with the
|
||||
// given CalendarItem
|
||||
|
||||
List<SlotItem> list = _SList[n];
|
||||
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
SlotItem si = list[i];
|
||||
|
||||
DateTime start = item.StartTime > si.CItem.StartTime ? item.StartTime : si.CItem.StartTime;
|
||||
DateTime end = item.EndTime < si.CItem.EndTime ? item.EndTime : si.CItem.EndTime;
|
||||
|
||||
// If we found an item, return it
|
||||
|
||||
if ((start < end) ||
|
||||
(start <= end && ( item.StartTime == item.EndTime || si.CItem.StartTime == si.CItem.EndTime)))
|
||||
return (si);
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing currently at that slot
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CountColumns
|
||||
|
||||
/// <summary>
|
||||
/// Counts the number of columns for
|
||||
/// each column zero entry slot lists
|
||||
/// </summary>
|
||||
public void CountColumns()
|
||||
{
|
||||
if (_SList.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < _SList[0].Count; i++)
|
||||
{
|
||||
SlotItem si = _SList[0][i];
|
||||
|
||||
SetColumnCount(si, GetColumnCount(si, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the max column count from all
|
||||
/// zero level slot paths
|
||||
/// </summary>
|
||||
/// <param name="si">Initial SlotItem</param>
|
||||
/// <param name="count">Running level count</param>
|
||||
/// <returns></returns>
|
||||
private int GetColumnCount(SlotItem si, int count)
|
||||
{
|
||||
if (si.Count > 0)
|
||||
return (si.Count);
|
||||
|
||||
int maxCount = count;
|
||||
|
||||
if (si.SList != null)
|
||||
{
|
||||
for (int i = 0; i < si.SList.Count; i++)
|
||||
{
|
||||
int c = GetColumnCount(si.SList[i], count + 1);
|
||||
|
||||
if (c > maxCount)
|
||||
maxCount = c;
|
||||
}
|
||||
}
|
||||
|
||||
return (maxCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets all column entry counts to the given
|
||||
/// count
|
||||
/// </summary>
|
||||
/// <param name="si">Initial SlotItem</param>
|
||||
/// <param name="count">Count</param>
|
||||
private void SetColumnCount(SlotItem si, int count)
|
||||
{
|
||||
if (si.SList != null)
|
||||
{
|
||||
for (int i = 0; i < si.SList.Count; i++)
|
||||
SetColumnCount(si.SList[i], count);
|
||||
}
|
||||
|
||||
if (si.Count == 0)
|
||||
si.Count = count;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clear
|
||||
|
||||
/// <summary>
|
||||
/// Clears the Column slot list
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
_SList.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region SlotItem class definition
|
||||
|
||||
public class SlotItem
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private CalendarItem _CItem; // CalendarItem
|
||||
private List<SlotItem> _SList; // List of peer SlotItems
|
||||
private int _Count; // Count of peer items
|
||||
private int _Column;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="cItem">CalendarItem</param>
|
||||
public SlotItem(CalendarItem cItem)
|
||||
{
|
||||
_CItem = cItem;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the slots CalendarItem
|
||||
/// </summary>
|
||||
public CalendarItem CItem
|
||||
{
|
||||
get { return (_CItem); }
|
||||
set { _CItem = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the peer SlotItem list
|
||||
/// </summary>
|
||||
public List<SlotItem> SList
|
||||
{
|
||||
get { return (_SList); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the peer level count
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get { return (_Count); }
|
||||
set { _Count = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the peer column
|
||||
/// </summary>
|
||||
public int Column
|
||||
{
|
||||
get { return (_Column); }
|
||||
set { _Column = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
/// <summary>
|
||||
/// Adds a slot to the peer SlotItem list
|
||||
/// </summary>
|
||||
/// <param name="si">SlotItem to add</param>
|
||||
/// <param name="column">Slot column</param>
|
||||
public void AddPeerSlot(SlotItem si, int column)
|
||||
{
|
||||
if (si != null)
|
||||
{
|
||||
if (_SList == null)
|
||||
_SList = new List<SlotItem>();
|
||||
|
||||
if (_SList.Contains(si) == false)
|
||||
{
|
||||
si.Column = column;
|
||||
|
||||
_SList.Add(si);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,212 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using DevComponents.Schedule.Model;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class DayColumn
|
||||
{
|
||||
#region Consts
|
||||
|
||||
public const int NumberOfTimeSlices = 48;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private Rectangle _Bounds; // Slot bounding rectangle
|
||||
|
||||
private DateTime _Date; // Column date
|
||||
|
||||
private float _TimeSliceHeight; // TimeSlice height
|
||||
|
||||
private WorkTime _BusyStartTime; // Busy time
|
||||
private WorkTime _BusyEndTime;
|
||||
|
||||
private WorkTime _WorkStartTime; // Work time
|
||||
private WorkTime _WorkEndTime;
|
||||
|
||||
private List<CalendarItem> // Column CalendarItems
|
||||
_CalendarItems = new List<CalendarItem>();
|
||||
|
||||
private bool _NeedRecalcLayout = true;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="timeSliceHeight">Slice height</param>
|
||||
public DayColumn(float timeSliceHeight)
|
||||
{
|
||||
_TimeSliceHeight = timeSliceHeight;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region BoundingRect
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the week bounding Rectangle
|
||||
/// </summary>
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get { return (_Bounds); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Bounds.Equals(value) == false)
|
||||
{
|
||||
int yOffset = value.Y - _Bounds.Y;
|
||||
|
||||
_Bounds = value;
|
||||
|
||||
if (yOffset != 0)
|
||||
OffsetItemRects(yOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Offsets the bounding rectangles for the
|
||||
/// DayColumn's non-extended appointments
|
||||
/// </summary>
|
||||
/// <param name="yOffset">Amount to offset</param>
|
||||
private void OffsetItemRects(int yOffset)
|
||||
{
|
||||
for (int i = 0; i < _CalendarItems.Count; i++)
|
||||
{
|
||||
Rectangle r = _CalendarItems[i].Bounds;
|
||||
|
||||
r.Y += yOffset;
|
||||
|
||||
_CalendarItems[i].Bounds = r;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Date
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the column date
|
||||
/// </summary>
|
||||
public DateTime Date
|
||||
{
|
||||
get { return (_Date); }
|
||||
set { _Date = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TimeSliceHeight
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the TimeSlice height
|
||||
/// </summary>
|
||||
public float TimeSliceHeight
|
||||
{
|
||||
get { return (_TimeSliceHeight); }
|
||||
set { _TimeSliceHeight = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WorkTime properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the busy time start
|
||||
/// </summary>
|
||||
public WorkTime BusyStartTime
|
||||
{
|
||||
get { return (_BusyStartTime); }
|
||||
set { _BusyStartTime = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the busy time end
|
||||
/// </summary>
|
||||
public WorkTime BusyEndTime
|
||||
{
|
||||
get { return (_BusyEndTime); }
|
||||
set { _BusyEndTime = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the work time start
|
||||
/// </summary>
|
||||
public WorkTime WorkStartTime
|
||||
{
|
||||
get { return (_WorkStartTime); }
|
||||
set { _WorkStartTime = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the work time end
|
||||
/// </summary>
|
||||
public WorkTime WorkEndTime
|
||||
{
|
||||
get { return (_WorkEndTime); }
|
||||
set { _WorkEndTime = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalendarItems
|
||||
|
||||
/// <summary>
|
||||
/// Gets the column CalendarItems list
|
||||
/// </summary>
|
||||
public List<CalendarItem> CalendarItems
|
||||
{
|
||||
get { return (_CalendarItems); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NeedRecalcLayout
|
||||
|
||||
public bool NeedRecalcLayout
|
||||
{
|
||||
get { return (_NeedRecalcLayout); }
|
||||
set { _NeedRecalcLayout = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public methods
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the given time is tagged as a "Busy time"
|
||||
/// </summary>
|
||||
/// <param name="time">WorkTime to test</param>
|
||||
/// <returns>true if specified "time" is a Busy time</returns>
|
||||
public bool IsBusyTime(WorkTime time)
|
||||
{
|
||||
return ((!BusyStartTime.IsEmpty && !BusyEndTime.IsEmpty) &&
|
||||
(time >= BusyStartTime && time < BusyEndTime));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the given time is tagged as a "Work time"
|
||||
/// </summary>
|
||||
/// <param name="time">WorkTime to test</param>
|
||||
/// <returns>true if specified "time" is a Work time</returns>
|
||||
public bool IsWorkTime(WorkTime time)
|
||||
{
|
||||
if (WorkStartTime <= WorkEndTime)
|
||||
return (time >= WorkStartTime && time < WorkEndTime);
|
||||
|
||||
return (time < WorkEndTime || time >= WorkStartTime);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,44 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class DayView : WeekDayView
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="calendarView"></param>
|
||||
public DayView(CalendarView calendarView)
|
||||
: base(calendarView, eCalendarView.Day)
|
||||
{
|
||||
}
|
||||
|
||||
#region RecalcSize support
|
||||
|
||||
/// <summary>
|
||||
/// Normalizes the user specified start and end dates
|
||||
/// </summary>
|
||||
/// <param name="startDate">[out] Normalized start date</param>
|
||||
/// <param name="endDate">[out] Normalized end date</param>
|
||||
protected override void NormalizeDates(out DateTime startDate, out DateTime endDate)
|
||||
{
|
||||
startDate = this.StartDate;
|
||||
|
||||
// If both values are unset, then set them to
|
||||
// today's date
|
||||
|
||||
if (startDate == DateTime.MinValue)
|
||||
startDate = DateTime.Today.Date;
|
||||
|
||||
endDate = startDate;
|
||||
|
||||
DaysOfTheWeek = new DaysOfTheWeek(startDate.DayOfWeek, 1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,986 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DevComponents.Schedule.Model;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
internal class ModelWeekDayViewConnector : ModelViewConnector
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private CalendarModel _Model; // The associated CalendarModel
|
||||
private WeekDayView _View; // The associated WeekDayView
|
||||
|
||||
private bool _IsConnected; // Connection status
|
||||
private uint _RefreshCount;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="model">Assoc CalendarModel</param>
|
||||
/// <param name="weekDayView">Assoc WeekDayView</param>
|
||||
public ModelWeekDayViewConnector(CalendarModel model, WeekDayView weekDayView)
|
||||
{
|
||||
_Model = model;
|
||||
_View = weekDayView;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the connection status
|
||||
/// </summary>
|
||||
public override bool IsConnected
|
||||
{
|
||||
get { return (_IsConnected); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Connect processing
|
||||
|
||||
/// <summary>
|
||||
/// Performs Model connection processing
|
||||
/// </summary>
|
||||
public override void Connect()
|
||||
{
|
||||
VerifyModel();
|
||||
|
||||
if (_IsConnected)
|
||||
Disconnect();
|
||||
|
||||
LoadData();
|
||||
|
||||
// Get notification on Model property changes
|
||||
|
||||
_Model.PropertyChanged += ModelPropertyChanged;
|
||||
_Model.SubPropertyChanged += ModelSubPropertyChanged;
|
||||
|
||||
_View.CalendarView.CustomItems.CollectionChanged +=
|
||||
CustomItemsCollectionChanged;
|
||||
|
||||
_IsConnected = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Disconnect processing
|
||||
|
||||
/// <summary>
|
||||
/// Severs the Model/WeekDayView connection
|
||||
/// </summary>
|
||||
public override void Disconnect()
|
||||
{
|
||||
VerifyModel();
|
||||
|
||||
if (_IsConnected)
|
||||
{
|
||||
// Clear all AllDayPanel items
|
||||
|
||||
ClearAllDayPanelItems();
|
||||
|
||||
// Loop through each DayColumn, clearing each
|
||||
// associated view connection
|
||||
|
||||
for (int i = 0; i < _View.DayColumns.Length; i++)
|
||||
ClearWeekDayColumn(_View.DayColumns[i]);
|
||||
|
||||
_View.SubItems.Clear();
|
||||
|
||||
// Stop notification on Model property changes
|
||||
|
||||
_Model.PropertyChanged -= ModelPropertyChanged;
|
||||
_Model.SubPropertyChanged -= ModelSubPropertyChanged;
|
||||
|
||||
_View.CalendarView.CustomItems.CollectionChanged -=
|
||||
CustomItemsCollectionChanged;
|
||||
|
||||
_IsConnected = false;
|
||||
|
||||
OnSubItemsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#region ClearAllDayPanelItems
|
||||
|
||||
private void ClearAllDayPanelItems()
|
||||
{
|
||||
List<CalendarItem> items = _View.AllDayPanel.CalendarItems;
|
||||
|
||||
for (int i = items.Count - 1; i >= 0; i--)
|
||||
{
|
||||
AppointmentWeekDayView view = items[i] as AppointmentWeekDayView;
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
view.IsSelectedChanged -= _View.ItemIsSelectedChanged;
|
||||
|
||||
view.Appointment = null;
|
||||
view.IsSelected = false;
|
||||
view.AllDayPanel = null;
|
||||
}
|
||||
|
||||
items.RemoveAt(i);
|
||||
}
|
||||
|
||||
_View.AllDayPanel.SubItems.Clear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ClearWeekDayColumn
|
||||
|
||||
/// <summary>
|
||||
/// Clears individual DayColumn view connections
|
||||
/// </summary>
|
||||
/// <param name="dayColumn">DayColumn</param>
|
||||
private void ClearWeekDayColumn(DayColumn dayColumn)
|
||||
{
|
||||
if (dayColumn.CalendarItems.Count > 0)
|
||||
{
|
||||
// Loop through each CalendarItem, resetting
|
||||
// it's associated connection
|
||||
|
||||
for (int i = dayColumn.CalendarItems.Count - 1; i >= 0; i--)
|
||||
{
|
||||
AppointmentWeekDayView view =
|
||||
dayColumn.CalendarItems[i] as AppointmentWeekDayView;
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
view.IsSelectedChanged -= _View.ItemIsSelectedChanged;
|
||||
|
||||
view.Appointment = null;
|
||||
view.IsSelected = false;
|
||||
view.DayColumn = null;
|
||||
}
|
||||
|
||||
dayColumn.CalendarItems.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadData processing
|
||||
|
||||
/// <summary>
|
||||
/// Loads Model/WeekDayView connection data
|
||||
/// </summary>
|
||||
private void LoadData()
|
||||
{
|
||||
DayColumn[] dcs = _View.DayColumns;
|
||||
|
||||
if (dcs.Length > 0)
|
||||
{
|
||||
_RefreshCount++;
|
||||
|
||||
DateTime startDate = dcs[0].Date;
|
||||
DateTime endDate = DateTimeHelper.EndOfDay(dcs[dcs.Length - 1].Date);
|
||||
|
||||
DateTime appStartDate = startDate.AddMonths(-1);
|
||||
|
||||
List<Appointment> appts = GetAppointmentList(_Model, appStartDate, endDate);
|
||||
|
||||
for (int i = 0; i < dcs.Length; i++)
|
||||
{
|
||||
DayColumn dc = dcs[i];
|
||||
|
||||
UpdateColumnAppts(dc, appts);
|
||||
UpdateCustomItems(dc);
|
||||
}
|
||||
|
||||
UpdateAllDayPanelView(appts, startDate, endDate);
|
||||
UpdateAllDayPanelCustomItems();
|
||||
|
||||
OnSubItemsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#region UpdateColumnAppts
|
||||
|
||||
private void UpdateColumnAppts(DayColumn dayColumn, List<Appointment> appointments)
|
||||
{
|
||||
foreach (Appointment app in appointments)
|
||||
{
|
||||
DateTime date = dayColumn.Date.Date;
|
||||
|
||||
if (date >= app.StartTime.Date && date <= app.EndTime.Date)
|
||||
{
|
||||
if (IsAppointmentVisible(app))
|
||||
{
|
||||
// Get the assoc view
|
||||
|
||||
if (_View.IsAllDayItem(app) == false)
|
||||
{
|
||||
AppointmentWeekDayView view = GetViewFromColumn(dayColumn, app, false) ??
|
||||
GetViewFromAllDayPanel(app, true) ??
|
||||
GetNewView(app);
|
||||
|
||||
if (view.StartTime != app.StartTime || view.EndTime != app.EndTime)
|
||||
dayColumn.NeedRecalcLayout = true;
|
||||
|
||||
// Set the view start and end times to
|
||||
// match the assoc appointment
|
||||
|
||||
view.StartTime = app.StartTime;
|
||||
view.EndTime = app.EndTime;
|
||||
|
||||
view.RefreshCount = _RefreshCount;
|
||||
|
||||
// Update the DayColumn data
|
||||
|
||||
if (view.DayColumn == null)
|
||||
{
|
||||
view.DayColumn = dayColumn;
|
||||
|
||||
dayColumn.CalendarItems.Add(view);
|
||||
dayColumn.NeedRecalcLayout = true;
|
||||
|
||||
_View.SubItems.Add(view);
|
||||
_View.UpdateItemOrder(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update workDay details
|
||||
|
||||
UpdateWorkDayDetails(dayColumn);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateCustomItems
|
||||
|
||||
private void UpdateCustomItems(DayColumn dayColumn)
|
||||
{
|
||||
CustomCalendarItemCollection items = _View.CalendarView.CustomItems;
|
||||
|
||||
if (items != null)
|
||||
{
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
CustomCalendarItem item = items[i];
|
||||
|
||||
if (IsCustomItemVisible(item) == true && _View.IsAllDayItem(item) == false &&
|
||||
(item.StartTime < dayColumn.Date.AddDays(1) && item.EndTime > dayColumn.Date))
|
||||
{
|
||||
item.CalendarView = _View.CalendarView;
|
||||
|
||||
CustomCalendarItem ci = GetItemFromColumn(dayColumn, item, false);
|
||||
|
||||
if (ci == null)
|
||||
{
|
||||
ci = GetItemFromAllDayPanel(item, true) ?? GetNewCustomItem(item);
|
||||
|
||||
dayColumn.CalendarItems.Add(ci);
|
||||
dayColumn.NeedRecalcLayout = true;
|
||||
|
||||
_View.SubItems.Add(ci);
|
||||
_View.UpdateItemOrder(ci);
|
||||
}
|
||||
|
||||
ci.StartTime = item.StartTime;
|
||||
ci.EndTime = item.EndTime;
|
||||
|
||||
ci.RefreshCount = _RefreshCount;
|
||||
|
||||
dayColumn.NeedRecalcLayout = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RefreshData processing
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the data in a previously established
|
||||
/// and loaded connection
|
||||
/// </summary>
|
||||
public void RefreshData()
|
||||
{
|
||||
CalendarItem selItem = _View.SelectedItem;
|
||||
|
||||
LoadData();
|
||||
|
||||
List<CalendarItem> removedViews = null;
|
||||
|
||||
foreach (DayColumn dc in _View.DayColumns)
|
||||
RemoveOutdatedViews(dc, ref removedViews);
|
||||
|
||||
RemoveOutdatedAllDayViews(ref removedViews);
|
||||
|
||||
ProcessRemovedData(removedViews);
|
||||
|
||||
if (selItem != null)
|
||||
{
|
||||
selItem.IsSelected = false;
|
||||
selItem.IsSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
#region RemoveOutdatedViews
|
||||
|
||||
private void RemoveOutdatedViews(
|
||||
DayColumn dayColumn, ref List<CalendarItem> removedViews)
|
||||
{
|
||||
for (int i = dayColumn.CalendarItems.Count - 1; i >= 0; i--)
|
||||
{
|
||||
CalendarItem view = dayColumn.CalendarItems[i];
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
if (view.RefreshCount != _RefreshCount)
|
||||
{
|
||||
if (removedViews == null)
|
||||
removedViews = new List<CalendarItem>();
|
||||
|
||||
removedViews.Add(view);
|
||||
|
||||
_View.SubItems._Remove(view);
|
||||
_View.NeedRecalcSize = true;
|
||||
|
||||
dayColumn.CalendarItems.Remove(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RemoveOutdatedAllDayViews
|
||||
|
||||
private void RemoveOutdatedAllDayViews(ref List<CalendarItem> removedViews)
|
||||
{
|
||||
for (int i = _View.AllDayPanel.CalendarItems.Count - 1; i >= 0; i--)
|
||||
{
|
||||
CalendarItem view =
|
||||
_View.AllDayPanel.CalendarItems[i] as CalendarItem;
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
if (view.RefreshCount != _RefreshCount ||
|
||||
_View.IsAllDayItem(view) == false)
|
||||
{
|
||||
if (removedViews == null)
|
||||
removedViews = new List<CalendarItem>();
|
||||
|
||||
removedViews.Add(view);
|
||||
|
||||
_View.AllDayPanel.CalendarItems.RemoveAt(i);
|
||||
_View.AllDayPanel.SubItems.Remove(view);
|
||||
|
||||
_View.NeedRecalcLayout = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessRemovedData
|
||||
|
||||
private void ProcessRemovedData(List<CalendarItem> removedViews)
|
||||
{
|
||||
if (removedViews != null && removedViews.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < removedViews.Count; i++)
|
||||
{
|
||||
CalendarItem item = removedViews[i];
|
||||
|
||||
item.IsSelectedChanged -= _View.ItemIsSelectedChanged;
|
||||
|
||||
item.Dispose();
|
||||
}
|
||||
|
||||
_View.NeedRecalcLayout = true;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateAllDayPanelView
|
||||
|
||||
private void UpdateAllDayPanelView(
|
||||
List<Appointment> appts, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
// Loop through each appointment
|
||||
// updating the assoc view accordingly
|
||||
|
||||
foreach (Appointment app in appts)
|
||||
{
|
||||
if (app.StartTime < endDate && app.EndTime > startDate)
|
||||
{
|
||||
if (IsAppointmentVisible(app))
|
||||
{
|
||||
// Get the assoc view
|
||||
|
||||
if (_View.IsAllDayItem(app) == true)
|
||||
{
|
||||
AppointmentWeekDayView view =
|
||||
GetViewFromAllColumns(app, true) ??
|
||||
GetViewFromAllDayPanel(app, false) ??
|
||||
GetNewView(app);
|
||||
|
||||
// Set the view start and end times to
|
||||
// match the assoc appointment
|
||||
|
||||
view.StartTime = app.StartTime;
|
||||
view.EndTime = app.EndTime;
|
||||
|
||||
view.RefreshCount = _RefreshCount;
|
||||
|
||||
if (view.AllDayPanel == null)
|
||||
{
|
||||
view.AllDayPanel = _View.AllDayPanel;
|
||||
|
||||
_View.AllDayPanel.CalendarItems.Add(view);
|
||||
_View.AllDayPanel.SubItems.Add(view);
|
||||
|
||||
_View.NeedRecalcLayout = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateAllDayPanelCustomItems
|
||||
|
||||
private void UpdateAllDayPanelCustomItems()
|
||||
{
|
||||
CustomCalendarItemCollection items = _View.CalendarView.CustomItems;
|
||||
|
||||
if (items != null)
|
||||
{
|
||||
DateTime startDate = _View.StartDate;
|
||||
DateTime endDate = _View.EndDate.AddDays(1);
|
||||
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
{
|
||||
CustomCalendarItem item = items[i];
|
||||
|
||||
if (IsCustomItemVisible(item) == true && _View.IsAllDayItem(item) == true &&
|
||||
(item.StartTime < endDate && item.EndTime > startDate))
|
||||
{
|
||||
item.CalendarView = _View.CalendarView;
|
||||
|
||||
CustomCalendarItem ci = GetItemFromAllDayPanel(item, false);
|
||||
|
||||
if (ci == null)
|
||||
{
|
||||
ci = GetItemFromAllColumns(item, true);
|
||||
|
||||
if (ci == null)
|
||||
ci = GetNewCustomItem(item);
|
||||
|
||||
_View.AllDayPanel.CalendarItems.Add(ci);
|
||||
_View.NeedRecalcLayout = true;
|
||||
|
||||
_View.AllDayPanel.SubItems.Add(ci);
|
||||
}
|
||||
|
||||
if (ci.StartTime != item.StartTime || ci.EndTime != item.EndTime)
|
||||
{
|
||||
ci.StartTime = item.StartTime;
|
||||
ci.EndTime = item.EndTime;
|
||||
|
||||
_View.NeedRecalcLayout = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateWorkDayDetails
|
||||
|
||||
/// <summary>
|
||||
/// Updates DayColumn workday details
|
||||
/// </summary>
|
||||
/// <param name="dayColumn">DayColumn to update</param>
|
||||
private void UpdateWorkDayDetails(DayColumn dayColumn)
|
||||
{
|
||||
// Update workDay timings
|
||||
|
||||
Owner owner = _Model.Owners[_View.OwnerKey];
|
||||
|
||||
if (owner == null || GetCalendarWorkDays(dayColumn, owner.CalendarWorkDays) == false)
|
||||
{
|
||||
if (GetCalendarWorkDays(dayColumn, _Model.CalendarWorkDays) == false)
|
||||
{
|
||||
if (owner == null || GetWorkDays(dayColumn, owner.WorkDays) == false)
|
||||
{
|
||||
if (GetWorkDays(dayColumn, _Model.WorkDays) == false)
|
||||
{
|
||||
dayColumn.WorkStartTime = new WorkTime();
|
||||
dayColumn.WorkEndTime = new WorkTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region GetCalendarWorkDays
|
||||
|
||||
/// <summary>
|
||||
/// GetCalendarWorkDays
|
||||
/// </summary>
|
||||
/// <param name="dayColumn"></param>
|
||||
/// <param name="calendarWorkDays"></param>
|
||||
/// <returns></returns>
|
||||
private bool GetCalendarWorkDays(
|
||||
DayColumn dayColumn, CalendarWorkDayCollection calendarWorkDays)
|
||||
{
|
||||
if (calendarWorkDays != null && calendarWorkDays.Count > 0)
|
||||
{
|
||||
CalendarWorkDay cwd = calendarWorkDays[dayColumn.Date];
|
||||
|
||||
if (cwd != null)
|
||||
{
|
||||
dayColumn.WorkStartTime = cwd.WorkStartTime;
|
||||
dayColumn.WorkEndTime = cwd.WorkEndTime;
|
||||
|
||||
return (true);
|
||||
}
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetWorkDays
|
||||
|
||||
/// <summary>
|
||||
/// GetWorkDays
|
||||
/// </summary>
|
||||
/// <param name="dayColumn"></param>
|
||||
/// <param name="workDays"></param>
|
||||
/// <returns></returns>
|
||||
private bool GetWorkDays(
|
||||
DayColumn dayColumn, WorkDayCollection workDays)
|
||||
{
|
||||
if (workDays != null && workDays.Count > 0)
|
||||
{
|
||||
WorkDay wd = workDays[dayColumn.Date.DayOfWeek];
|
||||
|
||||
if (wd != null)
|
||||
{
|
||||
dayColumn.WorkStartTime = wd.WorkStartTime;
|
||||
dayColumn.WorkEndTime = wd.WorkEndTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
dayColumn.WorkStartTime = new WorkTime();
|
||||
dayColumn.WorkEndTime = new WorkTime();
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetView routines
|
||||
|
||||
#region GetViewFromAll
|
||||
|
||||
private AppointmentWeekDayView
|
||||
GetViewFromAll(Appointment app, bool remove)
|
||||
{
|
||||
AppointmentWeekDayView view = GetViewFromAllColumns(app, remove);
|
||||
|
||||
if (view != null)
|
||||
return (view);
|
||||
|
||||
return (GetViewFromAllDayPanel(app, remove));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetViewFromAllColumns
|
||||
|
||||
private AppointmentWeekDayView
|
||||
GetViewFromAllColumns(Appointment app, bool remove)
|
||||
{
|
||||
for (int i = 0; i < _View.NumberOfColumns; i++)
|
||||
{
|
||||
AppointmentWeekDayView view =
|
||||
GetViewFromColumn(_View.DayColumns[i], app, remove);
|
||||
|
||||
if (view != null)
|
||||
return (view);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetViewFromColumn
|
||||
|
||||
private AppointmentWeekDayView
|
||||
GetViewFromColumn(DayColumn dayColumn, Appointment appointment, bool remove)
|
||||
{
|
||||
foreach (CalendarItem item in dayColumn.CalendarItems)
|
||||
{
|
||||
AppointmentWeekDayView view = item as AppointmentWeekDayView;
|
||||
|
||||
if (view != null && view.Appointment == appointment)
|
||||
{
|
||||
if (remove == true)
|
||||
{
|
||||
dayColumn.CalendarItems.Remove(view);
|
||||
_View.SubItems.Remove(view);
|
||||
|
||||
view.DayColumn = null;
|
||||
}
|
||||
|
||||
return (view);
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetViewFromAllDayPanel
|
||||
|
||||
private AppointmentWeekDayView
|
||||
GetViewFromAllDayPanel(Appointment appointment, bool remove)
|
||||
{
|
||||
foreach (CalendarItem item in _View.AllDayPanel.CalendarItems)
|
||||
{
|
||||
AppointmentWeekDayView view = item as AppointmentWeekDayView;
|
||||
|
||||
if (view != null && view.Appointment == appointment)
|
||||
{
|
||||
if (remove == true)
|
||||
{
|
||||
_View.AllDayPanel.CalendarItems.Remove(view);
|
||||
_View.AllDayPanel.SubItems.Remove(view);
|
||||
|
||||
view.AllDayPanel = null;
|
||||
}
|
||||
|
||||
return (view);
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetItem routines
|
||||
|
||||
#region GetItemFromColumn
|
||||
|
||||
private CustomCalendarItem
|
||||
GetItemFromColumn(DayColumn dayColumn, CustomCalendarItem item, bool remove)
|
||||
{
|
||||
foreach (CalendarItem citem in dayColumn.CalendarItems)
|
||||
{
|
||||
CustomCalendarItem view = citem as CustomCalendarItem;
|
||||
|
||||
if (view != null && (view == item || view.BaseCalendarItem == item))
|
||||
{
|
||||
if (remove == true)
|
||||
dayColumn.CalendarItems.Remove(view);
|
||||
|
||||
return (view);
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetItemFromAllColumns
|
||||
|
||||
private CustomCalendarItem
|
||||
GetItemFromAllColumns(CustomCalendarItem item, bool remove)
|
||||
{
|
||||
for (int i = 0; i < _View.NumberOfColumns; i++)
|
||||
{
|
||||
CustomCalendarItem view =
|
||||
GetItemFromColumn(_View.DayColumns[i], item, false);
|
||||
|
||||
if (view != null)
|
||||
return (view);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetItemFromAllDayPanel
|
||||
|
||||
private CustomCalendarItem
|
||||
GetItemFromAllDayPanel(CustomCalendarItem item, bool remove)
|
||||
{
|
||||
foreach (CalendarItem citem in _View.AllDayPanel.CalendarItems)
|
||||
{
|
||||
CustomCalendarItem view = citem as CustomCalendarItem;
|
||||
|
||||
if (view != null && (view == item || view.BaseCalendarItem == item))
|
||||
{
|
||||
if (remove == true)
|
||||
_View.AllDayPanel.CalendarItems.Remove(view);
|
||||
|
||||
return (view);
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetNewView
|
||||
|
||||
/// <summary>
|
||||
/// Gets a new appointment view
|
||||
/// </summary>
|
||||
/// <param name="appointment">Appointment</param>
|
||||
/// <returns>New view</returns>
|
||||
private AppointmentWeekDayView GetNewView(Appointment appointment)
|
||||
{
|
||||
AppointmentWeekDayView view = new AppointmentWeekDayView(_View, appointment);
|
||||
|
||||
view.Tooltip = appointment.Tooltip;
|
||||
|
||||
view.IsSelectedChanged += _View.ItemIsSelectedChanged;
|
||||
|
||||
return (view);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetNewCustomItem
|
||||
|
||||
private CustomCalendarItem GetNewCustomItem(CustomCalendarItem item)
|
||||
{
|
||||
CustomCalendarItem ci = (CustomCalendarItem)item.Copy();
|
||||
ci.BaseCalendarItem = item;
|
||||
|
||||
ci.IsSelectedChanged += _View.ItemIsSelectedChanged;
|
||||
|
||||
return (ci);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region View support routines
|
||||
|
||||
/// <summary>
|
||||
/// Returns the view
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override eCalendarView GetView()
|
||||
{
|
||||
return (eCalendarView.Week);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies the Model and MonthView are valid
|
||||
/// </summary>
|
||||
private void VerifyModel()
|
||||
{
|
||||
if (_Model == null)
|
||||
throw new NullReferenceException("CalendarModel must be set on connector.");
|
||||
|
||||
if (_View == null)
|
||||
throw new NullReferenceException("WeekDayCalendarView must be set on connector.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Model property change processing
|
||||
|
||||
/// <summary>
|
||||
/// Handles Model property change notifications
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ModelPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == CalendarModel.AppointmentsPropertyName)
|
||||
{
|
||||
RefreshData();
|
||||
UpdateDisplay();
|
||||
}
|
||||
else if (e.PropertyName == CalendarModel.WorkDaysPropertyName)
|
||||
{
|
||||
for (int i = 0; i < _View.NumberOfColumns; i++)
|
||||
UpdateWorkDayDetails(_View.DayColumns[i]);
|
||||
|
||||
_View.CalendarView.CalendarPanel.RecalcSize();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ModelSubPropertyChanged
|
||||
|
||||
/// <summary>
|
||||
/// Handles ModelSubProperty change notifications
|
||||
/// </summary>
|
||||
/// <param name="sender">object</param>
|
||||
/// <param name="e">SubPropertyChangedEventArgs</param>
|
||||
private void ModelSubPropertyChanged(object sender, SubPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.Source is WorkDay)
|
||||
{
|
||||
for (int i = 0; i < _View.NumberOfColumns; i++)
|
||||
UpdateWorkDayDetails(_View.DayColumns[i]);
|
||||
|
||||
_View.CalendarView.CalendarPanel.RecalcSize();
|
||||
}
|
||||
else if (e.Source is Owner)
|
||||
{
|
||||
Owner owner = (Owner) e.Source;
|
||||
|
||||
if (_View.OwnerKey != null && _View.OwnerKey.Equals(owner.Key))
|
||||
{
|
||||
if (e.PropertyChangedArgs.PropertyName == Owner.DisplayNamePropertyName)
|
||||
_View.DisplayName = owner.DisplayName;
|
||||
|
||||
else if (e.PropertyChangedArgs.PropertyName.Equals("ColorScheme"))
|
||||
_View.CalendarColor = owner.ColorScheme;
|
||||
}
|
||||
}
|
||||
else if (e.Source is Appointment)
|
||||
{
|
||||
Appointment app = e.Source as Appointment;
|
||||
AppointmentWeekDayView appView;
|
||||
|
||||
string name = e.PropertyChangedArgs.PropertyName;
|
||||
|
||||
if (name.Equals("Tooltip"))
|
||||
{
|
||||
appView = GetViewFromAll(app, false);
|
||||
|
||||
if (appView != null)
|
||||
appView.Tooltip = app.Tooltip;
|
||||
}
|
||||
else if (name.Equals("IsSelected"))
|
||||
{
|
||||
appView = GetViewFromAll(app, false);
|
||||
|
||||
if (appView != null)
|
||||
appView.IsSelected = app.IsSelected;
|
||||
}
|
||||
else if (name.Equals("CategoryColor") || name.Equals("TimeMarkedAs") || name.Equals("ImageKey"))
|
||||
{
|
||||
appView = GetViewFromAll(app, false);
|
||||
|
||||
if (appView != null)
|
||||
appView.Refresh();
|
||||
}
|
||||
else if (name.Equals("OwnerKey"))
|
||||
{
|
||||
if (_View.CalendarView.IsMultiCalendar == true)
|
||||
{
|
||||
if (_View.OwnerKey == app.OwnerKey)
|
||||
{
|
||||
RefreshData();
|
||||
UpdateDisplay();
|
||||
}
|
||||
else
|
||||
{
|
||||
appView = GetViewFromAll(app, false);
|
||||
|
||||
if (appView != null)
|
||||
{
|
||||
RefreshData();
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (name.Equals("Visible"))
|
||||
{
|
||||
RefreshData();
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CustomItems_CollectionChanged
|
||||
|
||||
void CustomItemsCollectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
RefreshData();
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UpdateDisplay
|
||||
|
||||
private void UpdateDisplay()
|
||||
{
|
||||
if (_View.Displayed == true)
|
||||
{
|
||||
if (_View.NeedRecalcLayout == false)
|
||||
{
|
||||
for (int i = 0; i < _View.NumberOfColumns; i++)
|
||||
{
|
||||
if (_View.DayColumns[i].NeedRecalcLayout)
|
||||
{
|
||||
_View.RecalcSize();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnSubItemsChanged
|
||||
|
||||
private void OnSubItemsChanged()
|
||||
{
|
||||
System.Windows.Forms.Cursor.Position =
|
||||
System.Windows.Forms.Cursor.Position;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
59
PROMS/DotNetBar Source Code/DevComponents.DotNetBar.Schedule/WeekView/PosWin.Designer.cs
generated
Normal file
59
PROMS/DotNetBar Source Code/DevComponents.DotNetBar.Schedule/WeekView/PosWin.Designer.cs
generated
Normal file
@@ -0,0 +1,59 @@
|
||||
#if FRAMEWORK20
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
partial class PosWin
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PosWin
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.CausesValidation = false;
|
||||
this.ClientSize = new System.Drawing.Size(1, 1);
|
||||
this.ControlBox = false;
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Location = new System.Drawing.Point(1000, 1000);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "PosWin";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "PosWin";
|
||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.PosWin_Paint);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,132 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public partial class PosWin : Form
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private string _PosText = ""; // Window content
|
||||
private int _PosHeight; // Calculated window height
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public PosWin()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region CreateParams / show support
|
||||
|
||||
// This code permits us to be able to create a
|
||||
// window with a drop shadow
|
||||
|
||||
private const int CS_DROPSHADOW = 0x00020000;
|
||||
|
||||
protected override CreateParams CreateParams
|
||||
{
|
||||
get
|
||||
{
|
||||
CreateParams parameters = base.CreateParams;
|
||||
|
||||
parameters.ClassStyle =
|
||||
(parameters.ClassStyle | CS_DROPSHADOW);
|
||||
|
||||
return (parameters);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ShowWithoutActivation
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the window content text
|
||||
/// </summary>
|
||||
public string PosText
|
||||
{
|
||||
get { return (_PosText); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_PosText != value)
|
||||
{
|
||||
_PosText = value;
|
||||
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the calculated window height
|
||||
/// </summary>
|
||||
public int PosHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_PosHeight <= 0)
|
||||
{
|
||||
using (Graphics g = CreateGraphics())
|
||||
{
|
||||
eTextFormat tf = eTextFormat.Default |
|
||||
eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter;
|
||||
|
||||
Size sz = TextDrawing.MeasureString(g, "ABC", SystemFonts.CaptionFont, 0, tf);
|
||||
|
||||
_PosHeight = sz.Height + 4;
|
||||
}
|
||||
}
|
||||
|
||||
return (_PosHeight);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint processing
|
||||
|
||||
private void PosWin_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
eTextFormat tf = eTextFormat.Default | eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter;
|
||||
|
||||
Size sz = TextDrawing.MeasureString(g, _PosText, SystemFonts.CaptionFont, 0, tf);
|
||||
|
||||
sz.Width += 6;
|
||||
sz.Height += 4;
|
||||
|
||||
this.Size = sz;
|
||||
|
||||
int swidth = Screen.FromControl(this).Bounds.Width;
|
||||
|
||||
if (Location.X + sz.Width > swidth)
|
||||
Location = new Point(swidth - sz.Width, Location.Y);
|
||||
|
||||
Rectangle r = new Rectangle(0, 0, sz.Width - 1, sz.Height - 1);
|
||||
|
||||
g.DrawRectangle(Pens.Black, r);
|
||||
|
||||
TextDrawing.DrawString(g, _PosText, SystemFonts.CaptionFont, Color.Black, r, tf);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@@ -0,0 +1,760 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class TimeRulerPanel : BaseItem
|
||||
{
|
||||
#region Private Variables
|
||||
|
||||
private CalendarView _CalendarView; // Assoc CalendarView
|
||||
|
||||
private int _VScrollPos; // Vertical scroll position
|
||||
|
||||
private TimeRulerColor _ViewColor = // View display color table
|
||||
new TimeRulerColor();
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="calendarView"></param>
|
||||
public TimeRulerPanel(CalendarView calendarView)
|
||||
{
|
||||
_CalendarView = calendarView;
|
||||
|
||||
Name = "TimeRulerPanel";
|
||||
|
||||
HookEvents(true);
|
||||
}
|
||||
|
||||
#region Private properties
|
||||
|
||||
#region General display properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TimeRuler font
|
||||
/// </summary>
|
||||
private Font TimeRulerFont
|
||||
{
|
||||
get { return (_CalendarView.TimeRulerFont); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TimeRuler font (small)
|
||||
/// </summary>
|
||||
private Font TimeRulerFontSm
|
||||
{
|
||||
get { return (_CalendarView.TimeRulerFontSm); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Time Slice Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default Time Slice height
|
||||
/// </summary>
|
||||
private float TimeSliceHeight
|
||||
{
|
||||
get { return (_CalendarView.TimeSliceHeight); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TimeSlotDuration
|
||||
/// </summary>
|
||||
private int TimeSlotDuration
|
||||
{
|
||||
get { return (_CalendarView.TimeSlotDuration); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the SlotsPerHour
|
||||
/// </summary>
|
||||
private int SlotsPerHour
|
||||
{
|
||||
get { return (_CalendarView.SlotsPerHour); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the NumberOfSlices
|
||||
/// </summary>
|
||||
private int NumberOfSlices
|
||||
{
|
||||
get { return (_CalendarView.NumberOfSlices); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the starting Time Slice
|
||||
/// </summary>
|
||||
private int StartSlice
|
||||
{
|
||||
get { return (_CalendarView.StartSlice); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AM / PM designators
|
||||
|
||||
/// <summary>
|
||||
/// Gets the culturally correct AM time designator
|
||||
/// </summary>
|
||||
private string AmDesignator
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ScheduleSettings.GetActiveCulture().
|
||||
DateTimeFormat.AMDesignator.ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the culturally correct PM time designator
|
||||
/// </summary>
|
||||
private string PmDesignator
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ScheduleSettings.GetActiveCulture().
|
||||
DateTimeFormat.PMDesignator.ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hook / Unhook Events
|
||||
|
||||
/// <summary>
|
||||
/// Routine hooks all necessary events for this control
|
||||
/// </summary>
|
||||
/// <param name="hook">True to hook, false to unhook</param>
|
||||
private void HookEvents(bool hook)
|
||||
{
|
||||
if (hook == true)
|
||||
{
|
||||
_CalendarView.LabelTimeSlotsChanged += CalendarView_LabelTimeSlotsChanged;
|
||||
_CalendarView.Is24HourFormatChanged += CalendarView_Is24HourFormatChanged;
|
||||
_CalendarView.TimeSlotDurationChanged += CalendarView_TimeSlotDurationChanged;
|
||||
_CalendarView.TimeIndicatorsChanged += CalendarView_TimeIndicatorsChanged;
|
||||
_CalendarView.TimeIndicatorTimeChanged += CalendarView_TimeIndicatorTimeChanged;
|
||||
|
||||
_CalendarView.WeekDayVScrollPanel.ScrollBarChanged += VScrollPanel_ScrollBarChanged;
|
||||
}
|
||||
else
|
||||
{
|
||||
_CalendarView.LabelTimeSlotsChanged -= CalendarView_LabelTimeSlotsChanged;
|
||||
_CalendarView.Is24HourFormatChanged -= CalendarView_Is24HourFormatChanged;
|
||||
_CalendarView.TimeSlotDurationChanged -= CalendarView_TimeSlotDurationChanged;
|
||||
_CalendarView.TimeIndicatorsChanged -= CalendarView_TimeIndicatorsChanged;
|
||||
_CalendarView.TimeIndicatorTimeChanged -= CalendarView_TimeIndicatorTimeChanged;
|
||||
|
||||
_CalendarView.WeekDayVScrollPanel.ScrollBarChanged -= VScrollPanel_ScrollBarChanged;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Processing
|
||||
|
||||
#region CalendarView_LabelTimeSlotsChanged
|
||||
|
||||
/// <summary>
|
||||
/// Processes LabelTimeSlotsChanged events
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CalendarView_LabelTimeSlotsChanged(
|
||||
object sender, LabelTimeSlotsChangedEventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalendarView_Is24HourFormatChanged
|
||||
|
||||
/// <summary>
|
||||
/// Processes Is24HourFormatChanged events
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CalendarView_Is24HourFormatChanged(
|
||||
object sender, Is24HourFormatChangedEventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalendarView_TimeSlotDurationChanged
|
||||
|
||||
/// <summary>
|
||||
/// Processes TimeSlotDurationChanged events
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CalendarView_TimeSlotDurationChanged(
|
||||
object sender, TimeSlotDurationChangedEventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalendarView_TimeIndicatorsChanged
|
||||
|
||||
/// <summary>
|
||||
/// Processes CalendarView_TimeIndicatorsChanged events
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CalendarView_TimeIndicatorsChanged(object sender, EventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalendarView_TimeIndicatorTimeChanged
|
||||
|
||||
/// <summary>
|
||||
/// Processes CalendarView_TimeIndicatorTimeChanged events
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CalendarView_TimeIndicatorTimeChanged(
|
||||
object sender, TimeIndicatorTimeChangedEventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region VScrollPanel_ScrollBarChanged
|
||||
|
||||
void VScrollPanel_ScrollBarChanged(object sender, EventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
|
||||
Rectangle r = Bounds;
|
||||
|
||||
r.Y = _CalendarView.WeekDayVScrollPanel.Bounds.Y;
|
||||
r.Height = _CalendarView.WeekDayVScrollPanel.Bounds.Height;
|
||||
|
||||
Bounds = r;
|
||||
|
||||
_VScrollPos = -_CalendarView.WeekDayVScrollPanel.ScrollBar.Value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint processing
|
||||
|
||||
/// <summary>
|
||||
/// Paint processing routine
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public override void Paint(ItemPaintArgs e)
|
||||
{
|
||||
int sliceStart, sliceEnd;
|
||||
int sliceCount = GetSliceRange(e, out sliceStart, out sliceEnd);
|
||||
|
||||
if (sliceCount > 0)
|
||||
{
|
||||
_ViewColor.SetColorTable();
|
||||
|
||||
DrawTimeRuler(e, sliceStart, sliceEnd);
|
||||
}
|
||||
}
|
||||
|
||||
#region Slice Support Routines
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the range of slices needed to be drawn
|
||||
/// to satisfy the specified paint request
|
||||
/// </summary>
|
||||
/// <param name="e">ItemPaintArgs</param>
|
||||
/// <param name="sliceStart">[out] Slice start index</param>
|
||||
/// <param name="sliceEnd">[out] Slice end index</param>
|
||||
/// <returns>Slice range count (end - start)</returns>
|
||||
internal int GetSliceRange(ItemPaintArgs e, out int sliceStart, out int sliceEnd)
|
||||
{
|
||||
// Calc our starting index
|
||||
|
||||
int start = 0;
|
||||
|
||||
while (start < NumberOfSlices)
|
||||
{
|
||||
Rectangle r = GetSliceRect(start);
|
||||
|
||||
if (r.Bottom > Bounds.Top)
|
||||
{
|
||||
if (r.Bottom > e.ClipRectangle.Y)
|
||||
break;
|
||||
}
|
||||
|
||||
start++;
|
||||
}
|
||||
|
||||
// Calc our ending index
|
||||
|
||||
int end = start;
|
||||
|
||||
while (end < NumberOfSlices)
|
||||
{
|
||||
Rectangle r = GetSliceRect(end);
|
||||
|
||||
if (r.Y >= e.ClipRectangle.Bottom)
|
||||
break;
|
||||
|
||||
end++;
|
||||
}
|
||||
|
||||
// Set the user supplied 'out' values, and
|
||||
// return the range count to the caller
|
||||
|
||||
if (end - start == 0)
|
||||
{
|
||||
sliceStart = 0;
|
||||
sliceEnd = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
sliceStart = start;
|
||||
sliceEnd = end - 1;
|
||||
|
||||
return (end - start);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the given slice rectangle
|
||||
/// </summary>
|
||||
/// <param name="slice">Slice</param>
|
||||
/// <returns>Bounding rectangle</returns>
|
||||
private Rectangle GetSliceRect(int slice)
|
||||
{
|
||||
Rectangle r = Bounds;
|
||||
|
||||
float n = slice * TimeSliceHeight;
|
||||
|
||||
r.Y += (int)(n) + _VScrollPos;
|
||||
r.Height = (int)(n + TimeSliceHeight) - (int)n;
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawTimeRuler
|
||||
|
||||
/// <summary>
|
||||
/// Draws the TimeRuler
|
||||
/// </summary>
|
||||
/// <param name="e">ItemPaintArgs</param>
|
||||
/// <param name="sliceStart"></param>
|
||||
/// <param name="sliceEnd"></param>
|
||||
private void DrawTimeRuler(ItemPaintArgs e, int sliceStart, int sliceEnd)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
Region regSav = g.Clip;
|
||||
g.SetClip(Bounds);
|
||||
|
||||
DrawBackGround(g);
|
||||
DrawTimeIndicators(g, sliceStart, sliceEnd);
|
||||
DrawRulerContent(g, sliceStart, sliceEnd);
|
||||
|
||||
// Restore our original clip region
|
||||
|
||||
g.Clip = regSav;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawBackGround
|
||||
|
||||
/// <summary>
|
||||
/// DrawBackGround
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackGround(Graphics g)
|
||||
{
|
||||
using (Brush br = _ViewColor.BrushPart((int)eTimeRulerPart.TimeRulerBackground, Bounds))
|
||||
g.FillRectangle(br, Bounds);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawTimeIndicators
|
||||
|
||||
#region DrawTimeIndicators
|
||||
|
||||
/// <summary>
|
||||
/// Draws TimeIndicators
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="sliceStart"></param>
|
||||
/// <param name="sliceEnd"></param>
|
||||
private void DrawTimeIndicators(Graphics g, int sliceStart, int sliceEnd)
|
||||
{
|
||||
DateTime start, end;
|
||||
GetViewDates(out start, out end);
|
||||
|
||||
Rectangle r = Rectangle.Union(GetSliceRect(sliceStart), GetSliceRect(sliceEnd));
|
||||
|
||||
for (int i = 0; i < _CalendarView.TimeIndicators.Count; i++)
|
||||
{
|
||||
TimeIndicator ti = _CalendarView.TimeIndicators[i];
|
||||
|
||||
if (ti.IndicatorArea == eTimeIndicatorArea.All ||
|
||||
ti.IndicatorArea == eTimeIndicatorArea.Header)
|
||||
{
|
||||
if (ti.IsVisible())
|
||||
{
|
||||
DateTime time = ti.IndicatorDisplayTime;
|
||||
|
||||
if (time >= start && time < end)
|
||||
DrawTimeIndicator(g, r, ti);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawTimeIndicator
|
||||
|
||||
#region DrawTimeIndicator
|
||||
|
||||
/// <summary>
|
||||
/// Draws individual TimeIndicators
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="sRect"></param>
|
||||
/// <param name="ti"></param>
|
||||
private void DrawTimeIndicator(Graphics g, Rectangle sRect, TimeIndicator ti)
|
||||
{
|
||||
Rectangle r = GetIndicatorRect(ti);
|
||||
|
||||
if (r.IntersectsWith(sRect) == true)
|
||||
{
|
||||
if (r.Height > 0)
|
||||
{
|
||||
ColorDef cdef = GetIndicatorColor(ti);
|
||||
|
||||
if (cdef != null)
|
||||
{
|
||||
using (Brush br = _ViewColor.BrushPart(cdef, r))
|
||||
{
|
||||
if (br is LinearGradientBrush)
|
||||
((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipX;
|
||||
|
||||
g.FillRectangle(br, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Color color = GetIndicatorBorder(ti);
|
||||
|
||||
if (color.IsEmpty == false)
|
||||
{
|
||||
using (Pen pen = new Pen(color))
|
||||
g.DrawLine(pen, r.X + 1, r.Bottom, r.Right - 1, r.Bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetIndicatorColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Indicator Back color
|
||||
/// </summary>
|
||||
/// <param name="ti"></param>
|
||||
/// <returns></returns>
|
||||
private ColorDef GetIndicatorColor(TimeIndicator ti)
|
||||
{
|
||||
ColorDef cdef = ti.IndicatorColor;
|
||||
|
||||
if (cdef == null || cdef.IsEmpty == true)
|
||||
cdef = _ViewColor.GetColorDef((int)eTimeRulerPart.TimeRulerIndicator);
|
||||
|
||||
return (cdef);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetIndicatorBorder
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Indicator Border color
|
||||
/// </summary>
|
||||
/// <param name="ti"></param>
|
||||
/// <returns></returns>
|
||||
private Color GetIndicatorBorder(TimeIndicator ti)
|
||||
{
|
||||
return (ti.BorderColor.IsEmpty == false ? ti.BorderColor :
|
||||
_ViewColor.GetColor((int)eTimeRulerPart.TimeRulerIndicatorBorder));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetViewDates
|
||||
|
||||
/// <summary>
|
||||
/// GetViewDates
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
private void GetViewDates(out DateTime start, out DateTime end)
|
||||
{
|
||||
switch (_CalendarView.SelectedView)
|
||||
{
|
||||
case eCalendarView.Day:
|
||||
start = _CalendarView.DayViewDate;
|
||||
end = _CalendarView.DayViewDate.AddDays(1);
|
||||
break;
|
||||
|
||||
default:
|
||||
start = _CalendarView.WeekViewStartDate;
|
||||
end = _CalendarView.WeekViewEndDate.AddDays(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetIndicatorRect
|
||||
|
||||
/// <summary>
|
||||
/// GetIndicatorRect
|
||||
/// </summary>
|
||||
/// <param name="ti"></param>
|
||||
/// <returns></returns>
|
||||
private Rectangle GetIndicatorRect(TimeIndicator ti)
|
||||
{
|
||||
DateTime time = ti.IndicatorDisplayTime;
|
||||
|
||||
int offset = (int)(time.Hour * SlotsPerHour * TimeSliceHeight +
|
||||
(TimeSliceHeight * time.Minute) / TimeSlotDuration);
|
||||
|
||||
offset -= (int)(StartSlice * TimeSliceHeight);
|
||||
|
||||
Rectangle r = Bounds;
|
||||
|
||||
r.Y += (offset - ti.Thickness + _VScrollPos);
|
||||
r.Height = ti.Thickness;
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawRulerContent
|
||||
|
||||
private void DrawRulerContent(Graphics g, int sliceStart, int sliceEnd)
|
||||
{
|
||||
Point pt1 = new Point();
|
||||
Point pt2 = new Point();
|
||||
|
||||
using (Pen pen = new Pen(
|
||||
_ViewColor.GetColor((int)eTimeRulerPart.TimeRulerBorder)))
|
||||
{
|
||||
pt1.X = 3;
|
||||
pt2.X = Bounds.Width - 4;
|
||||
|
||||
for (int i = sliceStart; i <= sliceEnd; i++)
|
||||
{
|
||||
Rectangle r = GetSliceRect(i);
|
||||
|
||||
// Draw an hourly separation border line
|
||||
|
||||
if ((i % SlotsPerHour) == 0)
|
||||
{
|
||||
pt1.Y = pt2.Y = r.Y;
|
||||
|
||||
g.DrawLine(pen, pt1, pt2);
|
||||
}
|
||||
|
||||
// Draw the time text
|
||||
|
||||
DrawTimeRulerText(g, r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawTimeRulerText
|
||||
|
||||
/// <summary>
|
||||
/// Draws the time text
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="r"></param>
|
||||
/// <param name="slice"></param>
|
||||
private void DrawTimeRulerText(Graphics g, Rectangle r, int slice)
|
||||
{
|
||||
// Get our hour and minute display text
|
||||
|
||||
slice += StartSlice;
|
||||
|
||||
int hour = slice / SlotsPerHour;
|
||||
int minute = (slice % SlotsPerHour) * TimeSlotDuration;
|
||||
|
||||
if (_CalendarView.LabelTimeSlots == true || minute == 0)
|
||||
{
|
||||
string sHour = GetRulerHour(hour);
|
||||
string sMinute = GetRulerMinute(hour, minute);
|
||||
|
||||
// Setup for our output
|
||||
|
||||
Color color = _ViewColor.GetColor(
|
||||
(int)eTimeRulerPart.TimeRulerForeground);
|
||||
|
||||
eTextFormat tf = eTextFormat.Top | eTextFormat.Left | eTextFormat.NoPadding;
|
||||
|
||||
Size sz = TextDrawing.MeasureString(g, sHour, TimeRulerFont, 0, tf);
|
||||
|
||||
Rectangle r2 = new Rectangle(Bounds.X, r.Y + 1,
|
||||
Bounds.Width / 2, (int)TimeSliceHeight - 1);
|
||||
|
||||
// If we are displaying an hourly marker, then display
|
||||
// it as an offset hour and minute (or AM/PM designator) display
|
||||
|
||||
if (minute == 0)
|
||||
{
|
||||
r2.X = r2.Right - sz.Width;
|
||||
|
||||
if (r2.X < 0)
|
||||
r2.X = 0;
|
||||
|
||||
r2.Width = sz.Width;
|
||||
|
||||
TextDrawing.DrawString(g, sHour, TimeRulerFont, color, r2, tf);
|
||||
|
||||
r2.X = r2.Right + 2;
|
||||
r2.Y += 1;
|
||||
|
||||
tf = eTextFormat.Top | eTextFormat.Left | eTextFormat.NoPadding;
|
||||
|
||||
TextDrawing.DrawString(g, sMinute, TimeRulerFontSm, color, r2, tf);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Non-hourly display
|
||||
|
||||
r2.Width = Bounds.Width - 4;
|
||||
r2.Y += 2;
|
||||
|
||||
tf = eTextFormat.Top | eTextFormat.Right | eTextFormat.NoPadding;
|
||||
|
||||
TextDrawing.DrawString(g,
|
||||
sHour + ScheduleSettings.GetActiveCulture().DateTimeFormat.TimeSeparator +
|
||||
sMinute, TimeRulerFontSm, color, r2, tf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hourly display text
|
||||
/// </summary>
|
||||
/// <param name="hour">Hour</param>
|
||||
/// <returns>Hourly text</returns>
|
||||
private string GetRulerHour(int hour)
|
||||
{
|
||||
if (_CalendarView.Is24HourFormat == false)
|
||||
{
|
||||
int h = hour % 12;
|
||||
hour = (h == 0) ? 12 : h;
|
||||
}
|
||||
else
|
||||
{
|
||||
int h = hour % 24;
|
||||
hour = (h == 0) ? 0 : h;
|
||||
}
|
||||
|
||||
return (hour.ToString(ScheduleSettings.TimeRulerHourFormatString));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the minute display text
|
||||
/// </summary>
|
||||
/// <param name="hour">Hour</param>
|
||||
/// <param name="minute">Minute</param>
|
||||
/// <returns>Minute text</returns>
|
||||
private string GetRulerMinute(int hour, int minute)
|
||||
{
|
||||
if (minute == 0 && _CalendarView.Is24HourFormat == false)
|
||||
{
|
||||
hour %= 24;
|
||||
|
||||
if (hour == 0)
|
||||
return (AmDesignator);
|
||||
|
||||
if (hour == 12)
|
||||
return (PmDesignator);
|
||||
}
|
||||
|
||||
return (minute.ToString(ScheduleSettings.TimeRulerMinuteFormatString));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing == true && IsDisposed == false)
|
||||
HookEvents(false);
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of the item.
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
TimeRulerPanel objCopy = new TimeRulerPanel(_CalendarView);
|
||||
CopyToItem(objCopy);
|
||||
|
||||
return (objCopy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the TimeRulerPanel specific properties to new instance of the item.
|
||||
/// </summary>
|
||||
/// <param name="copy">New TimeRulerPanel instance</param>
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
TimeRulerPanel objCopy = copy as TimeRulerPanel;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -0,0 +1,27 @@
|
||||
#if FRAMEWORK20
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class WeekDayVScrollPanel : VScrollPanel
|
||||
{
|
||||
public WeekDayVScrollPanel(CalendarView calendarView)
|
||||
: base(calendarView)
|
||||
{
|
||||
}
|
||||
|
||||
#region Private properties
|
||||
|
||||
protected override int ScrollPanelSmallChange
|
||||
{
|
||||
get { return ((int)CalendarView.TimeSliceHeight); }
|
||||
}
|
||||
|
||||
protected override int ScrollPanelMaximum
|
||||
{
|
||||
get { return ((int)(CalendarView.TimeSliceHeight * CalendarView.NumberOfSlices)); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,177 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Schedule
|
||||
{
|
||||
public class WeekView : WeekDayView
|
||||
{
|
||||
public WeekView(CalendarView calendarView)
|
||||
: base(calendarView, eCalendarView.Week)
|
||||
{
|
||||
}
|
||||
|
||||
#region RecalcSize support
|
||||
|
||||
/// <summary>
|
||||
/// Normalizes the user specified start and end dates
|
||||
/// </summary>
|
||||
/// <param name="startDate">[out] Normalized start date</param>
|
||||
/// <param name="endDate">[out] Normalized end date</param>
|
||||
protected override void NormalizeDates(out DateTime startDate, out DateTime endDate)
|
||||
{
|
||||
startDate = this.StartDate;
|
||||
endDate = this.EndDate;
|
||||
|
||||
DaysOfTheWeek = new DaysOfTheWeek(startDate.DayOfWeek, DaysInWeek);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessUpDownKey
|
||||
|
||||
/// <summary>
|
||||
/// Processes Up and Down key events
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
/// <param name="dy"></param>
|
||||
protected override void ProcessUpDownKey(KeyEventArgs objArg, int dy)
|
||||
{
|
||||
if (ValidDateSelection())
|
||||
{
|
||||
DateTime startDate = CalendarView.DateSelectionStart.Value;
|
||||
DateTime endDate = CalendarView.DateSelectionEnd.Value;
|
||||
|
||||
if (startDate.Equals(DateSelectionAnchor.Value) == true)
|
||||
startDate = endDate.AddMinutes(-CalendarView.TimeSlotDuration);
|
||||
|
||||
int col = GetColumnFromDate(startDate);
|
||||
|
||||
startDate = startDate.AddMinutes(dy);
|
||||
|
||||
if (GetColumnFromDate(startDate) == col)
|
||||
{
|
||||
if (col < 0)
|
||||
{
|
||||
startDate = CalendarView.DateSelectionStart.Value;
|
||||
col = GetColumnFromDate(startDate);
|
||||
}
|
||||
|
||||
if (col < 0)
|
||||
{
|
||||
startDate = CalendarView.DateSelectionEnd.Value;
|
||||
col = GetColumnFromDate(startDate);
|
||||
}
|
||||
|
||||
if (col >= 0)
|
||||
{
|
||||
endDate = startDate.AddMinutes(CalendarView.TimeSlotDuration);
|
||||
|
||||
DateTime sd = DayColumns[col].Date.AddMinutes(CalendarView.StartSlice * CalendarView.TimeSlotDuration);
|
||||
DateTime ed = sd.AddMinutes(CalendarView.NumberOfActiveSlices * CalendarView.TimeSlotDuration);
|
||||
|
||||
if (startDate >= sd && endDate <= ed)
|
||||
{
|
||||
ExtendSelection(ref startDate, ref endDate);
|
||||
|
||||
CalendarView.DateSelectionStart = startDate;
|
||||
CalendarView.DateSelectionEnd = endDate;
|
||||
|
||||
EnsureSelectionVisible();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
objArg.Handled = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessLeftRightKey
|
||||
|
||||
/// <summary>
|
||||
/// Processes Left and Right Key events
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
/// <param name="dx"></param>
|
||||
protected override void ProcessLeftRightKey(KeyEventArgs objArg, int dx)
|
||||
{
|
||||
objArg.Handled = true;
|
||||
|
||||
if (ValidDateSelection())
|
||||
{
|
||||
DateTime startDate = CalendarView.DateSelectionStart.Value;
|
||||
DateTime endDate = CalendarView.DateSelectionEnd.Value;
|
||||
|
||||
bool newRange = (startDate < DayColumns[0].Date ||
|
||||
endDate > DayColumns[NumberOfColumns - 1].Date.AddDays(1));
|
||||
|
||||
if (CalendarView.WeekDayCanExtendRange == true || newRange == false)
|
||||
{
|
||||
bool cancelled = false;
|
||||
|
||||
if ((objArg.Modifiers & Keys.Shift) == Keys.Shift)
|
||||
{
|
||||
if (startDate.Equals(DateSelectionAnchor.Value) == true)
|
||||
startDate = endDate.AddMinutes(-CalendarView.TimeSlotDuration);
|
||||
|
||||
startDate = startDate.AddDays(dx);
|
||||
endDate = startDate.AddMinutes(CalendarView.TimeSlotDuration);
|
||||
|
||||
if (IsNewRange(startDate, endDate) == true)
|
||||
{
|
||||
if (CalendarView.WeekDayCanExtendRange == false)
|
||||
return;
|
||||
|
||||
cancelled = CalendarView.DoViewDateChanging(this,
|
||||
StartDate, EndDate, ref startDate, ref endDate);
|
||||
|
||||
if (cancelled == false)
|
||||
CalendarView.EnsureVisible(startDate, startDate.AddDays(1));
|
||||
}
|
||||
|
||||
ExtendSelection(ref startDate, ref endDate);
|
||||
}
|
||||
else
|
||||
{
|
||||
startDate = startDate.AddDays(dx);
|
||||
endDate = endDate.AddDays(dx);
|
||||
|
||||
if (IsNewRange(startDate, endDate) == true)
|
||||
{
|
||||
if (CalendarView.WeekDayCanExtendRange == false)
|
||||
return;
|
||||
|
||||
cancelled = CalendarView.DoViewDateChanging(this,
|
||||
StartDate, EndDate, ref startDate, ref endDate);
|
||||
|
||||
if (cancelled == false)
|
||||
CalendarView.EnsureVisible(startDate, startDate.AddDays(1));
|
||||
}
|
||||
|
||||
DateSelectionAnchor = startDate;
|
||||
}
|
||||
|
||||
if (cancelled == false)
|
||||
{
|
||||
CalendarView.DateSelectionStart = startDate;
|
||||
CalendarView.DateSelectionEnd = endDate;
|
||||
}
|
||||
|
||||
EnsureSelectionVisible();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsNewRange(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
return (startDate < DayColumns[0].Date ||
|
||||
endDate > DayColumns[NumberOfColumns - 1].Date.AddDays(1));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user