예제 #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;
 }