12 using System.Collections.
Generic;
22 private Dictionary<UInt32, object> _transactions =
new Dictionary<UInt32, object>();
38 object actionDelegate;
39 if (_transactions.TryGetValue(eventArgs.
RequestId, out actionDelegate)) {
40 Action<bool> changeAction = actionDelegate as Action<bool>;
42 _transactions.Remove(eventArgs.
RequestId);
46 private void handleConfigResponse(
object sender, SetConfigResponseEventArgs eventArgs) {
47 object actionDelegate =
new object();
48 if (_transactions.TryGetValue(eventArgs.RequestId, out actionDelegate)) {
49 switch (eventArgs.DataType) {
51 Action<bool> boolAction = actionDelegate as Action<bool>;
52 boolAction((
int)eventArgs.Value != 0);
55 Action<float> floatAction = actionDelegate as Action<float>;
56 floatAction((
float)eventArgs.Value);
59 Action<Int32> intAction = actionDelegate as Action<Int32>;
60 intAction((Int32)eventArgs.Value);
63 Action<string> stringAction = actionDelegate as Action<string>;
64 stringAction((
string)eventArgs.Value);
69 _transactions.Remove(eventArgs.RequestId);
82 public bool Get<T>(
string key, Action<T> onResult) {
85 _transactions.Add(requestId, onResult);
100 public bool Set<T>(
string key, T value, Action<bool> onResult) where T : IConvertible {
101 uint requestId = _connection.SetConfigValue<T>(key, value);
104 _transactions.Add(requestId, onResult);
110 [Obsolete(
"Use the generic Set<T> method instead.")]
115 [Obsolete(
"Use the generic Get<T> method instead.")]
120 [Obsolete(
"Use the generic Set<T> method instead.")]
125 [Obsolete(
"Use the generic Get<T> method instead.")]
130 [Obsolete(
"Use the generic Set<T> method instead.")]
135 [Obsolete(
"Use the generic Get<T> method instead.")]
140 [Obsolete(
"Use the generic Set<T> method instead.")]
145 [Obsolete(
"Use the generic Get<T> method instead.")]
150 [Obsolete(
"Use the generic Set<T> method instead.")]
Dispatched when a configuration change is completed.
The Config class provides access to Leap Motion system configuration information.
bool SetString(string key, string value)
ValueType Type(string key)
bool Get< T >(string key, Action< T > onResult)
Requests a configuration value.
bool SetBool(string key, bool value)
bool GetString(string key)
Config(Connection.Key connectionKey)
Creates a new Config object for setting runtime configuration settings.
bool SetInt32(string key, int value)
bool GetInt32(string key)
bool Set< T >(string key, T value, Action< bool > onResult)
Sets a configuration value.
bool SetFloat(string key, float value)
bool GetFloat(string key)
ValueType
Enumerates the possible data types for configuration values.
uint GetConfigValue(string config_key)
static Connection GetConnection(int connectionId=0)
EventHandler< ConfigChangeEventArgs > LeapConfigChange
EventHandler< SetConfigResponseEventArgs > LeapConfigResponse