示例#1
0
        private async void Switch_OnToggled(object sender, ToggledEventArgs e)
        {
            var s = ((BindableObject)sender).BindingContext;

            if (s != null)
            {
                var p = (Plug)s;

                var stateaction = await str.GetStateAction();

                if (!string.Equals(stateaction, L10n.Localize("State3")))
                {
                    if (string.Equals(stateaction, L10n.Localize("State2")))
                    {
                        if (p.MyPlugState.IsScheduleEnabled != null && (bool)p.MyPlugState.IsScheduleEnabled)
                        {
                            await SelectActionState(p.Mac);
                        }
                    }
                    else if (string.Equals(stateaction, L10n.Localize("State1")))
                    {
                        string schOffMsg = "DisableSchedule {\"MAC\":" + p.Mac + ",\"Number\":0}";
                        connection.Send(schOffMsg);
                    }
                }


                if (e.Value == true)
                {
                    string turnOnMsg = "TurnOn {\"MAC\":" + p.Mac + ",\"Number\":0}";
                    connection.Send(turnOnMsg);
                }
                else if (e.Value == false)
                {
                    string turnOffMsg = "TurnOff {\"MAC\":" + p.Mac + ",\"Number\":0}";
                    connection.Send(turnOffMsg);
                }
            }
        }
示例#2
0
        protected override async void OnAppearing()
        {
            var ur   = new UserResources();
            var user = await ur.GetUserAsync();

            EmailLabel.Text    = user.Email;
            ProviderLabel.Text = user.IdentityProvider;
            UserLabel.Text     = user.Name;


            st = new StateActionResources();
            var text = await st.GetStateAction();

            if (string.IsNullOrWhiteSpace(text))
            {
                StateGrid.IsVisible = false;
            }
            else
            {
                StateGrid.IsVisible = true;
                StateLabel.Text     = text;
            }
        }