예제 #1
0
        private async void ToolbarItem_Backup_Activated(object sender, EventArgs e)
        {
            OperationInProgress = true;
            RefreshToolbarItems();
            UploadingBackup = new BackupModel()
            {
                ProgressPercent = 0
            };
            var newList = new List <BackupModel> {
                UploadingBackup
            };

            newList.AddRange(Backups.ToList());
            Backups = new ObservableCollection <BackupModel>(newList);
            BackupsList.ItemsSource = null;
            BackupsList.ItemsSource = Backups;

            var result = await Connectivity.UploadBackupToServerAsync(new UploadFileCompleted(UploadFileCompleted), new UploadProgressChanged(UploadProgressChanged));

            if (!result.Success)
            {
                App.ShowError("خطا", result.Message, "خوب");
            }

            Backups                 = new ObservableCollection <BackupModel>(Backups.ToList().Union(new BackupModel[] { UploadingBackup }));
            UploadingBackup         = null;
            BackupsList.ItemsSource = null;
            BackupsList.ItemsSource = Backups;
            OperationInProgress     = false;
            BackupsList_Refreshing(null, null);

            App.ToastMessageHandler.ShowMessage("پشتیبان اطلاعات با موفقیت به سرور ارسال شد.", ToastMessageDuration.Long);
        }
예제 #2
0
        private void BackupsList_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            var ThisSelectedItem = (BackupModel)e.Item;

            if (ThisSelectedItem == SelectedItem)
            {
                SelectedItem.Selected = false;
                SelectedItem          = null;
            }
            else
            {
                if (SelectedItem != null)
                {
                    SelectedItem.Selected = false;
                }
                SelectedItem          = ThisSelectedItem;
                SelectedItem.Selected = true;
            }

            RefreshToolbarItems();
        }
예제 #3
0
        private async void BackupsList_Refreshing(object sender, EventArgs e)
        {
            BackupsList.IsRefreshing = true;
            await Task.Delay(100);

            var Result = await Connectivity.GetBackupListFromServerAsync();

            if (!Result.Success)
            {
                App.ShowError("خطا", "در نمایش لیست پشتیبان ها خطایی رخ داد.\n" + Result.Message, "خوب");
                BackupsList.IsRefreshing = false;
                return;
            }

            Backups = new ObservableCollection <BackupModel>(Result.Data);
            BackupsList.ItemsSource = null;
            BackupsList.ItemsSource = Backups;
            SelectedItem            = null;
            RefreshToolbarItems();

            await Task.Delay(100);

            BackupsList.IsRefreshing = false;
        }