3
using System.Collections;
6
namespace Stetic.Wrapper
8
public class RadioActionGroupManager: IRadioGroupManager
10
public event GroupsChangedDelegate GroupsChanged;
11
Hashtable actions = new Hashtable ();
12
ArrayList groups = new ArrayList ();
14
public IEnumerable GroupNames {
16
foreach (string grp in groups)
21
public void Rename (string oldName, string newName)
23
int i = groups.IndexOf (oldName);
29
ArrayList list = new ArrayList ();
30
foreach (Action a in FindActionsInGroup (oldName))
33
foreach (Action a in list)
34
actions [a] = newName;
39
public void Add (string name)
45
public RadioGroup FindGroup (string name)
47
for (int i = 0; i < groups.Count; i++) {
48
RadioGroup group = groups[i] as RadioGroup;
49
if (group.Name == name)
55
public string GetGroup (Action action)
57
return actions [action] as string;
60
public void SetGroup (Action action, string group)
63
if (actions.Contains (action)) {
64
actions.Remove (action);
65
action.Disposed -= OnActionDisposed;
70
if (!actions.Contains (action))
71
action.Disposed += OnActionDisposed;
72
actions [action] = group;
73
if (!groups.Contains (group))
77
void OnActionDisposed (object s, EventArgs a)
79
Action ac = (Action) s;
81
ac.Disposed -= OnActionDisposed;
86
public string LastGroup {
88
if (groups.Count == 0)
90
return groups [groups.Count - 1] as string;
94
void EmitGroupsChanged ()
96
if (GroupsChanged != null)
100
IEnumerable FindActionsInGroup (string grp)
102
foreach (DictionaryEntry e in actions)
103
if (((string)e.Value) == grp)
107
public CodeExpression GenerateGroupExpression (GeneratorContext ctx, Action action)
109
// Returns and expression that represents the group to which the radio belongs.
110
// This expression can be an empty SList, if this is the first radio of the
111
// group that has been generated, or an SList taken from previously generated
112
// radios from the same group.
114
string group = actions [action] as string;
116
return new CodePrimitiveExpression (null);
118
CodeExpression var = null;
120
foreach (Action a in FindActionsInGroup (group)) {
123
var = ctx.WidgetMap.GetWidgetExp (a);
129
return new CodeObjectCreateExpression (
131
new CodePropertyReferenceExpression (
132
new CodeTypeReferenceExpression (typeof(IntPtr)),
137
return new CodePropertyReferenceExpression (