Browse Source

Fixed import of VS2003 projects that were saved with system encoding.

Remove unused parameter from TextArea.SetCaretToDesiredColumn.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2542 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
f3787b6fc0
  1. 4
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/CaretActions.cs
  2. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs
  3. 6
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs
  4. 43
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Util/TipText.cs
  5. 15
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

4
src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/CaretActions.cs

@ -86,7 +86,7 @@ namespace ICSharpCode.TextEditor.Actions @@ -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 @@ -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);

2
src/Libraries/ICSharpCode.TextEditor/Project/Src/Actions/MiscActions.cs

@ -212,7 +212,7 @@ namespace ICSharpCode.TextEditor.Actions @@ -212,7 +212,7 @@ namespace ICSharpCode.TextEditor.Actions
} else {
textArea.Caret.DesiredColumn = Math.Max(0, currentColumn - remainder);
}
textArea.SetCaretToDesiredColumn(textArea.Caret.Line);
textArea.SetCaretToDesiredColumn();
}
}
}

6
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs

@ -270,6 +270,12 @@ namespace ICSharpCode.TextEditor @@ -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));

43
src/Libraries/ICSharpCode.TextEditor/Project/Src/Util/TipText.cs

@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
// <version>$Revision$</version>
// </file>
using System;
using System.Drawing;
namespace ICSharpCode.TextEditor.Util
@ -13,7 +14,7 @@ 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 @@ -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 @@ -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 @@ -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 @@ -103,7 +106,7 @@ namespace ICSharpCode.TextEditor.Util
Graphics.DrawString(tipText, tipFont,
BrushRegistry.GetBrush(Color),
drawRectangle,
GetInternalStringFormat());
GetInternalStringFormat());
}
}

15
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -857,7 +857,20 @@ namespace ICSharpCode.SharpDevelop.Project @@ -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() == "<VisualStudioProject>") {
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);

Loading…
Cancel
Save