diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/CaretActions.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/CaretActions.cs
index 8c6b296324..a447dd069a 100644
--- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/CaretActions.cs
+++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/CaretActions.cs
@@ -86,7 +86,7 @@ namespace ICSharpCode.TextEditor.Actions
Point pos = new Point(xpos,
textArea.TextView.DrawingPosition.Y + (visualLine - 1) * textArea.TextView.FontHeight - textArea.TextView.TextArea.VirtualTop.Y);
textArea.Caret.Position = textArea.TextView.GetLogicalPosition(pos.X, pos.Y);
- textArea.SetCaretToDesiredColumn(textArea.Caret.Position.Y);
+ textArea.SetCaretToDesiredColumn();
}
// if (textArea.Caret.Line > 0) {
// textArea.SetCaretToDesiredColumn(textArea.Caret.Line - 1);
@@ -106,7 +106,7 @@ namespace ICSharpCode.TextEditor.Actions
Point pos = new Point(xpos,
textArea.TextView.DrawingPosition.Y + (visualLine + 1) * textArea.TextView.FontHeight - textArea.TextView.TextArea.VirtualTop.Y);
textArea.Caret.Position = textArea.TextView.GetLogicalPosition(pos.X, pos.Y);
- textArea.SetCaretToDesiredColumn(textArea.Caret.Position.Y);
+ textArea.SetCaretToDesiredColumn();
}
// if (textArea.Caret.Line + 1 < textArea.Document.TotalNumberOfLines) {
// textArea.SetCaretToDesiredColumn(textArea.Caret.Line + 1);
diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs
index 3cf3284fcc..ea6b4cac08 100644
--- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs
+++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs
@@ -212,7 +212,7 @@ namespace ICSharpCode.TextEditor.Actions
} else {
textArea.Caret.DesiredColumn = Math.Max(0, currentColumn - remainder);
}
- textArea.SetCaretToDesiredColumn(textArea.Caret.Line);
+ textArea.SetCaretToDesiredColumn();
}
}
}
diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs
index 44a1fdc40c..dbad2c245a 100644
--- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs
+++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs
@@ -270,6 +270,12 @@ namespace ICSharpCode.TextEditor
Caret.DesiredColumn = TextView.GetDrawingXPos(Caret.Line, Caret.Column) + (int)(VirtualTop.X * textView.WideSpaceWidth);
}
+ public void SetCaretToDesiredColumn()
+ {
+ Caret.Position = textView.GetLogicalColumn(Caret.Line, Caret.DesiredColumn + (int)(VirtualTop.X * textView.WideSpaceWidth));
+ }
+
+ [Obsolete("Use the parameterless version")]
public void SetCaretToDesiredColumn(int caretLine)
{
Caret.Position = textView.GetLogicalColumn(Caret.Line, Caret.DesiredColumn + (int)(VirtualTop.X * textView.WideSpaceWidth));
diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Util/TipText.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Util/TipText.cs
index ab68341814..2dc472dfbe 100644
--- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Util/TipText.cs
+++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Util/TipText.cs
@@ -5,6 +5,7 @@
// $Revision$
//
+using System;
using System.Drawing;
namespace ICSharpCode.TextEditor.Util
@@ -13,7 +14,7 @@ namespace ICSharpCode.TextEditor.Util
{
float triHeight = 10;
float triWidth = 10;
-
+
public CountTipText(Graphics graphics, Font font, string text) : base(graphics, font, text)
{
}
@@ -27,20 +28,20 @@ namespace ICSharpCode.TextEditor.Util
brush = Brushes.Black;
if (flipped) {
base.Graphics.FillPolygon(brush, new PointF[] {
- new PointF(x, y + triHeight2 - triHeight4),
- new PointF(x + triWidth / 2, y + triHeight2 + triHeight4),
- new PointF(x + triWidth, y + triHeight2 - triHeight4),
- });
+ new PointF(x, y + triHeight2 - triHeight4),
+ new PointF(x + triWidth / 2, y + triHeight2 + triHeight4),
+ new PointF(x + triWidth, y + triHeight2 - triHeight4),
+ });
} else {
base.Graphics.FillPolygon(brush, new PointF[] {
- new PointF(x, y + triHeight2 + triHeight4),
- new PointF(x + triWidth / 2, y + triHeight2 - triHeight4),
- new PointF(x + triWidth, y + triHeight2 + triHeight4),
- });
+ new PointF(x, y + triHeight2 + triHeight4),
+ new PointF(x + triWidth / 2, y + triHeight2 - triHeight4),
+ new PointF(x + triWidth, y + triHeight2 + triHeight4),
+ });
}
}
-
+
public Rectangle DrawingRectangle1;
public Rectangle DrawingRectangle2;
@@ -48,14 +49,14 @@ namespace ICSharpCode.TextEditor.Util
{
if (tipText != null && tipText.Length > 0) {
base.Draw(new PointF(location.X + triWidth + 4, location.Y));
- DrawingRectangle1 = new Rectangle((int)location.X + 2,
- (int)location.Y + 2,
- (int)(triWidth),
- (int)(triHeight));
+ DrawingRectangle1 = new Rectangle((int)location.X + 2,
+ (int)location.Y + 2,
+ (int)(triWidth),
+ (int)(triHeight));
DrawingRectangle2 = new Rectangle((int)(location.X + base.AllocatedSize.Width - triWidth - 2),
- (int)location.Y + 2,
- (int)(triWidth),
- (int)(triHeight));
+ (int)location.Y + 2,
+ (int)(triWidth),
+ (int)(triHeight));
DrawTriangle(location.X + 2, location.Y + 2, false);
DrawTriangle(location.X + base.AllocatedSize.Width - triWidth - 2, location.Y + 2, true);
}
@@ -79,16 +80,18 @@ namespace ICSharpCode.TextEditor.Util
class TipText: TipSection
{
protected StringAlignment horzAlign;
- protected StringAlignment vertAlign;
+ protected StringAlignment vertAlign;
protected Color tipColor;
protected Font tipFont;
protected StringFormat tipFormat;
protected string tipText;
-
+
public TipText(Graphics graphics, Font font, string text):
base(graphics)
{
tipFont = font; tipText = text;
+ if (text != null && text.Length > short.MaxValue)
+ throw new ArgumentException("TipText: text too long (max. is " + short.MaxValue + " characters)", "text");
Color = SystemColors.InfoText;
HorizontalAlignment = StringAlignment.Near;
@@ -103,7 +106,7 @@ namespace ICSharpCode.TextEditor.Util
Graphics.DrawString(tipText, tipFont,
BrushRegistry.GetBrush(Color),
drawRectangle,
- GetInternalStringFormat());
+ GetInternalStringFormat());
}
}
diff --git a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
index 572ef20134..c8ba31f4f4 100644
--- a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
+++ b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
@@ -857,7 +857,20 @@ namespace ICSharpCode.SharpDevelop.Project
project.Load(fileName);
} catch (MSBuild.InvalidProjectFileException ex) {
LoggingService.Warn(ex);
- if (ex.ErrorCode == "MSB4075") {
+ LoggingService.Warn("ErrorCode = " + ex.ErrorCode);
+ bool isVS2003ProjectWithInvalidEncoding = false;
+ if (ex.ErrorCode == "MSB4025") {
+ // Invalid XML.
+ // This MIGHT be a VS2003 project in default encoding, so we have to use this
+ // ugly trick to detect old-style projects
+ using (StreamReader r = File.OpenText(fileName)) {
+ if (r.ReadLine() == "") {
+ isVS2003ProjectWithInvalidEncoding = true;
+ }
+ }
+ }
+ if (ex.ErrorCode == "MSB4075" || isVS2003ProjectWithInvalidEncoding) {
+ // MSB4075 is:
// "The project file must be opened in VS IDE and converted to latest version
// before it can be build by MSBuild."
Converter.PrjxToSolutionProject.ConvertVSNetProject(fileName);