Ejemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics              g                   = e.Graphics;
            Pen                   pen                 = new Pen(Color.Black);
            SolidBrush            solidBrush          = new SolidBrush(Color.Black);
            Font                  fontDraw            = new Font("Microsoft Sans Serif", 8.25f);
            Font                  fontBold            = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Bold);
            List <WebChatSession> listWebChatSessions = WebChatSessions.GetActiveSessions();
            int                   controlHeight       = 16;
            int                   controlMargin       = 3;
            int                   customerWidth       = 80;
            int                   customerX           = 60;
            int                   customerY           = 18;
            int                   extensionWidth      = 96;
            int                   statusWidth         = 62;
            int                   statusX             = 0;
            int                   statusY             = 20;
            int                   imageLocationX      = 99;
            int                   proxLocationX       = 126;
            int                   timeBoxLocationX    = 3;
            int                   timeBoxLocationY    = 17;
            int                   timeBoxWidth        = 56;
            int                   timeLocationX       = 11;
            int                   yTop                = _tileStart; //the offset of the phone tile taking the other controls of the form into account
            int                   x                   = 0;          //x axis location
            int                   y                   = 0;          //y axis location
            int                   numColumns          = (int)Math.Ceiling((double)_listPhones.Count / _tilesPerColumn);
            int                   webChatHeightWidth  = 17;         //Used for the rectangle that houses the web chat icon to prevent it from breaking the box boundary.

            //i starts at 1, because it determines the number of columns with modulo division on line if(i%_tilesPerColumn==0)
            for (int i = 1; i < _listPhones.Count + 1; i++)
            {
                int            numCur         = i - 1;
                ChatUser       chatUser       = _listChatUsers.Where(chat => chat.Extension == _listPhones[numCur].Extension).FirstOrDefault();
                WebChatSession webChatSession = listWebChatSessions.FirstOrDefault(session => session.TechName == _listPhones[numCur].EmployeeName);
                Color          outerColor;
                Color          innerColor;
                Color          fontColor;
                bool           isTriageOperatorOnTheClock = false;
                //set the phone color
                Phones.GetPhoneColor(_listPhones[numCur], _listPhoneEmpDefaults.Find(phone => phone.EmployeeNum == _listPhones[numCur].EmployeeNum), false,
                                     out outerColor, out innerColor, out fontColor, out isTriageOperatorOnTheClock);
                //get the color scheme
                Phones.PhoneColorScheme phoneColorScheme = new Phones.PhoneColorScheme(true);
                string extensionAndName = $"{_listPhones[numCur].Extension}-{_listPhones[numCur].EmployeeName}";
                //determine if the extension has a user associated with it
                if (_listPhones[numCur].EmployeeName == "")
                {
                    extensionAndName += "Vacant";
                }
                //determine the status or note if the user is gone, otherwise just leave it
                string statusAndNote = "";
                if (_listPhones[numCur].ClockStatus == ClockStatusEnum.Home ||
                    _listPhones[numCur].ClockStatus == ClockStatusEnum.None ||
                    _listPhones[numCur].ClockStatus == ClockStatusEnum.Off)
                {
                    statusAndNote = "Clock In";
                }
                if (_listPhones[numCur].ClockStatus == ClockStatusEnum.Unavailable)
                {
                    statusAndNote = "Unavailable";
                }
                //get the customer number
                string customer = _listPhones[numCur].CustomerNumber;
                //get the time that has passed on a call
                string time = "";
                if (_listPhones[numCur].DateTimeNeedsHelpStart.Date == DateTime.Today)
                {
                    time = (DateTime.Now - _listPhones[numCur].DateTimeNeedsHelpStart + _timeSpanDelta).ToStringHmmss();
                }
                else if (_listPhones[numCur].DateTimeStart.Date == DateTime.Today)
                {
                    time = (DateTime.Now - _listPhones[numCur].DateTimeStart + _timeSpanDelta).ToStringHmmss();
                }
                //draw the time box with its determined color
                Color colorBar = outerColor;
                //don't draw anything if they are clocked out or unavailable
                if (_listPhones[numCur].ClockStatus != ClockStatusEnum.Home &&
                    _listPhones[numCur].ClockStatus != ClockStatusEnum.None &&
                    _listPhones[numCur].ClockStatus != ClockStatusEnum.Off &&
                    _listPhones[numCur].ClockStatus != ClockStatusEnum.Unavailable)
                {
                    //determine if they need help and flash pink if they do
                    if (_listPhones[numCur].ClockStatus == ClockStatusEnum.NeedsHelp)
                    {
                        if (_isFlashingPink)
                        {
                            colorBar = phoneColorScheme.ColorOuterNeedsHelp;
                        }
                        else
                        {
                            colorBar = Color.Transparent;
                        }
                    }
                    //set the color of the inside of the time box
                    if (_listPhones[numCur].ClockStatus == ClockStatusEnum.HelpOnTheWay)
                    {
                        colorBar = phoneColorScheme.ColorOuterNeedsHelp;
                    }
                    //draw the inside of the time box if the user is not on break
                    if (_listPhones[numCur].ClockStatus != ClockStatusEnum.Break)
                    {
                        using (SolidBrush brush = new SolidBrush(colorBar)) {
                            g.FillRectangle(brush, (x * _tileWidth) + timeBoxLocationX, (y * _tileHeight) + yTop + timeBoxLocationY, timeBoxWidth, controlHeight);
                        }
                    }
                    //draw the outline of the time box
                    g.DrawRectangle(pen, (x * _tileWidth) + timeBoxLocationX, (y * _tileHeight) + yTop + timeBoxLocationY, timeBoxWidth, controlHeight);
                    //draw either the figure or circle depending on if they are proxmial
                    if (_listPhones[numCur].IsProxVisible)
                    {
                        g.DrawImage(Properties.Resources.Figure, (x * _tileWidth) + proxLocationX, (y * _tileHeight) + yTop + controlMargin);
                    }
                    else if (_listPhones[numCur].DateTProximal.AddHours(8) > DateTime.Now)
                    {
                        g.DrawImage(Properties.Resources.NoFigure, (x * _tileWidth) + proxLocationX, (y * _tileHeight) + yTop + controlMargin);
                    }
                    //draw the phone image if it is in use
                    if (_listPhones[numCur].Description != "")
                    {
                        g.DrawImage(Properties.Resources.phoneInUse, (x * _tileWidth) + imageLocationX, (y * _tileHeight) + yTop + controlMargin);
                    }
                    else if (webChatSession != null)
                    {
                        g.DrawImage(Properties.Resources.WebChatIcon,
                                    new Rectangle((x * _tileWidth) + imageLocationX, (y * _tileHeight) + yTop + controlMargin, webChatHeightWidth, webChatHeightWidth));
                        time = (DateTime.Now - webChatSession.DateTcreated).ToStringHmmss();
                    }
                    else if (chatUser != null && chatUser.CurrentSessions != 0)
                    {
                        g.DrawImage(Properties.Resources.gtaicon3, (x * _tileWidth) + imageLocationX, (y * _tileHeight) + yTop + controlMargin);
                        time = TimeSpan.FromMilliseconds(chatUser.SessionTime).ToStringHmmss();
                    }
                    //draw the time on call or what ever activity they are doing
                    if (time != "")
                    {
                        g.DrawString(time, fontDraw, solidBrush, (x * _tileWidth) + timeLocationX, (y * _tileHeight) + yTop + timeBoxLocationY + 2);
                    }
                }
                //draw the things that need to be shown at all times such as the employee name, customer, and emp status
                g.DrawString(extensionAndName, fontBold, solidBrush, new RectangleF((x * _tileWidth), (y * _tileHeight) + yTop + controlMargin,
                                                                                    extensionWidth, controlHeight), new StringFormat()
                {
                    FormatFlags = StringFormatFlags.NoWrap
                });
                if (statusAndNote != "")                //the status only shows if it is Clock In or Unavailable
                {
                    g.DrawString(statusAndNote, fontDraw, solidBrush, new RectangleF((x * _tileWidth) + statusX, (y * _tileHeight) + yTop + statusY,
                                                                                     statusWidth, controlHeight), new StringFormat()
                    {
                        Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap
                    });
                }
                g.DrawString(customer, fontDraw, solidBrush, new RectangleF((x * _tileWidth) + customerX, (y * _tileHeight) + yTop + customerY + controlMargin,
                                                                            customerWidth, controlHeight), new StringFormat()
                {
                    Trimming = StringTrimming.EllipsisCharacter, FormatFlags = StringFormatFlags.NoWrap
                });
                //draw the grid lines
                if (i == 1)                //this line needs to be drawn differently than the rest
                {
                    g.DrawLine(pen, 0, yTop, numColumns * _tileWidth, yTop);
                }
                else
                {
                    g.DrawLine(pen, 0, (_tileHeight * y) + yTop, numColumns * _tileWidth, (_tileHeight * y) + yTop);
                }
                y++;
                if (i % _tilesPerColumn == 0 && i != _listPhones.Count)
                {
                    x++;
                    //draw the right grid line of the entire column
                    g.DrawLine(pen, _tileWidth * x, yTop, _tileWidth * x, (_tileHeight * _tilesPerColumn) + yTop);
                    y = 0;
                }
            }                                                                                                                            //for listPhones
            g.DrawLine(pen, 0, (_tileHeight * _tilesPerColumn) + yTop, numColumns * _tileWidth, (_tileHeight * _tilesPerColumn) + yTop); //final bottom line
            g.DrawLine(pen, _tileWidth * (x + 1), yTop, _tileWidth * (x + 1), (_tileHeight * _tilesPerColumn) + yTop);                   //final right line
            //dispose of the objects we no longer need
            pen.Dispose();
            solidBrush.Dispose();
            fontDraw.Dispose();
            fontBold.Dispose();
        }
Ejemplo n.º 2
0
 ///<summary>Set phone and triage flag to display. Get/Set accessor won't work here because we require 2 seperate fields in order to update the control properly.</summary>
 public void SetPhone(Phone phone, PhoneEmpDefault phoneEmpDefault, ChatUser chatUserCur, bool isTriageOperator)
 {
     _phoneCur = phone;
     if (_phoneCur == null)                      //empty out everything and return
     {
         pictureInUse.Visible           = false; //pictureInUse.Visible=false;
         labelStatusAndNote.Text        = "";
         pictureProx.Visible            = false;
         labelExtensionName.Text        = "";
         labelTime.Text                 = "";
         labelTime.BackColor            = this.BackColor;
         pictureNeedsHelpButton.Visible = false;
         pictureGTA.Visible             = false;
         labelCustomer.Text             = "Invalid Comp or Phone";
         return;
     }
     pictureInUse.Visible = _phoneCur.Description != "";
     //Check if the user is logged in.
     if (_phoneCur.ClockStatus == ClockStatusEnum.Home ||
         _phoneCur.ClockStatus == ClockStatusEnum.None ||
         _phoneCur.ClockStatus == ClockStatusEnum.Off)
     {
         labelStatusAndNote.Text = "Clock In";
     }
     else
     {
         labelStatusAndNote.Text = _phoneCur.ClockStatus.GetDescription();
     }
     //Always show ext and name, no matter if user is clocked in or not. This keeps phone tiles from appearing blank with no extension and name.
     if (_phoneCur.EmployeeName != "")
     {
         labelExtensionName.Text = _phoneCur.Extension.ToString() + " - " + _phoneCur.EmployeeName;
     }
     else
     {
         labelExtensionName.Text = _phoneCur.Extension.ToString() + " - Vacant";
     }
     if (_phoneCur.DateTimeNeedsHelpStart.Date == DateTime.Today)
     {
         labelTime.Text = (DateTime.Now - _phoneCur.DateTimeNeedsHelpStart + TimeDelta).ToStringHmmss();
     }
     else if (_phoneCur.DateTimeStart.Date == DateTime.Today)
     {
         labelTime.Text = (DateTime.Now - _phoneCur.DateTimeStart + TimeDelta).ToStringHmmss();
     }
     else
     {
         labelTime.Text = "";
     }
     if (_phoneCur.ClockStatus == ClockStatusEnum.Home ||
         _phoneCur.ClockStatus == ClockStatusEnum.None ||
         _phoneCur.ClockStatus == ClockStatusEnum.Break)
     {
         labelTime.BackColor = this.BackColor;              //No color if employee is not currently working.
         pictureNeedsHelpButton.BackColor = this.BackColor; //No color if employee is not currently working.
     }
     else
     {
         Color outerColor;
         Color innerColor;
         Color fontColor;
         bool  isTriageOperatorOnTheClock = false;
         //get the cubicle color and triage status
         Phones.GetPhoneColor(phone, phoneEmpDefault, false, out outerColor, out innerColor, out fontColor, out isTriageOperatorOnTheClock);
         if (!timerFlash.Enabled)
         {
             //if the control is already flashing then don't overwrite the colors. this would cause a "spastic" flash effect.
             Phones.PhoneColorScheme colorScheme = new Phones.PhoneColorScheme(true);
             labelTime.BackColor = outerColor;
             if (phone.ClockStatus == ClockStatusEnum.HelpOnTheWay)
             {
                 labelTime.BackColor = colorScheme.ColorOuterNeedsHelp;
             }
             if (_phoneCur.ClockStatus == ClockStatusEnum.NeedsHelp)
             {
                 //Only start the flash timer and color the control once. This prevents over-flashing effect.
                 labelTime.Tag = new object[2] {
                     false, colorScheme.ColorOuterNeedsHelp
                 };                                                                                           // labelTime.BackColor };
                 timerFlash.Start();
             }
         }
     }
     if (_phoneCur.ClockStatus != ClockStatusEnum.NeedsHelp)            //Always assume the flash timer was previously turned on and turn it off here. No harm if it' already off.
     {
         timerFlash.Stop();
     }
     if (_phoneCur.ClockStatus == ClockStatusEnum.Home ||
         _phoneCur.ClockStatus == ClockStatusEnum.None)
     {
         labelTime.BorderStyle = System.Windows.Forms.BorderStyle.None;              //Remove color box if employee is not currently working.
     }
     else
     {
         labelTime.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
     }
     labelCustomer.Text = _phoneCur.CustomerNumber;
     //Always show ext and name, no matter if user is clocked in or not. This keeps phone tiles from appearing blank with no extension and name.
     if (_phoneCur.EmployeeName != "")
     {
         labelExtensionName.Text = _phoneCur.Extension.ToString() + " - " + _phoneCur.EmployeeName;           // +(IsProximal ? " "+_cPerson : "");
     }
     else
     {
         labelExtensionName.Text = _phoneCur.Extension.ToString() + " - Vacant";
     }
     pictureProx.Visible = true;
     if (phone.IsProxVisible)
     {
         pictureProx.Image = Properties.Resources.Figure;
     }
     else if (phone.DateTProximal.AddHours(8) > DateTime.Now)
     {
         pictureProx.Image = Properties.Resources.NoFigure;              //TODO: replace image with one from Nathan
     }
     else
     {
         pictureProx.Visible = false;
     }
     if (LayoutHorizontal)
     {
         this.labelExtensionName.Location = new Point(3, 9);
         pictureProx.Location             = new Point(173, 11);
     }
     else
     {
         int stringW   = TextRenderer.MeasureText(labelExtensionName.Text, labelExtensionName.Font).Width;
         int locationX = labelExtensionName.Location.X
                         + stringW
                         + (labelExtensionName.Width - stringW) / 2 //half of the unused space around the centered text
                         + 1;                                       //padding
         pictureProx.Location           = new Point(locationX, 6);
         pictureNeedsHelpButton.Visible = true;
     }
     if (phone.ClockStatus == ClockStatusEnum.Home ||
         phone.ClockStatus == ClockStatusEnum.Lunch ||
         phone.ClockStatus == ClockStatusEnum.Break ||
         phone.ClockStatus == ClockStatusEnum.None)
     {
         pictureNeedsHelpButton.Visible = false;
     }
     else
     {
         pictureNeedsHelpButton.Enabled = true;
         pictureNeedsHelpButton.Image   = Properties.Resources.raisehanddisabled;
     }
     if (chatUserCur == null || chatUserCur.CurrentSessions == 0 || pictureInUse.Visible)
     {
         pictureGTA.Visible = false;
         pictureGTA.SendToBack();
     }
     else
     {
         pictureGTA.Visible = true;
         pictureGTA.BringToFront();
         labelTime.Text = TimeSpan.FromMilliseconds(chatUserCur.SessionTime).ToStringHmmss();
     }
 }