private void ProcessFile()
        {
            i++;
            if (files.Length <= i || files[i] == null)
            {
                if (PushBulletAPI.GetBoolConfigurationOption(PushBullet.conf, "showDoneWindow", true))
                {
                    MessageBox.Show(Properties.Strings.UploadCompleted, "Ok", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                Application.Current.Dispatcher.BeginInvoke(new Action(() => Application.Current.Shutdown()));
                return;
            }
            Application.Current.Dispatcher.BeginInvoke(new Action(() => uploadLabel.Content = string.Format(Properties.Strings.UploadingFormatStr, Path.GetFileName(files[i]), i + 1, files.Length)));
            if (!File.Exists(files[i]))
            {
                PushBullet.ShowError(string.Format(Properties.Strings.FileDoesNotExist, files[i]));
                ProcessFile();
                return;
            }
            FileInfo info = new FileInfo(files[i]);

            if (info.Length > 0x1900000 || info.Length == 0) // 0x1900000 == 26214400 bytes == 25 MiB
            {
                PushBullet.ShowError(string.Format(Properties.Strings.IncorrectSize, files[i]));
                ProcessFile();
                return;
            }
            currentWorker                            = new BackgroundWorker();
            currentWorker.DoWork                    += RunInBackground;
            currentWorker.ProgressChanged           += UpdateProgress;
            currentWorker.RunWorkerCompleted        += UpdateUIElements;
            currentWorker.WorkerReportsProgress      = true;
            currentWorker.WorkerSupportsCancellation = true;
            Application.Current.Dispatcher.BeginInvoke(new Action(() => currentWorker.RunWorkerAsync(new string[] { deviceId, files[i] })));
        }
Beispiel #2
0
 public APIGUI2()
 {
     InitializeComponent();
     if (PushBulletAPI.HasConfigurationOption(PushBullet.conf, "apikey"))
     {
         this.apikeyInput.Text = PushBulletAPI.GetNonNullConfigurationOption(PushBullet.conf, "apikey");
     }
     this.doneWindowChkBox.IsChecked = PushBulletAPI.GetBoolConfigurationOption(PushBullet.conf, "showDoneWindow", true);
     this.Loaded += WinLoaded;
 }