Example #1
0
        /// <summary>
        /// Throws:
        /// ArgumentException
        /// </summary>
        internal DiscussionsForm(MergeRequestDescriptor mrd, string mrTitle, User mergeRequestAuthor,
                                 IGitRepository gitRepository, int diffContextDepth, ColorScheme colorScheme, List <Discussion> discussions,
                                 DiscussionManager manager, User currentUser, Func <MergeRequestDescriptor, Task> updateGitRepository)
        {
            _mergeRequestDescriptor = mrd;
            _mergeRequestTitle      = mrTitle;
            _mergeRequestAuthor     = mergeRequestAuthor;

            _gitRepository    = gitRepository;
            _diffContextDepth = diffContextDepth;

            _colorScheme = colorScheme;

            _manager             = manager;
            _updateGitRepository = updateGitRepository;

            _currentUser = currentUser;
            if (_currentUser.Id == 0)
            {
                throw new ArgumentException("Bad user Id");
            }

            InitializeComponent();

            DiscussionFilterState state = new DiscussionFilterState
            {
                ByCurrentUserOnly = false,
                ByAnswers         = FilterByAnswers.Answered | FilterByAnswers.Unanswered,
                ByResolution      = FilterByResolution.Resolved | FilterByResolution.NotResolved
            };

            DisplayFilter = new DiscussionFilter(_currentUser, _mergeRequestAuthor, state);
            SystemFilter  = new DiscussionFilter(_currentUser, _mergeRequestAuthor, state);

            FilterPanel = new DiscussionFilterPanel(DisplayFilter.Filter,
                                                    () =>
            {
                DisplayFilter.Filter = FilterPanel.Filter;
                updateLayout(null);
            });
            ActionsPanel = new DiscussionActionsPanel(async() => await onRefresh());

            Controls.Add(FilterPanel);
            Controls.Add(ActionsPanel);

            if (!renderDiscussions(discussions))
            {
                throw new NoDiscussionsToShow();
            }
        }
Example #2
0
        /// <summary>
        /// Throws:
        /// ArgumentException
        /// </summary>
        internal DiscussionsForm(
            DataCache dataCache, GitLabInstance gitLabInstance, IModificationListener modificationListener,
            IGitCommandService git, User currentUser, MergeRequestKey mrk, IEnumerable <Discussion> discussions,
            string mergeRequestTitle, User mergeRequestAuthor,
            int diffContextDepth, ColorScheme colorScheme,
            Func <MergeRequestKey, IEnumerable <Discussion>, Task> updateGit, Action onDiscussionModified)
        {
            _mergeRequestKey    = mrk;
            _mergeRequestTitle  = mergeRequestTitle;
            _mergeRequestAuthor = mergeRequestAuthor;

            _git = git;
            _diffContextDepth = diffContextDepth;

            _colorScheme = colorScheme;

            _dataCache            = dataCache;
            _gitLabInstance       = gitLabInstance;
            _modificationListener = modificationListener;
            _updateGit            = updateGit;
            _onDiscussionModified = onDiscussionModified;

            _currentUser = currentUser;
            if (_currentUser.Id == 0)
            {
                throw new ArgumentException("Bad user Id");
            }

            CommonControls.Tools.WinFormsHelpers.FixNonStandardDPIIssue(this,
                                                                        (float)Common.Constants.Constants.FontSizeChoices["Design"], 96);
            InitializeComponent();
            CommonControls.Tools.WinFormsHelpers.LogScaleDimensions(this);

            DisplayFilter = new DiscussionFilter(_currentUser, _mergeRequestAuthor,
                                                 DiscussionFilterState.Default);
            SystemFilter = new DiscussionFilter(_currentUser, _mergeRequestAuthor,
                                                DiscussionFilterState.AllExceptSystem);

            FilterPanel = new DiscussionFilterPanel(DisplayFilter.Filter,
                                                    () =>
            {
                DisplayFilter.Filter = FilterPanel.Filter;
                updateLayout(null, true, true);
                updateSearch();
            });

            ActionsPanel = new DiscussionActionsPanel(() => BeginInvoke(new Action(async() => await onRefresh())));

            SearchPanel = new DiscussionSearchPanel(
                (query, forward) =>
            {
                if (query.Text == String.Empty)
                {
                    resetSearch();
                }
                else if (TextSearch == null || !query.Equals(TextSearch.Query))
                {
                    startSearch(query, true);
                }
                else
                {
                    MostRecentFocusedDiscussionControl?.Focus();
                    continueSearch(forward);
                }
            });

            DiscussionSortState sortState = DiscussionSortState.Default;

            DisplaySort = new DiscussionSort(sortState);
            SortPanel   = new DiscussionSortPanel(DisplaySort.SortState,
                                                  () =>
            {
                DisplaySort.SortState = SortPanel.SortState;
                updateLayout(null, true, true);
                updateSearch();
            });

            FontSelectionPanel = new DiscussionFontSelectionPanel(font => applyFont(font));

            Controls.Add(FilterPanel);
            Controls.Add(ActionsPanel);
            Controls.Add(SearchPanel);
            Controls.Add(SortPanel);
            Controls.Add(FontSelectionPanel);

            applyFont(Program.Settings.MainWindowFontSizeName);
            applyTheme(Program.Settings.VisualThemeName);

            if (!renderDiscussions(discussions, false))
            {
                throw new NoDiscussionsToShow();
            }
        }