Beispiel #1
0
        internal void setDiscussionNoteText(Control noteControl, DiscussionNote note)
        {
            if (note == null)
            {
                // this is possible when noteControl detaches from parent
                return;
            }

            Debug.Assert(noteControl is HtmlPanel);
            HtmlPanel htmlPanel = noteControl as HtmlPanel;

            htmlPanel.BaseStylesheet = String.Format(
                "{0} body div {{ font-size: {1}px; padding-left: 4px; padding-right: {2}px; }}",
                Properties.Resources.Common_CSS, WinFormsHelpers.GetFontSizeInPixels(noteControl),
                SystemInformation.VerticalScrollBarWidth * 2); // this is really weird

            // We need to zero the control size before SetText call to allow HtmlPanel to compute the size
            int prevWidth = noteControl.Width;

            noteControl.Width  = 0;
            noteControl.Height = 0;

            string body = MarkDownUtils.ConvertToHtml(note.Body, _imagePath, _specialDiscussionNoteMarkdownPipeline);

            noteControl.Text = String.Format(MarkDownUtils.HtmlPageTemplate, addPrefix(body, note, _firstNoteAuthor));
            resizeLimitedWidthHtmlPanel(htmlPanel, prevWidth);

            _htmlDiscussionNoteToolTip.BaseStylesheet =
                String.Format("{0} body div {{ font-size: {1}px; }}",
                              Properties.Resources.Common_CSS,
                              WinFormsHelpers.GetFontSizeInPixels(noteControl));
            _htmlDiscussionNoteToolTip.SetToolTip(noteControl, getNoteTooltipHtml(note));
        }
Beispiel #2
0
        private void setServiceDiscussionNoteText(Control noteControl, DiscussionNote note)
        {
            if (note == null)
            {
                Debug.Assert(false);
                return;
            }

            // We need to zero the control size before SetText call to allow HtmlPanel to compute the size
            noteControl.Width  = 0;
            noteControl.Height = 0;

            Debug.Assert(noteControl is HtmlPanel);
            HtmlPanel htmlPanel = noteControl as HtmlPanel;

            htmlPanel.BaseStylesheet = String.Format("{0} body div {{ font-size: {1}px; }}",
                                                     Properties.Resources.Common_CSS,
                                                     WinFormsHelpers.GetFontSizeInPixels(noteControl));

            string body = MarkDownUtils.ConvertToHtml(note.Body, _imagePath, _specialDiscussionNoteMarkdownPipeline);

            noteControl.Text = String.Format(MarkDownUtils.HtmlPageTemplate, body);

            resizeFullSizeHtmlPanel(noteControl as HtmlPanel);
        }
        internal AcceptMergeRequestForm(
            MergeRequestKey mrk,
            string repositoryPath,
            Action onMerged,
            Func <MergeRequestKey, string, User, string, Task> onOpenDiscussions,
            Func <DataCache> getCache,
            Func <Task <DataCache> > fetchCache,
            Func <GitLabClient.MergeRequestAccessor> getMergeRequestAccessor)
        {
            CommonControls.Tools.WinFormsHelpers.FixNonStandardDPIIssue(this,
                                                                        (float)Common.Constants.Constants.FontSizeChoices["Design"]);
            InitializeComponent();
            CommonControls.Tools.WinFormsHelpers.LogScaleDimensions(this);

            applyFont(Program.Settings.MainWindowFontSizeName);
            _formDefaultMinimumHeight           = MinimumSize.Height;
            _groupBoxCommitMessageDefaultHeight = groupBoxMergeCommitMessage.Height;

            _mergeRequestKey         = mrk;
            _repositoryPath          = repositoryPath ?? throw new ArgumentException("repositoryPath argument cannot be null");
            _mdPipeline              = MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl());
            _onOpenDiscussions       = onOpenDiscussions;
            _onMerged                = onMerged;
            _getCache                = getCache;
            _fetchCache              = fetchCache;
            _getMergeRequestAccessor = getMergeRequestAccessor;

            initializeGitUILinks();
            subscribeToTimer();
        }
Beispiel #4
0
        private string convertTextToHtml(string text)
        {
            string prefix = StringUtils.GetGitLabAttachmentPrefix(_hostname, getProjectName());
            string html   = MarkDownUtils.ConvertToHtml(text, prefix, _mdPipeline);

            return(String.Format(MarkDownUtils.HtmlPageTemplate, html));
        }
Beispiel #5
0
        internal MainForm(bool startMinimized, bool runningAsUwp, string startUrl)
        {
            _startMinimized = startMinimized;
            _startUrl       = startUrl;

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

            _allowAutoStartApplication           = runningAsUwp;
            checkBoxRunWhenWindowsStarts.Enabled = !_allowAutoStartApplication;

            _trayIcon   = new TrayIcon(notifyIcon);
            _mdPipeline =
                MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl());

            this.columnHeaderName.Width    = this.listViewProjects.Width - SystemInformation.VerticalScrollBarWidth - 5;
            this.linkLabelConnectedTo.Text = String.Empty;

            foreach (Control control in CommonControls.Tools.WinFormsHelpers.GetAllSubControls(this))
            {
                if (control.Anchor.HasFlag(AnchorStyles.Right) &&
                    (control.MinimumSize.Width != 0 || control.MinimumSize.Height != 0))
                {
                    Debug.Assert(false);
                }
            }

            buttonTimeTrackingCancel.ConfirmationCondition = () => true;
            buttonTimeTrackingCancel.ConfirmationText      = "Tracked time will be lost, are you sure?";

            listViewMergeRequests.Deselected      += ListViewMergeRequests_Deselected;
            listViewFoundMergeRequests.Deselected += ListViewMergeRequests_Deselected;
        }
        internal MergeRequestPropertiesForm(string hostname, ProjectAccessor projectAccessor, User currentUser,
                                            bool isAllowedToChangeSource)
        {
            CommonControls.Tools.WinFormsHelpers.FixNonStandardDPIIssue(this,
                                                                        (float)Common.Constants.Constants.FontSizeChoices["Design"], 96);
            InitializeComponent();
            CommonControls.Tools.WinFormsHelpers.LogScaleDimensions(this);

            applyFont(Program.Settings.MainWindowFontSizeName);

            _hostname                = hostname;
            _projectAccessor         = projectAccessor;
            _currentUser             = currentUser;
            _mdPipeline              = MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl());
            _isAllowedToChangeSource = isAllowedToChangeSource;

            string css = String.Format("{0}", mrHelper.App.Properties.Resources.Common_CSS);

            htmlPanelTitle.BaseStylesheet       = css;
            htmlPanelDescription.BaseStylesheet = css;

            labelSpecialNotePrefix.Text = Program.ServiceManager.GetSpecialNotePrefix();

            buttonCancel.ConfirmationCondition = () => true;

            comboBoxProject.SelectedIndexChanged +=
                new System.EventHandler(this.comboBoxProject_SelectedIndexChanged_Base);
        }
        private string convertTextToHtml(string text)
        {
            string hostname    = _mergeRequestKey.ProjectKey.HostName;
            string projectname = _mergeRequestKey.ProjectKey.ProjectName;
            string prefix      = StringUtils.GetGitLabAttachmentPrefix(hostname, projectname);
            string html        = MarkDownUtils.ConvertToHtml(text, prefix, _mdPipeline);

            return(String.Format(MarkDownUtils.HtmlPageTemplate, html));
        }
        private void updatePreview(HtmlPanel previewPanel, string text)
        {
            previewPanel.BaseStylesheet = String.Format("{0} body div {{ font-size: {1}px; }}",
                                                        Properties.Resources.Common_CSS, WinFormsHelpers.GetFontSizeInPixels(previewPanel));

            var    pipeline = MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl());
            string body     = MarkDownUtils.ConvertToHtml(text, String.Empty, pipeline);

            previewPanel.Text = String.Format(MarkDownUtils.HtmlPageTemplate, body);
        }
        private void tabControlMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControlMode.SelectedTab == tabPagePreview)
            {
                htmlPanelPreview.BaseStylesheet = String.Format("{0} body div {{ font-size: {1}px; }}",
                                                                Properties.Resources.Common_CSS, WinFormsHelpers.GetFontSizeInPixels(htmlPanelPreview));

                Markdig.MarkdownPipeline pipeline = MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl());
                string body = MarkDownUtils.ConvertToHtml(textBox.Text, _uploadsPrefix, pipeline);
                htmlPanelPreview.Text = String.Format(MarkDownUtils.HtmlPageTemplate, body);
            }
        }
Beispiel #10
0
        internal DiscussionBox(
            CustomFontForm parent,
            SingleDiscussionAccessor accessor, IGitCommandService git,
            User currentUser, ProjectKey projectKey, Discussion discussion,
            User mergeRequestAuthor,
            int diffContextDepth, ColorScheme colorScheme,
            Action <DiscussionBox> preContentChange,
            Action <DiscussionBox, bool> onContentChanged,
            Action <Control> onControlGotFocus)
        {
            Parent = parent;

            Discussion = discussion;

            _accessor           = accessor;
            _editor             = accessor.GetDiscussionEditor();
            _mergeRequestAuthor = mergeRequestAuthor;
            _currentUser        = currentUser;
            _imagePath          = StringUtils.GetHostWithPrefix(projectKey.HostName) + "/" + projectKey.ProjectName;

            _diffContextDepth    = new ContextDepth(0, diffContextDepth);
            _tooltipContextDepth = new ContextDepth(5, 5);
            if (git != null)
            {
                _panelContextMaker   = new EnhancedContextMaker(git);
                _tooltipContextMaker = new CombinedContextMaker(git);
            }
            _colorScheme = colorScheme;

            _preContentChange  = preContentChange;
            _onContentChanged  = onContentChanged;
            _onControlGotFocus = onControlGotFocus;

            _htmlDiffContextToolTip = new HtmlToolTip
            {
                AutoPopDelay = 20000, // 20s
                InitialDelay = 300
            };

            _htmlDiscussionNoteToolTip = new HtmlToolTip
            {
                AutoPopDelay = 20000, // 20s
                InitialDelay = 300,
            };

            _specialDiscussionNoteMarkdownPipeline =
                MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl());

            onCreate();
        }
        internal MainForm(bool startMinimized, bool runningAsUwp, string startUrl, bool integratedInGitExtensions,
                          bool integratedInSourceTree)
        {
            _startMinimized            = startMinimized;
            _startUrl                  = startUrl;
            _integratedInGitExtensions = integratedInGitExtensions;
            _integratedInSourceTree    = integratedInSourceTree;

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

            _allowAutoStartApplication           = runningAsUwp;
            checkBoxRunWhenWindowsStarts.Enabled = !_allowAutoStartApplication;

            _trayIcon   = new TrayIcon(notifyIcon);
            _mdPipeline =
                MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl());

            columnHeaderName.Width    = this.listViewProjects.Width - SystemInformation.VerticalScrollBarWidth - 5;
            linkLabelConnectedTo.Text = String.Empty;
            linkLabelConnectedTo.SetLinkLabelClicked(UrlHelper.OpenBrowser);

            foreach (Control control in CommonControls.Tools.WinFormsHelpers.GetAllSubControls(this))
            {
                if (control.Anchor.HasFlag(AnchorStyles.Right) &&
                    (control.MinimumSize.Width != 0 || control.MinimumSize.Height != 0))
                {
                    Debug.Assert(false);
                }
            }

            buttonTimeTrackingCancel.ConfirmationCondition = () => true;
            buttonTimeTrackingCancel.ConfirmationText      = "Tracked time will be lost, are you sure?";

            listViewLiveMergeRequests.Tag   = Constants.LiveListViewName;
            listViewFoundMergeRequests.Tag  = Constants.SearchListViewName;
            listViewRecentMergeRequests.Tag = Constants.RecentListViewName;

            forEachListView(listView => listView.ContentChanged += listViewMergeRequests_ContentChanged);
            forEachListView(listView => listView.Initialize());

            SystemEvents.SessionSwitch          += SystemEvents_SessionSwitch;
            SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;
            _applicationUpdateChecker            = new PeriodicUpdateChecker(this);

            _redrawTimer.Tick += onRedrawTimer;
            _redrawTimer.Start();
        }
Beispiel #12
0
        internal MergeRequestPropertiesForm(string hostname, ProjectAccessor projectAccessor, User currentUser,
                                            bool isAllowedToChangeSource, IEnumerable <User> users)
        {
            CommonControls.Tools.WinFormsHelpers.FixNonStandardDPIIssue(this,
                                                                        (float)Common.Constants.Constants.FontSizeChoices["Design"]);
            InitializeComponent();
            CommonControls.Tools.WinFormsHelpers.LogScaleDimensions(this);

            applyFont(Program.Settings.MainWindowFontSizeName);

            _hostname                = hostname;
            _projectAccessor         = projectAccessor;
            _currentUser             = currentUser;
            _mdPipeline              = MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl());
            _isAllowedToChangeSource = isAllowedToChangeSource;

            string css = String.Format("{0}", mrHelper.App.Properties.Resources.Common_CSS);

            htmlPanelTitle.BaseStylesheet       = css;
            htmlPanelDescription.BaseStylesheet = css;

            labelSpecialNotePrefix.Text = Program.ServiceManager.GetSpecialNotePrefix();

            buttonCancel.ConfirmationCondition = () => true;

            if (users == null || !users.Any())
            {
                // This may happen when new MR creation is requested by URL and mrHelper is not launched.
                // In this case User Cache is still not filled. Let's load project users.
                comboBoxProject.SelectedIndexChanged += new System.EventHandler(loadProjectUsersForAutoCompletion);
            }
            else
            {
                textBoxSpecialNote.SetUsers(users
                                            .Select(user => new CommonControls.Controls.TextBoxWithUserAutoComplete.User(user.Name, user.Username)));
            }
        }