Exemple #1
0
            /// <summary>
            /// Creates a new <see cref="RefreshTask"/> bound to the specified <see cref="PullRequestView" />.k
            /// </summary>
            /// <param name="prView">The view to refresh.</param>
            /// <returns>A new <see cref="RefreshTask"/>.</returns>
            public static RefreshTask Create(PullRequestView prView)
            {
                RefreshTask refreshTask = new RefreshTask(prView);

#pragma warning disable EPC13

                Task.Run(() => refreshTask.MainLoop());

#pragma warning restore EPC13

                return(refreshTask);
            }
Exemple #2
0
        public static void RunUiLoop(Config config, IPullRequestSource source)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            Application.Init();
            Application.Current.ColorScheme = CustomColorSchemes.Main;

            Toplevel top = Application.Top;

            top.X      = Pos.Center();
            top.Y      = Pos.Center();
            top.Height = Dim.Fill();
            top.Width  = Dim.Fill();

            Dim computedHeight = Dim.Sized(0);

            // We intentionally initialize the status bar first, as the status
            // bar hooks events on the source, and the pull request view, will
            // drive API calls on the source which will trigger those events.
            // To avoid races here, make sure to hook first, run later.
            //
            StatusBar?statusBar = null;

            if (config.StatusBarEnabled)
            {
                computedHeight += StatusBarHeight;
                statusBar       = new StatusBar(source);
            }

            TextView?descriptionView = null;

            if (config.DescriptionEnabled)
            {
                computedHeight += DescriptionHeight;

                descriptionView = new TextView()
                {
                    Height   = Dim.Fill(),
                    Width    = Dim.Fill(),
                    ReadOnly = true,
                };
            }

            using PullRequestView requestView = new PullRequestView(source, descriptionView);

            using Window contentWindow = new Window(ActionableTitle)
                  {
                      Width       = Dim.Fill(),
                      Height      = Dim.Fill() - computedHeight,
                      ColorScheme = WindowTheme,
                  };

            contentWindow.Add(requestView);
            top.Add(contentWindow);

            if (config.DescriptionEnabled)
            {
                Window descriptionWindow = new Window("Description:")
                {
                    Width       = Dim.Fill(),
                    Height      = DescriptionHeight,
                    Y           = Pos.Bottom(contentWindow),
                    ColorScheme = WindowTheme,
                };

                descriptionWindow.Add(descriptionView);
                top.Add(descriptionWindow);
            }

            if (config.StatusBarEnabled)
            {
                Window statusWindow = new Window("Status:")
                {
                    Width       = Dim.Fill(),
                    Height      = StatusBarHeight,
                    Y           = Pos.Bottom(top.Subviews.Last()),
                    ColorScheme = WindowTheme,
                };

                statusWindow.Add(statusBar);
                top.Add(statusWindow);
            }

            // Start processing data within the view now that everything is constructed.
            //
            requestView.Start();

            Application.Run();
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RefreshTask"/> class.
 /// </summary>
 /// <param name="prView">The pr view.</param>
 private RefreshTask(PullRequestView prView) => m_pullRequestView = prView;