/// <summary> /// Initializes a new instance of the <see cref="StatusBar"/> class. /// </summary> public StatusBar(IPullRequestSource source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } CanFocus = false; Width = Dim.Fill(); Height = 1; ColorScheme = CustomColorSchemes.MutedEdges; // Listen on statistics update callback. // m_source = source; m_source.StatisticsUpdate += StatisUpdateCallback; m_status = new Label(LoadingText) { Height = Dim.Fill(), Width = Dim.Fill(), }; Add(m_status); }
/// <summary> /// Initializes a new instance of the <see cref="PullRequestView"/> class. /// </summary> /// <param name="source">The source of elements for this view.</param> public PullRequestView(IPullRequestSource source, TextView?descriptionView) : base(LoadingContents) { Width = Dim.Fill(); Height = Dim.Fill(); m_pullRequestSource = source; m_descriptionView = descriptionView; // Override the color scheme to our main theme for this view. // ColorScheme = CustomColorSchemes.Main; if (m_descriptionView != null) { // Subscribe to selection change. // SelectedItemChanged += HandleSelectedPullRequestChanged; } OpenSelectedItem += HandleOpenSelectedItem; // Initialize background refresh task. // m_refreshTask = RefreshTask.Create(this); }
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(); }
/// <summary> /// Constructs a display. /// </summary> /// <param name="pullRequestSource">The backing data source to render from.</param> public Display(IPullRequestSource pullRequestSource) { m_pullRequestSource = pullRequestSource; }