/// <summary> /// Adds each logged in user to a scrollable container. /// </summary> /// <returns>A <see cref="VerticalScrollContainer"/> containing the user list</returns> private VerticalScrollContainer GenerateUserList() { // Create a flex container to hold the users VerticalFlexContainer userListFlexContainer = new VerticalFlexContainer(); // Add each logged in user to the flex container foreach (string uuid in Instance.GetUserUuids(true)) { // Try to get the display name of the user if (!Instance.TryGetDisplayName(uuid, out string displayName)) { displayName = "???"; } // Skip the user if they don't contain the search text if (!string.IsNullOrEmpty(userSearch) && !displayName.ToLower().Contains(userSearch.ToLower())) { continue; } // Strip name formatting if the user wishes not to see it if (!Instance.ShowNameFormatting) { displayName = TextHelper.StripRichText(displayName); } userListFlexContainer.Add( new ButtonWidget( label: displayName, clickAction: () => DrawUserContextMenu(uuid, displayName), drawBackground: false ) ); } // Wrap the flex container in a scroll container VerticalScrollContainer verticalScrollContainer = new VerticalScrollContainer(userListFlexContainer, userListScroll, newScrollPos => userListScroll = newScrollPos); // Return the scroll container return(verticalScrollContainer); }
/// <summary> /// Creates a new <see cref="TradeList"/>. /// </summary> public TradeList() { this.tradeRows = new List <TradeRow>(); // Create the initial layout tradeRowsFlexContainer = new VerticalFlexContainer(); // Wrap the column in a scroll container VerticalScrollContainer scrolledColumn = new VerticalScrollContainer(tradeRowsFlexContainer); // Make sure we have active trades before attempting to draw them ConditionalContainer activeTradesConditional = new ConditionalContainer( childIfTrue: scrolledColumn, childIfFalse: new PlaceholderWidget("Phinix_trade_noActiveTradesPlaceholder".Translate()), condition: () => tradeRowsFlexContainer.Contents.Any() ); // Make sure we are online above all else ConditionalContainer onlineConditional = new ConditionalContainer( childIfTrue: activeTradesConditional, childIfFalse: new PlaceholderWidget("Phinix_chat_pleaseLogInPlaceholder".Translate()), condition: () => Client.Instance.Online ); // Save the layout ready for the draw thread constructedLayout = onlineConditional; // Subscribe to update events Client.Instance.OnTradesSynced += (s, e) => repopulateTradeRows(); Client.Instance.OnTradeCancelled += onTradeCompletedOrCancelledHandler; Client.Instance.OnTradeCompleted += onTradeCompletedOrCancelledHandler; Client.Instance.OnTradeCreationSuccess += onTradeCreationSuccessHandler; Client.Instance.OnTradeUpdateFailure += onTradeUpdateHandler; Client.Instance.OnTradeUpdateSuccess += onTradeUpdateHandler; Client.Instance.OnUserDisplayNameChanged += onUserDisplayNameChangedHandler; // Pre-fill the trade rows repopulateTradeRows(); }