Sort ROs in Groups

Use generic comparison from DisplayRO to sort ROs
Make GreaterValue public so that it can be used for DisplayReports and DisplaySearch to sort ROs consistently.
Remove debug printout
This commit is contained in:
Rich 2014-02-06 18:36:57 +00:00
parent 5e621b46a6
commit 4fd9ef75c4
4 changed files with 30 additions and 24 deletions

View File

@ -369,7 +369,7 @@ namespace Volian.Controls.Library
}
private static Regex _RegExGetNumber = new Regex(@"^ *[+-]?[.,0-9/]+(E[+-]?[0-9]+)?");
// Sort by numeric value if possible, Otherwise sort alphabetically.
private bool GreaterValue(string value1, string value2)
public static bool GreaterValue(string value1, string value2)
{
Match match1 = _RegExGetNumber.Match(value1);
Match match2 = _RegExGetNumber.Match(value2);

View File

@ -608,7 +608,9 @@ namespace Volian.Controls.Library
tmp.Text = chld[i].title;
tmp.Tag = chld[i];
tmp.CheckBoxVisible = true;
tn.Nodes.Add(tmp);
int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp);
//tn.Nodes.Add(tmp);
DevComponents.AdvTree.Node sub = new DevComponents.AdvTree.Node();
sub.Text = "VLN_DUMMY_FOR_TREE";
tmp.Nodes.Add(sub);
@ -676,18 +678,19 @@ namespace Volian.Controls.Library
}
return index;
}
private static Regex _RegExGetNumber = new Regex(@"^ *[+-]?[.,0-9]+(E[+-]?[0-9]+)?");
//private static Regex _RegExGetNumber = new Regex(@"^ *[+-]?[.,0-9]+(E[+-]?[0-9]+)?");
private bool GreaterValue(string value1, string value2)
{
Match match1 = _RegExGetNumber.Match(value1);
Match match2 = _RegExGetNumber.Match(value2);
if (match1.Success && match2.Success) // Compare the numeric value
{
double dbl1 = double.Parse(match1.ToString());
double dbl2 = double.Parse(match2.ToString());
return dbl1 > dbl2;
}
return String.Compare(value1, value2, true) > 0;
return DisplayRO.GreaterValue(value1, value2);
// Match match1 = _RegExGetNumber.Match(value1);
// Match match2 = _RegExGetNumber.Match(value2);
// if (match1.Success && match2.Success) // Compare the numeric value
// {
// double dbl1 = double.Parse(match1.ToString());
// double dbl2 = double.Parse(match2.ToString());
// return dbl1 > dbl2;
// }
// return String.Compare(value1, value2, true) > 0;
}

View File

@ -561,7 +561,9 @@ namespace Volian.Controls.Library
tmp = new DevComponents.AdvTree.Node();
tmp.Text = chld[i].title;
tmp.Tag = chld[i];
tn.Nodes.Add(tmp);
int index = FindIndex(tn.Nodes, tmp.Text);
tn.Nodes.Insert(index, tmp);
//tn.Nodes.Add(tmp);
DevComponents.AdvTree.Node sub = new DevComponents.AdvTree.Node();
sub.Text = "VLN_DUMMY_FOR_TREE";
tmp.Nodes.Add(sub);
@ -590,18 +592,19 @@ namespace Volian.Controls.Library
}
return index;
}
private static Regex _RegExGetNumber = new Regex(@"^ *[+-]?[.,0-9]+(E[+-]?[0-9]+)?");
// private static Regex _RegExGetNumber = new Regex(@"^ *[+-]?[.,0-9]+(E[+-]?[0-9]+)?");
private bool GreaterValue(string value1, string value2)
{
Match match1 = _RegExGetNumber.Match(value1);
Match match2 = _RegExGetNumber.Match(value2);
if (match1.Success && match2.Success) // Compare the numeric value
{
double dbl1 = double.Parse(match1.ToString());
double dbl2 = double.Parse(match2.ToString());
return dbl1 > dbl2;
}
return String.Compare(value1, value2, true) > 0;
return DisplayRO.GreaterValue(value1, value2);
//Match match1 = _RegExGetNumber.Match(value1);
//Match match2 = _RegExGetNumber.Match(value2);
//if (match1.Success && match2.Success) // Compare the numeric value
//{
// double dbl1 = double.Parse(match1.ToString());
// double dbl2 = double.Parse(match2.ToString());
// return dbl1 > dbl2;
//}
//return String.Compare(value1, value2, true) > 0;
}
private void cmboTreeROs_SelectedIndexChanged(object sender, EventArgs e)

View File

@ -94,7 +94,7 @@ namespace Volian.Controls.Library
OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyProcedure.ItemID, CheckOutType.Procedure);
else
OwnerID = myDisplayTabControl.MySessionInfo.CheckOutItem(myItemInfo.MyContent.MyEntry.DocID, CheckOutType.Document);
Console.WriteLine("DisplayTabItem");
//Console.WriteLine("DisplayTabItem");
_MyKey = myKey;
_MyDisplayTabControl = myDisplayTabControl;
container.Add(this);