async private void Button_Click(object sender, RoutedEventArgs e)
        {
            var service           = new ListDataService(db.token);
            var selectedWaypoints = waypointList.FindAll(s => s.IsSelected);
            var totalSecs         = selectedWaypoints.Count * 2;
            var mins = totalSecs / 60;
            var secs = totalSecs % 60;

            var messageBox = new Gat.Controls.MessageBoxView();
            var vm         = (Gat.Controls.MessageBoxViewModel)messageBox.FindResource("ViewModel");

            var cancelled = false;

            ThreadPool.QueueUserWorkItem(async(state) =>
            {
                foreach (var waypoint in selectedWaypoints)
                {
                    if (cancelled)
                    {
                        break;
                    }
                    var result = await service.AddWaypoint(waypoint);
                    await Task.Delay(2000);
                }
                Dispatcher.Invoke(() =>
                {
                    vm.AutoClose();
                });
            });


            vm.Message = $"Exporting waypoints. This will take approx. {mins} minutes and {secs} seconds...";


            vm.OkVisibility     = false;
            vm.CancelVisibility = true;
            vm.YesVisibility    = false;
            vm.NoVisibility     = false;

            vm.Show();

            cancelled = true;
        }
Example #2
0
        async private void Button_Click(object sender, RoutedEventArgs e)
        {
            Window window = new Window()
            {
                WindowStyle        = WindowStyle.None,
                WindowState        = System.Windows.WindowState.Maximized,
                Background         = System.Windows.Media.Brushes.Transparent,
                AllowsTransparency = true,
                ShowInTaskbar      = false,
                ShowActivated      = true,
                Topmost            = true
            };

            window.Show();
            var listName = nameTextBox.Text;

            ThreadPool.QueueUserWorkItem(async(state) =>
            {
                var caches     = db.getCaches(id);
                var cacheArray = new List <string>();
                foreach (DataRowView row in caches.Tables[0].DefaultView)
                {
                    cacheArray.Add(row["cacheCode"].ToString());
                }
                var service = new ListDataService(db.token);
                var listId  = await service.CreateList(listName);
                var result  = await service.AddToList(listId, cacheArray);

                Dispatcher.Invoke(() =>
                {
                    window.Close();
                    MessageBox.Show(window, "List Exported");
                    this.Close();
                });
            });
            var res = MessageBox.Show(window, "Exporting List...");
        }