From 10b427cfaffa3a83ac87525f4e214873dacb4ec6 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sun, 28 Nov 2010 19:09:32 +0000 Subject: [PATCH 01/88] Fix SD-1657 - Grid adorner - File no longer marked as dirty when just moving the mouse over the column header. --- .../Project/Controls/GridAdorner.cs | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs index 53aee95b0e..23a5f166ae 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs @@ -433,34 +433,37 @@ namespace ICSharpCode.WpfDesign.Designer.Controls public void SetGridLengthUnit(GridUnitType unit) { DesignItem item = unitSelector.SelectedItem; - GridLength value; - grid.UpdateLayout(); Debug.Assert(item != null); if (orientation == Orientation.Vertical) { - value = (GridLength)item.Properties[RowDefinition.HeightProperty].ValueOnInstance; - - if (unit == GridUnitType.Auto) - value = GridLength.Auto; - else - value = new GridLength(value.Value, unit); - - item.Properties[RowDefinition.HeightProperty].SetValue(value); + SetGridLengthUnit(unit, item, RowDefinition.HeightProperty); } else { - value = (GridLength)item.Properties[ColumnDefinition.WidthProperty].ValueOnInstance; - - if (unit == GridUnitType.Auto) - value = GridLength.Auto; - else - value = new GridLength(value.Value, unit); - - item.Properties[ColumnDefinition.WidthProperty].SetValue(value); + SetGridLengthUnit(unit, item, ColumnDefinition.WidthProperty); } grid.UpdateLayout(); InvalidateVisual(); } + + void SetGridLengthUnit(GridUnitType unit, DesignItem item, DependencyProperty property) + { + DesignItemProperty itemProperty = item.Properties[property]; + GridLength oldValue = (GridLength)itemProperty.ValueOnInstance; + GridLength value = GetNewGridLength(unit, oldValue); + + if (value != oldValue) { + itemProperty.SetValue(value); + } + } + + GridLength GetNewGridLength(GridUnitType unit, GridLength oldValue) + { + if (unit == GridUnitType.Auto) { + return GridLength.Auto; + } + return new GridLength(oldValue.Value, unit); + } } public abstract class GridSplitterAdorner : Control From b83553d64c35829a0970d92963241244e082b293 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 29 Nov 2010 17:07:14 +0100 Subject: [PATCH 02/88] fixed http://community.sharpdevelop.net/forums/t/12320.aspx --- .../Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs index f4d8d8b7f9..ac9c05394a 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs @@ -1956,12 +1956,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter else TrackVisit(forNextStatement.LoopVariableExpression, data); outputFormatter.Space(); - PrimitiveExpression pe = forNextStatement.Step as PrimitiveExpression; + Expression stepExpr = forNextStatement.Step; + while (stepExpr is ParenthesizedExpression) + stepExpr = ((ParenthesizedExpression)stepExpr).Expression; + PrimitiveExpression pe = stepExpr as PrimitiveExpression; if ((pe == null || !(pe.Value is int) || ((int)pe.Value) >= 0) - && !(forNextStatement.Step is UnaryOperatorExpression)) + && !(stepExpr is UnaryOperatorExpression)) outputFormatter.PrintToken(Tokens.LessEqual); else { - if (forNextStatement.Step is UnaryOperatorExpression && ((UnaryOperatorExpression)forNextStatement.Step).Op == UnaryOperatorType.Plus) + if (stepExpr is UnaryOperatorExpression && ((UnaryOperatorExpression)stepExpr).Op == UnaryOperatorType.Plus) outputFormatter.PrintToken(Tokens.LessEqual); else outputFormatter.PrintToken(Tokens.GreaterEqual); From fb4d7f319ecba332d58b0165516f88d05dae5f77 Mon Sep 17 00:00:00 2001 From: peterforstmeier Date: Mon, 29 Nov 2010 20:07:40 +0100 Subject: [PATCH 03/88] Fire RowRenderEvent after Layouter and before Converter --- .../Project/BaseClasses/Printing/Layouter.cs | 12 ++++++------ .../Exporter/Converters/BaseConverter.cs | 18 ++++++++++-------- .../Exporter/Converters/GroupedRowConverter.cs | 5 +++-- .../Converters/GroupedTableConverter.cs | 4 +++- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs index b6ea39b395..b3f63ca23a 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/Printing/Layouter.cs @@ -33,8 +33,8 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing return Rectangle.Empty; } - Console.WriteLine("\tlayouter for container <{0}>",container.ToString()); - +// Console.WriteLine("\tlayouter for container <{0}>",container.ToString()); + Console.WriteLine("\tLayouter for Container"); Rectangle desiredContainerRectangle = new Rectangle (container.Location,container.Size); System.Collections.Generic.IEnumerable canGrowShrinkCollection = from bt in container.Items where bt.CanGrow == true select bt; @@ -58,7 +58,7 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing // // Console.WriteLine("Diff {0} - {1} dif {2}",desiredContainerRectangle,r1,desiredContainerRectangle.Height - r1.Height); } - Console.WriteLine("\tContainer : {0} - DesiredContainerRectangle {1} ",container.Size,desiredContainerRectangle.Size); +// Console.WriteLine("\tContainer : {0} - DesiredContainerRectangle {1} ",container.Size,desiredContainerRectangle.Size); return desiredContainerRectangle; } @@ -72,8 +72,8 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing throw new ArgumentNullException("section"); } - Console.WriteLine("\tlayouter for section <{0}>",section.Name); - +// Console.WriteLine("\tLayouter for Container");Console.WriteLine("\tlayouter for section <{0}>",section.Name); + Console.WriteLine("\tLayouter for Section"); IEnumerable canGrowShrinkCollection = from bt in section.Items where bt.CanGrow == true select bt; Rectangle desiredSectionRectangle = new Rectangle(section.Location.X, @@ -93,7 +93,7 @@ namespace ICSharpCode.Reports.Core.BaseClasses.Printing surroundingRec.Size.Height); } } - Console.WriteLine("\tSection : {0} - DesiredContainerRectangle {1} ",section.Size,desiredSectionRectangle.Size); +// Console.WriteLine("\tSection : {0} - DesiredContainerRectangle {1} ",section.Size,desiredSectionRectangle.Size); return desiredSectionRectangle; } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs index 6ea374ca63..5e6612ea83 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs @@ -247,10 +247,19 @@ namespace ICSharpCode.Reports.Core.Exporter } + protected void PrepareContainerForConverting(BaseSection section,ISimpleContainer simpleContainer) + { + Console.WriteLine("\tPrepareContainerForConverting"); + FireSectionRendering(section); + LayoutRow(simpleContainer); + } + + protected Point ConvertStandardRow(ExporterCollection mylist, BaseSection section, ISimpleContainer simpleContainer) { + Console.WriteLine("\tConvertStandardRow"); var rowSize = simpleContainer.Size; - PrepareContainerForConverting(section,simpleContainer); +// PrepareContainerForConverting(section,simpleContainer); Point curPos = ConvertContainer(mylist,simpleContainer,DefaultLeftPosition,CurrentPosition); AfterConverting (mylist); simpleContainer.Size = rowSize; @@ -258,13 +267,6 @@ namespace ICSharpCode.Reports.Core.Exporter } - protected void PrepareContainerForConverting(BaseSection section,ISimpleContainer simpleContainer) - { - FireSectionRendering(section); - LayoutRow(simpleContainer); - } - - protected void AfterConverting (ExporterCollection convertedList) { StandardPrinter.EvaluateRow(Evaluator,convertedList); diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs index 7de663af78..e352c48ed7 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs @@ -123,9 +123,10 @@ namespace ICSharpCode.Reports.Core.Exporter Console.WriteLine(""); Size containerSize = section.Items[0].Size; base.FillRow(simpleContainer); - + base.PrepareContainerForConverting(section,simpleContainer); + FireRowRendering(simpleContainer,base.DataNavigator); base.CurrentPosition = ConvertStandardRow (exporterCollection,section,simpleContainer); - base.FireRowRendering(simpleContainer,base.DataNavigator); +// base.FireRowRendering(simpleContainer,base.DataNavigator); section.Size = base.RestoreSectionSize; section.Items[0].Size = containerSize; Console.WriteLine(""); diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs index e59fab02fa..a870deaa88 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs @@ -138,8 +138,10 @@ namespace ICSharpCode.Reports.Core.Exporter PrintHelper.AdjustSectionLocation(section); CheckForPageBreak(section,simpleContainer,headerRow,exporterCollection); FillRow(simpleContainer); - base.CurrentPosition = ConvertStandardRow (exporterCollection,section,simpleContainer); + base.PrepareContainerForConverting(section,simpleContainer); FireRowRendering(simpleContainer,base.DataNavigator); + base.CurrentPosition = ConvertStandardRow (exporterCollection,section,simpleContainer); +// FireRowRendering(simpleContainer,base.DataNavigator); simpleContainer.Size = containerSize; section.Size = base.RestoreSectionSize; Console.WriteLine(""); From 12f96be5bff3e5eca55bad7fd6372c297bc0ea37 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 24 Nov 2010 15:54:10 +0100 Subject: [PATCH 04/88] Use ITypeDescriptorContext for call to TypeConverter.CanConvertTo() --- .../WpfDesign.XamlDom/Project/XamlDocument.cs | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs index df9a2b40af..5b62424e57 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs @@ -44,22 +44,24 @@ namespace ICSharpCode.WpfDesign.XamlDom /// type descriptor context needs to resolve an XML namespace. internal ITypeDescriptorContext GetTypeDescriptorContext(XamlObject containingObject) { - return new DummyTypeDescriptorContext(this, containingObject); + IServiceProvider serviceProvider; + if (containingObject != null) { + if (containingObject.OwnerDocument != this) + throw new ArgumentException("Containing object must belong to the document!"); + serviceProvider = containingObject.ServiceProvider; + } else { + serviceProvider = this.ServiceProvider; + } + return new DummyTypeDescriptorContext(serviceProvider); } sealed class DummyTypeDescriptorContext : ITypeDescriptorContext { - IServiceProvider baseServiceProvider; + readonly IServiceProvider baseServiceProvider; - public DummyTypeDescriptorContext(XamlDocument document, XamlObject containingObject) + public DummyTypeDescriptorContext(IServiceProvider serviceProvider) { - if (containingObject != null) { - if (containingObject.OwnerDocument != document) - throw new ArgumentException("Containing object must belong to the document!"); - baseServiceProvider = containingObject.ServiceProvider; - } else { - baseServiceProvider = document.ServiceProvider; - } + this.baseServiceProvider = serviceProvider; } public IContainer Container { @@ -67,7 +69,7 @@ namespace ICSharpCode.WpfDesign.XamlDom } public object Instance { - get { return null; } + get; set; } public PropertyDescriptor PropertyDescriptor { @@ -157,10 +159,11 @@ namespace ICSharpCode.WpfDesign.XamlDom Type elementType = instance.GetType(); TypeConverter c = TypeDescriptor.GetConverter(instance); - bool hasStringConverter = c.CanConvertTo(typeof(string)) && c.CanConvertFrom(typeof(string)); - + var ctx = new DummyTypeDescriptorContext(this.ServiceProvider); + ctx.Instance = instance; + bool hasStringConverter = c.CanConvertTo(ctx, typeof(string)) && c.CanConvertFrom(typeof(string)); if (forProperty != null && hasStringConverter) { - return new XamlTextValue(this, c.ConvertToInvariantString(instance)); + return new XamlTextValue(this, c.ConvertToInvariantString(ctx, instance)); } From 021db4c9fa4632aeae93e94b36d100a63f03337c Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 30 Nov 2010 12:54:57 +0100 Subject: [PATCH 05/88] Use InvariantCulture instead of Ordinal in CompletionList filtering. --- .../CodeCompletion/CompletionList.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs index e4089e66f6..95ecfc5df6 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs @@ -326,31 +326,31 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion // -1 = no match if (query == itemText) return 8; - if (string.Equals(itemText, query, StringComparison.OrdinalIgnoreCase)) + if (string.Equals(itemText, query, StringComparison.InvariantCultureIgnoreCase)) return 7; - if (itemText.StartsWith(query, StringComparison.Ordinal)) + if (itemText.StartsWith(query, StringComparison.InvariantCulture)) return 6; - if (itemText.StartsWith(query, StringComparison.OrdinalIgnoreCase)) + if (itemText.StartsWith(query, StringComparison.InvariantCultureIgnoreCase)) return 5; bool? camelCaseMatch = null; if (query.Length <= 2) { camelCaseMatch = CamelCaseMatch(itemText, query); - if (camelCaseMatch.GetValueOrDefault(false)) return 4; + if (camelCaseMatch == true) return 4; } // search by substring, if filtering (i.e. new behavior) turned on if (IsFiltering) { - if (itemText.Contains(query)) + if (itemText.IndexOf(query, StringComparison.InvariantCulture) >= ) return 3; - if (itemText.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0) + if (itemText.IndexOf(query, StringComparison.InvariantCultureIgnoreCase) >= 0) return 2; } if (!camelCaseMatch.HasValue) camelCaseMatch = CamelCaseMatch(itemText, query); - if (camelCaseMatch.GetValueOrDefault(false)) + if (camelCaseMatch == true) return 1; return -1; From 2f53cc69dac37c9f9ca117a1b4b16fa979a37983 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 30 Nov 2010 13:32:58 +0100 Subject: [PATCH 06/88] Fix build. --- .../ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs index 95ecfc5df6..d9fe15041b 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs @@ -342,7 +342,7 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion // search by substring, if filtering (i.e. new behavior) turned on if (IsFiltering) { - if (itemText.IndexOf(query, StringComparison.InvariantCulture) >= ) + if (itemText.IndexOf(query, StringComparison.InvariantCulture) >= 0) return 3; if (itemText.IndexOf(query, StringComparison.InvariantCultureIgnoreCase) >= 0) return 2; From 996193282c1a871122ee0e401565575a44322f85 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Tue, 30 Nov 2010 19:44:13 +0000 Subject: [PATCH 07/88] Fix null reference when completion window closed and completion list selection changed event fired afterwards. --- .../CodeCompletion/CompletionWindow.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs index 351c026e51..95b113d516 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs @@ -48,8 +48,6 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion toolTip.Placement = PlacementMode.Right; toolTip.Closed += toolTip_Closed; - completionList.InsertionRequested += completionList_InsertionRequested; - completionList.SelectionChanged += completionList_SelectionChanged; AttachEvents(); } @@ -98,6 +96,8 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion void AttachEvents() { + this.completionList.InsertionRequested += completionList_InsertionRequested; + this.completionList.SelectionChanged += completionList_SelectionChanged; this.TextArea.Caret.PositionChanged += CaretPositionChanged; this.TextArea.MouseWheel += textArea_MouseWheel; this.TextArea.PreviewTextInput += textArea_PreviewTextInput; @@ -106,6 +106,8 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion /// protected override void DetachEvents() { + this.completionList.InsertionRequested -= completionList_InsertionRequested; + this.completionList.SelectionChanged -= completionList_SelectionChanged; this.TextArea.Caret.PositionChanged -= CaretPositionChanged; this.TextArea.MouseWheel -= textArea_MouseWheel; this.TextArea.PreviewTextInput -= textArea_PreviewTextInput; From 765270af19d6cf80acc855571a5983aeb2e42c47 Mon Sep 17 00:00:00 2001 From: peterforstmeier Date: Wed, 1 Dec 2010 20:20:05 +0100 Subject: [PATCH 08/88] RowRenderEvent fire on correct position --- .../Exporter/Converters/BaseConverter.cs | 22 ++++-------- .../Converters/GroupedRowConverter.cs | 20 ++++++----- .../Converters/GroupedTableConverter.cs | 36 +++++++++++++------ 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs index 5e6612ea83..6c09bd0dad 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs @@ -136,27 +136,18 @@ namespace ICSharpCode.Reports.Core.Exporter #region Grouping - protected void ConvertGroupFooter (BaseSection section,ISimpleContainer container,ExporterCollection exporterCollection) + protected void ConvertGroupFooter (ISimpleContainer container,ExporterCollection exporterCollection) { var footers = BaseConverter.FindGroupFooter(container); if (footers.Count > 0) { Size rowSize = footers[0].Size; - CurrentPosition = ConvertStandardRow(exporterCollection,section,(ISimpleContainer)footers[0]); + CurrentPosition = ConvertStandardRow(exporterCollection,(ISimpleContainer)footers[0]); FireGroupFooterRendering(footers[0]); footers[0].Size = rowSize; } } - protected Point ConvertGroupChilds(ExporterCollection mylist, BaseSection section, - ISimpleContainer simpleContainer) - { - PrepareContainerForConverting(section,simpleContainer); - Point curPos = ConvertContainer(mylist,simpleContainer,DefaultLeftPosition,CurrentPosition); - AfterConverting (mylist); - return curPos; - } - protected void PageBreakAfterGroupChange(BaseSection section,ExporterCollection exporterCollection) { @@ -255,11 +246,11 @@ namespace ICSharpCode.Reports.Core.Exporter } - protected Point ConvertStandardRow(ExporterCollection mylist, BaseSection section, ISimpleContainer simpleContainer) + protected Point ConvertStandardRow(ExporterCollection mylist, ISimpleContainer simpleContainer) { Console.WriteLine("\tConvertStandardRow"); var rowSize = simpleContainer.Size; -// PrepareContainerForConverting(section,simpleContainer); + Point curPos = ConvertContainer(mylist,simpleContainer,DefaultLeftPosition,CurrentPosition); AfterConverting (mylist); simpleContainer.Size = rowSize; @@ -281,10 +272,11 @@ namespace ICSharpCode.Reports.Core.Exporter } - protected void FillRow (ISimpleContainer row) + protected static void FillRow (ISimpleContainer row,IDataNavigator currentNavigator) { Console.WriteLine("\tFillRow"); - DataNavigator.Fill(row.Items); + //DataNavigator.Fill(row.Items); + currentNavigator.Fill(row.Items); } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs index e352c48ed7..ccd61c3cb5 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs @@ -100,17 +100,18 @@ namespace ICSharpCode.Reports.Core.Exporter section.Size = base.RestoreSectionSize; section.Items[0].Size = groupSize; section.Items[1].Size = childSize; - Console.WriteLine("\tFillRow"); - childNavigator.Fill(simpleContainer.Items); - base.CurrentPosition = ConvertGroupChilds (exporterCollection,section,simpleContainer); + + FillRow(simpleContainer,childNavigator); + PrepareContainerForConverting(section,simpleContainer); + FireRowRendering(simpleContainer,childNavigator); + base.CurrentPosition = ConvertStandardRow(exporterCollection,simpleContainer); CheckForPageBreak(section,exporterCollection); - Console.WriteLine(""); } while ( childNavigator.MoveNext()); // GroupFooter - base.ConvertGroupFooter(section,section,exporterCollection); + base.ConvertGroupFooter(section,exporterCollection); base.PageBreakAfterGroupChange(section,exporterCollection); @@ -122,10 +123,10 @@ namespace ICSharpCode.Reports.Core.Exporter // No Grouping at all, the first item in section.items is the DetailRow Console.WriteLine(""); Size containerSize = section.Items[0].Size; - base.FillRow(simpleContainer); + FillRow(simpleContainer,base.DataNavigator); base.PrepareContainerForConverting(section,simpleContainer); FireRowRendering(simpleContainer,base.DataNavigator); - base.CurrentPosition = ConvertStandardRow (exporterCollection,section,simpleContainer); + base.CurrentPosition = ConvertStandardRow (exporterCollection,simpleContainer); // base.FireRowRendering(simpleContainer,base.DataNavigator); section.Size = base.RestoreSectionSize; section.Items[0].Size = containerSize; @@ -186,10 +187,11 @@ namespace ICSharpCode.Reports.Core.Exporter AfterConverting (list); retVal = new Point (DefaultLeftPosition,offset.Y + groupCollection[0].Size.Height + 20 + (3 *GlobalValues.GapBetweenContainer)); } else { - FillRow(groupedRows[0]); + FillRow(groupedRows[0],base.DataNavigator); rowSize = groupedRows[0].Size; - retVal = ConvertStandardRow(exportList,section,groupedRows[0]); base.FireGroupHeaderRendering(groupedRows[0]); + retVal = ConvertStandardRow(exportList,groupedRows[0]); + groupedRows[0].Size = rowSize; } return retVal; diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs index a870deaa88..eeef12d1f1 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs @@ -95,7 +95,16 @@ namespace ICSharpCode.Reports.Core.Exporter childNavigator.Reset(); childNavigator.MoveNext(); - + +/* + FillRow + PrepareContainerForConverting + Layouter for Container + FireRowRendering +eportViewer - RowRendering : + ConvertStandardRow + + */ //Convert children if (childNavigator != null) { do @@ -104,10 +113,12 @@ namespace ICSharpCode.Reports.Core.Exporter simpleContainer = table.Items[2] as ISimpleContainer; containerSize = simpleContainer.Size; - childNavigator.Fill(simpleContainer.Items); - - base.CurrentPosition = ConvertGroupChilds (exporterCollection,section,simpleContainer); - + FillRow(simpleContainer,childNavigator); + PrepareContainerForConverting(section,simpleContainer); + FireRowRendering(simpleContainer,childNavigator); + + base.CurrentPosition = ConvertStandardRow(exporterCollection,simpleContainer); + simpleContainer.Size = containerSize; CheckForPageBreak(section,simpleContainer,headerRow,exporterCollection); @@ -115,7 +126,7 @@ namespace ICSharpCode.Reports.Core.Exporter while ( childNavigator.MoveNext()); // GroupFooter - base.ConvertGroupFooter(section,table,exporterCollection); + base.ConvertGroupFooter(table,exporterCollection); base.PageBreakAfterGroupChange(section,exporterCollection); base.Evaluator.SinglePage.IDataNavigator = base.DataNavigator; @@ -137,11 +148,12 @@ namespace ICSharpCode.Reports.Core.Exporter Console.WriteLine(""); PrintHelper.AdjustSectionLocation(section); CheckForPageBreak(section,simpleContainer,headerRow,exporterCollection); - FillRow(simpleContainer); + + FillRow(simpleContainer,base.DataNavigator); base.PrepareContainerForConverting(section,simpleContainer); + FireRowRendering(simpleContainer,base.DataNavigator); - base.CurrentPosition = ConvertStandardRow (exporterCollection,section,simpleContainer); -// FireRowRendering(simpleContainer,base.DataNavigator); + base.CurrentPosition = ConvertStandardRow (exporterCollection,simpleContainer); simpleContainer.Size = containerSize; section.Size = base.RestoreSectionSize; Console.WriteLine(""); @@ -170,7 +182,7 @@ namespace ICSharpCode.Reports.Core.Exporter { base.CurrentPosition = ForcePageBreak(exporterCollection,section); - base.CurrentPosition = ConvertStandardRow (exporterCollection,section,headerRow); + base.CurrentPosition = ConvertStandardRow (exporterCollection,headerRow); } } @@ -210,9 +222,11 @@ namespace ICSharpCode.Reports.Core.Exporter } else { + rowSize = groupedRow[0].Size; + FillRow(groupedRow[0],base.DataNavigator); base.FireGroupHeaderRendering(groupedRow[0]); - retVal = ConvertStandardRow(exportList,section,groupedRow[0]); + retVal = ConvertStandardRow(exportList,groupedRow[0]); groupedRow[0].Size = rowSize; } return retVal; From f08cb9ad1eb8a1b5ba356bcf796a46c08a4d5057 Mon Sep 17 00:00:00 2001 From: peterforstmeier Date: Thu, 2 Dec 2010 20:06:02 +0100 Subject: [PATCH 09/88] Samples are running again --- samples/SharpDevelopReports/src/ReportSamples.sln | 12 +++++++++++- .../src/SharpReportSamples/MainForm.cs | 2 +- .../src/SharpReportSamples/SharpReportSamples.csproj | 10 ++++++++-- .../Project/Exporter/Converters/BaseConverter.cs | 10 +++------- .../Exporter/Converters/GroupedRowConverter.cs | 5 +---- .../Exporter/Converters/GroupedTableConverter.cs | 8 ++------ 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/samples/SharpDevelopReports/src/ReportSamples.sln b/samples/SharpDevelopReports/src/ReportSamples.sln index 2258aa18e8..17ea8cced5 100644 --- a/samples/SharpDevelopReports/src/ReportSamples.sln +++ b/samples/SharpDevelopReports/src/ReportSamples.sln @@ -1,9 +1,11 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.0.0.5930 +# SharpDevelop 4.1.0.7014 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReportSamples", "SharpReportSamples\SharpReportSamples.csproj", "{BB5D34DA-3561-48B1-894A-46765C2A18C1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reports.Core", "..\..\..\src\AddIns\Misc\Reports\ICSharpCode.Reports.Core\ICSharpCode.Reports.Core.csproj", "{4B2239FF-8FD6-431D-9D22-1B8049BA6917}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -20,6 +22,14 @@ Global {BB5D34DA-3561-48B1-894A-46765C2A18C1}.Debug|x86.ActiveCfg = Debug|x86 {BB5D34DA-3561-48B1-894A-46765C2A18C1}.Release|x86.Build.0 = Release|x86 {BB5D34DA-3561-48B1-894A-46765C2A18C1}.Release|x86.ActiveCfg = Release|x86 + {4B2239FF-8FD6-431D-9D22-1B8049BA6917}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B2239FF-8FD6-431D-9D22-1B8049BA6917}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B2239FF-8FD6-431D-9D22-1B8049BA6917}.Debug|x86.Build.0 = Debug|Any CPU + {4B2239FF-8FD6-431D-9D22-1B8049BA6917}.Debug|x86.ActiveCfg = Debug|Any CPU + {4B2239FF-8FD6-431D-9D22-1B8049BA6917}.Release|Any CPU.Build.0 = Release|Any CPU + {4B2239FF-8FD6-431D-9D22-1B8049BA6917}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B2239FF-8FD6-431D-9D22-1B8049BA6917}.Release|x86.Build.0 = Release|Any CPU + {4B2239FF-8FD6-431D-9D22-1B8049BA6917}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs b/samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs index 87f5144785..db9e6f6f23 100644 --- a/samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs +++ b/samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs @@ -291,7 +291,7 @@ namespace SharpReportSamples ReportModel model = ReportEngine.LoadReportModel(fileName); IDataManager dataManager = DataManager.CreateInstance(eLog.EventLog,model.ReportSettings); - this.previewControl1.SectionRendering += PushPrinting; +// this.previewControl1.SectionRendering += PushPrinting; this.previewControl1.PreviewLayoutChanged += delegate (object sender, EventArgs e) diff --git a/samples/SharpDevelopReports/src/SharpReportSamples/SharpReportSamples.csproj b/samples/SharpDevelopReports/src/SharpReportSamples/SharpReportSamples.csproj index f0b3fa7ebb..e09f5b2627 100644 --- a/samples/SharpDevelopReports/src/SharpReportSamples/SharpReportSamples.csproj +++ b/samples/SharpDevelopReports/src/SharpReportSamples/SharpReportSamples.csproj @@ -32,8 +32,8 @@ - - ..\..\..\..\AddIns\AddIns\Misc\SharpDevelopReports\ICSharpCode.Reports.Core.dll + + ..\..\..\..\src\AddIns\Misc\Reports\Irony\obj\Debug\Irony.dll @@ -71,4 +71,10 @@ + + + {4B2239FF-8FD6-431D-9D22-1B8049BA6917} + ICSharpCode.Reports.Core + + \ No newline at end of file diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs index 6c09bd0dad..dade10f1b9 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs @@ -78,7 +78,7 @@ namespace ICSharpCode.Reports.Core.Exporter if (row == null) { throw new ArgumentException("row"); } - Console.WriteLine("\tFireRowRendering"); +// Console.WriteLine("\tFireRowRendering"); RowRenderEventArgs rrea = new RowRenderEventArgs(row,currentNavigator.Current); EventHelper.Raise(RowRendering,this,rrea); } @@ -86,7 +86,7 @@ namespace ICSharpCode.Reports.Core.Exporter protected void FireGroupHeaderRendering (GroupHeader groupHeader) { - Console.WriteLine("\tFireGroupHeaderRendering"); +// Console.WriteLine("\tFireGroupHeaderRendering"); GroupHeaderEventArgs ghea = new GroupHeaderEventArgs(groupHeader); EventHelper.Raise(GroupHeaderRendering,this,ghea); } @@ -94,7 +94,7 @@ namespace ICSharpCode.Reports.Core.Exporter protected void FireGroupFooterRendering (GroupFooter groupFooter) { - Console.WriteLine("\tFireGroupFooterRendering"); +// Console.WriteLine("\tFireGroupFooterRendering"); GroupFooterEventArgs gfea = new GroupFooterEventArgs(groupFooter); EventHelper.Raise(GroupFooterRendering,this,gfea); } @@ -240,7 +240,6 @@ namespace ICSharpCode.Reports.Core.Exporter protected void PrepareContainerForConverting(BaseSection section,ISimpleContainer simpleContainer) { - Console.WriteLine("\tPrepareContainerForConverting"); FireSectionRendering(section); LayoutRow(simpleContainer); } @@ -248,7 +247,6 @@ namespace ICSharpCode.Reports.Core.Exporter protected Point ConvertStandardRow(ExporterCollection mylist, ISimpleContainer simpleContainer) { - Console.WriteLine("\tConvertStandardRow"); var rowSize = simpleContainer.Size; Point curPos = ConvertContainer(mylist,simpleContainer,DefaultLeftPosition,CurrentPosition); @@ -274,8 +272,6 @@ namespace ICSharpCode.Reports.Core.Exporter protected static void FillRow (ISimpleContainer row,IDataNavigator currentNavigator) { - Console.WriteLine("\tFillRow"); - //DataNavigator.Fill(row.Items); currentNavigator.Fill(row.Items); } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs index ccd61c3cb5..f65176c1c6 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs @@ -96,7 +96,6 @@ namespace ICSharpCode.Reports.Core.Exporter StandardPrinter.AdjustBackColor(simpleContainer,GlobalValues.DefaultBackColor); do { - Console.WriteLine(""); section.Size = base.RestoreSectionSize; section.Items[0].Size = groupSize; section.Items[1].Size = childSize; @@ -121,16 +120,14 @@ namespace ICSharpCode.Reports.Core.Exporter else { // No Grouping at all, the first item in section.items is the DetailRow - Console.WriteLine(""); + Size containerSize = section.Items[0].Size; FillRow(simpleContainer,base.DataNavigator); base.PrepareContainerForConverting(section,simpleContainer); FireRowRendering(simpleContainer,base.DataNavigator); base.CurrentPosition = ConvertStandardRow (exporterCollection,simpleContainer); -// base.FireRowRendering(simpleContainer,base.DataNavigator); section.Size = base.RestoreSectionSize; section.Items[0].Size = containerSize; - Console.WriteLine(""); } CheckForPageBreak (section,exporterCollection); ShouldDrawBorder (section,exporterCollection); diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs index eeef12d1f1..85780a00dd 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs @@ -38,7 +38,7 @@ namespace ICSharpCode.Reports.Core.Exporter ExporterCollection mylist = base.Convert(parent,item); this.table = (BaseTableItem)item ; this.table.Parent = parent; - this.table.DataNavigator = base.DataNavigator; +// this.table.DataNavigator = base.DataNavigator; return ConvertInternal(mylist); } @@ -142,10 +142,9 @@ eportViewer - RowRendering : simpleContainer = table.Items[1] as ISimpleContainer; base.SaveSectionSize(section.Size); containerSize = simpleContainer.Size; - Console.WriteLine("datasection - NO grouping"); + do { - Console.WriteLine(""); PrintHelper.AdjustSectionLocation(section); CheckForPageBreak(section,simpleContainer,headerRow,exporterCollection); @@ -156,11 +155,8 @@ eportViewer - RowRendering : base.CurrentPosition = ConvertStandardRow (exporterCollection,simpleContainer); simpleContainer.Size = containerSize; section.Size = base.RestoreSectionSize; - Console.WriteLine(""); } while (base.DataNavigator.MoveNext()); - Console.WriteLine(""); - Console.WriteLine("END of datasection - NO grouping"); base.DataNavigator.Reset(); base.DataNavigator.MoveNext(); SectionBounds.ReportFooterRectangle = new Rectangle(SectionBounds.ReportFooterRectangle.Left, From a5ac7aa860ff72a5e5bfd67ae1f0c606302af78e Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 2 Dec 2010 22:25:32 +0100 Subject: [PATCH 10/88] fixed SD-1778 - No Xaml completion for TextBlock FontFamily --- .../XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs index a0223bc88f..02855f0047 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs @@ -220,9 +220,9 @@ namespace ICSharpCode.XamlBinding start = ""; completionList.PreselectionLength = start.Length; } else if (mrr.ResolvedType.FullyQualifiedName == "System.Windows.Media.FontFamily") { - string text = context.ValueStartOffset > -1 ? context.RawAttributeValue.Substring(0, Math.Min(context.ValueStartOffset + 1, context.RawAttributeValue.Length)) : ""; + string text = context.ValueStartOffset > -1 ? context.RawAttributeValue.Substring(0, Math.Min(context.ValueStartOffset, context.RawAttributeValue.Length)) : ""; int lastComma = text.LastIndexOf(','); - completionList.PreselectionLength = lastComma == -1 ? context.ValueStartOffset + 1 : context.ValueStartOffset - lastComma; + completionList.PreselectionLength = lastComma == -1 ? context.ValueStartOffset : context.ValueStartOffset - lastComma - 1; } } } From 890ecbb23cb4a261510818493d656d4ad24f3b96 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 3 Dec 2010 20:08:22 +0100 Subject: [PATCH 11/88] AvalonEdit: calculate WideSpaceWidth instead of simply using FontSize/2. --- .../Rendering/TextView.cs | 54 ++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs index e91c7e8c40..6be172d646 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs @@ -109,8 +109,8 @@ namespace ICSharpCode.AvalonEdit.Rendering ClearVisualLines(); if (newValue != null) { TextDocumentWeakEventManager.Changing.AddListener(newValue, this); - heightTree = new HeightTree(newValue, FontSize + 3); formatter = TextFormatterFactory.Create(this); + heightTree = new HeightTree(newValue, DefaultLineHeight); // measuring DefaultLineHeight depends on formatter cachedElements = new TextViewCachedElements(); } InvalidateMeasure(DispatcherPriority.Normal); @@ -1115,12 +1115,12 @@ namespace ICSharpCode.AvalonEdit.Rendering void IScrollInfo.LineUp() { - ((IScrollInfo)this).SetVerticalOffset(scrollOffset.Y - FontSize); + ((IScrollInfo)this).SetVerticalOffset(scrollOffset.Y - DefaultLineHeight); } void IScrollInfo.LineDown() { - ((IScrollInfo)this).SetVerticalOffset(scrollOffset.Y + FontSize); + ((IScrollInfo)this).SetVerticalOffset(scrollOffset.Y + DefaultLineHeight); } void IScrollInfo.LineLeft() @@ -1156,14 +1156,14 @@ namespace ICSharpCode.AvalonEdit.Rendering void IScrollInfo.MouseWheelUp() { ((IScrollInfo)this).SetVerticalOffset( - scrollOffset.Y - (SystemParameters.WheelScrollLines * FontSize)); + scrollOffset.Y - (SystemParameters.WheelScrollLines * DefaultLineHeight)); OnScrollChange(); } void IScrollInfo.MouseWheelDown() { ((IScrollInfo)this).SetVerticalOffset( - scrollOffset.Y + (SystemParameters.WheelScrollLines * FontSize)); + scrollOffset.Y + (SystemParameters.WheelScrollLines * DefaultLineHeight)); OnScrollChange(); } @@ -1181,12 +1181,52 @@ namespace ICSharpCode.AvalonEdit.Rendering OnScrollChange(); } + double wideSpaceWidth; // Width of an 'x'. Used as basis for the tab width, and for scrolling. + double defaultLineHeight; // Height of a line containing 'x'. Used for scrolling. + double WideSpaceWidth { get { - return FontSize / 2; + if (wideSpaceWidth == 0) { + MeasureWideSpaceWidthAndDefaultLineHeight(); + } + return wideSpaceWidth; } } + double DefaultLineHeight { + get { + if (defaultLineHeight == 0) { + MeasureWideSpaceWidthAndDefaultLineHeight(); + } + return defaultLineHeight; + } + } + + void MeasureWideSpaceWidthAndDefaultLineHeight() + { + if (formatter != null) { + var textRunProperties = CreateGlobalTextRunProperties(); + using (var line = formatter.FormatLine( + new SimpleTextSource("x", textRunProperties), + 0, 32000, + new VisualLineTextParagraphProperties { defaultTextRunProperties = textRunProperties }, + null)) + { + wideSpaceWidth = Math.Max(1, line.WidthIncludingTrailingWhitespace); + defaultLineHeight = line.Height; + } + } else { + wideSpaceWidth = FontSize / 2; + defaultLineHeight = FontSize + 3; + } + } + + void InvalidateWideSpaceWidthAndDefaultLineHeight() + { + wideSpaceWidth = 0; + defaultLineHeight = 0; + } + static double ValidateVisualOffset(double offset) { if (double.IsNaN(offset)) @@ -1613,6 +1653,7 @@ namespace ICSharpCode.AvalonEdit.Rendering if (TextFormatterFactory.PropertyChangeAffectsTextFormatter(e.Property)) { RecreateCachedElements(); RecreateTextFormatter(); + InvalidateWideSpaceWidthAndDefaultLineHeight(); } if (e.Property == Control.ForegroundProperty || e.Property == Control.FontFamilyProperty @@ -1622,6 +1663,7 @@ namespace ICSharpCode.AvalonEdit.Rendering || e.Property == Control.FontWeightProperty) { RecreateCachedElements(); + InvalidateWideSpaceWidthAndDefaultLineHeight(); Redraw(); } } From 7547363c981f61cf598a9b174dbe8d2797b34973 Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Sat, 4 Dec 2010 02:08:13 +0200 Subject: [PATCH 12/88] Fix SD-1779 - Attach to process form does not show .NET 2.0 processes --- .../Debugger.AddIn/Service/AttachToProcessForm.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/AttachToProcessForm.cs b/src/AddIns/Debugger/Debugger.AddIn/Service/AttachToProcessForm.cs index 964f35eb3d..e3507a5ec8 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Service/AttachToProcessForm.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Service/AttachToProcessForm.cs @@ -5,7 +5,9 @@ using System; using System.ComponentModel; using System.Diagnostics; using System.IO; +using System.Linq; using System.Windows.Forms; + using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Gui; @@ -23,7 +25,10 @@ namespace ICSharpCode.SharpDevelop.Services { this.process = process; try { - managed = debugger.IsManaged(process.Id); + var modules = process.Modules.Cast().Where( + m => m.ModuleName.StartsWith("mscor", StringComparison.InvariantCultureIgnoreCase)); + + managed = modules.Count() > 0; } catch { } string fileName = Path.GetFileName(process.MainModule.FileName); @@ -54,7 +59,7 @@ namespace ICSharpCode.SharpDevelop.Services { listView.Items.Clear(); WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger; - Process currentProcess = Process.GetCurrentProcess(); + Process currentProcess = Process.GetCurrentProcess(); foreach (Process process in Process.GetProcesses()) { try { if (process.HasExited) continue; @@ -69,8 +74,8 @@ namespace ICSharpCode.SharpDevelop.Services } catch (Win32Exception) { // Do nothing. } - } + } listView.Sort(); - } + } } } From 73b5a6660a09880d6dc4d0a327653e7b4963ba58 Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Sat, 4 Dec 2010 03:03:01 +0200 Subject: [PATCH 13/88] Fix SD-1782 - Interaction between bookmarks and breakpoints --- src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs | 6 ++++-- .../Base/Project/Src/Bookmarks/Commands/MenuCommands.cs | 3 ++- .../Base/Project/Src/Services/Debugger/DebuggerService.cs | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs b/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs index 9f5321d68c..074dfcdcc5 100644 --- a/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs +++ b/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs @@ -107,10 +107,12 @@ namespace ICSharpCode.SharpDevelop.Bookmarks public static void ToggleBookmark(ITextEditor editor, int line, Predicate canToggle, - Func bookmarkFactory) + Func bookmarkFactory, + Type bookmarkType) { foreach (SDBookmark bookmark in GetBookmarks(new FileName(editor.FileName))) { - if (canToggle(bookmark) && bookmark.LineNumber == line) { + if (canToggle(bookmark) && bookmark.LineNumber == line && + bookmark.GetType().UnderlyingSystemType == bookmarkType) { BookmarkManager.RemoveMark(bookmark); return; } diff --git a/src/Main/Base/Project/Src/Bookmarks/Commands/MenuCommands.cs b/src/Main/Base/Project/Src/Bookmarks/Commands/MenuCommands.cs index 5569f0d7bd..0030e2ff88 100644 --- a/src/Main/Base/Project/Src/Bookmarks/Commands/MenuCommands.cs +++ b/src/Main/Base/Project/Src/Bookmarks/Commands/MenuCommands.cs @@ -42,7 +42,8 @@ namespace ICSharpCode.SharpDevelop.Bookmarks { BookmarkManager.ToggleBookmark(editor, editor.Caret.Line, b => b.CanToggle, - location => new SDBookmark(editor.FileName, location)); + location => new SDBookmark(editor.FileName, location), + typeof(SDBookmark)); } } diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 168c3f751c..e67ebec0a3 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -227,7 +227,8 @@ namespace ICSharpCode.SharpDevelop.Debugging BookmarkManager.ToggleBookmark( editor, lineNumber, b => b.CanToggle && b is BreakpointBookmark, - location => new BreakpointBookmark(editor.FileName, location, BreakpointAction.Break, "", "")); + location => new BreakpointBookmark(editor.FileName, location, BreakpointAction.Break, "", ""), + typeof(BreakpointBookmark)); } /* TODO: reimplement this stuff From daf172e700ecce1b4a8d4d3897dfe6110333083f Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Sat, 4 Dec 2010 14:32:27 +0200 Subject: [PATCH 14/88] Fix SD-1782 - Interaction between bookmarks and breakpoints (with Daniel's suggestion) --- src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs | 6 ++---- .../Base/Project/Src/Bookmarks/Commands/MenuCommands.cs | 8 +++----- .../Base/Project/Src/Services/Debugger/DebuggerService.cs | 3 +-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs b/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs index 074dfcdcc5..9f5321d68c 100644 --- a/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs +++ b/src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs @@ -107,12 +107,10 @@ namespace ICSharpCode.SharpDevelop.Bookmarks public static void ToggleBookmark(ITextEditor editor, int line, Predicate canToggle, - Func bookmarkFactory, - Type bookmarkType) + Func bookmarkFactory) { foreach (SDBookmark bookmark in GetBookmarks(new FileName(editor.FileName))) { - if (canToggle(bookmark) && bookmark.LineNumber == line && - bookmark.GetType().UnderlyingSystemType == bookmarkType) { + if (canToggle(bookmark) && bookmark.LineNumber == line) { BookmarkManager.RemoveMark(bookmark); return; } diff --git a/src/Main/Base/Project/Src/Bookmarks/Commands/MenuCommands.cs b/src/Main/Base/Project/Src/Bookmarks/Commands/MenuCommands.cs index 0030e2ff88..963a65cd59 100644 --- a/src/Main/Base/Project/Src/Bookmarks/Commands/MenuCommands.cs +++ b/src/Main/Base/Project/Src/Bookmarks/Commands/MenuCommands.cs @@ -41,13 +41,11 @@ namespace ICSharpCode.SharpDevelop.Bookmarks protected override void Run(ITextEditor editor, IBookmarkMargin bookmarkMargin) { BookmarkManager.ToggleBookmark(editor, editor.Caret.Line, - b => b.CanToggle, - location => new SDBookmark(editor.FileName, location), - typeof(SDBookmark)); + b => b.CanToggle && b.GetType() == typeof(SDBookmark), + location => new SDBookmark(editor.FileName, location)); } } - - public class PrevBookmark : BookmarkMenuCommand + public class PrevBookmark : BookmarkMenuCommand { protected override void Run(ITextEditor editor, IBookmarkMargin bookmarkMargin) { diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index e67ebec0a3..168c3f751c 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -227,8 +227,7 @@ namespace ICSharpCode.SharpDevelop.Debugging BookmarkManager.ToggleBookmark( editor, lineNumber, b => b.CanToggle && b is BreakpointBookmark, - location => new BreakpointBookmark(editor.FileName, location, BreakpointAction.Break, "", ""), - typeof(BreakpointBookmark)); + location => new BreakpointBookmark(editor.FileName, location, BreakpointAction.Break, "", "")); } /* TODO: reimplement this stuff From 5205d52d1f1cf00a7a69e95f7b6818a33c5123a0 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 3 Dec 2010 20:59:01 +0100 Subject: [PATCH 15/88] Add setter to TextDocument.UndoStack. --- .../ICSharpCode.AvalonEdit/Document/TextDocument.cs | 12 +++++++++++- .../AvalonEdit/ICSharpCode.AvalonEdit/Utils/Deque.cs | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs index 00e2c0c25e..e2db61ef12 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs @@ -722,13 +722,23 @@ namespace ICSharpCode.AvalonEdit.Document } } - readonly UndoStack undoStack; + UndoStack undoStack; /// /// Gets the of the document. /// + /// This property can also be used to set the undo stack, e.g. for sharing a common undo stack between multiple documents. public UndoStack UndoStack { get { return undoStack; } + set { + if (value == null) + throw new ArgumentNullException(); + if (value != undoStack) { + undoStack.ClearAll(); // first clear old undo stack, so that it can't be used to perform unexpected changes on this document + // ClearAll() will also throw an exception when it's not safe to replace the undo stack (e.g. update is currently in progress) + undoStack = value; + } + } } /// diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Deque.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Deque.cs index 2bb3c31424..373b5f5f70 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Deque.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Deque.cs @@ -12,7 +12,7 @@ namespace ICSharpCode.AvalonEdit.Utils /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] [Serializable] - public class Deque : ICollection + public sealed class Deque : ICollection { T[] arr = Empty.Array; int size, head, tail; From 3b45327b379484a67d5e9558e64ba2c51e9b4ac4 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 4 Dec 2010 16:00:00 +0100 Subject: [PATCH 16/88] Fix SD-1787 - Memory Leak in ContextActionsBulbPopup --- .../AvalonEdit.AddIn/Src/CodeEditor.cs | 8 +++- .../AvalonEdit.AddIn/Src/CodeEditorView.cs | 7 ++- .../Src/ContextActionsRenderer.cs | 45 ++++++++----------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs index 2146d112ed..57c364d3d6 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs @@ -217,10 +217,11 @@ namespace ICSharpCode.AvalonEdit.AddIn TextCopied(this, e); } - protected virtual void DisposeTextEditor(TextEditor textEditor) + protected virtual void DisposeTextEditor(CodeEditorView textEditor) { // detach IconBarMargin from IconBarManager textEditor.TextArea.LeftMargins.OfType().Single().TextView = null; + textEditor.Dispose(); } void textEditor_GotFocus(object sender, RoutedEventArgs e) @@ -332,9 +333,9 @@ namespace ICSharpCode.AvalonEdit.AddIn // remove secondary editor this.Children.Remove(secondaryTextEditor); this.Children.Remove(gridSplitter); + secondaryTextEditorAdapter.Language.Detach(); DisposeTextEditor(secondaryTextEditor); secondaryTextEditor = null; - secondaryTextEditorAdapter.Language.Detach(); secondaryTextEditorAdapter = null; gridSplitter = null; this.RowDefinitions.RemoveAt(this.RowDefinitions.Count - 1); @@ -574,6 +575,9 @@ namespace ICSharpCode.AvalonEdit.AddIn if (errorPainter != null) errorPainter.Dispose(); this.Document = null; + DisposeTextEditor(primaryTextEditor); + if (secondaryTextEditor != null) + DisposeTextEditor(secondaryTextEditor); } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs index b467774c84..b47eabd56e 100755 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs @@ -34,7 +34,7 @@ namespace ICSharpCode.AvalonEdit.AddIn /// There can be two CodeEditorView instances in a single CodeEditor if split-view /// is enabled. /// - public class CodeEditorView : SharpDevelopTextEditor + public class CodeEditorView : SharpDevelopTextEditor, IDisposable { public ITextEditor Adapter { get; set; } @@ -61,6 +61,11 @@ namespace ICSharpCode.AvalonEdit.AddIn SetupTabSnippetHandler(); } + public virtual void Dispose() + { + contextActionsRenderer.Dispose(); + } + protected override string FileName { get { return this.Adapter.FileName; } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs index a30362582a..6f1f1b2241 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs @@ -18,7 +18,7 @@ namespace ICSharpCode.AvalonEdit.AddIn /// /// Renders Popup with context actions on the left side of the current line in the editor. /// - public class ContextActionsRenderer + public sealed class ContextActionsRenderer : IDisposable { readonly CodeEditorView editorView; ITextEditor Editor { get { return this.editorView.Adapter; } } @@ -36,12 +36,11 @@ namespace ICSharpCode.AvalonEdit.AddIn public bool IsEnabled { get { - try { - string fileName = this.Editor.FileName; - return fileName.EndsWith(".cs") || fileName.EndsWith(".vb"); - } catch { + string fileName = this.Editor.FileName; + if (String.IsNullOrEmpty(fileName)) return false; - } + return fileName.EndsWith(".cs", StringComparison.OrdinalIgnoreCase) + || fileName.EndsWith(".vb", StringComparison.OrdinalIgnoreCase); } } @@ -59,10 +58,16 @@ namespace ICSharpCode.AvalonEdit.AddIn this.delayMoveTimer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(delayMoveMilliseconds) }; this.delayMoveTimer.Stop(); this.delayMoveTimer.Tick += TimerMoveTick; - WorkbenchSingleton.Workbench.ViewClosed += WorkbenchSingleton_Workbench_ViewClosed; WorkbenchSingleton.Workbench.ActiveViewContentChanged += WorkbenchSingleton_Workbench_ActiveViewContentChanged; } - + + public void Dispose() + { + ClosePopup(); + WorkbenchSingleton.Workbench.ActiveViewContentChanged -= WorkbenchSingleton_Workbench_ActiveViewContentChanged; + delayMoveTimer.Stop(); + } + void ContextActionsRenderer_KeyDown(object sender, KeyEventArgs e) { if (this.popup == null) @@ -131,26 +136,14 @@ namespace ICSharpCode.AvalonEdit.AddIn this.popup.IsHiddenActionsExpanded = false; this.popup.ViewModel = null; } - - void WorkbenchSingleton_Workbench_ViewClosed(object sender, ViewContentEventArgs e) - { - try { - // prevent memory leaks - if (e.Content.PrimaryFileName == this.Editor.FileName) { - WorkbenchSingleton.Workbench.ViewClosed -= WorkbenchSingleton_Workbench_ViewClosed; - WorkbenchSingleton.Workbench.ActiveViewContentChanged -= WorkbenchSingleton_Workbench_ActiveViewContentChanged; - } - } catch {} - } - void WorkbenchSingleton_Workbench_ActiveViewContentChanged(object sender, EventArgs e) { - ClosePopup(); - try { - // open the popup again if in current file - if (((IViewContent)WorkbenchSingleton.Workbench.ActiveContent).PrimaryFileName == this.Editor.FileName) - CaretPositionChanged(this, EventArgs.Empty); - } catch {} + // open the popup again if in current file + IViewContent activeViewContent = WorkbenchSingleton.Workbench.ActiveViewContent; + if (activeViewContent != null && activeViewContent.PrimaryFileName == this.Editor.FileName) + CaretPositionChanged(this, EventArgs.Empty); + else // otherwise close popup + ClosePopup(); } } } From 9c333a8e6ca420d6107b2b0dc3c115848e7be8b5 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 4 Dec 2010 18:25:39 +0000 Subject: [PATCH 17/88] Fix SD-1569 - Errors deleting a folder in projects pad cause unhandled exception --- .../Project/Src/Services/File/FileService.cs | 14 +++++----- .../Services/MessageService/MessageService.cs | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/Main/Base/Project/Src/Services/File/FileService.cs b/src/Main/Base/Project/Src/Services/File/FileService.cs index 07b41e60d1..f3f115975f 100644 --- a/src/Main/Base/Project/Src/Services/File/FileService.cs +++ b/src/Main/Base/Project/Src/Services/File/FileService.cs @@ -412,8 +412,7 @@ namespace ICSharpCode.SharpDevelop Directory.Delete(fileName, true); } } catch (Exception e) { - MessageService.ShowException(e, "Can't remove directory " + fileName); -// return; + MessageService.ShowHandledException(e, "Can't remove directory " + fileName); } } else { try { @@ -424,8 +423,7 @@ namespace ICSharpCode.SharpDevelop File.Delete(fileName); } } catch (Exception e) { - MessageService.ShowException(e, "Can't remove file " + fileName); -// return; + MessageService.ShowHandledException(e, "Can't remove file " + fileName); } } } @@ -464,9 +462,9 @@ namespace ICSharpCode.SharpDevelop } } catch (Exception e) { if (isDirectory) { - MessageService.ShowException(e, "Can't rename directory " + oldName); + MessageService.ShowHandledException(e, "Can't rename directory " + oldName); } else { - MessageService.ShowException(e, "Can't rename file " + oldName); + MessageService.ShowHandledException(e, "Can't rename file " + oldName); } return false; } @@ -508,9 +506,9 @@ namespace ICSharpCode.SharpDevelop } } catch (Exception e) { if (isDirectory) { - MessageService.ShowException(e, "Can't copy directory " + oldName); + MessageService.ShowHandledException(e, "Can't copy directory " + oldName); } else { - MessageService.ShowException(e, "Can't copy file " + oldName); + MessageService.ShowHandledException(e, "Can't copy file " + oldName); } return false; } diff --git a/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs b/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs index ca41f38b4f..20777b1058 100644 --- a/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs +++ b/src/Main/Core/Project/Src/Services/MessageService/MessageService.cs @@ -52,6 +52,33 @@ namespace ICSharpCode.Core ServiceManager.Instance.MessageService.ShowException(ex, message); } + /// + /// Shows an exception. + /// + public static void ShowHandledException(Exception ex) + { + ShowHandledException(ex, null); + } + + /// + /// Shows an exception. + /// + public static void ShowHandledException(Exception ex, string message) + { + LoggingService.Error(message, ex); + LoggingService.Warn("Stack trace of last exception log:\n" + Environment.StackTrace); + message = GetMessage(message, ex); + ServiceManager.Instance.MessageService.ShowError(message); + } + + static string GetMessage(string message, Exception ex) + { + if (message == null) { + return ex.Message; + } + return message + "\r\n\r\n" + ex.Message; + } + /// /// Shows a warning message. /// From f7c9cb8c1c3fe6479298ed211ea548d88d8cbc2f Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 4 Dec 2010 16:26:06 +0100 Subject: [PATCH 18/88] working on SD-1592: translated PHP-Mode.xshd to the new format --- .../Highlighting/Resources/PHP-Mode.xshd | 340 ++++++++---------- 1 file changed, 150 insertions(+), 190 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/PHP-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/PHP-Mode.xshd index 39d5fa3ec5..f09ff27d93 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/PHP-Mode.xshd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/PHP-Mode.xshd @@ -1,198 +1,158 @@ - - - - - - - - ~!%^*()-+=|\#/{}[]:;"'<> , .? - - - # - - - - /// - - - - //@!/@ - - - - /* - */ - - - - " - " - - - - @@" - " - - - - ' - ' - - - ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ~!@%^*()-+=|\#/{}[]:;"'<> , .? - - - - + + + + + + + + + + + + + + + + + + + \# + + + + // + + + + /\* + \*/ + - - ~!@%^*()-+=|\#/{}[]:;"'<> , .? - - - < - > - - - - - - + + + \b0[xX][0-9a-fA-F]+ # hex number + | + \b0[0-9]+ # octal number + | + ( \b\d+(\.[0-9]+)? #number with optional floating point + | \.[0-9]+ #or just starting with floating point + ) + ([eE][+-]?[0-9]+)? # optional exponent + - - ~!@%^*()-+=|\#/{}[]:;"'<> , .? + + [?,.:;()\[\]{}+\-/%*<>&^!|~@]+ + - - " - " - + + + \b + [\d\w_]+ # an identifier + (?=\s*\() # followed by ( + + + ' + ' + + + + + + + + " + " + + + + + + + + + <<<\"?[\d\w_]+\"?$ + ^[\d\w_]+; + + + + + <<<\'[\d\w_]+\'$ + ^[\d\w_]+; + + + + global + my + var + - - - - - - - + + and + or + new + clone + instanceof + xor + true + false + + + + else + else + switch + case + endif + elseif + + + + do + for + foreach + while + endwhile + exit + + + + break + continue + default + goto + return + + + + require + include + require + include + function + + + + int + integer + real + double + float + string + array + object + + + + class + void + + + + public + private + + - From 2e248e72e19baa54bb62bff754fe214c00e17e28 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 4 Dec 2010 17:22:53 +0100 Subject: [PATCH 19/88] working on SD-1592: translated ASPX.xshd to the new format --- .../Highlighting/Resources/ASPX.xshd | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ASPX.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ASPX.xshd index b101156cc6..f780a5843e 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ASPX.xshd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/ASPX.xshd @@ -1,13 +1,16 @@ - - - - - <% - %> - - - - - + + + + + + + <% + %> + + + + + + From d43ee6b81c9e5c1a3643eb66a040ebb1ff8c1109 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 4 Dec 2010 17:35:03 +0100 Subject: [PATCH 20/88] working on SD-1592: translated Coco-Mode.xshd to the new format --- .../Highlighting/Resources/Coco-Mode.xshd | 167 ++++++++---------- 1 file changed, 72 insertions(+), 95 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Coco-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Coco-Mode.xshd index 0eb3b93930..9395198b52 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Coco-Mode.xshd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Coco-Mode.xshd @@ -1,97 +1,74 @@ - - - - - - - &<>~!@%^*()-+=|\#/{}[]:;"' , .? - - - // - - - - /* - */ - - - - - COMPILER - TOKENNAMES - - - - " - " - - - - ' - ' - - - - < - > - - - - (. - .) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + [{}\(\)\[\]|+\-=\.]+ + + + ANY + CHARACTERS + COMMENTS + COMPILER + CONTEXT + END + FROM + IF + IGNORE + NAMESPACE + NESTED + PRAGMAS + PRODUCTIONS + SYNC + TO + TOKENS + TOKENNAMES + WEAK + using + + + // + + + /\* + \*/ + + + COMPILER + TOKENNAMES + + + " + " + + + ' + ' + + + < + > + + + \(\. + \.\) + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + \ No newline at end of file From 5c45af55b3b8eb8aa392879afd2bf6f20c82af7d Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 4 Dec 2010 22:07:17 +0100 Subject: [PATCH 21/88] working on SD-1592: converted C++, HTML, JavaScript and Java highlighting to new format --- .../Highlighting/Resources/CPP-Mode.xshd | 429 +++++----- .../Highlighting/Resources/HTML-Mode.xshd | 765 +++++++++--------- .../Highlighting/Resources/Java-Mode.xshd | 328 ++++---- .../Resources/JavaScript-Mode.xshd | 255 +++--- 4 files changed, 847 insertions(+), 930 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd index 09c1a6a497..f552ad4136 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/CPP-Mode.xshd @@ -1,236 +1,195 @@ - - - - - - - - - - - - - ~!%^*()-+=|\#/{}[]:;"'<> , .? - - - # - - - - // - - - - /* - */ - - - - " - " - - - - ' - ' - - - ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + [?,.;()\[\]{}+\-/%*<>^=~!&]+ + + + __abstract + __box + __delegate + __gc + __identifier + __nogc + __pin + __property + __sealed + __try_cast + __typeof + __value + __event + __hook + __raise + __unhook + __interface + ref class + ref struct + value class + value struct + interface class + interface struct + enum class + enum struct + delegate + event + property + abstract + override + sealed + generic + where + finally + for each + gcnew + in + initonly + literal + nullptr + + + this + + + and + and_eq + bitand + bitor + new + not + not_eq + or + or_eq + xor + xor_eq + + + using + namespace + + + friend + + + private + protected + public + const + volatile + static + + + bool + char + unsigned + union + virtual + double + float + short + signed + void + class + enum + struct + + + false + true + + + do + for + while + + + break + continue + goto + return + + + catch + throw + try + + + case + else + if + switch + default + + + asm + auto + compl + mutable + const_cast + delete + dynamic_cast + explicit + export + extern + inline + int + long + operator + register + reinterpret_cast + sizeof + static_cast + template + typedef + typeid + typename + + + \# + + + // + + + /\* + \*/ + + + " + " + + + + + + ' + ' + + + + + [\d\w_]+(?=(\s*\()) + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + \ No newline at end of file diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/HTML-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/HTML-Mode.xshd index 5ca4ec47ac..e23d6a624d 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/HTML-Mode.xshd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/HTML-Mode.xshd @@ -1,385 +1,384 @@ - - - - - - - - - - - - - <!-- - --> - - - <script> - </script> - - - <script lang="JavaScript"> - </script> - - - <script lang="JScript"> - </script> - - - <script lang="VBScript"> - </script> - - - <script@C - </script> - - - < - > - - - - & - ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /= - - - " - " - - - - ' - ' - - - = - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + <!-- + --> + + + <script> + </script> + + + <script\ lang="JavaScript"> + </script> + + + <script\ lang="JScript"> + </script> + + + <script\ lang="VBScript"> + </script> + + + <script[^\w\d_] + </script> + + + < + > + + + & + ; + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + + + aacute + agrave + acirc + amp + atilde + aring + auml + aelig + ccedil + copy + eacute + egrave + ecirc + euml + iacute + igrave + icirc + iuml + eth + gt + lt + nbsp + ntilde + oacute + ograve + ocirc + otilde + ouml + oslash + quot + reg + szlig + uacute + ugrave + ucirc + uuml + yacute + thorn + trade + yuml + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + + + / + + + = + + + !DOCTYPE + A + ABBR + ACRONYM + ADDRESS + APPLET + AREA + B + BASE + BASEFONT + BGSOUND + BDO + BIG + BLINK + BLOCKQUOTE + BODY + BR + BUTTON + CAPTION + CENTER + CITE + CODE + COL + COLGROUP + COMMENT + DD + DEL + DFN + DIR + DIV + DL + DT + EM + EMBED + FIELDSET + FONT + FORM + FRAME + FRAMESET + H + H1 + H2 + H3 + H4 + H5 + H6 + HEAD + HR + HTA:APPLICATION + HTML + I + IFRAME + IMG + INPUT + INS + ISINDEX + KBD + LABEL + LEGEnd + LI + LINK + LISTING + MAP + MARQUEE + MENU + META + MULTICOL + NEXTID + NOBR + NOFRAMES + NOSCRIPT + OBJECT + OL + OPTGROUP + OPTION + P + PARAM + PLAINTEXT + PRE + Q + S + SAMP + SCRIPT + SELECT + SERVER + SMALL + SOUND + SPACER + Span + STRONG + STYLE + SUB + SUP + TABLE + TBODY + TD + TEXTAREA + TEXTFLOW + TFOOT + TH + THEAD + TITLE + TR + TT + U + VAR + WBR + XMP + + + abbr + accept-charset + accept + accesskey + action + align + alink + alt + applicationname + archive + axis + background + behavior + bgcolor + bgproperties + border + bordercolor + bordercolordark + bordercolorligh + borderstyle + caption + cellpadding + cellspacing + char + charoff + charset + checked + cite + class + classid + clear + code + codetype + color + cols + colspan + compact + content + coords + data + datetime + declare + defer + dir + direction + disabled + dynsrc + enctype + face + for + frame + frameborder + framespacing + gutter + headers + height + href + hreflang + hspace + http-equiv + icon + id + ismap + label + language + leftmargin + link + longdesc + loop + lowsrc + marginheight + marginwidth + maximizebutton + maxlength + media + method + methods + minimizebutton + multiple + name + nohref + noresize + noshade + nowrap + object + onabort + onblur + onchange + onclick + ondblclick + onerror + onfocus + onkeydown + onkeypress + onkeyup + onload + onmousedown + onmousemove + onmouseout + onmouseover + onmouseup + onreset + onselect + onsubmit + onunload + profile + prompt + readonly + rel + rev + rows + rowspan + rules + runat + scheme + scope + scrollamount + scrolldelay + scrolling + selected + shape + showintaskbar + singleinstance + size + span + src + standby + start + style + summary + sysmenu + tabindex + target + text + title + topmargin + type + urn + usemap + valign + value + valuetype + version + vlink + vrml + vspace + width + windowstate + wrap + + + " + " + + + ' + ' + + [\d\w_]+(?=(\s*=)) + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + \ No newline at end of file diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Java-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Java-Mode.xshd index 913d16e95c..dd5053e911 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Java-Mode.xshd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/Java-Mode.xshd @@ -1,180 +1,152 @@ - - - - - - - - - - - - - ~!%^*()-+=|\#/{}[]:;"'<> , .? - - - // - - - - /* - */ - - - - " - " - - - - ' - ' - - - ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ~!%^*()-+=|\#/{}[]:;"'<> , .? - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + [?,.()\[\]{}+\-/%*<>^!|]+ + + + this + super + + + new + instanceof + true + false + + + else + if + switch + case + + + do + for + while + + + break + continue + default + goto + return + + + try + throw + catch + finally + + + boolean + double + int + short + long + float + byte + char + + + class + interface + object + + + void + + + abstract + const + static + final + native + extends + implements + volatile + transient + throws + strictfp + synchronized + + + public + protected + private + + + package + import + + + null + + + // + + + /\* + \*/ + + + " + " + + + + + + ' + ' + + + + + [\d\w_]+(?=(\s*\()) + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + + + TODO + + + @author + @version + @param + @return + @exception + @throws + @see + @since + @serial + @serialField + @serialData + @deprecated + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + \ No newline at end of file diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/JavaScript-Mode.xshd b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/JavaScript-Mode.xshd index 23a4708021..59556e4942 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/JavaScript-Mode.xshd +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/Resources/JavaScript-Mode.xshd @@ -1,136 +1,123 @@ - - - - - - - - - - - - =!><+-/*%&|^~.}{,;][?: - - - // - - - - /* - */ - - - - " - " - - - - ' - ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + break + continue + delete + else + for + function + if + in + new + return + this + typeof + var + void + while + with + abstract + boolean + byte + case + catch + char + class + const + debugger + default + do + double + enum + export + extends + final + finally + float + goto + implements + import + instanceof + int + interface + long + native + package + private + protected + public + short + static + super + switch + synchronized + throw + throws + transient + try + volatile + + + Array + Boolean + Date + Function + Global + Math + Number + Object + RegExp + String + + + false + null + true + NaN + Infinity + + + eval + parseInt + parseFloat + escape + unescape + isNaN + isFinite + + + // + + + /\* + \*/ + + + " + " + + + + + + ' + ' + + + + + \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? + + \ No newline at end of file From 1c446023e11028b3459c788d5890b7c03ee6f1e3 Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Sat, 4 Dec 2010 23:12:32 +0200 Subject: [PATCH 22/88] Fix SD-701 - Moving the mouse over multiple references to the same object leaves the tooltip displayed --- .../AvalonEdit.AddIn/Src/CodeEditorView.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs index b467774c84..9797f69a26 100755 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs @@ -57,9 +57,17 @@ namespace ICSharpCode.AvalonEdit.AddIn this.MouseLeave += TextEditorMouseLeave; this.TextArea.TextView.MouseDown += TextViewMouseDown; this.TextArea.Caret.PositionChanged += HighlightBrackets; + this.TextArea.TextView.VisualLinesChanged += CodeEditorView_VisualLinesChanged; SetupTabSnippetHandler(); } + + void CodeEditorView_VisualLinesChanged(object sender, EventArgs e) + { + // hide tooltip + if (this.toolTip != null) + this.toolTip.IsOpen = false; + } protected override string FileName { get { return this.Adapter.FileName; } From b9b8378eae343c6db3dc28b1f5ab76f307f968bd Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 4 Dec 2010 22:51:43 +0100 Subject: [PATCH 23/88] Fix http://community.sharpdevelop.net/forums/t/12329.aspx Error List, Task and Thread pads selection is hidden when losing focus --- src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs | 1 + src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs index c8adde832d..3afbadc12b 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/RunningThreadsPad.cs @@ -32,6 +32,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads protected override void InitializeComponents() { runningThreadsList = new ListView(); + runningThreadsList.HideSelection = false; runningThreadsList.FullRowSelect = true; runningThreadsList.AutoArrange = true; runningThreadsList.Alignment = ListViewAlignment.Left; 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 06986a6249..f0e8d07846 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs @@ -106,6 +106,7 @@ namespace ICSharpCode.SharpDevelop.Gui this.Columns.Add(file); this.Columns.Add(path); + this.HideSelection = false; this.FullRowSelect = true; this.AutoArrange = true; this.Alignment = ListViewAlignment.Left; From 794a0f8af748d05181a87d21a41eb76585d68d57 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 4 Dec 2010 23:12:58 +0100 Subject: [PATCH 24/88] Fix "interaction problem between code completion and scrolling" (http://community.sharpdevelop.net/forums/t/12215.aspx) --- .../CodeCompletion/CompletionWindowBase.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs index 0ad375b8e6..d8a6beb058 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs @@ -5,9 +5,9 @@ using System; using System.Linq; using System.Diagnostics; using System.Windows; +using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Threading; - using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Rendering; @@ -159,7 +159,13 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion void TextViewScrollOffsetChanged(object sender, EventArgs e) { - UpdatePosition(); + IScrollInfo scrollInfo = this.TextArea.TextView; + Rect visibleRect = new Rect(scrollInfo.HorizontalOffset, scrollInfo.VerticalOffset, scrollInfo.ViewportWidth, scrollInfo.ViewportHeight); + // close completion window when the user scrolls so far that the anchor position is leaving the visible area + if (visibleRect.Contains(visualLocation) || visibleRect.Contains(visualLocationTop)) + UpdatePosition(); + else + Close(); } void TextAreaDocumentChanged(object sender, EventArgs e) From 58b32c7005acaed7f510eb114df1b9c2e6727afd Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sun, 5 Dec 2010 00:37:01 +0000 Subject: [PATCH 25/88] Fix null reference exception in IronPython resolver when class member has a null IReturnType. --- .../Project/Src/PythonMemberResolver.cs | 8 +++- .../Test/PythonBinding.Tests.csproj | 2 + ...olveMemberWhenFieldHasNoReturnTypeTests.cs | 40 +++++++++++++++++++ .../Resolver/ResolveRandomRandintTests.cs | 38 ++++++++++++++++++ 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMemberWhenFieldHasNoReturnTypeTests.cs create mode 100644 src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveRandomRandintTests.cs diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonMemberResolver.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonMemberResolver.cs index ef62a48825..12ff2667b3 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonMemberResolver.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonMemberResolver.cs @@ -119,8 +119,12 @@ namespace ICSharpCode.PythonBinding IMember FindMemberInParent(IMember parentMember, string memberName) { - IClass parentMemberClass = parentMember.ReturnType.GetUnderlyingClass(); - return FindMemberInClass(parentMemberClass, memberName); + IReturnType returnType = parentMember.ReturnType; + if (returnType != null) { + IClass parentMemberClass = returnType.GetUnderlyingClass(); + return FindMemberInClass(parentMemberClass, memberName); + } + return null; } } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj index cfbaac957e..4a51b1f5f5 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj @@ -369,11 +369,13 @@ + + diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMemberWhenFieldHasNoReturnTypeTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMemberWhenFieldHasNoReturnTypeTests.cs new file mode 100644 index 0000000000..4d5e778069 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveMemberWhenFieldHasNoReturnTypeTests.cs @@ -0,0 +1,40 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Collections; +using System.Collections.Generic; + +using ICSharpCode.PythonBinding; +using ICSharpCode.Scripting.Tests.Utils; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Dom.CSharp; +using NUnit.Framework; +using PythonBinding.Tests.Utils; +using UnitTestingUtils = UnitTesting.Tests.Utils; + +namespace PythonBinding.Tests.Resolver +{ + [TestFixture] + public class ResolveMemberWhenFieldHasNoReturnTypeTests + { + [Test] + public void Resolve_FieldHasNoReturnType_DoesNotThrowNullReferenceException() + { + MockProjectContent projectContent = new MockProjectContent(); + UnitTestingUtils.MockClass c = new UnitTestingUtils.MockClass(projectContent, "Test"); + projectContent.SetClassToReturnFromGetClass("self", c); + DefaultField field = c.AddField("randomNumber"); + field.ReturnType = null; + ParseInformation parseInfo = new ParseInformation(c.CompilationUnit); + + ExpressionResult expression = new ExpressionResult("self.randomNumber.randint", ExpressionContext.Default); + PythonClassResolver classResolver = new PythonClassResolver(); + PythonLocalVariableResolver localVariableResolver = new PythonLocalVariableResolver(classResolver); + PythonMemberResolver resolver = new PythonMemberResolver(classResolver, localVariableResolver); + + PythonResolverContext context = new PythonResolverContext(parseInfo, expression, "class Test:\r\npass"); + Assert.DoesNotThrow(delegate { resolver.Resolve(context); }); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveRandomRandintTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveRandomRandintTests.cs new file mode 100644 index 0000000000..d471a876e7 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveRandomRandintTests.cs @@ -0,0 +1,38 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using ICSharpCode.PythonBinding; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; +using PythonBinding.Tests.Utils; + +namespace PythonBinding.Tests.Resolver +{ + [TestFixture] + public class ResolveRandomRandintTests : ResolveTestsBase + { + protected override ExpressionResult GetExpressionResult() + { + return new ExpressionResult("self.randomNumber.randint", ExpressionContext.Default); + } + + protected override string GetPythonScript() + { + return + "import random\r\n" + + "\r\n" + + "class Test:\r\n" + + " def __init__(self):\r\n" + + " self.randomNumber = random.random()\r\n" + + " self.randomNumber.randint\r\n" + + "\r\n"; + } + + [Test] + public void Resolve_RandomModuleCannotBeFound_NoNullRefererenceExceptionThrown() + { + Assert.IsNotNull(resolveResult as PythonMethodGroupResolveResult); + } + } +} From 85715b044d59119f167c1fa24d13f4cabe1a47b1 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 5 Dec 2010 15:04:54 +0100 Subject: [PATCH 26/88] dispose unneeded AXml data after parsing files without IViewContent --- .../XamlBinding/XamlBinding/XamlParser.cs | 15 ++++++++++ .../ICSharpCode.AvalonEdit/Xml/AXmlParser.cs | 28 +++++++++++++------ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs index c03df01f4b..d056ffac3d 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs @@ -104,6 +104,21 @@ namespace ICSharpCode.XamlBinding return visitor.CompilationUnit; } //} + // During project load all XAML files are parsed + // most of them are not opened, thus fileContent.Version is null. + // We can clear the parser data, because the file will be reparsed + // as soon as it is opened by the user. + + // This will save us some memory, because we only use the + // compilation unit created by the visitor above for code completion. + if (fileContent.Version == null) { + parser.Lock.EnterWriteLock(); + // double-checked locking (other threads might parse the document in the meantime) + if (lastParsedVersion == null) { + parser.Clear(); + } + parser.Lock.ExitWriteLock(); + } } /// diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Xml/AXmlParser.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Xml/AXmlParser.cs index eb282e9628..9af6b4cacf 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Xml/AXmlParser.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Xml/AXmlParser.cs @@ -97,15 +97,8 @@ namespace ICSharpCode.AvalonEdit.Xml /// Create new parser public AXmlParser() { - this.UnknownEntityReferenceIsError = true; - this.TrackedSegments = new TrackedSegmentCollection(); this.Lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); - - this.userDocument = new AXmlDocument() { Parser = this }; - this.userDocument.Document = this.userDocument; - // Track the document - this.TrackedSegments.AddParsedObject(this.userDocument, null); - this.userDocument.IsCached = false; + ClearInternal(); } /// Throws exception if condition is false @@ -181,5 +174,24 @@ namespace ICSharpCode.AvalonEdit.Xml return userDocument; } } + + public void Clear() + { + if (!Lock.IsWriteLockHeld) + throw new InvalidOperationException("Write lock needed!"); + + ClearInternal(); + } + + void ClearInternal() + { + this.UnknownEntityReferenceIsError = true; + this.TrackedSegments = new TrackedSegmentCollection(); + this.userDocument = new AXmlDocument() { Parser = this }; + this.userDocument.Document = this.userDocument; + // Track the document + this.TrackedSegments.AddParsedObject(this.userDocument, null); + this.userDocument.IsCached = false; + } } } From 3dc2b5b1056d504e49df763f6423f54361f0ecfb Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 5 Dec 2010 15:22:47 +0100 Subject: [PATCH 27/88] fixed unreachable code and added a documentation comment to the Clear()-method. --- .../XamlBinding/XamlBinding/XamlParser.cs | 10 ++++++---- .../ICSharpCode.AvalonEdit/Xml/AXmlParser.cs | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs index d056ffac3d..1423a1e7aa 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlParser.cs @@ -91,8 +91,8 @@ namespace ICSharpCode.XamlBinding public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ITextBuffer fileContent) { - //using (new DebugTimerObject("background parser")) { - // Core.LoggingService.Info("file: " + fileName); + ICompilationUnit compilationUnit; + using (ParseAndLock(fileContent)) { var document = parser.LastDocument; @@ -101,9 +101,9 @@ namespace ICSharpCode.XamlBinding document.AcceptVisitor(visitor); - return visitor.CompilationUnit; + compilationUnit = visitor.CompilationUnit; } - //} + // During project load all XAML files are parsed // most of them are not opened, thus fileContent.Version is null. // We can clear the parser data, because the file will be reparsed @@ -119,6 +119,8 @@ namespace ICSharpCode.XamlBinding } parser.Lock.ExitWriteLock(); } + + return compilationUnit; } /// diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Xml/AXmlParser.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Xml/AXmlParser.cs index 9af6b4cacf..a068bb8b77 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Xml/AXmlParser.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Xml/AXmlParser.cs @@ -175,6 +175,10 @@ namespace ICSharpCode.AvalonEdit.Xml } } + /// + /// Clears the parser data. + /// + /// No write lock is held by the current thread. public void Clear() { if (!Lock.IsWriteLockHeld) From 9f130b0233a8dfb7fd9bc7061668a92799daac79 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 5 Dec 2010 21:17:46 +0100 Subject: [PATCH 28/88] fixed SD-1715 - UnauthorizedAccessException when trying to add item to project without write permission: might not be the optimal solution, because a new IViewContent is opened before the exception occurs and stays open after the exception. --- .../Project/Src/Gui/Dialogs/NewFileDialog.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs index 43d6e0b8b6..534267bfa4 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs @@ -9,8 +9,8 @@ using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; - using ICSharpCode.Core; +using ICSharpCode.Core.Services; using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Gui.XmlForms; using ICSharpCode.SharpDevelop.Internal.Templates; @@ -505,14 +505,20 @@ namespace ICSharpCode.SharpDevelop.Gui } } ScriptRunner scriptRunner = new ScriptRunner(); - - foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates) { - if (!String.IsNullOrEmpty(newfile.BinaryFileName)) { - SaveFile(newfile, null, newfile.BinaryFileName); - } else { - SaveFile(newfile, scriptRunner.CompileScript(item.Template, newfile), null); - } + foreach (FileDescriptionTemplate newFile in item.Template.FileDescriptionTemplates) { + FileOperationResult result = FileUtility.ObservedSave( + () => { + if (!String.IsNullOrEmpty(newFile.BinaryFileName)) { + SaveFile(newFile, null, newFile.BinaryFileName); + } else { + SaveFile(newFile, scriptRunner.CompileScript(item.Template, newFile), null); + } + }, StringParser.Parse(newFile.Name) + ); + if (result != FileOperationResult.OK) + return; } + DialogResult = DialogResult.OK; // raise FileCreated event for the new files. From 7ec189fc1dae12704893d8b18a6c6d6970595baf Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 7 Dec 2010 13:23:13 +0100 Subject: [PATCH 29/88] Add 200ms timeout to CaretReferencesRenderer. --- .../Src/CaretReferencesRenderer.cs | 20 +++++++++++++++---- .../Base/Project/Src/Gui/IProgressMonitor.cs | 6 ++---- .../RefactoringService/RefactoringService.cs | 20 ++++++++++++++++--- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs index 4a72f4c514..72bb3ac568 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Threading; using System.Windows.Threading; using ICSharpCode.AvalonEdit.AddIn.Options; @@ -10,6 +11,7 @@ using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Refactoring; namespace ICSharpCode.AvalonEdit.AddIn @@ -127,10 +129,20 @@ namespace ICSharpCode.AvalonEdit.AddIn /// List GetReferencesInCurrentFile(ResolveResult resolveResult) { - var references = RefactoringService.FindReferencesLocal(resolveResult, Editor.FileName, null); - if (references == null || references.Count == 0) - return null; - return references; + var cancellationTokenSource = new CancellationTokenSource(); + using (new Timer( + delegate { + LoggingService.Debug("Aborting GetReferencesInCurrentFile due to timeout"); + cancellationTokenSource.Cancel(); + }, null, 200, Timeout.Infinite)) + { + var progressMonitor = new DummyProgressMonitor(); + progressMonitor.CancellationToken = cancellationTokenSource.Token; + var references = RefactoringService.FindReferencesLocal(resolveResult, Editor.FileName, progressMonitor); + if (references == null || references.Count == 0) + return null; + return references; + } } /// diff --git a/src/Main/Base/Project/Src/Gui/IProgressMonitor.cs b/src/Main/Base/Project/Src/Gui/IProgressMonitor.cs index 878467001c..5a64f85bb5 100644 --- a/src/Main/Base/Project/Src/Gui/IProgressMonitor.cs +++ b/src/Main/Base/Project/Src/Gui/IProgressMonitor.cs @@ -120,15 +120,13 @@ namespace ICSharpCode.SharpDevelop.Gui public OperationStatus Status { get; set; } - public CancellationToken CancellationToken { - get { return CancellationToken.None; } - } + public CancellationToken CancellationToken { get; set; } public double Progress { get; set; } public IProgressMonitor CreateSubTask(double workAmount) { - return new DummyProgressMonitor(); + return new DummyProgressMonitor() { CancellationToken = this.CancellationToken }; } public void Dispose() diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs index 853be79220..7924d13692 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/RefactoringService.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Linq; +using System.Threading; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; @@ -228,6 +229,9 @@ namespace ICSharpCode.SharpDevelop.Refactoring if (progressMonitor != null) progressMonitor.ShowingDialog = false; return null; } + + CancellationToken ct = progressMonitor != null ? progressMonitor.CancellationToken : CancellationToken.None; + List files; if (!string.IsNullOrEmpty(fileName)) { // search just in given file @@ -249,7 +253,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring if (progressMonitor != null) { progressMonitor.Progress += 1.0 / files.Count; - if (progressMonitor.CancellationToken.IsCancellationRequested) + if (ct.IsCancellationRequested) return null; } // Don't read files we don't have a parser for. @@ -257,7 +261,14 @@ namespace ICSharpCode.SharpDevelop.Refactoring if (ParserService.GetParser(itemFileName) != null) { ITextBuffer content = finder.Create(itemFileName); if (content != null) { - AddReferences(references, ownerClass, member, itemFileName, content.Text); + try { + AddReferences(references, ownerClass, member, itemFileName, content.Text, ct); + } catch (OperationCanceledException ex) { + if (ex.CancellationToken == ct) + return null; + else + throw; + } } } } @@ -270,7 +281,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring /// static void AddReferences(List list, IClass parentClass, IMember member, - string fileName, string fileContent) + string fileName, string fileContent, + CancellationToken cancellationToken) { TextFinder textFinder; // the class used to find the position to resolve if (member == null) { @@ -292,6 +304,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring TextFinderMatch match = new TextFinderMatch(-1, 0); while (true) { + cancellationToken.ThrowIfCancellationRequested(); match = textFinder.Find(fileContentForFinder, match.Position + 1); if (match.Position < 0) break; @@ -307,6 +320,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring if (expr.Expression != null) { Point position = GetPosition(fileContent, match.ResolvePosition); repeatResolve: + cancellationToken.ThrowIfCancellationRequested(); // TODO: Optimize by re-using the same resolver if multiple expressions were // found in this file (the resolver should parse all methods at once) ResolveResult rr = ParserService.Resolve(expr, position.Y, position.X, fileName, fileContent); From 9aa18af3d11facc1e06daf0b381ce20ccb8a1efc Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 7 Dec 2010 13:38:22 +0100 Subject: [PATCH 30/88] Truncate argument values in CallStackPad. This avoids performance problems when long strings are passed as arguments. --- src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs index b2a0e3bc53..366b2a5ac0 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs @@ -187,6 +187,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads if (showArgumentValues) { try { argValue = frame.GetArgumentValue(i).AsString; + if (argValue != null && argValue.Length > 100) + argValue = argValue.Substring(0, 100) + "..."; } catch { } } if (parameterName != null && argValue != null) { From 6dfa03cd028bcf35465081b07d2e88e9767fcca5 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 7 Dec 2010 14:16:30 +0100 Subject: [PATCH 31/88] Add maxLength parameter to Value.AsString() method. --- .../Debugger.AddIn/Pads/CallStackPad.xaml.cs | 4 +- .../Debugger.AddIn/Service/WindowsDebugger.cs | 2 +- .../TreeModel/ExpressionNode.cs | 2 +- .../Visualizers/Utils/DebuggerHelpers.cs | 4 +- .../Debugger/Debugger.Core/Exception.cs | 4 +- src/AddIns/Debugger/Debugger.Core/Thread.cs | 2 +- src/AddIns/Debugger/Debugger.Core/Value.cs | 43 +++++++++++-------- 7 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs index 366b2a5ac0..a0e03155b0 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs @@ -186,9 +186,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } if (showArgumentValues) { try { - argValue = frame.GetArgumentValue(i).AsString; - if (argValue != null && argValue.Length > 100) - argValue = argValue.Substring(0, 100) + "..."; + argValue = frame.GetArgumentValue(i).AsString(100); } catch { } } if (parameterName != null && argValue != null) { diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs index bf7c9a2dca..8a9e8154ed 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs @@ -382,7 +382,7 @@ namespace ICSharpCode.SharpDevelop.Services try { Value val = GetValueFromName(variableName); if (val == null) return null; - return val.AsString; + return val.AsString(); } catch (GetValueException) { return null; } diff --git a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs index a1ee943a84..d41a282c3b 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs @@ -195,7 +195,7 @@ namespace Debugger.AddIn.TreeModel return; } } else { - fullText = val.AsString; + fullText = val.AsString(); } this.Text = (fullText.Length > 256) ? fullText.Substring(0, 256) + "..." : fullText; diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/DebuggerHelpers.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/DebuggerHelpers.cs index af98c2c42e..165f739a48 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/DebuggerHelpers.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Utils/DebuggerHelpers.cs @@ -88,11 +88,11 @@ namespace Debugger.AddIn.Visualizers.Utils // value.InvokeMethod is nice for instance methods. // what about MethodInfo.Invoke() ? // also, there could be an overload that takes 1 parameter instead of array - string defaultHashCode = Eval.InvokeMethod(DebuggerHelpers.hashCodeMethod, null, new Value[]{value}).AsString; + Value defaultHashCode = Eval.InvokeMethod(DebuggerHelpers.hashCodeMethod, null, new Value[]{value}); //MethodInfo method = value.Type.GetMember("GetHashCode", BindingFlags.Method | BindingFlags.IncludeSuperType) as MethodInfo; //string hashCode = value.InvokeMethod(method, null).AsString; - return int.Parse(defaultHashCode); + return (int)defaultHashCode.PrimitiveValue; } public static Value EvalPermanentReference(this Expression expr) diff --git a/src/AddIns/Debugger/Debugger.Core/Exception.cs b/src/AddIns/Debugger/Debugger.Core/Exception.cs index 4153077ab1..ee75897de2 100644 --- a/src/AddIns/Debugger/Debugger.Core/Exception.cs +++ b/src/AddIns/Debugger/Debugger.Core/Exception.cs @@ -33,7 +33,7 @@ namespace Debugger public string Message { get { Value message = exception.GetMemberValue("_message"); - return message.IsNull ? string.Empty : message.AsString; + return message.IsNull ? string.Empty : message.AsString(); } } @@ -86,7 +86,7 @@ namespace Debugger // Note that evaluation is not possible after a stackoverflow exception Value stackTrace = exception.GetMemberValue("StackTrace"); if (!stackTrace.IsNull) { - sb.Append(stackTrace.AsString); + sb.Append(stackTrace.AsString()); sb.AppendLine(); } return sb.ToString(); diff --git a/src/AddIns/Debugger/Debugger.Core/Thread.cs b/src/AddIns/Debugger/Debugger.Core/Thread.cs index 330cb1d9e3..5ad86f2df8 100644 --- a/src/AddIns/Debugger/Debugger.Core/Thread.cs +++ b/src/AddIns/Debugger/Debugger.Core/Thread.cs @@ -156,7 +156,7 @@ namespace Debugger if (runtimeValue.IsNull) return string.Empty; Value runtimeName = runtimeValue.GetMemberValue("m_Name"); if (runtimeName.IsNull) return string.Empty; - return runtimeName.AsString.ToString(); + return runtimeName.AsString(100); } } diff --git a/src/AddIns/Debugger/Debugger.Core/Value.cs b/src/AddIns/Debugger/Debugger.Core/Value.cs index 61985a5cb5..e104f05c19 100644 --- a/src/AddIns/Debugger/Debugger.Core/Value.cs +++ b/src/AddIns/Debugger/Debugger.Core/Value.cs @@ -114,7 +114,7 @@ namespace Debugger public bool IsInvalid { get { return corValue_pauseSession != this.Process.PauseSession && - !(corValue is ICorDebugHandleValue); + !(corValue is ICorDebugHandleValue); } } @@ -149,12 +149,23 @@ namespace Debugger } /// Gets a string representation of the value - public string AsString { - get { - if (this.IsNull) return "null"; - if (this.Type.IsPrimitive) return PrimitiveValue.ToString(); - if (this.Type.FullName == typeof(string).FullName) return PrimitiveValue.ToString(); - return "{" + this.Type.FullName + "}"; + /// + /// The maximum length of the result string. + /// + public string AsString(int maxLength = int.MaxValue) + { + if (this.IsNull) return "null"; + if (this.Type.IsPrimitive || this.Type.FullName == typeof(string).FullName) { + string text = PrimitiveValue.ToString(); + if (text != null && text.Length > maxLength) + text = text.Substring(0, Math.Max(0, maxLength - 3)) + "..."; + return text; + } else { + string name = this.Type.FullName; + if (name != null && name.Length > maxLength) + return "{" + name.Substring(0, Math.Max(0, maxLength - 5)) + "...}"; + else + return "{" + name + "}"; } } @@ -251,7 +262,7 @@ namespace Debugger /// /// If setting of a value fails, NotSupportedException is thrown. /// - public object PrimitiveValue { + public object PrimitiveValue { get { if (this.Type.FullName == typeof(string).FullName) { if (this.IsNull) return null; @@ -302,7 +313,7 @@ namespace Debugger /// eg new object[4,5] returns 2 /// /// 0 for non-arrays - public int ArrayRank { + public int ArrayRank { get { if (!this.Type.IsArray) return 0; return (int)CorArrayValue.GetRank(); @@ -476,7 +487,7 @@ namespace Debugger ICorDebugFrame curFrame = null; if (process.IsPaused && process.SelectedThread != null && - process.SelectedThread.MostRecentStackFrame != null && + process.SelectedThread.MostRecentStackFrame != null && process.SelectedThread.MostRecentStackFrame.CorILFrame != null) { curFrame = process.SelectedThread.MostRecentStackFrame.CorILFrame; @@ -600,14 +611,14 @@ namespace Debugger } /// Invoke the ToString() method - public string InvokeToString() + public string InvokeToString(int maxLength = int.MaxValue) { - if (this.Type.IsPrimitive) return AsString; - if (this.Type.FullName == typeof(string).FullName) return AsString; + if (this.Type.IsPrimitive) return AsString(maxLength); + if (this.Type.FullName == typeof(string).FullName) return AsString(maxLength); if (this.Type.IsPointer) return "0x" + this.PointerAddress.ToString("X"); // if (!IsObject) // Can invoke on primitives DebugMethodInfo methodInfo = (DebugMethodInfo)this.AppDomain.ObjectType.GetMethod("ToString", new DebugType[] {}); - return Eval.InvokeMethod(methodInfo, this, new Value[] {}).AsString; + return Eval.InvokeMethod(methodInfo, this, new Value[] {}).AsString(maxLength); } #region Convenience overload methods @@ -636,9 +647,7 @@ namespace Debugger public override string ToString() { - return this.AsString; + return this.AsString(); } } - - } From f96b37170c3034aa932dcd33eb3a6fa40e783b95 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Tue, 7 Dec 2010 16:24:17 +0100 Subject: [PATCH 32/88] Fix build. --- .../Debugger.Tests/Tests/AppDomain_Tests.cs | 2 +- .../Tests/ExpressionEvaluator_Tests.cs | 4 ++-- .../Tests/StackFrame_VariablesLifetime.cs | 20 ------------------- .../Debugger.Tests/Tests/Value_Tests.cs | 4 ---- 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/AddIns/Debugger/Debugger.Tests/Tests/AppDomain_Tests.cs b/src/AddIns/Debugger/Debugger.Tests/Tests/AppDomain_Tests.cs index 22684b3201..99b3c792c1 100644 --- a/src/AddIns/Debugger/Debugger.Tests/Tests/AppDomain_Tests.cs +++ b/src/AddIns/Debugger/Debugger.Tests/Tests/AppDomain_Tests.cs @@ -43,7 +43,7 @@ namespace Debugger.Tests { DebugType type1b = process.SelectedStackFrame.GetLocalVariableValue("one").Type; ObjectDump("SameDomainEqual", type1 == type1b); process.Continue(); - ObjectDump("AppDomainName", process.SelectedStackFrame.GetLocalVariableValue("appDomainName").AsString); + ObjectDump("AppDomainName", process.SelectedStackFrame.GetLocalVariableValue("appDomainName").AsString()); DebugType type2 = process.SelectedStackFrame.GetLocalVariableValue("two").Type; ObjectDump("OtherDomainEqual", type1 == type2); ObjectDump("AppDomainsEqual", type1.AppDomain == type2.AppDomain); diff --git a/src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluator_Tests.cs b/src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluator_Tests.cs index a649e0cc1e..2aa62276b7 100644 --- a/src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluator_Tests.cs +++ b/src/AddIns/Debugger/Debugger.Tests/Tests/ExpressionEvaluator_Tests.cs @@ -264,9 +264,9 @@ namespace Debugger.Tests { ObjectDump("TypesIdentitcal", object.ReferenceEquals(locType, valType)); ObjectDump("TypesEqual", locType == valType); - ObjectDump("WorkerThreadMoved", process.SelectedStackFrame.GetThisValue().GetMemberValue("WorkerThreadMoved").AsString); + ObjectDump("WorkerThreadMoved", process.SelectedStackFrame.GetThisValue().GetMemberValue("WorkerThreadMoved").AsString()); process.Continue(); - ObjectDump("WorkerThreadMoved", process.SelectedStackFrame.GetThisValue().GetMemberValue("WorkerThreadMoved").AsString); + ObjectDump("WorkerThreadMoved", process.SelectedStackFrame.GetThisValue().GetMemberValue("WorkerThreadMoved").AsString()); EndTest(); } diff --git a/src/AddIns/Debugger/Debugger.Tests/Tests/StackFrame_VariablesLifetime.cs b/src/AddIns/Debugger/Debugger.Tests/Tests/StackFrame_VariablesLifetime.cs index 3bb9833307..720052911f 100644 --- a/src/AddIns/Debugger/Debugger.Tests/Tests/StackFrame_VariablesLifetime.cs +++ b/src/AddIns/Debugger/Debugger.Tests/Tests/StackFrame_VariablesLifetime.cs @@ -97,26 +97,22 @@ namespace Debugger.Tests { Break StackFrame_VariablesLifetime.cs:21,4-21,40 <_x0040_class> Break StackFrame_VariablesLifetime.cs:30,4-30,40 <_x0040_class> Break StackFrame_VariablesLifetime.cs:23,4-23,40 <_x0040_class> Break StackFrame_VariablesLifetime.cs:30,4-30,40 <_x0040_class> Break StackFrame_VariablesLifetime.cs:15,4-15,40 <_x0040_class> @@ -112,7 +111,6 @@ namespace Debugger.Tests { ArrayDimensions="{2, 2}" ArrayLength="4" ArrayRank="2" - AsString="{System.Int32[,]}" GetArrayElements="{0, 1, 2, 3}" IsReference="True" PrimitiveValue="{Exception: Value is not a primitive type}" @@ -123,7 +121,6 @@ namespace Debugger.Tests { ArrayDimensions="{10..11, 20..21}" ArrayLength="4" ArrayRank="2" - AsString="{System.Char[,]}" GetArrayElements="{a, b, c, d}" IsReference="True" PrimitiveValue="{Exception: Value is not a primitive type}" @@ -131,7 +128,6 @@ namespace Debugger.Tests { From 239fb0a454218b038634cd18e43a629612813470 Mon Sep 17 00:00:00 2001 From: peterforstmeier Date: Tue, 7 Dec 2010 20:13:11 +0100 Subject: [PATCH 33/88] RowRendering Event, cleanup --- .../src/SharpReportSamples/MainForm.cs | 10 +--- .../Project/Commands/PreviewCommands.cs | 17 ++---- .../Project/ReportDesignerView.cs | 38 ++++++++++++- .../ReportViewerSecondaryView.cs | 6 +- .../ICSharpCode.Reports.Core.csproj | 1 - .../Exporter/Converters/BaseConverter.cs | 7 ++- .../Converters/GroupedRowConverter.cs | 6 +- .../Converters/GroupedTableConverter.cs | 21 ++++--- .../Printing/ExtendedPrintController.cs | 56 ------------------- .../Project/ReportEngine.cs | 1 - .../Project/ReportViewer/ReportViewer.cs | 2 +- 11 files changed, 69 insertions(+), 96 deletions(-) delete mode 100644 src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/ExtendedPrintController.cs diff --git a/samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs b/samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs index db9e6f6f23..4673dcc811 100644 --- a/samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs +++ b/samples/SharpDevelopReports/src/SharpReportSamples/MainForm.cs @@ -98,9 +98,7 @@ namespace SharpReportSamples this.RunContributors(reportName); } else if (s == "ContributorsListWithParameters"){ - //this.V1_RunContributorsWithParameters(reportName); -// this.V2_RunContributorsWithParameters(string fileName) - this.V3_RunContributorsWithParameters(reportName); + this.RunContributorsWithParameters(reportName); } else if (s == "NoConnectionReport") { @@ -221,7 +219,7 @@ namespace SharpReportSamples } - private void V3_RunContributorsWithParameters(string fileName) + private void RunContributorsWithParameters(string fileName) { var model = ReportEngine.LoadReportModel(fileName); ReportParameters parameters = ReportEngine.LoadParameters(fileName); @@ -231,10 +229,6 @@ namespace SharpReportSamples List list = ContributorsReportData.CreateContributorsList(); -// IDataManager dataManager = DataManager.CreateInstance(list,model.ReportSettings); - - - //IReportCreator creator = ReportEngine.CreatePageBuilder(model,eventLogger.EventLog,null); IReportCreator creator = ReportEngine.CreatePageBuilder(model,list,parameters); diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/PreviewCommands.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/PreviewCommands.cs index 1c7cdb8a3d..ba2a4fbe27 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/PreviewCommands.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/PreviewCommands.cs @@ -2,13 +2,8 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Globalization; -using System.Windows.Forms; - using ICSharpCode.Core; using ICSharpCode.Reports.Core; -using ICSharpCode.SharpDevelop; -using ICSharpCode.Reports.Core.ReportViewer; using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.Reports.Addin.Commands @@ -50,9 +45,9 @@ namespace ICSharpCode.Reports.Addin.Commands } - public class AsyncFormsSheetPreviewCommand:AbstractPreviewCommand + public class FormsSheetPreviewCommand:AbstractPreviewCommand { - public AsyncFormsSheetPreviewCommand(ReportModel model, + public FormsSheetPreviewCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) { } @@ -65,10 +60,10 @@ namespace ICSharpCode.Reports.Addin.Commands } - public class AsyncPullModelPreviewCommand:AbstractPreviewCommand + public class PullModelPreviewCommand:AbstractPreviewCommand { - public AsyncPullModelPreviewCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) + public PullModelPreviewCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) { } @@ -81,9 +76,9 @@ namespace ICSharpCode.Reports.Addin.Commands } - public class AsyncPushModelPreviewCommand:AbstractPreviewCommand + public class PushModelPreviewCommand:AbstractPreviewCommand { - public AsyncPushModelPreviewCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) + public PushModelPreviewCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) { } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs index 35f8199d21..7b6cc3f4f5 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs @@ -12,6 +12,7 @@ using System.Windows.Forms; using ICSharpCode.Core; using ICSharpCode.Reports.Addin.Designer; +using ICSharpCode.Reports.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Gui; @@ -556,13 +557,48 @@ namespace ICSharpCode.Reports.Addin #region IPrintable + private void ccc() + { + /* + ReportModel model = loader.CreateRenderableModel(); + IReportCreator creator = ReportEngine.CreatePageBuilder(model,eventLogger.EventLog,null); + //creator.SectionRendering += PushPrinting; + creator.BuildExportList(); + using (PdfRenderer pdfRenderer = PdfRenderer.CreateInstance(creator,SelectFilename(),true)) + { + pdfRenderer.Start(); + pdfRenderer.RenderOutput(); + pdfRenderer.End(); + } + */ + + + var model = loader.CreateRenderableModel(); + switch (model.DataModel) { + case GlobalEnums.PushPullModel.FormSheet : { + //cmd = new FormsSheetPreviewCommand (model,control); + break; + } + case GlobalEnums.PushPullModel.PullData:{ + //cmd = new PullModelPreviewCommand(model,control); + break; + } + case GlobalEnums.PushPullModel.PushData:{ + //cmd = new PushModelPreviewCommand(model,control); + break; + } + default: + throw new InvalidReportModelException(); + } + } + public System.Drawing.Printing.PrintDocument PrintDocument { get { + ccc(); ICSharpCode.Reports.Core.ReportModel model = this.loader.CreateRenderableModel(); StandartPreviewManager reportManager = new StandartPreviewManager(); ICSharpCode.Reports.Core.AbstractRenderer r = reportManager.CreateRenderer (model); - r.ReportDocument.PrintController = new ICSharpCode.Reports.Core.ExtendedPrintController(new System.Drawing.Printing.PreviewPrintController()); return r.ReportDocument; } } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/ReportViewerSecondaryView.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/ReportViewerSecondaryView.cs index 9af6ac3c14..cac5e2eb61 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/ReportViewerSecondaryView.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/ReportViewerSecondaryView.cs @@ -50,15 +50,15 @@ namespace ICSharpCode.Reports.Addin AbstractPreviewCommand cmd = null; switch (model.DataModel) { case GlobalEnums.PushPullModel.FormSheet : { - cmd = new AsyncFormsSheetPreviewCommand (model,control); + cmd = new FormsSheetPreviewCommand (model,control); break; } case GlobalEnums.PushPullModel.PullData:{ - cmd = new AsyncPullModelPreviewCommand(model,control); + cmd = new PullModelPreviewCommand(model,control); break; } case GlobalEnums.PushPullModel.PushData:{ - cmd = new AsyncPushModelPreviewCommand(model,control); + cmd = new PushModelPreviewCommand(model,control); break; } default: diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/ICSharpCode.Reports.Core.csproj b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/ICSharpCode.Reports.Core.csproj index ca2350f731..e3d4cc16d1 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/ICSharpCode.Reports.Core.csproj +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/ICSharpCode.Reports.Core.csproj @@ -260,7 +260,6 @@ - diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs index dade10f1b9..1c0bff7623 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/BaseConverter.cs @@ -240,6 +240,8 @@ namespace ICSharpCode.Reports.Core.Exporter protected void PrepareContainerForConverting(BaseSection section,ISimpleContainer simpleContainer) { + Console.WriteLine("\tPrepareContainerForConverting"); + FireSectionRendering(section); LayoutRow(simpleContainer); } @@ -248,11 +250,13 @@ namespace ICSharpCode.Reports.Core.Exporter protected Point ConvertStandardRow(ExporterCollection mylist, ISimpleContainer simpleContainer) { var rowSize = simpleContainer.Size; - +Console.WriteLine("ConvertStandardRow"); Point curPos = ConvertContainer(mylist,simpleContainer,DefaultLeftPosition,CurrentPosition); AfterConverting (mylist); simpleContainer.Size = rowSize; + Console.WriteLine(""); return curPos; + } @@ -272,6 +276,7 @@ namespace ICSharpCode.Reports.Core.Exporter protected static void FillRow (ISimpleContainer row,IDataNavigator currentNavigator) { + Console.WriteLine("\tFillrow"); currentNavigator.Fill(row.Items); } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs index f65176c1c6..5ff2050a82 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedRowConverter.cs @@ -101,9 +101,10 @@ namespace ICSharpCode.Reports.Core.Exporter section.Items[1].Size = childSize; FillRow(simpleContainer,childNavigator); + FireRowRendering(simpleContainer,childNavigator); PrepareContainerForConverting(section,simpleContainer); - FireRowRendering(simpleContainer,childNavigator); +// FireRowRendering(simpleContainer,childNavigator); base.CurrentPosition = ConvertStandardRow(exporterCollection,simpleContainer); CheckForPageBreak(section,exporterCollection); } @@ -123,8 +124,9 @@ namespace ICSharpCode.Reports.Core.Exporter Size containerSize = section.Items[0].Size; FillRow(simpleContainer,base.DataNavigator); - base.PrepareContainerForConverting(section,simpleContainer); FireRowRendering(simpleContainer,base.DataNavigator); + base.PrepareContainerForConverting(section,simpleContainer); +// FireRowRendering(simpleContainer,base.DataNavigator); base.CurrentPosition = ConvertStandardRow (exporterCollection,simpleContainer); section.Size = base.RestoreSectionSize; section.Items[0].Size = containerSize; diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs index 85780a00dd..6ebcc10687 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/Converters/GroupedTableConverter.cs @@ -97,14 +97,12 @@ namespace ICSharpCode.Reports.Core.Exporter childNavigator.MoveNext(); /* - FillRow - PrepareContainerForConverting - Layouter for Container - FireRowRendering -eportViewer - RowRendering : - ConvertStandardRow - - */ +---- GroupTableConverter.cs Zeile 151: +FillRow(simpleContainer,base.DataNavigator); +FireRowRendering(simpleContainer,base.DataNavigator); +base.PrepareContainerForConverting(section,simpleContainer); +---- +*/ //Convert children if (childNavigator != null) { do @@ -114,9 +112,9 @@ eportViewer - RowRendering : containerSize = simpleContainer.Size; FillRow(simpleContainer,childNavigator); - PrepareContainerForConverting(section,simpleContainer); +// PrepareContainerForConverting(section,simpleContainer); FireRowRendering(simpleContainer,childNavigator); - + PrepareContainerForConverting(section,simpleContainer); base.CurrentPosition = ConvertStandardRow(exporterCollection,simpleContainer); simpleContainer.Size = containerSize; @@ -149,9 +147,10 @@ eportViewer - RowRendering : CheckForPageBreak(section,simpleContainer,headerRow,exporterCollection); FillRow(simpleContainer,base.DataNavigator); +// base.PrepareContainerForConverting(section,simpleContainer); + FireRowRendering(simpleContainer,base.DataNavigator); base.PrepareContainerForConverting(section,simpleContainer); - FireRowRendering(simpleContainer,base.DataNavigator); base.CurrentPosition = ConvertStandardRow (exporterCollection,simpleContainer); simpleContainer.Size = containerSize; section.Size = base.RestoreSectionSize; diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/ExtendedPrintController.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/ExtendedPrintController.cs deleted file mode 100644 index 1e5f2fb385..0000000000 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/ExtendedPrintController.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.Drawing.Printing; - -namespace ICSharpCode.Reports.Core -{ - /// - /// Description of ExtendedPrintController. - /// - - - public class ExtendedPrintController:PrintController - { - PrintController controller; - - public ExtendedPrintController(PrintController controller):base() - { - if (controller == null) { - throw new ArgumentNullException("controller"); - } - this.controller = controller; - } - - public override System.Drawing.Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e) - { - System.Diagnostics.Trace.WriteLine("ExtPrintcontroller OnStartPage"); - return this.controller.OnStartPage (document, e); - } - - - public override void OnStartPrint(PrintDocument document, PrintEventArgs e) - { - System.Diagnostics.Trace.WriteLine("ExtPrintcontroller OnStartPrint"); - this.controller.OnStartPrint(document, e); - } - - - public override void OnEndPage(PrintDocument document, PrintPageEventArgs e) - { - System.Diagnostics.Trace.WriteLine("ExtPrintcontroller OnEndPage"); - this.controller.OnEndPage (document, e); - } - - public override void OnEndPrint(PrintDocument document, PrintEventArgs e) - { - System.Diagnostics.Trace.WriteLine("ExtPrintcontroller OnEndprint"); - PreviewPrintController c = this.controller as PreviewPrintController; - if (c != null) { - PreviewPageInfo[] ppia = c.GetPreviewPageInfo(); - } - this.controller.OnEndPrint(document,e); - } - } -} diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportEngine.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportEngine.cs index 2cf0999347..19ef6c3279 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportEngine.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportEngine.cs @@ -21,7 +21,6 @@ namespace ICSharpCode.Reports.Core { public class ReportEngine : IDisposable { private PreviewControl previewControl; -// private IDataManager dataMan; /// /// This event is fired before a Section is Rendered, you can use diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs index b426d6dd8e..c506297df9 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs @@ -23,7 +23,7 @@ namespace ICSharpCode.Reports.Core.ReportViewer public partial class PreviewControl { public event EventHandler PreviewLayoutChanged; -// public event EventHandler SectionRendering; + private float zoom; From f5a56a05bd51a8572f8ff0f414b25e6d220df180 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 8 Dec 2010 16:45:51 +0100 Subject: [PATCH 34/88] SD-1592: color used for bracket highlighting is now customisable --- .../Src/BracketHighlightRenderer.cs | 36 +++++++++++++++---- .../AvalonEdit.AddIn/Src/CodeEditorView.cs | 5 +-- .../Src/Options/HighlightingOptions.xaml.cs | 30 +++++++++++++++- 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/BracketHighlightRenderer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/BracketHighlightRenderer.cs index 3e2778e723..2eca94cf29 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/BracketHighlightRenderer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/BracketHighlightRenderer.cs @@ -2,8 +2,10 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Collections.Generic; using System.Diagnostics; using System.Windows.Media; + using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.SharpDevelop.Editor; @@ -17,6 +19,12 @@ namespace ICSharpCode.AvalonEdit.AddIn Brush backgroundBrush; TextView textView; + // 255 - x is needed to produce the inverse Alpha value for subtraction. + static readonly Color transparencyBack = Color.FromArgb(255 - 22, 0, 0, 0); + static readonly Color transparencyFore = Color.FromArgb(255 - 52, 0, 0, 0); + + public const string BracketHighlight = "Bracket highlight"; + public void SetHighlight(BracketSearchResult result) { if (this.result != result) { @@ -30,16 +38,22 @@ namespace ICSharpCode.AvalonEdit.AddIn if (textView == null) throw new ArgumentNullException("textView"); - this.borderPen = new Pen(new SolidColorBrush(Color.FromArgb(52, 0, 0, 255)), 1); - this.borderPen.Freeze(); - - this.backgroundBrush = new SolidColorBrush(Color.FromArgb(22, 0, 0, 255)); - this.backgroundBrush.Freeze(); - this.textView = textView; this.textView.BackgroundRenderers.Add(this); } + + void UpdateColors(Color background, Color foreground) + { + Color border = Color.Subtract(foreground, transparencyFore); + Color back = Color.Subtract(background, transparencyBack); + + this.borderPen = new Pen(new SolidColorBrush(border), 1); + this.borderPen.Freeze(); + + this.backgroundBrush = new SolidColorBrush(back); + this.backgroundBrush.Freeze(); + } public KnownLayer Layer { get { @@ -66,5 +80,15 @@ namespace ICSharpCode.AvalonEdit.AddIn drawingContext.DrawGeometry(backgroundBrush, borderPen, geometry); } } + + public static void ApplyCustomizationsToRendering(BracketHighlightRenderer renderer, IEnumerable customizations) + { + renderer.UpdateColors(Colors.Blue, Colors.Blue); + foreach (CustomizedHighlightingColor color in customizations) { + if (color.Name == BracketHighlight) { + renderer.UpdateColors(color.Background ?? Colors.Blue, color.Foreground ?? Colors.Blue); + } + } + } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs index e584003e66..6e2528ccb4 100755 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs @@ -46,12 +46,12 @@ namespace ICSharpCode.AvalonEdit.AddIn { this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, OnHelpExecuted)); - UpdateCustomizedHighlighting(); - this.bracketRenderer = new BracketHighlightRenderer(this.TextArea.TextView); this.caretReferencesRenderer = new CaretReferencesRenderer(this); this.contextActionsRenderer = new ContextActionsRenderer(this); + UpdateCustomizedHighlighting(); + this.MouseHover += TextEditorMouseHover; this.MouseHoverStopped += TextEditorMouseHoverStopped; this.MouseLeave += TextEditorMouseLeave; @@ -501,6 +501,7 @@ namespace ICSharpCode.AvalonEdit.AddIn { string language = this.SyntaxHighlighting != null ? this.SyntaxHighlighting.Name : null; CustomizableHighlightingColorizer.ApplyCustomizationsToDefaultElements(this, FetchCustomizations(language)); + BracketHighlightRenderer.ApplyCustomizationsToRendering(this.bracketRenderer, FetchCustomizations(language)); this.TextArea.TextView.Redraw(); // manually redraw if default elements didn't change but customized highlightings did } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs index 35331c84a5..a915a03283 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs @@ -10,11 +10,13 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Xml; - using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.AvalonEdit.Highlighting.Xshd; using ICSharpCode.AvalonEdit.Rendering; +using ICSharpCode.SharpDevelop.Bookmarks; +using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.AvalonEdit.AddIn.Options @@ -29,9 +31,13 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options InitializeComponent(); textEditor.Document.UndoStack.SizeLimit = 0; textEditor.Options = CodeEditorOptions.Instance; + bracketHighlighter = new BracketHighlightRenderer(textEditor.TextArea.TextView); + CodeEditorOptions.Instance.BindToTextEditor(textEditor); } + BracketHighlightRenderer bracketHighlighter; + List customizationList; XshdSyntaxDefinition LoadBuiltinXshd(string name) @@ -132,6 +138,28 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options selectedText = new CustomizedHighlightingItem(customizationList, selectedText, language, canSetFont: false); selectedText.PropertyChanged += item_PropertyChanged; listBox.Items.Add(selectedText); + + // Create entry for "Bracket highlight" + IHighlightingItem bracketHighlight = new SimpleHighlightingItem( + BracketHighlightRenderer.BracketHighlight, + ta => { + ta.Document.Text = "(simple) example"; + XshdSyntaxDefinition xshd = (XshdSyntaxDefinition)languageComboBox.SelectedItem; + if (xshd == null) + return; + var customizationsForCurrentLanguage = customizationList.Where(c => c.Language == null || c.Language == xshd.Name); + BracketHighlightRenderer.ApplyCustomizationsToRendering(bracketHighlighter, customizationsForCurrentLanguage); + bracketHighlighter.SetHighlight(new BracketSearchResult(0, 1, 7, 1)); + }) + { + Foreground = Colors.Blue, + Background = Colors.Blue + }; + bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, null, canSetFont: false); + if (language != null) + selectedText = new CustomizedHighlightingItem(customizationList, bracketHighlight, language, canSetFont: false); + bracketHighlight.PropertyChanged += item_PropertyChanged; + listBox.Items.Add(bracketHighlight); } void item_PropertyChanged(object sender, PropertyChangedEventArgs e) From 8405f8c707ce72f089e632e668eafa2f02390ab3 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 8 Dec 2010 17:01:02 +0100 Subject: [PATCH 35/88] moved WpfDesigner-ColorPicker to ICSharpCode.SharpDevelop.Widgets.csproj --- .../Editors/BrushEditor/SolidBrushEditor.xaml | 10 ++++------ .../Project/WpfDesign.Designer.csproj | 9 --------- .../Project}/ColorHelper.cs | 2 +- .../Project}/ColorPicker.xaml | 20 +++++++++---------- .../Project}/ColorPicker.xaml.cs | 2 +- .../ICSharpCode.SharpDevelop.Widgets.csproj | 9 +++++++++ .../Project}/Picker.cs | 2 +- 7 files changed, 25 insertions(+), 29 deletions(-) rename src/{AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor => Main/ICSharpCode.SharpDevelop.Widgets/Project}/ColorHelper.cs (96%) rename src/{AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor => Main/ICSharpCode.SharpDevelop.Widgets/Project}/ColorPicker.xaml (90%) rename src/{AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor => Main/ICSharpCode.SharpDevelop.Widgets/Project}/ColorPicker.xaml.cs (98%) rename src/{AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor => Main/ICSharpCode.SharpDevelop.Widgets/Project}/Picker.cs (98%) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml index dadf1edc74..3a5fffea09 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml @@ -1,14 +1,12 @@ - + Height="284"> - + BrushTypeEditor.xaml - - - ColorPicker.xaml - GradientBrushEditor.xaml @@ -176,7 +172,6 @@ GradientSlider.xaml - SolidBrushEditor.xaml @@ -279,10 +274,6 @@ MSBuild:Compile Designer - - MSBuild:Compile - Designer - MSBuild:Compile Designer diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ColorHelper.cs similarity index 96% rename from src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorHelper.cs rename to src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ColorHelper.cs index 3196c7e584..6df1e66c4d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorHelper.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ColorHelper.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Media; -namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor +namespace ICSharpCode.SharpDevelop.Widgets { public static class ColorHelper { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ColorPicker.xaml similarity index 90% rename from src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml rename to src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ColorPicker.xaml index 730e55bb3a..efa3758076 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml +++ b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ColorPicker.xaml @@ -1,9 +1,7 @@ - @@ -55,7 +53,7 @@ - @@ -143,7 +141,7 @@ - - + - - - - + + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml.cs b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ColorPicker.xaml.cs similarity index 98% rename from src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml.cs rename to src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ColorPicker.xaml.cs index 20027bc148..ba7d4a2be2 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ColorPicker.xaml.cs @@ -16,7 +16,7 @@ using System.Windows.Navigation; using System.Windows.Shapes; using System.ComponentModel; -namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor +namespace ICSharpCode.SharpDevelop.Widgets { public partial class ColorPicker { diff --git a/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ICSharpCode.SharpDevelop.Widgets.csproj b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ICSharpCode.SharpDevelop.Widgets.csproj index 70f8c2d0af..b8fb0e7900 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ICSharpCode.SharpDevelop.Widgets.csproj +++ b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/ICSharpCode.SharpDevelop.Widgets.csproj @@ -63,6 +63,10 @@ Configuration\GlobalAssemblyInfo.cs + + + ColorPicker.xaml + @@ -76,6 +80,7 @@ NumericUpDown.xaml + @@ -99,6 +104,10 @@ + + MSBuild:Compile + Designer + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/Picker.cs b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/Picker.cs similarity index 98% rename from src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/Picker.cs rename to src/Main/ICSharpCode.SharpDevelop.Widgets/Project/Picker.cs index 86431dda27..187e74f948 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/Picker.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Widgets/Project/Picker.cs @@ -12,7 +12,7 @@ using System.Windows.Controls; using System.Windows.Media; using System.Windows.Data; -namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor +namespace ICSharpCode.SharpDevelop.Widgets { public class Picker : Grid { From bbe1cdb13abc9989d1d43507db026551800b3868 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 8 Dec 2010 21:23:46 +0100 Subject: [PATCH 36/88] use WpfDesigner color picker in ColorPicker button --- .../Src/Gui/Components/ColorPicker.xaml.cs | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs b/src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs index 3a3fcdfc0b..93740e689d 100644 --- a/src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs +++ b/src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs @@ -2,15 +2,14 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Collections.Generic; -using System.Text; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; using System.Windows.Media; +using Widgets = ICSharpCode.SharpDevelop.Widgets; + namespace ICSharpCode.SharpDevelop.Gui { /// @@ -60,14 +59,22 @@ namespace ICSharpCode.SharpDevelop.Gui void ButtonClick(object sender, RoutedEventArgs e) { - e.Handled = true; - using (SharpDevelopColorDialog dlg = new SharpDevelopColorDialog()) { - dlg.WpfColor = this.Value; - if (dlg.ShowWpfDialog() == true) { - // use SetCurrentValue instead of SetValue so that two-way data binding can be used - SetCurrentValue(ValueProperty, dlg.WpfColor); + var control = new Widgets.ColorPicker(); + Popup popup = new Popup() { + Child = control, + Placement = PlacementMode.Bottom, + PlacementTarget = this, + IsOpen = true, + StaysOpen = false + }; + + control.SetBinding( + Widgets.ColorPicker.ColorProperty, + new Binding("Value") { + Source = this, + Mode = BindingMode.TwoWay } - } + ); } } } From b467d76b21af50ce1127594c34cd2a4d09dadbad Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 8 Dec 2010 21:35:13 +0100 Subject: [PATCH 37/88] updated default colors for BracketHighlightRenderer (now with transparency) --- .../Src/BracketHighlightRenderer.cs | 14 +++++--------- .../Src/Options/HighlightingOptions.xaml.cs | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/BracketHighlightRenderer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/BracketHighlightRenderer.cs index 2eca94cf29..a7a93b6f89 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/BracketHighlightRenderer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/BracketHighlightRenderer.cs @@ -19,9 +19,8 @@ namespace ICSharpCode.AvalonEdit.AddIn Brush backgroundBrush; TextView textView; - // 255 - x is needed to produce the inverse Alpha value for subtraction. - static readonly Color transparencyBack = Color.FromArgb(255 - 22, 0, 0, 0); - static readonly Color transparencyFore = Color.FromArgb(255 - 52, 0, 0, 0); + public static readonly Color DefaultBackground = Color.FromArgb(22, 0, 0, 255); + public static readonly Color DefaultBorder = Color.FromArgb(52, 0, 0, 255); public const string BracketHighlight = "Bracket highlight"; @@ -45,13 +44,10 @@ namespace ICSharpCode.AvalonEdit.AddIn void UpdateColors(Color background, Color foreground) { - Color border = Color.Subtract(foreground, transparencyFore); - Color back = Color.Subtract(background, transparencyBack); - - this.borderPen = new Pen(new SolidColorBrush(border), 1); + this.borderPen = new Pen(new SolidColorBrush(foreground), 1); this.borderPen.Freeze(); - this.backgroundBrush = new SolidColorBrush(back); + this.backgroundBrush = new SolidColorBrush(background); this.backgroundBrush.Freeze(); } @@ -83,7 +79,7 @@ namespace ICSharpCode.AvalonEdit.AddIn public static void ApplyCustomizationsToRendering(BracketHighlightRenderer renderer, IEnumerable customizations) { - renderer.UpdateColors(Colors.Blue, Colors.Blue); + renderer.UpdateColors(DefaultBackground, DefaultBorder); foreach (CustomizedHighlightingColor color in customizations) { if (color.Name == BracketHighlight) { renderer.UpdateColors(color.Background ?? Colors.Blue, color.Foreground ?? Colors.Blue); diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs index a915a03283..97758bd9ce 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs @@ -152,8 +152,8 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options bracketHighlighter.SetHighlight(new BracketSearchResult(0, 1, 7, 1)); }) { - Foreground = Colors.Blue, - Background = Colors.Blue + Foreground = BracketHighlightRenderer.DefaultBorder, + Background = BracketHighlightRenderer.DefaultBackground }; bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, null, canSetFont: false); if (language != null) From 8c0fbdc2037d60ec0672a54c36df85950ebfa328 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Wed, 8 Dec 2010 21:47:15 +0000 Subject: [PATCH 38/88] Fix SD-1777 - 'Replace all' (in project) does not perform any replacements in files that are not open --- .../SearchAndReplace/Project/Engine/SearchReplaceManager.cs | 2 +- .../Src/Editor/Search/ProvidedDocumentInformation.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchReplaceManager.cs b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchReplaceManager.cs index a7855b4594..1a6a83cde1 100644 --- a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchReplaceManager.cs +++ b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchReplaceManager.cs @@ -215,7 +215,7 @@ namespace SearchAndReplace if (textArea != null) { string transformedPattern = result.TransformReplacePattern(SearchOptions.ReplacePattern); find.Replace(result.Offset, result.Length, transformedPattern); - if (!find.CurrentDocumentInformation.IsDocumentCreated) { + if (find.CurrentDocumentInformation.IsDocumentCreatedFromTextBuffer) { textArea.Document.Replace(result.Offset, result.Length, transformedPattern); } } else { diff --git a/src/Main/Base/Project/Src/Editor/Search/ProvidedDocumentInformation.cs b/src/Main/Base/Project/Src/Editor/Search/ProvidedDocumentInformation.cs index 0325d8133e..f33b2829c6 100644 --- a/src/Main/Base/Project/Src/Editor/Search/ProvidedDocumentInformation.cs +++ b/src/Main/Base/Project/Src/Editor/Search/ProvidedDocumentInformation.cs @@ -15,6 +15,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Search ITextBuffer textBuffer; FileName fileName; int currentOffset; + bool documentCreatedFromTextBuffer; public FileName FileName { get { @@ -35,8 +36,8 @@ namespace ICSharpCode.SharpDevelop.Editor.Search } } - public bool IsDocumentCreated { - get { return document != null; } + public bool IsDocumentCreatedFromTextBuffer { + get { return documentCreatedFromTextBuffer; } } public int CurrentOffset { @@ -109,6 +110,7 @@ namespace ICSharpCode.SharpDevelop.Editor.Search this.textBuffer = textBuffer; this.fileName = FileName.Create(fileName); this.endOffset = this.currentOffset = currentOffset; + documentCreatedFromTextBuffer = true; } } } From d7a6c74a91e8a2491963726279a2632e81ffea51 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 8 Dec 2010 23:30:21 +0100 Subject: [PATCH 39/88] SD-1592: color for non-printable characters is now customisable --- .../Src/CustomizableHighlightingColorizer.cs | 13 ++++++++++++- .../Src/Options/HighlightingOptions.xaml.cs | 18 +++++++++++++++++- .../Rendering/NewLineElementGenerator.cs | 2 +- .../SingleCharacterElementGenerator.cs | 4 ++-- .../Rendering/TextView.cs | 14 +++++++++++++- .../Rendering/TextViewCachedElements.cs | 18 +++++++++--------- 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs index a7d18c4533..38e6f58f88 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs @@ -22,6 +22,7 @@ namespace ICSharpCode.AvalonEdit.AddIn { public const string DefaultTextAndBackground = "Default text/background"; public const string SelectedText = "Selected text"; + public const string NonPrintableCharacters = "Non-printable characters"; public static void ApplyCustomizationsToDefaultElements(TextEditor textEditor, IEnumerable customizations) { @@ -30,8 +31,10 @@ namespace ICSharpCode.AvalonEdit.AddIn textEditor.TextArea.ClearValue(TextArea.SelectionBorderProperty); textEditor.TextArea.ClearValue(TextArea.SelectionBrushProperty); textEditor.TextArea.ClearValue(TextArea.SelectionForegroundProperty); + textEditor.TextArea.TextView.ClearValue(TextView.NonPrintableCharacterBrushProperty); bool assignedDefaultText = false; bool assignedSelectedText = false; + bool assignedNonPrintableCharacter = false; foreach (CustomizedHighlightingColor color in customizations) { switch (color.Name) { case DefaultTextAndBackground: @@ -54,7 +57,7 @@ namespace ICSharpCode.AvalonEdit.AddIn pen.Freeze(); textEditor.TextArea.SelectionBorder = pen; SolidColorBrush back = new SolidColorBrush(color.Background.Value); - back.Opacity = 0.7; + back.Opacity = 0.7; // TODO : remove this constant, let the use choose the opacity. back.Freeze(); textEditor.TextArea.SelectionBrush = back; } @@ -62,6 +65,14 @@ namespace ICSharpCode.AvalonEdit.AddIn textEditor.TextArea.SelectionForeground = CreateFrozenBrush(color.Foreground.Value); } break; + case NonPrintableCharacters: + if (assignedNonPrintableCharacter) + continue; + assignedNonPrintableCharacter = true; + + if (color.Foreground != null) + textEditor.TextArea.TextView.NonPrintableCharacterBrush = CreateFrozenBrush(color.Foreground.Value); + break; } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs index 97758bd9ce..ccd7d833fa 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs @@ -139,6 +139,21 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options selectedText.PropertyChanged += item_PropertyChanged; listBox.Items.Add(selectedText); + // Create entry for "Non-printable characters" + IHighlightingItem nonPrintChars = new SimpleHighlightingItem( + CustomizableHighlightingColorizer.NonPrintableCharacters, + ta => { + ta.Document.Text = " \r \r\n \n"; + }) + { + Foreground = Colors.LightGray + }; + nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, null, canSetFont: false, canSetBackground: false); + if (language != null) + nonPrintChars = new CustomizedHighlightingItem(customizationList, nonPrintChars, language, canSetFont: false); + nonPrintChars.PropertyChanged += item_PropertyChanged; + listBox.Items.Add(nonPrintChars); + // Create entry for "Bracket highlight" IHighlightingItem bracketHighlight = new SimpleHighlightingItem( BracketHighlightRenderer.BracketHighlight, @@ -157,7 +172,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options }; bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, null, canSetFont: false); if (language != null) - selectedText = new CustomizedHighlightingItem(customizationList, bracketHighlight, language, canSetFont: false); + bracketHighlight = new CustomizedHighlightingItem(customizationList, bracketHighlight, language, canSetFont: false); bracketHighlight.PropertyChanged += item_PropertyChanged; listBox.Items.Add(bracketHighlight); } @@ -203,6 +218,7 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options textView.LineTransformers.Add(colorizer); } textEditor.Select(0, 0); + bracketHighlighter.SetHighlight(null); item.ShowExample(textEditor.TextArea); } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/NewLineElementGenerator.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/NewLineElementGenerator.cs index dea23c35d7..e81afbb22e 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/NewLineElementGenerator.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/NewLineElementGenerator.cs @@ -54,7 +54,7 @@ namespace ICSharpCode.AvalonEdit.Rendering } else { return null; } - return new NewLineTextElement(CurrentContext.TextView.cachedElements.GetSimpleLightGrayText(newlineText, CurrentContext)); + return new NewLineTextElement(CurrentContext.TextView.cachedElements.GetTextForNonPrintableCharacter(newlineText, CurrentContext)); } sealed class NewLineTextElement : FormattedTextElement diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs index da1aacbc45..3d26e7c9b9 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/SingleCharacterElementGenerator.cs @@ -88,9 +88,9 @@ namespace ICSharpCode.AvalonEdit.Rendering { char c = CurrentContext.Document.GetCharAt(offset); if (ShowSpaces && c == ' ') { - return new SpaceTextElement(CurrentContext.TextView.cachedElements.GetSimpleLightGrayText("\u00B7", CurrentContext)); + return new SpaceTextElement(CurrentContext.TextView.cachedElements.GetTextForNonPrintableCharacter("\u00B7", CurrentContext)); } else if (ShowTabs && c == '\t') { - return new TabTextElement(CurrentContext.TextView.cachedElements.GetSimpleLightGrayText("\u00BB", CurrentContext)); + return new TabTextElement(CurrentContext.TextView.cachedElements.GetTextForNonPrintableCharacter("\u00BB", CurrentContext)); } else if (ShowBoxForControlCharacters && char.IsControl(c)) { var p = new VisualLineElementTextRunProperties(CurrentContext.GlobalTextRunProperties); p.SetForegroundBrush(Brushes.White); diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs index 6be172d646..b615748b15 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs @@ -366,6 +366,17 @@ namespace ICSharpCode.AvalonEdit.Rendering } #endregion + #region Brushes + public static readonly DependencyProperty NonPrintableCharacterBrushProperty = + DependencyProperty.Register("NonPrintableCharacterBrush", typeof(Brush), typeof(TextView), + new FrameworkPropertyMetadata(Brushes.LightGray)); + + public Brush NonPrintableCharacterBrush { + get { return (Brush)GetValue(NonPrintableCharacterBrushProperty); } + set { SetValue(NonPrintableCharacterBrushProperty, value); } + } + #endregion + #region Redraw methods / VisualLine invalidation /// /// Causes the text editor to regenerate all visual lines. @@ -1660,7 +1671,8 @@ namespace ICSharpCode.AvalonEdit.Rendering || e.Property == Control.FontSizeProperty || e.Property == Control.FontStretchProperty || e.Property == Control.FontStyleProperty - || e.Property == Control.FontWeightProperty) + || e.Property == Control.FontWeightProperty + || e.Property == TextView.NonPrintableCharacterBrushProperty) { RecreateCachedElements(); InvalidateWideSpaceWidthAndDefaultLineHeight(); diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextViewCachedElements.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextViewCachedElements.cs index c6f21fb312..b76a8a7be8 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextViewCachedElements.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextViewCachedElements.cs @@ -12,28 +12,28 @@ namespace ICSharpCode.AvalonEdit.Rendering sealed class TextViewCachedElements : IDisposable { TextFormatter formatter; - Dictionary simpleLightGrayTexts; + Dictionary nonPrintableCharacterTexts; - public TextLine GetSimpleLightGrayText(string text, ITextRunConstructionContext context) + public TextLine GetTextForNonPrintableCharacter(string text, ITextRunConstructionContext context) { - if (simpleLightGrayTexts == null) - simpleLightGrayTexts = new Dictionary(); + if (nonPrintableCharacterTexts == null) + nonPrintableCharacterTexts = new Dictionary(); TextLine textLine; - if (!simpleLightGrayTexts.TryGetValue(text, out textLine)) { + if (!nonPrintableCharacterTexts.TryGetValue(text, out textLine)) { var p = new VisualLineElementTextRunProperties(context.GlobalTextRunProperties); - p.SetForegroundBrush(Brushes.LightGray); + p.SetForegroundBrush(context.TextView.NonPrintableCharacterBrush); if (formatter == null) formatter = TextFormatterFactory.Create(context.TextView); textLine = FormattedTextElement.PrepareText(formatter, text, p); - simpleLightGrayTexts[text] = textLine; + nonPrintableCharacterTexts[text] = textLine; } return textLine; } public void Dispose() { - if (simpleLightGrayTexts != null) { - foreach (TextLine line in simpleLightGrayTexts.Values) + if (nonPrintableCharacterTexts != null) { + foreach (TextLine line in nonPrintableCharacterTexts.Values) line.Dispose(); } if (formatter != null) From ef888b4c221a26021bd93a7d6f25359485049068 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 9 Dec 2010 16:27:19 +0100 Subject: [PATCH 40/88] SD-1592: color of line numbers is now customisable --- .../Src/CustomizableHighlightingColorizer.cs | 14 +++++++- .../Src/Options/HighlightingOptions.xaml.cs | 18 +++++++++++ .../Rendering/TextView.cs | 6 ++++ .../ICSharpCode.AvalonEdit/TextEditor.cs | 32 ++++++++++++++++++- .../themes/generic.xaml | 1 - 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs index 38e6f58f88..db54de5841 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CustomizableHighlightingColorizer.cs @@ -6,8 +6,8 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Windows; +using System.Windows.Controls; using System.Windows.Media; - using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Highlighting; @@ -23,18 +23,22 @@ namespace ICSharpCode.AvalonEdit.AddIn public const string DefaultTextAndBackground = "Default text/background"; public const string SelectedText = "Selected text"; public const string NonPrintableCharacters = "Non-printable characters"; + public const string LineNumbers = "Line numbers"; public static void ApplyCustomizationsToDefaultElements(TextEditor textEditor, IEnumerable customizations) { textEditor.ClearValue(TextEditor.BackgroundProperty); textEditor.ClearValue(TextEditor.ForegroundProperty); + textEditor.ClearValue(TextEditor.LineNumbersForegroundProperty); textEditor.TextArea.ClearValue(TextArea.SelectionBorderProperty); textEditor.TextArea.ClearValue(TextArea.SelectionBrushProperty); textEditor.TextArea.ClearValue(TextArea.SelectionForegroundProperty); textEditor.TextArea.TextView.ClearValue(TextView.NonPrintableCharacterBrushProperty); + bool assignedDefaultText = false; bool assignedSelectedText = false; bool assignedNonPrintableCharacter = false; + bool assignedLineNumbers = false; foreach (CustomizedHighlightingColor color in customizations) { switch (color.Name) { case DefaultTextAndBackground: @@ -73,6 +77,14 @@ namespace ICSharpCode.AvalonEdit.AddIn if (color.Foreground != null) textEditor.TextArea.TextView.NonPrintableCharacterBrush = CreateFrozenBrush(color.Foreground.Value); break; + case LineNumbers: + if (assignedLineNumbers) + continue; + assignedLineNumbers = true; + + if (color.Foreground != null) + textEditor.LineNumbersForeground = CreateFrozenBrush(color.Foreground.Value); + break; } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs index ccd7d833fa..20b1836244 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/HighlightingOptions.xaml.cs @@ -154,6 +154,24 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options nonPrintChars.PropertyChanged += item_PropertyChanged; listBox.Items.Add(nonPrintChars); + // Create entry for "Line numbers" + IHighlightingItem lineNumbers = new SimpleHighlightingItem( + CustomizableHighlightingColorizer.LineNumbers, + ta => { + ta.Document.Text = "These are just" + Environment.NewLine + + "multiple" + Environment.NewLine + + "lines of" + Environment.NewLine + + "text"; + }) + { + Foreground = Colors.Gray + }; + lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, null, canSetFont: false, canSetBackground: false); + if (language != null) + lineNumbers = new CustomizedHighlightingItem(customizationList, lineNumbers, language, canSetFont: false); + lineNumbers.PropertyChanged += item_PropertyChanged; + listBox.Items.Add(lineNumbers); + // Create entry for "Bracket highlight" IHighlightingItem bracketHighlight = new SimpleHighlightingItem( BracketHighlightRenderer.BracketHighlight, diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs index b615748b15..96278a72b1 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs @@ -367,10 +367,16 @@ namespace ICSharpCode.AvalonEdit.Rendering #endregion #region Brushes + /// + /// NonPrintableCharacterBrush dependency property. + /// public static readonly DependencyProperty NonPrintableCharacterBrushProperty = DependencyProperty.Register("NonPrintableCharacterBrush", typeof(Brush), typeof(TextView), new FrameworkPropertyMetadata(Brushes.LightGray)); + /// + /// Gets/sets the Brush used for displaying non-printable characters. + /// public Brush NonPrintableCharacterBrush { get { return (Brush)GetValue(NonPrintableCharacterBrushProperty); } set { SetValue(NonPrintableCharacterBrushProperty, value); } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs index d3c74ca179..0c44e07733 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs @@ -4,6 +4,7 @@ using System; using System.ComponentModel; using System.IO; +using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; @@ -11,6 +12,7 @@ using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Input; using System.Windows.Markup; +using System.Windows.Media; using System.Windows.Threading; using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; @@ -449,7 +451,7 @@ namespace ICSharpCode.AvalonEdit #region ShowLineNumbers /// - /// IsReadOnly dependency property. + /// ShowLineNumbers dependency property. /// public static readonly DependencyProperty ShowLineNumbersProperty = DependencyProperty.Register("ShowLineNumbers", typeof(bool), typeof(TextEditor), @@ -470,6 +472,7 @@ namespace ICSharpCode.AvalonEdit if ((bool)e.NewValue) { leftMargins.Insert(0, new LineNumberMargin()); leftMargins.Insert(1, DottedLineMargin.Create()); + leftMargins[0].SetValue(Control.ForegroundProperty, editor.LineNumbersForeground); } else { for (int i = 0; i < leftMargins.Count; i++) { if (leftMargins[i] is LineNumberMargin) { @@ -484,6 +487,33 @@ namespace ICSharpCode.AvalonEdit } #endregion + #region LineNumbersForeground + /// + /// LineNumbersForeground dependency property. + /// + public static readonly DependencyProperty LineNumbersForegroundProperty = + DependencyProperty.Register("LineNumbersForeground", typeof(Brush), typeof(TextEditor), + new FrameworkPropertyMetadata(Brushes.Gray, OnLineNumbersForegroundChanged)); + + /// + /// Gets/sets the Brush used for displaying the foreground color of line numbers. + /// + public Brush LineNumbersForeground { + get { return (Brush)GetValue(LineNumbersForegroundProperty); } + set { SetValue(LineNumbersForegroundProperty, value); } + } + + static void OnLineNumbersForegroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + TextEditor editor = (TextEditor)d; + var lineNumberMargin = editor.TextArea.LeftMargins.FirstOrDefault(margin => margin is LineNumberMargin) as LineNumberMargin;; + + if (lineNumberMargin != null) { + lineNumberMargin.SetValue(Control.ForegroundProperty, e.NewValue); + } + } + #endregion + #region TextBoxBase-like methods /// /// Appends text to the end of the document. diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/themes/generic.xaml b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/themes/generic.xaml index a2d821d61c..ad76a3eea0 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/themes/generic.xaml +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/themes/generic.xaml @@ -9,7 +9,6 @@ From d9f3afd5b287cc709adf032969658a3b4067ff77 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 9 Dec 2010 18:52:55 +0100 Subject: [PATCH 41/88] SD-1592: DottedLineMargin got same color as line numbers --- .../Editing/DottedLineMargin.cs | 13 ++++++++++--- .../AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs | 10 +++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/DottedLineMargin.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/DottedLineMargin.cs index 7408e28865..d19791d500 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/DottedLineMargin.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/DottedLineMargin.cs @@ -3,6 +3,7 @@ using System; using System.Windows; +using System.Windows.Data; using System.Windows.Media; using System.Windows.Shapes; @@ -19,18 +20,24 @@ namespace ICSharpCode.AvalonEdit.Editing /// /// Creates a vertical dotted line to separate the line numbers from the text view. /// - public static UIElement Create() + public static UIElement Create(TextEditor editor) { - return new Line { + Line line = new Line { X1 = 0, Y1 = 0, X2 = 0, Y2 = 1, StrokeDashArray = { 0, 2 }, Stretch = Stretch.Fill, - Stroke = Brushes.Gray, StrokeThickness = 1, StrokeDashCap = PenLineCap.Round, Margin = new Thickness(2, 0, 2, 0), Tag = tag }; + + line.SetBinding( + Line.StrokeProperty, + new Binding("LineNumbersForeground") { Source = editor } + ); + + return line; } /// diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs index 0c44e07733..4152385319 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/TextEditor.cs @@ -470,9 +470,13 @@ namespace ICSharpCode.AvalonEdit TextEditor editor = (TextEditor)d; var leftMargins = editor.TextArea.LeftMargins; if ((bool)e.NewValue) { - leftMargins.Insert(0, new LineNumberMargin()); - leftMargins.Insert(1, DottedLineMargin.Create()); - leftMargins[0].SetValue(Control.ForegroundProperty, editor.LineNumbersForeground); + var lineNumbers = new LineNumberMargin(); + leftMargins.Insert(0, lineNumbers); + leftMargins.Insert(1, DottedLineMargin.Create(editor)); + lineNumbers.SetBinding(Control.ForegroundProperty, + new Binding("LineNumbersForeground") { + Source = editor + }); } else { for (int i = 0; i < leftMargins.Count; i++) { if (leftMargins[i] is LineNumberMargin) { From f6077076b20f557ca7502502844f234644e07c0e Mon Sep 17 00:00:00 2001 From: mkonicek Date: Wed, 8 Dec 2010 18:46:13 +0100 Subject: [PATCH 42/88] Fix: NRefactoryResolver now resolves constructor definitions (before it was returning UnknownMethodResolveResult) -> Find references and context menu on constructor definitions work Please Daniel check if this is OK and also tell me if fixes like this are already useless because of the new NRefactory. (next thing I would like to fix are Find references to interface members). --- .../Project/Src/CtrlSpaceResolveHelper.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs index 08865ce3ff..473b422cf2 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs @@ -216,7 +216,11 @@ namespace ICSharpCode.SharpDevelop.Dom if (expressionResult.Context != ExpressionContext.Type) { if (callingMember != null && !callingMember.BodyRegion.IsInside(caretLine, caretColumn) - && callingClass.ProjectContent.Language.NameComparer.Equals(expression, callingMember.Name)) + && (callingClass.ProjectContent.Language.NameComparer.Equals(expression, callingMember.Name) || + // For constructor definition, the expression is the constructor name (e.g. "MyClass") but the name of the member is "#ctor" + (callingMember.Name == "#ctor" && callingClass.ProjectContent.Language.NameComparer.Equals(expression, callingClass.Name)) + ) + ) { return new MemberResolveResult(callingClass, callingMember, callingMember); } From 5990c898eccc4145fcc394f2536146a52adc9529 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 4 Dec 2010 14:50:40 +0100 Subject: [PATCH 43/88] ICSharpCode.Core: memory optimization: use common XmlNameTable for all addins being loaded. --- .../Core/Project/Src/AddInTree/AddIn/AddIn.cs | 18 +++++++++--------- .../Core/Project/Src/AddInTree/AddInManager.cs | 2 +- .../Core/Project/Src/AddInTree/AddInTree.cs | 3 ++- .../Src/Services/PropertyService/Properties.cs | 6 +++++- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs index 03d23b8e0e..35e67775fa 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/AddIn.cs @@ -227,6 +227,7 @@ namespace ICSharpCode.Core } string fileName = Path.Combine(hintPath, reader.GetAttribute(0)); XmlReaderSettings xrs = new XmlReaderSettings(); + xrs.NameTable = reader.NameTable; // share the name table xrs.ConformanceLevel = ConformanceLevel.Fragment; using (XmlReader includeReader = XmlTextReader.Create(fileName, xrs)) { SetupAddIn(includeReader, addIn, Path.GetDirectoryName(fileName)); @@ -260,16 +261,13 @@ namespace ICSharpCode.Core return paths[pathName]; } - public static AddIn Load(TextReader textReader) - { - return Load(textReader, null); - } - - public static AddIn Load(TextReader textReader, string hintPath) + public static AddIn Load(TextReader textReader, string hintPath = null, XmlNameTable nameTable = null) { + if (nameTable == null) + nameTable = new NameTable(); try { AddIn addIn = new AddIn(); - using (XmlTextReader reader = new XmlTextReader(textReader)) { + using (XmlTextReader reader = new XmlTextReader(textReader, nameTable)) { while (reader.Read()){ if (reader.IsStartElement()) { switch (reader.LocalName) { @@ -289,14 +287,16 @@ namespace ICSharpCode.Core } } - public static AddIn Load(string fileName) + public static AddIn Load(string fileName, XmlNameTable nameTable = null) { try { using (TextReader textReader = File.OpenText(fileName)) { - AddIn addIn = Load(textReader, Path.GetDirectoryName(fileName)); + AddIn addIn = Load(textReader, Path.GetDirectoryName(fileName), nameTable); addIn.addInFileName = fileName; return addIn; } + } catch (AddInLoadException) { + throw; } catch (Exception e) { throw new AddInLoadException("Can't load " + fileName, e); } diff --git a/src/Main/Core/Project/Src/AddInTree/AddInManager.cs b/src/Main/Core/Project/Src/AddInTree/AddInManager.cs index 53481c3d76..baa646819d 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddInManager.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddInManager.cs @@ -260,7 +260,7 @@ namespace ICSharpCode.Core /// /// /// The list of AddIns to add. (use instances - /// created by ). + /// created by ). /// public static void AddExternalAddIns(IList addIns) { diff --git a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs index 82f36690dd..6ab5df49d7 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs @@ -347,10 +347,11 @@ namespace ICSharpCode.Core List list = new List(); Dictionary dict = new Dictionary(); Dictionary addInDict = new Dictionary(); + var nameTable = new System.Xml.NameTable(); foreach (string fileName in addInFiles) { AddIn addIn; try { - addIn = AddIn.Load(fileName); + addIn = AddIn.Load(fileName, nameTable); } catch (AddInLoadException ex) { LoggingService.Error(ex); if (ex.InnerException != null) { diff --git a/src/Main/Core/Project/Src/Services/PropertyService/Properties.cs b/src/Main/Core/Project/Src/Services/PropertyService/Properties.cs index 04eb473685..b2d2a0cda3 100644 --- a/src/Main/Core/Project/Src/Services/PropertyService/Properties.cs +++ b/src/Main/Core/Project/Src/Services/PropertyService/Properties.cs @@ -151,7 +151,11 @@ namespace ICSharpCode.Core if (reader.HasAttributes) { for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); - properties[reader.Name] = reader.Value; + // some values are frequently repeated (e.g. type="MenuItem"), + // so we also use the NameTable for attribute values + // (XmlReader itself only uses it for attribute names) + string val = reader.NameTable.Add(reader.Value); + properties[reader.Name] = val; } reader.MoveToElement(); //Moves the reader back to the element node. } From 84ed7ca1783484d6265be59940460ffe5b0e7f59 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 11 Dec 2010 14:23:09 +0100 Subject: [PATCH 44/88] Avoid test failure on build server when unit tests for several branches are running concurrently. --- .../Tests/Designer/EditOperationTests.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs index 64cf9b9bc2..e83a8bc05b 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/EditOperationTests.cs @@ -1,16 +1,41 @@ // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using System; +using System.Threading; using System.Windows; -using NUnit.Framework; + using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.XamlDom; +using NUnit.Framework; namespace ICSharpCode.WpfDesign.Tests.Designer { [TestFixture] public class EditOperationTests : ModelTestHelper { + Mutex mutex; + + [TestFixtureSetUp] + public void FixtureSetUp() + { + // Avoid test failure on build server when unit tests for several branches are run concurrently. + bool createdNew; + mutex = new Mutex(true, "ClipboardUnitTest", out createdNew); + if (!createdNew) { + if (!mutex.WaitOne(10000)) { + throw new Exception("Could not acquire mutex"); + } + } + } + + [TestFixtureTearDown] + public void FixtureTearDown() + { + mutex.ReleaseMutex(); + mutex.Dispose(); + } + [Test] public void Cut() { From 3c808b1b048b8c62f16902d452ee975649d1dedf Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 11 Dec 2010 17:56:45 +0000 Subject: [PATCH 45/88] Fix SD-1793 - ObjectDisposedException in System.Windows.Forms.Integration.WinFormsAdapter --- .../FormsDesigner/Project/Src/DesignerViewContent.cs | 9 +++++++-- src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs index 6d80987781..8c103d1316 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerViewContent.cs @@ -494,8 +494,13 @@ namespace ICSharpCode.FormsDesigner host.Dispose(); return; } - if (host != null && host.Child == value) - return; + if (host != null) { + if (host.IsDisposed) { + host = null; + } else if (host.Child == value) { + return; + } + } if (host == null) { host = new SDWindowsFormsHost(true); host.ServiceObject = this; diff --git a/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs b/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs index 5e8aa8dd81..aeabfff577 100644 --- a/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs +++ b/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs @@ -207,12 +207,15 @@ namespace ICSharpCode.SharpDevelop.Gui /// public bool DisposeChild { get; set; } + public bool IsDisposed { get; private set; } + protected override void Dispose(bool disposing) { if (disposing && !this.DisposeChild && Child != null) { // prevent child from being disposed Child = null; } + IsDisposed = disposing; base.Dispose(disposing); } } From 43a01803db9554656476a9750900b56640e1e4a0 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 11 Dec 2010 18:40:54 +0100 Subject: [PATCH 46/88] Optimize initializing TextDocument. --- .../Document/ITextSource.cs | 29 +++++++++++ .../Document/NewLineFinder.cs | 36 ++++++------- .../Document/TextDocument.cs | 6 +++ .../ICSharpCode.AvalonEdit/Utils/CharRope.cs | 50 +++++++++++++++++-- .../Utils/ImmutableStack.cs | 7 +++ .../ICSharpCode.AvalonEdit/Utils/Rope.cs | 13 ++--- .../ICSharpCode.AvalonEdit/Utils/RopeNode.cs | 2 +- .../Project/Src/Editor/DocumentUtilitites.cs | 13 +++++ src/Main/StartUp/Project/StartUp.csproj | 1 + 9 files changed, 123 insertions(+), 34 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextSource.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextSource.cs index a7f7b6c610..dd32422401 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextSource.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/ITextSource.cs @@ -43,6 +43,15 @@ namespace ICSharpCode.AvalonEdit.Document /// it doesn't require creating a String object. char GetCharAt(int offset); + /// + /// Gets the index of the first occurrence of any character in the specified array. + /// + /// + /// Start index of the search. + /// Length of the area to search. + /// The first index where any character was found; or -1 if no occurrence was found. + int IndexOfAny(char[] anyOf, int startIndex, int count); + /// /// Retrieves the text for a portion of the document. /// @@ -148,6 +157,14 @@ namespace ICSharpCode.AvalonEdit.Document { return CreateSnapshot().CreateReader(); } + + /// + public int IndexOfAny(char[] anyOf, int startIndex, int count) + { + int offset = viewedSegment.Offset; + int result = baseTextSource.IndexOfAny(anyOf, startIndex + offset, count); + return result >= 0 ? result - offset : result; + } } /// @@ -212,6 +229,12 @@ namespace ICSharpCode.AvalonEdit.Document { return new StringTextSource(text.Substring(offset, length)); } + + /// + public int IndexOfAny(char[] anyOf, int startIndex, int count) + { + return text.IndexOfAny(anyOf, startIndex, count); + } } /// @@ -287,5 +310,11 @@ namespace ICSharpCode.AvalonEdit.Document { return new RopeTextSource(rope.GetRange(offset, length)); } + + /// + public int IndexOfAny(char[] anyOf, int startIndex, int count) + { + return rope.IndexOfAny(anyOf, startIndex, count); + } } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/NewLineFinder.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/NewLineFinder.cs index ee2c118b7c..29b2aa8cdf 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/NewLineFinder.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/NewLineFinder.cs @@ -10,24 +10,21 @@ namespace ICSharpCode.AvalonEdit.Document { static class NewLineFinder { + static readonly char[] newline = { '\r', '\n' }; + /// /// Gets the location of the next new line character, or SimpleSegment.Invalid /// if none is found. /// internal static SimpleSegment NextNewLine(string text, int offset) { - for (int i = offset; i < text.Length; i++) { - switch (text[i]) { - case '\r': - if (i + 1 < text.Length) { - if (text[i + 1] == '\n') { - return new SimpleSegment(i, 2); - } - } - goto case '\n'; - case '\n': - return new SimpleSegment(i, 1); + int pos = text.IndexOfAny(newline, offset); + if (pos >= 0) { + if (text[pos] == '\r') { + if (pos + 1 < text.Length && text[pos + 1] == '\n') + return new SimpleSegment(pos, 2); } + return new SimpleSegment(pos, 1); } return SimpleSegment.Invalid; } @@ -39,18 +36,13 @@ namespace ICSharpCode.AvalonEdit.Document internal static SimpleSegment NextNewLine(ITextSource text, int offset) { int textLength = text.TextLength; - for (int i = offset; i < textLength; i++) { - switch (text.GetCharAt(i)) { - case '\r': - if (i + 1 < textLength) { - if (text.GetCharAt(i + 1) == '\n') { - return new SimpleSegment(i, 2); - } - } - goto case '\n'; - case '\n': - return new SimpleSegment(i, 1); + int pos = text.IndexOfAny(newline, offset, textLength - offset); + if (pos >= 0) { + if (text.GetCharAt(pos) == '\r') { + if (pos + 1 < textLength && text.GetCharAt(pos + 1) == '\n') + return new SimpleSegment(pos, 2); } + return new SimpleSegment(pos, 1); } return SimpleSegment.Invalid; } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs index e2db61ef12..86dc81848d 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs @@ -155,6 +155,12 @@ namespace ICSharpCode.AvalonEdit.Document return GetText(segment.Offset, segment.Length); } + int ITextSource.IndexOfAny(char[] anyOf, int startIndex, int count) + { + DebugVerifyAccess(); // frequently called (NewLineFinder), so must be fast in release builds + return rope.IndexOfAny(anyOf, startIndex, count); + } + /// public char GetCharAt(int offset) { diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/CharRope.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/CharRope.cs index bd95ad9e61..2903cb680b 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/CharRope.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/CharRope.cs @@ -93,16 +93,22 @@ namespace ICSharpCode.AvalonEdit.Utils internal static RopeNode InitFromString(string text) { - char[] arr = text.ToCharArray(); - return RopeNode.CreateFromArray(arr, 0, arr.Length); - /* if (text.Length == 0) { return RopeNode.emptyRopeNode; } RopeNode node = RopeNode.CreateNodes(text.Length); - // TODO: store data + FillNode(node, text, 0); return node; - */ + } + + static void FillNode(RopeNode node, string text, int start) + { + if (node.contents != null) { + text.CopyTo(start, node.contents, 0, node.length); + } else { + FillNode(node.left, text, start); + FillNode(node.right, text, start + node.left.length); + } } internal static void WriteTo(this RopeNode node, int index, StringBuilder output, int count) @@ -128,5 +134,39 @@ namespace ICSharpCode.AvalonEdit.Utils } } } + + /// + /// Gets the index of the first occurrence of any element in the specified array. + /// + /// The target rope. + /// Array of characters being searched. + /// Start index of the search. + /// Length of the area to search. + /// The first index where any character was found; or -1 if no occurrence was found. + public static int IndexOfAny(this Rope rope, char[] anyOf, int startIndex, int length) + { + if (rope == null) + throw new ArgumentNullException("rope"); + if (anyOf == null) + throw new ArgumentNullException("anyOf"); + rope.VerifyRange(startIndex, length); + + while (length > 0) { + var entry = rope.FindNodeUsingCache(startIndex).UnsafePeek(); + char[] contents = entry.node.contents; + int startWithinNode = startIndex - entry.nodeStartIndex; + int nodeLength = Math.Min(entry.node.length, startWithinNode + length); + for (int i = startIndex - entry.nodeStartIndex; i < nodeLength; i++) { + char element = contents[i]; + foreach (char needle in anyOf) { + if (element == needle) + return entry.nodeStartIndex + i; + } + } + length -= nodeLength - startWithinNode; + startIndex = entry.nodeStartIndex + nodeLength; + } + return -1; + } } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/ImmutableStack.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/ImmutableStack.cs index a8cdafd6ba..e46b415763 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/ImmutableStack.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/ImmutableStack.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Text; namespace ICSharpCode.AvalonEdit.Utils @@ -57,6 +58,12 @@ namespace ICSharpCode.AvalonEdit.Utils return value; } + internal T UnsafePeek() + { + Debug.Assert(!IsEmpty); + return value; + } + /// /// Gets the stack with the top item removed. /// diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs index e0d0ce2062..90f4b9cb75 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs @@ -407,7 +407,7 @@ namespace ICSharpCode.AvalonEdit.Utils } #region Caches / Changed event - struct RopeCacheEntry + internal struct RopeCacheEntry { internal readonly RopeNode node; internal readonly int nodeStartIndex; @@ -451,7 +451,7 @@ namespace ICSharpCode.AvalonEdit.Utils if (unchecked((uint)index >= (uint)this.Length)) { throw new ArgumentOutOfRangeException("index", index, "0 <= index < " + this.Length.ToString(CultureInfo.InvariantCulture)); } - RopeCacheEntry entry = FindNodeUsingCache(index).Peek(); + RopeCacheEntry entry = FindNodeUsingCache(index).UnsafePeek(); return entry.node.contents[index - entry.nodeStartIndex]; } set { @@ -500,7 +500,7 @@ namespace ICSharpCode.AvalonEdit.Utils } } - ImmutableStack FindNodeUsingCache(int index) + internal ImmutableStack FindNodeUsingCache(int index) { Debug.Assert(index >= 0 && index < this.Length); @@ -511,10 +511,10 @@ namespace ICSharpCode.AvalonEdit.Utils if (stack == null) { stack = ImmutableStack.Empty.Push(new RopeCacheEntry(root, 0)); } - while (!stack.Peek().IsInside(index)) + while (!stack.UnsafePeek().IsInside(index)) stack = stack.Pop(); while (true) { - RopeCacheEntry entry = stack.Peek(); + RopeCacheEntry entry = stack.UnsafePeek(); // check if we've reached a leaf or function node if (entry.node.height == 0) { if (entry.node.contents == null) { @@ -622,9 +622,10 @@ namespace ICSharpCode.AvalonEdit.Utils /// public int IndexOf(T item) { + var comparer = EqualityComparer.Default; int index = 0; foreach (T element in this) { - if (object.Equals(item, element)) + if (comparer.Equals(item, element)) return index; index++; } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/RopeNode.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/RopeNode.cs index ce1c26f776..68b10de2c5 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/RopeNode.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/RopeNode.cs @@ -121,7 +121,7 @@ namespace ICSharpCode.AvalonEdit.Utils return node.StoreElements(0, arr, index, length); } - static RopeNode CreateNodes(int totalLength) + internal static RopeNode CreateNodes(int totalLength) { int leafCount = (totalLength + NodeSize - 1) / NodeSize; return CreateNodes(leafCount, totalLength); diff --git a/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs b/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs index 5ab816cee9..a0a3a07997 100644 --- a/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs +++ b/src/Main/Base/Project/Src/Editor/DocumentUtilitites.cs @@ -265,6 +265,19 @@ namespace ICSharpCode.SharpDevelop.Editor { return GetTextSource(textBuffer.CreateSnapshot(offset, length)); } + + public int IndexOfAny(char[] anyOf, int startIndex, int count) + { + int endIndex = startIndex + count; + for (int i = startIndex; i < endIndex; i++) { + char c = textBuffer.GetCharAt(i); + foreach (char d in anyOf) { + if (c == d) + return i; + } + } + return -1; + } } #endregion } diff --git a/src/Main/StartUp/Project/StartUp.csproj b/src/Main/StartUp/Project/StartUp.csproj index bca99d3a1b..9fb7e3627f 100644 --- a/src/Main/StartUp/Project/StartUp.csproj +++ b/src/Main/StartUp/Project/StartUp.csproj @@ -78,6 +78,7 @@ + {2748AD25-9C63-4E12-877B-4DCE96FBED54} ICSharpCode.SharpDevelop From b62ec44d371f10a2b540d403ecfb9a63589beae2 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 11 Dec 2010 21:01:17 +0100 Subject: [PATCH 47/88] Fixed performance issue when scrolling down for the first time in a long document. The Highlighter is calling OnHighlightStateChanged() once for each line in the document when the highlighting is initialized for the first time. For each of those calls, we were calling Redraw() to invalidate the following line. Now we avoid these unnecessary Redraw() calls by ignoring all OnHighlightStateChanged() calls for all 'scanned' lines (all lines other than the one currently being colorized). --- .../Highlighting/DocumentHighlighter.cs | 1 + .../Highlighting/HighlightingColorizer.cs | 27 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs index 759eada8eb..f863f6cb7d 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/DocumentHighlighter.cs @@ -114,6 +114,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting /// /// The line to highlight. /// A line object that represents the highlighted sections. + [ObsoleteAttribute("Use the (int lineNumber) overload instead")] public HighlightedLine HighlightLine(DocumentLine line) { if (!document.Lines.Contains(line)) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs index 2c74cd10c2..ecebe980a4 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Highlighting/HighlightingColorizer.cs @@ -68,7 +68,7 @@ namespace ICSharpCode.AvalonEdit.Highlighting /// protected virtual IHighlighter CreateHighlighter(TextView textView, TextDocument document) { - return new TextViewDocumentHighlighter(textView, document, ruleSet); + return new TextViewDocumentHighlighter(this, textView, document, ruleSet); } /// @@ -98,7 +98,9 @@ namespace ICSharpCode.AvalonEdit.Highlighting // This is necessary in case the document gets modified above the FirstLineInView so that the highlighting state changes. // We need to detect this case and issue a redraw (through TextViewDocumentHighligher.OnHighlightStateChanged) // before the visual line construction reuses existing lines that were built using the invalid highlighting state. - highlighter.GetSpanStack(e.FirstLineInView.LineNumber - 1); + lineNumberBeingColorized = e.FirstLineInView.LineNumber - 1; + highlighter.GetSpanStack(lineNumberBeingColorized); + lineNumberBeingColorized = 0; } } @@ -116,18 +118,24 @@ namespace ICSharpCode.AvalonEdit.Highlighting // (e.g. when the line ends with a fold marker). // But even if we didn't highlight it, we'll have to update the highlighting state for it so that the // proof inside TextViewDocumentHighlighter.OnHighlightStateChanged holds. - highlighter.GetSpanStack(context.VisualLine.LastDocumentLine.LineNumber); + lineNumberBeingColorized = context.VisualLine.LastDocumentLine.LineNumber; + highlighter.GetSpanStack(lineNumberBeingColorized); + lineNumberBeingColorized = 0; } } this.lastColorizedLine = null; } + int lineNumberBeingColorized; + /// protected override void ColorizeLine(DocumentLine line) { IHighlighter highlighter = CurrentContext.TextView.Services.GetService(typeof(IHighlighter)) as IHighlighter; if (highlighter != null) { - HighlightedLine hl = highlighter.HighlightLine(line.LineNumber); + lineNumberBeingColorized = line.LineNumber; + HighlightedLine hl = highlighter.HighlightLine(lineNumberBeingColorized); + lineNumberBeingColorized = 0; foreach (HighlightedSection section in hl.Sections) { ChangeLinePart(section.Offset, section.Offset + section.Length, visualLineElement => ApplyColorToElement(visualLineElement, section.Color)); @@ -167,18 +175,27 @@ namespace ICSharpCode.AvalonEdit.Highlighting /// sealed class TextViewDocumentHighlighter : DocumentHighlighter { + readonly HighlightingColorizer colorizer; readonly TextView textView; - public TextViewDocumentHighlighter(TextView textView, TextDocument document, HighlightingRuleSet baseRuleSet) + public TextViewDocumentHighlighter(HighlightingColorizer colorizer, TextView textView, TextDocument document, HighlightingRuleSet baseRuleSet) : base(document, baseRuleSet) { + Debug.Assert(colorizer != null); Debug.Assert(textView != null); + this.colorizer = colorizer; this.textView = textView; } protected override void OnHighlightStateChanged(DocumentLine line, int lineNumber) { base.OnHighlightStateChanged(line, lineNumber); + if (colorizer.lineNumberBeingColorized != lineNumber) { + // Ignore notifications for any line except the one we're interested in. + // This improves the performance as Redraw() can take quite some time when called repeatedly + // while scanning the document (above the visible area) for highlighting changes. + return; + } if (textView.Document != this.Document) { // May happen if document on text view was changed but some user code is still using the // existing IHighlighter instance. From 3e13c25cb17b411be5bbe0078cfa010036f04bd4 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 11 Dec 2010 21:10:21 +0100 Subject: [PATCH 48/88] Fixed performance issue in Ctrl-Space completion. --- .../Project/Src/CtrlSpaceResolveHelper.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs index 473b422cf2..11671b10fa 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs @@ -108,17 +108,19 @@ namespace ICSharpCode.SharpDevelop.Dom if (callingClass == null) { return; } + // use HashSet so that Contains lookups are possible in O(1). + HashSet existingResults = new HashSet(result); string[] namespaceParts = callingClass.Namespace.Split('.'); for (int i = 1; i <= namespaceParts.Length; i++) { foreach (ICompletionEntry member in projectContent.GetNamespaceContents(string.Join(".", namespaceParts, 0, i))) { - if (!result.Contains(member)) + if (!existingResults.Contains(member)) result.Add(member); } } IClass currentClass = callingClass; do { foreach (IClass innerClass in currentClass.GetCompoundClass().GetAccessibleTypes(currentClass)) { - if (!result.Contains(innerClass)) + if (!existingResults.Contains(innerClass)) result.Add(innerClass); } currentClass = currentClass.DeclaringType; From be8c299f6ae26cf6f52e60a2d106527a1a6009ad Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 11 Dec 2010 20:51:54 +0000 Subject: [PATCH 49/88] WPF designer now looks in project references for assemblies when opening the designer. --- .../WpfDesign.AddIn/Src/MyTypeFinder.cs | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs index 67b37d4335..507b8215d6 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs @@ -33,19 +33,33 @@ namespace ICSharpCode.WpfDesign.AddIn } return null; } else { - // Load any other assembly from the solution. - foreach(var project in ProjectService.OpenSolution.Projects) { - if(project.AssemblyName==name) { - var pc = ParserService.GetProjectContent(project); - if (pc != null) - return this.typeResolutionService.LoadAssembly(pc); - } - + Assembly assembly = FindAssemblyInProjectReferences(name); + if (assembly != null) { + return assembly; } return base.LoadAssembly(name); } } + Assembly FindAssemblyInProjectReferences(string name) + { + IProjectContent pc = GetProjectContent(file); + if (pc != null) { + return FindAssemblyInProjectReferences(pc, name); + } + return null; + } + + Assembly FindAssemblyInProjectReferences(IProjectContent pc, string name) + { + foreach (IProjectContent referencedProjectContent in pc.ReferencedContents) { + if (name == referencedProjectContent.AssemblyName) { + return this.typeResolutionService.LoadAssembly(referencedProjectContent); + } + } + return null; + } + public override XamlTypeFinder Clone() { MyTypeFinder copy = new MyTypeFinder(); From 4ca5aa4757f5f0e0639d630880042db5e0324fe0 Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Sun, 12 Dec 2010 01:56:08 +0200 Subject: [PATCH 50/88] Center the geometry of the builder --- .../Rendering/BackgroundGeometryBuilder.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/BackgroundGeometryBuilder.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/BackgroundGeometryBuilder.cs index c0f5a4e149..505f966ed8 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/BackgroundGeometryBuilder.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/BackgroundGeometryBuilder.cs @@ -56,16 +56,16 @@ namespace ICSharpCode.AvalonEdit.Rendering foreach (Rect r in GetRectsForSegment(textView, segment)) { if (AlignToWholePixels) { AddRectangle(PixelSnapHelpers.Round(r.Left, pixelSize.Width), - PixelSnapHelpers.Round(r.Top, pixelSize.Height), + PixelSnapHelpers.Round(r.Top + 1, pixelSize.Height), PixelSnapHelpers.Round(r.Right, pixelSize.Width), - PixelSnapHelpers.Round(r.Bottom, pixelSize.Height)); + PixelSnapHelpers.Round(r.Bottom + 1, pixelSize.Height)); } else if (AlignToMiddleOfPixels) { AddRectangle(PixelSnapHelpers.PixelAlign(r.Left, pixelSize.Width), - PixelSnapHelpers.PixelAlign(r.Top, pixelSize.Height), + PixelSnapHelpers.PixelAlign(r.Top + 1, pixelSize.Height), PixelSnapHelpers.PixelAlign(r.Right, pixelSize.Width), - PixelSnapHelpers.PixelAlign(r.Bottom, pixelSize.Height)); + PixelSnapHelpers.PixelAlign(r.Bottom + 1, pixelSize.Height)); } else { - AddRectangle(r.Left, r.Top, r.Right, r.Bottom); + AddRectangle(r.Left, r.Top + 1, r.Right, r.Bottom + 1); } } } From 77bb7ced641af7901109cd684d1a3fa0a1406141 Mon Sep 17 00:00:00 2001 From: peterforstmeier Date: Sun, 12 Dec 2010 19:53:38 +0100 Subject: [PATCH 51/88] File/Preview and File/Print use Exporter#s (same as in ReportViewer), the standard print code (Renderer's) will not be further developed --- .../Project/Commands/PreviewCommands.cs | 32 +++---- .../Project/ReportDesignerView.cs | 89 ++++++++++--------- .../ReportViewerSecondaryView.cs | 6 +- .../ExportRenderer/BaseExportRenderer.cs | 3 + .../ExportRenderer/PreviewRenderer.cs | 19 ++-- .../Exporter/ExportRenderer/PrintRenderer.cs | 26 +++--- 6 files changed, 89 insertions(+), 86 deletions(-) diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/PreviewCommands.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/PreviewCommands.cs index ba2a4fbe27..94af309b46 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/PreviewCommands.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Commands/PreviewCommands.cs @@ -11,8 +11,6 @@ namespace ICSharpCode.Reports.Addin.Commands public class AbstractPreviewCommand :AbstractCommand { - ReportModel model; - ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer; public AbstractPreviewCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer) { @@ -23,31 +21,29 @@ namespace ICSharpCode.Reports.Addin.Commands throw new ArgumentNullException("reportViewer"); } - this.model = model; - this.reportViewer = reportViewer; + this.Model = model; + this.ReportViewer = reportViewer; } public override void Run() { - CollectParametersCommand sql = new CollectParametersCommand(model); - sql.Run(); + CollectParametersCommand cmd = new CollectParametersCommand(Model); + cmd.Run(); } - public ICSharpCode.Reports.Core.ReportViewer.PreviewControl ReportViewer { - get { return reportViewer; } - } + public ICSharpCode.Reports.Core.ReportViewer.PreviewControl ReportViewer {get;private set;} + + + public ReportModel Model {get;private set;} - public ReportModel Model { - get { return this.model; } - } } - public class FormsSheetPreviewCommand:AbstractPreviewCommand + public class FormSheetToReportViewerCommand:AbstractPreviewCommand { - public FormsSheetPreviewCommand(ReportModel model, + public FormSheetToReportViewerCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) { } @@ -60,10 +56,10 @@ namespace ICSharpCode.Reports.Addin.Commands } - public class PullModelPreviewCommand:AbstractPreviewCommand + public class PullModelToReportViewerCommand:AbstractPreviewCommand { - public PullModelPreviewCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) + public PullModelToReportViewerCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) { } @@ -76,9 +72,9 @@ namespace ICSharpCode.Reports.Addin.Commands } - public class PushModelPreviewCommand:AbstractPreviewCommand + public class PushModelToReportViewerCommand:AbstractPreviewCommand { - public PushModelPreviewCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) + public PushModelToReportViewerCommand(ReportModel model, ICSharpCode.Reports.Core.ReportViewer.PreviewControl reportViewer):base (model,reportViewer) { } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs index 7b6cc3f4f5..3fd44c3a72 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs @@ -5,14 +5,20 @@ using System; using System.Collections; using System.ComponentModel.Design; using System.ComponentModel.Design.Serialization; +using System.Data; using System.Drawing.Design; +using System.Drawing.Printing; using System.IO; using System.Text; using System.Windows.Forms; using ICSharpCode.Core; +using ICSharpCode.Reports.Addin.Commands; using ICSharpCode.Reports.Addin.Designer; using ICSharpCode.Reports.Core; +using ICSharpCode.Reports.Core.BaseClasses.Printing; +using ICSharpCode.Reports.Core.Exporter; +using ICSharpCode.Reports.Core.Exporter.ExportRenderer; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Gui; @@ -557,52 +563,51 @@ namespace ICSharpCode.Reports.Addin #region IPrintable - private void ccc() - { - /* - ReportModel model = loader.CreateRenderableModel(); - IReportCreator creator = ReportEngine.CreatePageBuilder(model,eventLogger.EventLog,null); - //creator.SectionRendering += PushPrinting; - creator.BuildExportList(); - using (PdfRenderer pdfRenderer = PdfRenderer.CreateInstance(creator,SelectFilename(),true)) - { - pdfRenderer.Start(); - pdfRenderer.RenderOutput(); - pdfRenderer.End(); - } - */ - - var model = loader.CreateRenderableModel(); - switch (model.DataModel) { - case GlobalEnums.PushPullModel.FormSheet : { - //cmd = new FormsSheetPreviewCommand (model,control); - break; - } - case GlobalEnums.PushPullModel.PullData:{ - //cmd = new PullModelPreviewCommand(model,control); - break; - } - case GlobalEnums.PushPullModel.PushData:{ - //cmd = new PushModelPreviewCommand(model,control); - break; - } - default: - throw new InvalidReportModelException(); - } - } - - - public System.Drawing.Printing.PrintDocument PrintDocument { + + public PrintDocument PrintDocument + { get { - ccc(); - ICSharpCode.Reports.Core.ReportModel model = this.loader.CreateRenderableModel(); - StandartPreviewManager reportManager = new StandartPreviewManager(); - ICSharpCode.Reports.Core.AbstractRenderer r = reportManager.CreateRenderer (model); - return r.ReportDocument; + ReportModel model = loader.CreateRenderableModel(); + IReportCreator reportCreator = null; + Layouter layouter = new Layouter(); + var c = new CollectParametersCommand(model); + c.Run(); + switch (model.DataModel) { + case GlobalEnums.PushPullModel.FormSheet : + { + reportCreator = FormPageBuilder.CreateInstance(model,layouter); + break; + } + case GlobalEnums.PushPullModel.PullData: + { + + IDataManager dataManager = DataManagerFactory.CreateDataManager(model,(ReportParameters)null); + reportCreator = DataPageBuilder.CreateInstance(model,dataManager,layouter); + break; + } + case GlobalEnums.PushPullModel.PushData:{ + ICSharpCode.Reports.Addin.Commands.DataSetFromXsdCommand cmd = + new ICSharpCode.Reports.Addin.Commands.DataSetFromXsdCommand(); + cmd.Run(); + DataSet ds = cmd.DataSet; + IDataManager dataManager = DataManagerFactory.CreateDataManager(model,ds.Tables[0]); + reportCreator = DataPageBuilder.CreateInstance(model,dataManager,layouter); + break; + } + default: + throw new InvalidReportModelException(); + } + + reportCreator.BuildExportList(); + PrintRenderer printer = PrintRenderer.CreateInstance(reportCreator.Pages); + printer.Start(); + printer.RenderOutput(); + printer.End(); + return printer.PrintDocument; } } - + #endregion diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/ReportViewerSecondaryView.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/ReportViewerSecondaryView.cs index cac5e2eb61..825cbfaef2 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/ReportViewerSecondaryView.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/SecondaryViews/ReportViewerSecondaryView.cs @@ -50,15 +50,15 @@ namespace ICSharpCode.Reports.Addin AbstractPreviewCommand cmd = null; switch (model.DataModel) { case GlobalEnums.PushPullModel.FormSheet : { - cmd = new FormsSheetPreviewCommand (model,control); + cmd = new FormSheetToReportViewerCommand (model,control); break; } case GlobalEnums.PushPullModel.PullData:{ - cmd = new PullModelPreviewCommand(model,control); + cmd = new PullModelToReportViewerCommand(model,control); break; } case GlobalEnums.PushPullModel.PushData:{ - cmd = new PushModelPreviewCommand(model,control); + cmd = new PushModelToReportViewerCommand(model,control); break; } default: diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/BaseExportRenderer.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/BaseExportRenderer.cs index 963f3de630..f219aa2de0 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/BaseExportRenderer.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/BaseExportRenderer.cs @@ -11,6 +11,7 @@ namespace ICSharpCode.Reports.Core.Exporter.ExportRenderer{ /// /// public class BaseExportRenderer{ + PagesCollection pages; public BaseExportRenderer () @@ -46,6 +47,7 @@ namespace ICSharpCode.Reports.Core.Exporter.ExportRenderer{ { } + public virtual void RenderOutput () { } @@ -54,6 +56,7 @@ namespace ICSharpCode.Reports.Core.Exporter.ExportRenderer{ { } + public PagesCollection Pages { get {if (this.pages == null) { diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/PreviewRenderer.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/PreviewRenderer.cs index ec4b775058..d5162d7f64 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/PreviewRenderer.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/PreviewRenderer.cs @@ -11,10 +11,8 @@ namespace ICSharpCode.Reports.Core.Exporter.ExportRenderer /// - public class PreviewRenderer:BaseExportRenderer + internal class PreviewRenderer:BaseExportRenderer { - Graphics graphics; - ExporterPage page; #region Constructor @@ -29,23 +27,18 @@ namespace ICSharpCode.Reports.Core.Exporter.ExportRenderer public override void RenderOutput(){ base.RenderOutput(); - if (this.graphics != null) { - BaseExportRenderer.DrawItems(this.graphics,this.page.Items); + if (this.Graphics != null) { + BaseExportRenderer.DrawItems(this.Graphics,this.Page.Items); } else { return; } } - public Graphics Graphics { - get { return this.graphics;} - set { this.graphics = value;} - } + public Graphics Graphics {get;set;} + - public ExporterPage Page { - get {return this.page;} - set { page = value; } - } + public ExporterPage Page {get;set;} } } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/PrintRenderer.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/PrintRenderer.cs index ccf877fafe..7e05a601a3 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/PrintRenderer.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportRenderer/PrintRenderer.cs @@ -10,7 +10,7 @@ namespace ICSharpCode.Reports.Core.Exporter.ExportRenderer{ /// Description of PrintRenderer. /// public class PrintRenderer:BaseExportRenderer,IDisposable{ - PrintDocument doc; + int currentPage; PrinterSettings printerSettings; @@ -43,11 +43,14 @@ namespace ICSharpCode.Reports.Core.Exporter.ExportRenderer{ private PrintRenderer(PagesCollection pages):base(pages) { - doc = new PrintDocument(); + this.PrintDocument = new PrintDocument(); + this.PrintDocument.PrinterSettings = new PrinterSettings(); + + // doc.QueryPageSettings += new QueryPageSettingsEventHandler(OnQueryPage); - doc.BeginPrint += new PrintEventHandler(OnBeginPrint); - doc.EndPrint += new PrintEventHandler(OnEndPrint); - doc.PrintPage += new PrintPageEventHandler(OnPrintPage); + this.PrintDocument.BeginPrint += new PrintEventHandler(OnBeginPrint); + this.PrintDocument.EndPrint += new PrintEventHandler(OnEndPrint); + this.PrintDocument.PrintPage += new PrintPageEventHandler(OnPrintPage); } #endregion @@ -87,22 +90,25 @@ namespace ICSharpCode.Reports.Core.Exporter.ExportRenderer{ { base.RenderOutput(); if (this.printerSettings != null) { - doc.PrinterSettings = this.printerSettings; + this.PrintDocument.PrinterSettings = this.printerSettings; } - doc.Print(); } + public override void End() { base.End(); } + public PrintDocument PrintDocument {get;private set;} + internal PrinterSettings PrinterSettings { set { printerSettings = value; } } + #region IDisposable public void Dispose() @@ -116,10 +122,10 @@ namespace ICSharpCode.Reports.Core.Exporter.ExportRenderer{ if (disposing) { // free managed resources - if (this.doc != null) + if (this.PrintDocument != null) { - doc.Dispose(); - doc = null; + this.PrintDocument.Dispose(); + this.PrintDocument = null; } } } From 7b011cf067935ce43d6f42b69960162be7f3acbf Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 13 Dec 2010 17:57:38 +0100 Subject: [PATCH 52/88] Make FoldingManager independent of TextView. This allows using a single FoldingManager in multiple TextViews. --- .../Folding/FoldingElementGenerator.cs | 56 +++++++++++--- .../Folding/FoldingManager.cs | 75 ++++++++++++++++--- .../Folding/FoldingSection.cs | 36 +++++---- .../Rendering/CollapsedLineSection.cs | 10 ++- .../Rendering/TextView.cs | 6 +- 5 files changed, 143 insertions(+), 40 deletions(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs index 40e16b52cd..5168a04100 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingElementGenerator.cs @@ -2,11 +2,11 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Collections.Generic; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.TextFormatting; - using ICSharpCode.AvalonEdit.Rendering; using ICSharpCode.AvalonEdit.Utils; @@ -15,21 +15,57 @@ namespace ICSharpCode.AvalonEdit.Folding /// /// A that produces line elements for folded s. /// - public class FoldingElementGenerator : VisualLineElementGenerator + public sealed class FoldingElementGenerator : VisualLineElementGenerator, ITextViewConnect { + readonly List textViews = new List(); + FoldingManager foldingManager; + + #region FoldingManager property / connecting with TextView /// /// Gets/Sets the folding manager from which the foldings should be shown. /// - public FoldingManager FoldingManager { get; set; } + public FoldingManager FoldingManager { + get { + return foldingManager; + } + set { + if (foldingManager != value) { + if (foldingManager != null) { + foreach (TextView v in textViews) + foldingManager.RemoveFromTextView(v); + } + foldingManager = value; + if (foldingManager != null) { + foreach (TextView v in textViews) + foldingManager.AddToTextView(v); + } + } + } + } + + void ITextViewConnect.AddToTextView(TextView textView) + { + textViews.Add(textView); + if (foldingManager != null) + foldingManager.AddToTextView(textView); + } + + void ITextViewConnect.RemoveFromTextView(TextView textView) + { + textViews.Remove(textView); + if (foldingManager != null) + foldingManager.RemoveFromTextView(textView); + } + #endregion /// public override void StartGeneration(ITextRunConstructionContext context) { base.StartGeneration(context); - if (FoldingManager != null) { - if (context.TextView != FoldingManager.textView) + if (foldingManager != null) { + if (!foldingManager.textViews.Contains(context.TextView)) throw new ArgumentException("Invalid TextView"); - if (context.Document != FoldingManager.document) + if (context.Document != foldingManager.document) throw new ArgumentException("Invalid document"); } } @@ -37,8 +73,8 @@ namespace ICSharpCode.AvalonEdit.Folding /// public override int GetFirstInterestedOffset(int startOffset) { - if (FoldingManager != null) - return FoldingManager.GetNextFoldedFoldingStart(startOffset); + if (foldingManager != null) + return foldingManager.GetNextFoldedFoldingStart(startOffset); else return -1; } @@ -46,11 +82,11 @@ namespace ICSharpCode.AvalonEdit.Folding /// public override VisualLineElement ConstructElement(int offset) { - if (FoldingManager == null) + if (foldingManager == null) return null; int foldedUntil = -1; FoldingSection foldingSection = null; - foreach (FoldingSection fs in FoldingManager.GetFoldingsAt(offset)) { + foreach (FoldingSection fs in foldingManager.GetFoldingsAt(offset)) { if (fs.IsFolded) { if (fs.EndOffset > foldedUntil) { foldedUntil = fs.EndOffset; diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs index 7403ab1aab..0dbf278a03 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingManager.cs @@ -20,27 +20,33 @@ namespace ICSharpCode.AvalonEdit.Folding /// public class FoldingManager : IWeakEventListener { - internal readonly TextView textView; internal readonly TextDocument document; + internal readonly List textViews = new List(); readonly TextSegmentCollection foldings; #region Constructor /// /// Creates a new FoldingManager instance. /// - public FoldingManager(TextView textView, TextDocument document) + public FoldingManager(TextDocument document) { - if (textView == null) - throw new ArgumentNullException("textView"); if (document == null) throw new ArgumentNullException("document"); - this.textView = textView; this.document = document; this.foldings = new TextSegmentCollection(); document.VerifyAccess(); TextDocumentWeakEventManager.Changed.AddListener(document, this); } + + /// + /// Creates a new FoldingManager instance. + /// + [Obsolete("Use the (TextDocument) constructor instead.")] + public FoldingManager(TextView textView, TextDocument document) + : this(document) + { + } #endregion #region ReceiveWeakEvent @@ -73,6 +79,57 @@ namespace ICSharpCode.AvalonEdit.Folding } #endregion + #region Manage TextViews + internal void AddToTextView(TextView textView) + { + if (textView == null || textViews.Contains(textView)) + throw new ArgumentException(); + textViews.Add(textView); + foreach (FoldingSection fs in foldings) { + if (fs.collapsedSections != null) { + Array.Resize(ref fs.collapsedSections, textViews.Count); + fs.collapsedSections[fs.collapsedSections.Length - 1] = fs.CollapseSection(textView); + } + } + } + + internal void RemoveFromTextView(TextView textView) + { + int pos = textViews.IndexOf(textView); + if (pos < 0) + throw new ArgumentException(); + foreach (FoldingSection fs in foldings) { + if (fs.collapsedSections != null) { + CollapsedLineSection[] c = new CollapsedLineSection[textViews.Count]; + Array.Copy(fs.collapsedSections, 0, c, 0, pos); + Array.Copy(fs.collapsedSections, pos + 1, c, pos, c.Length - pos); + fs.collapsedSections = c; + } + } + } + + internal CollapsedLineSection[] CollapseLines(DocumentLine start, DocumentLine end) + { + CollapsedLineSection[] c = new CollapsedLineSection[textViews.Count]; + for (int i = 0; i < c.Length; i++) { + c[i] = textViews[i].CollapseLines(start, end); + } + return c; + } + + internal void Redraw() + { + foreach (TextView textView in textViews) + textView.Redraw(); + } + + internal void Redraw(FoldingSection fs) + { + foreach (TextView textView in textViews) + textView.Redraw(fs); + } + #endregion + #region Create / Remove / Clear /// /// Creates a folding for the specified text section. @@ -83,7 +140,7 @@ namespace ICSharpCode.AvalonEdit.Folding throw new ArgumentException("startOffset must be less than endOffset"); FoldingSection fs = new FoldingSection(this, startOffset, endOffset); foldings.Add(fs); - textView.Redraw(fs, DispatcherPriority.Normal); + Redraw(fs); return fs; } @@ -96,7 +153,7 @@ namespace ICSharpCode.AvalonEdit.Folding throw new ArgumentNullException("fs"); fs.IsFolded = false; foldings.Remove(fs); - textView.Redraw(fs, DispatcherPriority.Normal); + Redraw(fs); } /// @@ -108,7 +165,7 @@ namespace ICSharpCode.AvalonEdit.Folding foreach (FoldingSection s in foldings) s.IsFolded = false; foldings.Clear(); - textView.Redraw(); + Redraw(); } #endregion @@ -264,7 +321,7 @@ namespace ICSharpCode.AvalonEdit.Folding FoldingMargin margin; FoldingElementGenerator generator; - public FoldingManagerInstallation(TextArea textArea) : base(textArea.TextView, textArea.Document) + public FoldingManagerInstallation(TextArea textArea) : base(textArea.Document) { this.textArea = textArea; margin = new FoldingMargin() { FoldingManager = this }; diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs index 703ba0813c..7df9196e98 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/FoldingSection.cs @@ -13,9 +13,9 @@ namespace ICSharpCode.AvalonEdit.Folding /// public sealed class FoldingSection : TextSegment { - FoldingManager manager; + readonly FoldingManager manager; bool isFolded; - CollapsedLineSection collapsedSection; + internal CollapsedLineSection[] collapsedSections; string title; /// @@ -32,18 +32,29 @@ namespace ICSharpCode.AvalonEdit.Folding DocumentLine endLine = manager.document.GetLineByOffset(EndOffset); if (startLine != endLine) { DocumentLine startLinePlusOne = startLine.NextLine; - collapsedSection = manager.textView.CollapseLines(startLinePlusOne, endLine); + collapsedSections = manager.CollapseLines(startLinePlusOne, endLine); } } } else { RemoveCollapsedLineSection(); } if (manager != null) - manager.textView.Redraw(this, DispatcherPriority.Normal); + manager.Redraw(this); } } } + internal CollapsedLineSection CollapseSection(TextView textView) + { + DocumentLine startLine = manager.document.GetLineByOffset(StartOffset); + DocumentLine endLine = manager.document.GetLineByOffset(EndOffset); + if (startLine != endLine) { + DocumentLine startLinePlusOne = startLine.NextLine; + return textView.CollapseLines(startLinePlusOne, endLine); + } + return null; + } + /// /// Gets/Sets the text used to display the collapsed version of the folding section. /// @@ -55,7 +66,7 @@ namespace ICSharpCode.AvalonEdit.Folding if (title != value) { title = value; if (this.IsFolded && manager != null) - manager.textView.Redraw(this, DispatcherPriority.Normal); + manager.Redraw(this); } } } @@ -74,16 +85,13 @@ namespace ICSharpCode.AvalonEdit.Folding void RemoveCollapsedLineSection() { - if (collapsedSection != null) { - if (collapsedSection.Start != null) - collapsedSection.Uncollapse(); - collapsedSection = null; + if (collapsedSections != null) { + foreach (var collapsedSection in collapsedSections) { + if (collapsedSection != null && collapsedSection.Start != null) + collapsedSection.Uncollapse(); + } + collapsedSections = null; } } - - internal void Removed() - { - manager = null; - } } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CollapsedLineSection.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CollapsedLineSection.cs index 3c3366e930..35e06f0e16 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CollapsedLineSection.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/CollapsedLineSection.cs @@ -30,7 +30,9 @@ namespace ICSharpCode.AvalonEdit.Rendering this.start = start; this.end = end; #if DEBUG - this.ID = "#" + (nextId++); + unchecked { + this.ID = " #" + (nextId++); + } #endif } @@ -49,7 +51,7 @@ namespace ICSharpCode.AvalonEdit.Rendering /// public DocumentLine Start { get { return start; } - internal set { + internal set { start = value; // TODO: raised property changed event (but only after the operation is complete) } @@ -63,7 +65,7 @@ namespace ICSharpCode.AvalonEdit.Rendering public DocumentLine End { get { return end; } internal set { - end = value; + end = value; // TODO: raised property changed event (but only after the operation is complete) } } @@ -110,7 +112,7 @@ namespace ICSharpCode.AvalonEdit.Rendering [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Int32.ToString")] public override string ToString() { - return "[CollapsedSection " + ID + " Start=" + (start != null ? start.LineNumber.ToString() : "null") + return "[CollapsedSection" + ID + " Start=" + (start != null ? start.LineNumber.ToString() : "null") + " End=" + (end != null ? end.LineNumber.ToString() : "null") + " IsCollapsed=" + isCollapsed + "]"; } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs index 6fbf0b32bf..e08b291714 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs @@ -406,7 +406,7 @@ namespace ICSharpCode.AvalonEdit.Rendering /// /// Causes the text editor to regenerate the specified visual line. /// - public void Redraw(VisualLine visualLine, DispatcherPriority redrawPriority) + public void Redraw(VisualLine visualLine, DispatcherPriority redrawPriority = DispatcherPriority.Normal) { VerifyAccess(); if (allVisualLines.Remove(visualLine)) { @@ -419,7 +419,7 @@ namespace ICSharpCode.AvalonEdit.Rendering /// /// Causes the text editor to redraw all lines overlapping with the specified segment. /// - public void Redraw(int offset, int length, DispatcherPriority redrawPriority) + public void Redraw(int offset, int length, DispatcherPriority redrawPriority = DispatcherPriority.Normal) { VerifyAccess(); bool removedLine = false; @@ -464,7 +464,7 @@ namespace ICSharpCode.AvalonEdit.Rendering /// Causes the text editor to redraw all lines overlapping with the specified segment. /// Does nothing if segment is null. /// - public void Redraw(ISegment segment, DispatcherPriority redrawPriority) + public void Redraw(ISegment segment, DispatcherPriority redrawPriority = DispatcherPriority.Normal) { if (segment != null) { Redraw(segment.Offset, segment.Length, redrawPriority); From 7d42a1dac20156b64de973b7d477bf45233dd19d Mon Sep 17 00:00:00 2001 From: peterforstmeier Date: Mon, 13 Dec 2010 20:03:16 +0100 Subject: [PATCH 53/88] Cleanup --- .../Project/ReportDesignerView.cs | 15 ++++------ .../ICSharpCode.Reports.Core.csproj | 1 - .../Project/Collections/Collections.cs | 1 - .../ListStrategy/BaseListStrategy.cs | 4 +-- .../Project/Exporter/BasePager.cs | 11 ++++--- .../Project/Exporter/DataPageBuilder.cs | 11 +++---- .../Project/Exporter/FormPageBuilder.cs | 7 ++--- .../Interfaces/IHierarchyInterfaces.cs | 30 ------------------- .../Project/ReportEngine.cs | 14 ++++----- .../Project/ReportViewer/ReportViewer.cs | 9 ++---- 10 files changed, 28 insertions(+), 75 deletions(-) delete mode 100644 src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IHierarchyInterfaces.cs diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs index 3fd44c3a72..2ae69f4f10 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/ReportDesignerView.cs @@ -570,29 +570,26 @@ namespace ICSharpCode.Reports.Addin get { ReportModel model = loader.CreateRenderableModel(); IReportCreator reportCreator = null; - Layouter layouter = new Layouter(); - var c = new CollectParametersCommand(model); - c.Run(); + var paramCmd = new CollectParametersCommand(model); + paramCmd.Run(); switch (model.DataModel) { case GlobalEnums.PushPullModel.FormSheet : { - reportCreator = FormPageBuilder.CreateInstance(model,layouter); + reportCreator = FormPageBuilder.CreateInstance(model); break; } case GlobalEnums.PushPullModel.PullData: { - IDataManager dataManager = DataManagerFactory.CreateDataManager(model,(ReportParameters)null); - reportCreator = DataPageBuilder.CreateInstance(model,dataManager,layouter); + reportCreator = DataPageBuilder.CreateInstance(model,dataManager); break; } case GlobalEnums.PushPullModel.PushData:{ - ICSharpCode.Reports.Addin.Commands.DataSetFromXsdCommand cmd = - new ICSharpCode.Reports.Addin.Commands.DataSetFromXsdCommand(); + var cmd = new ICSharpCode.Reports.Addin.Commands.DataSetFromXsdCommand(); cmd.Run(); DataSet ds = cmd.DataSet; IDataManager dataManager = DataManagerFactory.CreateDataManager(model,ds.Tables[0]); - reportCreator = DataPageBuilder.CreateInstance(model,dataManager,layouter); + reportCreator = DataPageBuilder.CreateInstance(model,dataManager); break; } default: diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/ICSharpCode.Reports.Core.csproj b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/ICSharpCode.Reports.Core.csproj index e3d4cc16d1..264bb5786e 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/ICSharpCode.Reports.Core.csproj +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/ICSharpCode.Reports.Core.csproj @@ -252,7 +252,6 @@ - diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Collections/Collections.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Collections/Collections.cs index 84e8a66302..710b951c4d 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Collections/Collections.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Collections/Collections.cs @@ -143,7 +143,6 @@ namespace ICSharpCode.Reports.Core{ protected override void RemoveItem(int index) { - BaseReportItem item = this[index]; base.RemoveItem(index); } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/BaseListStrategy.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/BaseListStrategy.cs index d7ce3cfc6b..dcc7992816 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/BaseListStrategy.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/BaseListStrategy.cs @@ -130,7 +130,7 @@ namespace ICSharpCode.Reports.Core { #endregion #region Debug Code - + /* protected static void ShowIndexList (IndexList list) { @@ -151,7 +151,7 @@ namespace ICSharpCode.Reports.Core { } } } - + */ #endregion public virtual void Reset() diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/BasePager.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/BasePager.cs index 5d28570ad0..f2b726cf33 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/BasePager.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/BasePager.cs @@ -27,16 +27,15 @@ namespace ICSharpCode.Reports.Core.Exporter #region Constructor - public BasePager(IReportModel reportModel,ILayouter layouter) + public BasePager(IReportModel reportModel) { if (reportModel == null) { throw new ArgumentNullException("reportModel"); } - if (layouter == null) { - throw new ArgumentNullException ("layouter"); - } + this.ReportModel = reportModel; - this.Layouter = layouter; + //this.Layouter = layouter; + this.Layouter = new Layouter(); this.Graphics = CreateGraphicObject.FromSize(this.ReportModel.ReportSettings.PageSize); } @@ -210,7 +209,7 @@ namespace ICSharpCode.Reports.Core.Exporter ExportText et = be as ExportText; if (et != null) { - if (et.Text.StartsWith("=")) { + if (et.Text.StartsWith("=",StringComparison.InvariantCulture)) { et.Text = evaluatorFassade.Evaluate(et.Text); } } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/DataPageBuilder.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/DataPageBuilder.cs index 4fcfcb06e5..ed0a7a24ee 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/DataPageBuilder.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/DataPageBuilder.cs @@ -19,8 +19,8 @@ namespace ICSharpCode.Reports.Core.Exporter #region Constructor - - public static IReportCreator CreateInstance(IReportModel reportModel, IDataManager dataManager,ILayouter layouter) + public static IReportCreator CreateInstance(IReportModel reportModel, IDataManager dataManager) +// public static IReportCreator CreateInstance(IReportModel reportModel, IDataManager dataManager,ILayouter layouter) { if (reportModel == null) { throw new ArgumentNullException("reportModel"); @@ -28,15 +28,12 @@ namespace ICSharpCode.Reports.Core.Exporter if (dataManager == null) { throw new ArgumentNullException("dataManager"); } - if (layouter == null) { - throw new ArgumentNullException("layouter"); - } - DataPageBuilder instance = new DataPageBuilder(reportModel,dataManager,layouter); + DataPageBuilder instance = new DataPageBuilder(reportModel,dataManager); return instance; } - private DataPageBuilder (IReportModel reportModel,IDataManager dataManager,ILayouter layouter):base(reportModel,layouter) + private DataPageBuilder (IReportModel reportModel,IDataManager dataManager):base(reportModel) { this.dataManager = dataManager; } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/FormPageBuilder.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/FormPageBuilder.cs index 4bfde611d1..63ec24a5f7 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/FormPageBuilder.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/FormPageBuilder.cs @@ -16,18 +16,17 @@ namespace ICSharpCode.Reports.Core.Exporter #region Constructure - public static FormPageBuilder CreateInstance(IReportModel reportModel,ILayouter layouter) + public static FormPageBuilder CreateInstance(IReportModel reportModel) { if (reportModel == null) { throw new ArgumentNullException("reportModel"); } - - FormPageBuilder instance = new FormPageBuilder(reportModel,layouter); + FormPageBuilder instance = new FormPageBuilder(reportModel); return instance; } - private FormPageBuilder(IReportModel reportModel,ILayouter layouter):base(reportModel,layouter) + private FormPageBuilder(IReportModel reportModel):base(reportModel) { } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IHierarchyInterfaces.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IHierarchyInterfaces.cs deleted file mode 100644 index eae93ece42..0000000000 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IHierarchyInterfaces.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -//ToDo with NET2.0 change this Interface to the one provided by NET2.0 -using System; - -namespace ICSharpCode.Reports.Core { - - public interface IHierarchyData{ - - IndexList GetChildren { - get; - } - - bool HasChildren { - get; - } - - object Item { - get; - } - string Path { - get; - } - - string Type { - get; - } - } -} diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportEngine.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportEngine.cs index 19ef6c3279..5d9957e2d6 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportEngine.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportEngine.cs @@ -469,13 +469,12 @@ namespace ICSharpCode.Reports.Core { IReportModel reportModel = LoadReportModel (fileName); IReportCreator builder = null; - Layouter layouter = new Layouter(); if (reportModel.DataModel == GlobalEnums.PushPullModel.FormSheet) { - builder = FormPageBuilder.CreateInstance(reportModel,layouter); + builder = FormPageBuilder.CreateInstance(reportModel); } else { CheckForParameters(reportModel,reportParameters); IDataManager dataMan = DataManagerFactory.CreateDataManager(reportModel,reportParameters); - builder = DataPageBuilder.CreateInstance(reportModel, dataMan,layouter); + builder = DataPageBuilder.CreateInstance(reportModel, dataMan); } return builder; } @@ -493,8 +492,7 @@ namespace ICSharpCode.Reports.Core { throw new ArgumentNullException("reportModel"); } IDataManager dataMan = DataManagerFactory.CreateDataManager(reportModel,(ReportParameters)null); - Layouter layouter = new Layouter(); - IReportCreator builder = DataPageBuilder.CreateInstance(reportModel, dataMan,layouter); + IReportCreator builder = DataPageBuilder.CreateInstance(reportModel, dataMan); return builder; } @@ -543,8 +541,7 @@ namespace ICSharpCode.Reports.Core { IDataManager dataMan = DataManager.CreateInstance(dataTable,reportModel.ReportSettings); if (dataMan != null) { - Layouter layouter = new Layouter(); - return DataPageBuilder.CreateInstance(reportModel, dataMan,layouter); + return DataPageBuilder.CreateInstance(reportModel, dataMan); } else { throw new MissingDataManagerException(); } @@ -571,8 +568,7 @@ namespace ICSharpCode.Reports.Core { ReportEngine.CheckForParameters(reportModel,reportParameters); IDataManager dataMan = DataManager.CreateInstance(list,reportModel.ReportSettings); if (dataMan != null) { - Layouter layouter = new Layouter(); - return DataPageBuilder.CreateInstance(reportModel,dataMan,layouter); + return DataPageBuilder.CreateInstance(reportModel,dataMan); } else { throw new MissingDataManagerException(); } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs index c506297df9..298990622d 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/ReportViewer/ReportViewer.cs @@ -151,9 +151,7 @@ namespace ICSharpCode.Reports.Core.ReportViewer private void RunFormSheet (ReportModel reportModel) { - - Layouter layouter = new Layouter(); - IReportCreator reportCreator = FormPageBuilder.CreateInstance(reportModel,layouter); + IReportCreator reportCreator = FormPageBuilder.CreateInstance(reportModel); reportCreator.SectionRendering += new EventHandler(PushPrinting); reportCreator.PageCreated += OnPageCreated; reportCreator.BuildExportList(); @@ -163,8 +161,7 @@ namespace ICSharpCode.Reports.Core.ReportViewer private void RunDataReport (ReportModel reportModel,IDataManager data) { - ILayouter layouter = new Layouter(); - IReportCreator reportCreator = DataPageBuilder.CreateInstance(reportModel,data,layouter); + IReportCreator reportCreator = DataPageBuilder.CreateInstance(reportModel,data); reportCreator.SectionRendering += new EventHandler(PushPrinting); reportCreator.GroupHeaderRendering += new EventHandler(GroupHeaderRendering); reportCreator.GroupFooterRendering += GroupFooterRendering; @@ -195,7 +192,7 @@ namespace ICSharpCode.Reports.Core.ReportViewer private void PushPrinting (object sender,SectionRenderEventArgs e) { - string sectionName = e.Section.Name; +// string sectionName = e.Section.Name; /* if (sectionName == ReportSectionNames.ReportHeader) { Console.WriteLine("PushPrinting :" + ReportSectionNames.ReportHeader); From 0a986b486a4caef57c4b3548c6822929b46c711d Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Mon, 13 Dec 2010 23:29:16 +0200 Subject: [PATCH 54/88] Collapse all in project browser pad and class browser pad --- data/resources/StringResources.resx | 3 +++ .../image/BitmapResources/BitmapResources.res | 1 + .../ProjectBrowserIcons/Toolbar.Collapse.png | Bin 0 -> 1420 bytes .../Project/ICSharpCode.SharpDevelop.addin | 10 ++++++++++ .../Src/Gui/Pads/ClassBrowser/ClassBrowser.cs | 10 ++++++++++ .../ClassBrowserToolbarCommands.cs | 11 +++++++++++ .../Commands/ToolbarCommands.cs | 8 ++++++++ .../ProjectBrowser/ProjectBrowserControl.cs | 17 +++++++++++++++++ .../Resources/BitmapResources.resources | Bin 654336 -> 655255 bytes 9 files changed, 60 insertions(+) create mode 100644 data/resources/image/BitmapResources/ProjectBrowserIcons/Toolbar.Collapse.png diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index b1eec43930..f60e37e8a8 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -3583,6 +3583,9 @@ You can also choose to store the setting in the .user-file instead of the projec Yes to All + + Collapse all nodes + File or directory name is already in use, choose a different one. diff --git a/data/resources/image/BitmapResources/BitmapResources.res b/data/resources/image/BitmapResources/BitmapResources.res index 76615e2224..0301ff5694 100644 --- a/data/resources/image/BitmapResources/BitmapResources.res +++ b/data/resources/image/BitmapResources/BitmapResources.res @@ -29,6 +29,7 @@ ProjectBrowser.MissingSolution = ProjectBrowserIcons\MissingSolution.png ProjectBrowser.Solution = ProjectBrowserIcons\Solution.png ProjectBrowser.Toolbar.Refresh = ProjectBrowserIcons\Toolbar.Refresh.png ProjectBrowser.Toolbar.ShowHiddenFiles = ProjectBrowserIcons\Toolbar.ShowHiddenFiles.png +ProjectBrowser.Toolbar.Collapse = ProjectBrowserIcons\Toolbar.Collapse.png ProjectBrowser.SolutionFolder.Closed = ProjectBrowserIcons\SolutionFolder.Closed.png ProjectBrowser.SolutionFolder.Open = ProjectBrowserIcons\SolutionFolder.Open.png ProjectBrowser.SolutionFolder.CreateNew = ProjectBrowserIcons\SolutionFolder.CreateNew.png diff --git a/data/resources/image/BitmapResources/ProjectBrowserIcons/Toolbar.Collapse.png b/data/resources/image/BitmapResources/ProjectBrowserIcons/Toolbar.Collapse.png new file mode 100644 index 0000000000000000000000000000000000000000..7bbd6e713a525e3d9a18268ec71763e2255763e3 GIT binary patch literal 1420 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NSs56Z83KGlT!G@Ip2=ojDF(?W3{y@RrJOX)IAxx3+9v0WQ^7gsqI2%07d*-? z`c_`@uf7~ycO|6$YGm`ZsFv&T?KcxTZl!eJPVK#uHSuot#C!Qu?-x$HpEmV#_RP;^ zGar`EepEg0NzMGn1#`cYF8orx^h^DUuQOKcXk7fPecAJliY2BVn>-S#XuXdm zw@+TWd;Z$}bGN^ozw_nFtw%TSKDluB%cZ+tFWvik<^Go|_rBhH@bv0~uh$=az4_?t zt;gSPKlyg&>9>1Nzu$fK?cTHRkDtDH@$%)XSFavC|Nh{`w}&sjKY8{2*_-dr-~4#- z_WR3s-(SA{@#@`=*YAJ6{qW=M$Di*%{do83=f}@KK79K5>C4YAUw?l621LKU|M>ai z$1h+Qj)EZ?0(*Ft6#(-ILrIWd@c)qw7=pjEs{*5uv%n*=n1O*?2!t6g-L3lr6l5>) z^mS#w!Xw4WA&@$OzX2#DS>hT|5}cn_Ql40p$`Fv4nOCCc=Nh6=W~^tbXLg}^Z4^+^ zMNb#U5RKsEAN_0+CRatCEKxb)(!%niVu!_zNJ*15Ykj_!ly2D?GG(er>XJx_D_5VS zsvdQ1W&K&X)6(+B49Sqqn~g392|r3!Qa*H;>CB7 + + @@ -768,6 +773,11 @@ label = "${res:MainWindow.Windows.ClassBrowser.ClassViewSettings.ShowOtherMembers.Label}" class = "ICSharpCode.SharpDevelop.Gui.ClassBrowser.ShowOtherMembers"/> + + diff --git a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs index eb96ad05d9..377a658c46 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs @@ -172,6 +172,16 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser UpdateToolbars(); } + public void CollapseAll() + { + if (this.classBrowserTreeView == null) return; + if (this.classBrowserTreeView.Nodes == null || this.classBrowserTreeView.Nodes.Count == 0) return; + + foreach(TreeNode node in this.classBrowserTreeView.Nodes) { + node.Collapse(false); + } + } + void ClassBrowserTreeViewAfterSelect(object sender, TreeViewEventArgs e) { if (navigateBack) { diff --git a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowserToolbarCommands.cs b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowserToolbarCommands.cs index 461f957913..a3566b259c 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowserToolbarCommands.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowserToolbarCommands.cs @@ -34,6 +34,17 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser } } + public class ClassBrowserCollapseAll : AbstractMenuCommand + { + public override bool IsEnabled { + get { return true; } + } + public override void Run() + { + ClassBrowserPad.Instance.CollapseAll(); + } + } + #region Class browser filter public class SelectClassBrowserFilter : AbstractMenuCommand { diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ToolbarCommands.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ToolbarCommands.cs index d9165e8ca6..5ae1990234 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ToolbarCommands.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ToolbarCommands.cs @@ -37,4 +37,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands ProjectBrowserPad.Instance.ProjectBrowserControl.RefreshView(); } } + + public class CollapseAllProjectBrowser : AbstractMenuCommand + { + public override void Run() + { + ProjectBrowserPad.Instance.ProjectBrowserControl.ExpandOrCollapseAll(false); + } + } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs index fabe7e2119..e04274091a 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs @@ -485,5 +485,22 @@ namespace ICSharpCode.SharpDevelop.Project this.ResumeLayout(false); } #endregion + + public void ExpandOrCollapseAll(bool expand) + { + if (this.treeView == null) return; + if (this.treeView.Nodes == null || this.treeView.Nodes.Count == 0) return; + + foreach(TreeNode node in this.treeView.Nodes) { + if (expand) { + node.ExpandAll(); + } + else { + node.Collapse(false); + } + } + + this.treeView.Nodes[0].Expand(); + } } } diff --git a/src/Main/StartUp/Project/Resources/BitmapResources.resources b/src/Main/StartUp/Project/Resources/BitmapResources.resources index 8740ee3c610027ed60ab5f99d07d39640c16b656..6c2cf3bb24dabec0247416ae25a76af6710377db 100644 GIT binary patch delta 1845 zcmZWo3s6+&89jU13-_`tZ&;9(<&8p6KtK?YC>Z1=%0nd>1QDYyEW0dHq@$n)CBB0E z3bBbn8c3oM&@4!FET9Q!V+543sPTbGjR`a&#ik{ev>#5KW}3P4?VbOe^Plhg&dx3W zmv`-dysPTP0SUkX*uY#**`4m}mP!|_+hJ>XgHJG;X7d{G&I(|w5%69Z&}|I79|hQC zv0ixPsJAXoU+g)NC#g zn+{aZ1WMU{Gbb-4-K|>$Bu}NB1H^{_d8B$wZ{H=r9!H>mHT%MBo}&}d5(~1H0^iao zSKWXz8W4mM(XfjIpiqD4!rwmQsyVxz49yX|V8kU;*vfCTvM|B(gAr)MJ(XY5#W zp)0pp!LAi5f-V5g2RU({Of!;xw(&yum zC(F~%xJv*hh+FT=i3WhUpgBq3g#WNMEE=htL)8r_3JNO%5s$4Ssh7K?1{ZS z?_cu5&?4KGJF}IIZuXQGRES^!Zyw#*R=m5dSVF~78MU_+OItZp9bm1KjNd6eP-|5s zI<+6zBJHaA4NCj$+V&gN`7PeT@Bh)=8RvN_V=9yOjPpWOVr|hU;?mkGe!MtvK=bMS?Wic)!$!~Rm$#u_e%Zp zJ$5G-`6i#PtT0~Okk##y){ts+uW`o;bz17}6Mt%mje5MXncZy24;<7uKZ;k*aa_oo z^lEzbz0W%8uKc63?vl4o=g~J2?$~=TPXE&@)x8&_mzsM*huv?!~_Jen>J5GEQ@b9Ich1csQ5BIbM9KO<*`jcwr(+S(s znA~%tUlhr&6qTx#suQPgMO3JVGVAXh`)6^D^Jw6QyQ<%H*!N9`^~1|Aza3Ru6RLIX z>d)Wv}sx9z(mKUWhXcMb!E^e zp8IoS-93+gKJJq|eF?;Y5QxD=D*S_>hl0Oi~k8 zt;4#;gP8#zXRP;jIjHuCG59=ay*SXm_o~$!=^nL%@-JT>ixKty4{>rZ!B7@v=)aHp zx^i!uGsb^B=fC%Ma{9A;leHsmx8f{3Y@IvD=Ej`*vb#{f{m1F8Z?nL0-C4V=$r`ReWoH`^VPt+15#e$5qQ+{$?Um)J3;1 J6vfWJ{}(!Ea0atDj=f^g)ycVB~Yf#B;|rMBJSnf3*4li zOafhNLwz>bGL`0!EL%nVfi3IW9Q|V%X_{=hu$eVkmaJOTmOZec?d;jv_kBOl=bZO> zhwo+g{*}G&E$yNL2mr0*8%P?BOhk?Cl^YBxlMTSZEx=0#;BYB05e*!z1SWUT9W|`H zNiEtdijjWQGIN71z-BLy$Mwl};JFmwJq@TU18!{qzRd$teZZ5n(pahVQ@3%4T+8`5 zO&OOcP4tJcFs`o=2v~tk{=~;_;6*AmJ>>nDsa+EIz8a`x^NUb|E@ocB`lmN271iE-_3xT zr*O6&SjVz=5&%6P2xkNBEW8#2^fduLZ37IOfG1So5N$Q5ITM)vtrqxvE&qH8;N1!w z$OTGhzj;Z<6nl?625jOXN4S6eYW6X8hu`_@fY+RK(fqKu+C)}MGLK@p#iPWL&yuOU zPyLq4yt~{}!j2EQ(s`UubM~wU9x3PXnSdfbODwyux6rI5%XyCH^}#B>fkGe@55)1M z^*VsTv6a?XB}p>s5X#JgMPQT zJVX(HsWiW#qK-yeQ%MhGQAN91^dDlTR{T0bBY_fe<0wr9$|c@bkw+`^rF2g>%Aem= zQMQoUI$ZMfsESn!=~PF&xOAE#9r@B7Swv!Wm+(zcfxbrE`kHjTP<(lXj_al3$P`WM zxgzH}nSvfUa8rewtU(veTZU)ogTN zT=fVe05{e^=cgS#sDlq(Xhti}TQoQpfl6Lz;pJ!1fo=vyZ8ROSi?(>03#Aw3CTd7r zM60liT^$H97Hj|Ch8O<(8&OVrywfh{QZ(d{tt**&JLBa?E)A&*>9Adu2QxHeEu_g# zo7|YQnEvUs3AdXpUD?u5%x7REk!reB5%JLe?ld};e9H54tR zPaO_y2_&kRaO b!Tq@B#2LvI%@s3#;*7elW_-6rOPc);Y-LYJ From 301352be0714c8240866a0105658aae5c3d8756d Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Tue, 14 Dec 2010 18:18:20 +0200 Subject: [PATCH 55/88] add collapse all to unit tests pad --- .../UnitTesting/Src/EmptyUnitTestsPad.cs | 2 + .../Analysis/UnitTesting/Src/IUnitTestsPad.cs | 3 +- .../UnitTesting/Src/UnitTestCommands.cs | 17 +++ .../Analysis/UnitTesting/Src/UnitTestsPad.cs | 11 ++ .../Analysis/UnitTesting/UnitTesting.addin | 101 +++++++++--------- .../Src/Gui/Pads/ClassBrowser/ClassBrowser.cs | 4 +- .../ProjectBrowser/ProjectBrowserControl.cs | 12 +-- 7 files changed, 91 insertions(+), 59 deletions(-) diff --git a/src/AddIns/Analysis/UnitTesting/Src/EmptyUnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Src/EmptyUnitTestsPad.cs index c97f3d1fde..24cec28f67 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/EmptyUnitTestsPad.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/EmptyUnitTestsPad.cs @@ -29,5 +29,7 @@ namespace ICSharpCode.UnitTesting { return null; } + + public void CollapseAll() { } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestsPad.cs index 5e6ea28b48..56a795b818 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestsPad.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestsPad.cs @@ -12,6 +12,7 @@ namespace ICSharpCode.UnitTesting void BringToFront(); void ResetTestResults(); IProject[] GetProjects(); - TestProject GetTestProject(IProject project); + TestProject GetTestProject(IProject project); + void CollapseAll(); } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestCommands.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestCommands.cs index a1566c59b7..89460d5c81 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/UnitTestCommands.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestCommands.cs @@ -2,6 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Windows.Forms; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Dom; @@ -99,4 +100,20 @@ namespace ICSharpCode.UnitTesting } } } + + public class CollapseAllTestsCommand : AbstractMenuCommand + { + public override void Run() + { + if (!(this.Owner is TreeView)) + return; + + var treeView = (TreeView)this.Owner; + treeView.CollapseAll(); + + if (treeView.Nodes.Count > 0) { + treeView.Nodes[0].Expand(); + } + } + } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestsPad.cs index 2d0df832dd..32775ae99a 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/UnitTestsPad.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestsPad.cs @@ -120,6 +120,17 @@ namespace ICSharpCode.UnitTesting ToolbarService.UpdateToolbar(toolStrip); } + /// + /// Collapses all nodes. + /// + public void CollapseAll() + { + if (treeView == null || treeView.Nodes == null || treeView.Nodes.Count == 0) + return; + + treeView.CollapseAll(); + } + /// /// Called when a solution has been loaded. /// diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.addin b/src/AddIns/Analysis/UnitTesting/UnitTesting.addin index 9e7d8f16d8..2a2f9cc880 100644 --- a/src/AddIns/Analysis/UnitTesting/UnitTesting.addin +++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.addin @@ -19,17 +19,17 @@ + class="ICSharpCode.UnitTesting.NUnitTestFramework" + supportedProjects=".csproj;.vbproj;.booproj" /> + category="Tools" + title="${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}" + icon="PadIcons.NUnitTest" + class="ICSharpCode.UnitTesting.UnitTestsPad" + defaultPosition="Right, Hidden" /> @@ -51,9 +51,9 @@ + label="${res:ICSharpCode.UnitTesting.RunInTestPad}" + icon="PadIcons.NUnitTest" + class="ICSharpCode.UnitTesting.RunTestInPadCommand"/> @@ -71,9 +71,9 @@ + label="${res:ICSharpCode.UnitTesting.RunInTestPad}" + icon="PadIcons.NUnitTest" + class="ICSharpCode.UnitTesting.RunTestInPadCommand"/> @@ -89,9 +89,9 @@ + label="${res:ICSharpCode.UnitTesting.RunWithDebugger}" + icon="Icons.16x16.RunProgramIcon" + class="ICSharpCode.UnitTesting.RunTestWithDebuggerCommand"/> @@ -104,14 +104,14 @@ + icon="Icons.16x16.RunAllIcon" + tooltip="${res:NUnitPad.NUnitPadContent.RunAllTests}" + class="ICSharpCode.UnitTesting.RunAllTestsInPadCommand"/> + insertafter="RunAll" + icon="Icons.16x16.RunProgramIcon" + tooltip="${res:NUnitPad.NUnitPadContent.RunItem}" + class="ICSharpCode.UnitTesting.RunTestInPadCommand"/> @@ -119,16 +119,21 @@ + icon="Icons.16x16.Debug.StopProcess" + tooltip="${res:NUnitPad.NUnitPadContent.StopTests}" + class="ICSharpCode.UnitTesting.StopTestsCommand"/> + icon="Icons.16x16.Reference" + tooltip="${res:NUnitPad.NUnitPadContent.ReferenceItem}" + class="ICSharpCode.UnitTesting.AddNUnitReferenceCommand"/> + + @@ -141,9 +146,9 @@ + icon="Icons.16x16.RunProgramIcon" + label="${res:NUnitPad.NUnitPadContent.RunTestsContextMenuLabel}" + class="ICSharpCode.UnitTesting.RunTestInPadCommand"/> @@ -152,14 +157,14 @@ + icon="Icons.16x16.Debug.StopProcess" + label="${res:NUnitPad.NUnitPadContent.StopTests}" + class="ICSharpCode.UnitTesting.StopTestsCommand"/> + label="${res:NUnitPad.NUnitPadContent.GotoDefinitionContextMenuLabel}" + class="ICSharpCode.UnitTesting.GotoDefinitionCommand"/> @@ -173,9 +178,9 @@ + icon="Icons.16x16.RunAllIcon" + label="${res:NUnitPad.NUnitPadContent.RunAllTests}" + class="ICSharpCode.UnitTesting.RunAllTestsInPadCommand"/> @@ -186,9 +191,9 @@ + icon="Icons.16x16.RunProgramIcon" + label="${res:ICSharpCode.UnitTesting.RunProjectTests}" + class="ICSharpCode.UnitTesting.RunProjectTestsInPadCommand"/> @@ -196,16 +201,16 @@ + icon="Icons.16x16.Debug.StopProcess" + label="${res:NUnitPad.NUnitPadContent.StopTests}" + class="ICSharpCode.UnitTesting.StopTestsCommand"/> + label="${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}" + class="ICSharpCode.UnitTesting.UnitTestingOptionsPanel"/> diff --git a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs index 377a658c46..778846f50f 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ClassBrowser/ClassBrowser.cs @@ -177,9 +177,7 @@ namespace ICSharpCode.SharpDevelop.Gui.ClassBrowser if (this.classBrowserTreeView == null) return; if (this.classBrowserTreeView.Nodes == null || this.classBrowserTreeView.Nodes.Count == 0) return; - foreach(TreeNode node in this.classBrowserTreeView.Nodes) { - node.Collapse(false); - } + this.classBrowserTreeView.CollapseAll(); } void ClassBrowserTreeViewAfterSelect(object sender, TreeViewEventArgs e) diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs index e04274091a..8616f4ba6f 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs @@ -491,13 +491,11 @@ namespace ICSharpCode.SharpDevelop.Project if (this.treeView == null) return; if (this.treeView.Nodes == null || this.treeView.Nodes.Count == 0) return; - foreach(TreeNode node in this.treeView.Nodes) { - if (expand) { - node.ExpandAll(); - } - else { - node.Collapse(false); - } + if (expand) { + this.treeView.ExpandAll(); + } + else { + this.treeView.CollapseAll(); } this.treeView.Nodes[0].Expand(); From cde9c67d1be21fde2d101de1880668259db8a57c Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Tue, 14 Dec 2010 18:30:01 +0200 Subject: [PATCH 56/88] fix build - implement CollapseAll in MockUnitTestsPad --- src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestsPad.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestsPad.cs index 3ee90b95e7..77bbbcc97c 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestsPad.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestsPad.cs @@ -68,5 +68,7 @@ namespace UnitTesting.Tests.Utils { testProjects.Add(testProject); } + + public void CollapseAll() { } } } From d9c2ae3a33fb671097f15cea7155d952a6e5d2d0 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Tue, 14 Dec 2010 21:41:07 +0000 Subject: [PATCH 57/88] Fix SD-1794 - Replace all in selection does not replace any text --- src/AddIns/Misc/SearchAndReplace/Project/Engine/Search.cs | 2 +- .../Engine/SearchStrategy/BruteForceSearchStrategy.cs | 5 ++++- .../Project/Engine/SearchStrategy/RegExSearchStrategy.cs | 5 ++++- .../Project/Engine/SearchStrategy/WildcardSearchStrategy.cs | 5 ++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/AddIns/Misc/SearchAndReplace/Project/Engine/Search.cs b/src/AddIns/Misc/SearchAndReplace/Project/Engine/Search.cs index 4e1f20345c..111e42d2c4 100644 --- a/src/AddIns/Misc/SearchAndReplace/Project/Engine/Search.cs +++ b/src/AddIns/Misc/SearchAndReplace/Project/Engine/Search.cs @@ -145,7 +145,7 @@ namespace SearchAndReplace if (documentIterator.MoveForward()) { info = documentIterator.Current; // document is valid for searching -> set iterator & fileName - if (info != null && info.EndOffset >= 0 && info.EndOffset < info.Document.TextLength) { + if (info != null && info.EndOffset >= 0 && info.EndOffset <= info.Document.TextLength) { textIterator = textIteratorBuilder.BuildTextIterator(info); } else { textIterator = null; diff --git a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/BruteForceSearchStrategy.cs b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/BruteForceSearchStrategy.cs index e6692bfae8..0ad639b754 100644 --- a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/BruteForceSearchStrategy.cs +++ b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/BruteForceSearchStrategy.cs @@ -54,7 +54,10 @@ namespace SearchAndReplace int InternalFindNext(ITextIterator textIterator, int offset, int length) { - while (textIterator.MoveAhead(1) && TextSelection.IsInsideRange(textIterator.Position, offset, length)) { + while (textIterator.MoveAhead(1)) { + if (textIterator.Position >= offset + length) { + textIterator.Position = offset; + } if (SearchOptions.MatchCase ? MatchCaseSensitive(textIterator.Document, textIterator.Position, searchPattern) : MatchCaseInsensitive(textIterator.Document, textIterator.Position, searchPattern)) { if (!SearchOptions.MatchWholeWord || IsWholeWordAt(textIterator.Document, textIterator.Position, searchPattern.Length)) { if (TextSelection.IsInsideRange(textIterator.Position + searchPattern.Length - 1, offset, length)) { diff --git a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/RegExSearchStrategy.cs b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/RegExSearchStrategy.cs index 96f3071f7a..7296f2cea3 100644 --- a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/RegExSearchStrategy.cs +++ b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/RegExSearchStrategy.cs @@ -58,7 +58,10 @@ namespace SearchAndReplace { string document = textIterator.Document.GetText(0, textIterator.Document.TextLength); - while (textIterator.MoveAhead(1) && TextSelection.IsInsideRange(textIterator.Position, offset, length)) { + while (textIterator.MoveAhead(1)) { + if (textIterator.Position >= offset + length) { + textIterator.Position = offset; + } Match m = regex.Match(document, textIterator.Position); if (m == null || !m.Success) { while (textIterator.Position < document.Length - 1) { diff --git a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/WildcardSearchStrategy.cs b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/WildcardSearchStrategy.cs index dd241261a4..35516d1ea9 100644 --- a/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/WildcardSearchStrategy.cs +++ b/src/AddIns/Misc/SearchAndReplace/Project/Engine/SearchStrategy/WildcardSearchStrategy.cs @@ -145,7 +145,10 @@ namespace SearchAndReplace int InternalFindNext(ITextIterator textIterator, int offset, int length) { - while (textIterator.MoveAhead(1) && TextSelection.IsInsideRange(textIterator.Position, offset, length)) { + while (textIterator.MoveAhead(1)) { + if (textIterator.Position >= offset + length) { + textIterator.Position = offset; + } int position = textIterator.Position; if (Match(textIterator.Document, position, !SearchOptions.MatchCase, 0)) { if (!SearchOptions.MatchWholeWord || SearchReplaceUtilities.IsWholeWordAt(textIterator.Document, position, curMatchEndOffset - position)) { From 754cb29bfdc309872eacd52b346f0fa27e270bb0 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 13 Dec 2010 18:42:42 +0100 Subject: [PATCH 58/88] Fix off-by-one error in profiler's "Go to definition". --- .../Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs | 2 +- src/Main/StartUp/Project/StartUp.csproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs index 424626f75d..e4d23f92f8 100644 --- a/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs +++ b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/GoToDefinition.cs @@ -26,7 +26,7 @@ namespace ICSharpCode.Profiler.AddIn.Commands IEntity member = GetMemberFromName(c, selectedItem.MethodName, selectedItem.Parameters); FilePosition position = c.ProjectContent.GetPosition(member ?? c); if (!position.IsEmpty && !string.IsNullOrEmpty(position.FileName)) { - FileService.JumpToFilePosition(position.FileName, position.Line - 1, position.Column - 1); + FileService.JumpToFilePosition(position.FileName, position.Line, position.Column); } } } diff --git a/src/Main/StartUp/Project/StartUp.csproj b/src/Main/StartUp/Project/StartUp.csproj index 9fb7e3627f..bca99d3a1b 100644 --- a/src/Main/StartUp/Project/StartUp.csproj +++ b/src/Main/StartUp/Project/StartUp.csproj @@ -78,7 +78,6 @@ - {2748AD25-9C63-4E12-877B-4DCE96FBED54} ICSharpCode.SharpDevelop From 1d25ed2fd160976d0a2b4fe1b16c38c86ed04dea Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 15 Dec 2010 15:59:12 +0100 Subject: [PATCH 59/88] Fix bug in WPF designer: ChangeGroup was left open when creating a control by clicking on the design surface (http://community.sharpdevelop.net/forums/t/12410.aspx) --- .../Project/Services/CreateComponentTool.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs index 94e112bbc3..7f130e3945 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs @@ -79,7 +79,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services if (AddItemWithDefaultSize(result.ModelHit, createdItem, e.GetPosition(result.ModelHit.View))) { moveLogic = new MoveLogic(createdItem); createPoint = p; + // We'll keep the ChangeGroup open as long as the moveLogic is active. } else { + // Abort the ChangeGroup created by the CreateItem() call. changeGroup.Abort(); } } @@ -169,7 +171,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services if (behavior != null) { DesignItem createdItem = CreateItem(designPanel.Context); - new CreateComponentMouseGesture(result.ModelHit, createdItem).Start(designPanel, e); + new CreateComponentMouseGesture(result.ModelHit, createdItem, changeGroup).Start(designPanel, e); + // CreateComponentMouseGesture now is responsible for the changeGroup created by CreateItem() + changeGroup = null; } } } @@ -181,12 +185,14 @@ namespace ICSharpCode.WpfDesign.Designer.Services DesignItem createdItem; PlacementOperation operation; DesignItem container; + ChangeGroup changeGroup; - public CreateComponentMouseGesture(DesignItem clickedOn, DesignItem createdItem) + public CreateComponentMouseGesture(DesignItem clickedOn, DesignItem createdItem, ChangeGroup changeGroup) { this.container = clickedOn; this.createdItem = createdItem; this.positionRelativeTo = clickedOn.View; + this.changeGroup = changeGroup; } // GrayOutDesignerExceptActiveArea grayOut; @@ -236,6 +242,10 @@ namespace ICSharpCode.WpfDesign.Designer.Services } else { CreateComponentTool.AddItemWithDefaultSize(container, createdItem, e.GetPosition(positionRelativeTo)); } + if (changeGroup != null) { + changeGroup.Commit(); + changeGroup = null; + } base.OnMouseUp(sender, e); } @@ -245,6 +255,10 @@ namespace ICSharpCode.WpfDesign.Designer.Services operation.Abort(); operation = null; } + if (changeGroup != null) { + changeGroup.Abort(); + changeGroup = null; + } if (services.Tool.CurrentTool is CreateComponentTool) { services.Tool.CurrentTool = services.Tool.PointerTool; } From 7b8e65a2d3a4702ef2885c7f348531b053de5257 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 15 Dec 2010 16:45:39 +0100 Subject: [PATCH 60/88] Simplify LanguageBindingDoozer (remove LanguageBindingDescriptor) and update DoozerList/ConditionList. --- data/schemas/AddIn.xsd | 523 +++++++++--------- doc/technotes/ConditionList.html | 39 +- doc/technotes/DoozerList.html | 290 +++++----- .../Project/ICSharpCode.SharpDevelop.csproj | 1 - .../LanguageBindingDescriptor.cs | 62 --- .../LanguageBinding/LanguageBindingDoozer.cs | 27 +- .../LanguageBinding/LanguageBindingService.cs | 20 +- .../BuildAddinDocumentation.csproj | 24 +- .../BuildAddinDocumentation.sln | 6 +- .../BuildAddinDocumentation/MainClass.cs | 31 +- 10 files changed, 502 insertions(+), 521 deletions(-) delete mode 100644 src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDescriptor.cs diff --git a/data/schemas/AddIn.xsd b/data/schemas/AddIn.xsd index d2ba801e4d..6b8a513e53 100644 --- a/data/schemas/AddIn.xsd +++ b/data/schemas/AddIn.xsd @@ -117,23 +117,22 @@ - - - + + - + @@ -188,23 +187,22 @@ - - - + + - + @@ -266,8 +264,8 @@ - The fully qualified type name of the class to create an instace of. - + The fully qualified type name of the class to create an instace of. + @@ -287,16 +285,16 @@ - Name of the ICodeCompletionBinding class (normally deriving from DefaultCodeCompletionBinding). - + Name of the ICodeCompletionBinding class (normally deriving from DefaultCodeCompletionBinding). + - List of semicolon-separated entries of the file extensions handled by the binding. - If no extensions attribute is specified, the binding is activated in all files. - + List of semicolon-separated entries of the file extensions handled by the binding. + If no extensions attribute is specified, the binding is activated in all files. + @@ -315,30 +313,30 @@ - The name of the MSBuild meta data. - + The name of the MSBuild meta data. + - The display name of the property. - + The display name of the property. + - The description text for the property. - + The description text for the property. + - Boolean property specifying whether the custom tool should be run when the property value is changed - by the user. Default: false. - + Boolean property specifying whether the custom tool should be run when the property value is changed + by the user. Default: false. + @@ -357,23 +355,23 @@ - ID used to identify the custom tool. - + ID used to identify the custom tool. + - Name of the ICustomTool class. - + Name of the ICustomTool class. + - Regular expression that specifies the file names for which the custom tool - can be used. Example: "\.res(x|ources)$" - + Regular expression that specifies the file names for which the custom tool + can be used. Example: "\.res(x|ources)$" + @@ -392,43 +390,43 @@ - Name of the IDebugger class. - + Name of the IDebugger class. + - Specifies if the debugger supports the 'Start' command. Default: true - + Specifies if the debugger supports the 'Start' command. Default: true + - Specifies if the debugger supports the 'StartWithoutDebugger' command. Default: true - + Specifies if the debugger supports the 'StartWithoutDebugger' command. Default: true + - Specifies if the debugger supports the 'Stop' (kill running process) command. Default: true - + Specifies if the debugger supports the 'Stop' (kill running process) command. Default: true + - Specifies if the debugger supports stepping. Default: false - + Specifies if the debugger supports stepping. Default: false + - Specifies if the debugger supports execution control (break, resume). Default: false - + Specifies if the debugger supports execution control (break, resume). Default: false + @@ -441,47 +439,14 @@ - - - - - - - - - - - - - Name of the IDialogPanel class. Optional if the page has subpages. - - - - - - - Caption of the dialog panel. - - - - - - - - - - Creates DefaultDialogPanelDescriptor objects that are used in option dialogs. - - - - Path relative to the directory which contains the .addin file defining the codon. - + Path relative to the directory which contains the .addin file defining the codon. + @@ -500,22 +465,22 @@ - Name of the IDisplayBinding or ISecondaryDisplayBinding class. - + Name of the IDisplayBinding or ISecondaryDisplayBinding class. + - Title of the display binding to use in the "Open With" dialog. - + Title of the display binding to use in the "Open With" dialog. + - Type of the display binding (either "Primary" or "Secondary"). Default: "Primary". - + Type of the display binding (either "Primary" or "Secondary"). Default: "Primary". + @@ -527,9 +492,9 @@ - Regular expression that specifies the file names for which the display binding - will be used. Example: "\.res(x|ources)$" - + Regular expression that specifies the file names for which the display binding + will be used. Example: "\.res(x|ources)$" + @@ -545,49 +510,21 @@ - - - - - - - Comma-separated list of keyboard shortcuts that activate the edit action. - E.g. "Control|C,Control|Insert" - - - - - - - Name of the IEditAction class. - - - - - - - - - - Creates IEditAction objects for the text editor. - - - - The name of the file filter entry. - + The name of the file filter entry. + - The extensions associated with this file filter entry. - + The extensions associated with this file filter entry. + @@ -606,24 +543,24 @@ - The name of a bitmap resource in the resource service. - + The name of a bitmap resource in the resource service. + - This attribute is specified when a project icon association should be created. - It specifies the language of the project types that use the icon. - + This attribute is specified when a project icon association should be created. + It specifies the language of the project types that use the icon. + - This attribute is specified when a file icon association should be created. - It specifies the semicolon-separated list of file types that use the icon. - + This attribute is specified when a file icon association should be created. + It specifies the semicolon-separated list of file types that use the icon. + @@ -643,18 +580,18 @@ - When this attribute is used, the include doozer builds the item that is at the - addin tree location specified by this attribute. - + When this attribute is used, the include doozer builds the item that is at the + addin tree location specified by this attribute. + - When this attribute is used, the include doozer builds all items inside the - path addin tree location specified by this attribute and returns an - IBuildItemsModifier which includes all items in the output list. - + When this attribute is used, the include doozer builds all items inside the + path addin tree location specified by this attribute and returns an + IBuildItemsModifier which includes all items in the output list. + @@ -669,62 +606,21 @@ - - - - - - - Project type GUID of the project used by MsBuild. - - - - - - - Semicolon-separated list of file extensions that are compilable files in the project. (e.g. ".boo") - - - - - - - File extension of project files. (e.g. ".booproj") - - - - - - - Name of the IProjectBinding class. - - - - - - - - - - Creates ProjectBindingDescriptor objects for the project service. - - - - Semicolon-separated list of file extensions that are handled by the language binding (e.g. .xaml) - + Semicolon-separated list of file extensions that are handled by the language binding (e.g. .xaml) + - Name of the ILanguageBinding class. - + Name of the ILanguageBinding class. + @@ -733,7 +629,7 @@ - Creates LanguageBindingDescriptor objects for the language service. + Creates LanguageBindingDescriptor objects for the language binding service. @@ -749,18 +645,18 @@ - Label of the menu item. - + Label of the menu item. + - This attribute must be one of these values: - Separator, CheckBox, Item=Command, Menu (=with subitems), - Builder (=class implementing ISubmenuBuilder). - Default: Command. - + This attribute must be one of these values: + Separator, CheckBox, Item=Command, Menu (=with subitems), + Builder (=class implementing ISubmenuBuilder). + Default: Command. + @@ -776,39 +672,48 @@ - Only for the type "Item"/"Command". - When set to false, the command class is loaded - immediately instead of the usual lazy-loading. - + Only for the type "Item"/"Command". + When set to false, the command class is loaded + immediately instead of the usual lazy-loading. + - Icon of the menu item. - + Icon of the menu item. + - Command class that is run when item is clicked. - + Command class that is run when item is clicked. + + + + + + + A WPF routed command that is executed when item is clicked. + Currently, this property is supported only for WPF Menus. + Only one of the "class" and "command" attributes can be used on a menu entry. + - Only for the type "Item"/"Command". Opens a webpage instead of running a command when - clicking the item. - + Only for the type "Item"/"Command". Opens a webpage instead of running a command when + clicking the item. + - Shortcut that activates the command (e.g. "Control|S"). - + Shortcut that activates the command (e.g. "Control|S"). + @@ -821,49 +726,89 @@ + + + + + + + + + + + + + Name of the IOptionPanel class. Optional if the page has subpages. + + + + + + + Caption of the dialog panel. + + + + + + + + + + Creates DefaultOptionPanelDescriptor objects that are used in option dialogs. + + + - IPadContent class that is loaded when the pad content is shown for the first time. - + IPadContent class that is loaded when the pad content is shown for the first time. + - Title of the pad that is shown in the user interface. - Should be a resource string, e.g. "${res:AddIns.HtmlHelp2.Contents}" - + Title of the pad that is shown in the user interface. + Should be a resource string, e.g. "${res:AddIns.HtmlHelp2.Contents}" + - Specifies the name of the icon resource used for the pad. - Pad icon resources must be registered with the ResourceService before the - workbench is loaded! - + Specifies the name of the icon resource used for the pad. + Pad icon resources must be registered with the ResourceService before the + workbench is loaded! + - Category of the pad. It is possible to create menu items that automatically - contain show commands for all pads in a certain category. - Pads in the category "Main" will show up in the "View" menu, the category - "Tools" in the "View -> Tools" menu, the category "Debugger" in the - "View -> Debugger" menu. - + Category of the pad. It is possible to create menu items that automatically + contain show commands for all pads in a certain category. + Pads in the category "Main" will show up in the "View" menu, the category + "Tools" in the "View -> Tools" menu, the category "Debugger" in the + "View -> Debugger" menu. + - Shortcut that activates the 'Show pad' command (e.g. "Control|Alt|T"). - + Shortcut that activates the 'Show pad' command (e.g. "Control|Alt|T"). + + + + + + + Default position of the pad, as a ICSharpCode.SharpDevelop.DefaultPadPositions enum value (e.g. "Bottom, Hidden"). + @@ -882,31 +827,65 @@ - Semicolon-separated list of file extensions for which the parser is used. (e.g. ".boo") - + Semicolon-separated list of file extensions for which the parser is used. (e.g. ".boo") + - + - File extension of project files. (e.g. ".booproj") - + Name of the IParser class. + - + + + + + + + Creates ParserDescriptor objects for the parsing service. + + + + + + + - Name of the IParser class. - + Project type GUID of the project used by MSBuild. + + + + + + + Semicolon-separated list of file extensions that are compilable files in the project. (e.g. ".boo") + + + + + + + File extension of project files. (e.g. ".booproj") + + + + + + + Name of the IProjectBinding class. + - + - Creates ParserDescriptor objects for the parsing service. + Creates ProjectBindingDescriptor objects for the project service. @@ -916,8 +895,8 @@ - Name of the ProjectContentRegistry class. - + Name of the ProjectContentRegistry class. + @@ -936,15 +915,15 @@ - Specifies the name of the protocol the extension handles. (e.g. 'ms-help' or 'startpage') - + Specifies the name of the protocol the extension handles. (e.g. 'ms-help' or 'startpage') + - Name of the ISchemeExtension class (normally deriving from DefaultSchemeExtension). - + Name of the ISchemeExtension class (normally deriving from DefaultSchemeExtension). + @@ -963,8 +942,8 @@ - The string to return. - + The string to return. + @@ -977,66 +956,60 @@ - + - - - - Name of the language for which the syntax mode is used. - - - - + - Semicolon-separated list of file extensions for which the syntax mode is used. - + Name of the IMSBuildAdditionalLogger class. + - + - Fully qualified name of the resource file. - + Specifies the name of the MSBuild task that must be running for + this logger to be active. + - + - Creates AddInTreeSyntaxMode objects that wrap a .xshd syntax mode stored as resource in the - addin assembly. + Creates IMSBuildAdditionalLogger objects that are only + activated when a specific MSBuild task is running. - + - Name of the IMSBuildAdditionalLogger class. - + Name of the IMSBuildLoggerFilter class. + - Specifies the name of the MSBuild task that must be running for - this logger to be active. - + Specifies the name of the MSBuild task that must be running for + this logger to be active. + - + - Creates IMSBuildAdditionalLogger objects that are only + Creates IMSBuildLoggerFilter objects that are only activated when a specific MSBuild task is running. @@ -1053,23 +1026,23 @@ - Label of the tool bar item. - + Label of the tool bar item. + - Icon of the tool bar item. - + Icon of the tool bar item. + - This attribute must be one of these values: - Separator, CheckBox, Item, ComboBox, DropDownButton - + This attribute must be one of these values: + Separator, CheckBox, Item, ComboBox, DropDownButton + @@ -1084,24 +1057,24 @@ - Only for the type "Item". When set to false, the command class is loaded - immediately instead of the usual lazy-loading. - + Only for the type "Item". When set to false, the command class is loaded + immediately instead of the usual lazy-loading. + - Tooltip of the tool bar item. - + Tooltip of the tool bar item. + - Command class that is run when item is clicked; or class that manages - the ComboBox/DropDownButton. Required for everything except "Separator". - + Command class that is run when item is clicked; or class that manages + the ComboBox/DropDownButton. Required for everything except "Separator". + diff --git a/doc/technotes/ConditionList.html b/doc/technotes/ConditionList.html index 7db94b07c3..3b5b99750c 100644 --- a/doc/technotes/ConditionList.html +++ b/doc/technotes/ConditionList.html @@ -5,7 +5,7 @@

Condition List

This file was generated by the tool 'BuildAddinDocumentation'. -It is based on SharpDevelop 3.0.0.3062.

+It is based on SharpDevelop 4.0.0.7014.

ActiveContentExtension

@@ -176,7 +178,7 @@ It is based on SharpDevelop 3.0.0.3062.

comparisonType: The mode of the comparison: a field of the System.StringComparison enumeration. The default is - 'InvariantCultureIgnoreCase'. + 'OrdinalIgnoreCase'. @@ -213,7 +215,7 @@ It is based on SharpDevelop 3.0.0.3062.

comparisonType: The mode of the comparison: a field of the System.StringComparison enumeration. The default is - 'InvariantCultureIgnoreCase'. + 'OrdinalIgnoreCase'. @@ -423,7 +425,7 @@ It is based on SharpDevelop 3.0.0.3062.

+ @@ -459,7 +461,7 @@ It is based on SharpDevelop 3.0.0.3062.

Condition name: - ICSharpCode.SharpDevelop.DefaultEditor.Conditions.TextContentConditionEvaluatorICSharpCode.SharpDevelop.Editor.AvalonEdit.TextContentConditionEvaluator

Attributes:

Example: Test if the current window is a text editor

-            <Condition name="WindowActive" activewindow="ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.ITextEditorControlProvider">

+ <Condition name="WindowActive" activewindow="ICSharpCode.SharpDevelop.Editor.ITextEditorProvider">

Example: Test if any window is active

             <Condition name="WindowActive" activewindow="*">

@@ -487,9 +489,34 @@ It is based on SharpDevelop 3.0.0.3062.

Example: Test if a text editor is opened

-            <Condition name="WindowOpen" openwindow="ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.ITextEditorControlProvider">

+ <Condition name="WindowOpen" openwindow="ICSharpCode.SharpDevelop.Editor.ITextEditorProvider">

Example: Test if any window is open

             <Condition name="WindowOpen" openwindow="*">

+
+

WriteableProject

+

+ Tests if the caller project is writable. If caller is not an IProject it tests + Project.CurrentProject. +

+ + + + +
Condition name: + ICSharpCode.SharpDevelop.WriteableProjectConditionEvaluator
+
+
+

WriteableSolution

+

+ Description of WriteableSolutionEvaluator. +

+ + + + +
Condition name: + ICSharpCode.SharpDevelop.WriteableSolutionConditionEvaluator
+
diff --git a/doc/technotes/DoozerList.html b/doc/technotes/DoozerList.html index e60e8ce1a4..f1e853ddb9 100644 --- a/doc/technotes/DoozerList.html +++ b/doc/technotes/DoozerList.html @@ -5,29 +5,29 @@

Doozer List

This file was generated by the tool 'BuildAddinDocumentation'. -It is based on SharpDevelop 3.0.0.3062.

+It is based on SharpDevelop 4.0.0.7014.

@@ -70,7 +70,7 @@ It is based on SharpDevelop 3.0.0.3062.

+ @@ -275,50 +275,6 @@ It is based on SharpDevelop 3.0.0.3062.

Doozer name: - ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.CodeCompletionBindingDoozerICSharpCode.SharpDevelop.Editor.CodeCompletion.CodeCompletionBindingDoozer

Attributes:

-
-

DialogPanel

-

- Creates DefaultDialogPanelDescriptor objects that are used in option dialogs. -

- - - - - - - - - - - - - - - - - - - - - - -
Doozer name: - ICSharpCode.SharpDevelop.DialogPanelDoozer

Attributes:

class: - - Name of the IDialogPanel class. Optional if the page has subpages. -
label: - required - Caption of the dialog panel. -

Children: - - In the SharpDevelop options, option pages can have subpages by specifying them - as children in the AddInTree. -
Usage: - In /SharpDevelop/BackendBindings/ProjectOptions/ and /SharpDevelop/Dialogs/OptionsDialog
Returns: - - A DefaultDialogPanelDescriptor object. -
-

Directory

@@ -426,45 +382,6 @@ It is based on SharpDevelop 3.0.0.3062.

fileNamePattern = "\.(cs|vb)$" /> </Path>

-
-

EditAction

-

- Creates IEditAction objects for the text editor. -

- - - - - - - - - - - - - - - - - - - - -
Doozer name: - ICSharpCode.SharpDevelop.DefaultEditor.Codons.EditActionDoozer

Attributes:

keys: - required - Comma-separated list of keyboard shortcuts that activate the edit action. - E.g. "Control|C,Control|Insert" -
class: - required - Name of the IEditAction class. -

Usage: - Only in /AddIns/DefaultTextEditor/EditActions
Returns: - - An IEditAction object. -
-

FileFilter

@@ -497,8 +414,7 @@ It is based on SharpDevelop 3.0.0.3062.

Returns: - - String in the format "name|extensions". + FileFilterDescriptor in the format "name|extensions". @@ -593,7 +509,7 @@ It is based on SharpDevelop 3.0.0.3062.

LanguageBinding

- Creates LanguageBindingDescriptor objects for the project service. + Creates LanguageBindingDescriptor objects for the language binding service.

@@ -602,24 +518,10 @@ It is based on SharpDevelop 3.0.0.3062.

- - - - - - - - - @@ -637,7 +539,7 @@ It is based on SharpDevelop 3.0.0.3062.


Attributes:

guid: - required - Project type GUID of the project used by MsBuild. -
supportedextensions: - required - Semicolon-separated list of file extensions that are compilable files in the project. (e.g. ".boo") -
projectfileextension: + extensions: required - File extension of project files. (e.g. ".booproj") + Semicolon-separated list of file extensions that are handled by the language binding (e.g. .xaml)
Returns: - An LanguageBindingDescriptor object that wraps the ILanguageBinding object. + The ILanguageBinding object.
@@ -693,6 +595,15 @@ It is based on SharpDevelop 3.0.0.3062.

Command class that is run when item is clicked. + + command: + optional + + A WPF routed command that is executed when item is clicked. + Currently, this property is supported only for WPF Menus. + Only one of the "class" and "command" attributes can be used on a menu entry. + + link: optional @@ -722,7 +633,7 @@ It is based on SharpDevelop 3.0.0.3062.

Returns: - Any ToolStrip* object, depending on the type attribute. + A MenuItemDescriptor object. @@ -731,6 +642,50 @@ It is based on SharpDevelop 3.0.0.3062.

+
+

OptionPanel

+

+ Creates DefaultOptionPanelDescriptor objects that are used in option dialogs. +

+ + + + + + + + + + + + + + + + + + + + + + +
Doozer name: + ICSharpCode.SharpDevelop.OptionPanelDoozer

Attributes:

class: + + Name of the IOptionPanel class. Optional if the page has subpages. +
label: + required + Caption of the dialog panel. +

Children: + + In the SharpDevelop options, option pages can have subpages by specifying them + as children in the AddInTree. +
Usage: + In /SharpDevelop/BackendBindings/ProjectOptions/ and /SharpDevelop/Dialogs/OptionsDialog
Returns: + + A DefaultOptionPanelDescriptor object. +
+

Pad

@@ -784,6 +739,13 @@ It is based on SharpDevelop 3.0.0.3062.

Shortcut that activates the 'Show pad' command (e.g. "Control|Alt|T"). + + defaultPosition: + optional + + Default position of the pad, as a ICSharpCode.SharpDevelop.DefaultPadPositions enum value (e.g. "Bottom, Hidden"). + +
Usage: @@ -815,26 +777,72 @@ It is based on SharpDevelop 3.0.0.3062.

- projectfileextension: + class: + + Name of the IParser class. + + +
+ + Usage: + Only in /Workspace/Parser + + + Returns: + + An ParserDescriptor object that wraps the IParser object. + + + +
+
+

ProjectBinding

+

+ Creates ProjectBindingDescriptor objects for the project service. +

+ + + + + + + + + + + + + + + - +
Doozer name: + ICSharpCode.SharpDevelop.ProjectBindingDoozer

Attributes:

guid: + required + Project type GUID of the project used by MSBuild. +
supportedextensions: + required + Semicolon-separated list of file extensions that are compilable files in the project. (e.g. ".boo") +
projectfileextension: + required File extension of project files. (e.g. ".booproj")
class: + class: + required - Name of the IParser class. + Name of the IProjectBinding class.

Usage: - Only in /Workspace/ParserOnly in /SharpDevelop/Workbench/ProjectBinding
Returns: - An ParserDescriptor object that wraps the IParser object. + A ProjectBindingDescriptor object that wraps the IProjectBinding object.
@@ -943,69 +951,69 @@ It is based on SharpDevelop 3.0.0.3062.

-

SyntaxMode

+

TaskBoundAdditionalLogger

- Creates AddInTreeSyntaxMode objects that wrap a .xshd syntax mode stored as resource in the - addin assembly. + Creates IMSBuildAdditionalLogger objects that are only + activated when a specific MSBuild task is running.

+ - - - - - - +
Doozer name: - ICSharpCode.SharpDevelop.DefaultEditor.Codons.SyntaxModeDoozerICSharpCode.SharpDevelop.Project.TaskBoundAdditionalLoggerDoozer

Attributes:

name: - required - Name of the language for which the syntax mode is used. -
extensions: + class: required - Semicolon-separated list of file extensions for which the syntax mode is used. + Name of the IMSBuildAdditionalLogger class.
resource: + taskname: required - Fully qualified name of the resource file. + Specifies the name of the MSBuild task that must be running for + this logger to be active.

Usage: - Only in /SharpDevelop/ViewContent/DefaultTextEditor/SyntaxModesOnly in /SharpDevelop/MSBuildEngine/AdditionalLoggers
Returns: - An AddInTreeSyntaxMode object that loads the resource from the addin assembly when - its CreateTextReader method is called. + A IMSBuildAdditionalLogger object that lazy-loads the specified + IMSBuildAdditionalLogger when the specified task is running.
+

Example: +

+            <TaskBoundAdditionalLogger
+            	id = "FxCopLogger"
+            	taskname = "FxCop"
+            	class = "ICSharpCode.CodeAnalysis.FxCopLogger"/>

-

TaskBoundAdditionalLogger

+

TaskBoundLoggerFilter

- Creates IMSBuildAdditionalLogger objects that are only + Creates IMSBuildLoggerFilter objects that are only activated when a specific MSBuild task is running.

+ @@ -1019,22 +1027,22 @@ It is based on SharpDevelop 3.0.0.3062.

+
Doozer name: - ICSharpCode.SharpDevelop.Project.TaskBoundAdditionalLoggerDoozerICSharpCode.SharpDevelop.Project.TaskBoundLoggerFilterDoozer

Attributes:

class: required - Name of the IMSBuildAdditionalLogger class. + Name of the IMSBuildLoggerFilter class.

Usage: - Only in /SharpDevelop/MSBuildEngine/AdditionalLoggersOnly in /SharpDevelop/MSBuildEngine/LoggerFilters
Returns: - A IMSBuildAdditionalLogger object that lazy-loads the specified - IMSBuildAdditionalLogger when the specified task is running. + A IMSBuildLoggerFilter object that lazy-loads the specified + IMSBuildLoggerFilter when the specified task is running.

Example:

-            <TaskBoundAdditionalLogger
+            <TaskBoundLoggerFilter
             	id = "FxCopLogger"
             	taskname = "FxCop"
-            	class = "ICSharpCode.CodeAnalysis.FxCopLogger"/>

+ class = "ICSharpCode.CodeAnalysis.FxCopLoggerFilter"/>

ToolbarItem

diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 06ec4ab085..15768dfd9b 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -324,7 +324,6 @@ - diff --git a/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDescriptor.cs b/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDescriptor.cs deleted file mode 100644 index 5371c06fca..0000000000 --- a/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDescriptor.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using System.IO; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Editor; - -namespace ICSharpCode.SharpDevelop -{ - public class LanguageBindingDescriptor - { - Codon codon; - string[] extensions; - - public LanguageBindingDescriptor(Codon codon) - { - this.codon = codon; - } - - internal ILanguageBinding CreateBinding(ITextEditor editor) { - return (ILanguageBinding)codon.AddIn.CreateObject(codon.Properties["class"]); - } - - internal bool CanAttach(ITextEditor editor) - { - if (!string.IsNullOrEmpty(editor.FileName)) { - string extension = Path.GetExtension(editor.FileName).ToLowerInvariant(); - foreach (var ext in Extensions) { - if (extension == ext) - return true; - } - } - - return false; - } - - public string Language { - get { - return codon.Id; - } - } - - public Codon Codon { - get { - return codon; - } - } - - public string[] Extensions { - get { - if (extensions == null) { - if (codon.Properties["extensions"].Length == 0) - extensions = new string[0]; - else - extensions = codon.Properties["extensions"].ToLowerInvariant().Split(';'); - } - return extensions; - } - } - } -} diff --git a/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDoozer.cs b/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDoozer.cs index 7dae478f4a..dfa600f5b1 100644 --- a/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDoozer.cs +++ b/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingDoozer.cs @@ -2,7 +2,9 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.IO; using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Editor; namespace ICSharpCode.SharpDevelop { @@ -17,7 +19,7 @@ namespace ICSharpCode.SharpDevelop /// /// Only in /SharpDevelop/Workbench/LanguageBindings /// - /// A LanguageBindingDescriptor object that wraps the ILanguageBinding object. + /// The ILanguageBinding object. /// public class LanguageBindingDoozer : IDoozer { @@ -29,7 +31,28 @@ namespace ICSharpCode.SharpDevelop public object BuildItem(object caller, Codon codon, System.Collections.ArrayList subItems) { - return new LanguageBindingDescriptor(codon); + ITextEditor editor = (ITextEditor)caller; + string[] extensions = codon.Properties["extensions"].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + if (CanAttach(extensions, editor.FileName)) { + return codon.AddIn.CreateObject(codon.Properties["class"]); + } else { + return null; + } + } + + static bool CanAttach(string[] extensions, string fileName) + { + // always attach when no extensions were given + if (extensions.Length == 0) + return true; + if (string.IsNullOrEmpty(fileName)) + return false; + string fileExtension = Path.GetExtension(fileName); + foreach (string ext in extensions) { + if (string.Equals(ext, fileExtension, StringComparison.OrdinalIgnoreCase)) + return true; + } + return false; } } } diff --git a/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs b/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs index 4c78cc9c58..77b0a73b94 100644 --- a/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs +++ b/src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs @@ -11,30 +11,14 @@ namespace ICSharpCode.SharpDevelop public static class LanguageBindingService { const string languageBindingPath = "/SharpDevelop/Workbench/LanguageBindings"; - static readonly List bindings; - - static LanguageBindingService() - { - bindings = AddInTree.BuildItems(languageBindingPath, null, false); - } /// /// Creates the binding for the specified text editor. This method never returns null. /// public static ILanguageBinding CreateBinding(ITextEditor editor) { - return new AggregatedLanguageBinding(FindMatchingBindings(editor)); - } - - static ILanguageBinding[] FindMatchingBindings(ITextEditor editor) - { - List matches = new List(); - foreach (var binding in bindings) { - if (binding.CanAttach(editor)) - matches.Add(binding.CreateBinding(editor)); - } - - return matches.ToArray(); + var bindings = AddInTree.BuildItems(languageBindingPath, editor, false); + return new AggregatedLanguageBinding(bindings); } } } diff --git a/src/Tools/BuildAddinDocumentation/BuildAddinDocumentation.csproj b/src/Tools/BuildAddinDocumentation/BuildAddinDocumentation.csproj index 65582bc743..8bc975b43d 100644 --- a/src/Tools/BuildAddinDocumentation/BuildAddinDocumentation.csproj +++ b/src/Tools/BuildAddinDocumentation/BuildAddinDocumentation.csproj @@ -1,4 +1,5 @@ - + + Exe BuildAddinDocumentation @@ -6,12 +7,18 @@ Debug AnyCPU {211887B2-E9E4-45A4-BE16-6CEA4A7E00F2} + Client + v4.0 + False + False + 4 + false bin\Debug\ False DEBUG;TRACE - True + true Full True @@ -23,9 +30,22 @@ None False + + False + Auto + 4194304 + x86 + 4096 + + + 3.5 + + + 3.5 + diff --git a/src/Tools/BuildAddinDocumentation/BuildAddinDocumentation.sln b/src/Tools/BuildAddinDocumentation/BuildAddinDocumentation.sln index 6a2fb885a3..4f79ddb0f5 100644 --- a/src/Tools/BuildAddinDocumentation/BuildAddinDocumentation.sln +++ b/src/Tools/BuildAddinDocumentation/BuildAddinDocumentation.sln @@ -1,5 +1,7 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# SharpDevelop 2.0.0.783 + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# SharpDevelop 4.0.0.7002 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildAddinDocumentation", "BuildAddinDocumentation.csproj", "{211887B2-E9E4-45A4-BE16-6CEA4A7E00F2}" EndProject Global diff --git a/src/Tools/BuildAddinDocumentation/MainClass.cs b/src/Tools/BuildAddinDocumentation/MainClass.cs index 733654e498..2d5b123e31 100644 --- a/src/Tools/BuildAddinDocumentation/MainClass.cs +++ b/src/Tools/BuildAddinDocumentation/MainClass.cs @@ -24,14 +24,13 @@ namespace BuildAddinDocumentation List doozers = new List(); List conditions = new List(); - if (!ReadXmlDocu(srcDir + "Main\\Core\\Project", doozers, conditions)) - return; - if (!ReadXmlDocu(srcDir + "Main\\Base\\Project", doozers, conditions)) + if (!ReadXmlDocu(srcDir + "Main\\Base\\Project\\ICSharpCode.SharpDevelop.csproj", doozers, conditions)) return; // build normal SharpDevelop: ProcessStartInfo info = new ProcessStartInfo("cmd", "/c debugbuild.bat"); - info.WorkingDirectory = srcDir; + info.WorkingDirectory = Path.GetFullPath(Path.Combine(srcDir, "..")); + Debug.WriteLine(info.WorkingDirectory + ">" + info.FileName + " " + info.Arguments); Process p = Process.Start(info); if (!p.WaitForExit(60000)) { Debug.WriteLine("msbuild did not exit"); @@ -44,7 +43,10 @@ namespace BuildAddinDocumentation sdVersion = FileVersionInfo.GetVersionInfo(Path.GetFullPath(Path.Combine(srcDir, "..\\bin\\SharpDevelop.exe"))); - //sdVersion = FileVersionInfo.GetVersionInfo(Path.GetFullPath(Path.Combine(srcDir, "..\\bin\\ICSharpCode.Core.dll"))); + XmlDocument coreDoc = new XmlDocument(); + coreDoc.Load(srcDir + "..\\bin\\ICSharpCode.Core.xml"); + ReadXmlDocu(coreDoc, doozers, conditions); + Comparison comparison = delegate(XmlElement a, XmlElement b) { string shortNameA = a.GetAttribute("name").Substring(a.GetAttribute("name").LastIndexOf('.') + 1); string shortNameB = b.GetAttribute("name").Substring(b.GetAttribute("name").LastIndexOf('.') + 1); @@ -314,9 +316,14 @@ namespace BuildAddinDocumentation html.WriteLine(""); } - static bool ReadXmlDocu(string projectFolder, List doozers, List conditions) + static bool ReadXmlDocu(string projectFileName, List doozers, List conditions) + { + XmlDocument doc = GetXmlDocu(Path.GetFullPath(projectFileName)); + return ReadXmlDocu(doc, doozers, conditions); + } + + static bool ReadXmlDocu(XmlDocument doc, List doozers, List conditions) { - XmlDocument doc = GetXmlDocu(Path.GetFullPath(projectFolder)); if (doc == null) return false; foreach (XmlNode node in doc.DocumentElement["members"]) { XmlElement member = node as XmlElement; @@ -332,16 +339,16 @@ namespace BuildAddinDocumentation return true; } - static XmlDocument GetXmlDocu(string projectFolder) + static XmlDocument GetXmlDocu(string projectFileName) { string docFile = Path.GetFullPath("doc.xml"); if (File.Exists(docFile)) File.Delete(docFile); - string args = "\"/p:DocumentationFile=" + docFile + "\" \"/p:NoWarn=1591 1573 1574 1572 419\""; - string msbuild = Path.Combine(Path.GetDirectoryName(typeof(object).Assembly.Location), "..\\v3.5\\msbuild.exe"); + string args = Path.GetFileName(projectFileName) + " \"/p:DocumentationFile=" + docFile + "\" \"/p:NoWarn=1591 1573 1574 1572 419\""; + string msbuild = Path.Combine(Path.GetDirectoryName(typeof(object).Assembly.Location), "msbuild.exe"); ProcessStartInfo info = new ProcessStartInfo(msbuild, args); - Debug.WriteLine(projectFolder + ">" + msbuild + " " + args); - info.WorkingDirectory = projectFolder; + info.WorkingDirectory = Path.GetDirectoryName(projectFileName); + Debug.WriteLine(info.WorkingDirectory + ">" + info.FileName + " " + info.Arguments); Process p = Process.Start(info); if (!p.WaitForExit(60000)) { Debug.WriteLine("msbuild did not exit"); From 000d891754015b9b4d4e818ab4e54ee7ca078fd2 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 15 Dec 2010 18:46:13 +0100 Subject: [PATCH 61/88] Add "embedded image" sample AddIn. --- .../Configuration/AssemblyInfo.cs | 31 ++++++ .../EmbeddedImageAddIn.addin | 20 ++++ .../EmbeddedImageAddIn.csproj | 80 ++++++++++++++ .../EmbeddedImageAddIn/EmbeddedImageAddIn.sln | 18 ++++ .../EmbeddedImageLanguageBinding.cs | 38 +++++++ samples/EmbeddedImageAddIn/ImageCache.cs | 58 ++++++++++ samples/EmbeddedImageAddIn/ImageElement.cs | 101 ++++++++++++++++++ .../ImageElementGenerator.cs | 62 +++++++++++ .../EmbeddedImageAddIn/InsertImageCommand.cs | 39 +++++++ 9 files changed, 447 insertions(+) create mode 100644 samples/EmbeddedImageAddIn/Configuration/AssemblyInfo.cs create mode 100644 samples/EmbeddedImageAddIn/EmbeddedImageAddIn.addin create mode 100644 samples/EmbeddedImageAddIn/EmbeddedImageAddIn.csproj create mode 100644 samples/EmbeddedImageAddIn/EmbeddedImageAddIn.sln create mode 100644 samples/EmbeddedImageAddIn/EmbeddedImageLanguageBinding.cs create mode 100644 samples/EmbeddedImageAddIn/ImageCache.cs create mode 100644 samples/EmbeddedImageAddIn/ImageElement.cs create mode 100644 samples/EmbeddedImageAddIn/ImageElementGenerator.cs create mode 100644 samples/EmbeddedImageAddIn/InsertImageCommand.cs diff --git a/samples/EmbeddedImageAddIn/Configuration/AssemblyInfo.cs b/samples/EmbeddedImageAddIn/Configuration/AssemblyInfo.cs new file mode 100644 index 0000000000..a34d760501 --- /dev/null +++ b/samples/EmbeddedImageAddIn/Configuration/AssemblyInfo.cs @@ -0,0 +1,31 @@ +#region Using directives + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("EmbeddedImageAddIn")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("EmbeddedImageAddIn")] +[assembly: AssemblyCopyright("Copyright 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all the values or you can use the default the Revision and +// Build Numbers by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] diff --git a/samples/EmbeddedImageAddIn/EmbeddedImageAddIn.addin b/samples/EmbeddedImageAddIn/EmbeddedImageAddIn.addin new file mode 100644 index 0000000000..4c46efa291 --- /dev/null +++ b/samples/EmbeddedImageAddIn/EmbeddedImageAddIn.addin @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/samples/EmbeddedImageAddIn/EmbeddedImageAddIn.csproj b/samples/EmbeddedImageAddIn/EmbeddedImageAddIn.csproj new file mode 100644 index 0000000000..bb3a6144b4 --- /dev/null +++ b/samples/EmbeddedImageAddIn/EmbeddedImageAddIn.csproj @@ -0,0 +1,80 @@ + + + + {1F60F9B0-E2FE-462F-9758-2E834D845438} + Debug + x86 + Library + EmbeddedImageAddIn + EmbeddedImageAddIn + v4.0 + ..\..\AddIns\Samples\EmbeddedImage\ + False + False + 4 + false + + + x86 + False + Auto + 4194304 + 4096 + + + true + Full + False + True + DEBUG;TRACE + + + False + None + True + False + TRACE + + + + ..\..\bin\ICSharpCode.AvalonEdit.dll + False + + + ..\..\bin\ICSharpCode.Core.dll + False + + + ..\..\bin\ICSharpCode.SharpDevelop.dll + False + + + + + + 3.5 + + + + + + + 3.5 + + + + + + Always + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/EmbeddedImageAddIn/EmbeddedImageAddIn.sln b/samples/EmbeddedImageAddIn/EmbeddedImageAddIn.sln new file mode 100644 index 0000000000..1787be60a2 --- /dev/null +++ b/samples/EmbeddedImageAddIn/EmbeddedImageAddIn.sln @@ -0,0 +1,18 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# SharpDevelop 4.0.0.7002 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmbeddedImageAddIn", "EmbeddedImageAddIn.csproj", "{1F60F9B0-E2FE-462F-9758-2E834D845438}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1F60F9B0-E2FE-462F-9758-2E834D845438}.Debug|x86.Build.0 = Debug|x86 + {1F60F9B0-E2FE-462F-9758-2E834D845438}.Debug|x86.ActiveCfg = Debug|x86 + {1F60F9B0-E2FE-462F-9758-2E834D845438}.Release|x86.Build.0 = Release|x86 + {1F60F9B0-E2FE-462F-9758-2E834D845438}.Release|x86.ActiveCfg = Release|x86 + EndGlobalSection +EndGlobal diff --git a/samples/EmbeddedImageAddIn/EmbeddedImageLanguageBinding.cs b/samples/EmbeddedImageAddIn/EmbeddedImageLanguageBinding.cs new file mode 100644 index 0000000000..d06af3aac2 --- /dev/null +++ b/samples/EmbeddedImageAddIn/EmbeddedImageLanguageBinding.cs @@ -0,0 +1,38 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT X11 license (for details please see \doc\license.txt) + +using System; +using System.IO; +using ICSharpCode.AvalonEdit.Rendering; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Editor; + +namespace EmbeddedImageAddIn +{ + // SharpDevelop creates one instance of EmbeddedImageLanguageBinding for each text editor. + public class EmbeddedImageLanguageBinding : DefaultLanguageBinding + { + TextView textView; + ImageElementGenerator g; + + public override void Attach(ITextEditor editor) + { + base.Attach(editor); + // ITextEditor is SharpDevelop's abstraction of the text editor. + // We use GetService() to get the underlying AvalonEdit instance. + textView = editor.GetService(typeof(TextView)) as TextView; + if (textView != null) { + g = new ImageElementGenerator(Path.GetDirectoryName(editor.FileName)); + textView.ElementGenerators.Add(g); + } + } + + public override void Detach() + { + if (textView != null) { + textView.ElementGenerators.Remove(g); + } + base.Detach(); + } + } +} diff --git a/samples/EmbeddedImageAddIn/ImageCache.cs b/samples/EmbeddedImageAddIn/ImageCache.cs new file mode 100644 index 0000000000..5ebede8f2b --- /dev/null +++ b/samples/EmbeddedImageAddIn/ImageCache.cs @@ -0,0 +1,58 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT X11 license (for details please see \doc\license.txt) + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Windows.Media; +using System.Windows.Media.Imaging; + +using ICSharpCode.Core; + +namespace EmbeddedImageAddIn +{ + public static class ImageCache + { + static readonly Dictionary imageCache = new Dictionary(); + + public static ImageSource GetImage(FileName fileName) + { + lock (imageCache) { + WeakReference wr; + ImageSource image; + // retrieve image from cache, if possible + if (imageCache.TryGetValue(fileName, out wr)) { + image = (ImageSource)wr.Target; + if (image != null) + return image; + } + // load image: + image = LoadBitmap(fileName); + if (image != null) + imageCache[fileName] = new WeakReference(image); + // clean up cache: + List entriesToRemove = (from p in imageCache where !p.Value.IsAlive select p.Key).ToList(); + foreach (var entry in entriesToRemove) + imageCache.Remove(entry); + return image; + } + } + + static BitmapImage LoadBitmap(string fileName) + { + try { + if (File.Exists(fileName)) { + BitmapImage bitmap = new BitmapImage(new Uri(fileName)); + bitmap.Freeze(); + return bitmap; + } + } catch (ArgumentException) { + // invalid filename syntax + } catch (IOException) { + // other IO error + } + return null; + } + } +} diff --git a/samples/EmbeddedImageAddIn/ImageElement.cs b/samples/EmbeddedImageAddIn/ImageElement.cs new file mode 100644 index 0000000000..23b5a815d9 --- /dev/null +++ b/samples/EmbeddedImageAddIn/ImageElement.cs @@ -0,0 +1,101 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT X11 license (for details please see \doc\license.txt) + +using System; +using System.Diagnostics; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.TextFormatting; +using ICSharpCode.AvalonEdit.Rendering; + +namespace EmbeddedImageAddIn +{ + /// + /// VisualLineElement implementation for embedded images. + /// + public class ImageElement : VisualLineElement + { + readonly string imageFileName; + readonly ImageSource image; + + public ImageElement(string imageFileName, ImageSource image, int documentLength) : base(1, documentLength) + { + if (imageFileName == null) + throw new ArgumentNullException("imageFileName"); + if (image == null) + throw new ArgumentNullException("image"); + this.imageFileName = imageFileName; + this.image = image; + } + + public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context) + { + return new ImageTextRun(image, this.TextRunProperties); + } + + protected override void OnMouseDown(MouseButtonEventArgs e) + { + base.OnMouseDown(e); + if (!e.Handled && e.ClickCount == 2) { + // double click on image: open the image in editor + try { + Process.Start(imageFileName); + } catch (Exception ex) { + MessageBox.Show(ex.Message); + } + } + } + + sealed class ImageTextRun : TextEmbeddedObject + { + readonly ImageSource image; + readonly TextRunProperties properties; + + public ImageTextRun(ImageSource image, TextRunProperties properties) + { + this.image = image; + this.properties = properties; + } + + public override LineBreakCondition BreakBefore { + get { return LineBreakCondition.BreakPossible; } + } + + public override LineBreakCondition BreakAfter { + get { return LineBreakCondition.BreakPossible; } + } + + public override bool HasFixedSize { + get { return true; } + } + + public override CharacterBufferReference CharacterBufferReference { + get { return new CharacterBufferReference(); } + } + + public override int Length { + get { return 1; } + } + + public override TextRunProperties Properties { + get { return properties; } + } + + public override TextEmbeddedObjectMetrics Format(double remainingParagraphWidth) + { + return new TextEmbeddedObjectMetrics(image.Width, image.Height, image.Height); + } + + public override Rect ComputeBoundingBox(bool rightToLeft, bool sideways) + { + return new Rect(0, 0, image.Width, image.Height); + } + + public override void Draw(DrawingContext drawingContext, Point origin, bool rightToLeft, bool sideways) + { + drawingContext.DrawImage(image, new Rect(origin.X, origin.Y - image.Height, image.Width, image.Height)); + } + } + } +} diff --git a/samples/EmbeddedImageAddIn/ImageElementGenerator.cs b/samples/EmbeddedImageAddIn/ImageElementGenerator.cs new file mode 100644 index 0000000000..725ac8515e --- /dev/null +++ b/samples/EmbeddedImageAddIn/ImageElementGenerator.cs @@ -0,0 +1,62 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT X11 license (for details please see \doc\license.txt) + +using System; +using System.IO; +using System.Text.RegularExpressions; +using System.Windows.Media; +using ICSharpCode.AvalonEdit.Document; +using ICSharpCode.AvalonEdit.Rendering; +using ICSharpCode.Core; + +namespace EmbeddedImageAddIn +{ + /// + /// Implementation of AvalonEdit element generator. + /// This class looks for image tags and produces ImageElements to visually represent those images. + /// + public class ImageElementGenerator : VisualLineElementGenerator + { + readonly static Regex imageRegex = new Regex(@"<>"); + + readonly string baseDirectory; + + public ImageElementGenerator(string baseDirectory) + { + this.baseDirectory = baseDirectory; + } + + Match GetMatch(int startOffset) + { + DocumentLine endLine = CurrentContext.VisualLine.LastDocumentLine; + string relevantText = CurrentContext.Document.GetText(startOffset, endLine.EndOffset - startOffset); + return imageRegex.Match(relevantText); + } + + /// Gets the first offset >= startOffset where the generator wants to construct + /// an element. + /// Return -1 to signal no interest. + public override int GetFirstInterestedOffset(int startOffset) + { + Match m = GetMatch(startOffset); + return m.Success ? startOffset + m.Index : -1; + } + + /// Constructs an element at the specified offset. + /// May return null if no element should be constructed. + public override VisualLineElement ConstructElement(int offset) + { + Match m = GetMatch(offset); + // check whether there's a match exactly at offset + if (m.Success && m.Index == 0) { + string fileName = Path.Combine(baseDirectory, m.Groups[1].Value); + ImageSource image = ImageCache.GetImage(FileName.Create(fileName)); + if (image != null) { + // Pass the length of the match to the 'documentLength' parameter of ImageElement. + return new ImageElement(fileName, image, m.Length); + } + } + return null; + } + } +} diff --git a/samples/EmbeddedImageAddIn/InsertImageCommand.cs b/samples/EmbeddedImageAddIn/InsertImageCommand.cs new file mode 100644 index 0000000000..983562c225 --- /dev/null +++ b/samples/EmbeddedImageAddIn/InsertImageCommand.cs @@ -0,0 +1,39 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT X11 license (for details please see \doc\license.txt) + +using System; +using System.IO; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Gui; +using Microsoft.Win32; + +namespace EmbeddedImageAddIn +{ + /// + /// "Edit > Insert > Image" menu command. + /// + public class InsertImageCommand : AbstractMenuCommand + { + public override void Run() + { + if (WorkbenchSingleton.Workbench.ActiveViewContent == null) + return; + ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveViewContent.GetService(typeof(ITextEditorProvider)) as ITextEditorProvider; + if (provider == null) + return; + OpenFileDialog dlg = new OpenFileDialog(); + dlg.Filter = "Image files|*.png;*.jpg;*.gif;*.bmp;*.jpeg|All files|*.*"; + dlg.CheckFileExists = true; + dlg.DereferenceLinks = true; + string baseDirectory = Path.GetDirectoryName(provider.TextEditor.FileName); + dlg.InitialDirectory = baseDirectory; + if (dlg.ShowDialog() == true) { + string relativePath = FileUtility.GetRelativePath(baseDirectory, dlg.FileName); + if (!Path.IsPathRooted(relativePath)) + relativePath = relativePath.Replace('\\', '/'); + provider.TextEditor.Document.Insert(provider.TextEditor.Caret.Offset, "<>"); + } + } + } +} From f45bf5e1d73a6c018c804a8a55e0cdfb38e8981b Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 11 Dec 2010 22:03:16 +0100 Subject: [PATCH 62/88] created new ctor with optional parameters in ProfilerOptions for better usability --- .../Profiler/Controller/ProfilerOptions.cs | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/AddIns/Analysis/Profiler/Controller/ProfilerOptions.cs b/src/AddIns/Analysis/Profiler/Controller/ProfilerOptions.cs index a02a9ee68c..1c443b608c 100644 --- a/src/AddIns/Analysis/Profiler/Controller/ProfilerOptions.cs +++ b/src/AddIns/Analysis/Profiler/Controller/ProfilerOptions.cs @@ -89,9 +89,13 @@ namespace ICSharpCode.Profiler.Controller /// /// Creates new ProfilerOptions using the selected settings. /// - public ProfilerOptions(bool enableDC, int sharedMemorySize, bool profileDotNetInternals, - bool combineRecursiveFunction, bool enableDCAtStart, bool trackEvents, - IEnumerable counters) + public ProfilerOptions(bool enableDC = true, + int sharedMemorySize = DefaultSharedMemorySize, + bool profileDotNetInternals = false, + bool combineRecursiveFunction = false, + bool enableDCAtStart = true, + bool trackEvents = false, + IEnumerable counters = null) { this.enableDC = enableDC; this.sharedMemorySize = sharedMemorySize; @@ -99,15 +103,7 @@ namespace ICSharpCode.Profiler.Controller this.combineRecursiveFunction = combineRecursiveFunction; this.enableDCAtStart = enableDCAtStart; this.trackEvents = trackEvents; - this.counters = counters.ToArray(); - } - - /// - /// Creates default ProfilerOptions. - /// - public ProfilerOptions() - : this(true, DefaultSharedMemorySize, false, false, true, false, DefaultCounters) - { + this.counters = (counters ?? DefaultCounters).ToArray(); } } } From 66cfa9957e079b62d5b3b940ea86f8f010488bbd Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 15 Dec 2010 16:45:11 +0100 Subject: [PATCH 63/88] fixed background color of ColorPicker popup --- src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs b/src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs index 93740e689d..313c7c1690 100644 --- a/src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs +++ b/src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs @@ -59,7 +59,9 @@ namespace ICSharpCode.SharpDevelop.Gui void ButtonClick(object sender, RoutedEventArgs e) { - var control = new Widgets.ColorPicker(); + var control = new Widgets.ColorPicker() { + Background = SystemColors.ControlBrush + }; Popup popup = new Popup() { Child = control, Placement = PlacementMode.Bottom, From 998a9db966a2ca06cc10a05f0f98b1a7370baa95 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 15 Dec 2010 17:11:46 +0100 Subject: [PATCH 64/88] fixed SD-1780 - Xaml code completion tooltip hides completion window --- .../XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs index 02855f0047..2a884b04b2 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlCodeCompletionBinding.cs @@ -387,9 +387,9 @@ namespace ICSharpCode.XamlBinding string word = context.Editor.GetWordBeforeCaretExtended(); if (context.PressedKey != '.' && context.PressedKey != '=' && !word.EndsWith(".") && completionList.PreselectionLength == 0) completionList.PreselectionLength = word.Length; - context.Editor.ShowCompletionWindow(completionList); var insightList = CompletionDataHelper.CreateMarkupExtensionInsight(context); context.Editor.ShowInsightWindow(insightList); + context.Editor.ShowCompletionWindow(completionList); return completionList.Items.Any() || insightList.Any(); } From eece1ecd85692238c01fee95acaa10b618c59120 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 15 Dec 2010 21:57:08 +0100 Subject: [PATCH 65/88] fixed SD-1583 - Finalize() is visible in C# override completion --- .../OverrideCompletionItemProvider.cs | 2 +- .../Project/Src/LanguageProperties.cs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/OverrideCompletionItemProvider.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/OverrideCompletionItemProvider.cs index 1bc2a5d2ca..e853f1a6b8 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/OverrideCompletionItemProvider.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/OverrideCompletionItemProvider.cs @@ -48,7 +48,7 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion LanguageProperties language = c.ProjectContent.Language; OverrideCompletionItemList result = new OverrideCompletionItemList(); foreach (IMember m in GetOverridableMembers(c)) { - if (language.ShowMember(m, false)) { + if (language.ShowMemberInOverrideCompletion(m)) { result.Items.Add(new OverrideCompletionItem(m)); } } diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs index 0d2c129ebb..b6ee46075a 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs @@ -228,6 +228,11 @@ namespace ICSharpCode.SharpDevelop.Dom } return member.IsStatic == showStatic; } + + public virtual bool ShowMemberInOverrideCompletion(IMember member) + { + return true; + } #endregion /// @@ -320,6 +325,18 @@ namespace ICSharpCode.SharpDevelop.Dom } return true; } + + public override bool ShowMemberInOverrideCompletion(IMember member) + { + IMethod method = member as IMethod; + + if (method != null) { + if (method.Name == "Finalize" && method.Parameters.Count == 0) + return false; + } + + return base.ShowMemberInOverrideCompletion(member); + } } #endregion From b130c95019f1d08eac5c55f3bf1bfc6c61a8568b Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 15 Dec 2010 20:19:53 +0100 Subject: [PATCH 66/88] Make TextRunProperties setter private. --- .../ICSharpCode.AvalonEdit/Rendering/VisualLineElement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineElement.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineElement.cs index 026e9c0f99..0d5585ac96 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineElement.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLineElement.cs @@ -60,7 +60,7 @@ namespace ICSharpCode.AvalonEdit.Rendering /// will affect only this /// . /// - public VisualLineElementTextRunProperties TextRunProperties { get; set; } + public VisualLineElementTextRunProperties TextRunProperties { get; private set; } internal void SetTextRunProperties(VisualLineElementTextRunProperties p) { From 0c9ddb5f7449368fd3cd9a4a8da165949b61e350 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 16 Dec 2010 15:47:45 +0100 Subject: [PATCH 67/88] Update to AvalonDock 1.3.3585. --- .../Themes/ExpressionDark.xaml | 35 +++++++++- .../AvalonDock.Themes/Themes/dev2010.xaml | 14 +++- .../AvalonDock/AvalonDock/DockingManager.cs | 67 ------------------- .../AvalonDock/AvalonDock/DocumentPane.cs | 7 +- .../AvalonDock/FloatingDockablePane.cs | 2 +- .../AvalonDock/AvalonDock/FloatingWindow.cs | 54 --------------- .../AvalonDock/AvalonDock/FlyoutPaneWindow.cs | 16 +++-- .../AvalonDock/LogicalTreeAdapter.cs | 3 + .../AvalonDock/AvalonDock/NavigatorWindow.cs | 32 +-------- .../AvalonDock/Properties/AssemblyInfo.cs | 4 +- .../Resources/DockablePaneStyles.xaml | 5 ++ .../AvalonDock/Themes/aero.normalcolor.xaml | 14 +++- .../AvalonDock/AvalonDock/Themes/classic.xaml | 10 ++- 13 files changed, 95 insertions(+), 168 deletions(-) diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml index 95eaabfb06..ad074042e1 100644 --- a/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml @@ -414,7 +414,10 @@ - + + + + @@ -428,6 +431,36 @@ + + + - + - + + + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml b/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml index 82a3b60b98..a83c4637a0 100644 --- a/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml @@ -119,7 +119,7 @@ BorderBrush="DarkGray" Height="18"> -