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
public ICollection GetTypes(Type baseType, bool excludeGlobalTypes) public ICollection GetTypes(Type baseType, bool excludeGlobalTypes)
{ {
List<Type> types = new List<Type>(); List<Type> types = new List<Type>();
if (baseType != null) {
LoggingService.Debug("TypeDiscoveryService.GetTypes for " + baseType.FullName if (baseType == null) {
+ "excludeGlobalTypes=" + excludeGlobalTypes.ToString()); baseType = typeof(object);
//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 LoggingService.Debug("TypeDiscoveryService.GetTypes for " + baseType.FullName
// ToArray to prevent an exception if the collection changes. + "excludeGlobalTypes=" + excludeGlobalTypes.ToString());
foreach (Assembly asm in TypeResolutionService.DesignerAssemblies.ToArray()) { //seek in all assemblies
AddDerivedTypes(baseType, asm, types); //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"); AddDerivedTypes(baseType, asm, types);
// TODO - Don't look in all assemblies.
// Should use the current project and its referenced assemblies
// as well as System.Windows.Forms.
} }
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; return types;
} }

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

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

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

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

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

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

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

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

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

@ -98,15 +98,7 @@ namespace SharpReportCore {
#endregion #endregion
#region System.IDisposable interface implementation
public virtual void Dispose() {
if(Disposed != null){
Disposed(this,EventArgs.Empty);
}
}
#endregion
#region Properties #region Properties
@ -169,5 +161,33 @@ namespace SharpReportCore {
#endregion #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;
/// </remarks> /// </remarks>
namespace SharpReportCore { namespace SharpReportCore {
public class BaseReportObject : IBaseRenderer,INotifyPropertyChanged { public class BaseReportObject : IBaseRenderer,INotifyPropertyChanged,
IDisposable{
private string name; private string name;
private object parent; private object parent;
@ -212,5 +213,23 @@ namespace SharpReportCore {
} }
#endregion #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 @@
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version: 1.1.4322.2032 // 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. // the code is regenerated.
// </autogenerated> // </autogenerated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -16,32 +16,56 @@ using System.ComponentModel;
/// created by - Forstmeier Helmut /// created by - Forstmeier Helmut
/// created on - 01.09.2005 13:12:32 /// created on - 01.09.2005 13:12:32
/// </remarks> /// </remarks>
namespace SharpReportCore { namespace SharpReportCore {
public class BaseSection : SharpReportCore.BaseReportObject { public class BaseSection : SharpReportCore.BaseReportObject {
private ReportItemCollection items; 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 #region System.IDisposable interface implementation
public void Dispose() { public override void Dispose () {
for (int i = 0;i < items.Count ;i ++ ){ Dispose(true);
((BaseReportItem)items[i]).Dispose(); 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 #endregion
#region properties #region properties
public BaseSection (string sectionName) :base(){
this.Name = sectionName;
items = new ReportItemCollection();
}
[Browsable(false)] [Browsable(false)]
public ReportItemCollection Items{ public ReportItemCollection Items{
get { get {
if (this.items == null) {
items = new ReportItemCollection();
}
return items; return items;
} }
} }

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

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

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

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

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

@ -55,15 +55,33 @@ namespace SharpReportCore {
} }
} }
#region IDisposeable
public void Dispose () {
Dispose(true);
GC.SuppressFinalize(this);
}
~ConnectionObject(){
Dispose(false);
}
public void Dispose(){ protected virtual void Dispose(bool disposing) {
if (this.connection != null) { try{
if (this.connection.State == ConnectionState.Open) { if (disposing){
this.connection.Close(); 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 {
} }
/// <summary> /// <summary>
/// TODO - add method description /// Interface method from IComparable
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Interface method from IComparable /// Interface method from IComparable
/// ///
/// </remarks> /// </remarks>
/// <param name='obj'>TODO - add parameter description</param> /// <param name='obj'>a <see cref="BaseComparer"></see></param>
public virtual int CompareTo(object obj) { public virtual int CompareTo(object obj) {
return 0; return 0;
} }

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

@ -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;
/// </remarks> /// </remarks>
namespace SharpReportCore { namespace SharpReportCore {
public class GroupSeperator : SharpReportCore.GroupComparer,IHierarchyData { public class GroupSeperator : SharpReportCore.BaseComparer,IHierarchyData {
private string typeName = "GroupSeperator"; private string typeName = "GroupSeperator";
int groupLevel; int groupLevel;
IHierarchicalArray childs ; SharpIndexCollection childs ;
public GroupSeperator(ColumnCollection owner, int listIndex, object[] values,int groupLevel): public GroupSeperator(ColumnCollection owner, int listIndex, object[] values,int groupLevel):
base(owner,listIndex,values) { base(owner,listIndex,values) {
@ -40,16 +40,89 @@ namespace SharpReportCore {
} }
} }
public IHierarchicalArray Childs { public SharpIndexCollection GetChildren {
get { get {
if (this.childs == null) {
this.childs = new SharpIndexCollection("ChildList");
}
return childs; 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 #region SharpReportCore.IHierarchyData interface implementation
@ -85,13 +158,13 @@ namespace SharpReportCore {
} }
} }
public IHierarchicalEnumerable GetChildren() { // public IHierarchicalEnumerable GetChildren() {
return this.childs; // return this.childs;
} // }
//
public IHierarchyData GetParent() { // public IHierarchyData GetParent() {
return null; // return null;
} // }
#endregion #endregion

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

@ -28,7 +28,7 @@ namespace SharpReportCore {
throw new ArgumentNullException("value"); throw new ArgumentNullException("value");
if (value.ObjectArray.Length != base.ObjectArray.Length) if (value.ObjectArray.Length != base.ObjectArray.Length)
throw new InvalidOperationException("Differnet size of compare data"); throw new InvalidOperationException();
int compare = 0; int compare = 0;
@ -61,7 +61,7 @@ namespace SharpReportCore {
if (leftValue.GetType() != rightValue.GetType()) 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)) if (leftValue.GetType() == typeof(string))
{ {

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

@ -45,12 +45,11 @@ namespace SharpReportCore {
ConnectionObject connectionObject; ConnectionObject connectionObject;
IDbConnection connection; IDbConnection connection;
IDataViewStrategy dataViewStrategy; IDataViewStrategy dataViewStrategy;
GroupSeperator groupSeperator;
// private ListChangedEventArgs resetList = new ListChangedEventArgs(ListChangedType.Reset,-1,-1);
public event EventHandler <ListChangedEventArgs> ListChanged; public event EventHandler <ListChangedEventArgs> ListChanged;
public event EventHandler <GroupChangedEventArgs> GroupChanged; public event EventHandler <GroupChangedEventArgs> GroupChanged;
public event EventHandler <EventArgs> GroupChanging;
/// <summary> /// <summary>
/// use this Constructor for PullDataReports /// use this Constructor for PullDataReports
@ -60,34 +59,32 @@ namespace SharpReportCore {
#region Constructores #region Constructores
public DataManager(ConnectionObject connectionObject, ReportSettings reportSettings){ public DataManager(ConnectionObject connectionObject, ReportSettings reportSettings){
CheckAndSetReportSettings(reportSettings);
if (connectionObject == null) { if (connectionObject == null) {
throw new ArgumentNullException("DataManager:ConnectionObject"); throw new ArgumentNullException("DataManager:ConnectionObject");
} }
this.connectionObject = connectionObject;
try { if (reportSettings == null) {
CheckConnection (this.connectionObject); throw new ArgumentNullException("reportSettings");
CheckAndSetSource(this.FillDataSet().Tables[0]);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception) {
throw;
} }
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){ public DataManager(DataTable dataSource, ReportSettings reportSettings){
try {
CheckAndSetReportSettings(reportSettings); this.InitDataManager(reportSettings,dataSource);
CheckAndSetSource(dataSource); this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource, reportSettings);
reportSettings); this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception) {
throw ;
}
} }
public DataManager(DataSet dataSource, ReportSettings reportSettings) public DataManager(DataSet dataSource, ReportSettings reportSettings)
@ -97,54 +94,49 @@ namespace SharpReportCore {
public DataManager(DataSet dataSource,string dataMember, ReportSettings reportSettings){ public DataManager(DataSet dataSource,string dataMember, ReportSettings reportSettings){
try { this.dataMember = dataMember;
this.dataMember = dataMember; this.InitDataManager(reportSettings,dataSource);
CheckAndSetReportSettings(reportSettings); this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
CheckAndSetSource(dataSource); reportSettings);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource, this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception ) {
throw ;
}
} }
public DataManager(IList dataSource, ReportSettings reportSettings){ 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 { try {
CheckAndSetReportSettings(reportSettings); CheckReportSettings(reportSettings);
CheckAndSetSource(dataSource); CheckDataSource(dataSource);
this.dataViewStrategy = new CollectionStrategy ((IList)this.dataSource,
this.dataMember,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception) { } catch (Exception) {
throw; throw;
} }
} }
#endregion void CheckReportSettings(ReportSettings settings) {
void CheckAndSetReportSettings(ReportSettings settings) {
if (settings == null) {
throw new ArgumentNullException("settings");
}
try { try {
if (settings.DataModel != GlobalEnums.enmPushPullModel.PushData) { if (settings.DataModel != GlobalEnums.enmPushPullModel.PushData) {
SqlQueryCkecker check = new SqlQueryCkecker(); SqlQueryChecker checker = new SqlQueryChecker();
check.Check(settings.CommandText); checker.Check(settings.CommandText);
} }
} catch (Exception) { } catch (Exception) {
throw; throw;
} }
this.reportSettings = settings; this.reportSettings = settings;
} }
void CheckAndSetSource(object source) { void CheckDataSource(object source) {
if (source == null) { if (source == null) {
throw new MissingDataSourceException(); throw new MissingDataSourceException();
} }
@ -175,7 +167,7 @@ namespace SharpReportCore {
} }
} }
}else { }else {
throw new ArgumentException("DataManager:No Tables in DataSet"); throw new MissingDataSourceException();
} }
return; return;
} }
@ -186,24 +178,13 @@ namespace SharpReportCore {
this.dataSource = list; this.dataSource = list;
this.dataMember = source.ToString(); this.dataMember = source.ToString();
if (list.Count == 0) { if (list.Count == 0) {
//System.Console.WriteLine("List mit {0} Rows",list.Count); throw new MissingDataSourceException();
throw new ArgumentException("No empty IList allowed");
} }
return; 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 { } else {
throw new ArgumentException ("DataManager:Wrong DataSource"); throw new MissingDataSourceException();
} }
} }
@ -215,7 +196,7 @@ namespace SharpReportCore {
} }
connection.Open(); connection.Open();
connection.Close(); connection.Close();
} catch (Exception ) { } catch (Exception) {
throw; throw;
} }
} }
@ -296,14 +277,25 @@ namespace SharpReportCore {
this.ListChanged (this,e); this.ListChanged (this,e);
} }
} }
private void NotifyGroupChanging () {
if (this.GroupChanging!= null) {
this.GroupChanging (this,EventArgs.Empty);
}
}
private void NotifyGroupChange (object sender,GroupChangedEventArgs e) { private void NotifyGroupChanged() {
if (this.IsGrouped) {
if (this.GroupChanged != null) { if (this.GroupChanged != null) {
this.GroupChanged (this,e); this.GroupChanged (this,new GroupChangedEventArgs(this.groupSeperator));
}
} }
} }
private void OnGroupChange (object sender,GroupChangedEventArgs e) {
this.groupSeperator = e.GroupSeperator;
this.NotifyGroupChanging();
}
#endregion #endregion
public string DataMember { public string DataMember {
@ -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 #region SharpReportCore.IDataContainer interface implementation
public object DataSource { public object DataSource {
get { get {
return this.dataSource; return this.dataSource;
} }
set {
this.dataSource = value;
Reset();
}
} }
public int CurrentRow { public int CurrentRow {
@ -399,9 +345,8 @@ namespace SharpReportCore {
public bool DataBind() { public bool DataBind() {
this.dataViewStrategy.Bind();
this.dataViewStrategy.GroupChanged += new EventHandler <GroupChangedEventArgs>(NotifyGroupChange);
CheckReportColumns(); CheckReportColumns();
this.dataViewStrategy.Bind();
return true; return true;
} }
@ -411,11 +356,30 @@ namespace SharpReportCore {
public void FetchData(ReportItemCollection collection) { public void FetchData(ReportItemCollection collection) {
try { foreach (IItemRenderer item in collection) {
foreach (IItemRenderer item in collection) { this.dataViewStrategy.Fill(item);
this.dataViewStrategy.Fill(item); }
} this.NotifyGroupChanged();
} catch (Exception) { }
/// <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 {
public object Current { public object Current {
get { get {
throw new NotImplementedException("DataManager.Current"); throw new NotImplementedException();
} }
} }
@ -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 #region System.IDisposable interface implementation
public void Dispose() { public void Dispose() {
this.connectionObject = null; this.Dispose(true);
this.dataViewStrategy = null; 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 #endregion

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

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

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

@ -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 @@
//------------------------------------------------------------------------------
// <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{
Hashtable types = new Hashtable(); Hashtable types = new Hashtable();
private string MakeIndex(Type t, string name) private static string MakeIndex(Type t, string name)
{ {
return t.FullName + '.' + name; return t.FullName + '.' + name;
} }
public object this[Type t, string fieldName] public object this[Type type, string fieldName]
{ {
get get
{ {
return types[MakeIndex(t, fieldName)]; return types[MakeIndex(type, fieldName)];
} }
set set
{ {
if (value == null) if (value == null)
return; return;
string key = MakeIndex(t, fieldName); string key = MakeIndex(type, fieldName);
if (!types.Contains(key)) if (!types.Contains(key))
types.Add(key, value); types.Add(key, value);
} }

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

@ -1,306 +1,229 @@
using System; using System;
using System.Data; using System.Data;
using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Collections; using System.Collections;
using System.ComponentModel; using System.ComponentModel;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace SharpReportCore namespace SharpReportCore
{ {
/// <summary>
/// This class act'S as a IndexList to
/// <see cref="SharpBaseList"></see>
/// </summary> /// </summary>
public class SharpArrayList : ArrayList, IBindingList ,ITypedList,IExtendedList public class SharpIndexCollection :List<BaseComparer> {
{
Type elementType;
string name; string name;
int currentPosition; int currentPosition;
bool allowNew = true; public SharpIndexCollection():this ("SharpIndexList"){
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();
} }
#region ITypedList Member public SharpIndexCollection(string name){
this.name = name;
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);
}
} }
#region System.ComponentModel.IBindingList interface implementation #region properties
public bool AllowNew {
public int CurrentPosition {
get { get {
return this.allowNew; return currentPosition;
} }
} set {
currentPosition = value;
public bool AllowEdit {
get {
return this.allowEdit;
} }
} }
public bool AllowRemove { public string Name {
get { get {
return this.allowRemove; return name;
} }
} }
public bool SupportsChangeNotification {
get {
return true;
}
}
public bool SupportsSearching { #endregion
get { }
return this.supportsSearching;
} /// <summary>
set { /// This class act's as a store of the original Data
this.supportsSearching = value; /// </summary>
}
} public class SharpDataCollection<T> : IList<T>,ITypedList{
Collection<T> list = new Collection<T>();
Type elementType;
public bool SupportsSorting { public SharpDataCollection(Type elementType)
get { {
return this.supportsSorting; this.elementType = elementType;
}
set {
this.supportsSorting = value;
}
} }
public bool IsSorted { public T this[int index] {
get { get {
return this.isSorted; return list[index];
} }
set { 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 { get {
return null; return list.Count;
} }
} }
public System.ComponentModel.ListSortDirection SortDirection { public bool IsReadOnly {
get { get {
return ListSortDirection.Ascending; return false;
} }
} }
public void RemoveSort() { public int IndexOf(T item)
throw new NotImplementedException("RemoveSort"); {
} return list.IndexOf(item);
//TODO Test fehlt
public void RemoveIndex(System.ComponentModel.PropertyDescriptor property) {
throw new NotImplementedException("RemoveIndex");
} }
//TODO Test fehlt public void Insert(int index, T item)
public int Find(System.ComponentModel.PropertyDescriptor property, object key) { {
// return 0; list.Insert(index, item);
throw new NotImplementedException("Find");
} }
//TODO Test fehlt
public void ApplySort(System.ComponentModel.PropertyDescriptor property, System.ComponentModel.ListSortDirection direction) { public void RemoveAt(int index)
throw new NotImplementedException("ApplySort"); {
} // T item = list[index];
//TODO Test fehlt list.RemoveAt(index);
public void AddIndex(System.ComponentModel.PropertyDescriptor property) {
throw new NotImplementedException("AddIndex");
} }
public object AddNew() { public void Add(T item)
throw new NotImplementedException("AddNew"); {
list.Add(item);
} }
#endregion public void AddRange(IList range)
{
#region overrides foreach(T t in range) {
public override int Add(object value) { Add(t);
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 override void AddRange(System.Collections.ICollection c) { public void Clear(){
foreach (object o in c) { list = new Collection<T>();
this.Add (o);
}
} }
public bool Contains(T item)
public override void RemoveAt(int index) { {
if (this.allowRemove) { return list.Contains(item);
if (index > -1) {
base.RemoveAt(index);
this.OnListChange (new ListChangedEventArgs(ListChangedType.ItemDeleted,index));
}
} else {
throw new NotSupportedException("SharpArrayList:RemoveAt (index)");
}
} }
public void CopyTo(T[] array, int arrayIndex)
#endregion {
list.CopyTo(array, arrayIndex);
#region SharpReport.Data.IExtendedList interface implementation
public string Name {
get {
return this.name;
}
} }
public int CurrentPosition { public bool Remove(T item)
get { {
return currentPosition; if (list.Remove(item)) {
return true;
} }
set { return false;
currentPosition = value; }
#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 static Type GetElementType(IList list, Type parentType, string propertyName)
public IList IndexList { {
get { SharpDataCollection<T> al = null;
return(IList)this; 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) { private static SharpDataCollection<T> CheckForArrayList(object l)
throw new NotImplementedException("SharpArrayList:BuildHashList"); {
/* IList list = l as IList;
this.Clear(); if (list == null)
for (int i = 0;i < list.Count ;i++ ) { return null;
// this.Add (new PlainIndexItem(i,"satz " + i.ToString())); 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 #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;
using SharpReportCore; using SharpReportCore;
/// <summary> /// <summary>
/// BaseClass for all datahandling Strategies /// BaseClass for all Datahandling Strategies
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// created by - Forstmeier Peter /// created by - Forstmeier Peter
@ -30,10 +30,9 @@ namespace SharpReportCore {
private bool isGrouped; private bool isGrouped;
//Index to plain Datat //Index to plain Datat
private SharpArrayList indexList; private SharpIndexCollection indexList;
private ReportSettings reportSettings; private ReportSettings reportSettings;
private IHierarchicalArray hierarchicalList;
private ListChangedEventArgs resetList = new ListChangedEventArgs(ListChangedType.Reset,-1,-1); private ListChangedEventArgs resetList = new ListChangedEventArgs(ListChangedType.Reset,-1,-1);
@ -43,20 +42,16 @@ namespace SharpReportCore {
#region Constructor #region Constructor
protected BaseListStrategy(ReportSettings reportSettings) { protected BaseListStrategy(ReportSettings reportSettings) {
if (reportSettings == null) {
throw new ArgumentNullException("reportSettings");
}
this.reportSettings = reportSettings; this.reportSettings = reportSettings;
this.indexList = new SharpArrayList(typeof(BaseComparer),"IndexList"); this.indexList = new SharpIndexCollection("IndexList");
} }
#endregion #endregion
#region Event's #region Event's
protected void NotifyGroupChange (object source,GroupSeperator groupSeperator) {
if (this.GroupChanged != null) {
this.GroupChanged (source,new GroupChangedEventArgs(groupSeperator));
}
}
protected void NotifyResetList(){ protected void NotifyResetList(){
if (this.ListChanged != null) { if (this.ListChanged != null) {
@ -64,10 +59,18 @@ namespace SharpReportCore {
} }
} }
protected void NotifyGroupChanging (object source,GroupSeperator groupSeperator) {
if (this.GroupChanged != null) {
this.GroupChanged (source,new GroupChangedEventArgs(groupSeperator));
}
}
#endregion #endregion
public SharpArrayList IndexList { public SharpIndexCollection IndexList {
get { get {
return indexList; return indexList;
} }
@ -79,21 +82,87 @@ namespace SharpReportCore {
return reportSettings; 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){ private static GroupSeperator BuildGroupSeperator (BaseComparer newGroup,int groupLevel) {
// System.Console.WriteLine("");
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); System.Console.WriteLine("{0}",text);
// string tabs = String.Empty;
if (arr != null) { if (arr != null) {
int row = 0; int row = 0;
foreach (BaseComparer bc in arr) { foreach (BaseComparer bc in arr) {
GroupSeperator sep = bc as GroupSeperator; GroupSeperator sep = bc as GroupSeperator;
if (sep != null) { if (sep != null) {
// System.Console.WriteLine("\t Group change {0} level {1}",sep.ObjectArray[0].ToString(),
// sep.GroupLevel);
} else { } else {
object [] oarr = bc.ObjectArray; object [] oarr = bc.ObjectArray;
@ -107,12 +176,10 @@ namespace SharpReportCore {
} }
} }
System.Console.WriteLine("----------------"); System.Console.WriteLine("-----End of <CheckSortArray>-----------");
System.Console.WriteLine("");
} }
#region SharpReportCore.IDataViewStrategy interface implementation #region SharpReportCore.IDataViewStrategy interface implementation
public virtual ColumnCollection AvailableFields { public virtual ColumnCollection AvailableFields {
@ -133,8 +200,7 @@ namespace SharpReportCore {
} }
set { set {
if (value > this.indexList.Count){ if (value > this.indexList.Count){
throw new IndexOutOfRangeException ("There is no row at " + throw new IndexOutOfRangeException ();
"currentRow: " + value + ".");
} }
this.indexList.CurrentPosition = value; this.indexList.CurrentPosition = value;
} }
@ -167,15 +233,10 @@ namespace SharpReportCore {
get { get {
return this.isGrouped; return this.isGrouped;
} }
set {
this.isGrouped = true;
}
} }
protected virtual void Group() { protected virtual void Group() {
if (this.indexList != null) { if (this.indexList != null) {
this.BuildHierarchicalList (this.indexList);
this.isGrouped = true; this.isGrouped = true;
this.isSorted = true; this.isSorted = true;
} else { } else {
@ -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(); public bool HasChilds {
int level = 0; get {
if (this.IsGrouped == true) {
// System.Console.WriteLine(""); GroupSeperator gs = (GroupSeperator)this.indexList[this.CurrentRow] as GroupSeperator;
// System.Console.WriteLine("BuildHierachicalList"); if (gs != null) {
return (gs.GetChildren.Count > 0);
// ColumnCollection grBy =this.reportSettings.GroupColumnsCollection; } else {
// string columnName = grBy[level].ColumnName; return false;
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);
} }
} 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 { 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() { ~BaseListStrategy(){
this.NotifyResetList(); 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;
}
}
} // Release unmanaged resources.
// Set large fields to null.
public virtual void Fill(IItemRenderer item) { // Call Dispose on your base class.
} }
#endregion #endregion
} }
} }

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

@ -23,29 +23,67 @@ namespace SharpReportCore {
public class CollectionStrategy : BaseListStrategy { public class CollectionStrategy : BaseListStrategy {
// Holds the plain Data // Holds the plain Data
private SharpArrayList baseList;
private Type itemType; private Type itemType;
private object firstItem; private object firstItem;
private object current; private object current;
private PropertyDescriptorCollection listProperties; private PropertyDescriptorCollection listProperties;
private SharpDataCollection<object> baseList;
public CollectionStrategy(IList list,string dataMember,ReportSettings reportSettings):base(reportSettings) { public CollectionStrategy(IList list,string dataMember,ReportSettings reportSettings):base(reportSettings) {
if (list.Count > 0) { if (list.Count > 0) {
firstItem = list[0]; firstItem = list[0];
itemType = firstItem.GetType(); itemType = firstItem.GetType();
this.baseList = new SharpArrayList(itemType,dataMember);
this.baseList = new SharpDataCollection <object>(itemType);
this.baseList.AddRange(list); this.baseList.AddRange(list);
this.baseList.CurrentPosition = 0;
this.current = this.baseList[0];
} }
this.listProperties = this.baseList.GetItemProperties(null);
} }
private void BuildGroup(){ 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){ private PropertyDescriptor[] BuildSortProperties (ColumnCollection col){
@ -66,69 +104,54 @@ namespace SharpReportCore {
} }
#region Index Building #region Index Building
private void BuildSortIndex(SharpIndexCollection arrayList,ColumnCollection col) {
//Sorted Indexlist
private ArrayList BuildSortIndex(ColumnCollection col) {
PropertyDescriptor[] sortProperties = BuildSortProperties (col); PropertyDescriptor[] sortProperties = BuildSortProperties (col);
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
// Übertragen der zu sortierenden Werte in eine standartComparer Auflistung object rowItem = this.baseList[rowIndex];
ArrayList sortValues = new ArrayList(this.baseList.Count); object[] values = new object[col.Count];
try {
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){ // Hier bereits Wertabruf um dies nicht während des Sortierens tun zu müssen.
object rowItem = this.baseList[rowIndex]; for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++){
object[] values = new object[col.Count]; 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. if (value != null && value != DBNull.Value)
for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++){ {
object value = sortProperties[criteriaIndex].GetValue(rowItem); if (!(value is IComparable)){
// Hier auf Verträglichkeit testen um Vergleiche bei Sortierung zu vereinfachen. throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
// 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;
} }
values[criteriaIndex] = value;
} }
sortValues.Add(new SortComparer(col, rowIndex, values));
} }
} catch (Exception) { arrayList.Add(new SortComparer(col, rowIndex, values));
throw ;
} }
arrayList.Sort();
sortValues.Sort();
return sortValues;
} }
// if we have no sorting, we build the indexlist as well, so we don't need to // 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 //check each time we reasd data if we have to go directly or by IndexList
private void BuildPlainIndex(SharpIndexCollection arrayList,ColumnCollection col) {
private ArrayList BuildPlainIndex(ColumnCollection col) {
PropertyDescriptor[] sortProperties = new PropertyDescriptor[1]; PropertyDescriptor[] sortProperties = new PropertyDescriptor[1];
PropertyDescriptorCollection c = this.baseList.GetItemProperties(null); PropertyDescriptorCollection c = this.baseList.GetItemProperties(null);
PropertyDescriptor descriptor = c[0]; PropertyDescriptor descriptor = c[0];
sortProperties[0] = descriptor; sortProperties[0] = descriptor;
ArrayList sortValues = new ArrayList(this.baseList.Count);
try { for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){ object[] values = new object[1];
object[] values = new object[1];
// We insert only the RowNr as a dummy value
// We insert only the RowNr as a dummy value values[0] = rowIndex;
values[0] = rowIndex; arrayList.Add(new BaseComparer(col, rowIndex, values));
sortValues.Add(new BaseComparer(col, rowIndex, values));
}
} catch (Exception) {
throw ;
} }
return sortValues;;
} }
#endregion #endregion
#region SharpReportCore.IDataViewStrategy interface implementation #region SharpReportCore.IDataViewStrategy interface implementation
@ -156,7 +179,6 @@ namespace SharpReportCore {
set { set {
base.CurrentRow = value; base.CurrentRow = value;
current = this.baseList[((BaseComparer)base.IndexList[value]).ListIndex]; current = this.baseList[((BaseComparer)base.IndexList[value]).ListIndex];
} }
} }
@ -164,28 +186,19 @@ namespace SharpReportCore {
public override void Sort() { public override void Sort() {
base.Sort(); base.Sort();
ArrayList sortedArray = new ArrayList(); if ((base.ReportSettings.SortColumnCollection != null)) {
try { if (base.ReportSettings.SortColumnCollection.Count > 0) {
ColumnCollection sortColumnCollection = base.ReportSettings.SortColumnCollection; this.BuildSortIndex (base.IndexList,
if (sortColumnCollection != null) { base.ReportSettings.SortColumnCollection);
if (sortColumnCollection.Count > 0) {
sortedArray = this.BuildSortIndex (sortColumnCollection);
base.IsSorted = true; base.IsSorted = true;
} else { // BaseListStrategy.CheckSortArray (base.IndexList,"TableStrategy - CheckSortArray");
sortedArray = BuildPlainIndex (sortColumnCollection); } else {
base.IsSorted = false; 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 {
public override void Bind() { public override void Bind() {
base.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)) { if ((base.ReportSettings.GroupColumnsCollection != null) && (base.ReportSettings.GroupColumnsCollection.Count > 0)) {
BuildGroup (); this.Group ();
Reset();
return;
} }
this.Sort (); if (base.ReportSettings.SortColumnCollection != null) {
this.Reset(); this.Sort ();
base.NotifyResetList(); }
Reset();
} }
public override void Fill(IItemRenderer item) { public override void Fill(IItemRenderer item) {
base.Fill(item); try {
if (current != null) { base.Fill(item);
try { if (current != null) {
BaseDataItem baseDataItem = item as BaseDataItem; BaseDataItem baseDataItem = item as BaseDataItem;
PropertyDescriptor p = this.listProperties.Find (baseDataItem.ColumnName,true); PropertyDescriptor p = this.listProperties.Find (baseDataItem.ColumnName,true);
@ -225,12 +237,50 @@ namespace SharpReportCore {
baseDataItem.DbValue = ""; baseDataItem.DbValue = "";
baseDataItem.DbValue = p.GetValue(this.current).ToString(); 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 #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 {
/// created by - Forstmeier Peter /// created by - Forstmeier Peter
/// created on - 23.10.2005 15:12:06 /// created on - 23.10.2005 15:12:06
/// </remarks> /// </remarks>
public class TableStrategy : BaseListStrategy,IDisposable { public class TableStrategy : BaseListStrategy {
DataTable table; DataTable table;
DataView view = new DataView(); DataView view = new DataView();
@ -32,44 +32,19 @@ namespace SharpReportCore {
public TableStrategy(DataTable table,ReportSettings reportSettings):base(reportSettings) { public TableStrategy(DataTable table,ReportSettings reportSettings):base(reportSettings) {
if (table == null) {
throw new ArgumentNullException("table");
}
this.table = 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 #region Building the Index list
// if we have no sorting, we build the indexlist as well, so we don't need to private void BuildSortIndex(SharpIndexCollection arrayList,ColumnCollection col) {
//check each time we reasd data if we have to go directly or by IndexList
private ArrayList BuildSortIndex(ColumnCollection col) {
ArrayList sortValues = new ArrayList(this.view.Count);
try { try {
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){ for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){
DataRowView rowItem = this.view[rowIndex]; DataRowView rowItem = this.view[rowIndex];
@ -88,171 +63,79 @@ namespace SharpReportCore {
values[criteriaIndex] = DBNull.Value; values[criteriaIndex] = DBNull.Value;
} }
} }
sortValues.Add(new SortComparer(col, rowIndex, values)); arrayList.Add(new SortComparer(col, rowIndex, values));
} }
} catch (Exception) { } catch (Exception) {
throw;
} }
sortValues.Sort();
return sortValues;
}
private ArrayList BuildPlainIndex(ColumnCollection col) { arrayList.Sort();
ArrayList sortValues = new ArrayList(this.view.Count); }
// 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 { try {
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){ for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){
object[] values = new object[1]; object[] values = new object[1];
// We insert only the RowNr as a dummy value // We insert only the RowNr as a dummy value
values[0] = rowIndex; values[0] = rowIndex;
sortValues.Add(new BaseComparer(col, rowIndex, values)); arrayList.Add(new BaseComparer(col, rowIndex, values));
} }
} catch (Exception) { } catch (Exception) {
throw ; 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 #endregion
#region Grouping #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(){ private void BuildGroup(){
try { try {
ArrayList groupedArray = new ArrayList(); SharpIndexCollection groupedArray = new SharpIndexCollection();
if (base.ReportSettings.GroupColumnsCollection != null) { if (base.ReportSettings.GroupColumnsCollection != null) {
if (base.ReportSettings.GroupColumnsCollection.Count > 0) { if (base.ReportSettings.GroupColumnsCollection.Count > 0) {
groupedArray = this.BuildGroupIndex (base.ReportSettings.GroupColumnsCollection); this.BuildSortIndex (groupedArray,base.ReportSettings.GroupColumnsCollection);
System.Console.WriteLine("\t1");
} else {
groupedArray = BuildPlainIndex (base.ReportSettings.GroupColumnsCollection);
} }
} }
base.IndexList.Clear(); base.MakeGroupedIndexList (groupedArray);
base.IndexList.AddRange (InsertGroupRows(groupedArray));
// System.Console.WriteLine("GroupedList with {0} elements",base.IndexList.Count);
if (base.IndexList == null){ /*
throw new NotSupportedException("Sortieren für die Liste nicht unterstützt."); 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) { } catch (Exception e) {
System.Console.WriteLine("BuildGroup {0}",e.Message); System.Console.WriteLine("BuildGroup {0}",e.Message);
throw; 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 #endregion
@ -260,12 +143,10 @@ namespace SharpReportCore {
public override void Bind() { public override void Bind() {
base.Bind(); base.Bind();
view = this.table.DefaultView;
if ((base.ReportSettings.GroupColumnsCollection != null) && (base.ReportSettings.GroupColumnsCollection.Count > 0)) { if ((base.ReportSettings.GroupColumnsCollection != null) && (base.ReportSettings.GroupColumnsCollection.Count > 0)) {
this.Group (); this.Group ();
Reset(); Reset();
base.NotifyResetList();
return; return;
} }
@ -273,47 +154,44 @@ namespace SharpReportCore {
this.Sort (); this.Sort ();
} }
Reset(); Reset();
base.NotifyResetList();
} }
public override void Sort () { public override void Sort () {
base.Sort(); base.Sort();
ArrayList sortedArray = new ArrayList(); if ((base.ReportSettings.SortColumnCollection != null)) {
try { if (base.ReportSettings.SortColumnCollection.Count > 0) {
if ((base.ReportSettings.SortColumnCollection != null)) { this.BuildSortIndex (base.IndexList,
if (base.ReportSettings.SortColumnCollection.Count > 0) { base.ReportSettings.SortColumnCollection);
SortColumn sc = (SortColumn)base.ReportSettings.SortColumnCollection[0];
base.IsSorted = true;
sortedArray = this.BuildSortIndex (base.ReportSettings.SortColumnCollection); } else {
base.IsSorted = true; this.BuildPlainIndex(base.IndexList,
} else { base.ReportSettings.SortColumnCollection);
sortedArray = BuildPlainIndex (base.ReportSettings.SortColumnCollection); base.IsSorted = false;
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) { public override void Fill (IItemRenderer item) {
try { try {
base.Fill(item); base.Fill(item);
BaseDataItem baseDataItem = item as BaseDataItem; if (this.row != null) {
if (baseDataItem != null) { BaseDataItem baseDataItem = item as BaseDataItem;
baseDataItem.DbValue = row[baseDataItem.ColumnName].ToString(); if (baseDataItem != null) {
baseDataItem.DbValue = row[baseDataItem.ColumnName].ToString();
}
} }
} catch (Exception ) {
} catch (System.NullReferenceException) {
} }
} }
@ -340,7 +218,7 @@ namespace SharpReportCore {
public override int Count { public override int Count {
get { get {
return this.table.Rows.Count; return this.IndexList.Count;
} }
} }
@ -356,31 +234,41 @@ namespace SharpReportCore {
GroupSeperator sep = bc as GroupSeperator; GroupSeperator sep = bc as GroupSeperator;
if (sep != null) { if (sep != null) {
base.NotifyGroupChange(this,sep); base.NotifyGroupChanging(this,sep);
} }
row = this.view[((BaseComparer)base.IndexList[value]).ListIndex]; row = this.view[((BaseComparer)base.IndexList[value]).ListIndex];
} }
} }
} }
#endregion
#region IDisposable
public override void Dispose(){
this.Dispose(true);
public override bool IsSorted { GC.SuppressFinalize(this);
get {
return (this.view.Sort.Length > 0);
}
} }
#endregion ~TableStrategy(){
Dispose(false);
}
#region IDisposable protected override void Dispose(bool disposing){
public void Dispose(){ try {
if (this.view != null) { if (disposing) {
this.view.Dispose(); 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 #endregion
} }

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

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

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

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

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

@ -31,7 +31,6 @@ namespace SharpReportCore {
private FontSingleton() { private FontSingleton() {
MessageBox.Show ("Should be commented out","FontSingleton");
hash = new Hashtable(); hash = new Hashtable();
} }
public Hashtable Hash { public Hashtable Hash {
@ -54,14 +53,6 @@ namespace SharpReportCore {
public Font GetFont(string family, float size, FontStyle style){ public Font GetFont(string family, float size, FontStyle style){
try { try {
string s=family+size.ToString()+((int)style).ToString(); 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)){ if(hash.Contains(s)){
return (Font)hash[s]; return (Font)hash[s];
@ -75,10 +66,6 @@ MessageBox.Show ("font from hashtable","GetFont");
} }
public override string ToString() {
return base.ToString() + " FontSingleton / ";
}
/// <summary> /// <summary>
/// Clear the Hashtable from all Fonts /// Clear the Hashtable from all Fonts
/// </summary> /// </summary>
@ -87,7 +74,7 @@ MessageBox.Show ("font from hashtable","GetFont");
/// ///
/// </remarks> /// </remarks>
public void Dispose() { 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 {
/// Convert any possible string-Value of a given enumeration /// Convert any possible string-Value of a given enumeration
/// type to its internal representation. /// type to its internal representation.
public static object StringToEnum( Type t, string value ) { public static object StringToEnum( Type type, string value ) {
foreach ( FieldInfo fi in t.GetFields() ) foreach ( FieldInfo fi in type.GetFields() )
if ( fi.Name == value ) if ( fi.Name == value )
return fi.GetValue( null ); // We use null because return fi.GetValue( null ); // We use null because
throw new Exception( string.Format(CultureInfo.CurrentCulture, throw new Exception( string.Format(CultureInfo.CurrentCulture,
"Can't convert {0} to {1}", "Can't convert {0} to {1}",
value, value,
t.ToString()) ); type.ToString()) );
} }
} }
} }

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

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

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

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

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

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

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

@ -20,18 +20,18 @@ namespace SharpReportCore
/// <summary> /// <summary>
/// Measure the Size of the currnet Item /// Measure the Size of the currnet Item
/// </summary> /// </summary>
SizeF MeasureItem(System.Drawing.Graphics e); SizeF MeasureItem(System.Drawing.Graphics graphics);
/// <summary> /// <summary>
/// Format the current (TextBased) /// Format the current (TextBased)
/// </summary> /// </summary>
/// <param name="e"></param> /// <param name="e"></param>
/// <returns></returns> /// <returns></returns>
void FormatItem(System.Drawing.Graphics e ); void FormatItem(System.Drawing.Graphics graphics );
/// <summary> /// <summary>
/// Print them out to .... /// Print them out to ....
/// </summary> /// </summary>
/// <param name="e"></param> /// <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 {
} }
public RenderDataReport(ReportModel model,DataManager dataManager):base (model){ public RenderDataReport(ReportModel model,DataManager dataManager):base (model){
// System.Console.WriteLine("RenderDataReport".ToUpper());
this.dataManager = dataManager; 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 #region overrides

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

@ -80,7 +80,7 @@ namespace SharpReportCore {
} }
public void ReportDocumentPrintPage (object sender, PrintPageEventArgs e) { public void ReportDocumentPrintPage (object sender, PrintPageEventArgs e) {
// System.Console.WriteLine("\tReportDocument PrintPage"); System.Console.WriteLine("\tReportDocument PrintPage");
pageNr ++; pageNr ++;
ReportPageEventArgs pea = new ReportPageEventArgs (e,pageNr,false,new PointF (0,0)); 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 {
get { get {
return sectionCollection; return sectionCollection;
} }
set {
sectionCollection = value;
}
} }
#endregion #endregion
@ -136,16 +133,23 @@ namespace SharpReportCore {
} }
protected virtual void Dispose(bool disposing){ protected virtual void Dispose(bool disposing){
if (disposing) { try {
// Free other state (managed objects). if (disposing) {
if (this.reportSettings != null) { // Free other state (managed objects).
this.reportSettings.Dispose(); if (this.reportSettings != null) {
this.reportSettings = null; this.reportSettings.Dispose();
this.reportSettings = null;
}
if (this.sectionCollection != null) {
this.sectionCollection.Clear();
this.sectionCollection = null;
}
} }
} } finally {
// Free your own state (unmanaged objects). // Free your own state (unmanaged objects).
// Set large fields to null. // Set large fields to null.
}
} }
#endregion #endregion
} }

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

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

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

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

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

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

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

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

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

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

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

@ -10,6 +10,7 @@ using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Reflection;
using ICSharpCode.NRefactory.Parser; using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.VB; using ICSharpCode.NRefactory.Parser.VB;
@ -27,6 +28,8 @@ namespace ICSharpCode.NRefactory.Parser
// MyBase.New() and MyClass.New() calls inside the constructor are converted to :base() and :this() // MyBase.New() and MyClass.New() calls inside the constructor are converted to :base() and :this()
// Add Public Modifier to methods and properties // Add Public Modifier to methods and properties
// Override Finalize => Destructor // Override Finalize => Destructor
// IIF(cond, true, false) => ConditionalExpression
// Built-in methods => Prefix with class name
// The following conversions should be implemented in the future: // The following conversions should be implemented in the future:
// Function A() \n A = SomeValue \n End Function -> convert to return statement // Function A() \n A = SomeValue \n End Function -> convert to return statement
@ -198,5 +201,91 @@ namespace ICSharpCode.NRefactory.Parser
return base.Visit(propertyDeclaration, data); 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
"\tDead();\n" + "\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
protected void InitTargetFramework(string defaultTargets, string extendedTargets) protected void InitTargetFramework(string defaultTargets, string extendedTargets)
{ {
const string TargetFrameworkProperty = "TargetFrameworkVersion"; const string TargetFrameworkProperty = "TargetFrameworkVersion";
debugInfoBinding = helper.BindStringEnum("targetFrameworkComboBox", TargetFrameworkProperty, ConfigurationGuiBinding targetFrameworkBinding;
"", targetFrameworkBinding = helper.BindStringEnum("targetFrameworkComboBox", TargetFrameworkProperty,
new StringPair("", "Default (.NET 2.0)"), "",
new StringPair("v1.0", ".NET 1.0"), new StringPair("", "Default (.NET 2.0)"),
new StringPair("v1.1", ".NET 1.1"), new StringPair("v1.0", ".NET 1.0"),
new StringPair("v2.0", ".NET 2.0"), new StringPair("v1.1", ".NET 1.1"),
new StringPair("Mono v1.1", "Mono 1.1"), new StringPair("v2.0", ".NET 2.0"),
new StringPair("Mono v2.0", "Mono 2.0")); new StringPair("Mono v1.1", "Mono 1.1"),
debugInfoBinding.CreateLocationButton("targetFrameworkLabel"); new StringPair("Mono v2.0", "Mono 2.0"));
targetFrameworkBinding.CreateLocationButton("targetFrameworkLabel");
helper.Saved += delegate { helper.Saved += delegate {
// Test if SharpDevelop-Build extensions are needed // Test if SharpDevelop-Build extensions are needed
MSBuildProject project = helper.Project; MSBuildProject project = helper.Project;

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

@ -589,7 +589,12 @@ namespace ICSharpCode.SharpDevelop.Gui
if (discoveryClientProtocol != null) { if (discoveryClientProtocol != null) {
try { try {
discoveryClientProtocol.Abort(); 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.Dispose();
} }
discoveryClientProtocol = new WebServiceDiscoveryClientProtocol(); discoveryClientProtocol = new WebServiceDiscoveryClientProtocol();

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

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

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

@ -47,6 +47,12 @@ namespace ICSharpCode.SharpDevelop.Project
} }
} }
public AbstractProjectBrowserTreeNode RootNode {
get {
return treeView.Nodes[0] as AbstractProjectBrowserTreeNode;
}
}
public ExtTreeView TreeView { public ExtTreeView TreeView {
get { get {
return treeView; return treeView;
@ -140,7 +146,7 @@ namespace ICSharpCode.SharpDevelop.Project
return FindFileNode(treeView.Nodes, fileName); 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 // that we can select it again on opening a folder
string lastSelectionTarget; string lastSelectionTarget;

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

@ -20,6 +20,9 @@ namespace ICSharpCode.SharpDevelop.Project
static ProjectBrowserPad instance; static ProjectBrowserPad instance;
public static ProjectBrowserPad Instance { public static ProjectBrowserPad Instance {
get { get {
if (instance == null) {
WorkbenchSingleton.Workbench.GetPad(typeof(ProjectBrowserPad)).CreatePad();
}
return instance; return instance;
} }
} }
@ -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 { public ProjectBrowserControl ProjectBrowserControl {
get { get {
return projectBrowserPanel.ProjectBrowserControl; return projectBrowserPanel.ProjectBrowserControl;

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

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

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

@ -416,6 +416,11 @@ namespace ICSharpCode.SharpDevelop.Project
} }
base.Initialize(); base.Initialize();
} }
protected void BaseInitialize()
{
base.Initialize();
}
void AddParentFolder(string virtualName, string relativeDirectoryPath, Dictionary<string, DirectoryNode> directoryNodeList) 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
} }
} }
public string FileName { public virtual string FileName {
get { get {
return fileName; return fileName;
} }

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

@ -269,15 +269,20 @@ namespace ICSharpCode.SharpDevelop.Gui
StatusBarService.RedrawStatusbar(); 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) public Properties GetStoredMemento(IViewContent content)
{ {
if (content != null && content.FileName != null) { if (content != null && content.FileName != null) {
string directory = Path.Combine(PropertyService.ConfigDirectory, "temp"); string fullFileName = GetMementoFileName(content.FileName);
if (!Directory.Exists(directory)) {
Directory.CreateDirectory(directory);
}
string fileName = content.FileName.Substring(3).Replace('/', '.').Replace('\\', '.').Replace(Path.DirectorySeparatorChar, '.');
string fullFileName = Path.Combine(directory, fileName);
// check the file name length because it could be more than the maximum length of a file name // 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)) { if (FileUtility.IsValidFileName(fullFileName) && File.Exists(fullFileName)) {
@ -299,8 +304,7 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
Properties memento = ((IMementoCapable)content).CreateMemento(); Properties memento = ((IMementoCapable)content).CreateMemento();
string fileName = content.FileName.Substring(3).Replace('/', '.').Replace('\\', '.').Replace(Path.DirectorySeparatorChar, '.'); string fullFileName = GetMementoFileName(content.FileName);
string fullFileName = Path.Combine(directory, fileName);
if (FileUtility.IsValidFileName(fullFileName)) { if (FileUtility.IsValidFileName(fullFileName)) {
FileUtility.ObservedSave(new NamedFileOperationDelegate(memento.Save), fullFileName, FileErrorPolicy.Inform); FileUtility.ObservedSave(new NamedFileOperationDelegate(memento.Save), fullFileName, FileErrorPolicy.Inform);
@ -559,7 +563,12 @@ namespace ICSharpCode.SharpDevelop.Gui
foreach (string file in files) { foreach (string file in files) {
if (File.Exists(file)) { 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
protected List<ProjectItem> items = new List<ProjectItem>(); protected List<ProjectItem> items = new List<ProjectItem>();
protected List<string> imports = new List<string>(); protected List<string> imports = new List<string>();
readonly List<ProjectSection> projectSections = new List<ProjectSection>();
protected string fileName; string fileName;
protected string language; string language;
[Browsable(false)] [Browsable(false)]
public Dictionary<string, PropertyGroup> Configurations { public Dictionary<string, PropertyGroup> Configurations {
@ -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> /// <summary>
/// Gets the list of MSBuild Imports. /// Gets the list of MSBuild Imports.
/// </summary> /// </summary>
@ -172,7 +183,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (fileName == null) { if (fileName == null) {
return String.Empty; return String.Empty;
} }
return Path.GetFullPath(fileName); return fileName;
} }
set { set {
fileName = value; fileName = value;
@ -188,7 +199,7 @@ namespace ICSharpCode.SharpDevelop.Project
if (fileName == null) { if (fileName == null) {
return String.Empty; return String.Empty;
} }
directoryName = Path.GetFullPath(Path.GetDirectoryName(fileName)); directoryName = Path.GetDirectoryName(fileName);
} }
return directoryName; return directoryName;
} }

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

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

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

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

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

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

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

@ -55,17 +55,17 @@ namespace ICSharpCode.SharpDevelop.Project
} }
static Regex sectionPattern = new Regex("\\s*(?<Key>.*\\S)\\s*=\\s*(?<Value>.*\\S)\\s*", RegexOptions.Compiled); 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"); 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"); 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); ProjectSection newFolder = new ProjectSection(name, sectionType);
while (true) { while (true) {

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

@ -271,23 +271,14 @@ namespace ICSharpCode.SharpDevelop.Project
projectSection.AppendLine(); projectSection.AppendLine();
if (currentFolder is IProject) { if (currentFolder is IProject) {
// IProject project = (IProject)currentFolder; IProject project = (IProject)currentFolder;
// currently nothing to do. (I don't know if projects may have sections). // Web projects can have sections
SaveProjectSections(project.ProjectSections, projectSection);
} else if (currentFolder is SolutionFolder) { } else if (currentFolder is SolutionFolder) {
SolutionFolder folder = (SolutionFolder)currentFolder; SolutionFolder folder = (SolutionFolder)currentFolder;
foreach (ProjectSection section in folder.Sections) { SaveProjectSections(folder.Sections, projectSection);
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);
}
foreach (ISolutionFolder subFolder in folder.Folders) { foreach (ISolutionFolder subFolder in folder.Folders) {
stack.Push(subFolder); stack.Push(subFolder);
@ -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 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); static Regex projectLinePattern = new Regex("Project\\(\"(?<ProjectGuid>.*)\"\\)\\s+=\\s+\"(?<Title>.*)\",\\s*\"(?<Location>.*)\",\\s*\"(?<Guid>.*)\"", RegexOptions.Compiled);
@ -432,14 +439,19 @@ namespace ICSharpCode.SharpDevelop.Project
if (match.Success) { if (match.Success) {
string projectGuid = match.Result("${ProjectGuid}"); string projectGuid = match.Result("${ProjectGuid}");
string title = match.Result("${Title}"); string title = match.Result("${Title}");
string location = Path.Combine(solutionDirectory, match.Result("${Location}")); string location = match.Result("${Location}");
string guid = match.Result("${Guid}"); string guid = match.Result("${Guid}");
if (!FileUtility.IsUrl(location)) {
location = Path.Combine(solutionDirectory, location);
}
if (projectGuid == FolderGuid) { if (projectGuid == FolderGuid) {
SolutionFolder newFolder = SolutionFolder.ReadFolder(sr, title, location, guid); SolutionFolder newFolder = SolutionFolder.ReadFolder(sr, title, location, guid);
newSolution.AddFolder(newFolder); newSolution.AddFolder(newFolder);
} else { } else {
IProject newProject = LanguageBindingService.LoadProject(location, title, projectGuid); IProject newProject = LanguageBindingService.LoadProject(location, title, projectGuid);
ReadProjectSections(sr, newProject.ProjectSections);
newProject.IdGuid = guid; newProject.IdGuid = guid;
newSolution.AddFolder(newProject); newSolution.AddFolder(newProject);
} }

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

@ -117,9 +117,20 @@ namespace ICSharpCode.SharpDevelop.Project
#endregion #endregion
static Regex sectionHeaderPattern = new Regex("\\s*ProjectSection\\((?<Name>.*)\\)\\s*=\\s*(?<Type>.*)", RegexOptions.Compiled); 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); 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) { while (true) {
string line = sr.ReadLine(); string line = sr.ReadLine();
if (line == null || line.Trim() == "EndProject") { if (line == null || line.Trim() == "EndProject") {
@ -127,11 +138,9 @@ namespace ICSharpCode.SharpDevelop.Project
} }
Match match = sectionHeaderPattern.Match(line); Match match = sectionHeaderPattern.Match(line);
if (match.Success) { 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
} }
} }
public UnknownProject(string fileName) public UnknownProject(string fileName, string title)
{ {
Name = Path.GetFileNameWithoutExtension(fileName); Name = title;
FileName = fileName; FileName = fileName;
IdGuid = "{" + Guid.NewGuid().ToString() + "}"; IdGuid = "{" + Guid.NewGuid().ToString() + "}";
} }

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

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

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

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

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

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

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

@ -103,6 +103,10 @@ namespace ICSharpCode.Core
return result; return result;
} }
public static bool IsUrl(string path)
{
return path.IndexOf(':') >= 2;
}
/// <summary> /// <summary>
/// Converts a given absolute path and a given base path to a path that leads /// Converts a given absolute path and a given base path to a path that leads
@ -110,8 +114,15 @@ namespace ICSharpCode.Core
/// </summary> /// </summary>
public static string GetRelativePath(string baseDirectoryPath, string absPath) public static string GetRelativePath(string baseDirectoryPath, string absPath)
{ {
baseDirectoryPath = Path.GetFullPath(baseDirectoryPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)); if (IsUrl(absPath) || IsUrl(baseDirectoryPath)){
absPath = Path.GetFullPath(absPath); 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[] bPath = baseDirectoryPath.Split(separators);
string[] aPath = absPath.Split(separators); string[] aPath = absPath.Split(separators);
@ -265,6 +276,8 @@ namespace ICSharpCode.Core
} }
} }
public static int MaxPathLength = 260;
/// <summary> /// <summary>
/// This method checks the file fileName if it is valid. /// This method checks the file fileName if it is valid.
/// </summary> /// </summary>
@ -273,7 +286,7 @@ namespace ICSharpCode.Core
// Fixme: 260 is the hardcoded maximal length for a path on my Windows XP system // 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. // 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; return false;
} }

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

@ -56,6 +56,9 @@ namespace ICSharpCode.Core.Tests.AddInTreeTests.Tests
Assert.AreEqual(@"blub", FileUtility.GetRelativePath(@"C:\hello\.\..\A", @"C:\.\a\blub")); 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", @"C:\.\blub\.\..\.\a\.\blub"));
Assert.AreEqual(@"..\a\blub", FileUtility.GetRelativePath(@"C:\.\.\.\.\heLLo\A\..", @"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] [Test]

Loading…
Cancel
Save