Ejemplo n.º 1
0
        private async void SyncToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var packages = this.annotationPackageListControl.GetAllPackages().Where(o => o.IsDirty).ToArray();

            if (packages.Length == 0)
            {
                MessageBox.Show("There are no unchanged packages to sync.", "Nothing to sync!");
                return;
            }

            // Proceed with syncing
            using (var dialog = new SyncConfirmationDialog())
            {
                dialog.StartPosition = FormStartPosition.CenterParent;
                dialog.SetUnsyncedPackages(packages.ToList());

                var dialogResult = dialog.ShowDialog(this);
                if (dialogResult != DialogResult.OK)
                {
                    return;
                }
            }

            using (var syncDialog = new SyncProgressDialog(this._annotationPackageProvider))
            {
                syncDialog.StartPosition = FormStartPosition.CenterParent;
                syncDialog.Show(this);

                await syncDialog.Sync(packages);

                syncDialog.Dispose();

                this.annotationPackageListControl.RefreshDataGrid();
            }
        }
Ejemplo n.º 2
0
        private void SyncToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var packages = this.annotationPackageListControl.GetAllPackages().Where(o => o.IsDirty).ToArray();

            if (packages.Length > 0)
            {
                // Proceed with syncing
                var syncConfirmationDialog = new SyncConfirmationDialog();
                syncConfirmationDialog.Text = "Confirm syncing";
                syncConfirmationDialog.SetDescriptions("Do you want to sync the following packages?", string.Empty);
                syncConfirmationDialog.SetUnsyncedPackages(packages.ToList());

                var dialogResult = syncConfirmationDialog.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    var syncForm = new SyncProgressDialog(this._annotationPackageProvider);
                    syncForm.Show();

                    _ = Task.Run(() => syncForm.Sync(packages));

                    this.annotationPackageListControl.RefreshData();
                }
            }
            else
            {
                MessageBox.Show("There are no unchanged packages to sync.", "Nothing to sync!");
            }
        }