[622] | 1 | namespace IndianHealthService.ClinicalScheduling
|
---|
| 2 | {
|
---|
| 3 | using System;
|
---|
| 4 | using System.Collections;
|
---|
| 5 | using System.ComponentModel;
|
---|
| 6 | using System.Drawing;
|
---|
| 7 | using System.Globalization;
|
---|
| 8 | using System.Runtime.CompilerServices;
|
---|
| 9 | using System.Runtime.InteropServices;
|
---|
| 10 | using System.Windows.Forms;
|
---|
[824] | 11 |
|
---|
[622] | 12 | /// <summary>
|
---|
[821] | 13 | /// This class is reponsible for rendering the Calendar Grid.
|
---|
[622] | 14 | /// </summary>
|
---|
[1027] | 15 | public class CalendarGrid : ScrollableControl
|
---|
[622] | 16 | {
|
---|
[821] | 17 | private IContainer components;
|
---|
[622] | 18 | private Font fontArial10;
|
---|
| 19 | private Font fontArial8;
|
---|
| 20 | private CGAppointments m_Appointments;
|
---|
| 21 | private Hashtable m_ApptOverlapTable;
|
---|
| 22 | private bool m_bAutoDrag = true;
|
---|
| 23 | private bool m_bDragDropStart;
|
---|
| 24 | private bool m_bDrawWalkIns = true;
|
---|
| 25 | private bool m_bGridEnter;
|
---|
[1106] | 26 | //private bool m_bInitialUpdate;
|
---|
[622] | 27 | private bool m_bMouseDown;
|
---|
| 28 | private bool m_bScroll;
|
---|
| 29 | private bool m_bScrollDown;
|
---|
| 30 | private bool m_bSelectingRange;
|
---|
| 31 | private int m_cellHeight;
|
---|
| 32 | private int m_cellWidth;
|
---|
| 33 | private int m_col0Width;
|
---|
| 34 | private Hashtable m_ColumnInfoTable;
|
---|
| 35 | private CGCell m_currentCell;
|
---|
| 36 | private DateTime m_dtStart;
|
---|
| 37 | private Font m_fCell;
|
---|
| 38 | private string m_GridBackColor;
|
---|
| 39 | private CGCells m_gridCells;
|
---|
| 40 | private int m_nColumns = 5;
|
---|
| 41 | private int m_nSelectID;
|
---|
| 42 | private int m_nTimeScale = 20;
|
---|
| 43 | private ArrayList m_pAvArray;
|
---|
| 44 | private string m_sDragSource;
|
---|
| 45 | private CGAppointments m_SelectedAppointments;
|
---|
| 46 | private CGRange m_selectedRange;
|
---|
| 47 | private StringFormat m_sf;
|
---|
| 48 | private StringFormat m_sfHour;
|
---|
| 49 | private StringFormat m_sfRight;
|
---|
| 50 | private ArrayList m_sResourcesArray;
|
---|
[1106] | 51 | private Timer m_Timer; // Timer used in Drag and Drop Operations
|
---|
[622] | 52 | private ToolTip m_toolTip;
|
---|
[1075] | 53 | private const int WM_HSCROLL = 0x114; // Horizontal Scrolling Windows Message
|
---|
| 54 | private const int WM_VSCROLL = 0x115; // Vertical Scrolling Windows Message
|
---|
| 55 | private const int WM_MOUSEWHEEL = 0x20a; // Windows Mouse Scrolling Message
|
---|
[1106] | 56 | private System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
|
---|
[622] | 57 |
|
---|
[1106] | 58 |
|
---|
[1068] | 59 | public delegate void CGAppointmentChangedHandler(object sender, CGAppointmentChangedArgs e);
|
---|
| 60 | public event CGAppointmentChangedHandler CGAppointmentChanged;
|
---|
[622] | 61 | public event CGAppointmentChangedHandler CGAppointmentAdded;
|
---|
| 62 |
|
---|
[1068] | 63 | public delegate void CGSelectionChangedHandler(object sender, CGSelectionChangedArgs e);
|
---|
[622] | 64 | public event CGSelectionChangedHandler CGSelectionChanged;
|
---|
| 65 |
|
---|
| 66 | public CalendarGrid()
|
---|
| 67 | {
|
---|
| 68 | this.InitializeComponent();
|
---|
| 69 | base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
---|
| 70 | base.SetStyle(ControlStyles.UserPaint, true);
|
---|
| 71 | base.SetStyle(ControlStyles.DoubleBuffer, true);
|
---|
| 72 | this.m_nColumns = 5;
|
---|
| 73 | this.m_gridCells = new CGCells();
|
---|
| 74 | this.m_selectedRange = new CGRange();
|
---|
| 75 | this.m_SelectedAppointments = new CGAppointments();
|
---|
[1073] | 76 | //this.m_Appointments = new CGAppointments();
|
---|
[821] | 77 | this.m_dtStart = new DateTime(2003, 1, 27);
|
---|
[622] | 78 | this.m_ApptOverlapTable = new Hashtable();
|
---|
| 79 | this.m_ColumnInfoTable = new Hashtable();
|
---|
| 80 | this.m_sResourcesArray = new ArrayList();
|
---|
| 81 | base.ResizeRedraw = true;
|
---|
| 82 | this.m_col0Width = 100;
|
---|
| 83 | this.fontArial8 = new Font("Arial", 8f);
|
---|
| 84 | this.fontArial10 = new Font("Arial", 10f);
|
---|
| 85 | this.m_fCell = this.fontArial10;
|
---|
| 86 | this.m_sf = new StringFormat();
|
---|
| 87 | this.m_sfRight = new StringFormat();
|
---|
| 88 | this.m_sfHour = new StringFormat();
|
---|
| 89 | this.m_sf.LineAlignment = StringAlignment.Center;
|
---|
| 90 | this.m_sfRight.LineAlignment = StringAlignment.Center;
|
---|
| 91 | this.m_sfRight.Alignment = StringAlignment.Far;
|
---|
| 92 | this.m_sfHour.LineAlignment = StringAlignment.Center;
|
---|
| 93 | this.m_sfHour.Alignment = StringAlignment.Far;
|
---|
[1106] | 94 | // this.m_bInitialUpdate = false;
|
---|
[622] | 95 | }
|
---|
| 96 |
|
---|
| 97 | private Rectangle AdjustRectForOverlap()
|
---|
| 98 | {
|
---|
| 99 | return new Rectangle();
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | private void AutoDragStart()
|
---|
| 103 | {
|
---|
| 104 | this.m_bAutoDrag = true;
|
---|
| 105 | this.m_Timer = new Timer();
|
---|
| 106 | this.m_Timer.Interval = 5;
|
---|
| 107 | this.m_Timer.Tick += new EventHandler(this.tickEventHandler);
|
---|
| 108 | this.m_Timer.Start();
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | private void AutoDragStop()
|
---|
| 112 | {
|
---|
| 113 | this.m_bAutoDrag = false;
|
---|
| 114 | if (this.m_Timer != null)
|
---|
| 115 | {
|
---|
| 116 | this.m_Timer.Stop();
|
---|
[1106] | 117 | this.m_Timer.Tick -= new EventHandler(this.tickEventHandler);
|
---|
[622] | 118 | this.m_Timer.Dispose();
|
---|
| 119 | this.m_Timer = null;
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | private void BuildGridCellsArray(Graphics g)
|
---|
| 124 | {
|
---|
| 125 | try
|
---|
| 126 | {
|
---|
| 127 | SizeF ef = g.MeasureString("Test", this.m_fCell);
|
---|
| 128 | this.m_cellHeight = ((int) ef.Height) + 4;
|
---|
| 129 | int nColumns = this.m_nColumns;
|
---|
| 130 | int num2 = 60 / this.m_nTimeScale;
|
---|
[821] | 131 | int num3 = 24 * num2;
|
---|
[622] | 132 | nColumns++;
|
---|
| 133 | num3++;
|
---|
| 134 | this.m_cellWidth = 600 / nColumns;
|
---|
| 135 | if (base.ClientRectangle.Width > 600)
|
---|
| 136 | {
|
---|
| 137 | this.m_cellWidth = (base.ClientRectangle.Width - this.m_col0Width) / (nColumns - 1);
|
---|
| 138 | }
|
---|
| 139 | if (this.m_nColumns == 1)
|
---|
| 140 | {
|
---|
| 141 | this.m_cellWidth = base.ClientRectangle.Width - this.m_col0Width;
|
---|
| 142 | }
|
---|
| 143 | g.TranslateTransform((float) base.AutoScrollPosition.X, (float) base.AutoScrollPosition.Y);
|
---|
| 144 | for (int i = num3; i > -1; i--)
|
---|
| 145 | {
|
---|
| 146 | for (int j = 1; j < nColumns; j++)
|
---|
| 147 | {
|
---|
| 148 | int x = 0;
|
---|
| 149 | if (j == 1)
|
---|
| 150 | {
|
---|
| 151 | x = this.m_col0Width;
|
---|
| 152 | }
|
---|
| 153 | if (j > 1)
|
---|
| 154 | {
|
---|
| 155 | x = this.m_col0Width + (this.m_cellWidth * (j - 1));
|
---|
| 156 | }
|
---|
| 157 | Point point = new Point(x, i * this.m_cellHeight);
|
---|
| 158 | Rectangle r = new Rectangle(point.X, point.Y, this.m_cellWidth, this.m_cellHeight);
|
---|
| 159 | if (i != 0)
|
---|
| 160 | {
|
---|
| 161 | CGCell cell = null;
|
---|
| 162 | cell = new CGCell(r, i, j);
|
---|
| 163 | this.m_gridCells.AddCell(cell);
|
---|
| 164 | }
|
---|
| 165 | }
|
---|
| 166 | }
|
---|
| 167 | }
|
---|
| 168 | catch (Exception exception)
|
---|
| 169 | {
|
---|
| 170 | string message = exception.Message;
|
---|
| 171 | }
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | private void CalendarGrid_DragDrop(object Sender, DragEventArgs e)
|
---|
| 175 | {
|
---|
| 176 | CGAppointment data = (CGAppointment) e.Data.GetData(typeof(CGAppointment));
|
---|
| 177 | Point point = base.PointToClient(new Point(e.X, e.Y));
|
---|
| 178 | int x = point.X - base.AutoScrollPosition.X;
|
---|
| 179 | int y = point.Y - base.AutoScrollPosition.Y;
|
---|
| 180 | Point pt = new Point(x, y);
|
---|
| 181 | foreach (DictionaryEntry entry in this.m_gridCells.CellHashTable)
|
---|
| 182 | {
|
---|
| 183 | CGCell cgCell = (CGCell) entry.Value;
|
---|
| 184 | if (cgCell.CellRectangle.Contains(pt))
|
---|
| 185 | {
|
---|
| 186 | DateTime timeFromCell = this.GetTimeFromCell(cgCell);
|
---|
| 187 | string resourceFromColumn = this.GetResourceFromColumn(cgCell.CellColumn);
|
---|
| 188 | int duration = data.Duration;
|
---|
| 189 | TimeSpan span = new TimeSpan(0, duration, 0);
|
---|
| 190 | DateTime time2 = timeFromCell + span;
|
---|
| 191 | data.Selected = false;
|
---|
| 192 | this.m_nSelectID = 0;
|
---|
| 193 | CGAppointmentChangedArgs args = new CGAppointmentChangedArgs();
|
---|
| 194 | args.Appointment = data;
|
---|
| 195 | args.StartTime = timeFromCell;
|
---|
| 196 | args.EndTime = time2;
|
---|
| 197 | args.Resource = resourceFromColumn;
|
---|
| 198 | args.OldResource = data.Resource;
|
---|
| 199 | args.AccessTypeID = data.AccessTypeID;
|
---|
| 200 | args.Slots = data.Slots;
|
---|
| 201 | if (this.ApptDragSource == "grid")
|
---|
| 202 | {
|
---|
| 203 | this.CGAppointmentChanged(this, args);
|
---|
| 204 | }
|
---|
| 205 | else
|
---|
| 206 | {
|
---|
| 207 | this.CGAppointmentAdded(this, args);
|
---|
| 208 | }
|
---|
| 209 | break;
|
---|
| 210 | }
|
---|
| 211 | }
|
---|
| 212 | this.SetOverlapTable();
|
---|
| 213 | base.Invalidate();
|
---|
| 214 | }
|
---|
| 215 |
|
---|
| 216 | private void CalendarGrid_DragEnter(object Sender, DragEventArgs e)
|
---|
| 217 | {
|
---|
| 218 | if (e.Data.GetDataPresent(typeof(CGAppointment)))
|
---|
| 219 | {
|
---|
| 220 | if ((e.KeyState & 8) == 8)
|
---|
| 221 | {
|
---|
| 222 | e.Effect = DragDropEffects.Copy;
|
---|
| 223 | }
|
---|
| 224 | else
|
---|
| 225 | {
|
---|
| 226 | e.Effect = DragDropEffects.Move;
|
---|
| 227 | }
|
---|
| 228 | }
|
---|
| 229 | else
|
---|
| 230 | {
|
---|
| 231 | e.Effect = DragDropEffects.None;
|
---|
| 232 | }
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 | private void CalendarGrid_MouseDown(object sender, MouseEventArgs e)
|
---|
| 236 | {
|
---|
[1106] | 237 | //watch.Restart();
|
---|
[622] | 238 | if (e.Button == MouseButtons.Left)
|
---|
| 239 | {
|
---|
| 240 | foreach (DictionaryEntry entry in this.m_gridCells.CellHashTable)
|
---|
| 241 | {
|
---|
| 242 | CGCell cell = (CGCell) entry.Value;
|
---|
| 243 | cell.IsSelected = false;
|
---|
| 244 | }
|
---|
| 245 | this.m_selectedRange.Cells.ClearAllCells();
|
---|
| 246 | this.m_bMouseDown = true;
|
---|
| 247 | this.OnLButtonDown(e.X, e.Y, true);
|
---|
| 248 | }
|
---|
| 249 | }
|
---|
| 250 |
|
---|
| 251 | private void CalendarGrid_MouseMove(object Sender, MouseEventArgs e)
|
---|
| 252 | {
|
---|
[1106] | 253 | //test
|
---|
| 254 | //System.Diagnostics.Debug.Write(watch.ElapsedMilliseconds + "\n");
|
---|
| 255 | //test
|
---|
| 256 |
|
---|
| 257 | //if the left mouse button is down and we are moving the mouse...
|
---|
[622] | 258 | if (this.m_bMouseDown)
|
---|
| 259 | {
|
---|
[1106] | 260 | //if Y axis is outside the top or bottom
|
---|
[622] | 261 | if ((e.Y >= base.ClientRectangle.Bottom) || (e.Y <= base.ClientRectangle.Top))
|
---|
| 262 | {
|
---|
[1106] | 263 | //start auto scrolling. m_bScrollDown decides whether we scroll up or down.
|
---|
[622] | 264 | this.m_bScrollDown = e.Y >= base.ClientRectangle.Bottom;
|
---|
[1106] | 265 | AutoDragStart();
|
---|
[622] | 266 | }
|
---|
[1106] | 267 |
|
---|
| 268 | //if Y axis within client rectagle, stop dragging (whether you started or not)
|
---|
[622] | 269 | if ((e.Y < base.ClientRectangle.Bottom) && (e.Y > base.ClientRectangle.Top))
|
---|
| 270 | {
|
---|
[1106] | 271 | AutoDragStop();
|
---|
[622] | 272 | }
|
---|
| 273 | if (this.m_bSelectingRange)
|
---|
| 274 | {
|
---|
| 275 | this.OnLButtonDown(e.X, e.Y, false);
|
---|
| 276 | }
|
---|
| 277 | if (this.m_nSelectID != 0)
|
---|
| 278 | {
|
---|
| 279 | if (this.m_bGridEnter)
|
---|
| 280 | {
|
---|
| 281 | this.m_bGridEnter = false;
|
---|
| 282 | }
|
---|
| 283 | else if (!this.m_bDragDropStart)
|
---|
| 284 | {
|
---|
| 285 | CGAppointment data = (CGAppointment) this.m_Appointments.AppointmentTable[this.m_nSelectID];
|
---|
| 286 | this.ApptDragSource = "grid";
|
---|
| 287 | base.DoDragDrop(data, DragDropEffects.Move);
|
---|
| 288 | this.m_bDragDropStart = true;
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 | }
|
---|
| 292 | else
|
---|
| 293 | {
|
---|
[1106] | 294 | //test
|
---|
| 295 | AutoDragStop(); //is this needed?
|
---|
| 296 | //test
|
---|
[622] | 297 | int y = e.Y - base.AutoScrollPosition.Y;
|
---|
| 298 | int x = e.X - base.AutoScrollPosition.X;
|
---|
| 299 | Point pt = new Point(x, y);
|
---|
| 300 | foreach (CGAppointment appointment2 in this.m_Appointments.AppointmentTable.Values)
|
---|
| 301 | {
|
---|
| 302 | if (appointment2.GridRectangle.Contains(pt))
|
---|
| 303 | {
|
---|
| 304 | this.m_toolTip.SetToolTip(this, appointment2.ToString());
|
---|
| 305 | return;
|
---|
| 306 | }
|
---|
| 307 | }
|
---|
| 308 | this.m_toolTip.RemoveAll();
|
---|
[821] | 309 |
|
---|
| 310 | ////smh new code -- select cell
|
---|
| 311 | //int nRow = -1;
|
---|
| 312 | //int nCol = -1;
|
---|
| 313 |
|
---|
| 314 | ////Is the mouse over a known cell? If so, highlight cell
|
---|
| 315 | //if (this.HitTest(x, y, ref nRow, ref nCol))
|
---|
| 316 | //{
|
---|
| 317 | // CGCell cellFromRowCol = this.m_gridCells.GetCellFromRowCol(nRow, nCol);
|
---|
| 318 | // if (cellFromRowCol != null)
|
---|
| 319 | // {
|
---|
| 320 | // this.m_currentCell = cellFromRowCol;
|
---|
| 321 | // this.m_selectedRange.StartCell = null;
|
---|
| 322 | // this.m_selectedRange.EndCell = null;
|
---|
| 323 | // this.m_selectedRange.CreateRange(this.m_gridCells, cellFromRowCol, cellFromRowCol);
|
---|
| 324 | // this.m_bSelectingRange = true;
|
---|
| 325 | // cellFromRowCol.IsSelected = true;
|
---|
| 326 | // base.Invalidate(this.m_currentCell.CellRectangle);
|
---|
| 327 | // //base.Invalidate();
|
---|
| 328 | // }
|
---|
| 329 | //}
|
---|
| 330 |
|
---|
| 331 |
|
---|
[622] | 332 | }
|
---|
| 333 | }
|
---|
| 334 |
|
---|
| 335 | private void CalendarGrid_MouseUp(object Sender, MouseEventArgs e)
|
---|
| 336 | {
|
---|
| 337 | if (this.m_bAutoDrag)
|
---|
| 338 | {
|
---|
| 339 | this.m_bAutoDrag = false;
|
---|
| 340 | this.AutoDragStop();
|
---|
| 341 | }
|
---|
| 342 | this.m_bMouseDown = false;
|
---|
| 343 | if (this.m_bSelectingRange)
|
---|
| 344 | {
|
---|
| 345 | CGSelectionChangedArgs args = new CGSelectionChangedArgs();
|
---|
| 346 | args.StartTime = this.GetTimeFromCell(this.m_selectedRange.StartCell);
|
---|
| 347 | args.EndTime = this.GetTimeFromCell(this.m_selectedRange.EndCell);
|
---|
| 348 | args.Resource = this.GetResourceFromColumn(this.m_selectedRange.StartCell.CellColumn);
|
---|
| 349 | if (args.EndTime < args.StartTime)
|
---|
| 350 | {
|
---|
| 351 | DateTime startTime = args.StartTime;
|
---|
| 352 | args.StartTime = args.EndTime;
|
---|
| 353 | args.EndTime = startTime;
|
---|
| 354 | }
|
---|
| 355 | TimeSpan span = new TimeSpan(0, 0, this.m_nTimeScale, 0, 0);
|
---|
| 356 | args.EndTime += span;
|
---|
| 357 | this.CGSelectionChanged(this, args);
|
---|
| 358 | this.m_bSelectingRange = false;
|
---|
| 359 | }
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | private void CalendarGrid_Paint(object sender, PaintEventArgs e)
|
---|
| 363 | {
|
---|
| 364 | if (e.Graphics != null)
|
---|
| 365 | {
|
---|
| 366 | this.DrawGrid(e.Graphics);
|
---|
[1106] | 367 | /*
|
---|
[622] | 368 | if (!this.m_bInitialUpdate)
|
---|
| 369 | {
|
---|
| 370 | this.SetAppointmentTypes();
|
---|
| 371 | base.Invalidate();
|
---|
| 372 | this.m_bInitialUpdate = true;
|
---|
| 373 | }
|
---|
[1106] | 374 | */
|
---|
[622] | 375 | }
|
---|
| 376 | }
|
---|
| 377 |
|
---|
| 378 | public void CloseGrid()
|
---|
| 379 | {
|
---|
| 380 | foreach (CGAppointment appointment in this.m_Appointments.AppointmentTable.Values)
|
---|
| 381 | {
|
---|
| 382 | appointment.Selected = false;
|
---|
| 383 | }
|
---|
| 384 | this.m_nSelectID = 0;
|
---|
| 385 | }
|
---|
| 386 |
|
---|
| 387 | protected override void Dispose(bool disposing)
|
---|
| 388 | {
|
---|
| 389 | if (disposing && (this.components != null))
|
---|
| 390 | {
|
---|
| 391 | this.components.Dispose();
|
---|
| 392 | }
|
---|
| 393 | base.Dispose(disposing);
|
---|
| 394 | }
|
---|
| 395 |
|
---|
| 396 | private void DrawAppointments(Graphics g, int col0Width, int cellWidth, int cellHeight)
|
---|
| 397 | {
|
---|
| 398 | if (!base.DesignMode && (this.m_Appointments != null))
|
---|
| 399 | {
|
---|
| 400 | int num = 0;
|
---|
| 401 | int num2 = 0;
|
---|
| 402 | int x = 0;
|
---|
| 403 | ArrayList list = new ArrayList();
|
---|
| 404 | foreach (CGAppointment appointment in this.m_Appointments.AppointmentTable.Values)
|
---|
| 405 | {
|
---|
| 406 | bool bRet = false;
|
---|
| 407 | Rectangle rect = this.GetAppointmentRect(appointment, col0Width, cellWidth, cellHeight, out bRet);
|
---|
| 408 | if (bRet && (!appointment.WalkIn || this.m_bDrawWalkIns))
|
---|
| 409 | {
|
---|
| 410 | rect.Inflate(-10, 0);
|
---|
| 411 | num = (int) this.m_ApptOverlapTable[appointment.m_nKey];
|
---|
| 412 | num2 = rect.Right - rect.Left;
|
---|
| 413 | x = num2 / (num + 1);
|
---|
| 414 | rect.Width = x;
|
---|
| 415 | if (num > 0)
|
---|
| 416 | {
|
---|
| 417 | foreach (object obj2 in list)
|
---|
| 418 | {
|
---|
| 419 | Rectangle rectangle2 = (Rectangle) obj2;
|
---|
| 420 | if (rect.IntersectsWith(rectangle2))
|
---|
| 421 | {
|
---|
| 422 | rect.Offset(x, 0);
|
---|
| 423 | }
|
---|
| 424 | }
|
---|
| 425 | }
|
---|
| 426 | appointment.GridRectangle = rect;
|
---|
| 427 | if (appointment.Selected)
|
---|
| 428 | {
|
---|
| 429 | Pen pen = new Pen(Brushes.Black, 5f);
|
---|
| 430 | g.DrawRectangle(pen, rect);
|
---|
| 431 | pen.Dispose();
|
---|
| 432 | }
|
---|
| 433 | else
|
---|
| 434 | {
|
---|
| 435 | g.DrawRectangle(Pens.Blue, rect);
|
---|
| 436 | }
|
---|
| 437 | string s = appointment.ToString();
|
---|
| 438 | Rectangle rectangle3 = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 1, rect.Height - 1);
|
---|
| 439 | g.FillRectangle(Brushes.White, rectangle3);
|
---|
| 440 | Brush black = Brushes.Black;
|
---|
| 441 | if (appointment.CheckInTime.Ticks > 0L)
|
---|
| 442 | {
|
---|
| 443 | black = Brushes.Green;
|
---|
| 444 | g.FillRectangle(Brushes.LightGreen, rectangle3);
|
---|
| 445 | }
|
---|
| 446 | if (appointment.NoShow)
|
---|
| 447 | {
|
---|
| 448 | black = Brushes.Red;
|
---|
| 449 | g.FillRectangle(Brushes.LightPink, rectangle3);
|
---|
| 450 | }
|
---|
| 451 | if (appointment.WalkIn)
|
---|
| 452 | {
|
---|
| 453 | black = Brushes.Blue;
|
---|
| 454 | g.FillRectangle(Brushes.LightSteelBlue, rectangle3);
|
---|
| 455 | }
|
---|
| 456 | g.DrawString(s, this.fontArial8, black, rectangle3);
|
---|
| 457 | list.Add(rect);
|
---|
| 458 | }
|
---|
| 459 | }
|
---|
| 460 | }
|
---|
| 461 | }
|
---|
| 462 |
|
---|
| 463 | private void DrawGrid(Graphics g)
|
---|
| 464 | {
|
---|
[821] | 465 | //Default color of grid lines is black
|
---|
| 466 | Pen pen = new Pen(Color.Black);
|
---|
| 467 |
|
---|
| 468 | //each cell's height is Height of Arial Font 10pt + 10 pixels (by default 26 pixels)
|
---|
| 469 | SizeF ef = g.MeasureString("Test", this.m_fCell);
|
---|
| 470 | int num = 10;
|
---|
| 471 | this.m_cellHeight = ((int) ef.Height) + num;
|
---|
| 472 |
|
---|
| 473 | // Number of columns is dynamic based on user of Grid. See Property Columns. Default 5 in init.
|
---|
| 474 | int nColumns = this.m_nColumns;
|
---|
| 475 |
|
---|
| 476 | //Time scale is also dynamic. Property TimeScale. Default 20 (minutes)
|
---|
| 477 | //num3 stands for number of cells per hour
|
---|
| 478 | int num3 = 60 / this.m_nTimeScale;
|
---|
| 479 | //num4 stands for number of cells per day (aka rows in the grid)
|
---|
| 480 | int num4 = 24 * num3;
|
---|
| 481 | //Add extra column to hold time in the left hand corner
|
---|
| 482 | nColumns++;
|
---|
| 483 | //add extra row to represent dates or resources (depending on which view we are in)
|
---|
| 484 | //Not sure of which variable controls view yet.
|
---|
| 485 | num4++;
|
---|
| 486 |
|
---|
| 487 | // 100 px is reserved no matter our column sizes for displaying the time scale
|
---|
| 488 |
|
---|
| 489 | // Minimum cell width is 600/columns (100 px by default)
|
---|
| 490 | this.m_cellWidth = 600 / nColumns;
|
---|
| 491 |
|
---|
| 492 | // if we happen to have more than 600 pixels in our Client Window then cell
|
---|
| 493 | // is (Width-100) / (number of date columns)
|
---|
| 494 | if (base.ClientRectangle.Width > 600)
|
---|
[622] | 495 | {
|
---|
[821] | 496 | this.m_cellWidth = (base.ClientRectangle.Width - this.m_col0Width) / (nColumns - 1);
|
---|
| 497 | }
|
---|
| 498 |
|
---|
| 499 | // If we have one column, the cell width is the itself - 100
|
---|
| 500 | if (this.m_nColumns == 1)
|
---|
| 501 | {
|
---|
| 502 | this.m_cellWidth = base.ClientRectangle.Width - this.m_col0Width;
|
---|
| 503 | }
|
---|
| 504 |
|
---|
| 505 | // Our rectangle will start scrolling if width is less than 600 and height less than height of all cells comb
|
---|
| 506 | // Of course Height will scroll all the time unless you have a humungous screen
|
---|
| 507 | base.AutoScrollMinSize = new Size(600, this.m_cellHeight * num4);
|
---|
| 508 |
|
---|
| 509 | // Default Rectangle is Gray
|
---|
| 510 | g.FillRectangle(Brushes.LightGray, base.ClientRectangle);
|
---|
| 511 |
|
---|
| 512 | int num5 = 0; //Minutes (start at 0)
|
---|
| 513 | int num6 = 0; //Hour (starts at 0)
|
---|
| 514 |
|
---|
| 515 | // flag is true only if there are no cells what so ever in the screen
|
---|
| 516 | // Only true when no resource is selected.
|
---|
| 517 | bool flag = this.m_gridCells.CellCount == 0;
|
---|
| 518 |
|
---|
| 519 | // Move the base point from the client screen to the scrolling region top-left corner.
|
---|
| 520 | g.TranslateTransform((float) base.AutoScrollPosition.X, (float) base.AutoScrollPosition.Y);
|
---|
| 521 |
|
---|
[846] | 522 | // This for loop draws the time scale (although I haven't completely traced it out)
|
---|
[821] | 523 | // For each row except the first one (i starts from 1 rather than zero)
|
---|
| 524 | for (int i = 1; i < num4; i++)
|
---|
| 525 | {
|
---|
| 526 | int x = 0;
|
---|
| 527 | //point is (0, 1st Cell Start) then (0, 2nd Cell Start) until we run out
|
---|
| 528 | Point point = new Point(x, i * this.m_cellHeight);
|
---|
| 529 | //rectangle2 represents each cell rectangle
|
---|
| 530 | Rectangle rectangle2 = new Rectangle(point.X, point.Y, this.m_cellWidth, this.m_cellHeight);
|
---|
| 531 | //rect stands for the time scale rectangle; width is 100px; Height is length of the hour on grid
|
---|
| 532 | Rectangle rect = new Rectangle(0, rectangle2.Y, this.m_col0Width, rectangle2.Height * num3);
|
---|
| 533 | //height is length of hour
|
---|
| 534 | int height = rect.Height;
|
---|
| 535 | //Min font height is 25 pixels (100/4)--see below where it's used
|
---|
| 536 | height = (height > (this.m_col0Width / 4)) ? (this.m_col0Width / 4) : height;
|
---|
| 537 |
|
---|
| 538 | //if we are the top of the time scale (at hour:00) -- num5 is min
|
---|
| 539 | if (num5 == 0)
|
---|
[622] | 540 | {
|
---|
[821] | 541 | // Fill time scale triangle with Gray (remember, this is the whole hour!)
|
---|
| 542 | g.FillRectangle(Brushes.LightGray, rect);
|
---|
| 543 | // Draw Rectangle
|
---|
| 544 | g.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
|
---|
| 545 | //Pad time with at least one zero to make it 2 digits
|
---|
| 546 | string str = string.Format("{0}", num6).PadLeft(2, '0');
|
---|
| 547 | //Font height using pixels. Min is 25 pixels
|
---|
| 548 | Font font = new Font("Arial", (float) height, FontStyle.Bold, GraphicsUnit.Pixel);
|
---|
| 549 | // rectangle3 is the left half of the time rectangle
|
---|
| 550 | Rectangle rectangle3 = new Rectangle(rect.X, rect.Y, rect.Width / 2, rect.Height);
|
---|
| 551 | // In this left half, draw the hours (m_sfHour is the stringformat:
|
---|
| 552 | // Horizontal Center and Right Justified to rectangle3
|
---|
| 553 | g.DrawString(str, font, Brushes.Black, rectangle3, this.m_sfHour);
|
---|
| 554 | // Increment hour
|
---|
| 555 | num6++;
|
---|
| 556 | font.Dispose();
|
---|
[622] | 557 | }
|
---|
[821] | 558 |
|
---|
| 559 | // Pad minutes with zeros to be 2 digits long
|
---|
| 560 | string s = string.Format("{0}", num5);
|
---|
| 561 | s = ":" + s.PadLeft(2, '0');
|
---|
| 562 | // Rectangle starts at
|
---|
| 563 | // X: 2/3rds of width of Time Rectangle
|
---|
| 564 | // Y: Top of the current time slot cell
|
---|
| 565 | // Width: 1/3rd of the width of the Time Rectangle
|
---|
| 566 | // Height: Height of a time slot
|
---|
| 567 | Rectangle layoutRectangle = new Rectangle(rect.X + ((rect.Width * 2) / 3), rectangle2.Top, rect.Width / 3, rectangle2.Height);
|
---|
| 568 | // At in this rectangle, write the minutes. Horizontal Ctr and Right Justified to Rectangle
|
---|
| 569 | g.DrawString(s, this.m_fCell, Brushes.Black, layoutRectangle, this.m_sfRight);
|
---|
[846] | 570 | // Draw Line from two points, just under the time we have just written
|
---|
[821] | 571 | Point point2 = new Point(rect.X + ((rect.Width * 2) / 3), rectangle2.Bottom);
|
---|
| 572 | Point point3 = new Point(rect.Right, rectangle2.Bottom);
|
---|
| 573 | g.DrawLine(pen, point2, point3);
|
---|
[846] | 574 | // Increment the minutes with the time scale
|
---|
[821] | 575 | num5 += this.m_nTimeScale;
|
---|
[846] | 576 | // If miniutes reaches 60, reset to zero
|
---|
[821] | 577 | num5 = (num5 >= 60) ? 0 : num5;
|
---|
[846] | 578 | // When we reach the bottom (num4 - 1 is # of rows) and we are not scrolling
|
---|
[821] | 579 | if ((i == (num4 - 1)) && !this.m_bScroll)
|
---|
[622] | 580 | {
|
---|
[846] | 581 | // Fill the last cell with Gray (?)
|
---|
[821] | 582 | g.TranslateTransform((float) -base.AutoScrollPosition.X, (float) -base.AutoScrollPosition.Y);
|
---|
| 583 | rect = new Rectangle(0, 0, this.m_col0Width, this.m_cellHeight);
|
---|
| 584 | g.FillRectangle(Brushes.LightGray, rect);
|
---|
| 585 | g.DrawRectangle(pen, rect);
|
---|
| 586 | g.TranslateTransform((float) base.AutoScrollPosition.X, (float) base.AutoScrollPosition.Y);
|
---|
[622] | 587 | }
|
---|
[821] | 588 | }
|
---|
[846] | 589 |
|
---|
| 590 | //This for loop draws the cells
|
---|
| 591 | //Start from the bottom (num4 is # of rows) and go down to the zeroth row (ie date row/resource row)
|
---|
[821] | 592 | for (int j = num4; j > -1; j--)
|
---|
| 593 | {
|
---|
[846] | 594 | // For each column - 1 (we start at 1, not zero-->We drew the first column anyways in the 1st loop)
|
---|
[821] | 595 | for (int k = 1; k < nColumns; k++)
|
---|
[622] | 596 | {
|
---|
[846] | 597 | int num12 = 0; // X-axis position
|
---|
| 598 | if (k == 1) // If we are at the first column, start at 100px (default)
|
---|
[622] | 599 | {
|
---|
[821] | 600 | num12 = this.m_col0Width;
|
---|
[622] | 601 | }
|
---|
[846] | 602 | if (k > 1) //
|
---|
[622] | 603 | {
|
---|
[821] | 604 | num12 = this.m_col0Width + (this.m_cellWidth * (k - 1));
|
---|
[622] | 605 | }
|
---|
[821] | 606 | Point point4 = new Point(num12, j * this.m_cellHeight);
|
---|
| 607 | Rectangle r = new Rectangle(point4.X, point4.Y, this.m_cellWidth, this.m_cellHeight);
|
---|
| 608 | if (j != 0)
|
---|
[622] | 609 | {
|
---|
[821] | 610 | CGCell cellFromRowCol = null;
|
---|
| 611 | if (flag)
|
---|
[622] | 612 | {
|
---|
[821] | 613 | cellFromRowCol = new CGCell(r, j, k);
|
---|
| 614 | this.m_gridCells.AddCell(cellFromRowCol);
|
---|
[622] | 615 | }
|
---|
[821] | 616 | else
|
---|
[622] | 617 | {
|
---|
[821] | 618 | cellFromRowCol = this.m_gridCells.GetCellFromRowCol(j, k);
|
---|
| 619 | cellFromRowCol.CellRectangle = r;
|
---|
[622] | 620 | }
|
---|
[821] | 621 | if (this.m_sResourcesArray.Count > 0)
|
---|
[622] | 622 | {
|
---|
[1106] | 623 | //IMP
|
---|
| 624 | //this is the place where we the selected cells are drawn in Light Light Blue.
|
---|
| 625 | //IMP
|
---|
[821] | 626 | if (this.m_selectedRange.CellIsInRange(cellFromRowCol))
|
---|
[622] | 627 | {
|
---|
[821] | 628 | g.FillRectangle(Brushes.Aquamarine, r);
|
---|
[1106] | 629 | //g.FillRectangle(Brushes.AntiqueWhite, r);
|
---|
[622] | 630 | }
|
---|
| 631 | else
|
---|
| 632 | {
|
---|
[821] | 633 | g.FillRectangle(cellFromRowCol.AppointmentTypeColor, r);
|
---|
[622] | 634 | }
|
---|
[821] | 635 | g.DrawRectangle(pen, r.X, r.Y, r.Width, r.Height);
|
---|
| 636 | if (j == 1)
|
---|
[622] | 637 | {
|
---|
[821] | 638 | this.DrawAppointments(g, this.m_col0Width, this.m_cellWidth, this.m_cellHeight);
|
---|
[622] | 639 | }
|
---|
| 640 | }
|
---|
[821] | 641 | continue;
|
---|
| 642 | }
|
---|
| 643 | if (!this.m_bScroll)
|
---|
| 644 | {
|
---|
| 645 | g.TranslateTransform(0f, (float) -base.AutoScrollPosition.Y);
|
---|
| 646 | Rectangle rectangle6 = r;
|
---|
| 647 | g.FillRectangle(Brushes.LightBlue, rectangle6);
|
---|
| 648 | g.DrawRectangle(pen, rectangle6.X, rectangle6.Y, rectangle6.Width, rectangle6.Height);
|
---|
| 649 | string str3 = "";
|
---|
| 650 | if (this.m_sResourcesArray.Count > 1)
|
---|
[622] | 651 | {
|
---|
[821] | 652 | foreach (DictionaryEntry entry in this.m_ColumnInfoTable)
|
---|
[622] | 653 | {
|
---|
[821] | 654 | int num13 = (int) entry.Value;
|
---|
| 655 | num13++;
|
---|
| 656 | if (num13 == k)
|
---|
[622] | 657 | {
|
---|
[821] | 658 | str3 = entry.Key.ToString();
|
---|
| 659 | break;
|
---|
[622] | 660 | }
|
---|
| 661 | }
|
---|
[821] | 662 | }
|
---|
| 663 | else
|
---|
| 664 | {
|
---|
| 665 | DateTime dtStart = this.m_dtStart;
|
---|
| 666 | if (k > 1)
|
---|
[622] | 667 | {
|
---|
[821] | 668 | dtStart = dtStart.AddDays((double) (k - 1));
|
---|
[622] | 669 | }
|
---|
[821] | 670 | string format = "ddd, MMM d";
|
---|
| 671 | str3 = dtStart.ToString(format, DateTimeFormatInfo.InvariantInfo);
|
---|
[622] | 672 | }
|
---|
[821] | 673 | g.DrawString(str3, this.m_fCell, Brushes.Black, rectangle6, this.m_sf);
|
---|
| 674 | g.TranslateTransform(0f, (float) base.AutoScrollPosition.Y);
|
---|
[622] | 675 | }
|
---|
| 676 | }
|
---|
| 677 | }
|
---|
[821] | 678 | this.m_bScroll = false;
|
---|
| 679 | pen.Dispose();
|
---|
[622] | 680 | }
|
---|
| 681 |
|
---|
| 682 | public Rectangle GetAppointmentRect(CGAppointment a, int col0Width, int cellWidth, int cellHeight, out bool bRet)
|
---|
| 683 | {
|
---|
| 684 | DateTime startTime = a.StartTime;
|
---|
| 685 | DateTime endTime = a.EndTime;
|
---|
| 686 | string resource = a.Resource;
|
---|
[900] | 687 | int originX = 0;
|
---|
| 688 | int originY = 0;
|
---|
| 689 | int recHeight = 0;
|
---|
| 690 | int recWidth = 0;
|
---|
| 691 | int columnToPutAppt = 0;
|
---|
[622] | 692 | Rectangle rectangle = new Rectangle();
|
---|
[900] | 693 | int startTotalMinutesoffset = (int) startTime.TimeOfDay.TotalMinutes;
|
---|
| 694 | int endTotalMinutesoffset = (int) endTime.TimeOfDay.TotalMinutes;
|
---|
[1038] | 695 |
|
---|
| 696 | // To fix a bug with 1 day view: if the start time of appt is before Calendar Start Date, don't draw anything.
|
---|
| 697 | if (startTime < this.m_dtStart)
|
---|
| 698 | {
|
---|
| 699 | bRet = false;
|
---|
| 700 | return rectangle;
|
---|
| 701 | }
|
---|
| 702 |
|
---|
[900] | 703 | // if grid has more than one reource
|
---|
[622] | 704 | if (this.m_sResourcesArray.Count > 1)
|
---|
| 705 | {
|
---|
[900] | 706 | // get zero based index
|
---|
| 707 | columnToPutAppt = (int) this.m_ColumnInfoTable[resource];
|
---|
| 708 | // increment to 1 based index
|
---|
| 709 | columnToPutAppt++;
|
---|
[622] | 710 | }
|
---|
| 711 | else
|
---|
| 712 | {
|
---|
[900] | 713 | columnToPutAppt = (startTime - this.m_dtStart).Days + 1;
|
---|
[622] | 714 | }
|
---|
[1038] | 715 | // this if should not get tripped; it did the same function as the new first if check.
|
---|
| 716 | //if (columnToPutAppt < 1)
|
---|
| 717 | //{
|
---|
| 718 | // bRet = false;
|
---|
| 719 | // return rectangle;
|
---|
| 720 | //}
|
---|
[900] | 721 | originX = col0Width + (cellWidth * (columnToPutAppt - 1));
|
---|
| 722 | int num8 = startTotalMinutesoffset + this.m_nTimeScale;
|
---|
| 723 | int num9 = (endTotalMinutesoffset > 0) ? endTotalMinutesoffset : 0x5a0;
|
---|
| 724 | num9 -= startTotalMinutesoffset;
|
---|
| 725 | originY = (cellHeight * num8) / this.m_nTimeScale;
|
---|
| 726 | recHeight = (cellHeight * num9) / this.m_nTimeScale;
|
---|
| 727 | recWidth = cellWidth;
|
---|
| 728 | rectangle.X = originX;
|
---|
| 729 | rectangle.Y = originY;
|
---|
| 730 | rectangle.Width = recWidth;
|
---|
| 731 | rectangle.Height = recHeight;
|
---|
[622] | 732 | bRet = true;
|
---|
| 733 | return rectangle;
|
---|
| 734 | }
|
---|
| 735 |
|
---|
[1123] | 736 | /// <summary>
|
---|
| 737 | /// Translates a StartTime into a Cell, for coloring
|
---|
| 738 | /// </summary>
|
---|
| 739 | /// <param name="dDate"></param>
|
---|
| 740 | /// <param name="nRow"></param>
|
---|
| 741 | /// <param name="nCol"></param>
|
---|
| 742 | /// <param name="bStartCell"></param>
|
---|
| 743 | /// <param name="sResource"></param>
|
---|
| 744 | /// <returns></returns>
|
---|
[622] | 745 | public bool GetCellFromTime(DateTime dDate, ref int nRow, ref int nCol, bool bStartCell, string sResource)
|
---|
| 746 | {
|
---|
| 747 | int num = (dDate.Hour * 60) + dDate.Minute;
|
---|
| 748 | nRow = num / this.m_nTimeScale;
|
---|
| 749 | if (bStartCell)
|
---|
| 750 | {
|
---|
| 751 | nRow++;
|
---|
| 752 | }
|
---|
| 753 | if (this.m_sResourcesArray.Count > 1)
|
---|
| 754 | {
|
---|
| 755 | if (sResource == "")
|
---|
| 756 | {
|
---|
| 757 | sResource = this.m_sResourcesArray[0].ToString();
|
---|
| 758 | }
|
---|
| 759 | nCol = (int) this.m_ColumnInfoTable[sResource];
|
---|
| 760 | nCol++;
|
---|
| 761 | return true;
|
---|
| 762 | }
|
---|
| 763 | DateTime time = new DateTime(dDate.Year, dDate.Month, dDate.Day);
|
---|
| 764 | TimeSpan span = (TimeSpan) (time - this.StartDate);
|
---|
| 765 | int totalDays = 0;
|
---|
| 766 | totalDays = (int) span.TotalDays;
|
---|
| 767 | nCol = totalDays;
|
---|
| 768 | nCol++;
|
---|
| 769 | return true;
|
---|
| 770 | }
|
---|
| 771 |
|
---|
| 772 | private string GetResourceFromColumn(int nCol)
|
---|
| 773 | {
|
---|
| 774 | if (this.m_sResourcesArray.Count == 1)
|
---|
| 775 | {
|
---|
| 776 | return this.m_sResourcesArray[0].ToString();
|
---|
| 777 | }
|
---|
| 778 | foreach (DictionaryEntry entry in this.m_ColumnInfoTable)
|
---|
| 779 | {
|
---|
| 780 | int num = (int) entry.Value;
|
---|
| 781 | num++;
|
---|
| 782 | if (num == nCol)
|
---|
| 783 | {
|
---|
| 784 | return entry.Key.ToString();
|
---|
| 785 | }
|
---|
| 786 | }
|
---|
| 787 | return "";
|
---|
| 788 | }
|
---|
| 789 |
|
---|
| 790 | public bool GetSelectedTime(out DateTime dStart, out DateTime dEnd, out string sResource)
|
---|
| 791 | {
|
---|
| 792 | if (this.m_selectedRange.Cells.CellCount == 0)
|
---|
| 793 | {
|
---|
| 794 | dEnd = new DateTime();
|
---|
| 795 | dStart = dEnd;
|
---|
| 796 | sResource = "";
|
---|
| 797 | return false;
|
---|
| 798 | }
|
---|
| 799 | CGCell startCell = this.m_selectedRange.StartCell;
|
---|
| 800 | CGCell endCell = this.m_selectedRange.EndCell;
|
---|
| 801 | if (startCell.CellRow > endCell.CellRow)
|
---|
| 802 | {
|
---|
| 803 | CGCell cell3 = startCell;
|
---|
| 804 | startCell = endCell;
|
---|
| 805 | endCell = cell3;
|
---|
| 806 | }
|
---|
| 807 | dStart = this.GetTimeFromCell(startCell);
|
---|
| 808 | dEnd = this.GetTimeFromCell(endCell);
|
---|
| 809 | dEnd = dEnd.AddMinutes((double) this.m_nTimeScale);
|
---|
| 810 | sResource = this.GetResourceFromColumn(startCell.CellColumn);
|
---|
| 811 | return true;
|
---|
| 812 | }
|
---|
| 813 |
|
---|
| 814 | public bool GetSelectedType(out int nAccessTypeID)
|
---|
| 815 | {
|
---|
| 816 | nAccessTypeID = 0;
|
---|
| 817 | if (this.m_selectedRange.Cells.CellCount == 0)
|
---|
| 818 | {
|
---|
| 819 | return false;
|
---|
| 820 | }
|
---|
| 821 | CGCell startCell = this.m_selectedRange.StartCell;
|
---|
| 822 | CGCell endCell = this.m_selectedRange.EndCell;
|
---|
| 823 | if (startCell.CellRow > endCell.CellRow)
|
---|
| 824 | {
|
---|
| 825 | CGCell cell3 = startCell;
|
---|
| 826 | startCell = endCell;
|
---|
| 827 | endCell = cell3;
|
---|
| 828 | }
|
---|
| 829 | DateTime timeFromCell = this.GetTimeFromCell(startCell);
|
---|
| 830 | DateTime time2 = this.GetTimeFromCell(endCell).AddMinutes((double) this.m_nTimeScale);
|
---|
| 831 | foreach (CGAvailability availability in this.m_pAvArray)
|
---|
| 832 | {
|
---|
[1095] | 833 | if (TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2))
|
---|
[622] | 834 | {
|
---|
| 835 | nAccessTypeID = availability.AvailabilityType;
|
---|
| 836 | break;
|
---|
| 837 | }
|
---|
| 838 | }
|
---|
| 839 | return (nAccessTypeID > 0);
|
---|
| 840 | }
|
---|
| 841 |
|
---|
| 842 | public DateTime GetTimeFromCell(CGCell cgCell)
|
---|
| 843 | {
|
---|
| 844 | int cellRow = cgCell.CellRow;
|
---|
| 845 | int cellColumn = cgCell.CellColumn;
|
---|
| 846 | DateTime dtStart = this.m_dtStart;
|
---|
| 847 | int num3 = (cellRow - 1) * this.m_nTimeScale;
|
---|
| 848 | int num4 = num3 / 60;
|
---|
| 849 | if (num4 > 0)
|
---|
| 850 | {
|
---|
| 851 | num3 = num3 % (num4 * 60);
|
---|
| 852 | }
|
---|
| 853 | dtStart = dtStart.AddHours((double) num4).AddMinutes((double) num3);
|
---|
| 854 | if (this.m_sResourcesArray.Count == 1)
|
---|
| 855 | {
|
---|
| 856 | dtStart = dtStart.AddDays((double) (cellColumn - 1));
|
---|
| 857 | }
|
---|
| 858 | return dtStart;
|
---|
| 859 | }
|
---|
| 860 |
|
---|
| 861 | public bool GetTypeFromCell(CGCell cgCell, out int nAccessTypeID)
|
---|
| 862 | {
|
---|
| 863 | nAccessTypeID = 0;
|
---|
| 864 | CGCell cell = cgCell;
|
---|
| 865 | CGCell cell2 = cgCell;
|
---|
| 866 | if (cell.CellRow > cell2.CellRow)
|
---|
| 867 | {
|
---|
| 868 | CGCell cell3 = cell;
|
---|
| 869 | cell = cell2;
|
---|
| 870 | cell2 = cell3;
|
---|
| 871 | }
|
---|
| 872 | DateTime timeFromCell = this.GetTimeFromCell(cell);
|
---|
| 873 | DateTime time2 = this.GetTimeFromCell(cell2).AddMinutes((double) this.m_nTimeScale);
|
---|
| 874 | foreach (CGAvailability availability in this.m_pAvArray)
|
---|
| 875 | {
|
---|
[1095] | 876 | if (TimesOverlap(availability.StartTime, availability.EndTime, timeFromCell, time2))
|
---|
[622] | 877 | {
|
---|
| 878 | nAccessTypeID = availability.AvailabilityType;
|
---|
| 879 | break;
|
---|
| 880 | }
|
---|
| 881 | }
|
---|
| 882 | return (nAccessTypeID > 0);
|
---|
| 883 | }
|
---|
| 884 |
|
---|
| 885 | private bool HitTest(int X, int Y, ref int nRow, ref int nCol)
|
---|
| 886 | {
|
---|
| 887 | Y -= base.AutoScrollPosition.Y;
|
---|
| 888 | X -= base.AutoScrollPosition.X;
|
---|
| 889 | foreach (DictionaryEntry entry in this.m_gridCells)
|
---|
| 890 | {
|
---|
| 891 | CGCell cell = (CGCell) entry.Value;
|
---|
| 892 | if (cell.CellRectangle.Contains(X, Y))
|
---|
| 893 | {
|
---|
| 894 | nRow = cell.CellRow;
|
---|
| 895 | nCol = cell.CellColumn;
|
---|
| 896 | return true;
|
---|
| 897 | }
|
---|
| 898 | }
|
---|
| 899 | return false;
|
---|
| 900 | }
|
---|
| 901 |
|
---|
| 902 | public void InitializeCalendarGrid()
|
---|
| 903 | {
|
---|
| 904 | this.AllowDrop = true;
|
---|
| 905 | }
|
---|
| 906 |
|
---|
| 907 | private void InitializeComponent()
|
---|
| 908 | {
|
---|
[821] | 909 | this.components = new System.ComponentModel.Container();
|
---|
| 910 | this.m_toolTip = new System.Windows.Forms.ToolTip(this.components);
|
---|
| 911 | this.SuspendLayout();
|
---|
| 912 | //
|
---|
| 913 | // CalendarGrid
|
---|
| 914 | //
|
---|
[622] | 915 | this.AutoScroll = true;
|
---|
[821] | 916 | this.AutoScrollMinSize = new System.Drawing.Size(600, 400);
|
---|
| 917 | this.BackColor = System.Drawing.SystemColors.Window;
|
---|
| 918 | this.Paint += new System.Windows.Forms.PaintEventHandler(this.CalendarGrid_Paint);
|
---|
| 919 | this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.CalendarGrid_MouseMove);
|
---|
| 920 | this.DragDrop += new System.Windows.Forms.DragEventHandler(this.CalendarGrid_DragDrop);
|
---|
| 921 | this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CalendarGrid_MouseDown);
|
---|
| 922 | this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.CalendarGrid_MouseUp);
|
---|
| 923 | this.DragEnter += new System.Windows.Forms.DragEventHandler(this.CalendarGrid_DragEnter);
|
---|
| 924 | this.ResumeLayout(false);
|
---|
| 925 |
|
---|
[622] | 926 | }
|
---|
| 927 |
|
---|
[1095] | 928 | private static int MinSince80(DateTime d)
|
---|
[622] | 929 | {
|
---|
[821] | 930 | DateTime time = new DateTime(1980, 1, 1, 0, 0, 0);
|
---|
[622] | 931 | TimeSpan span = (TimeSpan) (d - time);
|
---|
| 932 | return (int) span.TotalMinutes;
|
---|
| 933 | }
|
---|
| 934 |
|
---|
| 935 | private void OnLButtonDown(int X, int Y, bool bStart)
|
---|
| 936 | {
|
---|
| 937 | this.m_bDragDropStart = false;
|
---|
| 938 | this.m_nSelectID = 0;
|
---|
| 939 | if (!this.m_bSelectingRange)
|
---|
| 940 | {
|
---|
| 941 | int y = Y - base.AutoScrollPosition.Y;
|
---|
| 942 | int x = X - base.AutoScrollPosition.X;
|
---|
| 943 | Point pt = new Point(x, y);
|
---|
| 944 | if (Control.ModifierKeys == Keys.Control)
|
---|
| 945 | {
|
---|
| 946 | this.m_bMouseDown = false;
|
---|
| 947 | foreach (CGAppointment appointment in this.m_Appointments.AppointmentTable.Values)
|
---|
| 948 | {
|
---|
| 949 | if (!appointment.GridRectangle.Contains(pt))
|
---|
| 950 | {
|
---|
| 951 | continue;
|
---|
| 952 | }
|
---|
| 953 | if (this.m_SelectedAppointments.AppointmentTable.ContainsKey(appointment.AppointmentKey))
|
---|
| 954 | {
|
---|
| 955 | this.m_SelectedAppointments.RemoveAppointment(appointment.AppointmentKey);
|
---|
| 956 | if (this.m_SelectedAppointments.AppointmentTable.Count == 0)
|
---|
| 957 | {
|
---|
| 958 | this.m_nSelectID = 0;
|
---|
| 959 | }
|
---|
| 960 | else
|
---|
| 961 | {
|
---|
| 962 | foreach (CGAppointment appointment2 in this.m_Appointments.AppointmentTable.Values)
|
---|
| 963 | {
|
---|
| 964 | this.m_nSelectID = appointment2.AppointmentKey;
|
---|
| 965 | }
|
---|
| 966 | }
|
---|
| 967 | }
|
---|
| 968 | else
|
---|
| 969 | {
|
---|
| 970 | this.m_SelectedAppointments.AddAppointment(appointment);
|
---|
| 971 | this.m_nSelectID = appointment.AppointmentKey;
|
---|
| 972 | }
|
---|
| 973 | appointment.Selected = !appointment.Selected;
|
---|
| 974 | break;
|
---|
| 975 | }
|
---|
| 976 | base.Invalidate();
|
---|
| 977 | return;
|
---|
| 978 | }
|
---|
| 979 | foreach (CGAppointment appointment3 in this.m_Appointments.AppointmentTable.Values)
|
---|
| 980 | {
|
---|
| 981 | if (!appointment3.GridRectangle.Contains(pt))
|
---|
| 982 | {
|
---|
| 983 | continue;
|
---|
| 984 | }
|
---|
| 985 | this.m_bMouseDown = false;
|
---|
| 986 | if (appointment3.Selected)
|
---|
| 987 | {
|
---|
| 988 | appointment3.Selected = false;
|
---|
| 989 | this.m_SelectedAppointments.ClearAllAppointments();
|
---|
| 990 | this.m_nSelectID = 0;
|
---|
| 991 | }
|
---|
| 992 | else
|
---|
| 993 | {
|
---|
| 994 | foreach (CGAppointment appointment4 in this.m_Appointments.AppointmentTable.Values)
|
---|
| 995 | {
|
---|
| 996 | appointment4.Selected = false;
|
---|
| 997 | }
|
---|
| 998 | this.m_SelectedAppointments.ClearAllAppointments();
|
---|
| 999 | this.m_SelectedAppointments.AddAppointment(appointment3);
|
---|
| 1000 | appointment3.Selected = true;
|
---|
| 1001 | this.m_nSelectID = appointment3.AppointmentKey;
|
---|
| 1002 | this.m_bMouseDown = true;
|
---|
| 1003 | this.m_bGridEnter = true;
|
---|
| 1004 | }
|
---|
| 1005 | base.Invalidate();
|
---|
| 1006 | return;
|
---|
| 1007 | }
|
---|
| 1008 | }
|
---|
| 1009 | int nRow = -1;
|
---|
| 1010 | int nCol = -1;
|
---|
| 1011 | if (this.HitTest(X, Y, ref nRow, ref nCol))
|
---|
| 1012 | {
|
---|
| 1013 | CGCell cellFromRowCol = this.m_gridCells.GetCellFromRowCol(nRow, nCol);
|
---|
| 1014 | if (cellFromRowCol != null)
|
---|
| 1015 | {
|
---|
| 1016 | if (bStart)
|
---|
| 1017 | {
|
---|
| 1018 | this.m_currentCell = cellFromRowCol;
|
---|
| 1019 | this.m_selectedRange.StartCell = null;
|
---|
| 1020 | this.m_selectedRange.EndCell = null;
|
---|
| 1021 | this.m_selectedRange.CreateRange(this.m_gridCells, cellFromRowCol, cellFromRowCol);
|
---|
| 1022 | bStart = false;
|
---|
| 1023 | this.m_bMouseDown = true;
|
---|
| 1024 | this.m_bSelectingRange = true;
|
---|
| 1025 | }
|
---|
| 1026 | else if (cellFromRowCol != this.m_currentCell)
|
---|
| 1027 | {
|
---|
| 1028 | if (!this.m_selectedRange.Cells.CellHashTable.ContainsKey(cellFromRowCol.Key))
|
---|
| 1029 | {
|
---|
| 1030 | this.m_selectedRange.AppendCell(this.m_gridCells, cellFromRowCol);
|
---|
| 1031 | }
|
---|
| 1032 | else
|
---|
| 1033 | {
|
---|
| 1034 | bool bUp = cellFromRowCol.CellRow < this.m_currentCell.CellRow;
|
---|
| 1035 | this.m_selectedRange.SubtractCell(this.m_gridCells, cellFromRowCol, bUp);
|
---|
| 1036 | }
|
---|
| 1037 | this.m_currentCell = cellFromRowCol;
|
---|
| 1038 | }
|
---|
| 1039 | cellFromRowCol.IsSelected = true;
|
---|
| 1040 | base.Invalidate();
|
---|
| 1041 | }
|
---|
| 1042 | }
|
---|
| 1043 | }
|
---|
| 1044 |
|
---|
| 1045 | public void OnUpdateArrays()
|
---|
| 1046 | {
|
---|
| 1047 | try
|
---|
| 1048 | {
|
---|
| 1049 | this.m_gridCells.ClearAllCells();
|
---|
| 1050 | this.SetColumnInfo();
|
---|
| 1051 | this.SetOverlapTable();
|
---|
| 1052 | Graphics g = base.CreateGraphics();
|
---|
| 1053 | this.BuildGridCellsArray(g);
|
---|
| 1054 | this.SetAppointmentTypes();
|
---|
| 1055 | }
|
---|
| 1056 | catch (Exception exception)
|
---|
| 1057 | {
|
---|
| 1058 | string message = exception.Message;
|
---|
| 1059 | }
|
---|
| 1060 | }
|
---|
| 1061 |
|
---|
[1083] | 1062 | /// <summary>
|
---|
| 1063 | /// Draws Availabilities. Draws Some of the Empty cells (don't know where the rest go) with the Khaki color
|
---|
| 1064 | /// </summary>
|
---|
[622] | 1065 | private void SetAppointmentTypes()
|
---|
| 1066 | {
|
---|
| 1067 | if (this.m_gridCells.CellCount != 0)
|
---|
| 1068 | {
|
---|
| 1069 | foreach (DictionaryEntry entry in this.m_gridCells.CellHashTable)
|
---|
| 1070 | {
|
---|
| 1071 | CGCell cell = (CGCell) entry.Value;
|
---|
| 1072 | cell.AppointmentTypeColor = (this.m_GridBackColor == "blue") ? Brushes.CornflowerBlue : Brushes.Khaki;
|
---|
| 1073 | }
|
---|
| 1074 | if ((this.m_pAvArray != null) && (this.m_pAvArray.Count != 0))
|
---|
| 1075 | {
|
---|
| 1076 | foreach (CGAvailability availability in this.m_pAvArray)
|
---|
| 1077 | {
|
---|
| 1078 | int nRow = 0;
|
---|
| 1079 | int nCol = 0;
|
---|
| 1080 | int num3 = 0;
|
---|
| 1081 | int num4 = 0;
|
---|
| 1082 | Brush brush = new SolidBrush(Color.FromArgb(availability.Red, availability.Green, availability.Blue));
|
---|
| 1083 | this.GetCellFromTime(availability.StartTime, ref nRow, ref nCol, true, availability.ResourceList);
|
---|
| 1084 | this.GetCellFromTime(availability.EndTime, ref num3, ref num4, false, availability.ResourceList);
|
---|
| 1085 | for (int i = nCol; i <= num4; i++)
|
---|
| 1086 | {
|
---|
| 1087 | for (int j = nRow; (i == num4) && (j <= num3); j++)
|
---|
| 1088 | {
|
---|
| 1089 | string str = "r" + j.ToString() + "c" + i.ToString();
|
---|
| 1090 | CGCell cell2 = (CGCell) this.m_gridCells.CellHashTable[str];
|
---|
| 1091 | if (cell2 != null)
|
---|
| 1092 | {
|
---|
| 1093 | cell2.AppointmentTypeColor = brush;
|
---|
| 1094 | }
|
---|
| 1095 | }
|
---|
| 1096 | }
|
---|
| 1097 | }
|
---|
| 1098 | }
|
---|
| 1099 | }
|
---|
| 1100 | }
|
---|
| 1101 |
|
---|
| 1102 | private void SetColumnInfo()
|
---|
| 1103 | {
|
---|
| 1104 | this.m_ColumnInfoTable.Clear();
|
---|
| 1105 | for (int i = 0; i < this.m_sResourcesArray.Count; i++)
|
---|
| 1106 | {
|
---|
| 1107 | this.m_ColumnInfoTable.Add(this.m_sResourcesArray[i], i);
|
---|
| 1108 | }
|
---|
| 1109 | if (this.m_sResourcesArray.Count > 1)
|
---|
| 1110 | {
|
---|
| 1111 | this.m_nColumns = this.m_sResourcesArray.Count;
|
---|
| 1112 | }
|
---|
| 1113 | }
|
---|
| 1114 |
|
---|
| 1115 | public void SetOverlapTable()
|
---|
| 1116 | {
|
---|
| 1117 | Hashtable hashtable = new Hashtable();
|
---|
| 1118 | int y = 0;
|
---|
| 1119 | int num2 = 0;
|
---|
| 1120 | int x = 0;
|
---|
| 1121 | foreach (CGAppointment appointment in this.m_Appointments.AppointmentTable.Values)
|
---|
| 1122 | {
|
---|
| 1123 | if (!appointment.WalkIn || this.m_bDrawWalkIns)
|
---|
| 1124 | {
|
---|
| 1125 | string resource = appointment.Resource;
|
---|
| 1126 | y = appointment.StartTime.Minute + (60 * appointment.StartTime.Hour);
|
---|
| 1127 | num2 = appointment.EndTime.Minute + (60 * appointment.EndTime.Hour);
|
---|
| 1128 | x = (this.m_sResourcesArray.Count > 1) ? (((int) this.m_ColumnInfoTable[resource]) + 1) : appointment.StartTime.DayOfYear;
|
---|
| 1129 | Rectangle rectangle = new Rectangle(x, y, 1, num2 - y);
|
---|
| 1130 | hashtable.Add(appointment.m_nKey, rectangle);
|
---|
| 1131 | }
|
---|
| 1132 | }
|
---|
| 1133 | this.m_ApptOverlapTable.Clear();
|
---|
| 1134 | foreach (int num4 in hashtable.Keys)
|
---|
| 1135 | {
|
---|
| 1136 | this.m_ApptOverlapTable.Add(num4, 0);
|
---|
| 1137 | }
|
---|
[821] | 1138 | // Here it draws the Dates on Top
|
---|
[622] | 1139 | if (this.m_ApptOverlapTable.Count != 0)
|
---|
| 1140 | {
|
---|
| 1141 | int num5 = (this.m_sResourcesArray.Count > 1) ? 1 : this.StartDate.DayOfYear;
|
---|
| 1142 | int num6 = (this.m_sResourcesArray.Count > 1) ? (this.m_sResourcesArray.Count + 1) : (this.Columns + this.StartDate.DayOfYear);
|
---|
| 1143 | for (int i = num5; i < num6; i++)
|
---|
| 1144 | {
|
---|
| 1145 | ArrayList list = new ArrayList();
|
---|
| 1146 | for (int j = 1; j < this.Rows; j++)
|
---|
| 1147 | {
|
---|
| 1148 | Rectangle rectangle2 = new Rectangle(i, j * this.m_nTimeScale, 1, this.m_nTimeScale);
|
---|
| 1149 | int num9 = -1;
|
---|
| 1150 | list.Clear();
|
---|
| 1151 | foreach (int num10 in hashtable.Keys)
|
---|
| 1152 | {
|
---|
| 1153 | Rectangle rect = (Rectangle) hashtable[num10];
|
---|
| 1154 | if (rectangle2.IntersectsWith(rect))
|
---|
| 1155 | {
|
---|
| 1156 | num9++;
|
---|
| 1157 | list.Add(num10);
|
---|
| 1158 | }
|
---|
| 1159 | }
|
---|
| 1160 | if (num9 > 0)
|
---|
| 1161 | {
|
---|
| 1162 | foreach (object obj2 in list)
|
---|
| 1163 | {
|
---|
| 1164 | int num11 = (int) obj2;
|
---|
| 1165 | if (((int) this.m_ApptOverlapTable[num11]) < num9)
|
---|
| 1166 | {
|
---|
| 1167 | this.m_ApptOverlapTable[num11] = num9;
|
---|
| 1168 | }
|
---|
| 1169 | }
|
---|
| 1170 | }
|
---|
| 1171 | }
|
---|
| 1172 | }
|
---|
| 1173 | }
|
---|
| 1174 | }
|
---|
| 1175 |
|
---|
[1106] | 1176 | /// <summary>
|
---|
| 1177 | /// Handles scrolling when the mouse button is down
|
---|
| 1178 | /// </summary>
|
---|
| 1179 | /// <param name="o"></param>
|
---|
| 1180 | /// <param name="e"></param>
|
---|
[622] | 1181 | private void tickEventHandler(object o, EventArgs e)
|
---|
| 1182 | {
|
---|
[1106] | 1183 | //if there are still WM_TIME messages in the Queue after the timer is dead, don't do anything.
|
---|
| 1184 | if (this.m_Timer == null) return;
|
---|
| 1185 |
|
---|
[622] | 1186 | Point point = new Point(base.AutoScrollPosition.X, base.AutoScrollPosition.Y);
|
---|
| 1187 | int x = point.X;
|
---|
| 1188 | int num = point.Y * -1;
|
---|
[1106] | 1189 | num = this.m_bScrollDown ? (num + 2) : (num - 2);
|
---|
[622] | 1190 | point.Y = num;
|
---|
| 1191 | base.AutoScrollPosition = point;
|
---|
| 1192 | base.Invalidate();
|
---|
| 1193 | }
|
---|
| 1194 |
|
---|
[1095] | 1195 | /// <summary>
|
---|
| 1196 | /// Do 2 time ranges overlap each other?
|
---|
| 1197 | /// </summary>
|
---|
| 1198 | /// <param name="dStart1">First Start Time</param>
|
---|
| 1199 | /// <param name="dEnd1">First End Time</param>
|
---|
| 1200 | /// <param name="dStart2">Second Start Time</param>
|
---|
| 1201 | /// <param name="dEnd2">Second End Time</param>
|
---|
| 1202 | /// <returns>True or False</returns>
|
---|
| 1203 | public static bool TimesOverlap(DateTime dStart1, DateTime dEnd1, DateTime dStart2, DateTime dEnd2)
|
---|
[622] | 1204 | {
|
---|
| 1205 | long ticks = dEnd1.Ticks - dStart1.Ticks;
|
---|
| 1206 | TimeSpan ts = new TimeSpan(ticks);
|
---|
| 1207 | ticks = dEnd2.Ticks - dStart2.Ticks;
|
---|
| 1208 | new TimeSpan(ticks).Subtract(ts);
|
---|
| 1209 | Rectangle rect = new Rectangle();
|
---|
| 1210 | Rectangle rectangle2 = new Rectangle();
|
---|
| 1211 | rect.X = 0;
|
---|
| 1212 | rectangle2.X = 0;
|
---|
| 1213 | rect.Width = 1;
|
---|
| 1214 | rectangle2.Width = 1;
|
---|
[1095] | 1215 | rect.Y = MinSince80(dStart1);
|
---|
| 1216 | rect.Height = MinSince80(dEnd1) - rect.Y;
|
---|
| 1217 | rectangle2.Y = MinSince80(dStart2);
|
---|
| 1218 | rectangle2.Height = MinSince80(dEnd2) - rectangle2.Y;
|
---|
[622] | 1219 | return rectangle2.IntersectsWith(rect);
|
---|
| 1220 | }
|
---|
| 1221 |
|
---|
[1068] | 1222 | public void PositionGrid(int nHour)
|
---|
| 1223 | {
|
---|
| 1224 | //Position grid to nHour
|
---|
| 1225 | int nRow = 0, nCol = 0;
|
---|
| 1226 | DateTime dStart = DateTime.Today;
|
---|
| 1227 | dStart = dStart.AddHours(nHour);
|
---|
| 1228 | this.GetCellFromTime(dStart, ref nRow, ref nCol, false, "");
|
---|
| 1229 | int nHeight = this.CellHeight + 10;
|
---|
| 1230 | nHeight *= nRow;
|
---|
| 1231 | this.AutoScrollPosition = new Point(50, nHeight);
|
---|
| 1232 | this.Invalidate();
|
---|
| 1233 | }
|
---|
| 1234 |
|
---|
| 1235 |
|
---|
[821] | 1236 | /// <summary>
|
---|
| 1237 | /// The purpose of this is to properly draw the date boxes at the top of the calendar grid.
|
---|
| 1238 | /// Otherwise, when scrolling, it gets garbled.
|
---|
| 1239 | /// </summary>
|
---|
[1075] | 1240 | /// <param name="msg">Handles three messages:
|
---|
[821] | 1241 | /// WM_VSCROLL (0x115 - Vertical Scrolling)
|
---|
| 1242 | /// WM_HSCROLL (0x114 - Horizontal Scrolling)
|
---|
[1075] | 1243 | /// WM_MOUSEWHEEL (0x20a - Mouse Wheel Movement)
|
---|
[821] | 1244 | /// </param>
|
---|
[622] | 1245 | protected override void WndProc(ref Message msg)
|
---|
| 1246 | {
|
---|
| 1247 | try
|
---|
| 1248 | {
|
---|
[1075] | 1249 | if (msg.Msg == WM_VSCROLL || msg.Msg == WM_MOUSEWHEEL)
|
---|
[622] | 1250 | {
|
---|
| 1251 | this.m_bScroll = true;
|
---|
| 1252 | base.Invalidate(false);
|
---|
| 1253 | this.m_bScroll = false;
|
---|
| 1254 | }
|
---|
[821] | 1255 | if (msg.Msg == WM_HSCROLL)
|
---|
[622] | 1256 | {
|
---|
| 1257 | base.Invalidate(false);
|
---|
| 1258 | }
|
---|
| 1259 | base.WndProc(ref msg);
|
---|
| 1260 | }
|
---|
| 1261 | catch (Exception exception)
|
---|
| 1262 | {
|
---|
| 1263 | MessageBox.Show("CalendarGrid::WndProc: " + exception.Message + "\nStack: " + exception.StackTrace);
|
---|
| 1264 | }
|
---|
| 1265 | }
|
---|
| 1266 |
|
---|
| 1267 | public CGAppointments Appointments
|
---|
| 1268 | {
|
---|
| 1269 | get
|
---|
| 1270 | {
|
---|
| 1271 | return this.m_Appointments;
|
---|
| 1272 | }
|
---|
| 1273 | set
|
---|
| 1274 | {
|
---|
| 1275 | this.m_Appointments = value;
|
---|
| 1276 | }
|
---|
| 1277 | }
|
---|
| 1278 |
|
---|
| 1279 | public string ApptDragSource
|
---|
| 1280 | {
|
---|
| 1281 | get
|
---|
| 1282 | {
|
---|
| 1283 | return this.m_sDragSource;
|
---|
| 1284 | }
|
---|
| 1285 | set
|
---|
| 1286 | {
|
---|
| 1287 | this.m_sDragSource = value;
|
---|
| 1288 | }
|
---|
| 1289 | }
|
---|
| 1290 |
|
---|
| 1291 | public ArrayList AvailabilityArray
|
---|
| 1292 | {
|
---|
| 1293 | get
|
---|
| 1294 | {
|
---|
| 1295 | return this.m_pAvArray;
|
---|
| 1296 | }
|
---|
| 1297 | set
|
---|
| 1298 | {
|
---|
| 1299 | this.m_pAvArray = value;
|
---|
| 1300 | }
|
---|
| 1301 | }
|
---|
| 1302 |
|
---|
| 1303 | public int CellHeight
|
---|
| 1304 | {
|
---|
| 1305 | get
|
---|
| 1306 | {
|
---|
| 1307 | return this.m_cellHeight;
|
---|
| 1308 | }
|
---|
| 1309 | }
|
---|
| 1310 |
|
---|
| 1311 | public ToolTip CGToolTip
|
---|
| 1312 | {
|
---|
| 1313 | get
|
---|
| 1314 | {
|
---|
| 1315 | return this.m_toolTip;
|
---|
| 1316 | }
|
---|
| 1317 | }
|
---|
| 1318 |
|
---|
| 1319 | public int Columns
|
---|
| 1320 | {
|
---|
| 1321 | get
|
---|
| 1322 | {
|
---|
| 1323 | return this.m_nColumns;
|
---|
| 1324 | }
|
---|
| 1325 | set
|
---|
| 1326 | {
|
---|
| 1327 | if ((value > 0) && (value < 11))
|
---|
| 1328 | {
|
---|
| 1329 | this.m_nColumns = value;
|
---|
| 1330 | this.m_gridCells.ClearAllCells();
|
---|
| 1331 | this.m_selectedRange.Cells.ClearAllCells();
|
---|
| 1332 | Graphics g = base.CreateGraphics();
|
---|
| 1333 | this.BuildGridCellsArray(g);
|
---|
| 1334 | this.SetAppointmentTypes();
|
---|
| 1335 | base.Invalidate();
|
---|
| 1336 | }
|
---|
| 1337 | }
|
---|
| 1338 | }
|
---|
| 1339 |
|
---|
| 1340 | public bool DrawWalkIns
|
---|
| 1341 | {
|
---|
| 1342 | get
|
---|
| 1343 | {
|
---|
| 1344 | return this.m_bDrawWalkIns;
|
---|
| 1345 | }
|
---|
| 1346 | set
|
---|
| 1347 | {
|
---|
| 1348 | this.m_bDrawWalkIns = value;
|
---|
| 1349 | }
|
---|
| 1350 | }
|
---|
| 1351 |
|
---|
| 1352 | public string GridBackColor
|
---|
| 1353 | {
|
---|
| 1354 | get
|
---|
| 1355 | {
|
---|
| 1356 | return this.m_GridBackColor;
|
---|
| 1357 | }
|
---|
| 1358 | set
|
---|
| 1359 | {
|
---|
| 1360 | this.m_GridBackColor = value;
|
---|
| 1361 | }
|
---|
| 1362 | }
|
---|
| 1363 |
|
---|
| 1364 | public bool GridEnter
|
---|
| 1365 | {
|
---|
| 1366 | get
|
---|
| 1367 | {
|
---|
| 1368 | return this.m_bGridEnter;
|
---|
| 1369 | }
|
---|
| 1370 | set
|
---|
| 1371 | {
|
---|
| 1372 | this.m_bGridEnter = value;
|
---|
| 1373 | }
|
---|
| 1374 | }
|
---|
| 1375 |
|
---|
| 1376 | public ArrayList Resources
|
---|
| 1377 | {
|
---|
| 1378 | get
|
---|
| 1379 | {
|
---|
| 1380 | return this.m_sResourcesArray;
|
---|
| 1381 | }
|
---|
| 1382 | set
|
---|
| 1383 | {
|
---|
| 1384 | this.m_sResourcesArray = value;
|
---|
| 1385 | }
|
---|
| 1386 | }
|
---|
| 1387 |
|
---|
| 1388 | public int Rows
|
---|
| 1389 | {
|
---|
| 1390 | get
|
---|
| 1391 | {
|
---|
| 1392 | return (0x5a0 / this.m_nTimeScale);
|
---|
| 1393 | }
|
---|
| 1394 | }
|
---|
| 1395 |
|
---|
| 1396 | public int SelectedAppointment
|
---|
| 1397 | {
|
---|
| 1398 | get
|
---|
| 1399 | {
|
---|
| 1400 | return this.m_nSelectID;
|
---|
| 1401 | }
|
---|
| 1402 | set
|
---|
| 1403 | {
|
---|
| 1404 | this.m_nSelectID = value;
|
---|
| 1405 | }
|
---|
| 1406 | }
|
---|
| 1407 |
|
---|
| 1408 | public CGAppointments SelectedAppointments
|
---|
| 1409 | {
|
---|
| 1410 | get
|
---|
| 1411 | {
|
---|
| 1412 | return this.m_SelectedAppointments;
|
---|
| 1413 | }
|
---|
| 1414 | }
|
---|
| 1415 |
|
---|
| 1416 | public CGRange SelectedRange
|
---|
| 1417 | {
|
---|
| 1418 | get
|
---|
| 1419 | {
|
---|
| 1420 | return this.m_selectedRange;
|
---|
| 1421 | }
|
---|
| 1422 | }
|
---|
| 1423 |
|
---|
| 1424 | public DateTime StartDate
|
---|
| 1425 | {
|
---|
| 1426 | get
|
---|
| 1427 | {
|
---|
| 1428 | return this.m_dtStart;
|
---|
| 1429 | }
|
---|
| 1430 | set
|
---|
| 1431 | {
|
---|
[1123] | 1432 | //this.m_dtStart = value;
|
---|
| 1433 | this.m_dtStart = value.Date; // only date portion!!!//smh
|
---|
[622] | 1434 | }
|
---|
| 1435 | }
|
---|
| 1436 |
|
---|
| 1437 | public int TimeScale
|
---|
| 1438 | {
|
---|
| 1439 | get
|
---|
| 1440 | {
|
---|
| 1441 | return this.m_nTimeScale;
|
---|
| 1442 | }
|
---|
| 1443 | set
|
---|
| 1444 | {
|
---|
| 1445 | if ((((value == 5) || (value == 10)) || ((value == 15) || (value == 20))) || ((value == 30) || (value == 60)))
|
---|
| 1446 | {
|
---|
| 1447 | this.m_nTimeScale = value;
|
---|
| 1448 | this.m_gridCells.ClearAllCells();
|
---|
| 1449 | this.m_selectedRange.Cells.ClearAllCells();
|
---|
| 1450 | Graphics g = base.CreateGraphics();
|
---|
| 1451 | this.BuildGridCellsArray(g);
|
---|
| 1452 | this.SetAppointmentTypes();
|
---|
| 1453 | base.Invalidate();
|
---|
| 1454 | }
|
---|
| 1455 | }
|
---|
| 1456 | }
|
---|
[821] | 1457 |
|
---|
[622] | 1458 | }
|
---|
| 1459 | }
|
---|
| 1460 |
|
---|