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