コード例 #1
0
        private void lstComments_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                int intSelection = (int)lstComments.SelectedIndex;

                Comment comment = new Comment();

                comment = file.Comments[intSelection];

                using (frmAddComment frm = new frmAddComment())
                {
                    frm.loadCommentText(comment.CommentText);

                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        comment.CommentText = frm.Comment.CommentText;

                        file.UpdateComment(comment);

                        bindComments();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        private void btnAddComment_Click(object sender, EventArgs e)
        {
            IntPtr curScintilla = IntPtr.Zero;

            try
            {
                curScintilla = PluginBase.GetCurrentScintilla();

                int selectionStartPos = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_GETSELECTIONSTART, 0, 0);
                int selectionEndPos   = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_GETSELECTIONEND, 0, 0);

                int selectionStartLine = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_LINEFROMPOSITION, selectionStartPos, 0);
                int selectionEndLine   = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_LINEFROMPOSITION, selectionEndPos, 0);

                int selectionStartCol = selectionStartPos - (int)Win32.SendMessage(curScintilla, SciMsg.SCI_POSITIONFROMLINE, selectionStartLine, 0);
                int selectionEndCol   = selectionEndPos - (int)Win32.SendMessage(curScintilla, SciMsg.SCI_POSITIONFROMLINE, selectionEndLine, 0);

                using (frmAddComment frm = new frmAddComment())
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        file.AddComment(selectionStartLine, selectionEndLine, selectionStartCol, selectionEndCol, frm.Comment.CommentText);

                        bindComments();

                        // Highlight
                        Win32.SendMessage(curScintilla, SciMsg.SCI_INDICSETSTYLE, 20, 7);
                        Win32.SendMessage(curScintilla, SciMsg.SCI_INDICSETFORE, 20, 0x00FFFF);
                        Win32.SendMessage(curScintilla, SciMsg.SCI_INDICSETALPHA, 20, 50);
                        Win32.SendMessage(curScintilla, SciMsg.SCI_SETINDICATORCURRENT, 20, 0);
                        Win32.SendMessage(curScintilla, SciMsg.SCI_INDICATORFILLRANGE, selectionStartPos, selectionEndPos - selectionStartPos);

                        // select the latest item
                        lstComments.SelectedIndex = lstComments.Items.Count - 1;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Marshal.Release(curScintilla);
            }
        }
コード例 #3
0
        private void btnAddComment_Click(object sender, EventArgs e)
        {
            IntPtr curScintilla = IntPtr.Zero;

            try
            {
                curScintilla = PluginBase.GetCurrentScintilla();

                int selectionStartPos = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_GETSELECTIONSTART, 0, 0);
                int selectionEndPos = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_GETSELECTIONEND, 0, 0);

                int selectionStartLine = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_LINEFROMPOSITION, selectionStartPos, 0);
                int selectionEndLine = (int)Win32.SendMessage(curScintilla, SciMsg.SCI_LINEFROMPOSITION, selectionEndPos, 0);

                int selectionStartCol = selectionStartPos - (int)Win32.SendMessage(curScintilla, SciMsg.SCI_POSITIONFROMLINE, selectionStartLine, 0);
                int selectionEndCol = selectionEndPos - (int)Win32.SendMessage(curScintilla, SciMsg.SCI_POSITIONFROMLINE, selectionEndLine, 0);

                using (frmAddComment frm = new frmAddComment())
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        file.AddComment(selectionStartLine, selectionEndLine, selectionStartCol, selectionEndCol, frm.Comment.CommentText);

                        bindComments();

                        // Highlight
                        Win32.SendMessage(curScintilla, SciMsg.SCI_INDICSETSTYLE, 20, 7);
                        Win32.SendMessage(curScintilla, SciMsg.SCI_INDICSETFORE, 20, 0x00FFFF);
                        Win32.SendMessage(curScintilla, SciMsg.SCI_INDICSETALPHA, 20, 50);
                        Win32.SendMessage(curScintilla, SciMsg.SCI_SETINDICATORCURRENT, 20, 0);
                        Win32.SendMessage(curScintilla, SciMsg.SCI_INDICATORFILLRANGE, selectionStartPos, selectionEndPos - selectionStartPos);

                        // select the latest item
                        lstComments.SelectedIndex = lstComments.Items.Count - 1;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Marshal.Release(curScintilla);
            }
        }
コード例 #4
0
        private void lstComments_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                int intSelection = (int)lstComments.SelectedIndex;

                Comment comment = new Comment();

                comment = file.Comments[intSelection];

                using (frmAddComment frm = new frmAddComment())
                {
                    frm.loadCommentText(comment.CommentText);

                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        comment.CommentText = frm.Comment.CommentText;

                        file.UpdateComment(comment);

                        bindComments();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }