async void SaveButtonClicked(object s, EventArgs e)
        {
            ImageButton imgB = (ImageButton)s;

            System.Diagnostics.Debug.WriteLine(((StackLayout)imgB.Parent).StyleId);
            StackLayout sl       = ((StackLayout)imgB.Parent);
            int         pk       = Int32.Parse(sl.StyleId);
            Timers      curTimer = await App.Database.GetTimerByPK(pk);

            Timers timer = new Timers
            {
                TimerId  = pk,
                Start    = ((TimePicker)sl.Children[0]).Time,
                Stop     = ((TimePicker)sl.Children[2]).Time,
                DeviceId = curTimer.DeviceId,
                UserId   = curTimer.UserId,
                StaatAan = curTimer.StaatAan
            };

            System.Diagnostics.Debug.WriteLine(System.Text.Json.JsonSerializer.Serialize(timer));

            await App.Database.UpdateTimer(timer);
        }
        async void SwitchClicked(object s, EventArgs e)
        {
            Switch      sw       = (Switch)s;
            StackLayout sl       = ((StackLayout)sw.Parent);
            int         pk       = Int32.Parse(sl.StyleId);
            Timers      curTimer = await App.Database.GetTimerByPK(pk);

            Timers timer = new Timers
            {
                TimerId  = pk,
                Start    = ((TimePicker)sl.Children[0]).Time,
                Stop     = ((TimePicker)sl.Children[2]).Time,
                DeviceId = curTimer.DeviceId,
                UserId   = curTimer.UserId,
                StaatAan = sw.IsToggled
            };
            await App.Database.UpdateTimer(timer);

            Timers currentTimer = await App.Database.GetTimerByPK(pk);

            System.Diagnostics.Debug.WriteLine(System.Text.Json.JsonSerializer.Serialize(currentTimer));
            System.Diagnostics.Debug.WriteLine(DateTime.Now.TimeOfDay.TotalMinutes);
            if (sw.IsToggled)
            {
                IDevice device = await CrossBluetoothLE.Current.Adapter.ConnectToKnownDeviceAsync(Guid.Parse(currentSchakelaars[devicePicker.SelectedIndex].DeviceGUID));

                await CrossBluetoothLE.Current.Adapter.ConnectToDeviceAsync(device);

                var service = await device.GetServiceAsync(Guid.Parse("6e400001-b5a3-f393-e0a9-e50e24dcca9e"));

                var characteristic0 = await service.GetCharacteristicAsync(Guid.Parse("6e400003-b5a3-f393-e0a9-e50e24dcca9e"));

                await characteristic0.WriteAsync(Encoding.ASCII.GetBytes("timer " + Math.Floor(DateTime.Now.TimeOfDay.TotalMinutes).ToString() + " " + Math.Floor(timer.Start.TotalMinutes).ToString() + " " + Math.Floor(timer.Stop.TotalMinutes).ToString()).Concat(StringToByteArray("0a")).ToArray());

                await CrossBluetoothLE.Current.Adapter.DisconnectDeviceAsync(device);
            }
        }
示例#3
0
 public Task <int> UpdateTimer(Timers timer)
 {
     return(_database.UpdateAsync(timer));
 }
示例#4
0
 public Task <int> AddTimer(Timers timer)
 {
     return(_database.InsertAsync(timer));
 }