Exemple #1
0
        private static void ApplySwitchState(SwitchType switch_type, string new_state, Action callback)
        {
            if(switch_type.State != new_state)
            {
                Chameleon.Invalidate();

                InvalidateOptions options = new InvalidateOptions();
                options.Time = 100;
                options.Callback = callback;

                string class_state_suffix="";
                if(switch_type.State != null)
                    class_state_suffix="-"+switch_type.State;

                string current_class = switch_type.ClassName + class_state_suffix;
                string new_class = switch_type.ClassName + "-" + new_state;

                jQuery.Select("." + current_class).RemoveClass("switch-" + switch_type.State).AddClass("switch-" + new_state);
                jQuery.Select("." + current_class).RemoveClass(current_class).AddClass(new_class)
                    .Plugin<ChameleonUiObject>().ChameleonInvalidate(options);

                switch_type.State = new_state;

                Chameleon.InvalidateTwo();
            }
        }
Exemple #2
0
 private static extern void ApplySwitchState(SwitchType switch_type, string new_state);
Exemple #3
0
        private static void InitSwitches(Dictionary options)
        {
            if(switchTypes == null){
                switchTypes = new List<SwitchType>();

                string test_state = "disabled";

                if(options["airplanemode"] != null && (bool)Type.GetField(options["airplanemode"], "exists")){
                    string airplane_state = "disabled";
                    if((bool)Type.GetField(options["airplanemode"], "enabled"))
                        airplane_state = "highlighted";

                    SwitchType airplane = new SwitchType();
                    airplane.Name = "airplanemode";
                    airplane.ClassName = "switch-airplanemode";
                    airplane.Caption = "Airplane Mode";
                    airplane.State = airplane_state;
                    airplane.OnClick = HandleAirplaneModeClick;
                    switchTypes.Add(airplane);
                }

                if(options["bluetooth"] != null && (bool)Type.GetField(options["bluetooth"], "exists")){
                    string bluetooth_state = "disabled";
                    if((bool)Type.GetField(options["bluetooth"], "enabled"))
                        bluetooth_state="highlighted";

                    SwitchType bluetooth = new SwitchType();
                    bluetooth.Name = "bluetooth";
                    bluetooth.ClassName = "switch-bluetooth";
                    bluetooth.Caption = "Bluetooth";
                    bluetooth.State = bluetooth_state;
                    bluetooth.OnClick = HandleBluetoothClick;
                    switchTypes.Add(bluetooth);
                }

                if(options["brightness"] != null && (bool)Type.GetField(options["brightness"], "exists")){
                    string brightness_state="off";

                    if((bool)Type.GetField(options["brightness"], "automode")){
                        brightness_state="auto";
                    }else if((int)Type.GetField(options["brightness"], "level") == 255){
                        brightness_state="full";
                    }else if((int)Type.GetField(options["brightness"], "level") >= 125){
                        brightness_state="half";
                    }

                    SwitchType brightness = new SwitchType();
                    brightness.Name = "brightness";
                    brightness.ClassName = "switch-brightness";
                    brightness.Caption = "Brightness";
                    brightness.State = brightness_state;
                    brightness.OnClick = HandleBrightnessClick;
                    switchTypes.Add(brightness);
                }

                if(options["gps"] != null && (bool)Type.GetField(options["gps"], "exists")){
                    string gps_state="disabled";
                    if((bool)Type.GetField(options["gps"], "enabled"))
                        gps_state="highlighted";

                    SwitchType gps = new SwitchType();
                    gps.Name = "gps";
                    gps.ClassName = "switch-gps";
                    gps.Caption = "GPS";
                    gps.State = gps_state;
                    gps.OnClick = HandleGPSClick;
                    switchTypes.Add(gps);
                }

                if(options["lock"] != null && (bool)Type.GetField(options["lock"], "exists"))
                {
                    SwitchType deviceLock = new SwitchType();
                    deviceLock.Name = "lock";
                    deviceLock.ClassName = "switch-lock";
                    deviceLock.Caption = "Lock";
                    deviceLock.State = test_state;
                    deviceLock.OnClick = HandleLockClick;
                    switchTypes.Add(deviceLock);
                }

                if(options["network"] != null && (bool)Type.GetField(options["network"], "exists"))
                {
                    SwitchType network = new SwitchType();
                    network.Name = "network";
                    network.ClassName = "switch-network";
                    network.Caption = "Network";
                    network.State = test_state;
                    network.OnClick = HandleNetworkClick;
                    switchTypes.Add(network);
                }

                if(options["ringer"] != null && (bool)Type.GetField(options["ringer"], "exists"))
                {
                    SwitchType ringer = new SwitchType();
                    ringer.Name = "ringer";
                    ringer.ClassName = "switch-ringer";
                    ringer.Caption = "Ringer";
                    ringer.State = test_state;
                    ringer.OnClick = HandleRingerClick;
                    switchTypes.Add(ringer);
                }

                if(options["rotation"] != null && (bool)Type.GetField(options["rotation"], "exists"))
                {
                    string rotation_state="disabled";
                    if((bool)Type.GetField(options["rotation"], "enabled"))
                        rotation_state="highlighted";

                    SwitchType rotation = new SwitchType();
                    rotation.Name = "rotation";
                    rotation.ClassName = "switch-rotation";
                    rotation.Caption = "Rotation";
                    rotation.State = test_state;
                    rotation.OnClick = HandleRotationClick;
                    switchTypes.Add(rotation);
                }

                if(options["sync"] != null && (bool)Type.GetField(options["sync"], "exists"))
                {
                    SwitchType sync = new SwitchType();
                    sync.Name = "sync";
                    sync.ClassName = "switch-sync";
                    sync.Caption = "Sync";
                    sync.State = test_state;
                    sync.OnClick = HandleSyncClick;
                    switchTypes.Add(sync);
                }

                if(options["timeout"] != null && (bool)Type.GetField(options["timeout"], "exists"))
                {
                    SwitchType timeout = new SwitchType();
                    timeout.Name = "timeout";
                    timeout.ClassName = "switch-timeout";
                    timeout.Caption = "Timeout";
                    timeout.State = test_state;
                    timeout.OnClick = HandleTimeoutClick;
                    switchTypes.Add(timeout);
                }

                if(options["vibrate"] != null && (bool)Type.GetField(options["vibrate"], "exists"))
                {
                    SwitchType vibrate = new SwitchType();
                    vibrate.Name = "vibrate";
                    vibrate.ClassName = "switch-vibrate";
                    vibrate.Caption = "Vibrate";
                    vibrate.State = test_state;
                    vibrate.OnClick = HandleVibrateClick;
                    switchTypes.Add(vibrate);
                }

                if(options["wifi"] != null && (bool)Type.GetField(options["wifi"], "exists"))
                {
                    string wifi_state = "disabled";
                    if((bool)Type.GetField(options["wifi"], "enabled"))
                        wifi_state="highlighted";

                    SwitchType wifi = new SwitchType();
                    wifi.Name = "wifi";
                    wifi.ClassName = "switch-wifi";
                    wifi.Caption = "WiFi";
                    wifi.State = wifi_state;
                    wifi.OnClick = HandleWiFiClick;
                    switchTypes.Add(wifi);
                }
            }
        }