Browse Source

Merged Corsavy r1183:1195 to trunk:

Improved VB -> C# converter.
Add Grouping (only one Column) to SharpReport
Fixed exception when opening a solution containing web projects.
Fixed SD2-711: Clear all bookmarks menu option selected when bookmarks pad not visible

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1199 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
b1945c6366
  1. 36
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeDiscoveryService.cs
  2. 14
      src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs
  3. 52
      src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs
  4. 1
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs
  5. 6
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs
  6. 38
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs
  7. 21
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs
  8. 48
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs
  9. 8
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs
  10. 16
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs
  11. 28
      src/AddIns/Misc/SharpReport/SharpReportCore/ConnectionObject.cs
  12. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/BaseComparer.cs
  13. 103
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupComparer.cs
  14. 97
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupSeperator.cs
  15. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/SortComparer.cs
  16. 250
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs
  17. 56
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/ExtendedPropertyDescriptor.cs
  18. 45
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/IExtendedList.cs
  19. 41
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/IHierarchicalArray.cs
  20. 8
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/PropertyTypeHash.cs
  21. 383
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/SharpArrayList.cs
  22. 263
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/BaseListStrategy.cs
  23. 228
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/CollectionStrategy.cs
  24. 296
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs
  25. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/SqlQueryChecker.cs
  26. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/MissingDataSourceException.cs
  27. 15
      src/AddIns/Misc/SharpReport/SharpReportCore/Globals/FontSingleton.cs
  28. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs
  29. 7
      src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataContainer.cs
  30. 27
      src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataViewStrategy.cs
  31. 15
      src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IHierarchyInterfaces.cs
  32. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IOutputStrategy.cs
  33. 15
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  34. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs
  35. 26
      src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs
  36. 66
      src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs
  37. 7
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj
  38. 61
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs
  39. 30
      src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs
  40. 1
      src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets
  41. 89
      src/Libraries/NRefactory/Project/Src/Parser/Visitors/VBNetConstructsConvertVisitor.cs
  42. 42
      src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs
  43. 19
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs
  44. 7
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddWebReferenceDialog.cs
  45. 6
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/WebServiceDiscoveryClientProtocol.cs
  46. 8
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs
  47. 12
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserPad.cs
  48. 6
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserPanel.cs
  49. 5
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs
  50. 2
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/FileNode.cs
  51. 27
      src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
  52. 19
      src/Main/Base/Project/Src/Project/AbstractProject.cs
  53. 3
      src/Main/Base/Project/Src/Project/Converter/LanguageConverter.cs
  54. 7
      src/Main/Base/Project/Src/Project/IProject.cs
  55. 4
      src/Main/Base/Project/Src/Project/MSBuildProject.cs
  56. 4
      src/Main/Base/Project/Src/Project/MissingProject.cs
  57. 6
      src/Main/Base/Project/Src/Project/Solution/ProjectSection.cs
  58. 42
      src/Main/Base/Project/Src/Project/Solution/Solution.cs
  59. 17
      src/Main/Base/Project/Src/Project/Solution/SolutionFolder.cs
  60. 4
      src/Main/Base/Project/Src/Project/UnknownProject.cs
  61. 6
      src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs
  62. 7
      src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs
  63. 3
      src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs
  64. 19
      src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs
  65. 3
      src/Main/Core/Test/AddInTreeTests/ExtPathTests.cs

36
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeDiscoveryService.cs

@ -34,22 +34,30 @@ namespace ICSharpCode.FormsDesigner.Services @@ -34,22 +34,30 @@ namespace ICSharpCode.FormsDesigner.Services
public ICollection GetTypes(Type baseType, bool excludeGlobalTypes)
{
List<Type> types = new List<Type>();
if (baseType != null) {
LoggingService.Debug("TypeDiscoveryService.GetTypes for " + baseType.FullName
+ "excludeGlobalTypes=" + excludeGlobalTypes.ToString());
//seek in all assemblies
//allow to work designers like columns editor in datagridview
// Searching types can cause additional assemblies to be loaded, so we need to use
// ToArray to prevent an exception if the collection changes.
foreach (Assembly asm in TypeResolutionService.DesignerAssemblies.ToArray()) {
AddDerivedTypes(baseType, asm, types);
if (baseType == null) {
baseType = typeof(object);
}
LoggingService.Debug("TypeDiscoveryService.GetTypes for " + baseType.FullName
+ "excludeGlobalTypes=" + excludeGlobalTypes.ToString());
//seek in all assemblies
//allow to work designers like columns editor in datagridview
// Searching types can cause additional assemblies to be loaded, so we need to use
// ToArray to prevent an exception if the collection changes.
foreach (Assembly asm in TypeResolutionService.DesignerAssemblies.ToArray()) {
if (excludeGlobalTypes) {
if (FileUtility.IsBaseDirectory(ReflectionProjectContent.GacRootPath, asm.Location)) {
continue;
}
}
LoggingService.Debug("TypeDiscoveryService returns " + types.Count + " types");
// TODO - Don't look in all assemblies.
// Should use the current project and its referenced assemblies
// as well as System.Windows.Forms.
AddDerivedTypes(baseType, asm, types);
}
LoggingService.Debug("TypeDiscoveryService returns " + types.Count + " types");
// TODO - Don't look in all assemblies.
// Should use the current project and its referenced assemblies
// as well as System.Windows.Forms.
return types;
}

14
src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs

@ -57,13 +57,10 @@ namespace SharpReport.Designer @@ -57,13 +57,10 @@ namespace SharpReport.Designer
#region overrides
protected override void Dispose(bool disposing ) {
if( disposing )
{
// if( components != null )
// components.Dispose();
if( disposing ){
this.reportControl = null;
this.ctrlRuler1 = null;
}
this.reportControl = null;
this.ctrlRuler1 = null;
base.Dispose( disposing );
}
@ -110,7 +107,10 @@ namespace SharpReport.Designer @@ -110,7 +107,10 @@ namespace SharpReport.Designer
public ReportModel ReportModel {
get {
reportModel.ReportSettings = reportControl.ReportSettings;
reportModel.SectionCollection = reportControl.SectionCollection;
reportModel.SectionCollection.Clear();
foreach (ReportSection section in reportControl.SectionCollection) {
reportModel.SectionCollection.Add (section);
}
return this.reportModel;
}

52
src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs

@ -73,7 +73,6 @@ namespace SharpReport{ @@ -73,7 +73,6 @@ namespace SharpReport{
/// <returns><see cref="ColumnCollection"</returns>
private ColumnCollection ReadColumnCollection() {
ColumnCollection columnCollecion = new ColumnCollection();
switch (baseDesignerControl.ReportModel.DataModel) {
case GlobalEnums.enmPushPullModel.FormSheet:
@ -88,13 +87,20 @@ namespace SharpReport{ @@ -88,13 +87,20 @@ namespace SharpReport{
if (base.ConnectionObject == null) {
base.ConnectionObject = this.BuildConnectionObject(baseDesignerControl.ReportModel.ReportSettings);
}
if (this.baseDesignerControl.ReportModel.DataModel.Equals(GlobalEnums.enmPushPullModel.PullData)){
using (DataManager dataManager = new DataManager(base.ConnectionObject,
baseDesignerControl.ReportModel.ReportSettings)) {
dataManager.DataBind();
columnCollecion = dataManager.AvailableFields;
try {
using (DataManager dataManager = new DataManager(base.ConnectionObject,
baseDesignerControl.ReportModel.ReportSettings)) {
dataManager.DataBind();
columnCollecion = dataManager.AvailableFields;
}
} catch (Exception e) {
throw e;
} finally {
System.Console.WriteLine("ReportManager:ReadColumnCollection in finally");
}
}
break;
@ -104,10 +110,7 @@ namespace SharpReport{ @@ -104,10 +110,7 @@ namespace SharpReport{
return columnCollecion;
}
private void AddItemsToSection (BaseSection section,ReportItemCollection collection) {
if ((section == null)|| (collection == null) ) {
@ -324,6 +327,7 @@ namespace SharpReport{ @@ -324,6 +327,7 @@ namespace SharpReport{
if (base.ConnectionObject == null) {
base.ConnectionObject = this.BuildConnectionObject(model.ReportSettings);
}
return base.AbstractRenderer(model);
}
@ -478,20 +482,22 @@ namespace SharpReport{ @@ -478,20 +482,22 @@ namespace SharpReport{
}
protected new void Dispose(bool disposing){
if (disposing) {
// Free other state (managed objects).
if (this.baseDesignerControl != null) {
this.baseDesignerControl.Dispose();
}
if (this.reportModel != null) {
this.reportModel.Dispose();
try {
if (disposing) {
// Free other state (managed objects).
if (this.baseDesignerControl != null) {
this.baseDesignerControl.Dispose();
}
if (this.reportModel != null) {
this.reportModel.Dispose();
}
}
} finally {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
base.Dispose();
}
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
base.Dispose();
}
#endregion
}

1
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs

@ -70,7 +70,6 @@ namespace SharpReportAddin { @@ -70,7 +70,6 @@ namespace SharpReportAddin {
return GlobalValues.IsValidPrinter();
}
public virtual ICSharpCode.SharpDevelop.Gui.IViewContent CreateContentForFile(string fileName) {
if (GlobalValues.IsValidPrinter() == true) {
SharpReportView view = new SharpReportView();

6
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs

@ -502,7 +502,6 @@ namespace SharpReportAddin{ @@ -502,7 +502,6 @@ namespace SharpReportAddin{
public override void Load(string fileName){
try {
designerControl.ReportControl.ObjectSelected -= new EventHandler <EventArgs>(OnObjectSelected);
reportManager.LoadFromFile (fileName);
base.FileName = fileName;
designerControl.ReportModel.ReportSettings.FileName = fileName;
@ -511,10 +510,9 @@ namespace SharpReportAddin{ @@ -511,10 +510,9 @@ namespace SharpReportAddin{
PropertyPad.Grid.SelectedObject = designerControl.ReportModel.ReportSettings;
PropertyPad.Grid.Refresh();
}
this.designerControl.ReportModel.ReportSettings.AvailableFieldsCollection = reportManager.AvailableFieldsCollection;
} catch (Exception ) {
} catch (Exception e) {
MessageService.ShowError(e,"SharpReportView:Load");
throw ;
}
}

38
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs

@ -98,15 +98,7 @@ namespace SharpReportCore { @@ -98,15 +98,7 @@ namespace SharpReportCore {
#endregion
#region System.IDisposable interface implementation
public virtual void Dispose() {
if(Disposed != null){
Disposed(this,EventArgs.Empty);
}
}
#endregion
#region Properties
@ -169,5 +161,33 @@ namespace SharpReportCore { @@ -169,5 +161,33 @@ namespace SharpReportCore {
#endregion
#region IDisposeable
public override void Dispose () {
Dispose(true);
GC.SuppressFinalize(this);
}
~BaseReportItem(){
Dispose(false);
}
protected override void Dispose(bool disposing) {
try {
if (disposing){
if (this.font != null){
this.font = null;
this.font.Dispose();
}
}
} finally {
if (this.Disposed != null) {
this.Disposed (this,EventArgs.Empty);
}
base.Dispose(disposing);
}
}
#endregion
}
}

21
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs

@ -25,7 +25,8 @@ using System.Drawing; @@ -25,7 +25,8 @@ using System.Drawing;
/// </remarks>
namespace SharpReportCore {
public class BaseReportObject : IBaseRenderer,INotifyPropertyChanged {
public class BaseReportObject : IBaseRenderer,INotifyPropertyChanged,
IDisposable{
private string name;
private object parent;
@ -212,5 +213,23 @@ namespace SharpReportCore { @@ -212,5 +213,23 @@ namespace SharpReportCore {
}
#endregion
#region IDisposable
public virtual void Dispose () {
Dispose(true);
GC.SuppressFinalize(this);
}
~BaseReportObject(){
Dispose(false);
}
protected virtual void Dispose(bool disposing) {
if (disposing){
}
}
#endregion
}
}

48
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
@ -16,32 +16,56 @@ using System.ComponentModel; @@ -16,32 +16,56 @@ using System.ComponentModel;
/// created by - Forstmeier Helmut
/// created on - 01.09.2005 13:12:32
/// </remarks>
namespace SharpReportCore {
namespace SharpReportCore {
public class BaseSection : SharpReportCore.BaseReportObject {
private ReportItemCollection items;
public BaseSection(): this("") {
#region Constructors
public BaseSection(): base() {
this.Name = String.Empty;
}
public BaseSection (string sectionName) :base(){
this.Name = sectionName;
}
#endregion
#region System.IDisposable interface implementation
public void Dispose() {
for (int i = 0;i < items.Count ;i ++ ){
((BaseReportItem)items[i]).Dispose();
}
public override void Dispose () {
Dispose(true);
GC.SuppressFinalize(this);
}
~BaseSection(){
Dispose(false);
}
protected override void Dispose(bool disposing) {
try {
if (disposing){
if (this.items != null) {
this.items.Clear();
this.items = null;
}
}
} finally {
base.Dispose(disposing);
}
}
#endregion
#region properties
public BaseSection (string sectionName) :base(){
this.Name = sectionName;
items = new ReportItemCollection();
}
[Browsable(false)]
public ReportItemCollection Items{
get {
if (this.items == null) {
items = new ReportItemCollection();
}
return items;
}
}

8
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs

@ -75,10 +75,10 @@ namespace SharpReportCore { @@ -75,10 +75,10 @@ namespace SharpReportCore {
}
}
public override void Dispose() {
base.Dispose();
this.image = null;
}
// public override void Dispose() {
// base.Dispose();
// this.image = null;
// }
public override string ToString() {
return "BaseImageItem";

16
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs

@ -76,14 +76,14 @@ namespace SharpReportCore { @@ -76,14 +76,14 @@ namespace SharpReportCore {
#region System.IDisposable interface implementation
public override void Dispose() {
base.Dispose();
for (int i = 0; i < arrayList.Count;i ++ ) {
IComponent curObj = (IComponent)arrayList[i];
curObj.Dispose();
}
arrayList = null;
}
// public override void Dispose() {
// base.Dispose();
// for (int i = 0; i < arrayList.Count;i ++ ) {
// IComponent curObj = (IComponent)arrayList[i];
// curObj.Dispose();
// }
// arrayList = null;
// }
#endregion

28
src/AddIns/Misc/SharpReport/SharpReportCore/ConnectionObject.cs

@ -55,15 +55,33 @@ namespace SharpReportCore { @@ -55,15 +55,33 @@ namespace SharpReportCore {
}
}
#region IDisposeable
public void Dispose () {
Dispose(true);
GC.SuppressFinalize(this);
}
~ConnectionObject(){
Dispose(false);
}
public void Dispose(){
if (this.connection != null) {
if (this.connection.State == ConnectionState.Open) {
this.connection.Close();
protected virtual void Dispose(bool disposing) {
try{
if (disposing){
if (this.connection != null){
if (this.connection.State == ConnectionState.Open) {
this.connection.Close();
}
this.connection.Dispose();
}
}
this.connection.Dispose();
}
finally{
connection = null;
}
}
#endregion
}
}

4
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/BaseComparer.cs

@ -33,13 +33,13 @@ namespace SharpReportCore { @@ -33,13 +33,13 @@ namespace SharpReportCore {
}
/// <summary>
/// TODO - add method description
/// Interface method from IComparable
/// </summary>
/// <remarks>
/// Interface method from IComparable
///
/// </remarks>
/// <param name='obj'>TODO - add parameter description</param>
/// <param name='obj'>a <see cref="BaseComparer"></see></param>
public virtual int CompareTo(object obj) {
return 0;
}

103
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupComparer.cs

@ -1,103 +0,0 @@ @@ -1,103 +0,0 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Text;
using System.ComponentModel;
using SharpReportCore;
/// <summary>
/// TODO - Add class summary
/// </summary>
/// <remarks>
/// created by - Forstmeier Helmut
/// created on - 27.11.2005 14:59:28
/// </remarks>
namespace SharpReportCore {
public class GroupComparer : SharpReportCore.BaseComparer{
public GroupComparer(ColumnCollection owner, int listIndex, object[] values):
base(owner,listIndex,values) {
}
internal int CompareTo(GroupComparer value)
{
// we shouldn't get to this point
if (value == null)
throw new ArgumentNullException("value");
if (value.ObjectArray.Length != base.ObjectArray.Length)
throw new InvalidOperationException("Differnet size of compare data");
int compare = 0;
for (int index = 0; index < base.ObjectArray.Length; index++)
{
object leftValue = base.ObjectArray[index];
object rightValue = value.ObjectArray[index];
// Indizes sind hier deckungsgleich
GroupColumn groupColumn = (GroupColumn)base.ColumnCollection[index];
bool descending = (groupColumn.SortDirection == ListSortDirection.Descending);
// null means equl
if (leftValue == null || leftValue == System.DBNull.Value)
{
if (rightValue != null && rightValue != System.DBNull.Value)
{
return (descending) ? 1 : -1;
}
// Beide Null
continue;
}
if (rightValue == null || rightValue == System.DBNull.Value)
{
return (descending) ? -1 : 1;
}
if (leftValue.GetType() != rightValue.GetType())
throw new InvalidOperationException("Compare of different types is not supported");
if (leftValue.GetType() == typeof(string))
{
compare = String.Compare((string)leftValue, (string)rightValue,
!groupColumn.CaseSensitive, base.ColumnCollection.Culture);
}
else
{
compare = ((IComparable)leftValue).CompareTo(rightValue);
}
// Sind ungleich, tauschen je nach Richtung
if (compare != 0)
{
return (descending) ? -compare : compare;
}
}
// Gleich Werte, dann Index bercksichtigen
return this.ListIndex.CompareTo(value.ListIndex);
}
public override int CompareTo(object obj) {
base.CompareTo(obj);
return this.CompareTo((GroupComparer)obj);
}
}
}

97
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupSeperator.cs

@ -22,11 +22,11 @@ using SharpReportCore; @@ -22,11 +22,11 @@ using SharpReportCore;
/// </remarks>
namespace SharpReportCore {
public class GroupSeperator : SharpReportCore.GroupComparer,IHierarchyData {
public class GroupSeperator : SharpReportCore.BaseComparer,IHierarchyData {
private string typeName = "GroupSeperator";
int groupLevel;
IHierarchicalArray childs ;
SharpIndexCollection childs ;
public GroupSeperator(ColumnCollection owner, int listIndex, object[] values,int groupLevel):
base(owner,listIndex,values) {
@ -40,16 +40,89 @@ namespace SharpReportCore { @@ -40,16 +40,89 @@ namespace SharpReportCore {
}
}
public IHierarchicalArray Childs {
public SharpIndexCollection GetChildren {
get {
if (this.childs == null) {
this.childs = new SharpIndexCollection("ChildList");
}
return childs;
}
set {
childs = value;
}
#region Comparer
internal int CompareTo(BaseComparer value)
{
// we shouldn't get to this point
if (value == null)
throw new ArgumentNullException("value");
if (value.ObjectArray.Length != base.ObjectArray.Length)
throw new InvalidOperationException("Differnet size of compare data");
int compare = 0;
for (int index = 0; index < base.ObjectArray.Length; index++)
{
object leftValue = base.ObjectArray[index];
object rightValue = value.ObjectArray[index];
// Indizes sind hier deckungsgleich
GroupColumn groupColumn = (GroupColumn)base.ColumnCollection[index];
bool descending = (groupColumn.SortDirection == ListSortDirection.Descending);
// null means equl
if (leftValue == null || leftValue == System.DBNull.Value)
{
if (rightValue != null && rightValue != System.DBNull.Value)
{
return (descending) ? 1 : -1;
}
// Beide Null
continue;
}
if (rightValue == null || rightValue == System.DBNull.Value)
{
return (descending) ? -1 : 1;
}
if (leftValue.GetType() != rightValue.GetType())
throw new InvalidOperationException("Compare of different types is not supported");
if (leftValue.GetType() == typeof(string))
{
compare = String.Compare((string)leftValue, (string)rightValue,
!groupColumn.CaseSensitive, base.ColumnCollection.Culture);
}
else
{
compare = ((IComparable)leftValue).CompareTo(rightValue);
}
// Sind ungleich, tauschen je nach Richtung
if (compare != 0)
{
return (descending) ? -compare : compare;
}
}
// Gleich Werte, dann Index bercksichtigen
return this.ListIndex.CompareTo(value.ListIndex);
}
public override int CompareTo(object obj) {
base.CompareTo(obj);
return this.CompareTo((BaseComparer)obj);
}
#endregion
#region SharpReportCore.IHierarchyData interface implementation
@ -85,13 +158,13 @@ namespace SharpReportCore { @@ -85,13 +158,13 @@ namespace SharpReportCore {
}
}
public IHierarchicalEnumerable GetChildren() {
return this.childs;
}
public IHierarchyData GetParent() {
return null;
}
// public IHierarchicalEnumerable GetChildren() {
// return this.childs;
// }
//
// public IHierarchyData GetParent() {
// return null;
// }
#endregion

4
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/SortComparer.cs

@ -28,7 +28,7 @@ namespace SharpReportCore { @@ -28,7 +28,7 @@ namespace SharpReportCore {
throw new ArgumentNullException("value");
if (value.ObjectArray.Length != base.ObjectArray.Length)
throw new InvalidOperationException("Differnet size of compare data");
throw new InvalidOperationException();
int compare = 0;
@ -61,7 +61,7 @@ namespace SharpReportCore { @@ -61,7 +61,7 @@ namespace SharpReportCore {
if (leftValue.GetType() != rightValue.GetType())
throw new InvalidOperationException("COmpare of different types is not supported");
throw new InvalidOperationException("Compare of different types is not supported");
if (leftValue.GetType() == typeof(string))
{

250
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs

@ -45,12 +45,11 @@ namespace SharpReportCore { @@ -45,12 +45,11 @@ namespace SharpReportCore {
ConnectionObject connectionObject;
IDbConnection connection;
IDataViewStrategy dataViewStrategy;
// private ListChangedEventArgs resetList = new ListChangedEventArgs(ListChangedType.Reset,-1,-1);
GroupSeperator groupSeperator;
public event EventHandler <ListChangedEventArgs> ListChanged;
public event EventHandler <GroupChangedEventArgs> GroupChanged;
public event EventHandler <EventArgs> GroupChanging;
/// <summary>
/// use this Constructor for PullDataReports
@ -60,34 +59,32 @@ namespace SharpReportCore { @@ -60,34 +59,32 @@ namespace SharpReportCore {
#region Constructores
public DataManager(ConnectionObject connectionObject, ReportSettings reportSettings){
CheckAndSetReportSettings(reportSettings);
if (connectionObject == null) {
throw new ArgumentNullException("DataManager:ConnectionObject");
}
this.connectionObject = connectionObject;
try {
CheckConnection (this.connectionObject);
CheckAndSetSource(this.FillDataSet().Tables[0]);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception) {
throw;
if (reportSettings == null) {
throw new ArgumentNullException("reportSettings");
}
this.connectionObject = connectionObject;
CheckConnection (this.connectionObject);
CheckReportSettings(reportSettings);
CheckDataSource(this.FillDataSet().Tables[0]);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
this.dataViewStrategy.GroupChanged += new EventHandler<GroupChangedEventArgs> (OnGroupChange);
}
public DataManager(DataTable dataSource, ReportSettings reportSettings){
try {
CheckAndSetReportSettings(reportSettings);
CheckAndSetSource(dataSource);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception) {
throw ;
}
this.InitDataManager(reportSettings,dataSource);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
}
public DataManager(DataSet dataSource, ReportSettings reportSettings)
@ -97,54 +94,49 @@ namespace SharpReportCore { @@ -97,54 +94,49 @@ namespace SharpReportCore {
public DataManager(DataSet dataSource,string dataMember, ReportSettings reportSettings){
try {
this.dataMember = dataMember;
CheckAndSetReportSettings(reportSettings);
CheckAndSetSource(dataSource);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception ) {
throw ;
}
this.dataMember = dataMember;
this.InitDataManager(reportSettings,dataSource);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
}
public DataManager(IList dataSource, ReportSettings reportSettings){
this.InitDataManager(reportSettings,dataSource);
this.dataViewStrategy = new CollectionStrategy ((IList)this.dataSource,
this.dataMember,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
}
#endregion
void InitDataManager (ReportSettings reportSettings,object dataSource) {
try {
CheckAndSetReportSettings(reportSettings);
CheckAndSetSource(dataSource);
this.dataViewStrategy = new CollectionStrategy ((IList)this.dataSource,
this.dataMember,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
CheckReportSettings(reportSettings);
CheckDataSource(dataSource);
} catch (Exception) {
throw;
}
}
#endregion
void CheckAndSetReportSettings(ReportSettings settings) {
if (settings == null) {
throw new ArgumentNullException("settings");
}
void CheckReportSettings(ReportSettings settings) {
try {
if (settings.DataModel != GlobalEnums.enmPushPullModel.PushData) {
SqlQueryCkecker check = new SqlQueryCkecker();
check.Check(settings.CommandText);
SqlQueryChecker checker = new SqlQueryChecker();
checker.Check(settings.CommandText);
}
} catch (Exception) {
throw;
}
this.reportSettings = settings;
}
void CheckAndSetSource(object source) {
void CheckDataSource(object source) {
if (source == null) {
throw new MissingDataSourceException();
}
@ -175,7 +167,7 @@ namespace SharpReportCore { @@ -175,7 +167,7 @@ namespace SharpReportCore {
}
}
}else {
throw new ArgumentException("DataManager:No Tables in DataSet");
throw new MissingDataSourceException();
}
return;
}
@ -186,24 +178,13 @@ namespace SharpReportCore { @@ -186,24 +178,13 @@ namespace SharpReportCore {
this.dataSource = list;
this.dataMember = source.ToString();
if (list.Count == 0) {
//System.Console.WriteLine("List mit {0} Rows",list.Count);
throw new ArgumentException("No empty IList allowed");
throw new MissingDataSourceException();
}
return;
}
// if (source is IList) {
// IList list = source as IList;
// this.dataSource = list;
// this.dataMember = source.ToString();
// if (list.Count == 0) {
// //System.Console.WriteLine("List mit {0} Rows",list.Count);
// throw new ArgumentException("No empty IList allowed");
// }
// return;
// }
} else {
throw new ArgumentException ("DataManager:Wrong DataSource");
throw new MissingDataSourceException();
}
}
@ -215,7 +196,7 @@ namespace SharpReportCore { @@ -215,7 +196,7 @@ namespace SharpReportCore {
}
connection.Open();
connection.Close();
} catch (Exception ) {
} catch (Exception) {
throw;
}
}
@ -296,14 +277,25 @@ namespace SharpReportCore { @@ -296,14 +277,25 @@ namespace SharpReportCore {
this.ListChanged (this,e);
}
}
private void NotifyGroupChanging () {
if (this.GroupChanging!= null) {
this.GroupChanging (this,EventArgs.Empty);
}
}
private void NotifyGroupChange (object sender,GroupChangedEventArgs e) {
if (this.GroupChanged != null) {
this.GroupChanged (this,e);
private void NotifyGroupChanged() {
if (this.IsGrouped) {
if (this.GroupChanged != null) {
this.GroupChanged (this,new GroupChangedEventArgs(this.groupSeperator));
}
}
}
private void OnGroupChange (object sender,GroupChangedEventArgs e) {
this.groupSeperator = e.GroupSeperator;
this.NotifyGroupChanging();
}
#endregion
public string DataMember {
@ -319,59 +311,13 @@ namespace SharpReportCore { @@ -319,59 +311,13 @@ namespace SharpReportCore {
}
public IHierarchicalArray IHierarchicalArray {
get {
return (IHierarchicalArray)this.dataViewStrategy.IHierarchicalEnumerable;
}
}
/*
public void PerformHierarchy (IHierarchicalEnumerable list) {
IEnumerator iter = list.GetEnumerator();
System.Console.WriteLine("PerformHierarchy");
if (iter != null) {
while (iter.MoveNext()){
GroupSeperator g = (GroupSeperator)iter.Current;
System.Console.WriteLine("list {0} {1}",g.Path,g.ListIndex);
CheckGroups (g);
}
} else {
throw new SystemException("PerformHierarchy: No valid IEnumerator");
}
}
private void CheckGroups(GroupSeperator sep) {
System.Console.WriteLine("CheckGroups");
IEnumerator children = ((IHierarchicalEnumerable)sep.GetChildren()).GetEnumerator();
while (children.MoveNext()) {
System.Console.WriteLine("children");
}
}
public IHierarchicalEnumerable HierarchicalList {
get {
return hierarchicalList;
}
}
*/
#region SharpReportCore.IDataContainer interface implementation
public object DataSource {
get {
return this.dataSource;
}
set {
this.dataSource = value;
Reset();
}
}
public int CurrentRow {
@ -399,9 +345,8 @@ namespace SharpReportCore { @@ -399,9 +345,8 @@ namespace SharpReportCore {
public bool DataBind() {
this.dataViewStrategy.Bind();
this.dataViewStrategy.GroupChanged += new EventHandler <GroupChangedEventArgs>(NotifyGroupChange);
CheckReportColumns();
this.dataViewStrategy.Bind();
return true;
}
@ -411,11 +356,30 @@ namespace SharpReportCore { @@ -411,11 +356,30 @@ namespace SharpReportCore {
public void FetchData(ReportItemCollection collection) {
try {
foreach (IItemRenderer item in collection) {
this.dataViewStrategy.Fill(item);
}
} catch (Exception) {
foreach (IItemRenderer item in collection) {
this.dataViewStrategy.Fill(item);
}
this.NotifyGroupChanged();
}
/// <summary>
/// Indicate's if the current <see cref="GroupSeperator"></see> has ChildRows
/// </summary>
public bool HasChilds {
get {
return this.dataViewStrategy.HasChilds;
}
}
/// <summary>
/// Returns a <see cref="SharpArrayList"></see>, be carefull, this list is only a Indexlist
/// to the actuall data
/// </summary>
public SharpIndexCollection ChildRows {
get {
return this.dataViewStrategy.ChildRows;
}
}
@ -436,7 +400,7 @@ namespace SharpReportCore { @@ -436,7 +400,7 @@ namespace SharpReportCore {
public object Current {
get {
throw new NotImplementedException("DataManager.Current");
throw new NotImplementedException();
}
}
@ -463,10 +427,40 @@ namespace SharpReportCore { @@ -463,10 +427,40 @@ namespace SharpReportCore {
}
}
public bool IsSorted {
get {
return this.dataViewStrategy.IsSorted;
}
}
public bool IsFiltered {
get {
return this.dataViewStrategy.IsFiltered;
}
}
#region System.IDisposable interface implementation
public void Dispose() {
this.connectionObject = null;
this.dataViewStrategy = null;
this.Dispose(true);
GC.SuppressFinalize(this);
}
~DataManager(){
Dispose(false);
}
protected virtual void Dispose(bool disposing){
try {
if (disposing) {
// Free other state (managed objects).
if (this.dataViewStrategy != null) {
this.dataViewStrategy.Dispose();
}
}
} finally {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
}
#endregion

56
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/ExtendedPropertyDescriptor.cs

@ -8,7 +8,7 @@ namespace SharpReportCore { @@ -8,7 +8,7 @@ namespace SharpReportCore {
/// This class supports data binding
/// </summary>
public class SharpPropertyDescriptor : PropertyDescriptor{
bool readOnly;
Type componentType;
Type propertyType;
PropertyInfo prop;
@ -18,65 +18,59 @@ namespace SharpReportCore { @@ -18,65 +18,59 @@ namespace SharpReportCore {
{
this.componentType = componentType;
this.propertyType = propertyType;
this.readOnly= false;
}
public override object GetValue (object component)
{
if (!componentType.IsAssignableFrom(component.GetType()))
{
public override object GetValue (object component){
if (!componentType.IsAssignableFrom(component.GetType())){
return null;
}
if (prop == null)
if (prop == null) {
prop = componentType.GetProperty (Name);
object o = prop.GetValue (component, null);
if (o is IList)
{
PropertyTypeHash.Instance[componentType, Name] = SharpArrayList.GetElementType((IList)o, componentType, Name);
}
return o;
object obj = prop.GetValue (component, null);
if (obj != null) {
if (obj is IList){
PropertyTypeHash.Instance[componentType, Name] = SharpDataCollection<object>.GetElementType((IList)obj, componentType, Name);
}
}
return obj;
}
public override void SetValue(object component, object value)
{
if (IsReadOnly)
public override void SetValue(object component, object value) {
if (IsReadOnly){
return;
if (prop == null)
}
if (prop == null){
prop = componentType.GetProperty (Name);
}
prop.SetValue (component, value, null);
}
public override void ResetValue(object component)
{
public override void ResetValue(object component) {
return;
}
public override bool CanResetValue(object component)
{
public override bool CanResetValue(object component) {
return false;
}
public override bool ShouldSerializeValue(object component)
{
public override bool ShouldSerializeValue(object component) {
return false;
}
public override Type ComponentType
{
public override Type ComponentType{
get { return componentType; }
}
public override bool IsReadOnly
{
get { return readOnly; }
public override bool IsReadOnly{
get { return false; }
}
public override Type PropertyType
{
public override Type PropertyType{
get { return propertyType; }
}
}

45
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/IExtendedList.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 04.08.2005
* Time: 09:06
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
namespace SharpReportCore {
public interface IExtendedList{
///<summary>
/// Build the Hash/IndexList we need for indexing the DataSource
/// </summary>
void BuildHashList (IList list);
/// <summary>
/// This List is used as an Index to the DataSource
/// ListItems are added by derived Classes
/// </summary>
IList IndexList{
get;
}
/// <summary>
/// returns the Name of the <see cref="ExtendedListArray"></see>
/// </summary>
string Name {
get;
}
///<summary>
/// CurrentPosition in <see cref="SharpArrayList"></see>
/// </summary>
int CurrentPosition {
get;set;
}
}
}

41
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/IHierarchicalArray.cs

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
namespace SharpReportCore {
using System;
using SharpReportCore;
using System.Collections;
/// <summary>
///
/// </summary>
/// <remarks>
/// created by - Forstmeier peter
/// created on - 02.12.2005 13:42:08
/// </remarks>
public class IHierarchicalArray : ArrayList,IHierarchicalEnumerable {
/// <summary>
/// Default constructor - initializes all fields to default values
/// </summary>
public IHierarchicalArray(){
}
#region SharpReportCore.IHierarchicalEnumerable interface implementation
public IHierarchyData GetHierarchyData(Object enumeratedItem) {
return enumeratedItem as IHierarchyData;
}
#endregion
}
}

8
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/PropertyTypeHash.cs

@ -12,22 +12,22 @@ namespace SharpReportCore{ @@ -12,22 +12,22 @@ namespace SharpReportCore{
Hashtable types = new Hashtable();
private string MakeIndex(Type t, string name)
private static string MakeIndex(Type t, string name)
{
return t.FullName + '.' + name;
}
public object this[Type t, string fieldName]
public object this[Type type, string fieldName]
{
get
{
return types[MakeIndex(t, fieldName)];
return types[MakeIndex(type, fieldName)];
}
set
{
if (value == null)
return;
string key = MakeIndex(t, fieldName);
string key = MakeIndex(type, fieldName);
if (!types.Contains(key))
types.Add(key, value);
}

383
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/SharpArrayList.cs

@ -1,306 +1,229 @@ @@ -1,306 +1,229 @@
using System;
using System.Data;
using System.Diagnostics;
using System.Reflection;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace SharpReportCore
{
/// <summary>
/// This class act'S as a IndexList to
/// <see cref="SharpBaseList"></see>
/// </summary>
public class SharpArrayList : ArrayList, IBindingList ,ITypedList,IExtendedList
{
Type elementType;
public class SharpIndexCollection :List<BaseComparer> {
string name;
int currentPosition;
bool allowNew = true;
bool allowEdit = true;
bool allowRemove = true;
bool supportsSearching ;
bool supportsSorting ;
bool isSorted;
private ListChangedEventArgs resetEvent = new ListChangedEventArgs(ListChangedType.Reset, -1);
public event ListChangedEventHandler ListChanged;
public SharpArrayList(Type elementType,string name){
this.Clear();
this.elementType = elementType;
this.name = name;
Reset();
public SharpIndexCollection():this ("SharpIndexList"){
}
#region ITypedList Member
public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors){
if (listAccessors != null && listAccessors.Length > 0){
Type t = this.elementType;
for(int i = 0; i < listAccessors.Length; i++){
PropertyDescriptor pd = listAccessors[i];
// System.Diagnostics.Debug.WriteLine("*** " + t.FullName + ": " + pd.Name);
t = (Type) PropertyTypeHash.Instance[t, pd.Name];
}
// System.Diagnostics.Debug.WriteLine("*** New Collection for " + t.FullName);
// if t is null an empty list will be generated
return SharpTypeDescriptor.GetProperties(t);
}
return SharpTypeDescriptor.GetProperties(elementType);
}
public static Type GetElementType(IList list,
Type parentType,
string propertyName){
SharpArrayList al = list as SharpArrayList;
if (al == null)
return null;
return al.elementType;
}
#if longVersion
public static Type GetElementType(IList list,
Type parentType,
string propertyName){
SharpArrayList al = null;
object element = null;
al = CheckForArrayList(list);
if (al == null){
if (list.Count > 0){
element = list[0];
}
}
if (al == null && element == null){
PropertyInfo pi = parentType.GetProperty(propertyName);
if (pi != null){
object parentObject = null;
try{
parentObject = Activator.CreateInstance(parentType);
}
catch(Exception ex) {}
if (parentObject != null){
list = pi.GetValue(parentObject, null) as IList;
al = CheckForArrayList(list);
}
}
}
if (al != null){
return al.elementType;
}
else if (element != null){
return element.GetType();
}
return null;
}
private static SharpArrayList CheckForArrayList(object l){
IList list = l as IList;
if (list == null)
return null;
if (list.GetType().FullName == "System.Collections.ArrayList+ReadOnlyArrayList"){
FieldInfo fi = list.GetType().GetField("_list", BindingFlags.NonPublic | BindingFlags.Instance);
if (fi != null){
list = (IList) fi.GetValue(list);
}
}
return list as SharpArrayList;
}
#endif
public string GetListName(PropertyDescriptor[] listAccessors){
return elementType.Name;
}
#endregion
protected void Reset(){
this.currentPosition = 0;
this.OnListChange (resetEvent);
}
private void OnListChange (ListChangedEventArgs handler) {
if (this.ListChanged != null) {
this.ListChanged (this,handler);
}
public SharpIndexCollection(string name){
this.name = name;
}
#region System.ComponentModel.IBindingList interface implementation
public bool AllowNew {
#region properties
public int CurrentPosition {
get {
return this.allowNew;
return currentPosition;
}
}
public bool AllowEdit {
get {
return this.allowEdit;
set {
currentPosition = value;
}
}
public bool AllowRemove {
public string Name {
get {
return this.allowRemove;
return name;
}
}
public bool SupportsChangeNotification {
get {
return true;
}
}
public bool SupportsSearching {
get {
return this.supportsSearching;
}
set {
this.supportsSearching = value;
}
}
#endregion
}
/// <summary>
/// This class act's as a store of the original Data
/// </summary>
public class SharpDataCollection<T> : IList<T>,ITypedList{
Collection<T> list = new Collection<T>();
Type elementType;
public bool SupportsSorting {
get {
return this.supportsSorting;
}
set {
this.supportsSorting = value;
}
public SharpDataCollection(Type elementType)
{
this.elementType = elementType;
}
public bool IsSorted {
public T this[int index] {
get {
return this.isSorted;
return list[index];
}
set {
this.isSorted = value;
T oldValue = list[index];
if (!object.Equals(oldValue, value)) {
list[index] = value;
}
}
}
public System.ComponentModel.PropertyDescriptor SortProperty {
public int Count {
[DebuggerStepThrough]
get {
return null;
return list.Count;
}
}
public System.ComponentModel.ListSortDirection SortDirection {
public bool IsReadOnly {
get {
return ListSortDirection.Ascending;
return false;
}
}
public void RemoveSort() {
throw new NotImplementedException("RemoveSort");
}
//TODO Test fehlt
public void RemoveIndex(System.ComponentModel.PropertyDescriptor property) {
throw new NotImplementedException("RemoveIndex");
public int IndexOf(T item)
{
return list.IndexOf(item);
}
//TODO Test fehlt
public int Find(System.ComponentModel.PropertyDescriptor property, object key) {
// return 0;
throw new NotImplementedException("Find");
public void Insert(int index, T item)
{
list.Insert(index, item);
}
//TODO Test fehlt
public void ApplySort(System.ComponentModel.PropertyDescriptor property, System.ComponentModel.ListSortDirection direction) {
throw new NotImplementedException("ApplySort");
}
//TODO Test fehlt
public void AddIndex(System.ComponentModel.PropertyDescriptor property) {
throw new NotImplementedException("AddIndex");
public void RemoveAt(int index)
{
// T item = list[index];
list.RemoveAt(index);
}
public object AddNew() {
throw new NotImplementedException("AddNew");
public void Add(T item)
{
list.Add(item);
}
#endregion
#region overrides
public override int Add(object value) {
if (this.elementType.GetType().IsAssignableFrom (value.GetType())) {
System.Console.WriteLine("type ok");
}
if ((value.GetType().IsSubclassOf(this.elementType))||( value.GetType() == this.elementType)){
if (this.allowNew) {
int i = base.Add(value);
this.OnListChange (new ListChangedEventArgs(ListChangedType.ItemAdded,i));
return i;
} else {
throw new NotSupportedException("SharpArrayList:Add(object)");
}
} else {
string str = String.Format("Add:Wrong Type {0} {1}",this.elementType,value.GetType());
throw new ArgumentException(str);
public void AddRange(IList range)
{
foreach(T t in range) {
Add(t);
}
}
public override void AddRange(System.Collections.ICollection c) {
foreach (object o in c) {
this.Add (o);
}
public void Clear(){
list = new Collection<T>();
}
public override void RemoveAt(int index) {
if (this.allowRemove) {
if (index > -1) {
base.RemoveAt(index);
this.OnListChange (new ListChangedEventArgs(ListChangedType.ItemDeleted,index));
}
} else {
throw new NotSupportedException("SharpArrayList:RemoveAt (index)");
}
public bool Contains(T item)
{
return list.Contains(item);
}
#endregion
#region SharpReport.Data.IExtendedList interface implementation
public string Name {
get {
return this.name;
}
public void CopyTo(T[] array, int arrayIndex)
{
list.CopyTo(array, arrayIndex);
}
public int CurrentPosition {
get {
return currentPosition;
public bool Remove(T item)
{
if (list.Remove(item)) {
return true;
}
set {
currentPosition = value;
return false;
}
#region ITypedList Member
public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors){
if (listAccessors != null && listAccessors.Length > 0){
Type t = this.elementType;
for(int i = 0; i < listAccessors.Length; i++){
PropertyDescriptor pd = listAccessors[i];
t = (Type) PropertyTypeHash.Instance[t, pd.Name];
}
// if t is null an empty list will be generated
return SharpTypeDescriptor.GetProperties(t);
}
return SharpTypeDescriptor.GetProperties(elementType);
}
public string GetListName(PropertyDescriptor[] listAccessors){
return elementType.Name;
}
public IList IndexList {
get {
return(IList)this;
public static Type GetElementType(IList list, Type parentType, string propertyName)
{
SharpDataCollection<T> al = null;
object element = null;
al = CheckForArrayList(list);
if (al == null)
{
if (list.Count > 0)
{
element = list[0];
}
}
if (al == null && element == null)
{
PropertyInfo pi = parentType.GetProperty(propertyName);
if (pi != null)
{
object parentObject = null;
try
{
parentObject = Activator.CreateInstance(parentType);
}
catch(Exception) {}
if (parentObject != null)
{
list = pi.GetValue(parentObject, null) as IList;
al = CheckForArrayList(list);
}
}
}
if (al != null)
{
return al.elementType;
}
else if (element != null)
{
return element.GetType();
}
return null;
}
public void BuildHashList(IList list) {
throw new NotImplementedException("SharpArrayList:BuildHashList");
/*
this.Clear();
for (int i = 0;i < list.Count ;i++ ) {
// this.Add (new PlainIndexItem(i,"satz " + i.ToString()));
private static SharpDataCollection<T> CheckForArrayList(object l)
{
IList list = l as IList;
if (list == null)
return null;
if (list.GetType().FullName == "System.Collections.ArrayList+ReadOnlyArrayList")
{
FieldInfo fi = list.GetType().GetField("_list", BindingFlags.NonPublic | BindingFlags.Instance);
if (fi != null)
{
list = (IList) fi.GetValue(list);
}
}
this.OnListChange (new ListChangedEventArgs(ListChangedType.Reset,-1,-1));
*/
return list as SharpDataCollection<T>;
}
#endregion
[DebuggerStepThrough]
public IEnumerator<T> GetEnumerator()
{
return list.GetEnumerator();
}
[DebuggerStepThrough]
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return list.GetEnumerator();
}
}
}

263
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/BaseListStrategy.cs

@ -16,7 +16,7 @@ using System.Collections.Generic; @@ -16,7 +16,7 @@ using System.Collections.Generic;
using SharpReportCore;
/// <summary>
/// BaseClass for all datahandling Strategies
/// BaseClass for all Datahandling Strategies
/// </summary>
/// <remarks>
/// created by - Forstmeier Peter
@ -30,10 +30,9 @@ namespace SharpReportCore { @@ -30,10 +30,9 @@ namespace SharpReportCore {
private bool isGrouped;
//Index to plain Datat
private SharpArrayList indexList;
private SharpIndexCollection indexList;
private ReportSettings reportSettings;
private IHierarchicalArray hierarchicalList;
private ListChangedEventArgs resetList = new ListChangedEventArgs(ListChangedType.Reset,-1,-1);
@ -43,20 +42,16 @@ namespace SharpReportCore { @@ -43,20 +42,16 @@ namespace SharpReportCore {
#region Constructor
protected BaseListStrategy(ReportSettings reportSettings) {
if (reportSettings == null) {
throw new ArgumentNullException("reportSettings");
}
this.reportSettings = reportSettings;
this.indexList = new SharpArrayList(typeof(BaseComparer),"IndexList");
this.indexList = new SharpIndexCollection("IndexList");
}
#endregion
#region Event's
protected void NotifyGroupChange (object source,GroupSeperator groupSeperator) {
if (this.GroupChanged != null) {
this.GroupChanged (source,new GroupChangedEventArgs(groupSeperator));
}
}
protected void NotifyResetList(){
if (this.ListChanged != null) {
@ -64,10 +59,18 @@ namespace SharpReportCore { @@ -64,10 +59,18 @@ namespace SharpReportCore {
}
}
protected void NotifyGroupChanging (object source,GroupSeperator groupSeperator) {
if (this.GroupChanged != null) {
this.GroupChanged (source,new GroupChangedEventArgs(groupSeperator));
}
}
#endregion
public SharpArrayList IndexList {
public SharpIndexCollection IndexList {
get {
return indexList;
}
@ -79,21 +82,87 @@ namespace SharpReportCore { @@ -79,21 +82,87 @@ namespace SharpReportCore {
return reportSettings;
}
}
#region Building Groups
private static void WriteToIndexFile (SharpIndexCollection destination,BaseComparer comparer) {
SortComparer sc = comparer as SortComparer;
// if (sc != null) {
// System.Console.WriteLine("\t {0} - <{1}>",comparer.ListIndex, comparer.ObjectArray[0].ToString());
// } else {
// System.Console.WriteLine("Wrong comparer");
// }
destination.Add(comparer);
}
protected void CheckSortArray (ArrayList arr,string text){
// System.Console.WriteLine("");
private static GroupSeperator BuildGroupSeperator (BaseComparer newGroup,int groupLevel) {
GroupSeperator seperator = new GroupSeperator (newGroup.ColumnCollection,
newGroup.ListIndex,
newGroup.ObjectArray,
groupLevel);
// System.Console.WriteLine("Add Parent <{0}>",seperator.ObjectArray[0].ToString());
return seperator;
}
protected void MakeGroupedIndexList (SharpIndexCollection sourceList) {
if (sourceList == null) {
throw new ArgumentNullException("sourceList");
}
int level = 0;
this.indexList.Clear();
SortComparer compareComparer = null;
GroupSeperator parent = null;
// System.Console.WriteLine("MakeGroupedIndexList with {0} rows",sourceList.Count);
for (int i = 0;i < sourceList.Count ;i++ ) {
SortComparer currentComparer = (SortComparer)sourceList[i];
/*
System.Console.WriteLine("\t\t\t performing nr {0}",i);
if (i == 68) {
System.Console.WriteLine("last");
}
*/
if (compareComparer != null) {
string str1,str2;
str1 = currentComparer.ObjectArray[0].ToString();
str2 = compareComparer.ObjectArray[0].ToString();
int compareVal = str1.CompareTo(str2);
if (compareVal != 0) {
BaseListStrategy.WriteToIndexFile(parent.GetChildren,compareComparer);
parent = BaseListStrategy.BuildGroupSeperator (currentComparer,level);
this.indexList.Add(parent);
BaseListStrategy.WriteToIndexFile(parent.GetChildren,currentComparer);
} else {
BaseListStrategy.WriteToIndexFile(parent.GetChildren,compareComparer);
}
}
else {
parent = BaseListStrategy.BuildGroupSeperator (currentComparer,level);
this.indexList.Add(parent);
}
compareComparer = (SortComparer)sourceList[i];
}
BaseListStrategy.WriteToIndexFile(parent.GetChildren,compareComparer);
}
#endregion
protected static void CheckSortArray (SharpIndexCollection arr,string text){
System.Console.WriteLine("{0}",text);
// string tabs = String.Empty;
if (arr != null) {
int row = 0;
foreach (BaseComparer bc in arr) {
GroupSeperator sep = bc as GroupSeperator;
if (sep != null) {
// System.Console.WriteLine("\t Group change {0} level {1}",sep.ObjectArray[0].ToString(),
// sep.GroupLevel);
} else {
object [] oarr = bc.ObjectArray;
@ -107,12 +176,10 @@ namespace SharpReportCore { @@ -107,12 +176,10 @@ namespace SharpReportCore {
}
}
System.Console.WriteLine("----------------");
System.Console.WriteLine("");
System.Console.WriteLine("-----End of <CheckSortArray>-----------");
}
#region SharpReportCore.IDataViewStrategy interface implementation
public virtual ColumnCollection AvailableFields {
@ -133,8 +200,7 @@ namespace SharpReportCore { @@ -133,8 +200,7 @@ namespace SharpReportCore {
}
set {
if (value > this.indexList.Count){
throw new IndexOutOfRangeException ("There is no row at " +
"currentRow: " + value + ".");
throw new IndexOutOfRangeException ();
}
this.indexList.CurrentPosition = value;
}
@ -167,15 +233,10 @@ namespace SharpReportCore { @@ -167,15 +233,10 @@ namespace SharpReportCore {
get {
return this.isGrouped;
}
set {
this.isGrouped = true;
}
}
protected virtual void Group() {
if (this.indexList != null) {
this.BuildHierarchicalList (this.indexList);
this.isGrouped = true;
this.isSorted = true;
} else {
@ -185,123 +246,77 @@ namespace SharpReportCore { @@ -185,123 +246,77 @@ namespace SharpReportCore {
}
protected IHierarchicalArray HierarchicalList {
get {
return hierarchicalList;
}
}
public virtual void Sort() {
this.indexList.Clear();
}
public virtual void Reset() {
this.NotifyResetList();
}
private GroupSeperator MakeSeperator (BaseComparer newGroup,int groupLevel) {
public virtual void Bind() {
GroupSeperator seperator = new GroupSeperator (newGroup.ColumnCollection,
newGroup.ListIndex,
newGroup.ObjectArray,
groupLevel);
// System.Console.WriteLine("");
// System.Console.WriteLine("\t Group change {0} level {1}",seperator.ObjectArray[0].ToString(),
// seperator.GroupLevel);
// System.Console.WriteLine("");
return seperator;
}
public virtual void Fill(IItemRenderer item) {
private IHierarchicalEnumerable BuildHierarchicalList(ArrayList sourceList) {
IHierarchicalArray destList = new IHierarchicalArray();
IHierarchicalArray childList = new IHierarchicalArray();
int level = 0;
// System.Console.WriteLine("");
// System.Console.WriteLine("BuildHierachicalList");
// ColumnCollection grBy =this.reportSettings.GroupColumnsCollection;
// string columnName = grBy[level].ColumnName;
GroupComparer compareComparer = null;
GroupSeperator seperator = null;
destList.Clear();
childList.Clear();
for (int i = 0;i < sourceList.Count ;i++ ) {
GroupComparer currentComparer = (GroupComparer)sourceList[i];
if (compareComparer != null) {
string str1,str2;
str1 = currentComparer.ObjectArray[0].ToString();
str2 = compareComparer.ObjectArray[0].ToString();
int compareVal = str1.CompareTo(str2);
if (compareVal != 0) {
// System.Console.WriteLine("child list with {0} entries",childList.Count);
seperator.Childs = childList;
/*
//testcode
if (childList != null) {
foreach (BaseComparer bc in seperator.Childs) {
System.Console.WriteLine("\t {0} {1}",bc.ListIndex,
bc.ObjectArray[0].ToString());
}
}
// end testCode
*/
childList = new IHierarchicalArray();
seperator = MakeSeperator (currentComparer,level);
childList.Clear();
destList.Add (seperator);
}
public bool HasChilds {
get {
if (this.IsGrouped == true) {
GroupSeperator gs = (GroupSeperator)this.indexList[this.CurrentRow] as GroupSeperator;
if (gs != null) {
return (gs.GetChildren.Count > 0);
} else {
return false;
}
} else {
return false;
}
else {
// System.Console.WriteLine("\t\t Start of List {0}",currentComparer.ObjectArray[0].ToString());
//
// System.Console.WriteLine("Group change ");
seperator = MakeSeperator (currentComparer,level);
childList.Clear();
destList.Add (seperator);
seperator.Childs = childList;
}
// System.Console.WriteLine("write {0} {1}",currentComparer.ListIndex,currentComparer.ObjectArray[0].ToString());
childList.Add (currentComparer);
compareComparer = (GroupComparer)sourceList[i];
}
// Add the last list
seperator.Childs = childList;
this.hierarchicalList = destList;
return destList;
}
public IHierarchicalEnumerable IHierarchicalEnumerable {
public SharpIndexCollection ChildRows {
get {
return this.hierarchicalList;
if (this.IsGrouped == true) {
GroupSeperator gs = (GroupSeperator)this.indexList[this.CurrentRow] as GroupSeperator;
if (gs != null) {
return (gs.GetChildren);
} else {
return null;
}
} else {
return null;
}
}
}
public virtual void Sort() {
public virtual void Dispose(){
this.Dispose(true);
GC.SuppressFinalize(this);
}
public virtual void Reset() {
this.NotifyResetList();
~BaseListStrategy(){
Dispose(false);
}
public virtual void Bind() {
protected virtual void Dispose(bool disposing){
if (disposing) {
// Free other state (managed objects).
if (this.indexList != null) {
this.indexList.Clear();
this.indexList = null;
}
}
}
public virtual void Fill(IItemRenderer item) {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
#endregion
}
}

228
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/CollectionStrategy.cs

@ -23,29 +23,67 @@ namespace SharpReportCore { @@ -23,29 +23,67 @@ namespace SharpReportCore {
public class CollectionStrategy : BaseListStrategy {
// Holds the plain Data
private SharpArrayList baseList;
private Type itemType;
private object firstItem;
private object current;
private PropertyDescriptorCollection listProperties;
private SharpDataCollection<object> baseList;
public CollectionStrategy(IList list,string dataMember,ReportSettings reportSettings):base(reportSettings) {
if (list.Count > 0) {
firstItem = list[0];
itemType = firstItem.GetType();
this.baseList = new SharpArrayList(itemType,dataMember);
this.baseList = new SharpDataCollection <object>(itemType);
this.baseList.AddRange(list);
this.baseList.CurrentPosition = 0;
this.current = this.baseList[0];
}
this.listProperties = this.baseList.GetItemProperties(null);
}
private void BuildGroup(){
// throw new NotImplementedException("No grouping at the time");
return;
try {
SharpIndexCollection groupedArray = new SharpIndexCollection();
if (base.ReportSettings.GroupColumnsCollection != null) {
if (base.ReportSettings.GroupColumnsCollection.Count > 0) {
this.BuildSortIndex (groupedArray,base.ReportSettings.GroupColumnsCollection);
}
}
base.MakeGroupedIndexList (groupedArray);
foreach (BaseComparer bc in this.IndexList) {
GroupSeperator gs = bc as GroupSeperator;
if (gs != null) {
System.Console.WriteLine("Group Header <{0}> with <{1}> Childs ",gs.ObjectArray[0].ToString(),gs.GetChildren.Count);
if (gs.HasChildren) {
foreach (SortComparer sc in gs.GetChildren) {
System.Console.WriteLine("\t {0} {1}",sc.ListIndex,sc.ObjectArray[0].ToString()); }
}
} else {
SortComparer sc = bc as SortComparer;
if (sc != null) {
System.Console.WriteLine("\t Child {0}",sc.ObjectArray[0].ToString());
}
}
}
} catch (Exception e) {
System.Console.WriteLine("BuildGroup {0}",e.Message);
throw;
}
}
private PropertyDescriptor[] BuildSortProperties (ColumnCollection col){
@ -66,69 +104,54 @@ namespace SharpReportCore { @@ -66,69 +104,54 @@ namespace SharpReportCore {
}
#region Index Building
//Sorted Indexlist
private ArrayList BuildSortIndex(ColumnCollection col) {
private void BuildSortIndex(SharpIndexCollection arrayList,ColumnCollection col) {
PropertyDescriptor[] sortProperties = BuildSortProperties (col);
// Übertragen der zu sortierenden Werte in eine standartComparer Auflistung
ArrayList sortValues = new ArrayList(this.baseList.Count);
try {
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
object rowItem = this.baseList[rowIndex];
object[] values = new object[col.Count];
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
object rowItem = this.baseList[rowIndex];
object[] values = new object[col.Count];
// Hier bereits Wertabruf um dies nicht während des Sortierens tun zu müssen.
for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++){
object value = sortProperties[criteriaIndex].GetValue(rowItem);
// Hier auf Verträglichkeit testen um Vergleiche bei Sortierung zu vereinfachen.
// Muss IComparable und gleicher Typ sein.
// Hier bereits Wertabruf um dies nicht während des Sortierens tun zu müssen.
for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++){
object value = sortProperties[criteriaIndex].GetValue(rowItem);
// Hier auf Verträglichkeit testen um Vergleiche bei Sortierung zu vereinfachen.
// Muss IComparable und gleicher Typ sein.
if (value != null && value != DBNull.Value)
{
if (!(value is IComparable)){
throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
}
values[criteriaIndex] = value;
if (value != null && value != DBNull.Value)
{
if (!(value is IComparable)){
throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
}
values[criteriaIndex] = value;
}
sortValues.Add(new SortComparer(col, rowIndex, values));
}
} catch (Exception) {
throw ;
arrayList.Add(new SortComparer(col, rowIndex, values));
}
sortValues.Sort();
return sortValues;
arrayList.Sort();
}
// if we have no sorting, we build the indexlist as well, so we don't need to
//check each time we reasd data if we have to go directly or by IndexList
private ArrayList BuildPlainIndex(ColumnCollection col) {
private void BuildPlainIndex(SharpIndexCollection arrayList,ColumnCollection col) {
PropertyDescriptor[] sortProperties = new PropertyDescriptor[1];
PropertyDescriptorCollection c = this.baseList.GetItemProperties(null);
PropertyDescriptor descriptor = c[0];
sortProperties[0] = descriptor;
ArrayList sortValues = new ArrayList(this.baseList.Count);
try {
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
object[] values = new object[1];
// We insert only the RowNr as a dummy value
values[0] = rowIndex;
sortValues.Add(new BaseComparer(col, rowIndex, values));
}
} catch (Exception) {
throw ;
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
object[] values = new object[1];
// We insert only the RowNr as a dummy value
values[0] = rowIndex;
arrayList.Add(new BaseComparer(col, rowIndex, values));
}
return sortValues;;
}
#endregion
#region SharpReportCore.IDataViewStrategy interface implementation
@ -156,7 +179,6 @@ namespace SharpReportCore { @@ -156,7 +179,6 @@ namespace SharpReportCore {
set {
base.CurrentRow = value;
current = this.baseList[((BaseComparer)base.IndexList[value]).ListIndex];
}
}
@ -164,28 +186,19 @@ namespace SharpReportCore { @@ -164,28 +186,19 @@ namespace SharpReportCore {
public override void Sort() {
base.Sort();
ArrayList sortedArray = new ArrayList();
try {
ColumnCollection sortColumnCollection = base.ReportSettings.SortColumnCollection;
if (sortColumnCollection != null) {
if (sortColumnCollection.Count > 0) {
sortedArray = this.BuildSortIndex (sortColumnCollection);
base.IsSorted = true;
} else {
sortedArray = BuildPlainIndex (sortColumnCollection);
base.IsSorted = false;
}
if ((base.ReportSettings.SortColumnCollection != null)) {
if (base.ReportSettings.SortColumnCollection.Count > 0) {
this.BuildSortIndex (base.IndexList,
base.ReportSettings.SortColumnCollection);
base.IsSorted = true;
// BaseListStrategy.CheckSortArray (base.IndexList,"TableStrategy - CheckSortArray");
} else {
this.BuildPlainIndex(base.IndexList,
base.ReportSettings.SortColumnCollection);
base.IsSorted = false;
}
base.IndexList.Clear();
base.IndexList.AddRange (sortedArray);
// base.CheckSortArray (sortedArray,"CollectionStrategy - CheckSortArray");
} catch (Exception) {
throw;
}
if (base.IndexList == null){
throw new NotSupportedException("Sortieren für die Liste nicht unterstützt.");
}
}
@ -200,24 +213,23 @@ namespace SharpReportCore { @@ -200,24 +213,23 @@ namespace SharpReportCore {
public override void Bind() {
base.Bind();
if (base.IndexList.Count > 0) {
base.IndexList.Clear();
}
this.listProperties = this.baseList.GetItemProperties(null);
if ((base.ReportSettings.GroupColumnsCollection != null) && (base.ReportSettings.GroupColumnsCollection.Count > 0)) {
BuildGroup ();
this.Group ();
Reset();
return;
}
this.Sort ();
this.Reset();
base.NotifyResetList();
if (base.ReportSettings.SortColumnCollection != null) {
this.Sort ();
}
Reset();
}
public override void Fill(IItemRenderer item) {
base.Fill(item);
if (current != null) {
try {
try {
base.Fill(item);
if (current != null) {
BaseDataItem baseDataItem = item as BaseDataItem;
PropertyDescriptor p = this.listProperties.Find (baseDataItem.ColumnName,true);
@ -225,12 +237,50 @@ namespace SharpReportCore { @@ -225,12 +237,50 @@ namespace SharpReportCore {
baseDataItem.DbValue = "";
baseDataItem.DbValue = p.GetValue(this.current).ToString();
}
} catch (Exception) {
}
} catch (System.NullReferenceException) {
}
}
protected override void Group() {
if (base.ReportSettings.GroupColumnsCollection.Count == 0) {
return;
}
this.BuildGroup();
base.Group();
}
#endregion
#region IDisposable
public override void Dispose(){
this.Dispose(true);
GC.SuppressFinalize(this);
}
~CollectionStrategy(){
Dispose(false);
}
protected override void Dispose(bool disposing){
try {
if (disposing) {
if (this.baseList != null) {
this.baseList.Clear();
this.baseList = null;
}
}
} finally {
base.Dispose(disposing);
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
}
#endregion
}
}

296
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs

@ -24,7 +24,7 @@ namespace SharpReportCore { @@ -24,7 +24,7 @@ namespace SharpReportCore {
/// created by - Forstmeier Peter
/// created on - 23.10.2005 15:12:06
/// </remarks>
public class TableStrategy : BaseListStrategy,IDisposable {
public class TableStrategy : BaseListStrategy {
DataTable table;
DataView view = new DataView();
@ -32,44 +32,19 @@ namespace SharpReportCore { @@ -32,44 +32,19 @@ namespace SharpReportCore {
public TableStrategy(DataTable table,ReportSettings reportSettings):base(reportSettings) {
if (table == null) {
throw new ArgumentNullException("table");
}
this.table = table;
// view.ListChanged += new ListChangedEventHandler (OnListChange);
view = this.table.DefaultView;
}
// private void OnListChange (object sender,ListChangedEventArgs e) {
// System.Console.WriteLine("called from view");
// MessageBox.Show ("On List Change");
// }
/*
private string a_BuildSort(ColumnCollection sortCollection){
System.Console.WriteLine("BuildSort");
StringBuilder sb = new StringBuilder();
for (int i = 0;i < sortCollection.Count ;i++ ) {
SortColumn sc = (SortColumn)sortCollection[i];
sb.Append(sc.ColumnName);
if (sc.SortDirection == ListSortDirection.Ascending) {
sb.Append (" ASC");
} else {
sb.Append(" DESC");
}
sb.Append (",");
}
if (sb.ToString().EndsWith (",")) {
sb.Remove(sb.Length -1,1);
}
System.Console.WriteLine("\tsort by {0}",sb.ToString());
return sb.ToString();
}
*/
#region Building the Index list
// if we have no sorting, we build the indexlist as well, so we don't need to
//check each time we reasd data if we have to go directly or by IndexList
private ArrayList BuildSortIndex(ColumnCollection col) {
private void BuildSortIndex(SharpIndexCollection arrayList,ColumnCollection col) {
ArrayList sortValues = new ArrayList(this.view.Count);
try {
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){
DataRowView rowItem = this.view[rowIndex];
@ -88,171 +63,79 @@ namespace SharpReportCore { @@ -88,171 +63,79 @@ namespace SharpReportCore {
values[criteriaIndex] = DBNull.Value;
}
}
sortValues.Add(new SortComparer(col, rowIndex, values));
arrayList.Add(new SortComparer(col, rowIndex, values));
}
} catch (Exception) {
throw;
}
sortValues.Sort();
return sortValues;
}
private ArrayList BuildPlainIndex(ColumnCollection col) {
ArrayList sortValues = new ArrayList(this.view.Count);
arrayList.Sort();
}
// if we have no sorting, we build the indexlist as well, so we don't need to
//check each time we reasd data if we have to go directly or by IndexList
private void BuildPlainIndex(SharpIndexCollection arrayList,ColumnCollection col) {
try {
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){
object[] values = new object[1];
// We insert only the RowNr as a dummy value
values[0] = rowIndex;
sortValues.Add(new BaseComparer(col, rowIndex, values));
arrayList.Add(new BaseComparer(col, rowIndex, values));
}
} catch (Exception) {
throw ;
}
return sortValues;;
}
private ArrayList BuildGroupIndex(ColumnCollection col) {
ArrayList groupValues = new ArrayList(this.view.Count);
System.Console.WriteLine("\tBuildGroupIndex");
try {
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){
DataRowView rowItem = this.view[rowIndex];
object[] values = new object[col.Count];
for (int criteriaIndex = 0; criteriaIndex < col.Count; criteriaIndex++){
AbstractColumn c = (AbstractColumn)col[criteriaIndex];
object value = rowItem[c.ColumnName];
if (value != null && value != DBNull.Value){
if (!(value is IComparable)){
throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
}
values[criteriaIndex] = value;
} else {
values[criteriaIndex] = DBNull.Value;
}
}
groupValues.Add(new GroupComparer(col, rowIndex, values));
}
} catch (Exception) {
}
groupValues.Sort();
return groupValues;
}
#endregion
#region Grouping
private void WriteToIndexFile (ArrayList destination,int index,GroupComparer comparer) {
destination.Add(comparer);
}
private void BuildGroupSeperator (ArrayList destination,BaseComparer newGroup,int groupLevel) {
GroupSeperator seperator = new GroupSeperator (newGroup.ColumnCollection,
newGroup.ListIndex,
newGroup.ObjectArray,
groupLevel);
// System.Console.WriteLine("\t Group change {0} level {1}",seperator.ObjectArray[0].ToString(),
// seperator.GroupLevel);
// System.Console.WriteLine("write group seperator");
destination.Add(seperator);
}
private ArrayList InsertGroupRows (ArrayList sourceList) {
ArrayList destList = new ArrayList();
int level = 0;
// // only for testing
// ColumnCollection grBy = base.ReportSettings.GroupColumnsCollection;
// string columnName = grBy[level].ColumnName;
//// System.Console.WriteLine("");
// System.Console.WriteLine("InsertGroupRows Grouping for {0}",columnName);
GroupComparer compareComparer = null;
for (int i = 0;i < sourceList.Count ;i++ ) {
GroupComparer currentComparer = (GroupComparer)sourceList[i];
if (compareComparer != null) {
string str1,str2;
str1 = currentComparer.ObjectArray[0].ToString();
str2 = compareComparer.ObjectArray[0].ToString();
int compareVal = str1.CompareTo(str2);
if (compareVal != 0) {
this.BuildGroupSeperator (destList,currentComparer,level);
}
}
else {
// System.Console.WriteLine("\t\t Start of List {0}",currentComparer.ObjectArray[0].ToString());
this.BuildGroupSeperator (destList,currentComparer,level);
}
this.WriteToIndexFile (destList,i,currentComparer);
compareComparer = (GroupComparer)sourceList[i];
}
return destList;
}
private void BuildGroup(){
try {
ArrayList groupedArray = new ArrayList();
SharpIndexCollection groupedArray = new SharpIndexCollection();
if (base.ReportSettings.GroupColumnsCollection != null) {
if (base.ReportSettings.GroupColumnsCollection.Count > 0) {
groupedArray = this.BuildGroupIndex (base.ReportSettings.GroupColumnsCollection);
System.Console.WriteLine("\t1");
} else {
groupedArray = BuildPlainIndex (base.ReportSettings.GroupColumnsCollection);
this.BuildSortIndex (groupedArray,base.ReportSettings.GroupColumnsCollection);
}
}
base.IndexList.Clear();
base.IndexList.AddRange (InsertGroupRows(groupedArray));
if (base.IndexList == null){
throw new NotSupportedException("Sortieren für die Liste nicht unterstützt.");
base.MakeGroupedIndexList (groupedArray);
// System.Console.WriteLine("GroupedList with {0} elements",base.IndexList.Count);
/*
foreach (BaseComparer bc in this.IndexList) {
GroupSeperator gs = bc as GroupSeperator;
if (gs != null) {
// System.Console.WriteLine("Group Header <{0}> with <{1}> Childs ",gs.ObjectArray[0].ToString(),gs.GetChildren.Count);
if (gs.HasChildren) {
foreach (SortComparer sc in gs.GetChildren) {
System.Console.WriteLine("\t {0} {1}",sc.ListIndex,sc.ObjectArray[0].ToString()); }
}
} else {
SortComparer sc = bc as SortComparer;
if (sc != null) {
System.Console.WriteLine("\t Child {0}",sc.ObjectArray[0].ToString());
}
}
}
*/
} catch (Exception e) {
System.Console.WriteLine("BuildGroup {0}",e.Message);
throw;
}
}
protected override void Group() {
if (base.ReportSettings.GroupColumnsCollection.Count == 0) {
return;
}
try {
this.BuildGroup();
base.Group();
if (this.IsGrouped == false) {
throw new SharpReportException("TableStratregy:Group Error in grouping");
}
} catch (Exception e) {
System.Console.WriteLine("Group {0}",e.Message);
base.IsGrouped = false;
base.IsSorted = false;
throw;
}
}
#endregion
@ -260,12 +143,10 @@ namespace SharpReportCore { @@ -260,12 +143,10 @@ namespace SharpReportCore {
public override void Bind() {
base.Bind();
view = this.table.DefaultView;
if ((base.ReportSettings.GroupColumnsCollection != null) && (base.ReportSettings.GroupColumnsCollection.Count > 0)) {
this.Group ();
Reset();
base.NotifyResetList();
return;
}
@ -273,47 +154,44 @@ namespace SharpReportCore { @@ -273,47 +154,44 @@ namespace SharpReportCore {
this.Sort ();
}
Reset();
base.NotifyResetList();
}
public override void Sort () {
base.Sort();
ArrayList sortedArray = new ArrayList();
try {
if ((base.ReportSettings.SortColumnCollection != null)) {
if (base.ReportSettings.SortColumnCollection.Count > 0) {
SortColumn sc = (SortColumn)base.ReportSettings.SortColumnCollection[0];
sortedArray = this.BuildSortIndex (base.ReportSettings.SortColumnCollection);
base.IsSorted = true;
} else {
sortedArray = BuildPlainIndex (base.ReportSettings.SortColumnCollection);
base.IsSorted = false;
}
if ((base.ReportSettings.SortColumnCollection != null)) {
if (base.ReportSettings.SortColumnCollection.Count > 0) {
this.BuildSortIndex (base.IndexList,
base.ReportSettings.SortColumnCollection);
base.IsSorted = true;
} else {
this.BuildPlainIndex(base.IndexList,
base.ReportSettings.SortColumnCollection);
base.IsSorted = false;
}
base.IndexList.Clear();
base.IndexList.AddRange (sortedArray);
// base.CheckSortArray (sortedArray,"TableStrategy - CheckSortArray");
} catch (Exception) {
throw;
}
if (base.IndexList == null){
throw new NotSupportedException("Sortieren für die Liste nicht unterstützt.");
}
protected override void Group() {
if (base.ReportSettings.GroupColumnsCollection.Count == 0) {
return;
}
this.BuildGroup();
base.Group();
}
public override void Fill (IItemRenderer item) {
try {
base.Fill(item);
BaseDataItem baseDataItem = item as BaseDataItem;
if (baseDataItem != null) {
baseDataItem.DbValue = row[baseDataItem.ColumnName].ToString();
if (this.row != null) {
BaseDataItem baseDataItem = item as BaseDataItem;
if (baseDataItem != null) {
baseDataItem.DbValue = row[baseDataItem.ColumnName].ToString();
}
}
} catch (Exception ) {
} catch (System.NullReferenceException) {
}
}
@ -340,7 +218,7 @@ namespace SharpReportCore { @@ -340,7 +218,7 @@ namespace SharpReportCore {
public override int Count {
get {
return this.table.Rows.Count;
return this.IndexList.Count;
}
}
@ -356,31 +234,41 @@ namespace SharpReportCore { @@ -356,31 +234,41 @@ namespace SharpReportCore {
GroupSeperator sep = bc as GroupSeperator;
if (sep != null) {
base.NotifyGroupChange(this,sep);
base.NotifyGroupChanging(this,sep);
}
row = this.view[((BaseComparer)base.IndexList[value]).ListIndex];
}
}
}
#endregion
#region IDisposable
public override bool IsSorted {
get {
return (this.view.Sort.Length > 0);
}
public override void Dispose(){
this.Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
~TableStrategy(){
Dispose(false);
}
#region IDisposable
public void Dispose(){
if (this.view != null) {
this.view.Dispose();
protected override void Dispose(bool disposing){
try {
if (disposing) {
if (this.view != null) {
this.view.Dispose();
this.view = null;
}
}
} finally {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
base.Dispose(disposing);
}
}
#endregion
}

4
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/SqlQueryChecker.cs

@ -16,14 +16,14 @@ namespace SharpReportCore @@ -16,14 +16,14 @@ namespace SharpReportCore
/// <summary>
/// This Class checks for invalid SqlStatements
/// </summary>
internal class SqlQueryCkecker{
internal class SqlQueryChecker{
internal string UPDATE = "UPDATE";
internal string DELETE = "DELETE";
internal string INSERT = "INSERT";
internal string noValidMessage = "is no valid Member of SqlString";
public SqlQueryCkecker(){
public SqlQueryChecker(){
}
public void Check (string queryString) {

4
src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/MissingDataSourceException.cs

@ -17,9 +17,7 @@ using System.Runtime.Serialization; @@ -17,9 +17,7 @@ using System.Runtime.Serialization;
/// created by - Forstmeier Peter
/// created on - 05.07.2005 22:32:47
/// </remarks>
///<remarks>
/// When porting to NET 2.0 use <see cref="Microsoft.Reporting.MissingdatasourceException"></see>
/// </remarks>
namespace SharpReportCore {
[Serializable()]

15
src/AddIns/Misc/SharpReport/SharpReportCore/Globals/FontSingleton.cs

@ -31,7 +31,6 @@ namespace SharpReportCore { @@ -31,7 +31,6 @@ namespace SharpReportCore {
private FontSingleton() {
MessageBox.Show ("Should be commented out","FontSingleton");
hash = new Hashtable();
}
public Hashtable Hash {
@ -54,14 +53,6 @@ namespace SharpReportCore { @@ -54,14 +53,6 @@ namespace SharpReportCore {
public Font GetFont(string family, float size, FontStyle style){
try {
string s=family+size.ToString()+((int)style).ToString();
MessageBox.Show (s);
//Remove when tested
if(hash.Contains(s)){
MessageBox.Show ("font from hashtable","GetFont");
} else {
MessageBox.Show ("font created","getFont");
}
if(hash.Contains(s)){
return (Font)hash[s];
@ -75,10 +66,6 @@ MessageBox.Show ("font from hashtable","GetFont"); @@ -75,10 +66,6 @@ MessageBox.Show ("font from hashtable","GetFont");
}
public override string ToString() {
return base.ToString() + " FontSingleton / ";
}
/// <summary>
/// Clear the Hashtable from all Fonts
/// </summary>
@ -87,7 +74,7 @@ MessageBox.Show ("font from hashtable","GetFont"); @@ -87,7 +74,7 @@ MessageBox.Show ("font from hashtable","GetFont");
///
/// </remarks>
public void Dispose() {
MessageBox.Show ("dispose fonts " + hash.Count.ToString());
}
}
}

6
src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs

@ -97,15 +97,15 @@ namespace SharpReportCore { @@ -97,15 +97,15 @@ namespace SharpReportCore {
/// Convert any possible string-Value of a given enumeration
/// type to its internal representation.
public static object StringToEnum( Type t, string value ) {
foreach ( FieldInfo fi in t.GetFields() )
public static object StringToEnum( Type type, string value ) {
foreach ( FieldInfo fi in type.GetFields() )
if ( fi.Name == value )
return fi.GetValue( null ); // We use null because
throw new Exception( string.Format(CultureInfo.CurrentCulture,
"Can't convert {0} to {1}",
value,
t.ToString()) );
type.ToString()) );
}
}
}

7
src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataContainer.cs

@ -26,12 +26,7 @@ namespace SharpReportCore { @@ -26,12 +26,7 @@ namespace SharpReportCore {
/// Reads one row of data and fill the
/// <see cref="ReportItemCollection"></see>
void FetchData (ReportItemCollection collection);
// /// <summary>
// /// set,get the SharpReportCore
// /// </summary>
// object SharpReportCore{
// get;set;
// }
int Count {
get;
}

27
src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataViewStrategy.cs

@ -5,7 +5,7 @@ using System.Collections; @@ -5,7 +5,7 @@ using System.Collections;
using System.ComponentModel;
namespace SharpReportCore{
public interface IDataViewStrategy {
public interface IDataViewStrategy:IDisposable{
/// <summary>
/// Sort the DataSource
@ -33,15 +33,7 @@ namespace SharpReportCore{ @@ -33,15 +33,7 @@ namespace SharpReportCore{
get;
}
/// <summary>
/// Build a Hierarchical List of grouped DataRows
/// </summary>
/// <param name="sourceList"></param>
/// <returns></returns>
IHierarchicalEnumerable IHierarchicalEnumerable{
get;
}
int Count {
get;
@ -78,8 +70,21 @@ namespace SharpReportCore{ @@ -78,8 +70,21 @@ namespace SharpReportCore{
bool IsGrouped {
get;
}
// event ListChangedEventHandler ListChanged;
/// <summary>
/// Returns if the current Row has Child's
/// </summary>
bool HasChilds {
get;
}
SharpIndexCollection ChildRows {
get;
}
event EventHandler <ListChangedEventArgs> ListChanged;
/// <summary>
/// Fired each tim the grouping will change, this means theGroupLevel changes up or down
/// </summary>

15
src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IHierarchyInterfaces.cs

@ -13,19 +13,12 @@ using System.Collections; @@ -13,19 +13,12 @@ using System.Collections;
namespace SharpReportCore {
public interface IHierarchicalEnumerable :IEnumerable {
IHierarchyData GetHierarchyData (Object enumeratedItem);
}
public interface IHierarchyData{
IHierarchicalEnumerable GetChildren ();
IHierarchyData GetParent();
SharpIndexCollection GetChildren {
get;
}
bool HasChildren {
get;
}

6
src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IOutputStrategy.cs

@ -20,18 +20,18 @@ namespace SharpReportCore @@ -20,18 +20,18 @@ namespace SharpReportCore
/// <summary>
/// Measure the Size of the currnet Item
/// </summary>
SizeF MeasureItem(System.Drawing.Graphics e);
SizeF MeasureItem(System.Drawing.Graphics graphics);
/// <summary>
/// Format the current (TextBased)
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
void FormatItem(System.Drawing.Graphics e );
void FormatItem(System.Drawing.Graphics graphics );
/// <summary>
/// Print them out to ....
/// </summary>
/// <param name="e"></param>
void OutputItem (System.Drawing.Graphics e);
void OutputItem (System.Drawing.Graphics graphics);
}
}

15
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs

@ -47,12 +47,23 @@ namespace SharpReportCore { @@ -47,12 +47,23 @@ namespace SharpReportCore {
}
public RenderDataReport(ReportModel model,DataManager dataManager):base (model){
// System.Console.WriteLine("RenderDataReport".ToUpper());
this.dataManager = dataManager;
System.Console.WriteLine("ReenderDataReport");
System.Console.WriteLine("connect to groupingevents");
this.dataManager.GroupChanged += new EventHandler<GroupChangedEventArgs>(OnGroupChanged);
this.dataManager.GroupChanging += new EventHandler <EventArgs> (OnGroupChanging);
}
void OnGroupChanged (object sender,GroupChangedEventArgs e) {
System.Console.WriteLine("OnGroupChanged");
}
void OnGroupChanging (object sender, EventArgs e) {
System.Console.WriteLine("OnGroupChanging");
}
#region overrides

2
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs

@ -80,7 +80,7 @@ namespace SharpReportCore { @@ -80,7 +80,7 @@ namespace SharpReportCore {
}
public void ReportDocumentPrintPage (object sender, PrintPageEventArgs e) {
// System.Console.WriteLine("\tReportDocument PrintPage");
System.Console.WriteLine("\tReportDocument PrintPage");
pageNr ++;
ReportPageEventArgs pea = new ReportPageEventArgs (e,pageNr,false,new PointF (0,0));

26
src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs

@ -117,9 +117,6 @@ namespace SharpReportCore { @@ -117,9 +117,6 @@ namespace SharpReportCore {
get {
return sectionCollection;
}
set {
sectionCollection = value;
}
}
#endregion
@ -136,16 +133,23 @@ namespace SharpReportCore { @@ -136,16 +133,23 @@ namespace SharpReportCore {
}
protected virtual void Dispose(bool disposing){
if (disposing) {
// Free other state (managed objects).
if (this.reportSettings != null) {
this.reportSettings.Dispose();
this.reportSettings = null;
try {
if (disposing) {
// Free other state (managed objects).
if (this.reportSettings != null) {
this.reportSettings.Dispose();
this.reportSettings = null;
}
if (this.sectionCollection != null) {
this.sectionCollection.Clear();
this.sectionCollection = null;
}
}
}
// Free your own state (unmanaged objects).
// Set large fields to null.
} finally {
// Free your own state (unmanaged objects).
// Set large fields to null.
}
}
#endregion
}

66
src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs

@ -100,18 +100,15 @@ namespace SharpReportCore{ @@ -100,18 +100,15 @@ namespace SharpReportCore{
XmlElement ctrlElem,
AbstractColumn item) {
try {
XmlNodeList nodeList = ctrlElem.ChildNodes;
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement)node;
if (elem.HasAttribute("value")) {
reader.SetValue (item,elem.Name,elem.GetAttribute("value"));
}
XmlNodeList nodeList = ctrlElem.ChildNodes;
foreach (XmlNode node in nodeList) {
XmlElement elem = node as XmlElement;
if (elem != null) {
if (elem.HasAttribute("value")) {
reader.SetValue (item,elem.Name,elem.GetAttribute("value"));
}
}
} catch (Exception ) {
throw ;
}
}
@ -124,18 +121,18 @@ namespace SharpReportCore{ @@ -124,18 +121,18 @@ namespace SharpReportCore{
private void BuildReportParameter(XmlFormReader reader,
XmlElement parElement,
SharpReportCore.AbstractParameter item) {
try {
XmlNodeList nodeList = parElement.ChildNodes;
foreach (XmlNode node in nodeList) {
XmlElement elem = (XmlElement)node;
XmlNodeList nodeList = parElement.ChildNodes;
foreach (XmlNode node in nodeList) {
XmlElement elem = node as XmlElement;
if (elem != null) {
if (elem.HasAttribute("value")) {
reader.SetValue ((SqlParameter)item,elem.Name,elem.GetAttribute("value"));
}
}
} catch (Exception) {
}
}
#endregion
#region RestoreItems
@ -152,8 +149,8 @@ namespace SharpReportCore{ @@ -152,8 +149,8 @@ namespace SharpReportCore{
XmlNodeList nodeList = xmlCol.ChildNodes;
this.availableFields.Clear();
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
AbstractColumn abstr = new AbstractColumn();
BuildAbstractColumn (xmlReader,elem,abstr);
this.availableFields.Add(abstr);
@ -167,8 +164,8 @@ namespace SharpReportCore{ @@ -167,8 +164,8 @@ namespace SharpReportCore{
XmlNodeList nodeList = xmlCol.ChildNodes;
this.sortingCollection.Clear();
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
SortColumn sc = new SortColumn();
BuildAbstractColumn (xmlReader,elem,sc);
sortingCollection.Add(sc);
@ -181,8 +178,8 @@ namespace SharpReportCore{ @@ -181,8 +178,8 @@ namespace SharpReportCore{
XmlNodeList nodeList = xmlCol.ChildNodes;
this.groupingsCollection.Clear();
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
GroupColumn gc = new GroupColumn();
BuildAbstractColumn (xmlReader,elem,gc);
groupingsCollection.Add(gc);
@ -195,8 +192,8 @@ namespace SharpReportCore{ @@ -195,8 +192,8 @@ namespace SharpReportCore{
XmlNodeList nodeList = xmlCol.ChildNodes;
this.reportParametersCollection.Clear();
foreach( XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
SqlParameter parameter = new SqlParameter();
BuildReportParameter (xmlReader,
elem,
@ -205,10 +202,7 @@ namespace SharpReportCore{ @@ -205,10 +202,7 @@ namespace SharpReportCore{
}
}
break;
}
default:
throw new SharpReportException ("Invalid Collection found in ReportSettings:CheckForCollection");
}
}
}
@ -218,8 +212,8 @@ namespace SharpReportCore{ @@ -218,8 +212,8 @@ namespace SharpReportCore{
XmlFormReader xmlFormReader = new XmlFormReader();
base.InitDone = false;
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
CheckForCollection (xmlFormReader,elem);
if (elem.Name == "PageSettings") {
@ -228,9 +222,7 @@ namespace SharpReportCore{ @@ -228,9 +222,7 @@ namespace SharpReportCore{
CultureInfo.InvariantCulture);
}
else if (elem.Name == "DefaultFont") {
Font f = XmlFormReader.MakeFont (elem.GetAttribute("value"));
}
else if (elem.HasAttribute("value")) {
xmlFormReader.SetValue (this,elem.Name,elem.GetAttribute("value"));
}
@ -526,9 +518,9 @@ namespace SharpReportCore{ @@ -526,9 +518,9 @@ namespace SharpReportCore{
get {
return sortingCollection;
}
set {
sortingCollection = value;
}
// set {
// sortingCollection = value;
// }
}
[Browsable(false)]
[XmlIgnoreAttribute]
@ -539,6 +531,7 @@ namespace SharpReportCore{ @@ -539,6 +531,7 @@ namespace SharpReportCore{
}
return groupingsCollection;
}
/*
set {
if (this.groupingsCollection == null) {
groupingsCollection = new ColumnCollection();
@ -548,6 +541,7 @@ namespace SharpReportCore{ @@ -548,6 +541,7 @@ namespace SharpReportCore{
this.NotifyPropertyChanged();
}
}
*/
}
[Browsable(false)]

7
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj

@ -35,9 +35,9 @@ @@ -35,9 +35,9 @@
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<Reference Include="System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="BaseItems\BaseTextItem.cs" />
@ -50,13 +50,10 @@ @@ -50,13 +50,10 @@
<Compile Include="BaseItems\Functions\BaseToday.cs" />
<Compile Include="BaseItems\Functions\BasePageNumber.cs" />
<Compile Include="DataManager\Comparer\BaseComparer.cs" />
<Compile Include="DataManager\Comparer\GroupComparer.cs" />
<Compile Include="DataManager\Comparer\GroupSeperator.cs" />
<Compile Include="DataManager\Comparer\SortComparer.cs" />
<Compile Include="DataManager\ListHandling\ExtendedPropertyDescriptor.cs" />
<Compile Include="DataManager\ListHandling\ExtendedTypeDescriptor.cs" />
<Compile Include="DataManager\ListHandling\IExtendedList.cs" />
<Compile Include="DataManager\ListHandling\IHierarchicalArray.cs" />
<Compile Include="DataManager\ListHandling\PropertyTypeHash.cs" />
<Compile Include="DataManager\ListHandling\SharpArrayList.cs" />
<Compile Include="DataManager\ListStrategy\BaseListStrategy.cs" />
@ -158,4 +155,4 @@ @@ -158,4 +155,4 @@
<Folder Include="BaseClasses" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>
</Project>

61
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs

@ -41,6 +41,7 @@ namespace SharpReportCore { @@ -41,6 +41,7 @@ namespace SharpReportCore {
private PreviewControl previewControl;
private ConnectionObject connectionObject;
private DataManager dataManager;
public event EventHandler <SharpReportEventArgs> NoData;
public event EventHandler <SharpReportParametersEventArgs> ParametersRequest;
@ -134,22 +135,18 @@ namespace SharpReportCore { @@ -134,22 +135,18 @@ namespace SharpReportCore {
}
}
private DataManager SetupDataContainer (ReportSettings settings) {
private void InitDataContainer (ReportSettings settings) {
if (settings.ReportType == GlobalEnums.enmReportType.DataReport) {
if (settings.CommandText != null) {
try {
GrapSqlParameters (settings);
if (this.connectionObject != null) {
DataManager container = new DataManager(this.connectionObject,
this.dataManager = new DataManager(this.connectionObject,
settings);
if (container.DataBind() == true) {
return container;
} else {
return null;
}
this.dataManager.DataBind();
}else {
throw new NullReferenceException("SetupContainer:connectionObject is missing");
}
@ -163,7 +160,6 @@ namespace SharpReportCore { @@ -163,7 +160,6 @@ namespace SharpReportCore {
}
}
}
return null;
}
@ -187,6 +183,7 @@ namespace SharpReportCore { @@ -187,6 +183,7 @@ namespace SharpReportCore {
protected SharpReportCore.AbstractRenderer SetupStandartRenderer (ReportModel model) {
AbstractRenderer abstr = null;
switch (model.ReportSettings.ReportType) {
//FormSheets reports
@ -195,9 +192,10 @@ namespace SharpReportCore { @@ -195,9 +192,10 @@ namespace SharpReportCore {
break;
//Databased reports
case GlobalEnums.enmReportType.DataReport :
DataManager dataManager = SetupDataContainer (model.ReportSettings);
if (dataManager != null) {
if (dataManager.DataSource != null) {
// DataManager dataManager = SetupDataContainer (model.ReportSettings);
InitDataContainer (model.ReportSettings);
if (this.dataManager != null) {
if (this.dataManager.DataSource != null) {
abstr = new RendererFactory().Create (model,dataManager);
}
@ -239,11 +237,12 @@ namespace SharpReportCore { @@ -239,11 +237,12 @@ namespace SharpReportCore {
}
AbstractRenderer abstr = null;
DataManager dataManager = new DataManager (dataTable,model.ReportSettings);
if (dataManager != null) {
dataManager.DataBind();
if (dataManager.DataSource != null) {
this.dataManager = new DataManager (dataTable,model.ReportSettings);
if (this.dataManager != null) {
this.dataManager.DataBind();
if (this.dataManager.DataSource != null) {
abstr = new RendererFactory().Create (model,dataManager);
}
@ -475,7 +474,7 @@ namespace SharpReportCore { @@ -475,7 +474,7 @@ namespace SharpReportCore {
try {
model = ModelFromFile (fileName);
if (!CheckForPushModel(model)) {
throw new SharpReportException ("PrintPushdataReport: No valid ReportModel");
throw new MissingModelException();
}
renderer = this.SetupPushDataRenderer (model,dataTable);
@ -555,19 +554,25 @@ namespace SharpReportCore { @@ -555,19 +554,25 @@ namespace SharpReportCore {
}
protected virtual void Dispose(bool disposing){
if (disposing) {
// Free other state (managed objects).
if (this.connectionObject != null) {
this.connectionObject.Dispose();
}
if (this.previewControl != null) {
this.previewControl.Dispose();
try {
if (disposing) {
// Free other state (managed objects).
if (this.connectionObject != null) {
this.connectionObject.Dispose();
}
if (this.dataManager != null) {
this.dataManager.Dispose();
this.dataManager = null;
}
if (this.previewControl != null) {
this.previewControl.Dispose();
}
}
} finally {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
#endregion
}

30
src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs

@ -44,12 +44,8 @@ namespace SharpReportCore { @@ -44,12 +44,8 @@ namespace SharpReportCore {
///
public static bool IsSharpReport (XmlElement elem) {
bool isOk = false;
try {
if (elem.Name.Equals (SharpReportCore.GlobalValues.SharpReportString)) {
isOk = true;
}
} catch (Exception) {
throw ;
if (elem.Name.Equals (SharpReportCore.GlobalValues.SharpReportString)) {
isOk = true;
}
return isOk;
}
@ -75,13 +71,13 @@ namespace SharpReportCore { @@ -75,13 +71,13 @@ namespace SharpReportCore {
// Valid Document
return xmlDoc;
} else {
throw new SharpReportException ("XmlHelper.OpenSharpReport - > No SharpReport");
throw new IllegalFileFormatException();
}
} else {
throw new SharpReportException ("XmlHelper.OpenSharpReport - > No valid DocumentElement");
throw new IllegalFileFormatException();
}
}
catch (System.Xml.XmlException) {
catch (System.Xml.XmlException ) {
IllegalFileFormatException wf = new IllegalFileFormatException("XmlHelper.OpenSharpReport - > Wrong File Format");
throw wf;
}
@ -108,19 +104,13 @@ namespace SharpReportCore { @@ -108,19 +104,13 @@ namespace SharpReportCore {
XmlNodeList nodeList = element.ChildNodes;
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
if (elem.HasAttribute("value")) {
try {
reader.SetValue (section,elem.Name,elem.GetAttribute("value"));
} catch (Exception e) {
MessageBox.Show (elem.Name + " / " + elem.GetAttribute("value"));
MessageBox.Show (e.Message);
}
reader.SetValue (section,elem.Name,elem.GetAttribute("value"));
}
} else {
throw new System.Xml.XmlException ("Report : SetValues Wrong Node in Report");
}else {
throw new System.Xml.XmlException ();
}
}
}

1
src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.Build.CSharp.targets

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(SharpDevelopUse1xCompiler)' == 'true' ">
<UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>
<ErrorReport/>
<PlatformTarget/>
</PropertyGroup>

89
src/Libraries/NRefactory/Project/Src/Parser/Visitors/VBNetConstructsConvertVisitor.cs

@ -10,6 +10,7 @@ using System.Text; @@ -10,6 +10,7 @@ using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB;
@ -27,6 +28,8 @@ namespace ICSharpCode.NRefactory.Parser @@ -27,6 +28,8 @@ namespace ICSharpCode.NRefactory.Parser
// MyBase.New() and MyClass.New() calls inside the constructor are converted to :base() and :this()
// Add Public Modifier to methods and properties
// Override Finalize => Destructor
// IIF(cond, true, false) => ConditionalExpression
// Built-in methods => Prefix with class name
// The following conversions should be implemented in the future:
// Function A() \n A = SomeValue \n End Function -> convert to return statement
@ -198,5 +201,91 @@ namespace ICSharpCode.NRefactory.Parser @@ -198,5 +201,91 @@ namespace ICSharpCode.NRefactory.Parser
return base.Visit(propertyDeclaration, data);
}
static volatile Dictionary<string, Expression> constantTable;
static volatile Dictionary<string, Expression> methodTable;
public static readonly string VBAssemblyName = "Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
static Dictionary<string, Expression> CreateDictionary(params string[] classNames)
{
Dictionary<string, Expression> d = new Dictionary<string, Expression>(StringComparer.InvariantCultureIgnoreCase);
Assembly asm = Assembly.Load(VBAssemblyName);
foreach (string className in classNames) {
Type type = asm.GetType("Microsoft.VisualBasic." + className);
Expression expr = new IdentifierExpression(className);
foreach (MemberInfo member in type.GetMembers()) {
if (member.DeclaringType == type) { // only direct members
d[member.Name] = expr;
}
}
}
return d;
}
public override object Visit(IdentifierExpression identifierExpression, object data)
{
if (constantTable == null) {
constantTable = CreateDictionary("Constants");
}
Expression expr;
if (constantTable.TryGetValue(identifierExpression.Identifier, out expr)) {
FieldReferenceExpression fre = new FieldReferenceExpression(expr, identifierExpression.Identifier);
ReplaceCurrentNode(fre);
return base.Visit(fre, data);
}
return base.Visit(identifierExpression, data);
}
public override object Visit(InvocationExpression invocationExpression, object data)
{
IdentifierExpression ident = invocationExpression.TargetObject as IdentifierExpression;
if (ident != null) {
if ("IIF".Equals(ident.Identifier, StringComparison.InvariantCultureIgnoreCase)
&& invocationExpression.Arguments.Count == 3)
{
ConditionalExpression ce = new ConditionalExpression(invocationExpression.Arguments[0],
invocationExpression.Arguments[1],
invocationExpression.Arguments[2]);
ReplaceCurrentNode(new ParenthesizedExpression(ce));
return base.Visit(ce, data);
}
if ("IsNothing".Equals(ident.Identifier, StringComparison.InvariantCultureIgnoreCase)
&& invocationExpression.Arguments.Count == 1)
{
BinaryOperatorExpression boe = new BinaryOperatorExpression(invocationExpression.Arguments[0],
BinaryOperatorType.ReferenceEquality,
new PrimitiveExpression(null, "null"));
ReplaceCurrentNode(new ParenthesizedExpression(boe));
return base.Visit(boe, data);
}
if (methodTable == null) {
methodTable = CreateDictionary("Conversion", "FileSystem", "Financial", "Information",
"Interaction", "Strings", "VBMath");
}
Expression expr;
if (methodTable.TryGetValue(ident.Identifier, out expr)) {
FieldReferenceExpression fre = new FieldReferenceExpression(expr, ident.Identifier);
invocationExpression.TargetObject = fre;
}
}
return base.Visit(invocationExpression, data);
}
public override object Visit(UnaryOperatorExpression unaryOperatorExpression, object data)
{
base.Visit(unaryOperatorExpression, data);
if (unaryOperatorExpression.Op == UnaryOperatorType.Not) {
ParenthesizedExpression pe = unaryOperatorExpression.Expression as ParenthesizedExpression;
if (pe != null) {
BinaryOperatorExpression boe = pe.Expression as BinaryOperatorExpression;
if (boe != null && boe.Op == BinaryOperatorType.ReferenceEquality) {
boe.Op = BinaryOperatorType.ReferenceInequality;
ReplaceCurrentNode(pe);
}
}
}
return null;
}
}
}

42
src/Libraries/NRefactory/Test/Output/CSharp/VBToCSharpConverterTest.cs

@ -188,5 +188,47 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -188,5 +188,47 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
"\tDead();\n" +
"}");
}
[Test]
public void IIFExpression()
{
TestStatement("a = iif(cond, trueEx, falseEx)",
"a = (cond ? trueEx : falseEx);");
}
[Test]
public void IsNothing()
{
TestStatement("a = IsNothing(ex)",
"a = (ex == null);");
}
[Test]
public void IsNotNothing()
{
TestStatement("a = Not IsNothing(ex)",
"a = (ex != null);");
}
[Test]
public void CompatibilityMethods()
{
TestStatement("Beep()",
"Interaction.Beep();");
}
[Test]
public void EqualsCall()
{
TestStatement("Equals(a, b)",
"Equals(a, b);");
}
[Test]
public void VBConstants()
{
TestStatement("a = vbYesNo",
"a = Constants.vbYesNo;");
}
}
}

19
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AbstractBuildOptions.cs

@ -192,15 +192,16 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -192,15 +192,16 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
protected void InitTargetFramework(string defaultTargets, string extendedTargets)
{
const string TargetFrameworkProperty = "TargetFrameworkVersion";
debugInfoBinding = helper.BindStringEnum("targetFrameworkComboBox", TargetFrameworkProperty,
"",
new StringPair("", "Default (.NET 2.0)"),
new StringPair("v1.0", ".NET 1.0"),
new StringPair("v1.1", ".NET 1.1"),
new StringPair("v2.0", ".NET 2.0"),
new StringPair("Mono v1.1", "Mono 1.1"),
new StringPair("Mono v2.0", "Mono 2.0"));
debugInfoBinding.CreateLocationButton("targetFrameworkLabel");
ConfigurationGuiBinding targetFrameworkBinding;
targetFrameworkBinding = helper.BindStringEnum("targetFrameworkComboBox", TargetFrameworkProperty,
"",
new StringPair("", "Default (.NET 2.0)"),
new StringPair("v1.0", ".NET 1.0"),
new StringPair("v1.1", ".NET 1.1"),
new StringPair("v2.0", ".NET 2.0"),
new StringPair("Mono v1.1", "Mono 1.1"),
new StringPair("Mono v2.0", "Mono 2.0"));
targetFrameworkBinding.CreateLocationButton("targetFrameworkLabel");
helper.Saved += delegate {
// Test if SharpDevelop-Build extensions are needed
MSBuildProject project = helper.Project;

7
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddWebReferenceDialog.cs

@ -589,7 +589,12 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -589,7 +589,12 @@ namespace ICSharpCode.SharpDevelop.Gui
if (discoveryClientProtocol != null) {
try {
discoveryClientProtocol.Abort();
} catch (NotImplementedException) {};
} catch (NotImplementedException) {
} catch (ObjectDisposedException) {
// Receive this error if the url pointed to a file.
// The discovery client will already have closed the file
// so the abort fails.
}
discoveryClientProtocol.Dispose();
}
discoveryClientProtocol = new WebServiceDiscoveryClientProtocol();

6
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/WebServiceDiscoveryClientProtocol.cs

@ -42,9 +42,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -42,9 +42,9 @@ namespace ICSharpCode.SharpDevelop.Gui
protected override WebResponse GetWebResponse(WebRequest request)
{
lastResponseReceived = null;
lastResponseReceived = base.GetWebResponse(request) as HttpWebResponse;
return lastResponseReceived;
WebResponse response = base.GetWebResponse(request);
lastResponseReceived = response as HttpWebResponse;
return response;
}
}
}

8
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserControl.cs

@ -47,6 +47,12 @@ namespace ICSharpCode.SharpDevelop.Project @@ -47,6 +47,12 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
public AbstractProjectBrowserTreeNode RootNode {
get {
return treeView.Nodes[0] as AbstractProjectBrowserTreeNode;
}
}
public ExtTreeView TreeView {
get {
return treeView;
@ -140,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -140,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.Project
return FindFileNode(treeView.Nodes, fileName);
}
// stores the fileName of the last selected target so
// stores the fileName of the last selected target so
// that we can select it again on opening a folder
string lastSelectionTarget;

12
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/ProjectBrowserPad.cs

@ -20,6 +20,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -20,6 +20,9 @@ namespace ICSharpCode.SharpDevelop.Project
static ProjectBrowserPad instance;
public static ProjectBrowserPad Instance {
get {
if (instance == null) {
WorkbenchSingleton.Workbench.GetPad(typeof(ProjectBrowserPad)).CreatePad();
}
return instance;
}
}
@ -31,6 +34,15 @@ namespace ICSharpCode.SharpDevelop.Project @@ -31,6 +34,15 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
/// <summary>
/// Gets the root node of the project tree view.
/// </summary>
public AbstractProjectBrowserTreeNode SolutionNode {
get {
return projectBrowserPanel.RootNode;
}
}
public ProjectBrowserControl ProjectBrowserControl {
get {
return projectBrowserPanel.ProjectBrowserControl;

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

@ -29,6 +29,12 @@ namespace ICSharpCode.SharpDevelop.Project @@ -29,6 +29,12 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
public AbstractProjectBrowserTreeNode RootNode {
get {
return projectBrowserControl.RootNode;
}
}
public ProjectBrowserControl ProjectBrowserControl {
get {
return projectBrowserControl;

5
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs

@ -416,6 +416,11 @@ namespace ICSharpCode.SharpDevelop.Project @@ -416,6 +416,11 @@ namespace ICSharpCode.SharpDevelop.Project
}
base.Initialize();
}
protected void BaseInitialize()
{
base.Initialize();
}
void AddParentFolder(string virtualName, string relativeDirectoryPath, Dictionary<string, DirectoryNode> directoryNodeList)
{

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

@ -26,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -26,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
public string FileName {
public virtual string FileName {
get {
return fileName;
}

27
src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs

@ -269,15 +269,20 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -269,15 +269,20 @@ namespace ICSharpCode.SharpDevelop.Gui
StatusBarService.RedrawStatusbar();
}
string GetMementoFileName(string contentName)
{
string directory = Path.Combine(PropertyService.ConfigDirectory, "temp");
//string directoryName = Path.GetDirectoryName(contentName);
return Path.Combine(directory,
Path.GetFileName(contentName)
+ "." + contentName.ToLowerInvariant().GetHashCode().ToString("x")
+ ".xml");
}
public Properties GetStoredMemento(IViewContent content)
{
if (content != null && content.FileName != null) {
string directory = Path.Combine(PropertyService.ConfigDirectory, "temp");
if (!Directory.Exists(directory)) {
Directory.CreateDirectory(directory);
}
string fileName = content.FileName.Substring(3).Replace('/', '.').Replace('\\', '.').Replace(Path.DirectorySeparatorChar, '.');
string fullFileName = Path.Combine(directory, fileName);
string fullFileName = GetMementoFileName(content.FileName);
// check the file name length because it could be more than the maximum length of a file name
if (FileUtility.IsValidFileName(fullFileName) && File.Exists(fullFileName)) {
@ -299,8 +304,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -299,8 +304,7 @@ namespace ICSharpCode.SharpDevelop.Gui
}
Properties memento = ((IMementoCapable)content).CreateMemento();
string fileName = content.FileName.Substring(3).Replace('/', '.').Replace('\\', '.').Replace(Path.DirectorySeparatorChar, '.');
string fullFileName = Path.Combine(directory, fileName);
string fullFileName = GetMementoFileName(content.FileName);
if (FileUtility.IsValidFileName(fullFileName)) {
FileUtility.ObservedSave(new NamedFileOperationDelegate(memento.Save), fullFileName, FileErrorPolicy.Inform);
@ -559,7 +563,12 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -559,7 +563,12 @@ namespace ICSharpCode.SharpDevelop.Gui
foreach (string file in files) {
if (File.Exists(file)) {
FileService.OpenFile(file);
IProjectLoader loader = ProjectService.GetProjectLoader(file);
if (loader != null) {
FileUtility.ObservedLoad(new NamedFileOperationDelegate(loader.Load), file);
} else {
FileService.OpenFile(file);
}
}
}
}

19
src/Main/Base/Project/Src/Project/AbstractProject.cs

@ -29,9 +29,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -29,9 +29,10 @@ namespace ICSharpCode.SharpDevelop.Project
protected List<ProjectItem> items = new List<ProjectItem>();
protected List<string> imports = new List<string>();
readonly List<ProjectSection> projectSections = new List<ProjectSection>();
protected string fileName;
protected string language;
string fileName;
string language;
[Browsable(false)]
public Dictionary<string, PropertyGroup> Configurations {
@ -153,6 +154,16 @@ namespace ICSharpCode.SharpDevelop.Project @@ -153,6 +154,16 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
/// <summary>
/// Gets a list of property sections stored in the solution file.
/// </summary>
[Browsable(false)]
public List<ProjectSection> ProjectSections {
get {
return projectSections;
}
}
/// <summary>
/// Gets the list of MSBuild Imports.
/// </summary>
@ -172,7 +183,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -172,7 +183,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (fileName == null) {
return String.Empty;
}
return Path.GetFullPath(fileName);
return fileName;
}
set {
fileName = value;
@ -188,7 +199,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -188,7 +199,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (fileName == null) {
return String.Empty;
}
directoryName = Path.GetFullPath(Path.GetDirectoryName(fileName));
directoryName = Path.GetDirectoryName(fileName);
}
return directoryName;
}

3
src/Main/Base/Project/Src/Project/Converter/LanguageConverter.cs

@ -140,6 +140,9 @@ namespace ICSharpCode.SharpDevelop.Project.Converter @@ -140,6 +140,9 @@ namespace ICSharpCode.SharpDevelop.Project.Converter
targetProject.Save();
targetProject.Dispose();
TreeNode node = ProjectBrowserPad.Instance.SelectedNode;
if (node == null) {
node = ProjectBrowserPad.Instance.SolutionNode;
}
while (node != null) {
if (node is ISolutionFolderNode) {
AddExitingProjectToSolution.AddProject((ISolutionFolderNode)node, targetProject.FileName);

7
src/Main/Base/Project/Src/Project/IProject.cs

@ -30,6 +30,13 @@ namespace ICSharpCode.SharpDevelop.Project @@ -30,6 +30,13 @@ namespace ICSharpCode.SharpDevelop.Project
get;
}
/// <summary>
/// Gets a list of property sections stored in the solution file.
/// </summary>
List<ProjectSection> ProjectSections {
get;
}
/// <summary>
/// Marks a project for needing recompilation.
/// </summary>

4
src/Main/Base/Project/Src/Project/MSBuildProject.cs

@ -61,7 +61,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -61,7 +61,7 @@ namespace ICSharpCode.SharpDevelop.Project
configurations["Release|*"]["DebugSymbols"] = "False";
configurations["Release|*"]["DebugType"] = "None";
fileName = information.OutputProjectFileName;
this.FileName = Path.GetFullPath(information.OutputProjectFileName);
}
public override bool CanCompile(string fileName)
@ -86,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -86,7 +86,7 @@ namespace ICSharpCode.SharpDevelop.Project
protected void SetupProject(string projectFileName)
{
this.fileName = projectFileName;
this.FileName = Path.GetFullPath(projectFileName);
using (MSBuildFileReader reader = new MSBuildFileReader(projectFileName)) {
reader.WhitespaceHandling = WhitespaceHandling.Significant;
reader.MoveToContent(); // we have to skip over the XmlDeclaration (if it exists)

4
src/Main/Base/Project/Src/Project/MissingProject.cs

@ -24,9 +24,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -24,9 +24,9 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
public MissingProject(string fileName)
public MissingProject(string fileName, string title)
{
Name = Path.GetFileNameWithoutExtension(fileName);
Name = title;
FileName = fileName;
IdGuid = "{" + Guid.NewGuid().ToString() + "}";
}

6
src/Main/Base/Project/Src/Project/Solution/ProjectSection.cs

@ -55,17 +55,17 @@ namespace ICSharpCode.SharpDevelop.Project @@ -55,17 +55,17 @@ namespace ICSharpCode.SharpDevelop.Project
}
static Regex sectionPattern = new Regex("\\s*(?<Key>.*\\S)\\s*=\\s*(?<Value>.*\\S)\\s*", RegexOptions.Compiled);
public static ProjectSection ReadGlobalSection(StreamReader sr, string name, string sectionType)
public static ProjectSection ReadGlobalSection(TextReader sr, string name, string sectionType)
{
return ReadSection(sr, name, sectionType, "EndGlobalSection");
}
public static ProjectSection ReadProjectSection(StreamReader sr, string name, string sectionType)
public static ProjectSection ReadProjectSection(TextReader sr, string name, string sectionType)
{
return ReadSection(sr, name, sectionType, "EndProjectSection");
}
static ProjectSection ReadSection(StreamReader sr, string name, string sectionType, string endTag)
static ProjectSection ReadSection(TextReader sr, string name, string sectionType, string endTag)
{
ProjectSection newFolder = new ProjectSection(name, sectionType);
while (true) {

42
src/Main/Base/Project/Src/Project/Solution/Solution.cs

@ -271,23 +271,14 @@ namespace ICSharpCode.SharpDevelop.Project @@ -271,23 +271,14 @@ namespace ICSharpCode.SharpDevelop.Project
projectSection.AppendLine();
if (currentFolder is IProject) {
// IProject project = (IProject)currentFolder;
// currently nothing to do. (I don't know if projects may have sections).
IProject project = (IProject)currentFolder;
// Web projects can have sections
SaveProjectSections(project.ProjectSections, projectSection);
} else if (currentFolder is SolutionFolder) {
SolutionFolder folder = (SolutionFolder)currentFolder;
foreach (ProjectSection section in folder.Sections) {
projectSection.Append("\tProjectSection(");
projectSection.Append(section.Name);
projectSection.Append(") = ");
projectSection.Append(section.SectionType);
projectSection.Append(Environment.NewLine);
section.AppendSection(projectSection, "\t\t");
projectSection.Append("\tEndProjectSection");
projectSection.Append(Environment.NewLine);
}
SaveProjectSections(folder.Sections, projectSection);
foreach (ISolutionFolder subFolder in folder.Folders) {
stack.Push(subFolder);
@ -339,6 +330,22 @@ namespace ICSharpCode.SharpDevelop.Project @@ -339,6 +330,22 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
static void SaveProjectSections(IEnumerable<ProjectSection> sections, StringBuilder projectSection)
{
foreach (ProjectSection section in sections) {
projectSection.Append("\tProjectSection(");
projectSection.Append(section.Name);
projectSection.Append(") = ");
projectSection.Append(section.SectionType);
projectSection.Append(Environment.NewLine);
section.AppendSection(projectSection, "\t\t");
projectSection.Append("\tEndProjectSection");
projectSection.Append(Environment.NewLine);
}
}
static Regex versionPattern = new Regex("Microsoft Visual Studio Solution File, Format Version\\s+(?<Version>.*)", RegexOptions.Compiled);
static Regex projectLinePattern = new Regex("Project\\(\"(?<ProjectGuid>.*)\"\\)\\s+=\\s+\"(?<Title>.*)\",\\s*\"(?<Location>.*)\",\\s*\"(?<Guid>.*)\"", RegexOptions.Compiled);
@ -432,14 +439,19 @@ namespace ICSharpCode.SharpDevelop.Project @@ -432,14 +439,19 @@ namespace ICSharpCode.SharpDevelop.Project
if (match.Success) {
string projectGuid = match.Result("${ProjectGuid}");
string title = match.Result("${Title}");
string location = Path.Combine(solutionDirectory, match.Result("${Location}"));
string location = match.Result("${Location}");
string guid = match.Result("${Guid}");
if (!FileUtility.IsUrl(location)) {
location = Path.Combine(solutionDirectory, location);
}
if (projectGuid == FolderGuid) {
SolutionFolder newFolder = SolutionFolder.ReadFolder(sr, title, location, guid);
newSolution.AddFolder(newFolder);
} else {
IProject newProject = LanguageBindingService.LoadProject(location, title, projectGuid);
ReadProjectSections(sr, newProject.ProjectSections);
newProject.IdGuid = guid;
newSolution.AddFolder(newProject);
}

17
src/Main/Base/Project/Src/Project/Solution/SolutionFolder.cs

@ -117,9 +117,20 @@ namespace ICSharpCode.SharpDevelop.Project @@ -117,9 +117,20 @@ namespace ICSharpCode.SharpDevelop.Project
#endregion
static Regex sectionHeaderPattern = new Regex("\\s*ProjectSection\\((?<Name>.*)\\)\\s*=\\s*(?<Type>.*)", RegexOptions.Compiled);
public static SolutionFolder ReadFolder(StreamReader sr, string title, string location, string guid)
public static SolutionFolder ReadFolder(TextReader sr, string title, string location, string guid)
{
SolutionFolder newFolder = new SolutionFolder(title, location, guid);
ReadProjectSections(sr, newFolder.Sections);
return newFolder;
}
/// <summary>
/// Reads project sections from the TextReader until the line "EndProject" is found and saves
/// them into the specified sectionList.
/// </summary>
public static void ReadProjectSections(TextReader sr, ICollection<ProjectSection> sectionList)
{
while (true) {
string line = sr.ReadLine();
if (line == null || line.Trim() == "EndProject") {
@ -127,11 +138,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -127,11 +138,9 @@ namespace ICSharpCode.SharpDevelop.Project
}
Match match = sectionHeaderPattern.Match(line);
if (match.Success) {
newFolder.Sections.Add(ProjectSection.ReadProjectSection(sr, match.Result("${Name}"), match.Result("${Type}")));
sectionList.Add(ProjectSection.ReadProjectSection(sr, match.Result("${Name}"), match.Result("${Type}")));
}
}
return newFolder;
}
}
}

4
src/Main/Base/Project/Src/Project/UnknownProject.cs

@ -24,9 +24,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -24,9 +24,9 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
public UnknownProject(string fileName)
public UnknownProject(string fileName, string title)
{
Name = Path.GetFileNameWithoutExtension(fileName);
Name = title;
FileName = fileName;
IdGuid = "{" + Guid.NewGuid().ToString() + "}";
}

6
src/Main/Base/Project/Src/Services/LanguageBinding/LanguageBindingService.cs

@ -84,7 +84,7 @@ namespace ICSharpCode.Core @@ -84,7 +84,7 @@ namespace ICSharpCode.Core
{
IProject newProject;
if (!File.Exists(location)) {
newProject = new MissingProject(location);
newProject = new MissingProject(location, title);
newProject.TypeGuid = projectTypeGuid;
} else {
ILanguageBinding binding = LanguageBindingService.GetBindingPerProjectFile(location);
@ -93,11 +93,11 @@ namespace ICSharpCode.Core @@ -93,11 +93,11 @@ namespace ICSharpCode.Core
newProject = binding.LoadProject(location, title);
} catch (XmlException ex) {
MessageService.ShowError("Error loading " + location + ":\n" + ex.Message);
newProject = new UnknownProject(location);
newProject = new UnknownProject(location, title);
newProject.TypeGuid = projectTypeGuid;
}
} else {
newProject = new UnknownProject(location);
newProject = new UnknownProject(location, title);
newProject.TypeGuid = projectTypeGuid;
}
}

7
src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs

@ -296,9 +296,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -296,9 +296,10 @@ namespace ICSharpCode.SharpDevelop.Project
static string GetPreferenceFileName(string projectFileName)
{
string directory = Path.Combine(PropertyService.ConfigDirectory, "preferences");
string fileName = projectFileName.Substring(3).Replace('/', '.').Replace('\\', '.').Replace(Path.DirectorySeparatorChar, '.');
string fullFileName = Path.Combine(directory, fileName + ".xml");
return fullFileName;
return Path.Combine(directory,
Path.GetFileName(projectFileName)
+ "." + projectFileName.ToLowerInvariant().GetHashCode().ToString("x")
+ ".xml");
}
public static void SaveSolutionPreferences()

3
src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs

@ -29,6 +29,9 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -29,6 +29,9 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
public static BookmarkPad Instance {
get {
if (instance == null) {
WorkbenchSingleton.Workbench.GetPad(typeof(BookmarkPad)).CreatePad();
}
return instance;
}
}

19
src/Main/Core/Project/Src/Services/FileUtility/FileUtility.cs

@ -103,6 +103,10 @@ namespace ICSharpCode.Core @@ -103,6 +103,10 @@ namespace ICSharpCode.Core
return result;
}
public static bool IsUrl(string path)
{
return path.IndexOf(':') >= 2;
}
/// <summary>
/// Converts a given absolute path and a given base path to a path that leads
@ -110,8 +114,15 @@ namespace ICSharpCode.Core @@ -110,8 +114,15 @@ namespace ICSharpCode.Core
/// </summary>
public static string GetRelativePath(string baseDirectoryPath, string absPath)
{
baseDirectoryPath = Path.GetFullPath(baseDirectoryPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
absPath = Path.GetFullPath(absPath);
if (IsUrl(absPath) || IsUrl(baseDirectoryPath)){
return absPath;
}
try {
baseDirectoryPath = Path.GetFullPath(baseDirectoryPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
absPath = Path.GetFullPath(absPath);
} catch (Exception ex) {
throw new ArgumentException("GetRelativePath error '" + baseDirectoryPath + "' -> '" + absPath + "'", ex);
}
string[] bPath = baseDirectoryPath.Split(separators);
string[] aPath = absPath.Split(separators);
@ -265,6 +276,8 @@ namespace ICSharpCode.Core @@ -265,6 +276,8 @@ namespace ICSharpCode.Core
}
}
public static int MaxPathLength = 260;
/// <summary>
/// This method checks the file fileName if it is valid.
/// </summary>
@ -273,7 +286,7 @@ namespace ICSharpCode.Core @@ -273,7 +286,7 @@ namespace ICSharpCode.Core
// Fixme: 260 is the hardcoded maximal length for a path on my Windows XP system
// I can't find a .NET property or method for determining this variable.
if (fileName == null || fileName.Length == 0 || fileName.Length >= 260) {
if (fileName == null || fileName.Length == 0 || fileName.Length >= MaxPathLength) {
return false;
}

3
src/Main/Core/Test/AddInTreeTests/ExtPathTests.cs

@ -56,6 +56,9 @@ namespace ICSharpCode.Core.Tests.AddInTreeTests.Tests @@ -56,6 +56,9 @@ namespace ICSharpCode.Core.Tests.AddInTreeTests.Tests
Assert.AreEqual(@"blub", FileUtility.GetRelativePath(@"C:\hello\.\..\A", @"C:\.\a\blub"));
Assert.AreEqual(@"..\a\blub", FileUtility.GetRelativePath(@"C:\.\.\.\.\HELlo", @"C:\.\blub\.\..\.\a\.\blub"));
Assert.AreEqual(@"..\a\blub", FileUtility.GetRelativePath(@"C:\.\.\.\.\heLLo\A\..", @"C:\.\blub\.\..\.\a\.\blub"));
// Project filename could be an URL
Assert.AreEqual("http://example.com/vdir/", FileUtility.GetRelativePath("C:\\temp", "http://example.com/vdir/"));
}
[Test]

Loading…
Cancel
Save