Ejemplo n.º 1
0
        private void errorPanel1_ErrorDoubleClick(ErrorPanel sender, int lineNumber, int columnNumber)
        {
            // another error
            if (0 == lineNumber)
            {
                return;
            }

            string[] split = wpfControl1.TextEditor1.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            if (split.Length > lineNumber - 1)
            {
                int targetLinePosition = 0;
                for (int i = 0; i < lineNumber - 1; i++)
                {
                    targetLinePosition += split[i].Length + Environment.NewLine.Length;
                }

                if (split[lineNumber - 1].Length >= columnNumber - 1)
                {
                    targetLinePosition += columnNumber - 1;
                }

                wpfControl1.TextEditor1.SelectionStart = targetLinePosition;
                wpfControl1.TextEditor1.Focus();

                int validatedColumnNumber = columnNumber;
                if (split[lineNumber - 1].Length < columnNumber - 1)
                {
                    validatedColumnNumber = 0;
                }

                wpfControl1.TextEditor1.ScrollTo(lineNumber - 1, validatedColumnNumber);
            }
        }
Ejemplo n.º 2
0
        private void errorPanel1_ErrorDoubleClick(ErrorPanel sender, int lineNumber, int columnNumber)
        {
            // another error
            if (0 == lineNumber)
                return;

            string[] split = wpfControl1.TextEditor1.Text.Split(new string[]{Environment.NewLine}, StringSplitOptions.None);
            if (split.Length > lineNumber-1)
            {
                int targetLinePosition = 0;
                for (int i = 0; i < lineNumber -1; i++)
                    targetLinePosition += split[i].Length + Environment.NewLine.Length;
               
                if (split[lineNumber - 1].Length >= columnNumber-1)
                    targetLinePosition += columnNumber - 1;

                wpfControl1.TextEditor1.SelectionStart = targetLinePosition;
                wpfControl1.TextEditor1.Focus();

                int validatedColumnNumber = columnNumber;
                if (split[lineNumber - 1].Length < columnNumber - 1)
                    validatedColumnNumber = 0;

                wpfControl1.TextEditor1.ScrollTo(lineNumber - 1, validatedColumnNumber);
            }
        }