///<summary>Mouse down event anywhere on the sheet. Could be a blank space or on an actual appointment.</summary> private void ContrApptSheet2_MouseDown(object sender,System.Windows.Forms.MouseEventArgs e) { if(infoBubble.Visible) { infoBubble.Visible=false; } if(ApptDrawing.VisOps.Count==0) {//no ops visible. return; } if(mouseIsDown) {//if user clicks right mouse button while dragging return; } //some of this is a little redundant, but still necessary for now. SheetClickedonHour=ApptDrawing.YPosToHour(e.Y); SheetClickedonMin=ApptDrawing.YPosToMin(e.Y); TimeSpan sheetClickedOnTime=new TimeSpan(SheetClickedonHour,SheetClickedonMin,0); ContrApptSingle.ClickedAptNum=HitTestAppt(e.Location); SheetClickedonOp=ApptDrawing.VisOps[ApptDrawing.XPosToOpIdx(e.X)].OperatoryNum; SheetClickedonDay=ApptDrawing.XPosToDay(e.X); if(!ApptDrawing.IsWeeklyView) { SheetClickedonDay=((int)AppointmentL.DateSelected.DayOfWeek)-1; } Graphics grfx=ContrApptSheet2.CreateGraphics(); //if clicked on an appt----------------------------------------------------------------------------------------------- if(ContrApptSingle.ClickedAptNum!=0) { if(e.Button==MouseButtons.Left) { mouseIsDown = true; } int thisIndex=GetIndex(ContrApptSingle.ClickedAptNum); pinBoard.SelectedIndex=-1; //ContrApptSingle.PinBoardIsSelected=false; if(ContrApptSingle.SelectedAptNum!=-1//unselects previously selected unless it's the same appt && ContrApptSingle.SelectedAptNum!=ContrApptSingle.ClickedAptNum) { int prevSel=GetIndex(ContrApptSingle.SelectedAptNum); //has to be done before refresh prev: ContrApptSingle.SelectedAptNum=ContrApptSingle.ClickedAptNum; if(prevSel!=-1) { ContrApptSingle3[prevSel].CreateShadow(); if(ContrApptSingle3[prevSel].Shadow!=null) { grfx.DrawImage(ContrApptSingle3[prevSel].Shadow,ContrApptSingle3[prevSel].Location.X ,ContrApptSingle3[prevSel].Location.Y); } } } //again, in case missed in loop above: ContrApptSingle.SelectedAptNum=ContrApptSingle.ClickedAptNum; ContrApptSingle3[thisIndex].CreateShadow(); grfx.DrawImage(ContrApptSingle3[thisIndex].Shadow,ContrApptSingle3[thisIndex].Location.X ,ContrApptSingle3[thisIndex].Location.Y); RefreshModuleDataPatient(PIn.Long(ContrApptSingle3[thisIndex].DataRoww["PatNum"].ToString())); RefreshModuleScreenPatient(); OnPatientSelected(PatCur); //RefreshModulePatient(PIn.PInt(ContrApptSingle3[thisIndex].DataRoww["PatNum"].ToString())); if(e.Button==MouseButtons.Right) { //if(ApptDrawing.IsWeeklyView){ // menuWeeklyApt.Show(ContrApptSheet2,new Point(e.X,e.Y)); //} //else{ menuApt.Show(ContrApptSheet2,new Point(e.X,e.Y)); //} } else { TempApptSingle=new ContrApptSingle(); TempApptSingle.Visible=false;//otherwise I get a phantom appt while holding mouse down TempApptSingle.DataRoww=ContrApptSingle3[thisIndex].DataRoww; TempApptSingle.TableApptFields=ContrApptSingle3[thisIndex].TableApptFields; TempApptSingle.TablePatFields=ContrApptSingle3[thisIndex].TablePatFields; Controls.Add(TempApptSingle); TempApptSingle.Location=ApptSingleDrawing.SetLocation(TempApptSingle.DataRoww,0,ApptDrawing.VisOps.Count,0); TempApptSingle.Size=ApptSingleDrawing.SetSize(TempApptSingle.DataRoww); TempApptSingle.PatternShowing=ApptSingleDrawing.GetPatternShowing(TempApptSingle.DataRoww["Pattern"].ToString()); TempApptSingle.BringToFront(); //mouseOrigin is in ApptSheet coordinates mouseOrigin=e.Location; contOrigin=ContrApptSingle3[thisIndex].Location; TempApptSingle.CreateShadow(); if(HitTestApptBottom(e.Location)) { ResizingAppt=true; ResizingOrigH=TempApptSingle.Height; } else { ResizingAppt=false; } } } //not clicked on appt--------------------------------------------------------------------------------------------------- else { if(e.Button==MouseButtons.Right) { int clickedOnBlockCount=0; Schedule[] ListForType=Schedules.GetForType(SchedListPeriod,ScheduleType.Blockout,0); //List<ScheduleOp> listForSched; for(int i=0;i<ListForType.Length;i++) { if(ListForType[i].SchedDate.Date!=WeekStartDate.AddDays(SheetClickedonDay).Date) { continue; } if(ListForType[i].StartTime > sheetClickedOnTime || ListForType[i].StopTime <= sheetClickedOnTime) { continue; } //listForSched=ScheduleOps.GetForSched(ListForType[i].ScheduleNum); for(int p=0;p<ListForType[i].Ops.Count;p++) { if(ListForType[i].Ops[p]==SheetClickedonOp) { clickedOnBlockCount++; break;//out of ops loop } } } if(clickedOnBlockCount>0) { menuBlockout.MenuItems[0].Enabled=true;//Edit menuBlockout.MenuItems[1].Enabled=true;//Cut menuBlockout.MenuItems[2].Enabled=true;//Clone menuBlockout.MenuItems[3].Enabled=false;//paste. Can't paste on top of an existing blockout menuBlockout.MenuItems[4].Enabled=true;//Delete if(clickedOnBlockCount>1) { MsgBox.Show(this,"There are multiple blockouts in this slot. You should try to delete or move one of them."); } } else { menuBlockout.MenuItems[0].Enabled=false;//edit menuBlockout.MenuItems[1].Enabled=false;//edit menuBlockout.MenuItems[2].Enabled=false;//copy if(BlockoutClipboard==null) { menuBlockout.MenuItems[3].Enabled=false;//paste } else { menuBlockout.MenuItems[3].Enabled=true; } menuBlockout.MenuItems[4].Enabled=false;//delete } menuBlockout.Show(ContrApptSheet2,new Point(e.X,e.Y)); } } grfx.Dispose(); pinBoard.Invalidate(); //if(PinApptSingle.Visible){ // PinApptSingle.CreateShadow(); // PinApptSingle.Refresh(); //} CreateAptShadowsOnMain(); }
///<Summary>Sets selected and prepares for drag.</Summary> private void pinBoard_MouseDown(object sender,MouseEventArgs e) { if(pinBoard.SelectedIndex==-1) { return; } if(mouseIsDown) {//User right clicked while draging appt around. return; } if(e.Button==MouseButtons.Right) { ContextMenu cmen=new ContextMenu(); MenuItem menuItemProv=new MenuItem(Lan.g(this,"Change Provider")); menuItemProv.Click+=new EventHandler(menuItemProv_Click); cmen.MenuItems.Add(menuItemProv); cmen.Show(pinBoard,e.Location); return; } if(CancelPinMouseDown) {//I'm worried that setting this to false in pinBoard_SelectedIndexChanged is not frequent enough, //because a mouse down could happen without the selected index changing. //But in that case, a popup would already have happened. //Worst case scenario is that user would have to try again. CancelPinMouseDown=false; return; } mouseIsDown = true; //ContrApptSingle.PinBoardIsSelected=true; TempApptSingle=new ContrApptSingle(); TempApptSingle.DataRoww=pinBoard.SelectedAppt.DataRoww; TempApptSingle.TableApptFields=pinBoard.SelectedAppt.TableApptFields; TempApptSingle.TablePatFields=pinBoard.SelectedAppt.TablePatFields; TempApptSingle.Visible=false; Controls.Add(TempApptSingle); TempApptSingle.Location=ApptSingleDrawing.SetLocation(TempApptSingle.DataRoww,0,ApptDrawing.VisOps.Count,0); TempApptSingle.Size=ApptSingleDrawing.SetSize(TempApptSingle.DataRoww); TempApptSingle.PatternShowing=ApptSingleDrawing.GetPatternShowing(TempApptSingle.DataRoww["Pattern"].ToString()); TempApptSingle.CreateShadow(); TempApptSingle.BringToFront(); ContrApptSingle.SelectedAptNum=-1; //RefreshModulePatient(PIn.PInt(PinApptSingle.DataRoww["PatNum"].ToString()));//already done //PinApptSingle.CreateShadow(); //PinApptSingle.Refresh(); CreateAptShadowsOnMain();//to clear previous selection ContrApptSheet2.DrawShadow(); //mouseOrigin is in ContrAppt coordinates (essentially, the entire window) mouseOrigin.X=e.X+pinBoard.Location.X+panelCalendar.Location.X; //e.X+PinApptSingle.Location.X; mouseOrigin.Y=e.Y+pinBoard.SelectedAppt.Location.Y+pinBoard.Location.Y+panelCalendar.Location.Y; //e.Y+PinApptSingle.Location.Y; contOrigin=new Point(pinBoard.Location.X+panelCalendar.Location.X, pinBoard.SelectedAppt.Location.Y+pinBoard.Location.Y+panelCalendar.Location.Y); //PinApptSingle.Location; }