コード例 #1
0
        public IssueAlertWindow(IssueMonitor IssueMonitor, IssueData Issue, IssueAlertReason Reason)
        {
            this.IssueMonitor = IssueMonitor;
            this.Issue        = Issue;

            InitializeComponent();

            SetIssue(Issue, Reason);
        }
コード例 #2
0
        public void SetIssue(IssueData NewIssue, IssueAlertReason NewReason)
        {
            bool bNewStrongAlert = false;

            StringBuilder OwnerTextBuilder = new StringBuilder();

            if (NewIssue.Owner == null)
            {
                OwnerTextBuilder.Append("Currently unassigned.");
            }
            else
            {
                if (String.Compare(NewIssue.Owner, IssueMonitor.UserName, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if (NewIssue.NominatedBy != null)
                    {
                        OwnerTextBuilder.AppendFormat("You have been nominated to fix this issue by {0}.", Utility.FormatUserName(NewIssue.NominatedBy));
                    }
                    else
                    {
                        OwnerTextBuilder.AppendFormat("Assigned to {0}.", Utility.FormatUserName(NewIssue.Owner));
                    }
                    bNewStrongAlert = true;
                }
                else
                {
                    OwnerTextBuilder.AppendFormat("Assigned to {0}", Utility.FormatUserName(NewIssue.Owner));
                    if (NewIssue.NominatedBy != null)
                    {
                        OwnerTextBuilder.AppendFormat(" by {0}", Utility.FormatUserName(NewIssue.NominatedBy));
                    }
                    if (!NewIssue.AcknowledgedAt.HasValue && (NewReason & IssueAlertReason.UnacknowledgedTimer) != 0)
                    {
                        OwnerTextBuilder.Append(" (not acknowledged)");
                    }
                    OwnerTextBuilder.Append(".");
                }
            }
            OwnerTextBuilder.AppendFormat(" Open for {0}.", Utility.FormatDurationMinutes((int)(NewIssue.RetrievedAt - NewIssue.CreatedAt).TotalMinutes));
            string OwnerText = OwnerTextBuilder.ToString();

            bool bNewIsWarning = Issue.Builds.Count > 0 && !Issue.Builds.Any(x => x.Outcome != IssueBuildOutcome.Warning);

            Issue = NewIssue;

            string Summary = NewIssue.Summary;

            int MaxLength = 128;

            if (Summary.Length > MaxLength)
            {
                Summary = Summary.Substring(0, MaxLength).TrimEnd() + "...";
            }

            if (Summary != SummaryLabel.Text || OwnerText != OwnerLabel.Text || Reason != NewReason || bIsWarning != bNewIsWarning || bStrongAlert != bNewStrongAlert)
            {
                Rectangle PrevBounds = Bounds;
                SuspendLayout();

                SummaryLabel.Text = Summary;
                OwnerLabel.Text   = OwnerText;

                bool bForceUpdateButtons = false;
                if (bStrongAlert != bNewStrongAlert)
                {
                    bStrongAlert = bNewStrongAlert;

                    if (bNewStrongAlert)
                    {
                        SummaryLabel.ForeColor         = Color.FromArgb(255, 255, 255);
                        SummaryLabel.LinkColor         = Color.FromArgb(255, 255, 255);
                        OwnerLabel.ForeColor           = Color.FromArgb(255, 255, 255);
                        DetailsBtn.Theme               = AlertButtonControl.AlertButtonTheme.Strong;
                        AcceptBtn.Theme                = AlertButtonControl.AlertButtonTheme.Strong;
                        LatestBuildLinkLabel.LinkColor = Color.FromArgb(255, 255, 255);
                    }
                    else
                    {
                        SummaryLabel.ForeColor         = Color.FromArgb(32, 32, 64);
                        SummaryLabel.LinkColor         = Color.FromArgb(32, 32, 64);
                        OwnerLabel.ForeColor           = Color.FromArgb(32, 32, 64);
                        DetailsBtn.Theme               = AlertButtonControl.AlertButtonTheme.Normal;
                        AcceptBtn.Theme                = AlertButtonControl.AlertButtonTheme.Green;
                        LatestBuildLinkLabel.LinkColor = Color.FromArgb(16, 102, 192);
                    }

                    bForceUpdateButtons = true;
                }

                if (bIsWarning != bNewIsWarning)
                {
                    bIsWarning = bNewIsWarning;
                }

                if (Reason != NewReason || bForceUpdateButtons)
                {
                    Reason = NewReason;

                    List <Button> Buttons = new List <Button>();
                    Buttons.Add(DetailsBtn);
                    if ((NewReason & IssueAlertReason.Owner) != 0)
                    {
                        AcceptBtn.Text = "Acknowledge";
                        Buttons.Add(AcceptBtn);
                    }
                    else if ((NewReason & IssueAlertReason.Normal) != 0)
                    {
                        AcceptBtn.Text = "Will Fix";
                        Buttons.Add(AcceptBtn);
                        DeclineBtn.Text = "Not Me";
                        Buttons.Add(DeclineBtn);
                    }
                    else
                    {
                        DeclineBtn.Text = "Dismiss";
                        Buttons.Add(DeclineBtn);
                    }

                    tableLayoutPanel3.ColumnCount = Buttons.Count;
                    tableLayoutPanel3.Controls.Clear();
                    for (int Idx = 0; Idx < Buttons.Count; Idx++)
                    {
                        tableLayoutPanel3.Controls.Add(Buttons[Idx], Idx, 0);
                    }
                }

                ResumeLayout(true);
                Location = new Point(PrevBounds.Right - Bounds.Width, PrevBounds.Y);
                Invalidate();
            }
        }