diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogErrorListViewItem.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogErrorListViewItem.cs index cca68df174..8b3dde7230 100644 --- a/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogErrorListViewItem.cs +++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/SetupDialogErrorListViewItem.cs @@ -18,7 +18,7 @@ namespace ICSharpCode.WixBinding int column; public SetupDialogErrorListViewItem(string fileName, XmlException ex) - : this(fileName, ex.LineNumber - 1, ex.LinePosition - 1) + : this(fileName, ex.LineNumber, ex.LinePosition) { } diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs index 1ff7e111d2..fab6723400 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Gui/AddDialogsToSetupDialogListTestFixture.cs @@ -155,13 +155,13 @@ namespace WixBinding.Tests.Gui [Test] public void XmlErrorDialogItemErrorLine() { - Assert.AreEqual(9, xmlErrorDialogErrorLine); + Assert.AreEqual(10, xmlErrorDialogErrorLine); } [Test] public void XmlErrorDialogItemErrorColumn() { - Assert.AreEqual(4, xmlErrorDialogErrorColumn); + Assert.AreEqual(5, xmlErrorDialogErrorColumn); } [Test] diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs index 90b92c703b..ba206ee1e8 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs @@ -15,7 +15,7 @@ using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.AvalonEdit.AddIn { - public class AvalonEditViewContent : AbstractViewContent, IEditable, IMementoCapable, ITextEditorProvider + public class AvalonEditViewContent : AbstractViewContent, IEditable, IMementoCapable, ITextEditorProvider, IPositionable { readonly CodeEditor codeEditor = new CodeEditor(); @@ -145,5 +145,20 @@ namespace ICSharpCode.AvalonEdit.AddIn return null; } #endregion + + #region IPositionable + public int Line { + get { return codeEditor.TextArea.Caret.Line; } + } + + public int Column { + get { return codeEditor.TextArea.Caret.Column; } + } + + public void JumpTo(int line, int column) + { + codeEditor.TextArea.Caret.Position = new ICSharpCode.AvalonEdit.Gui.TextViewPosition(line, column); + } + #endregion } } diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs index 0a6f847910..7bed4c841f 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs @@ -596,7 +596,7 @@ namespace ICSharpCode.FormsDesigner if (FileUtility.IsEqualFileName(file, this.primaryViewContent.PrimaryFileName)) { ShowSourceCode(position); } else { - FileService.JumpToFilePosition(file, position - 1, 0); + FileService.JumpToFilePosition(file, position, 0); } } } diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs index 18d4df5722..634fdbc4a7 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XPathQueryControl.cs @@ -581,7 +581,7 @@ namespace ICSharpCode.XmlEditor void JumpTo(string fileName, int line, int column) { - FileService.JumpToFilePosition(fileName, line, column); + FileService.JumpToFilePosition(fileName, line + 1, column + 1); } /// diff --git a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs index 3d2947c9ef..1700864c83 100644 --- a/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs +++ b/src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs @@ -461,7 +461,7 @@ namespace ICSharpCode.XmlEditor // Open schema. if (schemaObject != null && schemaObject.SourceUri != null && schemaObject.SourceUri.Length > 0) { string fileName = schemaObject.SourceUri.Replace("file:///", String.Empty); - FileService.JumpToFilePosition(fileName, schemaObject.LineNumber - 1, schemaObject.LinePosition - 1); + FileService.JumpToFilePosition(fileName, schemaObject.LineNumber, schemaObject.LinePosition); } } diff --git a/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageControl.cs b/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageControl.cs index fe1739db6a..0aa01251d2 100644 --- a/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageControl.cs +++ b/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageControl.cs @@ -298,7 +298,7 @@ namespace ICSharpCode.CodeCoverage if (listView.SelectedItems.Count > 0) { CodeCoverageSequencePoint sequencePoint = (CodeCoverageSequencePoint)listView.SelectedItems[0].Tag; if (sequencePoint.Document.Length > 0) { - FileService.JumpToFilePosition(sequencePoint.Document, sequencePoint.Line - 1, sequencePoint.Column - 1); + FileService.JumpToFilePosition(sequencePoint.Document, sequencePoint.Line, sequencePoint.Column); } } } @@ -517,7 +517,7 @@ namespace ICSharpCode.CodeCoverage string fileName = textEditorControl.FileName; if (fileName != null) { Caret caret = textEditorControl.ActiveTextAreaControl.Caret; - FileService.JumpToFilePosition(fileName, caret.Line, caret.Column); + FileService.JumpToFilePosition(fileName, caret.Line + 1, caret.Column + 1); } } diff --git a/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethodTreeNode.cs b/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethodTreeNode.cs index 4c5e7aa001..b994551aaf 100644 --- a/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethodTreeNode.cs +++ b/src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethodTreeNode.cs @@ -41,7 +41,7 @@ namespace ICSharpCode.CodeCoverage } } - FileService.JumpToFilePosition(firstSequencePoint.Document, line - 1, column - 1); + FileService.JumpToFilePosition(firstSequencePoint.Document, line, column); } else if (Parent != null) { ((ExtTreeNode)Parent).ActivateItem(); diff --git a/src/AddIns/Misc/UnitTesting/Src/UnitTestCommands.cs b/src/AddIns/Misc/UnitTesting/Src/UnitTestCommands.cs index 11750e9b2f..af5b3fec2e 100644 --- a/src/AddIns/Misc/UnitTesting/Src/UnitTestCommands.cs +++ b/src/AddIns/Misc/UnitTesting/Src/UnitTestCommands.cs @@ -73,7 +73,7 @@ namespace ICSharpCode.UnitTesting if (filePosition.Position.IsEmpty) { FileService.OpenFile(filePosition.FileName); } else { - FileService.JumpToFilePosition(filePosition.FileName, filePosition.Line - 1, filePosition.Column - 1); + FileService.JumpToFilePosition(filePosition.FileName, filePosition.Line, filePosition.Column); } } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Caret.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Caret.cs index 027ef3f844..8f76bf2f56 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Caret.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/Caret.cs @@ -89,7 +89,7 @@ namespace ICSharpCode.AvalonEdit.Gui public int Line { get { return position.Line; } set { - this.Position = new TextViewPosition(new TextLocation(value, position.Column)); + this.Position = new TextViewPosition(value, position.Column); } } @@ -99,7 +99,7 @@ namespace ICSharpCode.AvalonEdit.Gui public int Column { get { return position.Column; } set { - this.Position = new TextViewPosition(new TextLocation(position.Line, value)); + this.Position = new TextViewPosition(position.Line, value); } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewPosition.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewPosition.cs index 0572c6cea8..44853b70cb 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewPosition.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Gui/TextViewPosition.cs @@ -53,6 +53,14 @@ namespace ICSharpCode.AvalonEdit.Gui this.visualColumn = visualColumn; } + /// + /// Creates a new TextViewPosition instance. + /// + public TextViewPosition(int line, int column) + : this(line, column, -1) + { + } + /// /// Creates a new TextViewPosition instance. /// @@ -67,10 +75,8 @@ namespace ICSharpCode.AvalonEdit.Gui /// Creates a new TextViewPosition instance. /// public TextViewPosition(TextLocation location) + : this(location, -1) { - this.line = location.Line; - this.column = location.Column; - this.visualColumn = -1; } /// diff --git a/src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs b/src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs index 470cb68cfd..f7f253e3ca 100644 --- a/src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs +++ b/src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs @@ -98,14 +98,14 @@ namespace ICSharpCode.SharpDevelop.Commands { IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable; if (positionable != null) - return (positionable.Line + 1).ToString(); + return positionable.Line.ToString(); break; } case "CURCOL": { IPositionable positionable = WorkbenchSingleton.Workbench.ActiveViewContent as IPositionable; if (positionable != null) - return (positionable.Column + 1).ToString(); + return positionable.Column.ToString(); break; } case "CURTEXT": diff --git a/src/Main/Base/Project/Src/Gui/ContentInterfaces/IPositionable.cs b/src/Main/Base/Project/Src/Gui/ContentInterfaces/IPositionable.cs index f03df074c6..1ae74cc685 100644 --- a/src/Main/Base/Project/Src/Gui/ContentInterfaces/IPositionable.cs +++ b/src/Main/Base/Project/Src/Gui/ContentInterfaces/IPositionable.cs @@ -15,20 +15,20 @@ namespace ICSharpCode.SharpDevelop.Gui public interface IPositionable { /// - /// Sets the 'caret' to the position pos, where pos.Y is the line (starting from 0). - /// And pos.X is the column (starting from 0 too). + /// Sets the 'caret' to the position pos, where pos.Y is the line (starting from 1). + /// And pos.X is the column (starting from 1 too). /// void JumpTo(int line, int column); /// - /// gets the 'caret' position line (starting from 0) + /// gets the 'caret' position line (starting from 1) /// int Line { get; } /// - /// gets the 'caret' position column (starting from 0) + /// gets the 'caret' position column (starting from 1) /// int Column { get; diff --git a/src/Main/Base/Project/Src/Gui/FormLocationHelper.cs b/src/Main/Base/Project/Src/Gui/FormLocationHelper.cs index 9e7cc41d76..492ba2cf38 100644 --- a/src/Main/Base/Project/Src/Gui/FormLocationHelper.cs +++ b/src/Main/Base/Project/Src/Gui/FormLocationHelper.cs @@ -6,7 +6,7 @@ // using System; -using System.Drawing; +using System.Windows; using System.Windows.Forms; using ICSharpCode.Core; @@ -37,13 +37,40 @@ namespace ICSharpCode.SharpDevelop.Gui } }; } - static Rectangle Validate(Rectangle bounds) + + public static void ApplyWindow(Window window, string propertyName, bool isResizable) + { + window.WindowStartupLocation = WindowStartupLocation.Manual; + if (isResizable) { + Rect bounds = Validate(PropertyService.Get(propertyName, GetDefaultBounds(window))); + window.Left = bounds.X; + window.Top = bounds.Y; + window.Width = bounds.Width; + window.Height = bounds.Height; + } else { + Size size = new Size(window.ActualWidth, window.ActualHeight); + Point location = Validate(PropertyService.Get(propertyName, GetDefaultLocation(window)), size); + window.Left = location.X; + window.Top = location.Y; + } + window.Closing += delegate { + if (isResizable) { + if (window.WindowState == System.Windows.WindowState.Normal) { + PropertyService.Set(propertyName, new Rect(window.Left, window.Top, window.ActualWidth, window.ActualHeight)); + } + } else { + PropertyService.Set(propertyName, new Point(window.Left, window.Top)); + } + }; + } + + static Rect Validate(Rect bounds) { // Check if form is outside the screen and get it back if necessary. // This is important when the user uses multiple screens, a window stores its location // on the secondary monitor and then the secondary monitor is removed. - Rectangle screen1 = Screen.FromPoint(new Point(bounds.X, bounds.Y)).WorkingArea; - Rectangle screen2 = Screen.FromPoint(new Point(bounds.X + bounds.Width, bounds.Y)).WorkingArea; + Rect screen1 = Screen.FromPoint(bounds.TopLeft.ToSystemDrawing()).WorkingArea.ToWpf(); + Rect screen2 = Screen.FromPoint(bounds.TopRight.ToSystemDrawing()).WorkingArea.ToWpf(); if (bounds.Y < screen1.Y - 5 && bounds.Y < screen2.Y - 5) bounds.Y = screen1.Y - 5; if (bounds.X < screen1.X - bounds.Width / 2) @@ -55,23 +82,49 @@ namespace ICSharpCode.SharpDevelop.Gui static Point Validate(Point location, Size size) { - return Validate(new Rectangle(location, size)).Location; + return Validate(new Rect(location, size)).Location; + } + + static System.Drawing.Rectangle Validate(System.Drawing.Rectangle bounds) + { + return Validate(bounds.ToWpf()).ToSystemDrawing(); + } + + static System.Drawing.Point Validate(System.Drawing.Point location, System.Drawing.Size size) + { + return Validate(location.ToWpf(), size.ToWpf()).ToSystemDrawing(); + } + + static System.Drawing.Rectangle GetDefaultBounds(Form form) + { + return new System.Drawing.Rectangle(GetDefaultLocation(form.Size.ToWpf()).ToSystemDrawing(), form.Size); + } + + static Rect GetDefaultBounds(Window window) + { + Size size = new Size(window.Width, window.Height); + return new Rect(GetDefaultLocation(size), size); + } + + static System.Drawing.Point GetDefaultLocation(Form form) + { + return GetDefaultLocation(form.Size.ToWpf()).ToSystemDrawing(); } - static Rectangle GetDefaultBounds(Form form) + static Point GetDefaultLocation(Window window) { - return new Rectangle(GetDefaultLocation(form), form.Size); + Size size = new Size(window.Width, window.Height); + return GetDefaultLocation(size); } - static Point GetDefaultLocation(Form form) + static Point GetDefaultLocation(Size formSize) { var mainWindow = WorkbenchSingleton.MainWindow; - Rectangle parent = new Rectangle( - (int)mainWindow.Left, (int)mainWindow.Top, (int)mainWindow.Width, (int)mainWindow.Height + Rect parent = new Rect( + mainWindow.Left, mainWindow.Top, mainWindow.Width, mainWindow.Height ); - Size size = form.Size; - return new Point(parent.Left + (parent.Width - size.Width) / 2, - parent.Top + (parent.Height - size.Height) / 2); + return new Point(parent.Left + (parent.Width - formSize.Width) / 2, + parent.Top + (parent.Height - formSize.Height) / 2); } } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs index 25bb0434f7..61c1012dd5 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/ClassNode.cs @@ -60,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser public override void ActivateItem() { if (c.CompilationUnit != null) { - FileService.JumpToFilePosition(c.CompilationUnit.FileName, c.Region.BeginLine - 1, c.Region.BeginColumn - 1); + FileService.JumpToFilePosition(c.CompilationUnit.FileName, c.Region.BeginLine, c.Region.BeginColumn); } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs index 890e2bc196..9f61abd455 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/Nodes/MemberNode.cs @@ -128,7 +128,7 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser public override void ActivateItem() { if (FileName != null) { - FileService.JumpToFilePosition(FileName, line - 1, column - 1); + FileService.JumpToFilePosition(FileName, line, column); } } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs index 72f297743f..af127e0990 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs @@ -22,12 +22,12 @@ namespace ICSharpCode.SharpDevelop.Gui /// /// The file line. /// - int line = 0; + int line; /// /// The line column. /// - int column = 0; + int column ; /// @@ -43,7 +43,8 @@ namespace ICSharpCode.SharpDevelop.Gui } /// - /// Gets or sets the line number + /// Gets or sets the line number. The first line has the number 1. + /// The value '0' means that no line information is available. /// public int Line { get { @@ -55,7 +56,8 @@ namespace ICSharpCode.SharpDevelop.Gui } /// - /// Gets or sets the line column. + /// Gets or sets the line column. The first line has the number 1. + /// The value '0' means that no column information is available. /// public int Column { get { diff --git a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs index d12aa14d22..8c07c22aa4 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/OutputTextLineParser.cs @@ -34,9 +34,8 @@ namespace ICSharpCode.SharpDevelop.Gui Match match = Regex.Match(lineText, @"\b(\w:[/\\].*?)\((\d+),(\d+)\)"); if (match.Success) { try { - // Take off 1 for line/col since SharpDevelop is zero index based. - int line = Convert.ToInt32(match.Groups[2].Value) - 1; - int col = Convert.ToInt32(match.Groups[3].Value) - 1; + int line = Convert.ToInt32(match.Groups[2].Value); + int col = Convert.ToInt32(match.Groups[3].Value); return new FileLineReference(match.Groups[1].Value, line, col); } catch (FormatException) { @@ -88,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Gui Match match = Regex.Match(lineText, @"\sin\s(.*?):line\s(\d+)?\r?$", regexOptions); while (match.Success) { try { - int line = Convert.ToInt32(match.Groups[2].Value) - 1; + int line = Convert.ToInt32(match.Groups[2].Value); result = new FileLineReference(match.Groups[1].Value, line); } catch (FormatException) { } catch (OverflowException) { @@ -115,8 +114,7 @@ namespace ICSharpCode.SharpDevelop.Gui if (match.Success) { try { - // Take off 1 for line/pos since SharpDevelop is zero index based. - int line = Convert.ToInt32(match.Groups[2].Value) - 1; + int line = Convert.ToInt32(match.Groups[2].Value); return new FileLineReference(match.Groups[1].Value.Trim(), line); } catch (FormatException) { diff --git a/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs b/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs index b46945d0f0..279df6c71a 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs @@ -59,7 +59,7 @@ namespace ICSharpCode.SharpDevelop.Gui string fileName = ctl.FileName; if (fileName != null) { Caret caret = ctl.ActiveTextAreaControl.Caret; - FileService.JumpToFilePosition(fileName, caret.Line, caret.Column); + FileService.JumpToFilePosition(fileName, caret.Line + 1, caret.Column + 1); // refresh DefinitionView to show the definition of the expression that was double-clicked UpdateTick(null); diff --git a/src/Main/Base/Project/Src/Gui/Pads/SearchResultPad/Nodes/SearchResultNode.cs b/src/Main/Base/Project/Src/Gui/Pads/SearchResultPad/Nodes/SearchResultNode.cs index 18af4a8a77..8efd1b29e2 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/SearchResultPad/Nodes/SearchResultNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/SearchResultPad/Nodes/SearchResultNode.cs @@ -117,7 +117,7 @@ namespace SearchAndReplace public override void ActivateItem() { - FileService.JumpToFilePosition(result.FileName, startPosition.Y, startPosition.X); + FileService.JumpToFilePosition(result.FileName, startPosition.Y + 1, startPosition.X + 1); } } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs index 0ae68c7366..e8772b66a2 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs @@ -75,10 +75,10 @@ namespace ICSharpCode.SharpDevelop.Gui b.Append(t.FileName); if (t.Line >= 0) { b.Append(':'); - b.Append(t.Line + 1); - if (t.Column > 0) { + b.Append(t.Line); + if (t.Column > 1) { b.Append(','); - b.Append(t.Column + 1); + b.Append(t.Column); } } } diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 3a2ebeeb37..4b68483c4f 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -253,7 +253,7 @@ namespace ICSharpCode.SharpDevelop.Debugging public static void JumpToCurrentLine(string SourceFullFilename, int StartLine, int StartColumn, int EndLine, int EndColumn) { - IViewContent viewContent = FileService.JumpToFilePosition(SourceFullFilename, StartLine - 1, StartColumn - 1); + IViewContent viewContent = FileService.JumpToFilePosition(SourceFullFilename, StartLine, StartColumn); CurrentLineBookmark.SetPosition(viewContent, StartLine, StartColumn, EndLine, EndColumn); } diff --git a/src/Main/Base/Project/Src/Services/File/FileService.cs b/src/Main/Base/Project/Src/Services/File/FileService.cs index d39fdc0683..a22c2fe22c 100644 --- a/src/Main/Base/Project/Src/Services/File/FileService.cs +++ b/src/Main/Base/Project/Src/Services/File/FileService.cs @@ -465,7 +465,7 @@ namespace ICSharpCode.SharpDevelop /// /// Opens the specified file and jumps to the specified file position. - /// Warning: Unlike parser coordinates, line and column are 0-based. + /// Line and column start counting at 1. /// public static IViewContent JumpToFilePosition(string fileName, int line, int column) { @@ -486,7 +486,7 @@ namespace ICSharpCode.SharpDevelop content.WorkbenchWindow.ActiveViewContent = content; NavigationService.ResumeLogging(); loggingResumed = true; - ((IPositionable)content).JumpTo(Math.Max(0, line), Math.Max(0, column)); + ((IPositionable)content).JumpTo(Math.Max(1, line), Math.Max(1, column)); } else { NavigationService.ResumeLogging(); loggingResumed = true; diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs b/src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs index 26bbdf0f0b..cc0cd06e31 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/FindReferencesAndRenameHelper.cs @@ -268,7 +268,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring string fileName = cu.FileName; if (fileName != null) { if (!member.Region.IsEmpty) { - viewContent = FileService.JumpToFilePosition(fileName, member.Region.BeginLine - 1, member.Region.BeginColumn - 1); + viewContent = FileService.JumpToFilePosition(fileName, member.Region.BeginLine, member.Region.BeginColumn); } else { FileService.OpenFile(fileName); } @@ -286,7 +286,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring string fileName = cu.FileName; if (fileName != null) { if (!member.Region.IsEmpty) { - viewContent = FileService.JumpToFilePosition(fileName, member.Region.EndLine, 0); + viewContent = FileService.JumpToFilePosition(fileName, member.Region.EndLine + 1, 1); } else { FileService.OpenFile(fileName); } diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs index 927b96f953..6eb91167fb 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringMenuBuilder.cs @@ -272,7 +272,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring ClassBrowserIconService.GotoArrow.Bitmap); gotoDefinitionItem.ShortcutKeys = Keys.Control | Keys.Enter; gotoDefinitionItem.Click += delegate { - FileService.JumpToFilePosition(cu.FileName, region.BeginLine - 1, region.BeginColumn - 1); + FileService.JumpToFilePosition(cu.FileName, region.BeginLine, region.BeginColumn); }; item.DropDown.Items.Add(gotoDefinitionItem); item.DropDown.Items.Add(new ToolStripSeparator()); diff --git a/src/Main/Base/Project/Src/Services/Tasks/Task.cs b/src/Main/Base/Project/Src/Services/Tasks/Task.cs index d54632158f..23bffb8695 100644 --- a/src/Main/Base/Project/Src/Services/Tasks/Task.cs +++ b/src/Main/Base/Project/Src/Services/Tasks/Task.cs @@ -41,7 +41,7 @@ namespace ICSharpCode.SharpDevelop } /// - /// The line number of the task. Zero-based (text editor coordinate) + /// The line number of the task. Starts counting at 1. /// public int Line { get { @@ -50,7 +50,7 @@ namespace ICSharpCode.SharpDevelop } /// - /// The column number of the task. Zero-based (text editor coordinate) + /// The column number of the task. Starts counting at 1. /// public int Column { get { @@ -114,8 +114,8 @@ namespace ICSharpCode.SharpDevelop public Task(BuildError error) { type = error.IsWarning ? TaskType.Warning : TaskType.Error; - column = Math.Max(error.Column - 1, 0); - line = Math.Max(error.Line - 1, 0); + column = Math.Max(error.Column, 1); + line = Math.Max(error.Line, 1); fileName = error.FileName; if (string.IsNullOrEmpty(error.ErrorCode)) { description = error.ErrorText; diff --git a/src/Main/Base/Project/Src/TextEditor/Actions.cs b/src/Main/Base/Project/Src/TextEditor/Actions.cs index e2a28bf3bb..4f3305560f 100644 --- a/src/Main/Base/Project/Src/TextEditor/Actions.cs +++ b/src/Main/Base/Project/Src/TextEditor/Actions.cs @@ -70,7 +70,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Actions if (pos.Position.IsEmpty) FileService.OpenFile(pos.FileName); else - FileService.JumpToFilePosition(pos.FileName, pos.Line - 1, pos.Column - 1); + FileService.JumpToFilePosition(pos.FileName, pos.Line, pos.Column); } catch (Exception ex) { MessageService.ShowError(ex, "Error jumping to '" + pos.FileName + "'."); } diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs index 174dce1741..1b6d1686c2 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs @@ -152,7 +152,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks if (node != null) { SDBookmark mark = node.Tag as SDBookmark; if (mark != null) { - FileService.JumpToFilePosition(mark.FileName, mark.LineNumber, 0); + FileService.JumpToFilePosition(mark.FileName, mark.LineNumber, 1); } } } diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs index 909a8b22d7..1ec012fdf1 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs @@ -96,7 +96,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks public override void ActivateItem() { - FileService.JumpToFilePosition(bookmark.FileName, bookmark.LineNumber, 0); + FileService.JumpToFilePosition(bookmark.FileName, bookmark.LineNumber, 1); } float DrawDocumentWord(Graphics g, string word, PointF position, Font font, Color foreColor) diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs b/src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs index 63c0b928cd..b85df2638f 100644 --- a/src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs +++ b/src/Main/Base/Project/Src/TextEditor/Commands/ClassBookmarkMenuBuilder.cs @@ -262,7 +262,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands if (baseClass != null) { string fileName = baseClass.CompilationUnit.FileName; if (fileName != null) { - FileService.JumpToFilePosition(fileName, baseClass.Region.BeginLine - 1, baseClass.Region.BeginColumn - 1); + FileService.JumpToFilePosition(fileName, baseClass.Region.BeginLine, baseClass.Region.BeginColumn); } } } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs index 47c98cbbac..068e688277 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/GotoDialog.cs @@ -40,11 +40,11 @@ namespace ICSharpCode.SharpDevelop.Gui public GotoDialog() { InitializeComponent(); -// FormLocationHelper.Apply(this, "ICSharpCode.SharpDevelop.Gui.GotoDialog.Bounds", true); - textBox.Focus(); + FormLocationHelper.ApplyWindow(this, "ICSharpCode.SharpDevelop.Gui.GotoDialog.Bounds", true); ParserService.LoadSolutionProjectsThreadEnded += ParserService_LoadSolutionProjectsThreadEnded; + textBox.Focus(); } - + void ParserService_LoadSolutionProjectsThreadEnded(object sender, EventArgs e) { // refresh the list box contents when parsing has completed @@ -390,7 +390,7 @@ namespace ICSharpCode.SharpDevelop.Gui void GotoRegion(DomRegion region, string fileName) { if (fileName != null && !region.IsEmpty) { - FileService.JumpToFilePosition(fileName, region.BeginLine - 1, region.BeginColumn - 1); + FileService.JumpToFilePosition(fileName, region.BeginLine, region.BeginColumn); } } @@ -428,7 +428,7 @@ namespace ICSharpCode.SharpDevelop.Gui if (flref.Line <= 0) { FileService.OpenFile(flref.FileName); } else { - FileService.JumpToFilePosition(flref.FileName, flref.Line - 1, flref.Column); + FileService.JumpToFilePosition(flref.FileName, flref.Line, flref.Column); } } else { throw new NotImplementedException("Unknown tag: " + tag); diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs index 563ec2b8ac..522bf6f6a9 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/ErrorDrawer.cs @@ -162,17 +162,17 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor if (!CheckTask(task)) return; if (task.Line >= 0 && task.Line < textEditor.Document.TotalNumberOfLines) { LineSegment line = textEditor.Document.GetLineSegment(task.Line); - int offset = line.Offset + task.Column; + int offset = line.Offset + task.Column - 1; int length = 1; if (line.Words != null) { foreach (TextWord tw in line.Words) { - if (task.Column == tw.Offset) { + if (task.Column - 1 == tw.Offset) { length = tw.Length; break; } } } - if (length == 1 && task.Column < line.Length) { + if (length == 1 && task.Column - 1 < line.Length) { length = 2; // use minimum length } textEditor.Document.MarkerStrategy.AddMarker(new VisualError(offset, length, task)); diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorBasedPad.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorBasedPad.cs index dfad509627..9b02fcbf25 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorBasedPad.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorBasedPad.cs @@ -95,25 +95,25 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor #region IPositionable implementation void IPositionable.JumpTo(int line, int column) { - this.TextEditorControl.ActiveTextAreaControl.JumpTo(line, column); + this.TextEditorControl.ActiveTextAreaControl.JumpTo(line - 1, column - 1); // we need to delay this call here because the text editor does not know its height if it was just created WorkbenchSingleton.SafeThreadAsyncCall( delegate { this.TextEditorControl.ActiveTextAreaControl.CenterViewOn( - line, (int)(0.3 * this.TextEditorControl.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount)); + line - 1, (int)(0.3 * this.TextEditorControl.ActiveTextAreaControl.TextArea.TextView.VisibleLineCount)); }); } int IPositionable.Line { get { - return this.TextEditorControl.ActiveTextAreaControl.Caret.Line; + return this.TextEditorControl.ActiveTextAreaControl.Caret.Line + 1; } } int IPositionable.Column { get { - return this.TextEditorControl.ActiveTextAreaControl.Caret.Column; + return this.TextEditorControl.ActiveTextAreaControl.Caret.Column + 1; } } #endregion diff --git a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs index 5121f45edf..83bc1443cd 100644 --- a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs +++ b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs @@ -152,7 +152,7 @@ namespace ICSharpCode.SharpDevelop DisposeChild = false }; } else if (content is string) { - contentControl.Content = new TextBlock { + contentControl.Content = new TextBlock { Text = content.ToString(), TextWrapping = TextWrapping.Wrap }; @@ -160,5 +160,37 @@ namespace ICSharpCode.SharpDevelop contentControl.Content = content; } } + + #region System.Drawing <-> WPF conversions + public static System.Drawing.Point ToSystemDrawing(this Point p) + { + return new System.Drawing.Point((int)p.X, (int)p.Y); + } + + public static System.Drawing.Size ToSystemDrawing(this Size s) + { + return new System.Drawing.Size((int)s.Width, (int)s.Height); + } + + public static System.Drawing.Rectangle ToSystemDrawing(this Rect r) + { + return new System.Drawing.Rectangle(r.TopLeft.ToSystemDrawing(), r.Size.ToSystemDrawing()); + } + + public static Point ToWpf(this System.Drawing.Point p) + { + return new Point(p.X, p.Y); + } + + public static Size ToWpf(this System.Drawing.Size s) + { + return new Size(s.Width, s.Height); + } + + public static Rect ToWpf(this System.Drawing.Rectangle rect) + { + return new Rect(rect.Location.ToWpf(), rect.Size.ToWpf()); + } + #endregion } } diff --git a/src/Main/Base/Test/OutputTextLineParserTestFixture.cs b/src/Main/Base/Test/OutputTextLineParserTestFixture.cs index d696c13db3..54fd51a1b3 100644 --- a/src/Main/Base/Test/OutputTextLineParserTestFixture.cs +++ b/src/Main/Base/Test/OutputTextLineParserTestFixture.cs @@ -20,7 +20,7 @@ namespace ICSharpCode.SharpDevelop.Tests string output = " at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\n"; FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(output, true); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); - Assert.AreEqual(21, lineRef.Line); + Assert.AreEqual(22, lineRef.Line); Assert.AreEqual(0, lineRef.Column); } @@ -30,7 +30,7 @@ namespace ICSharpCode.SharpDevelop.Tests string output = " at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\r\n"; FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(output, true); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); - Assert.AreEqual(21, lineRef.Line); + Assert.AreEqual(22, lineRef.Line); Assert.AreEqual(0, lineRef.Column); } @@ -41,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Tests " at NunitFoo.Tests.FooTest.Foo() in c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs:line 22\r\n"; FileLineReference lineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(output, true); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); - Assert.AreEqual(21, lineRef.Line); + Assert.AreEqual(22, lineRef.Line); Assert.AreEqual(0, lineRef.Column); } @@ -51,7 +51,7 @@ namespace ICSharpCode.SharpDevelop.Tests string output = "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs(22)"; FileLineReference lineRef = OutputTextLineParser.GetFileLineReference(output); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); - Assert.AreEqual(21, lineRef.Line); + Assert.AreEqual(22, lineRef.Line); Assert.AreEqual(0, lineRef.Column); } @@ -61,8 +61,8 @@ namespace ICSharpCode.SharpDevelop.Tests string output = "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs(22,10)"; FileLineReference lineRef = OutputTextLineParser.GetFileLineReference(output); Assert.AreEqual(lineRef.FileName, "c:\\test\\NunitFoo\\NunitFoo.Tests\\FooTest.cs"); - Assert.AreEqual(21, lineRef.Line); - Assert.AreEqual(9, lineRef.Column); + Assert.AreEqual(22, lineRef.Line); + Assert.AreEqual(10, lineRef.Column); } } }