/// <summary> /// Completes the layout after new controls have been added. /// </summary> private void CompleteLayout() { // Fix the panel widths to the largest. // We let the framework determine the appropriate widths, then fix them so that // updates to training time remaining don't cause the form to resize. int pnlWidth = 0; foreach (Control control in mainPanel.Controls) { if (control.Width > pnlWidth) { pnlWidth = control.Width; } } foreach (Control control in mainPanel.Controls) { if (control is FlowLayoutPanel) { FlowLayoutPanel flowPanel = control as FlowLayoutPanel; int pnlHeight = flowPanel.Height; flowPanel.AutoSize = false; flowPanel.Width = pnlWidth; flowPanel.Height = pnlHeight; } } // Position Popup TrayIcon.SetToolTipLocation(this); }
/// <summary> /// Updates the tooltip's content. /// </summary> private void UpdateContent() { if (!this.Visible) { m_updatePending = true; return; } m_updatePending = false; // Replaces the fragments like "%10546464r" (the number being the character ID) by the remaining time. string tooltip = m_tooltipFormat; foreach (var character in m_characters) { var trainingSkill = character.CurrentlyTrainingSkill; TimeSpan remainingTime = trainingSkill.EndTime - DateTime.UtcNow; tooltip = Regex.Replace(tooltip, '%' + character.CharacterID.ToString() + 'r', Skill.TimeSpanToDescriptiveText(remainingTime, DescriptiveTextOptions.IncludeCommas), RegexOptions.Compiled); } // Updates the tooltip and its location lblToolTip.Text = tooltip.ToString(); TrayIcon.SetToolTipLocation(this); }