Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <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);
        }