示例#1
0
        private async void Start()
        {
            var list = await GetFiles();

            int count = BluetoothManager.Current.FilesToShare.Count;

            foreach (var file in BluetoothManager.Current.FilesToShare)
            {
                FilesToShare.Add(file);
            }
            BluetoothManager.Current.AddFiles(list);
            foreach (var f in list)
            {
                FilesToShare.Add(f);
            }
            if (count == 0)
            {
                await StartScan();
            }
            else
            {
                DeviceListVisibility = false;
                FileListVisibility   = true;
                if (filesToShare[0].ShareStatus == FileShareStatus.Error)
                {
                    BluetoothManager.Current.StartService();
                }
            }
        }
示例#2
0
 private void ForegroundApp_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
 {
     BluetoothManager.FailedHandler            -= BluetoothManager_FailedHandler;
     BluetoothManager.ChangeProgressHandler    -= BluetoothManager_ChangeProgressHandler;
     BluetoothManager.ChangeStatusHandler      -= BluetoothManager_ChangeStatusHandler;
     BluetoothManager.RemoveFirstFileHandler   -= BluetoothManager_RemoveFirstFileHandler;
     BluetoothManager.SetDevicesListHandler    -= BluetoothManager_SetDevicesListHandler;
     BluetoothManager.TransferCompletedHandler -= BluetoothManager_TransferCompletedHandler;
     FilesToShare.Clear();
 }
示例#3
0
 async void BluetoothManager_RemoveFirstFileHandler()
 {
     await DispatcherHelper.RunAsync(() =>
     {
         if (!filesToShare.Count.Equals(0))
         {
             FilesToShare.RemoveAt(0);
         }
     });
 }
示例#4
0
 async void BluetoothManager_FailedHandler(FileItemToShare f)
 {
     await DispatcherHelper.RunAsync(() =>
     {
         FileItemToShare file = filesToShare[0];
         file.ShareStatus     = FileShareStatus.Error;
         file.Progress        = 0;
         FilesToShare.RemoveAt(0);
         FilesToShare.Add(file);
     });
 }
示例#5
0
 private void ForegroundApp_Resuming(object sender, object e)
 {
     foreach (var file in BluetoothManager.Current.FilesToShare)
     {
         FilesToShare.Add(file);
     }
     BluetoothManager.FailedHandler            += BluetoothManager_FailedHandler;
     BluetoothManager.ChangeProgressHandler    += BluetoothManager_ChangeProgressHandler;
     BluetoothManager.ChangeStatusHandler      += BluetoothManager_ChangeStatusHandler;
     BluetoothManager.RemoveFirstFileHandler   += BluetoothManager_RemoveFirstFileHandler;
     BluetoothManager.SetDevicesListHandler    += BluetoothManager_SetDevicesListHandler;
     BluetoothManager.TransferCompletedHandler += BluetoothManager_TransferCompletedHandler;
 }