Changeset 1073 for Scheduling/trunk/cs
- Timestamp:
- Jan 20, 2011, 9:32:28 AM (14 years ago)
- Location:
- Scheduling/trunk/cs/bsdx0200GUISourceCode
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAppointments.cs
r622 r1073 8 8 /// </summary> 9 9 [Serializable] 10 public class CGAppointments : IEnumerable 10 public class CGAppointments : IEnumerable, ICloneable 11 11 { 12 12 private Hashtable apptList = new Hashtable(); … … 56 56 } 57 57 } 58 59 //smh test 60 //one problem: Hashtable is a shallow copy. 61 //so it shouldn't work. But let's see. 62 public object Clone() 63 { 64 CGAppointments appts = new CGAppointments(); 65 appts.apptList = (Hashtable)apptList.Clone(); 66 return appts; 67 } 58 68 } 59 69 } -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocument.cs
r1071 r1073 270 270 } 271 271 272 273 public void RefreshDocument() 272 //sam: This is a test that duplicates RefreshDocument, but without the UpdateAllViews, 273 // as that has to be done synchornously. 274 //XXXXXX: Needs to be refactored obviously, but now for testing. 275 public void RefreshDocumentAsync() 274 276 { 275 277 bool bRet = false; … … 290 292 291 293 bRet = RefreshSchedule(); 294 } 295 296 297 public void RefreshDocument() 298 { 299 bool bRet = false; 300 if (m_sResourcesArray.Count == 0) 301 return; 302 if (m_sResourcesArray.Count == 1) 303 { 304 bRet = this.WeekNeedsRefresh(1, m_dSelectedDate, out this.m_dStartDate, out this.m_dEndDate); 305 } 306 else 307 { 308 this.m_dStartDate = m_dSelectedDate; 309 this.m_dEndDate = m_dSelectedDate; 310 this.m_dEndDate = this.m_dEndDate.AddHours(23); 311 this.m_dEndDate = this.m_dEndDate.AddMinutes(59); 312 this.m_dEndDate = this.m_dEndDate.AddSeconds(59); 313 } 314 315 bRet = RefreshSchedule(); 316 292 317 this.UpdateAllViews(); 293 318 } … … 344 369 this.DocManager, 345 370 m_dStartDate, 346 this.Appointments,347 371 this.DocName); 348 372 -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs
r1071 r1073 207 207 //A view is a specific arrangement of appointments and availabilites that constitute a document 208 208 CGView view = new CGView(); 209 view.InitializeDocView(doc, _current, doc.StartDate, doc.Appointments,_current.WindowText);209 view.InitializeDocView(doc, _current, doc.StartDate, _current.WindowText); 210 210 211 211 //Handle BMX Event … … 1068 1068 1069 1069 CGView view = new CGView(); 1070 view.InitializeDocView(doc, _current, doc.StartDate, doc.Appointments,_current.WindowText);1070 view.InitializeDocView(doc, _current, doc.StartDate, _current.WindowText); 1071 1071 1072 1072 view.Show(); … … 1117 1117 1118 1118 CGView view = new CGView(); 1119 view.InitializeDocView(doc, _current, doc.StartDate, doc.Appointments,_current.WindowText);1119 view.InitializeDocView(doc, _current, doc.StartDate, _current.WindowText); 1120 1120 1121 1121 view.Show(); -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CGView.cs
r1071 r1073 8 8 using System.Threading; 9 9 using IndianHealthService.BMXNet; 10 10 using System.Runtime.InteropServices; 11 11 12 12 namespace IndianHealthService.ClinicalScheduling … … 128 128 CGDocumentManager docMgr, 129 129 DateTime dStartDate, 130 CGAppointments cgAppts,131 130 string sText) 132 131 { … … 135 134 this.StartDate = dStartDate; 136 135 this.Document = doc; 137 this.Appointments = cgAppts; 138 136 137 //Rather strangely, this line is needed for God knows Why... 138 //Without it, the Grid tries to draw appointments, but can't. 139 //Making a constructor in the Calendar Grid itself didn't work. Don't know why. 140 //XXX: For later investigation. 141 this.Appointments = new CGAppointments(); 142 143 139 144 // Set username and division up top 140 145 this.Text = this.DocManager.ConnectInfo.UserName; … … 150 155 151 156 private BMXNetConnectInfo.BMXNetEventDelegate m_bmxDelegate; 152 delegate void OnUpdateScheduleDelegate(); 153 154 private void BMXNetEventHandler(Object obj, BMXNet.BMXNetEventArgs e) 155 { 156 try 157 { 158 if (e.BMXEvent == "BMXNet AutoFire") 159 { 160 Debug.Write("CGView caught AutoFire event.\n"); 161 if (this == null) 162 return; 163 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule); 164 this.BeginInvoke(ousd); 165 return; 166 } 167 168 if (e.BMXEvent != "BSDX SCHEDULE") 169 { 170 return; 171 } 172 string sResourceName; 173 for (int j=0; j < m_Document.m_sResourcesArray.Count; j++) 174 { 175 sResourceName = m_Document.m_sResourcesArray[j].ToString(); 176 if (e.BMXParam == sResourceName) 177 { 178 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule); 179 if (this == null) 180 return; 181 this.BeginInvoke(ousd); 182 Debug.Write("CGView caught BSDX SCHEDULE event.\n"); 183 break; 184 } 185 } 186 } 187 catch (Exception ex) 188 { 189 Debug.Write(ex.Message); 190 } 191 } 157 192 158 193 159 #endregion initialization … … 651 617 this.tvSchedules.Location = new System.Drawing.Point(0, 0); 652 618 this.tvSchedules.Name = "tvSchedules"; 653 this.tvSchedules.Size = new System.Drawing.Size(128, 437);619 this.tvSchedules.Size = new System.Drawing.Size(128, 395); 654 620 this.tvSchedules.Sorted = true; 655 621 this.tvSchedules.TabIndex = 1; … … 698 664 this.panelRight.Location = new System.Drawing.Point(941, 0); 699 665 this.panelRight.Name = "panelRight"; 700 this.panelRight.Size = new System.Drawing.Size(128, 437);666 this.panelRight.Size = new System.Drawing.Size(128, 395); 701 667 this.panelRight.TabIndex = 3; 702 668 this.panelRight.Visible = false; … … 796 762 this.panelCenter.Location = new System.Drawing.Point(136, 24); 797 763 this.panelCenter.Name = "panelCenter"; 798 this.panelCenter.Size = new System.Drawing.Size(802, 3 89);764 this.panelCenter.Size = new System.Drawing.Size(802, 347); 799 765 this.panelCenter.TabIndex = 7; 800 766 // … … 818 784 this.calendarGrid1.Resources = ((System.Collections.ArrayList)(resources.GetObject("calendarGrid1.Resources"))); 819 785 this.calendarGrid1.SelectedAppointment = 0; 820 this.calendarGrid1.Size = new System.Drawing.Size(802, 3 89);786 this.calendarGrid1.Size = new System.Drawing.Size(802, 347); 821 787 this.calendarGrid1.StartDate = new System.DateTime(2003, 1, 27, 0, 0, 0, 0); 822 788 this.calendarGrid1.TabIndex = 0; … … 826 792 this.calendarGrid1.CGSelectionChanged += new IndianHealthService.ClinicalScheduling.CalendarGrid.CGSelectionChangedHandler(this.calendarGrid1_CGSelectionChanged); 827 793 this.calendarGrid1.DoubleClick += new System.EventHandler(this.calendarGrid1_DoubleClick); 794 this.calendarGrid1.MouseEnter += new System.EventHandler(this.calendarGrid1_MouseEnter); 828 795 // 829 796 // ctxCalendarGrid … … 910 877 this.panelBottom.Controls.Add(this.statusBar1); 911 878 this.panelBottom.Dock = System.Windows.Forms.DockStyle.Bottom; 912 this.panelBottom.Location = new System.Drawing.Point(136, 413);879 this.panelBottom.Location = new System.Drawing.Point(136, 371); 913 880 this.panelBottom.Name = "panelBottom"; 914 881 this.panelBottom.Size = new System.Drawing.Size(802, 24); … … 928 895 this.splitter1.Location = new System.Drawing.Point(128, 24); 929 896 this.splitter1.Name = "splitter1"; 930 this.splitter1.Size = new System.Drawing.Size(8, 413);897 this.splitter1.Size = new System.Drawing.Size(8, 371); 931 898 this.splitter1.TabIndex = 9; 932 899 this.splitter1.TabStop = false; … … 937 904 this.splitter2.Location = new System.Drawing.Point(938, 24); 938 905 this.splitter2.Name = "splitter2"; 939 this.splitter2.Size = new System.Drawing.Size(3, 413);906 this.splitter2.Size = new System.Drawing.Size(3, 371); 940 907 this.splitter2.TabIndex = 10; 941 908 this.splitter2.TabStop = false; … … 949 916 // 950 917 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 951 this.ClientSize = new System.Drawing.Size(1069, 437);918 this.ClientSize = new System.Drawing.Size(1069, 395); 952 919 this.Controls.Add(this.panelCenter); 953 920 this.Controls.Add(this.panelBottom); … … 1060 1027 1061 1028 #endregion 1029 1062 1030 1063 1031 #region AppointmentMenu Handlers … … 1512 1480 } 1513 1481 1514 //If this Document has no resources then use it (happens when the GUI has nothing open, typically after log-in) 1482 //So if it is not a view that's already open, it means we have to grab the data for 1483 //So we tell the user to wait wait wait 1484 this.Cursor = Cursors.WaitCursor; 1485 this.LoadSplash(); //Open "Loading" splash 1486 1487 1488 //If this Document has no resources then use it (happens when the GUI has nothing open, typically after log-in) 1515 1489 //Else, create a new document 1516 1490 CGDocument doc; … … 1548 1522 v =this.DocManager.GetViewByResource(sSelectedTreeResourceArray); 1549 1523 1550 //Position the Grid 1524 //Position the Grid to start at a certain day. 1551 1525 //XXX: This must be a better way to do this. 1552 1526 v.dateTimePicker1.Value = dDate; … … 1628 1602 v.calendarGrid1.SetOverlapTable(); 1629 1603 v.calendarGrid1.Refresh(); 1604 1605 // Set cursor back and stop splash screen 1606 this.Cursor = Cursors.Default; 1607 StopSplash(); 1630 1608 } 1631 1609 … … 2224 2202 } 2225 2203 2204 #region BMX Event Processing and Callbacks 2205 /// <summary> 2206 /// Loosely typed delegate used several times below. 2207 /// </summary> 2208 delegate void OnUpdateScheduleDelegate(); 2209 2210 /// <summary> 2211 /// Subscription point for each CGView to process BMX events polled from the server 2212 /// </summary> 2213 /// <param name="obj">Not used</param> 2214 /// <param name="e">BMXEvent Args: 2215 /// e.BMXEvent is free text for Event Type; e.BMXParam is free text for Event Arguments</param> 2216 private void BMXNetEventHandler(Object obj, BMXNet.BMXNetEventArgs e) 2217 { 2218 try 2219 { 2220 // if this class is undefined (e.g. if the user just closed the form, do nothing 2221 if (this == null) return; 2222 2223 // if event is Autofire event 2224 if (e.BMXEvent == "BMXNet AutoFire") 2225 { 2226 Debug.Write("CGView caught AutoFire event.\n"); 2227 2228 //Create a delegate to OnUpdateSchedule and call Async 2229 //Once Async Call is done, go to OnUpdateScheduleCallback 2230 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule); 2231 ousd.BeginInvoke(OnUpdateScheduleCallback, null); 2232 2233 return; 2234 } 2235 2236 // if event is BSDX SCHEDULE 2237 else if (e.BMXEvent == "BSDX SCHEDULE") 2238 { 2239 //See if any of the resources in the event argument matches BSDX Schedule. 2240 //If yes, fire off the delegate 2241 string sResourceName; 2242 for (int j = 0; j < m_Document.m_sResourcesArray.Count; j++) 2243 { 2244 sResourceName = m_Document.m_sResourcesArray[j].ToString(); 2245 if (e.BMXParam == sResourceName) 2246 { 2247 Debug.Write("CGView caught BSDX SCHEDULE event.\n"); 2248 2249 //Create a delegate to OnUpdateSchedule and call Async 2250 //Once Async Call is done, go to OnUpdateScheduleCallb 2251 OnUpdateScheduleDelegate ousd = new OnUpdateScheduleDelegate(OnUpdateSchedule); 2252 ousd.BeginInvoke(OnUpdateScheduleCallback, null); 2253 2254 break; 2255 } 2256 } 2257 } 2258 } 2259 catch (Exception ex) 2260 { 2261 Debug.Write(ex.Message); 2262 } 2263 } 2264 2265 /// <summary> 2266 /// Update Appointments and Availabilites using Document.RefreshDocumentAsync on a different thread 2267 /// </summary> 2268 /// <remarks> 2269 /// This method is expected to be called asynchornously. 2270 /// </remarks> 2226 2271 public void OnUpdateSchedule() 2227 2272 { 2228 2273 try 2229 2274 { 2230 this.Cursor = Cursors.WaitCursor; 2231 m_Document.RefreshDocument(); 2275 m_Document.RefreshDocumentAsync(); //new 2232 2276 } 2233 2277 catch (Exception ex) … … 2235 2279 MessageBox.Show("Unable to refresh document " + ex.Message, "Clinical Scheduling"); 2236 2280 } 2237 finally 2238 { 2239 this.Cursor = Cursors.Default; 2240 } 2241 } 2281 } 2282 2283 /// <summary> 2284 /// Callback for when OnUpdateSchedule is done. Triggers the Grid to redraw itself by calling UpdateArrays. 2285 /// </summary> 2286 /// <param name="itfAR">not used</param> 2287 /// <remarks>Calls UpdateArrays via this.Invoke to make sure that the grid is redrawn on the UI thread</remarks> 2288 private void OnUpdateScheduleCallback(IAsyncResult itfAR) 2289 { 2290 OnUpdateScheduleDelegate d = new OnUpdateScheduleDelegate(UpdateArrays); 2291 this.Invoke(d); 2292 } 2293 2294 /// <summary> 2295 /// Create a new event in RPMS. Wrapper around BMXConnectInfo.RaiseEvent 2296 /// </summary> 2297 /// <param name="sEvent">Name of Event to Raise</param> 2298 /// <param name="sParams">Parameter of Event to Raise</param> 2299 public void RaiseRPMSEvent(string sEvent, string sParams) 2300 { 2301 try 2302 { 2303 //Signal RPMS to raise an event 2304 m_ConnectInfo.RaiseEvent(sEvent, sParams, true); 2305 } 2306 catch (Exception ex) 2307 { 2308 Debug.Write(ex.Message); 2309 } 2310 } 2311 2312 #endregion 2242 2313 2243 2314 /// <summary> … … 2251 2322 try 2252 2323 { 2253 this.calendarGrid1.AvailabilityArray = this.m_Document.AvailabilityArray; 2324 //Tell the grid about Avails, Appts, and Resources. 2325 this.calendarGrid1.AvailabilityArray = this.m_Document.AvailabilityArray; 2326 //Appts are cloned b/c if we tie into the class directly, we shoot off errors when we manipulate it. 2327 this.calendarGrid1.Appointments = (CGAppointments)this.m_Document.Appointments.Clone(); //smh new line again 2254 2328 this.calendarGrid1.Resources = this.m_Document.Resources; 2255 // this.calendarGrid1.Columns = 7; //test 2256 // this.calendarGrid1.StartDate = DateTime.Parse("10-10-2007"); // another test 2329 //Redraw the calendar grid 2257 2330 this.calendarGrid1.OnUpdateArrays(); // this draws the Calendar 2258 2331 this.lblResource.Text = this.m_Document.DocName; … … 2262 2335 { 2263 2336 MessageBox.Show("Unable to update arrays " + ex.Message, "Clinical Scheduling"); 2264 }2265 }2266 2267 public void RaiseRPMSEvent(string sEvent, string sParams)2268 {2269 try2270 {2271 //Signal RPMS to raise an event2272 m_ConnectInfo.RaiseEvent(sEvent, sParams, true);2273 }2274 catch (Exception ex)2275 {2276 Debug.Write(ex.Message);2277 2337 } 2278 2338 } … … 2372 2432 #region Events 2373 2433 2374 private void CGView_Load(object sender, System.EventArgs e) 2434 /// <summary> 2435 /// Special import to get the GetActiveWindow method from Win32 2436 /// </summary> 2437 /// <returns>Windows Handle number for Foregreound Active Window</returns> 2438 [DllImport("user32.dll")] 2439 static extern IntPtr GetActiveWindow(); 2440 2441 /// <summary> 2442 /// If a mouse enters the grid, check if the grid is on the active form first before stealing the focus 2443 /// </summary> 2444 /// <param name="sender"></param> 2445 /// <param name="e"></param> 2446 private void calendarGrid1_MouseEnter(object sender, EventArgs e) 2447 { 2448 if (GetActiveWindow() == this.Handle) 2449 calendarGrid1.Focus(); 2450 } 2451 2452 private void CGView_Load(object sender, System.EventArgs e) 2375 2453 { 2376 2454 Debug.Assert (this.Document != null); … … 3163 3241 } 3164 3242 3243 3244 3245 3165 3246 }//End class 3166 3247 } -
Scheduling/trunk/cs/bsdx0200GUISourceCode/CalendarGrid.cs
r1068 r1073 71 71 this.m_selectedRange = new CGRange(); 72 72 this.m_SelectedAppointments = new CGAppointments(); 73 //this.m_Appointments = new CGAppointments(); 73 74 this.m_dtStart = new DateTime(2003, 1, 27); 74 75 this.m_ApptOverlapTable = new Hashtable(); … … 89 90 this.m_sfHour.Alignment = StringAlignment.Far; 90 91 this.m_bInitialUpdate = false; 91 this.MouseEnter += new EventHandler(CalendarGrid_MouseEnter);92 }93 94 void CalendarGrid_MouseEnter(object sender, EventArgs e)95 {96 this.Focus();97 92 } 98 93 -
Scheduling/trunk/cs/bsdx0200GUISourceCode/LoadingSplash.Designer.cs
r1070 r1073 39 39 this.lblLoading.AutoSize = true; 40 40 this.lblLoading.Font = new System.Drawing.Font("Tahoma", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 41 this.lblLoading.Location = new System.Drawing.Point( 228, 181);41 this.lblLoading.Location = new System.Drawing.Point(138, 108); 42 42 this.lblLoading.Name = "lblLoading"; 43 43 this.lblLoading.Size = new System.Drawing.Size(255, 77); … … 51 51 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 52 52 this.BackColor = System.Drawing.SystemColors.ControlLightLight; 53 this.ClientSize = new System.Drawing.Size( 722, 449);53 this.ClientSize = new System.Drawing.Size(537, 315); 54 54 this.Controls.Add(this.lblLoading); 55 55 this.ForeColor = System.Drawing.SystemColors.ControlLight; 56 56 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 57 57 this.Name = "LoadingSplash"; 58 this.Opacity = 0.8D;59 58 this.ShowIcon = false; 60 59 this.ShowInTaskbar = false;
Note:
See TracChangeset
for help on using the changeset viewer.