Ejemplo n.º 1
0
        void OnPasteList(CommandEventArgs e, LogMessageEditor lme)
        {
            StringBuilder sb = new StringBuilder();
            foreach (PendingChange pci in lme.PasteSource.PendingChanges)
            {
                sb.AppendFormat("* {0}", pci.RelativePath);
                sb.AppendLine();
            }

            lme.PasteText(sb.ToString());
        }
Ejemplo n.º 2
0
        void OnPasteList(CommandEventArgs e, LogMessageEditor lme)
        {
            StringBuilder sb = new StringBuilder();

            foreach (PendingChange pci in lme.PendingChangeUI.CheckedItems)
            {
                sb.AppendFormat("* {0}", pci.RelativePath);
                sb.AppendLine();
            }

            lme.PasteText(sb.ToString());
        }
Ejemplo n.º 3
0
        public void OnUpdate(CommandUpdateEventArgs e)
        {
            LogMessageEditor lme = e.Selection.GetActiveControl <LogMessageEditor>();

            if (lme == null || lme.ReadOnly || lme.PendingChangeUI == null)
            {
                e.Enabled = e.Visible = false;
            }
            else if (e.Command == AnkhCommand.PcLogEditorPasteFileList && !lme.PendingChangeUI.HasCheckedItems)
            {
                e.Enabled = false;
            }
        }
Ejemplo n.º 4
0
        void OnPasteRecent(CommandEventArgs e, LogMessageEditor lme)
        {
            using (RecentMessageDialog rmd = new RecentMessageDialog())
            {
                rmd.Context = e.Context;

                if (DialogResult.OK != rmd.ShowDialog(e.Context))
                    return;

                string text = rmd.SelectedText;
                if (!string.IsNullOrEmpty(text))
                    lme.PasteText(text);
            }
        }
Ejemplo n.º 5
0
        void OnPasteRecent(CommandEventArgs e, LogMessageEditor lme)
        {
            using (RecentMessageDialog rmd = new RecentMessageDialog())
            {
                rmd.Context = e.Context;

                if (DialogResult.OK != rmd.ShowDialog(e.Context))
                {
                    return;
                }

                string text = rmd.SelectedText;
                if (!string.IsNullOrEmpty(text))
                {
                    lme.PasteText(text);
                }
            }
        }
Ejemplo n.º 6
0
        public void OnExecute(CommandEventArgs e)
        {
            LogMessageEditor lme = e.Selection.GetActiveControl <LogMessageEditor>();

            if (lme == null || lme.PendingChangeUI == null)
            {
                return;
            }

            switch (e.Command)
            {
            case AnkhCommand.PcLogEditorPasteFileList:
                OnPasteList(e, lme);
                break;

            case AnkhCommand.PcLogEditorPasteRecentLog:
                OnPasteRecent(e, lme);
                break;
            }
        }
Ejemplo n.º 7
0
        bool TryGetMarker(BaseCommandEventArgs e, bool issue, out TextMarker value)
        {
            value = null;
            IVsTextView tv = ((ISelectionContextEx)e.Selection).ActiveFrameTextView;

            if (tv == null)
            {
                LogMessageEditor editor = e.Selection.GetActiveControl <LogMessageEditor>();

                if (editor == null)
                {
                    return(false);
                }

                tv = ((IAnkhHasVsTextView)editor).TextView;
            }

            int x, y;

            if (!VSErr.Succeeded(tv.GetCaretPos(out y, out x)))
            {
                return(false);
            }

            IVsTextLines lines;

            if (!VSErr.Succeeded(tv.GetBuffer(out lines)))
            {
                return(false);
            }

            string text, pre = null, post = null;

            text = GetLine(lines, y);

            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }

            string combined = null;
            int    start    = 0;

            if (y > 0)
            {
                pre      = GetLine(lines, y - 1);
                combined = pre + '\n';
                start    = combined.Length;
            }

            combined += text;

            post = GetLine(lines, y + 1);

            if (!string.IsNullOrEmpty(post))
            {
                combined += '\n' + post;
            }

            if (_issueService == null)
            {
                _issueService = e.GetService <IAnkhIssueService>();
            }

            IEnumerable <TextMarker> markers;

            int posToCheck = x + start;

            if (issue)
            {
                if (!_issueService.TryGetIssues(combined, out markers))
                {
                    return(false);
                }
            }
            else
            {
                if (!_issueService.TryGetRevisions(combined, out markers))
                {
                    return(false);
                }
            }

            foreach (TextMarker im in markers)
            {
                if (im.Index > posToCheck)
                {
                    break;
                }

                if (im.Index + im.Length >= posToCheck)
                {
                    value = im;
                    return(true);
                }
            }

            return(false);
        }