コード例 #1
0
 public static void SendAPICall(WLEDDevice t, string call)
 {
     if (timer.Enabled)
     {
         //Save to send once waiting period over
         target      = t;
         toSend      = call;
         alreadySent = false;
         return;
     }
     timer.Start();
     t?.SendAPICall(call);
     alreadySent = true;
 }
コード例 #2
0
ファイル: DeviceDiscovery.cs プロジェクト: baenoinc/Bolt-App
        private async void OnServiceAdded(object sender, ServiceAnnouncementEventArgs e)
        {
            WLEDDevice toAdd = new WLEDDevice();

            foreach (var addr in e.Announcement.Addresses)
            {
                toAdd.NetworkAddress = addr.ToString(); break; //only get first address
            }
            toAdd.Name         = e.Announcement.Hostname;
            toAdd.NameIsCustom = false;
            if (await toAdd.Refresh()) //check if the service is a valid WLED light
            {
                OnValidDeviceFound(new DeviceCreatedEventArgs(toAdd, false));
            }
        }
コード例 #3
0
        public int CompareTo(object comp) //compares devices in alphabetic order based on name
        {
            WLEDDevice c = comp as WLEDDevice;

            if (c == null || c.Name == null)
            {
                return(1);
            }
            int result = (name.CompareTo(c.name));

            if (result != 0)
            {
                return(result);
            }
            return(networkAddress.CompareTo(c.networkAddress));
        }
コード例 #4
0
        private void UpdateElementsVisibility() //Show welcome labels and hide deletion mode button if there are no devices
        {
            bool listIsEmpty = (deviceList.Count == 0);

            welcomeLabel.IsVisible     = listIsEmpty;
            instructionLabel.IsVisible = listIsEmpty;
            topMenuBar.SetButtonIcon(ButtonLocation.Left, listIsEmpty ? ButtonIcon.None : ButtonIcon.Delete);

            //iOS workaround for listview not updating unless ItemSource is modified
            if (Device.RuntimePlatform == Device.iOS)
            {
                WLEDDevice dummy = new WLEDDevice();
                deviceList.Add(dummy);
                deviceList.Remove(dummy);
            }
        }
コード例 #5
0
        //If done, create device and close page
        private async void OnEntryCompleted(object sender, EventArgs e)
        {
            if (sender is Entry currentEntry)
            {
                currentEntry.Unfocus();
            }

            var device = new WLEDDevice();

            string address = networkAddressEntry.Text;
            string name    = nameEntry.Text;

            if (address == null || address.Length == 0)
            {
                address = "192.168.4.1";
            }
            if (address.StartsWith("http://"))
            {
                address = address.Substring(7);
            }
            if (address.EndsWith("/"))
            {
                address = address.Substring(0, address.Length - 1);
            }
            if (name == null || name.Length == 0)
            {
                name = "(New Light)";
                device.NameIsCustom = false;
            }

            device.Name           = name;
            device.NetworkAddress = address;

            await Navigation.PopModalAsync(false);

            //Add device, but not if the user clicked checkmark after doing auto-discovery only
            if (devicesFoundCount == 0 || !address.Equals("192.168.4.1"))
            {
                OnDeviceCreated(new DeviceCreatedEventArgs(device));
            }
        }