Ejemplo n.º 1
0
 private void panel1_MouseMove(object sender, MouseEventArgs e)
 {
     //there is 1 region per bucket (synced in paint event), loop through the regions and see if we are hovering over one of them
     for (int i = 0; i < ListRegions.Count; i++)
     {
         if (!ListRegions[i].IsVisible(new Point(e.X, e.Y)))                //we are hovering over this bucket
         {
             continue;
         }
         if (i == CurrentHoverRegionIdx)               //only activate this bucket once (prevents flicker)
         {
             return;
         }
         //build the display string for this hover bucket
         List <Employee> listEmps = null;
         TimeSpan        tsStart  = new TimeSpan(5, (i * 15), 0);
         toolTip.ToolTipTitle = tsStart.ToShortTimeString() + " - " + tsStart.Add(TimeSpan.FromMinutes(15)).ToShortTimeString();
         string employees = "";
         if (DictEmployeesPerBucket.TryGetValue(i, out listEmps))
         {
             toolTip.ToolTipTitle = toolTip.ToolTipTitle + " (" + listEmps.Count.ToString() + " Techs)";
             listEmps.Sort(new Employees.EmployeeComparer(Employees.EmployeeComparer.SortBy.firstName));
             for (int p = 0; p < listEmps.Count; p++)
             {
                 List <Schedule> sch = Schedules.GetForEmployee(ListScheds, listEmps[p].EmployeeNum);
                 employees += listEmps[p].FName;
                 employees += Schedules.GetCommaDelimStringForScheds(sch);
                 employees += "\r\n";
             }
         }
         //activate and show this bucket's tooltip
         toolTip.Active = true;
         toolTip.SetToolTip(this, employees);
         //save this region as current so we only activate it once
         CurrentHoverRegionIdx = i;
         return;
     }
     //not hovering over a bucket so kill the tooltip
     toolTip.Active        = false;
     CurrentHoverRegionIdx = -1;
 }
Ejemplo n.º 2
0
        private void FillGrid()
        {
            //get PhoneGraph entries for this date
            ListPhoneGraphsForDate = PhoneGraphs.GetAllForDate(DateEdit);
            //get current employee defaults
            ListPhoneEmpDefaults = PhoneEmpDefaults.Refresh();
            ListPhoneEmpDefaults.Sort(new PhoneEmpDefaults.PhoneEmpDefaultComparer(PhoneEmpDefaults.PhoneEmpDefaultComparer.SortBy.name));
            //get schedules
            ListSchedulesForDate = Schedules.GetDayList(DateEdit);
            long selectedEmployeeNum = -1;

            if (gridGraph.Rows.Count >= 1 &&
                gridGraph.GetSelectedIndex() >= 0 &&
                gridGraph.Rows[gridGraph.GetSelectedIndex()].Tag != null &&
                gridGraph.Rows[gridGraph.GetSelectedIndex()].Tag is PhoneEmpDefault)
            {
                selectedEmployeeNum = ((PhoneEmpDefault)gridGraph.Rows[gridGraph.GetSelectedIndex()].Tag).EmployeeNum;
            }
            gridGraph.BeginUpdate();
            gridGraph.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Employee"), 80);

            gridGraph.Columns.Add(col);             //column 0 (name - not clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Schedule"), 130);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 1 (schedule - clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Graph Default"), 90);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 2 (default - not clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Set Graph Status"), 110);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 3 (set graph status - clickable)
            col           = new ODGridColumn(Lan.g("TablePhoneGraphDate", "Is Overridden?"), 80);
            col.TextAlign = HorizontalAlignment.Center;
            gridGraph.Columns.Add(col);             //column 4 (is value an overridde of default? - not clickable)
            gridGraph.Rows.Clear();
            int selectedRow = -1;

            //loop through all employee defaults and create 1 row per employee
            for (int iPED = 0; iPED < ListPhoneEmpDefaults.Count; iPED++)
            {
                PhoneEmpDefault phoneEmpDefault = ListPhoneEmpDefaults[iPED];
                Employee        employee        = Employees.GetEmp(phoneEmpDefault.EmployeeNum);
                if (employee == null || employee.IsHidden)               //only deal with current employees
                {
                    continue;
                }
                List <Schedule> scheduleForEmployee = Schedules.GetForEmployee(ListSchedulesForDate, phoneEmpDefault.EmployeeNum);
                bool            isGraphed           = phoneEmpDefault.IsGraphed; //set default
                bool            hasOverride         = false;
                for (int iPG = 0; iPG < ListPhoneGraphsForDate.Count; iPG++)     //we have a default, now loop through all known exceptions and find a match
                {
                    PhoneGraph phoneGraph = ListPhoneGraphsForDate[iPG];
                    if (phoneEmpDefault.EmployeeNum == ListPhoneGraphsForDate[iPG].EmployeeNum)                   //found a match so no op necessary for this employee
                    {
                        isGraphed   = phoneGraph.IsGraphed;
                        hasOverride = true;
                        break;
                    }
                }
                ODGridRow row;
                row = new ODGridRow();
                row.Cells.Add(phoneEmpDefault.EmpName);                                                           //column 0 (name - not clickable)
                row.Cells.Add(Schedules.GetCommaDelimStringForScheds(scheduleForEmployee).Replace(", ", "\r\n")); //column 1 (shift times - not clickable)
                row.Cells.Add(phoneEmpDefault.IsGraphed?"X":"");                                                  //column 2 (default - not clickable)
                row.Cells.Add(isGraphed?"X":"");                                                                  //column 3 (set graph status - clickable)
                row.Cells.Add(hasOverride && isGraphed != phoneEmpDefault.IsGraphed?"X":"");                      //column 4 (is overridden to IsGraphed? - not clickable)
                row.Tag = phoneEmpDefault;                                                                        //store the employee for click events
                int rowIndex = gridGraph.Rows.Add(row);
                if (selectedEmployeeNum == phoneEmpDefault.EmployeeNum)
                {
                    selectedRow = rowIndex;
                }
            }
            gridGraph.EndUpdate();
            if (selectedRow >= 0)
            {
                gridGraph.SetSelected(selectedRow, true);
            }
        }