예제 #1
0
 private async System.Threading.Tasks.Task SyncDataAsync()
 {
     if (!DataSync.IsBusy)
     {
         //  ProgressBar.Max = DataSync.ProgressMax;
         await DataSync.Download();
     }
     // IconsDataSync IconsDataSync = new IconsDataSync(this);
     // await IconsDataSync.Download(2);
 }
예제 #2
0
        private async void SyncData()
        {
            var DataSync = new DataSync();

            IsSyncing = true;
            DataSync.DataSyncCompleted += (o, e) =>
            {
                LoadProgressBar.Hide();
                ProgressView.Visibility = ViewStates.Gone;
                EncryptView.Visibility  = ViewStates.Gone;
                SyncLayout.Visibility   = ViewStates.Gone;
                IsSyncing = false;
                PopulatMainMenuAsync();
            };
            DataSync.ProgressChanged += (o, e) =>
            {
                SyncLayout.Visibility    = ViewStates.Visible;
                LoadProgressBar.Progress = e.Progress;
                ProgressView.Visibility  = ViewStates.Visible;
                EncryptView.Visibility   = ViewStates.Visible;
                IsSyncing         = true;
                ProgressView.Text = e.Message;
            };
            DataSync.DataSyncFailed += (o, e) =>
            {
                MessageBox.Show(this, e.Message, "We could not sync");
                SyncLayout.Visibility = ViewStates.Gone;
                LoadProgressBar.Hide();
                ProgressView.Visibility = ViewStates.Gone;
                EncryptView.Visibility  = ViewStates.Gone;
                IsSyncing = false;
                PopulatMainMenuAsync();
            };
            if (!DataSync.IsBusy)
            {
                SyncLayout.Visibility = ViewStates.Visible;
                LoadProgressBar.Show();
                ProgressView.Visibility = ViewStates.Visible;
                LoadProgressBar.Max     = DataSync.ProgressMax;
                IsSyncing = true;
                await DataSync.Download();
                await LocationAsync();
            }
        }