This commit is contained in:
2008-08-12 11:21:19 +00:00
parent 610f408c6d
commit d0dba2aad4
14 changed files with 937 additions and 240 deletions

View File

@@ -17,6 +17,8 @@ using System.Configuration;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text.RegularExpressions;
namespace VEPROMS.CSLA.Library
{
@@ -68,9 +70,19 @@ namespace VEPROMS.CSLA.Library
return MyParent;
}
}
private Format _ActiveFormat = null;
public Format ActiveFormat
{
get { return LocalFormat != null ? LocalFormat : (ActiveParent != null ? ActiveParent.ActiveFormat : null); }
get
{
if (_ActiveFormat == null)
_ActiveFormat = (LocalFormat != null ? LocalFormat : ActiveParent != null ? ActiveParent.ActiveFormat : null);
return _ActiveFormat;
}
set
{
_ActiveFormat = null; // Reset
}
}
public Format LocalFormat
{
@@ -81,6 +93,16 @@ namespace VEPROMS.CSLA.Library
get { return FolderConfig; }
}
#endregion
#region MakeFolders for ManualOrder
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config, DateTime dts, string usrID)
{
return MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config, dts, usrID);
}
public static Folder MakeFolder(Folder myParent, Connection myConnection, string name, string title, string shortName, Format myFormat, string config)
{
return MakeFolder(myParent, myConnection, name, title, shortName, myFormat, null, config);
}
#endregion
}
public partial class FolderInfo:IVEDrillDownReadOnly
{
@@ -96,11 +118,84 @@ namespace VEPROMS.CSLA.Library
_FolderConfig = null;
}
#endregion
#region SortingChildren
public Csla.SortedBindingList<FolderInfo> _SortedChildFolders;
public Csla.SortedBindingList<FolderInfo> SortedChildFolders
{
get
{
if (ChildFolders != null)
{
if (_SortedChildFolders == null)
{
_SortedChildFolders = new SortedBindingList<FolderInfo>(ChildFolders);
//_SortedChildFolders.ApplySort("FolderID", ListSortDirection.Ascending);
//_SortedChildFolders.ApplySort("Name", ListSortDirection.Ascending);
}
else if (_SortedChildFolders.Count != ChildFolders.Count)
{
_SortedChildFolders = new SortedBindingList<FolderInfo>(ChildFolders);
}
_SortedChildFolders.ApplySort("ManualOrder", ListSortDirection.Ascending);
}
return _SortedChildFolders;
}
}
public double? NewManualOrder(int index)
{
double? retval = 1;
if (SortedChildFolders == null || SortedChildFolders.Count == 0)
retval = 1; // First value
else if (index == 0)
{
if (retval >= SortedChildFolders[index].ManualOrder) // If one is too big, then divide first value in half
retval = SortedChildFolders[index].ManualOrder / 2;
}
else if (SortedChildFolders.Count > index)
{
retval += SortedChildFolders[index - 1].ManualOrder; // Just go to the next whole number
if (retval >= SortedChildFolders[index].ManualOrder)
retval = (SortedChildFolders[index - 1].ManualOrder + SortedChildFolders[index].ManualOrder) / 2;
}
else
retval += SortedChildFolders[index - 1].ManualOrder;
return retval;
}
/// <summary>
/// UniqueChildName will check the existing children to assure that the name is not a duplicate name.
/// </summary>
/// <param name="folderName"></param>
/// <returns></returns>
public string UniqueChildName(string folderName)
{
string retval = folderName;
int iSuffix = -1;
RefreshChildFolders();
foreach (FolderInfo fi in ChildFolders)
{
if (fi.Name.StartsWith(folderName))
{
if (fi.Name == folderName)
iSuffix = 0;
else if (Regex.IsMatch(fi.Name, folderName + "[_][0-9]+"))
{
int ii = int.Parse(fi.Name.Substring(1 + folderName.Length));
if (ii > iSuffix) iSuffix = ii;
}
}
}
if (iSuffix >= 0)
retval = string.Format("{0}_{1}", folderName, iSuffix + 1);
// Console.WriteLine("FolderName = '{0}'", retval);
return retval;
}
#endregion
#region IVEReadOnlyItem
public System.Collections.IList GetChildren()
{
if(FolderDocVersionCount != 0)return FolderDocVersions;
if (ChildFolderCount != 0) return ChildFolders;
//if (ChildFolderCount != 0) return ChildFolders;
if (ChildFolderCount != 0) return SortedChildFolders;
return null;
}
//public bool ChildrenAreLoaded
@@ -178,4 +273,5 @@ namespace VEPROMS.CSLA.Library
}
#endregion
}
}