Example #1
0
 public void SelectDevices(IEnumerable <object> selected)
 {
     if (_updatingGroupedDevices)
     {
         return;
     }
     _deviceProvider.SelectDevices(selected);
 }
Example #2
0
        public void HandleDeviceContextRequested(Devices.Device device, UIElement targetElement, Point point)
        {
            _deviceProvider.SelectDevices(new Devices.Device[] { device });

            MenuFlyout flyout = new MenuFlyout();

            MenuFlyoutItem renameItem = new MenuFlyoutItem();

            renameItem.Text   = _stringProvider.GetString("DeviceContextMenuItemRename");
            renameItem.Tag    = new Tuple <Devices.Device, UIElement>(device, targetElement);
            renameItem.Icon   = new SymbolIcon(Symbol.Rename);
            renameItem.Click += RenameItem_Click;
            flyout.Items.Add(renameItem);

            MenuFlyoutItem deleteItem = new MenuFlyoutItem();

            deleteItem.Text   = _stringProvider.GetString("DeviceContextMenuItemRemove");
            deleteItem.Tag    = new Tuple <Devices.Device, UIElement>(device, targetElement);
            deleteItem.Icon   = new SymbolIcon(Symbol.Remove);
            deleteItem.Click += DeleteItem_Click;
            flyout.Items.Add(deleteItem);

            MenuFlyoutSubItem moveItem = new MenuFlyoutSubItem();

            moveItem.Text = _stringProvider.GetString("DeviceContextMenuItemMove");
            moveItem.Icon = new SymbolIcon(Symbol.MoveToFolder);
            flyout.Items.Add(moveItem);

            foreach (var room in _deviceProvider.Rooms)
            {
                if (room.Id != device.Room.Id)
                {
                    MenuFlyoutItem roomItem = new MenuFlyoutItem();
                    roomItem.Text   = room.Caption;
                    roomItem.Tag    = new Tuple <Devices.Device, Devices.Room>(device, room);
                    roomItem.Click += OnMoveDeviceToRoom;
                    moveItem.Items.Add(roomItem);
                }
            }

            flyout.ShowAt(targetElement, point);
        }