/// <summary> /// Get total width based on all <paramref name="appMenu"/> items. /// </summary> public static async Task <int> TotalWidthAsync(this IAppMenu appMenu) { var generalMenuItems = appMenu .LoadGeneral() .ToArray(); var jobMenuItems = await appMenu .LoadJobsAsync() .ToArrayAsync() .ConfigureAwait(false); return(generalMenuItems .Concat(jobMenuItems) .Max(item => item.Name.Length) + 4); }
/// <summary> /// Perform initialization. /// </summary> public async Task <GeneralMenu> InitializeAsync() { Title = "general"; Width = await appMenu.TotalWidthAsync().ConfigureAwait(false); Height = Dim.Percent(50f); Add(generalButtonFrame.Initialize()); appMenu .LoadGeneral() .AsListView() .FillDimensions() .WithVerticalOffset(Pos.Bottom(generalButtonFrame)) .OnSelectionOf <IMenuItem>(menuItem => menuItem.HandleClickAsync()) .To(Add); return(this); }