diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj index fdbf725c03..ae7d1cb23e 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj @@ -72,9 +72,19 @@ + + + + + + + + + + @@ -88,6 +98,7 @@ + @@ -120,18 +131,23 @@ + + + + + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs index b5439b7d81..d70eddcc96 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs @@ -37,23 +37,38 @@ namespace ICSharpCode.Reporting.Arrange throw new ArgumentNullException("exportColumn"); var container = exportColumn as IExportContainer; if ((container != null) && (container.ExportedItems.Count > 0)) { - BiggestRectangle = Rectangle.Empty; - foreach (var item in container.ExportedItems) { - if (item.DesiredSize.Height > BiggestRectangle.Size.Height) { - BiggestRectangle = new Rectangle(new Point(container.Location.X + item.Location.X, - container.Location.Y + item.Location.Y) - ,item.DesiredSize); + + FindBiggestRectangle(container); + var resizeable = from resize in container.ExportedItems + where ((resize.CanGrow == true)) + select resize; + + + if (resizeable.Count() > 0) { + + + + + if (!BiggestRectangle.IsEmpty) { + var containerRectangle = new Rectangle(container.Location,container.Size); + var desiredRectangle = Rectangle.Union(containerRectangle,BiggestRectangle); + container.DesiredSize = new Size(container.Size.Width,desiredRectangle.Size.Height + 5); } } - if (!BiggestRectangle.IsEmpty) { - var containerRectangle = new Rectangle(container.Location,container.Size); - var desiredRectangle = Rectangle.Union(containerRectangle,BiggestRectangle); - container.DesiredSize = new Size(container.Size.Width,desiredRectangle.Size.Height + 5); - } } } + private void FindBiggestRectangle (IExportContainer container) { + BiggestRectangle = Rectangle.Empty; + foreach (var item in container.ExportedItems) { + if (item.DesiredSize.Height > BiggestRectangle.Size.Height) { + BiggestRectangle = new Rectangle(new Point(container.Location.X + item.Location.X, + container.Location.Y + item.Location.Y) + ,item.DesiredSize); + } + } + } public Rectangle BiggestRectangle {get; private set;} } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/AbstractColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/AbstractColumn.cs new file mode 100644 index 0000000000..9702ffdf86 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/AbstractColumn.cs @@ -0,0 +1,63 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 21.05.2013 + * Time: 20:16 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Xml.Serialization; + +namespace ICSharpCode.Reporting.BaseClasses +{ + /// + /// Description of AbstractColumn. + /// + public class AbstractColumn + { + private string columnName; + private Type dataType; + private string dataTypeName; + + public AbstractColumn() { + this.dataType = typeof(System.String); + this.columnName = string.Empty; + } + +// public AbstractColumn(string columnName){ +// this.columnName = columnName; +// this.dataType = typeof(System.String); +// } + + public AbstractColumn(string columnName, Type dataType){ + this.columnName = columnName; + this.dataType = dataType; + } + + public string ColumnName {get;set;} + + + + public string DataTypeName { + get { + return this.dataType.ToString(); + } + set { + dataTypeName = value; + this.dataType = Type.GetType(dataTypeName,true,true); + } + } + + [XmlIgnoreAttribute] + public Type DataType { + get { + return dataType; + } + set { + dataType = value; + } + } + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs index 3131ca3615..3feacafeba 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs @@ -111,5 +111,9 @@ namespace ICSharpCode.Reporting.BaseClasses throw new NotImplementedException(); } } + + public bool CanGrow {get;set;} + + public bool CanShrink {get;set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs new file mode 100644 index 0000000000..ca6ce7e5aa --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs @@ -0,0 +1,53 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 21.05.2013 + * Time: 20:20 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.ComponentModel; + +namespace ICSharpCode.Reporting.BaseClasses +{ + /// + /// Description of SortColumn. + /// + public class SortColumn : AbstractColumn { + + private ListSortDirection sortDirection = ListSortDirection.Ascending; + private bool caseSensitive; + + + public SortColumn():this(String.Empty,ListSortDirection.Ascending,typeof(System.String),false) + { + } + + public SortColumn(string columnName,Type type ):this(columnName,ListSortDirection.Ascending,type,false) + { + } + + + public SortColumn(string columnName,ListSortDirection sortDirection) + :this(columnName,sortDirection,typeof(System.String),false){ + } + + + public SortColumn(string columnName, ListSortDirection sortDirection, Type type,bool caseSensitive ):base (columnName,type) + { + this.caseSensitive = caseSensitive; + this.sortDirection = sortDirection; + } + + #region properties + + public ListSortDirection SortDirection {get;set;} + + + public bool CaseSensitive {get;private set;} + + + #endregion + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs new file mode 100644 index 0000000000..42ea5cecff --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs @@ -0,0 +1,92 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 21.05.2013 + * Time: 20:03 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; + +using ICSharpCode.Reporting.BaseClasses; + +namespace ICSharpCode.Reporting +{ + /// + /// Description of Collections. + /// + + public class ColumnCollection: Collection{ + + public ColumnCollection() + { + } + + public AbstractColumn Find (string columnName) + { + if (String.IsNullOrEmpty(columnName)) { + throw new ArgumentNullException("columnName"); + } + + return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,true,CultureInfo.InvariantCulture)); + } + + + public void AddRange (IEnumerable items) + { + foreach (AbstractColumn item in items){ + this.Add(item); + } + } + + + /// + /// The Culture is used for direct String Comparison + /// + + public static CultureInfo Culture + { + get { return CultureInfo.CurrentCulture;} + } + } + + + + public class SortColumnCollection: ColumnCollection + { + public SortColumnCollection() + { + } + +// public new AbstractColumn Find (string columnName) +// { +// if (String.IsNullOrEmpty(columnName)) { +// throw new ArgumentNullException("columnName"); +// } +// +// return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,true,CultureInfo.InvariantCulture)); +// } + + + public void AddRange (IEnumerable items) + { + foreach (SortColumn item in items){ + this.Add(item); + } + } + + + /// + /// The Culture is used for direct String Comparison + /// + +// public new static CultureInfo Culture +// { +// get { return CultureInfo.CurrentCulture;} +// } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs new file mode 100644 index 0000000000..afbd22e3e6 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs @@ -0,0 +1,89 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 21.05.2013 + * Time: 20:09 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections; +using System.Collections.ObjectModel; +using System.ComponentModel; + +using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.DataSource; +using ICSharpCode.Reporting.Interfaces.Data; +using ICSharpCode.Reporting.Items; + +namespace ICSharpCode.Reporting.DataManager.Listhandling +{ + /// + /// Description of CollectionHandling. + /// + internal class CollectionSource:IDataViewHandling + { + + private PropertyDescriptorCollection listProperties; + private DataCollection baseList; + private ReportSettings reportSettings; + + + public CollectionSource(IList list,ReportSettings reportSettings) + { + + if (list.Count > 0) { +// firstItem = list[0]; + + var itemType = list[0].GetType(); + this.baseList = new DataCollection (itemType); + this.baseList.AddRange(list); + } + this.reportSettings = reportSettings; + this.listProperties = this.baseList.GetItemProperties(null); + IndexList = new IndexList(); + } + + public int Count + { + get { + return this.baseList.Count; + } + } + + public Collection AvailableFields { + get { +// base.AvailableFields.Clear(); + var av = new Collection(); + foreach (PropertyDescriptor p in this.listProperties){ + av.Add (new AbstractColumn(p.Name,p.PropertyType)); + } + return av; + } + } + + public object Current { + get { + throw new NotImplementedException(); + } + } + + public void Sort() + { + throw new NotImplementedException(); + } + + public bool MoveNext() + { + throw new NotImplementedException(); + } + + public void Reset() + { + throw new NotImplementedException(); + } + + public IndexList IndexList {get; private set;} + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/IndexList.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/IndexList.cs new file mode 100644 index 0000000000..4c39eb05dc --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/IndexList.cs @@ -0,0 +1,27 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 21.05.2013 + * Time: 20:54 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.Generic; +using ICSharpCode.Reporting.DataSource.Comparer; + +namespace ICSharpCode.Reporting.DataManager.Listhandling +{ + /// + /// Description of IndexList. + /// + public class IndexList :List + { + + public IndexList() + { + } + + public int CurrentPosition {get;set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/BaseComparer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/BaseComparer.cs new file mode 100644 index 0000000000..8413c8aeda --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/BaseComparer.cs @@ -0,0 +1,94 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 21.05.2013 + * Time: 20:57 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; + +namespace ICSharpCode.Reporting.DataSource.Comparer +{ + /// + /// Description of BaseComparer. + /// + public class BaseComparer : IComparable { + + private int listIndex; + private object[] objectArray; + + ColumnCollection columnCollection; + /// + /// Default constructor - initializes all fields to default values + /// + + public BaseComparer(ColumnCollection columnCollection , int listIndex, object[] values) { + this.columnCollection = columnCollection; + this.listIndex = listIndex; + this.objectArray = values; + } + + /// + /// Interface method from IComparable + /// + /// + /// Interface method from IComparable + /// + /// + /// a + public virtual int CompareTo(object obj) { + return 0; + } + + /// + /// Ausgeben der Werte als Pseudo-CSV + /// + public override string ToString() + { + System.Text.StringBuilder builder = new System.Text.StringBuilder(); + builder.AppendFormat("{0};", this.listIndex); + foreach (object value in objectArray) + { + if (value == null || value == DBNull.Value) + { + builder.AppendFormat(""); + } + else if (value.GetType() == typeof(string)) + { + builder.AppendFormat("\"{0}\"", (string)value); + } + else if (value is IFormattable) + { + builder.AppendFormat("{0}", ((IFormattable)value).ToString("g", System.Globalization.CultureInfo.InvariantCulture)); + } + else + { + builder.AppendFormat("[{0}]", value.ToString()); + } + builder.Append(';'); + } + return builder.ToString(); + } + + + public int ListIndex { + get { + return listIndex; + } + } + + public object[] ObjectArray { + get { + return objectArray; + } + } + + + public ColumnCollection ColumnCollection { + get { + return columnCollection; + } + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/DataCollection.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/DataCollection.cs new file mode 100644 index 0000000000..130a7a09ed --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/DataCollection.cs @@ -0,0 +1,203 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 20.05.2013 + * Time: 17:55 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Reflection; + +namespace ICSharpCode.Reporting.DataSource +{ + /// + /// Description of DataCollection. + /// + internal class DataCollection : IList,ITypedList + { + Collection list = new Collection(); + Type elementType; + + public DataCollection(Type elementType) + { + this.elementType = elementType; + } + + public T this[int index] + { + get { + return list[index]; + } + set { + T oldValue = list[index]; + if (!object.Equals(oldValue, value)) { + list[index] = value; + } + } + } + + public int Count + { + [DebuggerStepThrough] + get { + return list.Count; + } + } + + public bool IsReadOnly + { + get { + return false; + } + } + + public int IndexOf(T item) + { + return list.IndexOf(item); + } + + public void Insert(int index, T item) + { + list.Insert(index, item); + } + + public void RemoveAt(int index) + { + list.RemoveAt(index); + } + + public void Add(T item) + { + list.Add(item); + } + + + public void AddRange(IList range) + { + foreach(T t in range) { + Add(t); + } + } + + + public void Clear(){ + list = new Collection(); + } + + public bool Contains(T item) + { + return list.Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + list.CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (list.Remove(item)) { + return true; + } + return false; + } + + #region ITypedList Member + + public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors){ + if (listAccessors != null && listAccessors.Length > 0){ + Type t = this.elementType; + + for(int i = 0; i < listAccessors.Length; i++){ + PropertyDescriptor pd = listAccessors[i]; + t = (Type) PropertyTypeHash.Instance[t, pd.Name]; + } + // if t is null an empty list will be generated + return ExtendedTypeDescriptor.GetProperties(t); + } + return ExtendedTypeDescriptor.GetProperties(elementType); + } + + + public string GetListName(PropertyDescriptor[] listAccessors){ + return elementType.Name; + } + + public static Type GetElementType(IList list, Type parentType, string propertyName) + { + DataCollection al = null; + object element = null; + al = CheckForArrayList(list); + if (al == null) + { + if (list.Count > 0) + { + element = list[0]; + } + } + if (al == null && element == null) + { + PropertyInfo pi = parentType.GetProperty(propertyName); + if (pi != null) + { + object parentObject = null; + try + { + parentObject = Activator.CreateInstance(parentType); + } + catch(Exception) {} + if (parentObject != null) + { + list = pi.GetValue(parentObject, null) as IList; + al = CheckForArrayList(list); + } + } + } + if (al != null) + { + return al.elementType; + } + else if (element != null) + { + return element.GetType(); + } + return null; + } + + private static DataCollection 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 DataCollection; + } + #endregion + + + [DebuggerStepThrough] + public IEnumerator GetEnumerator() + { + return list.GetEnumerator(); + } + + [DebuggerStepThrough] + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + { + return list.GetEnumerator(); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedPropertyDescriptor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedPropertyDescriptor.cs new file mode 100644 index 0000000000..80d14fd170 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedPropertyDescriptor.cs @@ -0,0 +1,95 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 20.05.2013 + * Time: 18:05 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections; +using System.ComponentModel; +using System.Reflection; + +namespace ICSharpCode.Reporting.DataSource +{ + /// + /// Description of ExtendedPropertyDescriptor. + /// + internal class ExtendedPropertyDescriptor : PropertyDescriptor + { + + Type componentType; + Type propertyType; + PropertyInfo prop; + + public ExtendedPropertyDescriptor (string name, Type componentType, Type propertyType) + : base (name, null) + { + this.componentType = componentType; + this.propertyType = propertyType; + } + + + public override object GetValue (object component) + { + if (!componentType.IsAssignableFrom(component.GetType())){ + return null; + } + + if (prop == null) { + prop = componentType.GetProperty (Name); + } + + object obj = prop.GetValue (component, null); + if (obj != null) { + if (obj is IList){ + PropertyTypeHash.Instance[componentType, Name] = DataCollection.GetElementType((IList)obj, componentType, Name); + } + } + return obj; + } + + + public override void SetValue(object component, object value) + { + if (IsReadOnly){ + return; + } + if (prop == null){ + prop = componentType.GetProperty (Name); + } + prop.SetValue (component, value, null); + } + + public override void ResetValue(object component) + { + return; + } + + public override bool CanResetValue(object component) + { + return false; + } + + public override bool ShouldSerializeValue(object component) + { + return false; + } + + public override Type ComponentType + { + get { return componentType; } + } + + public override bool IsReadOnly + { + get { return false; } + } + + public override Type PropertyType + { + get { return propertyType; } + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedTypeDescriptor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedTypeDescriptor.cs new file mode 100644 index 0000000000..5a19164ba3 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedTypeDescriptor.cs @@ -0,0 +1,65 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 20.05.2013 + * Time: 17:59 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections; +using System.ComponentModel; +using System.Reflection; + +namespace ICSharpCode.Reporting.DataSource +{ + /// + /// Description of ExtendedTypeDescriptor. + /// + internal class ExtendedTypeDescriptor + { + private static Hashtable collections = new Hashtable(); + + private static bool IsAllowedProperty(string name) + { + return true; // alle erlaubt + } + + + public static PropertyDescriptorCollection GetProperties(Type memberType) + { + if (memberType == null) + return PropertyDescriptorCollection.Empty; + + PropertyDescriptorCollection pdc; + if ((pdc = (PropertyDescriptorCollection) collections[memberType]) != null) + return (pdc); + + PropertyInfo[] allProps = memberType.GetProperties(); + int l = allProps.Length; + for (int i = 0; i < allProps.Length; i++) + { + PropertyInfo pi = allProps[i]; + if (!IsAllowedProperty(pi.Name)) + { + allProps[i] = null; + l--; + } + } + + PropertyDescriptor[] descriptors = new PropertyDescriptor[l]; + + int j = 0; + foreach(PropertyInfo pinfo in allProps) + { + if (pinfo != null) + { + descriptors[j++] = new ExtendedPropertyDescriptor(pinfo.Name, memberType, pinfo.PropertyType); + } + } + PropertyDescriptorCollection result = new PropertyDescriptorCollection(descriptors); + collections.Add(memberType, result); + return result; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyTypeHash.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyTypeHash.cs new file mode 100644 index 0000000000..e0369d5293 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyTypeHash.cs @@ -0,0 +1,53 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 20.05.2013 + * Time: 18:02 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections; + +namespace ICSharpCode.Reporting.DataSource +{ + /// + /// Description of PropertyTypeHash. + /// + internal class PropertyTypeHash + { + static PropertyTypeHash instance = new PropertyTypeHash(); + + static public PropertyTypeHash Instance + { + get { return instance; } + } + + Hashtable types = new Hashtable(); + + private static string MakeIndex(Type t, string name) + { + return t.FullName + '.' + name; + } + + public object this[Type type, string fieldName] + { + get + { + return types[MakeIndex(type, fieldName)]; + } + set + { + if (value == null) + return; + string key = MakeIndex(type, fieldName); + if (!types.Contains(key)) + types.Add(key, value); + } + } + + private PropertyTypeHash() + { + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataViewHandling.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataViewHandling.cs new file mode 100644 index 0000000000..3c2e3e2b3a --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataViewHandling.cs @@ -0,0 +1,49 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 21.05.2013 + * Time: 20:35 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections; +using System.Collections.ObjectModel; + +using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.DataManager.Listhandling; + +namespace ICSharpCode.Reporting.Interfaces.Data +{ + /// + /// Description of IDataViewHandling. + /// + public interface IDataViewHandling:IEnumerator{ + + void Sort (); + +// void Group(); + +// void Bind(); + +// void Fill (int position,ReportItemCollection collection); + + //rausnehmen +// void Fill (IDataItem item); + + IndexList IndexList {get;} + +// object CurrentFromPosition(int pos); + +// CurrentItemsCollection FillDataRow(); +// CurrentItemsCollection FillDataRow(int pos); + // + Collection AvailableFields {get;} + + int Count {get;} + +// int CurrentPosition {get;set;} + +// IExpressionEvaluatorFacade ExpressionEvaluator {get;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IPrintableObject.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IPrintableObject.cs index 01dd059b10..ffb288029e 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IPrintableObject.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IPrintableObject.cs @@ -23,12 +23,14 @@ namespace ICSharpCode.Reporting.Interfaces Color ForeColor {get;set;} Color BackColor {get;set;} Color FrameColor{get;set;} + bool CanGrow {get;set;} } public interface IPrintableObject:IReportObject { IExportColumn CreateExportColumn(); IMeasurementStrategy MeasurementStrategy (); + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs index 51f35363ec..cba4d2445f 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs @@ -31,7 +31,5 @@ public class BaseSection:ReportContainer,IReportContainer } #endregion - - } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs index e64e191835..a885d4a5ae 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs @@ -23,7 +23,6 @@ namespace ICSharpCode.Reporting.Items { Font Font {get;set;} string Text {get;set;} - bool CanGrow {get;set;} } public class BaseTextItem:PrintableItem,ITextItem @@ -38,8 +37,6 @@ namespace ICSharpCode.Reporting.Items public string Text {get;set;} - public bool CanGrow {get;set;} - public override IExportColumn CreateExportColumn() { var ex = new ExportText(); @@ -51,6 +48,7 @@ namespace ICSharpCode.Reporting.Items ex.Size = Size; ex.Font = Font; ex.Text = Text; + ex.CanGrow = CanGrow; return ex; } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/PrintableItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/PrintableItem.cs index 093182ad62..baa295bd4b 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/PrintableItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/PrintableItem.cs @@ -39,5 +39,7 @@ namespace ICSharpCode.Reporting.Items public Color FrameColor {get;set;} + public bool CanGrow {get;set;} + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs index 2c6d5afce5..298483d479 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs @@ -39,7 +39,8 @@ namespace ICSharpCode.Reporting.Items return new ExportContainer(){ Name = this.Name, Size = this.Size, - Location = this.Location + Location = this.Location, + CanGrow = this.CanGrow, }; } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportColumn.cs index 209d22b815..0349793fe5 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportColumn.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportColumn.cs @@ -43,5 +43,7 @@ namespace ICSharpCode.Reporting.PageBuilder.ExportColumns public IExportColumn Parent {get;set;} + public bool CanGrow {get;set;} + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj index f01783fab3..05ee4ca4ff 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj @@ -58,6 +58,8 @@ + + @@ -75,6 +77,7 @@ + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs new file mode 100644 index 0000000000..6f656ccbad --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs @@ -0,0 +1,57 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 20.05.2013 + * Time: 18:15 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.Generic; +using ICSharpCode.Reporting.DataManager.Listhandling; +using ICSharpCode.Reporting.DataSource; +using ICSharpCode.Reporting.Items; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.DataSource +{ + [TestFixture] + public class CollectionHandlingFixture + { + + private ContributorCollection list; + + [Test] + public void CanInitDataCollection() + { + var collectionSource = new CollectionSource (list,new ReportSettings()); + Assert.That(collectionSource,Is.Not.Null); + } + + + [Test] + public void CollectionCountIsEqualToListCount() { + var collectionSource = new CollectionSource (list,new ReportSettings()); + Assert.That(collectionSource.Count,Is.EqualTo(list.Count)); + } + + + [Test] + public void AvailableFieldsEqualContibutorsPropertyCount() { + var collectionSource = new CollectionSource (list,new ReportSettings()); + Assert.That(collectionSource.AvailableFields.Count,Is.EqualTo(7)); + } + + + +//http://stackoverflow.com/questions/5378293/simplest-way-to-filter-generic-list +//http://stackoverflow.com/questions/5378293/simplest-way-to-filter-generic-list +//http://netmatze.wordpress.com/2012/06/21/implementing-a-generic-iequalitycomparer-and-icomparer-class/ +// http://blog.velir.com/index.php/2011/02/17/ilistt-sorting-a-better-way/ + [SetUp] + public void CreateList() { + var contributorList = new ContributorsList(); + list = contributorList.ContributorCollection; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/ContributorsList.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/ContributorsList.cs new file mode 100644 index 0000000000..365534fb6e --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/ContributorsList.cs @@ -0,0 +1,132 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 20.05.2013 + * Time: 18:09 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.Generic; + +namespace ICSharpCode.Reporting.Test.DataSource +{ + /// + /// Description of ContributorsList. + /// + public class ContributorsList + { + ContributorCollection contributorCollection; + + public ContributorsList() + { + this.contributorCollection = CreateContributorsList(); + } + + public ContributorCollection ContributorCollection { + get { return contributorCollection; } + } + + private ContributorCollection CreateContributorsList () { + + DateTime d1 = new DateTime(2000,11,11); + DateTime d2 = new DateTime(2000,01,01); + DateTime d3 = new DateTime(2000,12,24); + + ContributorCollection list = new ContributorCollection(); + + list.Add(new Contributor("Christoph","Wille","Senior Project Wrangler",17,new DateTime(1960,12,8),"F")); + list.Add(new Contributor("Bernhard","Spuida","Senior Project Wrangler",25,new DateTime(1962,2,24),"D")); + + + list.Add(new Contributor("Daniel","Grunwald","Technical Lead",12,d1,"F")); + + list.Add(new Contributor("Matt","Ward","NUnit",7,d1,"F")); + list.Add(new Contributor("David","Srbecky","Debugger",1,d1,"C")); + list.Add(new Contributor("Peter","Forstmeier","SharpDevelop.Reports",7,d1,"D")); + + list.Add(new Contributor("Alexander","Zeitler","SharpDevelop.Reports",3,d2,"D")); + list.Add(new Contributor("Markus","Palme","Prg.",6,d2,"R")); + list.Add(new Contributor("Georg","Brandl","Prg.",5,d2,"R")); + list.Add(new Contributor("Roman","Taranchenko","",2,d2,"U")); + list.Add(new Contributor("Denis","Erchoff","",13,d2,"U")); + + list.Add(new Contributor("Ifko","Kovacka","",31,d3,"A")); + list.Add(new Contributor("Nathan","Allen","",5,d3,"A")); + list.Add(new Contributor("Dickon","Field","DBTools",10,d3,"U")); + + list.Add(new Contributor("Troy","Simpson","Prg.",9,d3,"C")); + list.Add(new Contributor("David","Alpert","Prg.",6,d3,"C")); + return list; + } + } + + public class ContributorCollection: List + { + } + + public class Contributor { + string last; + string first; + string job; + + int randomInt; + DateTime randomDate; + + public Contributor(string last, string first,string job,int randomInt,DateTime randomDate,string groupItem) + { + this.last = last; + this.first = first; + this.job = job; + this.randomDate = randomDate; + this.randomInt = randomInt; + this.GroupItem = groupItem; + } + + + public string Last { + get { + return last; + } + + } + + public string First { + get { + return first; + } + + } + + public string Job { + get { + return job; + } + } + + public int RandomInt { + get { return randomInt; } + } + + + public DateTime RandomDate { + get { return randomDate; } + } + + public string GroupItem {get; set;} + + public MyDummyClass DummyClass {get;set;} + + } + + public class MyDummyClass + { + public MyDummyClass() + { + + } + + public string DummyString {get;set;} + public int DummyInt {get;set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerArrangeStrategyFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerArrangeStrategyFixture.cs index 0b3e01fd97..6d850c6b2b 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerArrangeStrategyFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/ContainerArrangeStrategyFixture.cs @@ -108,6 +108,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder Location = new Point(80,10), Size = new Size (20,70), DesiredSize = new Size (20,70), + CanGrow = true, Parent = container }; return secondItem; diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/SortColumn.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/SortColumn.cs index 80bd3d4814..7d7175d4a4 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/SortColumn.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseClasses/SortColumn.cs @@ -35,25 +35,16 @@ namespace ICSharpCode.Reports.Core public SortColumn(string columnName, ListSortDirection sortDirection, Type type,bool caseSensitive ):base (columnName,type) { - this.caseSensitive = caseSensitive; - this.sortDirection = sortDirection; + this.CaseSensitive = caseSensitive; + this.SortDirection = sortDirection; } #region properties - public ListSortDirection SortDirection { - get { - return sortDirection; - } - set{ - this.sortDirection = value; - } - } - public bool CaseSensitive { - get { - return caseSensitive; - } - } + public ListSortDirection SortDirection {get;set;} + + public bool CaseSensitive {get;set;} + #endregion } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/DataManager/ListStrategy/GroupListFixture.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/DataManager/ListStrategy/GroupListFixture.cs index 8521317946..d33dc22fb5 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/DataManager/ListStrategy/GroupListFixture.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Test/ICSharpCode.Reports.Core.Test/DataManager/ListStrategy/GroupListFixture.cs @@ -149,7 +149,7 @@ namespace ICSharpCode.Reports.Core.Test.DataManager.ListStrategy var itemDummy = (BaseDataItem)searchCol[0]; var itemLast = (BaseDataItem)searchCol[1]; var itemGroup = (BaseDataItem)searchCol[2]; -// Console.WriteLine ("\t{0} - {1} - {2}",itemDummy.DBValue,itemLast.DBValue,itemGroup.DBValue); + Console.WriteLine ("\t{0} - {1} - {2}",itemDummy.DBValue,itemLast.DBValue,itemGroup.DBValue); Assert.That(itemDummy.DBValue,Is.Not.Empty); Assert.That(itemLast.DBValue,Is.Not.Empty); Assert.That(itemGroup.DBValue,Is.Not.Empty);