async protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            DeviceClassTitle.Text = "";
            foreach (Type ty in classes)
            {
                if (DeviceClassTitle.Text.Length > 0)
                {
                    DeviceClassTitle.Text += ", ";
                }
                DeviceClassTitle.Text += SelectDeviceClass.ShortClassName(ty);
            }

            preferredDeviceName   = MainPage.Current.PreferredDeviceName;
            PreferredItemBox.Text = DeviceInfoToDisplayName();

            // optionally wait on list to be built out, if not watchers yet
            if (PosDeviceWatchers.PosWatchers == null)
            {
                BusySignal.IsActive = true;
                await CreateDeviceList_OneTime(classes);

                BusySignal.IsActive = false;
            }

            // setup of watchers to add/delete/update list
            PosDeviceWatchers.CombinedWatcherCallback = new DeviceClassWatcherCallbackRoutine(SelectionList);
        }
Пример #2
0
        public static async void ListUpdate(CoreDispatcher coreDispatcher, ListOperation oper, Type ty, DeviceInformation deviceInfo = null, string Id = null, string Name = null)
        {
            if (SelectionList == null)
            {
                return;
            }
            await coreDispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                if (SelectionList == null)
                {
                    return;
                }
                switch (oper)
                {
                case ListOperation.Add:
                    SelectDeviceClass sdc = new SelectDeviceClass();
                    sdc.DeviceClass       = ty;
                    sdc.DeviceName        = deviceInfo.Name;
                    sdc.DeviceId          = deviceInfo.Id;
                    SelectionList.Add(sdc);
                    break;

                case ListOperation.Delete:
                    for (int index = 0; index < SelectionList.Count; ++index)
                    {
                        if (SelectionList[index].DeviceId == Id)
                        {
                            SelectionList.RemoveAt(index);
                            break;
                        }
                    }
                    break;

                case ListOperation.Update:
                    for (int index = 0; index < SelectionList.Count; ++index)
                    {
                        if (SelectionList[index].DeviceId == Id)
                        {
                            // TBD
                            break;
                        }
                    }
                    break;
                }
            });
        }
 void AddToSelectionList(Type ty, DeviceInformationCollection collection)
 {
     if (SelectionList == null)
     {
         SelectionList = new ObservableCollection <SelectDeviceClass>();
     }
     if (collection != null)
     {
         foreach (DeviceInformation di in collection)
         {
             SelectDeviceClass sdc = new SelectDeviceClass();
             sdc.DeviceClass = ty;
             sdc.DeviceName  = di.Name;
             sdc.DeviceId    = di.Id;
             SelectionList.Add(sdc);
         }
     }
 }