26 changed files with 36 additions and 410 deletions
@ -1,33 +0,0 @@
@@ -1,33 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Reporting.DataSource.Comparer; |
||||
|
||||
namespace ICSharpCode.Reporting.DataManager.Listhandling |
||||
{ |
||||
/// <summary>
|
||||
/// Description of IndexList.
|
||||
/// </summary>
|
||||
public class IndexList :List<BaseComparer> |
||||
{ |
||||
|
||||
public int CurrentPosition {get;set;} |
||||
} |
||||
} |
@ -1,102 +0,0 @@
@@ -1,102 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.ObjectModel; |
||||
using ICSharpCode.Reporting.BaseClasses; |
||||
|
||||
namespace ICSharpCode.Reporting.DataSource.Comparer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of BaseComparer.
|
||||
/// </summary>
|
||||
public class BaseComparer : IComparable { |
||||
|
||||
private int listIndex; |
||||
private object[] objectArray; |
||||
|
||||
/// <summary>
|
||||
/// Default constructor - initializes all fields to default values
|
||||
/// </summary>
|
||||
|
||||
public BaseComparer(Collection<AbstractColumn> columnCollection , int listIndex, object[] values) { |
||||
this.ColumnCollection = columnCollection; |
||||
this.listIndex = listIndex; |
||||
this.objectArray = values; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Interface method from IComparable
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Interface method from IComparable
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name='obj'>a <see cref="BaseComparer"></see></param>
|
||||
public virtual int CompareTo(object obj) { |
||||
return 0; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Ausgeben der Werte als Pseudo-CSV
|
||||
/// </summary>
|
||||
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("<NULL>"); |
||||
} |
||||
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 Collection<AbstractColumn> ColumnCollection {get;private set;} |
||||
|
||||
} |
||||
} |
@ -1,39 +0,0 @@
@@ -1,39 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.ObjectModel; |
||||
using ICSharpCode.Reporting.BaseClasses; |
||||
using ICSharpCode.Reporting.DataManager.Listhandling; |
||||
|
||||
namespace ICSharpCode.Reporting.DataSource.Comparer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of GroupComparer.
|
||||
/// </summary>
|
||||
public class GroupComparer :SortComparer |
||||
{ |
||||
|
||||
public GroupComparer (Collection<AbstractColumn> owner, int listIndex, object[] values):base(owner,listIndex,values) |
||||
{ |
||||
IndexList = new IndexList(); |
||||
} |
||||
|
||||
public IndexList IndexList {get;private set;} |
||||
} |
||||
} |
@ -1,115 +0,0 @@
@@ -1,115 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.ObjectModel; |
||||
using System.ComponentModel; |
||||
using System.Globalization; |
||||
|
||||
using ICSharpCode.Reporting.BaseClasses; |
||||
using ICSharpCode.Reporting.Items; |
||||
|
||||
namespace ICSharpCode.Reporting.DataSource.Comparer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SortComparer.
|
||||
/// </summary>
|
||||
public class SortComparer : BaseComparer { |
||||
|
||||
public SortComparer(Collection<AbstractColumn> owner, int listIndex, object[] values):base(owner,listIndex,values) |
||||
{ |
||||
} |
||||
|
||||
|
||||
internal int CompareTo(SortComparer 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(); |
||||
|
||||
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
|
||||
|
||||
SortColumn sortColumn = (SortColumn)base.ColumnCollection[index]; |
||||
|
||||
bool descending = (sortColumn.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()){ |
||||
string s = String.Format(CultureInfo.CurrentCulture, |
||||
"{0} {1} {2}",this.GetType().ToString(), |
||||
leftValue.GetType().ToString(), |
||||
rightValue.GetType().ToString()); |
||||
|
||||
throw new ArgumentException(s); |
||||
} |
||||
if (leftValue.GetType() == typeof(string)) |
||||
{ |
||||
compare = String.Compare((string)leftValue, (string)rightValue, |
||||
!sortColumn.CaseSensitive, CultureInfo.CurrentCulture); |
||||
} |
||||
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((SortComparer)obj); |
||||
} |
||||
|
||||
|
||||
} |
||||
} |
@ -1,42 +0,0 @@
@@ -1,42 +0,0 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
namespace ICSharpCode.Reporting.DataSource.Comparer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SortExtension.
|
||||
/// </summary>
|
||||
internal static class SortExtension |
||||
{ |
||||
|
||||
public static IOrderedQueryable<BaseComparer> AscendingOrder(this IQueryable<BaseComparer> source ) |
||||
{ |
||||
|
||||
return source.OrderBy(x => x.ObjectArray[0]); |
||||
} |
||||
|
||||
public static IOrderedQueryable<BaseComparer> DescendingOrder(this IQueryable<BaseComparer> source ) |
||||
{ |
||||
|
||||
return source.OrderByDescending(x => x.ObjectArray[0]); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue