Exemple #1
0
        // Event handlers
        private async void ParrotClientOnConnectedEvent(object sender, EventArgs eventArgs)
        {
            Enabled = await GetNoiseControlEnabledAsync();

            Type = Enabled ? await GetNoiseControlAsync() : NoiseControlType.NoiseControlOff;

            // Dispatch initial event so the UI can update.
            ChangedEvent?.AsyncSafeInvoke(this, EventArgs.Empty);
        }
        // Event handlers
        private async void ParrotClientOnConnectedEvent(object sender, EventArgs eventArgs)
        {
            var concertHall = await GetConcertHall();

            Enabled = concertHall.enabled;
            Type    = concertHall.type;
            Angle   = concertHall.angle;

            // Dispatch initial event so the UI can update.
            ChangedEvent?.AsyncSafeInvoke(this, EventArgs.Empty);
        }
Exemple #3
0
        // Modify properties asynchronously
        public async Task SetEnabledAsync(bool state)
        {
            // Don't have to change if this is already the current state.
            if (Enabled == state)
            {
                return;
            }

            await SetNoiseControlEnabledAsync(state);

            Enabled = state;
            ChangedEvent?.AsyncSafeInvoke(this, EventArgs.Empty);
        }
        public async Task SetTypeAsync(ConcertHallRoomType type)
        {
            // Don't have to change if this is already the current type.
            if (Type == type)
            {
                return;
            }

            await SetConcertHallRoomAsync(type);

            Type = type;
            ChangedEvent?.AsyncSafeInvoke(this, EventArgs.Empty);
        }
Exemple #5
0
        // Modify properties asynchronously
        public async Task RefreshAsync()
        {
            var batteryData = await GetBatteryAsync();

            if (batteryData.charging != Charging ||
                batteryData.batteryPercent != Percent)
            {
                Charging = batteryData.charging;
                Percent  = batteryData.batteryPercent;

                ChangedEvent?.AsyncSafeInvoke(this, EventArgs.Empty);
            }
        }
Exemple #6
0
        public async Task SetTypeAsync(NoiseControlType type)
        {
            // Don't have to change if this is already the current type.
            if (Type == type)
            {
                return;
            }

            await SetNoiseControlAsync(type);

            Enabled = type != NoiseControlType.NoiseControlOff;
            Type    = type;
            ChangedEvent?.AsyncSafeInvoke(this, EventArgs.Empty);
        }
        public async Task SetAngleAsync(int angle)
        {
            // Don't have to change if this is already the current angle.
            if (Angle == angle)
            {
                return;
            }

            if (!ValidAngles.Contains(angle))
            {
                throw new Exception("Invalid angle specified.");
            }

            await SetConcertHallAngleAsync(angle);

            Angle = angle;
            ChangedEvent?.AsyncSafeInvoke(this, EventArgs.Empty);
        }
Exemple #8
0
        private async void ParrotClientOnNotificationEvent(object sender, NotifyEventArgs notifyEventArgs)
        {
            if (notifyEventArgs.Resource != ResourceType.NoiseControlGet)
            {
                return;
            }

            var newType = await GetNoiseControlAsync();

            if (newType == Type)
            {
                return;
            }

            Type = newType;

            // Dispatch event so the UI can update.
            ChangedEvent?.AsyncSafeInvoke(this, EventArgs.Empty);
        }