mirror of
https://gitee.com/csharpui/CPF.git
synced 2026-02-27 06:03:10 +08:00
初始化
This commit is contained in:
34
ConsoleApp1/Base/ControlBoxComparer.cs
Normal file
34
ConsoleApp1/Base/ControlBoxComparer.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using CPF;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
namespace xss_pro.Base
|
||||
{
|
||||
public class ControlBoxComparer : IComparer<UIElement>
|
||||
{
|
||||
private readonly UIElement[] _map;
|
||||
private bool _descending;
|
||||
public ControlBoxComparer(UIElement[] map , bool descending)
|
||||
{
|
||||
_map = map;
|
||||
_descending = descending;
|
||||
}
|
||||
public int Compare(UIElement x, UIElement y)
|
||||
{
|
||||
return _descending ? GetIndex(y) - GetIndex(x) : GetIndex(x) - GetIndex(y);
|
||||
}
|
||||
public int GetIndex(UIElement target)
|
||||
{
|
||||
int i = 0;
|
||||
foreach(UIElement element in _map)
|
||||
{
|
||||
if (element == target)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user