-
Notifications
You must be signed in to change notification settings - Fork 0
/
InteractionContextProxyComparer.cs
39 lines (32 loc) · 1.42 KB
/
InteractionContextProxyComparer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections.Generic;
namespace tud.mci.tangram.TangramLector.Classes
{
/// <summary>
/// Comparer for <see cref="IInteractionContextProxy"/> width respect to their adding time stamp and their zIndex.
/// </summary>
public class InteractionContextProxyComparer : Comparer<KeyValuePair<int, IInteractionContextProxy>>, IComparer<KeyValuePair<int, object>>
{
/*
* return:
* > 0 | x < y
* = 0 | x == x
* < 0 | x > y
* */
public override int Compare(KeyValuePair<int, IInteractionContextProxy> x, KeyValuePair<int, IInteractionContextProxy> y)
{
int zx = 0;
int zy = 0;
if (x.Value is IInteractionContextProxy) zx = ((IInteractionContextProxy)x.Value).ZIndex;
if (y.Value is IInteractionContextProxy) zy = ((IInteractionContextProxy)y.Value).ZIndex;
return zy - zx;
}
public int Compare(KeyValuePair<int, object> x, KeyValuePair<int, object> y)
{
if (x.Value is IInteractionContextProxy && y.Value is IInteractionContextProxy)
return Compare(
new KeyValuePair<int, IInteractionContextProxy>(x.Key, ((IInteractionContextProxy)x.Value)),
new KeyValuePair<int, IInteractionContextProxy>(y.Key, ((IInteractionContextProxy)x.Value)));
return 0;
}
}
}