Browse Source

Merge branch '4.0'

pull/15/head
Daniel Grunwald 15 years ago
parent
commit
c9a4734906
  1. 23
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/AssignStylesheetCommand.cs
  2. 13
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/DottedLineMargin.cs
  3. 1
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.cs
  4. 14
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs
  5. 23
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/HeightTree.cs
  6. 34
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  7. 14
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs
  8. 2
      src/Main/Base/Project/Src/Gui/FormLocationHelper.cs
  9. 6
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/FileNode.cs
  10. 33
      src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs
  11. 49
      src/Main/Base/Project/Src/Project/CustomTool.cs
  12. 19
      src/Main/ICSharpCode.SharpDevelop.BuildWorker/Program.cs

23
src/AddIns/DisplayBindings/XmlEditor/Project/Src/AssignStylesheetCommand.cs

@ -24,10 +24,11 @@ namespace ICSharpCode.XmlEditor
string stylesheetFileName = BrowseForStylesheetFile(); string stylesheetFileName = BrowseForStylesheetFile();
// Assign stylesheet. // Assign stylesheet.
if (stylesheetFileName != null) if (stylesheetFileName != null) {
xmlView.StylesheetFileName = stylesheetFileName; xmlView.StylesheetFileName = stylesheetFileName;
} }
} }
}
public static string BrowseForStylesheetFile() public static string BrowseForStylesheetFile()
{ {
@ -39,21 +40,29 @@ namespace ICSharpCode.XmlEditor
AddInTreeNode node = AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter"); AddInTreeNode node = AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter");
if (node != null) { if (node != null) {
string xmlFileFilter = GetFileFilter(node, "Xml");
string allFilesFilter = GetFileFilter(node, "AllFiles");
string xslFileFilter = GetFileFilter(node, "Xsl");
string xmlFileFilter = (string)node.BuildChildItem("Xml", null, null); dialog.Filter = String.Join("|", xslFileFilter, xmlFileFilter, allFilesFilter);
string allFilesFilter = (string)node.BuildChildItem("AllFiles", null, null);
string xslFileFilter = (string)node.BuildChildItem("Xsl", null, null);
dialog.Filter = string.Concat(xslFileFilter, "|", xmlFileFilter, "|", allFilesFilter);
dialog.FilterIndex = 1; dialog.FilterIndex = 1;
} }
if (dialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window) == DialogResult.OK) { if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) == DialogResult.OK) {
return dialog.FileName; return dialog.FileName;
} }
} }
return null; return null;
} }
static string GetFileFilter(AddInTreeNode node, string filterName)
{
FileFilterDescriptor fileFilter = node.BuildChildItem(filterName, null, null) as FileFilterDescriptor;
if (fileFilter != null) {
return fileFilter.ToString();
}
return String.Empty;
}
} }
} }

13
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/DottedLineMargin.cs

@ -20,7 +20,7 @@ namespace ICSharpCode.AvalonEdit.Editing
/// <summary> /// <summary>
/// Creates a vertical dotted line to separate the line numbers from the text view. /// Creates a vertical dotted line to separate the line numbers from the text view.
/// </summary> /// </summary>
public static UIElement Create(TextEditor editor) public static UIElement Create()
{ {
Line line = new Line { Line line = new Line {
X1 = 0, Y1 = 0, X2 = 0, Y2 = 1, X1 = 0, Y1 = 0, X2 = 0, Y2 = 1,
@ -32,6 +32,17 @@ namespace ICSharpCode.AvalonEdit.Editing
Tag = tag Tag = tag
}; };
return line;
}
/// <summary>
/// Creates a vertical dotted line to separate the line numbers from the text view.
/// </summary>
[Obsolete("This method got published accidentally; and will be removed again in a future version. Use the parameterless overload instead.")]
public static UIElement Create(TextEditor editor)
{
Line line = (Line)Create();
line.SetBinding( line.SetBinding(
Line.StrokeProperty, Line.StrokeProperty,
new Binding("LineNumbersForeground") { Source = editor } new Binding("LineNumbersForeground") { Source = editor }

1
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/SelectionMouseHandler.cs

@ -206,6 +206,7 @@ namespace ICSharpCode.AvalonEdit.Editing
textArea.Document.UndoStack.EndUndoGroup(); textArea.Document.UndoStack.EndUndoGroup();
} }
} }
e.Handled = true;
} }
} }
} catch (Exception ex) { } catch (Exception ex) {

14
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs

@ -95,6 +95,20 @@ namespace ICSharpCode.AvalonEdit.Folding
} }
} }
if (foldedUntil > offset && foldingSection != null) { if (foldedUntil > offset && foldingSection != null) {
// Handle overlapping foldings: if there's another folded folding
// (starting within the foldingSection) that continues after the end of the folded section,
// then we'll extend our fold element to cover that overlapping folding.
bool foundOverlappingFolding;
do {
foundOverlappingFolding = false;
foreach (FoldingSection fs in FoldingManager.GetFoldingsContaining(foldedUntil)) {
if (fs.IsFolded && fs.EndOffset > foldedUntil) {
foldedUntil = fs.EndOffset;
foundOverlappingFolding = true;
}
}
} while (foundOverlappingFolding);
string title = foldingSection.Title; string title = foldingSection.Title;
if (string.IsNullOrEmpty(title)) if (string.IsNullOrEmpty(title))
title = "..."; title = "...";

23
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/HeightTree.cs

@ -58,7 +58,24 @@ namespace ICSharpCode.AvalonEdit.Rendering
this.weakLineTracker = null; this.weakLineTracker = null;
} }
public double DefaultLineHeight { get; set; } double defaultLineHeight;
public double DefaultLineHeight {
get { return defaultLineHeight; }
set {
double oldValue = defaultLineHeight;
if (oldValue == value)
return;
defaultLineHeight = value;
// update the stored value in all nodes:
foreach (var node in AllNodes) {
if (node.lineNode.height == oldValue) {
node.lineNode.height = value;
UpdateAugmentedData(node, UpdateAfterChildrenChangeRecursionMode.IfRequired);
}
}
}
}
HeightTreeNode GetNode(DocumentLine ls) HeightTreeNode GetNode(DocumentLine ls)
{ {
@ -84,7 +101,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
HeightTreeNode[] nodes = new HeightTreeNode[document.LineCount]; HeightTreeNode[] nodes = new HeightTreeNode[document.LineCount];
int lineNumber = 0; int lineNumber = 0;
foreach (DocumentLine ls in document.Lines) { foreach (DocumentLine ls in document.Lines) {
nodes[lineNumber++] = new HeightTreeNode(ls, DefaultLineHeight); nodes[lineNumber++] = new HeightTreeNode(ls, defaultLineHeight);
} }
Debug.Assert(nodes.Length > 0); Debug.Assert(nodes.Length > 0);
// now build the corresponding balanced tree // now build the corresponding balanced tree
@ -161,7 +178,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
HeightTreeNode InsertAfter(HeightTreeNode node, DocumentLine newLine) HeightTreeNode InsertAfter(HeightTreeNode node, DocumentLine newLine)
{ {
HeightTreeNode newNode = new HeightTreeNode(newLine, DefaultLineHeight); HeightTreeNode newNode = new HeightTreeNode(newLine, defaultLineHeight);
if (node.right == null) { if (node.right == null) {
if (node.lineNode.collapsedSections != null) { if (node.lineNode.collapsedSections != null) {
// we are inserting directly after node - so copy all collapsedSections // we are inserting directly after node - so copy all collapsedSections

34
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -1233,18 +1233,15 @@ namespace ICSharpCode.AvalonEdit.Rendering
null)) null))
{ {
wideSpaceWidth = Math.Max(1, line.WidthIncludingTrailingWhitespace); wideSpaceWidth = Math.Max(1, line.WidthIncludingTrailingWhitespace);
defaultLineHeight = line.Height; defaultLineHeight = Math.Max(1, line.Height);
} }
} else { } else {
wideSpaceWidth = FontSize / 2; wideSpaceWidth = FontSize / 2;
defaultLineHeight = FontSize + 3; defaultLineHeight = FontSize + 3;
} }
} // Update heightTree.DefaultLineHeight, if a document is loaded.
if (heightTree != null)
void InvalidateWideSpaceWidthAndDefaultLineHeight() heightTree.DefaultLineHeight = defaultLineHeight;
{
wideSpaceWidth = 0;
defaultLineHeight = 0;
} }
static double ValidateVisualOffset(double offset) static double ValidateVisualOffset(double offset)
@ -1684,20 +1681,29 @@ namespace ICSharpCode.AvalonEdit.Rendering
{ {
base.OnPropertyChanged(e); base.OnPropertyChanged(e);
if (TextFormatterFactory.PropertyChangeAffectsTextFormatter(e.Property)) { if (TextFormatterFactory.PropertyChangeAffectsTextFormatter(e.Property)) {
RecreateCachedElements(); // first, create the new text formatter:
RecreateTextFormatter(); RecreateTextFormatter();
InvalidateWideSpaceWidthAndDefaultLineHeight(); // changing text formatter requires recreating the cached elements
RecreateCachedElements();
// and we need to re-measure the font metrics:
MeasureWideSpaceWidthAndDefaultLineHeight();
} else if (e.Property == Control.ForegroundProperty
|| e.Property == TextView.NonPrintableCharacterBrushProperty)
{
// changing brushes requires recreating the cached elements
RecreateCachedElements();
Redraw();
} }
if (e.Property == Control.ForegroundProperty if (e.Property == Control.FontFamilyProperty
|| e.Property == Control.FontFamilyProperty
|| e.Property == Control.FontSizeProperty || e.Property == Control.FontSizeProperty
|| e.Property == Control.FontStretchProperty || e.Property == Control.FontStretchProperty
|| e.Property == Control.FontStyleProperty || e.Property == Control.FontStyleProperty
|| e.Property == Control.FontWeightProperty || e.Property == Control.FontWeightProperty)
|| e.Property == TextView.NonPrintableCharacterBrushProperty)
{ {
// changing font properties requires recreating cached elements
RecreateCachedElements(); RecreateCachedElements();
InvalidateWideSpaceWidthAndDefaultLineHeight(); // and we need to re-measure the font metrics:
MeasureWideSpaceWidthAndDefaultLineHeight();
Redraw(); Redraw();
} }
} }

14
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs

@ -13,7 +13,9 @@ using System.Windows.Data;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Markup; using System.Windows.Markup;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting;
@ -470,13 +472,13 @@ namespace ICSharpCode.AvalonEdit
TextEditor editor = (TextEditor)d; TextEditor editor = (TextEditor)d;
var leftMargins = editor.TextArea.LeftMargins; var leftMargins = editor.TextArea.LeftMargins;
if ((bool)e.NewValue) { if ((bool)e.NewValue) {
var lineNumbers = new LineNumberMargin(); LineNumberMargin lineNumbers = new LineNumberMargin();
Line line = (Line)DottedLineMargin.Create();
leftMargins.Insert(0, lineNumbers); leftMargins.Insert(0, lineNumbers);
leftMargins.Insert(1, DottedLineMargin.Create(editor)); leftMargins.Insert(1, line);
lineNumbers.SetBinding(Control.ForegroundProperty, var lineNumbersForeground = new Binding("LineNumbersForeground") { Source = editor };
new Binding("LineNumbersForeground") { line.SetBinding(Line.StrokeProperty, lineNumbersForeground);
Source = editor lineNumbers.SetBinding(Control.ForegroundProperty, lineNumbersForeground);
});
} else { } else {
for (int i = 0; i < leftMargins.Count; i++) { for (int i = 0; i < leftMargins.Count; i++) {
if (leftMargins[i] is LineNumberMargin) { if (leftMargins[i] is LineNumberMargin) {

2
src/Main/Base/Project/Src/Gui/FormLocationHelper.cs

@ -60,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Gui
}; };
} }
static Rect Validate(Rect bounds) public static Rect Validate(Rect bounds)
{ {
// Check if form is outside the screen and get it back if necessary. // 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 // This is important when the user uses multiple screens, a window stores its location

6
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/FileNode.cs

@ -122,7 +122,11 @@ namespace ICSharpCode.SharpDevelop.Project
public override void ActivateItem() public override void ActivateItem()
{ {
FileService.OpenFile(FileName); var viewContent = FileService.OpenFile(FileName);
if (fileNodeStatus == FileNodeStatus.Missing && viewContent != null) {
fileNodeStatus = FileNodeStatus.InProject;
SetIcon();
}
} }
// protected override void Initialize() // protected override void Initialize()

33
src/Main/Base/Project/Src/Gui/Workbench/WpfWorkbench.cs

@ -529,25 +529,36 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
#endregion #endregion
System.Windows.WindowState lastNonMinimizedWindowState = System.Windows.WindowState.Normal;
Rect restoreBoundsBeforeClosing;
protected override void OnStateChanged(EventArgs e)
{
base.OnStateChanged(e);
if (this.WindowState != System.Windows.WindowState.Minimized)
lastNonMinimizedWindowState = this.WindowState;
}
public Properties CreateMemento() public Properties CreateMemento()
{ {
Properties prop = new Properties(); Properties prop = new Properties();
prop.Set("WindowState", this.WindowState); prop.Set("WindowState", lastNonMinimizedWindowState);
if (this.WindowState == System.Windows.WindowState.Normal) { var bounds = this.RestoreBounds;
prop.Set("Left", this.Left); if (bounds.IsEmpty) bounds = restoreBoundsBeforeClosing;
prop.Set("Top", this.Top); if (!bounds.IsEmpty) {
prop.Set("Width", this.Width); prop.Set("Bounds", bounds);
prop.Set("Height", this.Height);
} }
return prop; return prop;
} }
public void SetMemento(Properties memento) public void SetMemento(Properties memento)
{ {
this.Left = memento.Get("Left", 10.0); Rect bounds = memento.Get("Bounds", new Rect(10, 10, 750, 550));
this.Top = memento.Get("Top", 10.0); bounds = FormLocationHelper.Validate(bounds);
this.Width = memento.Get("Width", 600.0); this.Left = bounds.Left;
this.Height = memento.Get("Height", 400.0); this.Top = bounds.Top;
this.Width = bounds.Width;
this.Height = bounds.Height;
this.WindowState = memento.Get("WindowState", System.Windows.WindowState.Maximized); this.WindowState = memento.Get("WindowState", System.Windows.WindowState.Maximized);
} }
@ -574,6 +585,8 @@ namespace ICSharpCode.SharpDevelop.Gui
Project.ProjectService.CloseSolution(); Project.ProjectService.CloseSolution();
ParserService.StopParserThread(); ParserService.StopParserThread();
restoreBoundsBeforeClosing = this.RestoreBounds;
this.WorkbenchLayout = null; this.WorkbenchLayout = null;
foreach (PadDescriptor padDescriptor in this.PadContentCollection) { foreach (PadDescriptor padDescriptor in this.PadContentCollection) {

49
src/Main/Base/Project/Src/Project/CustomTool.cs

@ -99,12 +99,24 @@ namespace ICSharpCode.SharpDevelop.Project
} }
public string GetOutputFileName(FileProjectItem baseItem, string additionalExtension) public string GetOutputFileName(FileProjectItem baseItem, string additionalExtension)
{
return GetOutputFileName(baseItem, additionalExtension, true);
}
public string GetOutputFileName(FileProjectItem baseItem, string additionalExtension, bool isPrimaryOutput)
{ {
if (baseItem == null) if (baseItem == null)
throw new ArgumentNullException("baseItem"); throw new ArgumentNullException("baseItem");
if (baseItem.Project != project) if (baseItem.Project != project)
throw new ArgumentException("baseItem is not from project this CustomToolContext belongs to"); throw new ArgumentException("baseItem is not from project this CustomToolContext belongs to");
if (isPrimaryOutput) {
string lastGenOutput = baseItem.GetEvaluatedMetadata("LastGenOutput");
if (!string.IsNullOrEmpty(lastGenOutput)) {
return Path.Combine(Path.GetDirectoryName(baseItem.FileName), lastGenOutput);
}
}
string newExtension = null; string newExtension = null;
if (project.LanguageProperties.CodeDomProvider != null) { if (project.LanguageProperties.CodeDomProvider != null) {
newExtension = project.LanguageProperties.CodeDomProvider.FileExtension; newExtension = project.LanguageProperties.CodeDomProvider.FileExtension;
@ -121,22 +133,55 @@ namespace ICSharpCode.SharpDevelop.Project
newExtension = "." + newExtension; newExtension = "." + newExtension;
} }
return Path.ChangeExtension(baseItem.FileName, additionalExtension + newExtension); string newFileName = Path.ChangeExtension(baseItem.FileName, additionalExtension + newExtension);
int retryIndex = 0;
while (true) {
FileProjectItem item = project.FindFile(newFileName);
// If the file does not exist in the project, we can use that name.
if (item == null)
return newFileName;
// If the file already exists in the project, use it only if it belongs to our base item
if (string.Equals(item.DependentUpon, Path.GetFileName(baseItem.FileName), StringComparison.OrdinalIgnoreCase))
return newFileName;
// Otherwise, find another free file name
retryIndex++;
newFileName = Path.ChangeExtension(baseItem.FileName, additionalExtension + retryIndex + newExtension);
}
} }
public FileProjectItem EnsureOutputFileIsInProject(FileProjectItem baseItem, string outputFileName) public FileProjectItem EnsureOutputFileIsInProject(FileProjectItem baseItem, string outputFileName)
{ {
return EnsureOutputFileIsInProject(baseItem, outputFileName, true);
}
public FileProjectItem EnsureOutputFileIsInProject(FileProjectItem baseItem, string outputFileName, bool isPrimaryOutput)
{
if (baseItem == null)
throw new ArgumentNullException("baseItem");
if (baseItem.Project != project)
throw new ArgumentException("baseItem is not from project this CustomToolContext belongs to");
WorkbenchSingleton.AssertMainThread(); WorkbenchSingleton.AssertMainThread();
bool saveProject = false;
if (isPrimaryOutput) {
if (baseItem.GetEvaluatedMetadata("LastGenOutput") != Path.GetFileName(outputFileName)) {
saveProject = true;
baseItem.SetEvaluatedMetadata("LastGenOutput", Path.GetFileName(outputFileName));
}
}
FileProjectItem outputItem = project.FindFile(outputFileName); FileProjectItem outputItem = project.FindFile(outputFileName);
if (outputItem == null) { if (outputItem == null) {
outputItem = new FileProjectItem(project, ItemType.Compile); outputItem = new FileProjectItem(project, ItemType.Compile);
outputItem.FileName = outputFileName; outputItem.FileName = outputFileName;
outputItem.DependentUpon = Path.GetFileName(baseItem.FileName); outputItem.DependentUpon = Path.GetFileName(baseItem.FileName);
outputItem.SetEvaluatedMetadata("AutoGen", "True");
ProjectService.AddProjectItem(project, outputItem); ProjectService.AddProjectItem(project, outputItem);
FileService.FireFileCreated(outputFileName, false); FileService.FireFileCreated(outputFileName, false);
project.Save(); saveProject = true;
ProjectBrowserPad.RefreshViewAsync(); ProjectBrowserPad.RefreshViewAsync();
} }
if (saveProject)
project.Save();
return outputItem; return outputItem;
} }

19
src/Main/ICSharpCode.SharpDevelop.BuildWorker/Program.cs

@ -123,7 +123,12 @@ namespace ICSharpCode.SharpDevelop.BuildWorker
Program.Log("In build thread"); Program.Log("In build thread");
bool success = false; bool success = false;
try { try {
if (File.Exists(currentJob.ProjectFileName)) {
success = buildWrapper.DoBuild(currentJob, new ForwardingLogger(this)); success = buildWrapper.DoBuild(currentJob, new ForwardingLogger(this));
} else {
success = false;
HostReportEvent(new BuildErrorEventArgs(null, null, currentJob.ProjectFileName, 0, 0, 0, 0, "Project file '" + Path.GetFileName(currentJob.ProjectFileName) + "' not found", null, null));
}
} catch (Exception ex) { } catch (Exception ex) {
host.Writer.Write("ReportException"); host.Writer.Write("ReportException");
host.Writer.Write(ex.ToString()); host.Writer.Write(ex.ToString());
@ -297,19 +302,5 @@ namespace ICSharpCode.SharpDevelop.BuildWorker
} }
} }
#endif #endif
[Serializable]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1064:ExceptionsShouldBePublic")]
sealed class BuildCancelException : Exception
{
public BuildCancelException()
{
}
BuildCancelException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
} }
} }

Loading…
Cancel
Save