Exemplo n.º 1
0
        public void EditBtnClicked(string name, int pin, DeviceContentView dcv)
        {
            var a = new AddDevicePg(name, pin, dcv);

            a.Disappearing += DeviceContentFinishedEditing;
            Navigation.PushAsync(a, true);
        }
Exemplo n.º 2
0
 void UpdateDeviceStates()
 {
     for (int i = deviceContentOffset; i < stackLayout.Children.Count; i++)
     {
         DeviceContentView dcv = (DeviceContentView)stackLayout.Children[i];
         dcv.SetSwitchState(GetPinState(dcv.pin));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Saves the Device content data of the current rpi
        /// </summary>
        void Save()
        {
            if (rpiPicker.SelectedItem == null)
            {
                return;
            }

            //Overwrite file with current data
            using (StreamWriter sw = new StreamWriter(Path.Combine(saveDir, rpiPicker.SelectedItem.ToString()) + ext))
            {
                DeviceContentView dcv = null;
                for (int i = deviceContentOffset; i < stackLayout.Children.Count; i++)
                {
                    dcv = (DeviceContentView)stackLayout.Children[i];
                    sw.WriteLine($"{dcv.name} {dcv.pin}");
                }
            }
        }
        /// <summary>
        /// Pass parameters when an existing object is being edited. Button text will adjust accordingly
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pin"></param>
        /// <param name="dcv"></param>
        public AddDevicePg(string name = "", int pin = -1, DeviceContentView dcv = null)
        {
            InitializeComponent();

            deviceNameEntry.Text = name;
            startName            = name;

            startPin = pin;
            this.dcv = dcv;

            //Fill with GPIO pin numbers
            picker.ItemsSource = new int[] { 3, 5, 7, 11, 13, 15, 19, 21, 23, 29, 31, 33, 35, 37, 8, 10, 12, 16, 18, 22, 24, 26, 32, 36, 38, 40 };

            if (pin != -1)
            {
                picker.SelectedItem = pin;
            }
            btn.Text = dcv == null ? btn.Text : "Update Device";
        }
Exemplo n.º 5
0
 public void DeleteBtnClicked(DeviceContentView dcv)
 {
     stackLayout.Children.Remove(dcv);
     Save();
 }