-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathDynamicByteSelectionProvider.cs
61 lines (46 loc) · 1.36 KB
/
DynamicByteSelectionProvider.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
namespace Be.Windows.Forms
{
public class DynamicByteSelectionProvider : ISelectedByteProvider
{
List<bool> _selectedState;
public DynamicByteSelectionProvider( long NumBytes )
{
_selectedState = new List<bool>();
for ( long i = 0; i < NumBytes; ++i )
{
_selectedState.Add( false );
}
}
public bool IsByteSelected( long index )
{
if ( ( index < 0 )
|| ( index >= _selectedState.Count ) )
{
throw new IndexOutOfRangeException( "Index " + index + " is out of bounds 0," + _selectedState.Count );
}
return _selectedState[(int)index];
}
public void SetByteSelectionState( long index, bool Selected )
{
if ( ( index < 0 )
|| ( index >= _selectedState.Count ) )
{
throw new IndexOutOfRangeException( "Index " + index + " is out of bounds 0," + _selectedState.Count );
}
_selectedState[(int)index] = Selected;
}
public void InsertBytes( long index, long length )
{
for ( int i = 0; i < length; ++i )
{
_selectedState.Insert( (int)index, false );
}
}
public void DeleteBytes( long index, long length )
{
_selectedState.RemoveRange( (int)index, (int)length );
}
}
}