Ejemplo n.º 1
0
        private void Lst_Devices_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Library.Core.Room _SelectedRoom = (Library.Core.Room)Lst_Main.SelectedItem;
            if (_SelectedRoom.Devices.Count > 0)
            {
                txt_DeviceName.Text = ((Library.Core.Device)Lst_Devices.SelectedItem).Name;

                foreach (var item in cmb_DevicePin.Items)
                {
                    if (((string)((ComboBoxItem)item).Content) == ((Library.Core.Device)Lst_Devices.SelectedItem).Pin.ToString())
                    {
                        cmb_DevicePin.SelectedItem = item;
                        break;
                    }
                }

                // Update Device Image
                foreach (var _ImageListClass in Lst_DeviceImage.Items)
                {
                    ImageListClass _Image = (ImageListClass)_ImageListClass;
                    if (_Image.ImagePath == ((Library.Core.Device)Lst_Devices.SelectedItem).ImagePath)
                    {
                        Lst_DeviceImage.SelectedItem = _Image;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void LoadDevices(Library.Core.Room Room, ushort RoomNumber)
        {
            this.InitializeComponent();

            Devices         = Room.Devices;
            this.RoomNumber = RoomNumber;

            foreach (var _Device in Room.Devices)
            {
                _Device _Dev = new _Device();
                _Dev.DeviceImagePath = _Device.ImagePath;
                _Dev.DeviceName      = _Device.Name;

                if (_Device.Status == Library.Core.Device.StatusEnum.On)
                {
                    _Dev.DeviceStatusColor = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 99, 0));
                }
                else
                {
                    _Dev.DeviceStatusColor = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 128, 128, 128));
                }

                _Dev.Id            = _Device.Id;
                _Dev.DeviceToolTip = "R" + RoomNumber.ToString() + "\\Dev" + _Device.Id.ToString();

                ListView_Devices.Items.Add(_Dev);
            }
            txt_RoomName.Text = Room.RoomName;
        }
        private void Btn_Save_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (LB_Rooms.Items.Count > 0 && LB_Rooms.SelectedIndex != -1)
            {
                // Update Room Detail
                Library.Core.Room SelectedRoom = (Library.Core.Room)LB_Rooms.SelectedItem;

                SelectedRoom.Name = Txt_RoomName.Text;

                int             NewAddress = 0;
                IFormatProvider _Culture   = new CultureInfo("en-US");
                int.TryParse(Txt_RoomI2CAddress.Text.Replace("0x", ""), System.Globalization.NumberStyles.HexNumber, _Culture, out NewAddress);
                SelectedRoom.I2C_Slave_Address = NewAddress;

                SelectedRoom.ImagePath = ((ImageListClass)LV_RoomImage.SelectedItem).ImagePath;

                // Update Device Detail
                if (LB_Devices.Items.Count > 0)
                {
                    if (LB_Devices.SelectedIndex != -1)
                    {
                        Library.Core.Device SelectedDevice = (Library.Core.Device)LB_Devices.SelectedItem;

                        SelectedDevice.Name = txt_DeviceName.Text;
                        SelectedDevice.Pin  = (Library.Core.Device.PinsEnum)Enum.Parse(typeof(Library.Core.Device.PinsEnum), ((ComboBoxItem)cmb_DevicePin.SelectedItem).Content.ToString());

                        SelectedDevice.ImagePath = ((ImageListClass)LV_DeviceImage.SelectedItem).ImagePath;
                    }
                }
            }

            // Save
            Library.Core.Home.SaveHome(MainPage.MyHome);
        }
Ejemplo n.º 4
0
        private void Img_Btn_RemoveDevice_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Library.Core.Room _SelectedRoom = (Library.Core.Room)Lst_Main.SelectedItem;

            if (_SelectedRoom.Devices != null && _SelectedRoom.Devices.Count > 0)
            {
                _SelectedRoom.Devices.Remove(((Library.Core.Device)Lst_Devices.SelectedItem));
                RefreshDeviceList();
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var RawData = e.Parameter as object[];
            SelectedRoom = (Library.Core.Room)RawData[0];

            UpdateTexts();
            LoadDevices();

            UpdateSensorData();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var RawData = e.Parameter as object[];

            SelectedRoom = (Library.Core.Room)RawData[0];

            UpdateTexts();
            LoadDevices();

            UpdateSensorData();
        }
        private void Btn_AddRoom_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Library.Core.Room NewRoom = new Library.Core.Room();

            NewRoom.I2C_Slave_Address = 0x40;
            NewRoom.ImagePath         = "ms-appx:///Resources/Image/Tiles/Room/Flower1.png";
            NewRoom.Name = "My Room";

            MainPage.MyHome.Rooms.Add(NewRoom);

            UpdateListBox(1);
        }
        private void UpdateRoomDetailPane(Library.Core.Room SelectedRoom)
        {
            Txt_RoomName.Text       = SelectedRoom.Name;
            Txt_RoomI2CAddress.Text = "0x" + SelectedRoom.I2C_Slave_Address.ToString("X");

            foreach (var _Image in LV_RoomImage.Items)
            {
                if (((ImageListClass)_Image).ImagePath == SelectedRoom.ImagePath)
                {
                    LV_RoomImage.SelectedItem = _Image;
                    break;
                }
            }
        }
Ejemplo n.º 9
0
        private void Img_Btn_AddNewDevice_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Library.Core.Room _SelectedRoom = (Library.Core.Room)Lst_Main.SelectedItem;

            if (_SelectedRoom.Devices == null)
            {
                _SelectedRoom.Devices = new List <Library.Core.Device>();
            }

            _SelectedRoom.Devices.Add(new Library.Core.Device()
            {
                Name = "NewDevice", Id = (ushort)_SelectedRoom.Devices.Count, ImagePath = "ms-appx:///Resource/Images/Devices/Plug_130.png"
            });
            RefreshDeviceList();
        }
Ejemplo n.º 10
0
        private void RefreshDeviceList()
        {
            if (Lst_Main.SelectedItem != null)
            {
                Library.Core.Room _SelectedRoom = (Library.Core.Room)Lst_Main.SelectedItem;

                try
                {
                    Lst_Devices.Items.Clear();
                }
                catch (Exception) { }

                if (_SelectedRoom.Devices != null && _SelectedRoom.Devices.Count > 0)
                {
                    foreach (var _Device in _SelectedRoom.Devices)
                    {
                        Lst_Devices.Items.Add(_Device);
                    }
                    Lst_Devices.SelectedIndex = 0;
                    Lst_Devices_Tapped(null, null);
                    txt_DeviceName.Text = ((Library.Core.Device)Lst_Devices.SelectedItem).Name;

                    foreach (var item in cmb_DevicePin.Items)
                    {
                        if (((string)((ComboBoxItem)item).Content) == ((Library.Core.Device)Lst_Devices.SelectedItem).Pin.ToString())
                        {
                            cmb_DevicePin.SelectedItem = item;
                            break;
                        }
                    }
                }
            }
            else
            {
                try
                {
                    Lst_Devices.Items.Clear();
                }
                catch (Exception) { }
                txt_DeviceName.Text             = "N/A";
                txt_RoomName.Text               = "N/A";
                txt_Room_I2C_Slave_Address.Text = "N/A";
            }
        }
Ejemplo n.º 11
0
        private void UpdateDeviceDetailPane(Library.Core.Room SelectedRoom, bool SelectFirst = false, bool SkipClear = false)
        {
            if (SkipClear == false)
            {
                ClearDeviceDetailPane();
            }
            if (SelectedRoom.Devices.Count > 0)
            {
                if (SkipClear == false)
                {
                    foreach (var _Device in SelectedRoom.Devices)
                    {
                        LB_Devices.Items.Add(_Device);
                    }
                }

                if (SelectFirst)
                {
                    LB_Devices.SelectedIndex = 0;
                }

                Library.Core.Device SelectedDevice = (Library.Core.Device)LB_Devices.SelectedItem;

                txt_DeviceName.Text = SelectedDevice.Name;

                foreach (ComboBoxItem item in cmb_DevicePin.Items)
                {
                    if ((string)item.Content == SelectedDevice.Pin.ToString())
                    {
                        cmb_DevicePin.SelectedItem = item;
                        break;
                    }
                }

                foreach (var _Image in LV_DeviceImage.Items)
                {
                    if (((ImageListClass)_Image).ImagePath == SelectedDevice.ImagePath)
                    {
                        LV_DeviceImage.SelectedItem = _Image;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 12
0
        // Update Right Pane with room details
        private void Lst_Main_Tapped(object sender, TappedRoutedEventArgs e)
        {
            if (Lst_Main.SelectedItem != null)
            {
                Library.Core.Room _SelectedRoom = (Library.Core.Room)Lst_Main.SelectedItem;

                foreach (var _ImageListClass in Lst_RoomImage.Items)
                {
                    ImageListClass _Image = (ImageListClass)_ImageListClass;
                    if (_Image.ImagePath == _SelectedRoom.RoomImagePath)
                    {
                        Lst_RoomImage.SelectedItem = _Image;
                        break;
                    }
                }

                txt_RoomName.Text = _SelectedRoom.RoomName;
                txt_Room_I2C_Slave_Address.Text = _SelectedRoom.I2C_Slave_Address;

                // Update Devices
                RefreshDeviceList();
            }
        }
        private void Btn_AddRoom_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Library.Core.Room NewRoom = new Library.Core.Room();

            NewRoom.I2C_Slave_Address = 0x40;
            NewRoom.ImagePath = "ms-appx:///Resources/Image/Tiles/Room/Flower1.png";
            NewRoom.Name = "My Room";

            MainPage.MyHome.Rooms.Add(NewRoom);

            UpdateListBox(1);
        }