/// <summary> /// Gets the overview item. /// </summary> /// <param name="character">The character.</param> /// <returns></returns> private static OverviewItem GetOverviewItem(Character character) { OverviewItem overviewItem; OverviewItem tempOverviewItem = null; try { // Creates a new page tempOverviewItem = new OverviewItem(character, true); tempOverviewItem.Tag = character; tempOverviewItem.CreateControl(); overviewItem = tempOverviewItem; tempOverviewItem = null; } finally { tempOverviewItem?.Dispose(); } return(overviewItem); }
/// <summary> /// Performs the custom layout. /// </summary> private void PerformCustomLayout() { // Remove controls and dispose them IEnumerable <Control> oldControls = MainFlowLayoutPanel.Controls.Cast <Control>().ToList(); MainFlowLayoutPanel.Controls.Clear(); foreach (Control ctl in oldControls) { ctl.Dispose(); } IEnumerable <Character> characters = GetCharacters; // Add controls for characters if (Settings.UI.SystemTrayPopup.GroupBy == TrayPopupGrouping.Account && Settings.UI.SystemTrayPopup.IndentGroupedAccounts) { List <ESIKey> prevAPIKeys = new List <ESIKey>(); foreach (Character character in characters) { OverviewItem charPanel = GetOverviewItem(character); List <ESIKey> apiKeys = character.Identity.ESIKeys.ToList(); if (!apiKeys.Exists(apiKey => prevAPIKeys.Contains(apiKey))) { MainFlowLayoutPanel.Controls.Add(charPanel); prevAPIKeys = apiKeys; } else { FlowLayoutPanel tempAccountGroupPanel = null; try { tempAccountGroupPanel = new FlowLayoutPanel(); tempAccountGroupPanel.Controls.Add(charPanel); tempAccountGroupPanel.AutoSize = true; tempAccountGroupPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; tempAccountGroupPanel.FlowDirection = FlowDirection.TopDown; tempAccountGroupPanel.Padding = new Padding(10, 0, 0, 0); tempAccountGroupPanel.CreateControl(); FlowLayoutPanel accountGroupPanel = tempAccountGroupPanel; tempAccountGroupPanel = null; MainFlowLayoutPanel.Controls.Add(accountGroupPanel); } finally { tempAccountGroupPanel?.Dispose(); } prevAPIKeys = apiKeys; } } } else { MainFlowLayoutPanel.Controls.AddRange(characters.Select(GetOverviewItem).ToArray <Control>()); } }
/// <summary> /// Recreates the controls for character and warning /// </summary> private void UpdateContent() { if (!this.Visible) { m_updatePending = true; return; } m_updatePending = false; IEnumerable<Character> characters = GetCharacters(); // Remove controls and dispose them var oldControls = mainPanel.Controls.Cast<Control>().ToArray(); mainPanel.Controls.Clear(); foreach (var ctl in oldControls) { ctl.Dispose(); } // Add controls for characters if (Settings.UI.SystemTrayPopup.GroupBy == TrayPopupGrouping.Account && Settings.UI.SystemTrayPopup.IndentGroupedAccounts) { long PrevUserID = 0; foreach (Character character in characters) { if (character.Identity.Account.UserID != PrevUserID) { mainPanel.Controls.Add(new OverviewItem(character, Settings.UI.SystemTrayPopup)); PrevUserID = character.Identity.Account.UserID; } else { FlowLayoutPanel AccountGroupPanel = new FlowLayoutPanel(); AccountGroupPanel.AutoSize = true; AccountGroupPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; AccountGroupPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; AccountGroupPanel.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0); OverviewItem charpanel = new OverviewItem(character, Settings.UI.SystemTrayPopup); charpanel.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0); AccountGroupPanel.Controls.Add(charpanel); mainPanel.Controls.Add(AccountGroupPanel); PrevUserID = character.Identity.Account.UserID; } } } else { mainPanel.Controls.AddRange(characters.Select(x => new OverviewItem(x, Settings.UI.SystemTrayPopup)).ToArray()); } // Return if the user do not want to be warned about accounts not in training if (Settings.UI.SystemTrayPopup.ShowWarning) { // Creates the warning for accounts not in training string warningMessage; if (EveClient.Accounts.HasAccountsNotTraining(out warningMessage)) { FlowLayoutPanel warningPanel = CreateAccountsNotTrainingPanel(warningMessage); mainPanel.Controls.Add(warningPanel); } } // TQ Server Status if (Settings.UI.SystemTrayPopup.ShowServerStatus) { m_serverStatusLabel = new Label(); m_serverStatusLabel.AutoSize = true; mainPanel.Controls.Add(m_serverStatusLabel); UpdateServerStatusLabel(); } // EVE Time if (Settings.UI.SystemTrayPopup.ShowEveTime) { m_eveTimeLabel = new Label(); m_eveTimeLabel.AutoSize = true; mainPanel.Controls.Add(m_eveTimeLabel); UpdateEveTimeLabel(); } // Updates the tooltip width CompleteLayout(); }