コード例 #1
0
        // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
        // Word...

        private void ImportWord(string filepath, bool append)
        {
            if (!Office.IsWordInstalled())
            {
                UIHelper.ShowMessage("Word is not installed");
            }

            logger.StartClock();

            var completed = RunBackgroundTask(filepath, () =>
            {
                WordImporter(filepath, append);

                progressDialog.DialogResult = DialogResult.OK;
                progressDialog.Close();
            });

            if (completed)
            {
                logger.WriteTime("word file imported");
            }
            else
            {
                logger.StopClock();
            }
        }
コード例 #2
0
        void OpenServerLogFile(object o)
        {
            WebClient client = new WebClient {
                Credentials = CurrentEnvironment.Connection.HubConnection.Credentials
            };
            var dialog = new ProgressDialog();

            _progressDialogViewModel = new ProgressDialogViewModel(() => { dialog.Close(); }, delegate
            {
                dialog.Show();
            }, delegate
            {
                dialog.Close();
            });
            _progressDialogViewModel.StatusChanged("Server Log File", 0, 0);
            _progressDialogViewModel.SubLabel = "Preparing to download Warewolf Server log file.";
            dialog.DataContext = _progressDialogViewModel;
            _progressDialogViewModel.Show();
            client.DownloadProgressChanged += DownloadProgressChanged;
            client.DownloadFileCompleted   += DownloadFileCompleted;
            var managementServiceUri = WebServer.GetInternalServiceUri("getlogfile", CurrentEnvironment.Connection);
            var tempPath             = Path.GetTempPath();

            _serverLogFile = Path.Combine(tempPath, CurrentEnvironment.Connection.DisplayName + " Server Log.txt");
            client.DownloadFileAsync(managementServiceUri, _serverLogFile);
        }
コード例 #3
0
        private async void Download(BackgroundWorker worker)
        {
            tempFolder = Path.GetTempFileName();
            File.Delete(tempFolder);
            Directory.CreateDirectory(tempFolder);
            using (WebClient client = new WebClient())
            {
                client.DownloadProgressChanged += Client_DownloadProgressChanged;
                foreach (Package package in packages.CheckedItems)
                {
                    string file = Path.Combine(tempFolder, package.GetName() + ".zip");
                    try
                    {
                        await client.DownloadFileTaskAsync(package.GetURI(), file);
                    }
                    catch (WebException ex)
                    {
                        MessageBox.Show("Could not download package " + package.GetName() + ".\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        dlDialog.BeginInvoke(new Action(() => dlDialog.Close()));
                        Enabled = true;
                        return;
                    }
                }
            }
            string buildDir = Path.Combine(tempFolder, "build");

            worker.DoWork += (obj, e) =>
            {
                foreach (Package package in packages.CheckedItems)
                {
                    AddToBuild(Path.Combine(buildDir, package.GetInstallPath()), Path.Combine(tempFolder, package.GetName() + ".zip"));
                }
            };
            string build = Path.Combine(tempFolder, "build.zip");

            worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
            {
                ZipFile.CreateFromDirectory(buildDir, build);
                string emulatorsDir = "emulators";
                if (!Directory.Exists(emulatorsDir))
                {
                    Directory.CreateDirectory(emulatorsDir);
                }
                File.Move(build, Path.Combine(emulatorsDir, config.GetName() + ".zip"));
                dlDialog.BeginInvoke(new Action(() => dlDialog.Close()));
                Close();
            };
            worker.RunWorkerAsync();
        }
コード例 #4
0
        protected static Household GetImportSelection(Lot lot)
        {
            BinModel.Singleton.PopulateExportBin();

            ExportBinContents contents = new ImportSelection(BinModel.Singleton.ExportBinContents).SelectSingle() as ExportBinContents;

            if (contents == null)
            {
                return(null);
            }

            List <Household> houses = new List <Household>();

            Household household = null;

            ProgressDialog.Show(Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Global:Processing", new object[0x0]), false);

            Dictionary <string, List <News.NewsTuning.ArticleTuning> > namedArticles = News.sNewsTuning.mNamedArticles;

            try
            {
                // Doing so stops Marriage notices of imported sims from appearing in the newspaper
                News.sNewsTuning.mNamedArticles = new Dictionary <string, List <News.NewsTuning.ArticleTuning> >();

                HouseholdContentsProxy houseContents = HouseholdContentsProxy.Import(contents.PackageName);

                household = houseContents.Household;
                if (household == null)
                {
                    return(null);
                }

                List <ulong> indexMap = ExportBinContentsEx.CreateIndexMap(household);

                lot.MoveIn(household);

                CreateActors(lot);

                BinCommonEx.CreateInventories(household, houseContents.Contents, indexMap);

                BinCommon.UpdateImportedUrnstones(household, lot);

                household.FixupGenealogy();
            }
            finally
            {
                News.sNewsTuning.mNamedArticles = namedArticles;

                try
                {
                    ProgressDialog.Close();
                }
                catch
                { }
            }

            SpeedTrap.Sleep();

            return(household);
        }
コード例 #5
0
        public void RestoreWithUI(string fileName)
        {
            /// SaveAllMemos()はUIスレッドで呼び出す必要がある
            _app.SaveAllMemos();

            var dialog = new ProgressDialog();

            dialog.Text = "復元の進捗";
            dialog.Font = _app.Theme.CaptionFont;
            dialog.BackgroundWorker.DoWork             += DoRestoreAsync;
            dialog.BackgroundWorker.RunWorkerCompleted += (sender, e) => {
                if (e.Error != null)
                {
                    MessageBox.Show(_app.MainForm, "復元に失敗しました。", "復元エラー");
                }
                dialog.Close();
                dialog.Dispose();

                /// 復元前のmemoinfosなどが上書きされないように
                /// 終了時のSaveAll()を防ぐ
                _app._PreventSaveAll = true;
                Application.Restart();
            };
            dialog.Run(_app.MainForm, fileName);
        }
コード例 #6
0
        public void BackupWithUI(string fileName)
        {
            /// SaveAllMemos()はUIスレッドで呼び出す必要がある
            _app.SaveAllMemos();

            _app.SaveRecentIds();
            _app.SaveFusenFormIds();

            _app.MainForm.SaveFormSettings(_app._WindowSettings);
            MemopadSettings.SaveSettings(_app._Settings);
            MemopadWindowSettings.SaveWindowSettings(_app._WindowSettings);

            var dialog = new ProgressDialog();

            dialog.Text                                 = "バックアップの進捗";
            dialog.SupportCancel                        = true;
            dialog.Font                                 = _app.Theme.CaptionFont;
            dialog.BackgroundWorker.DoWork             += DoBackupAsync;
            dialog.BackgroundWorker.RunWorkerCompleted += (sender, e) => {
                if (e.Error != null)
                {
                    MessageBox.Show(_app.MainForm, "バックアップに失敗しました。", "バックアップエラー");
                }
                else if (e.Cancelled)
                {
                    MessageBox.Show(_app.MainForm, "バックアップをキャンセルしました。", "バックアップのキャンセル");
                }
                dialog.Close();
                dialog.Dispose();
            };
            dialog.Run(_app.MainForm, fileName);
        }
コード例 #7
0
ファイル: MemoProcessor.cs プロジェクト: rajeshwarn/MochaNote
        // ========================================
        // method
        // ========================================
        public void Process(Form owner, string caption, Action <EditorCanvas, Memo, MemoInfo> action)
        {
            if (action == null)
            {
                return;
            }

            var app    = MemopadApplication.Instance;
            var dialog = new ProgressDialog();

            dialog.Text          = caption;
            dialog.SupportCancel = true;
            dialog.Font          = app.Theme.CaptionFont;

            dialog.BackgroundWorker.DoWork             += DoProccessAsync;
            dialog.BackgroundWorker.RunWorkerCompleted += (sender, e) => {
                if (e.Error != null)
                {
                    MessageBox.Show(owner, "処理に失敗しました。", "処理エラー");
                }
                else if (e.Cancelled)
                {
                    MessageBox.Show(owner, "処理をキャンセルしました。", "処理のキャンセル");
                }
                else
                {
                    MessageBox.Show(owner, "処理を完了しました。", "処理の完了");
                }

                dialog.Close();
                dialog.Dispose();
            };
            dialog.Run(owner, action);
        }
コード例 #8
0
        private long MeasureProgressUpdateCost(bool doMakeProgressCalls, int iterationsToDo)
        {
            _dialog = new ProgressDialog();
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork           += OnDoSomeWork;
            _dialog.BackgroundWorker = worker;
            WorkArguments args = new WorkArguments();

            args.doMakeProgressCalls        = doMakeProgressCalls;
            args.secondsToUseUp             = 0;
            args.iterationsToDo             = iterationsToDo;
            _dialog.ProgressState.Arguments = args;
            Stopwatch w = new Stopwatch();

            w.Start();
            _dialog.ShowDialog();
            _dialog.Close();
            _dialog.Dispose();
            _dialog = null;
            w.Stop();
            worker.Dispose();
            Debug.WriteLine("Took " + w.Elapsed);
            return(w.ElapsedMilliseconds);
        }
コード例 #9
0
ファイル: Home.cs プロジェクト: parth281/sample
        private void backupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MsgBox.Show("Are you Sure want to Database Backup?", "Warning", MsgBox.Buttons.YesNo, MsgBox.Icon.Warning, MsgBox.AnimateStyle.FadeIn);

            if (dialogResult == DialogResult.Yes)
            {
                ProgressDialog progressDialog1  = new ProgressDialog();
                Thread         backgroundThread = new Thread(
                    new ThreadStart(() =>
                {
                    progressDialog1.SetIndeterminate(true);
                    generatebackup();
                    this.BeginInvoke((Action)(() =>
                    {
                        progressDialog1.Close();
                        if (backupdone)
                        {
                            MsgBox.Show("Backup Successfully Done.", "Information", MsgBox.Buttons.OK, MsgBox.Icon.Info, MsgBox.AnimateStyle.FadeIn);
                            backupdone = false;
                        }
                        else if (!backupdone)
                        {
                            MsgBox.Show("Backup Drive not Found or Drive Access Denied", "Error", MsgBox.Buttons.OK, MsgBox.Icon.Error, MsgBox.AnimateStyle.FadeIn);
                        }
                    }));
                }));


                backgroundThread.Start();
                progressDialog1.ShowDialog();
            }
        }
コード例 #10
0
        private IEnumerator RequestMissionData()
        {
            ProgressDialog progressDialog = ProgressDialog.Create("Fetching Missions");

            using (UnityWebRequest request = UnityWebRequest.Get(WebConfig.webAPI + "mission/get_missions.php"))
            {
                progressDialog.SetWebRequest(request);

                yield return(request.SendWebRequest());

                string error = WebConfig.GetErrorString(request);

                if (string.IsNullOrEmpty(error))
                {
                    // Success
                    MissionResponse response = MissionResponse.FromJson(request.downloadHandler.text);
                    m_Missions = response.missions;

                    PopulateMissions(m_MissionFilter);
                }
                else
                {
                    // Failure
                    Debug.Log(error);
                    InfoDialog.Create("", error.ToString());
                }
            }

            progressDialog.Close();
        }
コード例 #11
0
        public async void Update(object p)
        {
            var progressDialog = new ProgressDialog(false);

            progressDialog.Show();
            await Task.Run(() =>
            {
                using var db = MyDbContext.Instance;
                foreach (var i in Salemen)
                {
                    if (i.Id != 0)
                    {
                        db.Salesmen.Update(db, i);
                    }
                    else
                    {
                        i.Available = true;
                        db.Salesmen.Add(i);
                    }
                }
                db.SaveChanges();
            });

            progressDialog.Close();
            MainWindowViewModel.Instance.StatusText = "更新成功!";
        }
コード例 #12
0
        public void InitializeProductList()
        {
            var    dialog = new ProgressDialog();
            Action action = () => Task.Factory.StartNew(() =>
            {
                Invoke(new AsyncAction(() => product.BeginUpdate()));
                var products = DatabaseInstance.ProductTable.ToArray();
                foreach (var product in products)
                {
                    try
                    {
                        Invoke(new AsyncAction(() =>
                        {
                            this.product.Items.Add($"{product.ProductId}:{product.ProductName}");
                        }));
                    }
                    catch (ObjectDisposedException)
                    {
                        // ignore
                        break;
                    }
                }
                catch (InvalidOperationException)
                {
                    // ignore
                    break;
                }

                Invoke(new AsyncAction(() => product.EndUpdate()));
                Invoke(new AsyncAction(() =>
                {
                    dialog.DialogResult = DialogResult.OK;
                    dialog.Close();
                }));
            }, TaskCreationOptions.LongRunning);
コード例 #13
0
        private void OnMapRefreshed(MapRenderer mapRenderer)
        {
            if (m_ProgressDialog != null)
            {
                m_ProgressDialog.Close();
            }

            m_ProgressDialog = null;
        }
コード例 #14
0
ファイル: studentManager.cs プロジェクト: Datngo2001/QLSV
        //tạo proceduce
        public bool login(string username, string password)
        {
            try
            {
                if (CurrentUser.isManager == true)
                {
                    dataBase.Connection = new SqlConnection
                                              (@"Data Source=LAPTOP-CGKU0T3D;Initial Catalog=SinhVien;User ID=QLSV_Manager;Password=123");
                }
                else if (CurrentUser.isContact == true)
                {
                    dataBase.Connection = new SqlConnection
                                              (@"Data Source=LAPTOP-CGKU0T3D;Initial Catalog=SinhVien;User ID=QLSV_Contact;Password=123");
                }

                ProgressDialog progress = new ProgressDialog();
                progress.Show();

                DataTable      table   = new DataTable();
                SqlDataAdapter adapter = new SqlDataAdapter();
                dataBase.openConnection();
                SqlCommand cm = new SqlCommand(
                    "exec login_studentManager @User, @Pass", dataBase.Connection);
                cm.Parameters.Add("@User", SqlDbType.VarChar).Value = username;
                cm.Parameters.Add("@Pass", SqlDbType.VarChar).Value = password;
                adapter.SelectCommand = cm;

                progress.Bar.Value = 50;

                adapter.Fill(table);

                progress.Bar.Value = 100;

                dataBase.closeConnection();

                progress.Close();

                if (table.Rows.Count > 0)
                {
                    CurrentUser.UserName = table.Rows[0]["username"].ToString().Trim();
                    CurrentUser.isAdmin  = true;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                dataBase.closeConnection();
            }
        }
コード例 #15
0
        public void UpdateDisplayImageInfo()
        {
            ObservableCollection <ImageInfo> newInsertImage = tableImages.QueryNewInsertImage(Agencys, Patients, ImportDate, DisplayImageInfo);

            if (newInsertImage != null && newInsertImage.Count > 0)
            {
                ProgressDialog progressDialog = new ProgressDialog();

                progressDialog.Dispatcher.Invoke(() =>
                {
                    progressDialog.PText    = "載入新加入的圖片中( 0 / " + newInsertImage.Count + " )";
                    progressDialog.PMinimum = 0;
                    progressDialog.PValue   = 0;
                    progressDialog.PMaximum = newInsertImage.Count;
                    progressDialog.Show();
                });

                //multi - thread
                Task t = Task.Factory.StartNew(() =>
                {
                    foreach (ImageInfo ii in newInsertImage)
                    {
                        ii.BitmapImage = new CreateBitmapImage().BitmapImageShow(ii.Image_FullPath, 800);
                        DisplayImageInfo.Add(ii);

                        progressDialog.Dispatcher.Invoke(() =>
                        {
                            progressDialog.PValue++;
                            progressDialog.PText = "圖片載入中( " + progressDialog.PValue + " / " + newInsertImage.Count + " )";
                        });

                        UpdateImageInfo();
                    }
                    //Parallel.ForEach(newInsertImage, ii =>
                    //{
                    //    ii.BitmapImage = new CreateBitmapImage().BitmapImageShow(ii.Image_FullPath, 800);
                    //    DisplayImageInfo.Add(ii);

                    //    progressDialog.Dispatcher.Invoke(() =>
                    //    {
                    //        progressDialog.PValue++;
                    //        progressDialog.PText = "圖片載入中( " + progressDialog.PValue + " / " + newInsertImage.Count + " )";
                    //    });

                    //    UpdateImageInfo();
                    //});
                }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Current).ContinueWith(cw =>
                {
                    progressDialog.Dispatcher.Invoke(() =>
                    {
                        progressDialog.PText = "載入完成";
                        progressDialog.Close();
                    });
                    GC.Collect();
                });
            }
        }
コード例 #16
0
        public override void Apply()
        {
            try
            {
                List <SimDescription> allSims = new List <SimDescription>();
                if (mSourceSimList != null)
                {
                    foreach (KeyValuePair <ISimDescription, bool> pair in mSourceSimList)
                    {
                        SimDescription sim = pair.Key as SimDescription;
                        if (sim == null)
                        {
                            continue;
                        }

                        allSims.Add(sim);
                    }
                }

                if (mTargetSimList != null)
                {
                    foreach (KeyValuePair <ISimDescription, bool> pair in mTargetSimList)
                    {
                        SimDescription sim = pair.Key as SimDescription;
                        if (sim == null)
                        {
                            continue;
                        }

                        allSims.Add(sim);
                    }
                }

                using (DreamCatcher.HouseholdStore store = new DreamCatcher.HouseholdStore(allSims, Mover.Settings.mDreamCatcher))
                {
                    try
                    {
                        SplitMergeHouseholds += OnMerge;

                        base.Apply();
                    }
                    catch (Exception e)
                    {
                        Common.Exception("Apply", e);
                    }
                    finally
                    {
                        SplitMergeHouseholds -= OnMerge;

                        ProgressDialog.Close();
                    }
                }
            }
            catch (ExecutionEngineException)
            { }
        }
コード例 #17
0
        private async void Download(BackgroundWorker worker)
        {
            tempFolder = Path.GetTempFileName();
            File.Delete(tempFolder);
            Directory.CreateDirectory(tempFolder);
            string buildDir = Path.Combine(tempFolder, "build");

            using (WebClient client = new WebClient())
            {
                client.DownloadProgressChanged += Client_DownloadProgressChanged;
                foreach (Package package in packages.CheckedItems)
                {
                    try
                    {
                        await package.Download(client, tempFolder);

                        DirectoryInfo dir = await package.Unpack();

                        AddToBuild(Path.Combine(buildDir, package.GetInstallPath()), dir);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Could not download package " + package.GetName() + ".\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        dlDialog.BeginInvoke(new Action(() => dlDialog.Close()));
                        Enabled = true;
                        return;
                    }
                }
            }
            string build = Path.Combine(tempFolder, "build.zip");

            ZipFile.CreateFromDirectory(buildDir, build);
            string emulatorsDir = "emulators";

            if (!Directory.Exists(emulatorsDir))
            {
                Directory.CreateDirectory(emulatorsDir);
            }
            File.Move(build, Path.Combine(emulatorsDir, config.GetName() + ".zip"));
            dlDialog.BeginInvoke(new Action(() => dlDialog.Close()));
            Close();
        }
コード例 #18
0
        public async void VerifyRescueCode()
        {
            var progressBlock1 = new Progress <KeyValuePair <int, string> >();
            var progressBlock2 = new Progress <KeyValuePair <int, string> >();
            var progressDialog = new ProgressDialog(new List <Progress <KeyValuePair <int, string> > >()
            {
                progressBlock1, progressBlock2
            });

            _ = progressDialog.ShowDialog(_mainWindow);

            var block1Task = SQRL.DecryptBlock1(this.Identity, this.Password, progressBlock1);
            var block2Task = SQRL.DecryptBlock2(this.Identity, SQRL.CleanUpRescueCode(this.RescueCode), progressBlock2);
            await Task.WhenAll(block1Task, block2Task);

            progressDialog.Close();

            string msg = "";

            if (!block1Task.Result.DecryptionSucceeded)
            {
                msg = _loc.GetLocalizationValue("InvalidPasswordMessage") + Environment.NewLine;
            }
            if (!block2Task.Result.DecryptionSucceeded)
            {
                msg = _loc.GetLocalizationValue("InvalidRescueCodeMessage") + Environment.NewLine;
            }

            if (!string.IsNullOrEmpty(msg))
            {
                await new MessageBox(_loc.GetLocalizationValue("ErrorTitleGeneric"), $"{msg}",
                                     MessageBoxSize.Medium, MessageBoxButtons.OK, MessageBoxIcons.ERROR)
                .ShowDialog <MessagBoxDialogResult>(_mainWindow);
            }
            else
            {
                try
                {
                    _identityManager.ImportIdentity(this.Identity, true);
                }
                catch (InvalidOperationException e)
                {
                    await new Views.MessageBox(_loc.GetLocalizationValue("ErrorTitleGeneric"),
                                               e.Message, MessageBoxSize.Medium,
                                               MessageBoxButtons.OK, MessageBoxIcons.ERROR)
                    .ShowDialog <MessagBoxDialogResult>(_mainWindow);
                }
                finally
                {
                    ((MainWindowViewModel)_mainWindow.DataContext).Content =
                        new ExportIdentityViewModel();
                }
            }
        }
        private void Done()
        {
            // we have to hide the dialog first otherwise it will stick around until the auto connect has completed
            m_Progress.Hide();
            m_Progress.Close();

            if (convertAndCloseAutomatically == true)
            {
                Close();
            }
        }
コード例 #20
0
        private void ComicReader_ReportProgress(object sender, ComicReader.ProgressArgs e)
        {
            progDialog.SetMaximumValueAsync(e.TotalRecords);
            progDialog.UpdateProgressAsync(e.TotalProcessed);
            progDialog.SetDescriptionAsync(e.Description);
            backgroundProcessDone = e.IsDoneProcessing;

            if (backgroundProcessDone)
            {
                progDialog.BeginInvoke(new Action(() => progDialog.Close()));
            }
        }
コード例 #21
0
        public void LoadAllTemplatesImages(ObservableCollection <Templates_Images> observableCollection, Grid grid, int templateImagePixelWidth)
        {
            try
            {
                if (observableCollection.Count() > 0)
                {
                    ProgressDialog progressDialog = new ProgressDialog();
                    progressDialog.Dispatcher.Invoke(() =>
                    {
                        progressDialog.PText    = "圖片載入中( 0 / " + observableCollection.Count() + " )";
                        progressDialog.PMinimum = 0;
                        progressDialog.PValue   = 0;
                        progressDialog.PMaximum = observableCollection.Count();
                        progressDialog.Show();
                    });
                    //multi - thread
                    Task.Factory.StartNew(() =>
                    {
                        foreach (Templates_Images ti in observableCollection)
                        {
                            if (!string.IsNullOrEmpty(ti.Image_Path) && PathCheck.IsFileExist(ti.Image_Path))
                            {
                                grid.Dispatcher.Invoke(() =>
                                {
                                    Image iTarget  = (Image)grid.FindName("Image" + ti.Template_Image_Number);
                                    iTarget.Uid    = ti.Template_Image_ID.ToString();
                                    iTarget.Source = new CreateBitmapImage().BitmapImageShow(ti.Image_Path, templateImagePixelWidth);
                                });
                            }
                            progressDialog.Dispatcher.Invoke(() =>
                            {
                                progressDialog.PValue++;
                                progressDialog.PText = "圖片載入中( " + progressDialog.PValue + " / " + observableCollection.Count() + " )";
                            });
                        }
                    }).ContinueWith(t =>
                    {
                        progressDialog.Dispatcher.Invoke(() =>
                        {
                            progressDialog.PText = "載入完成";
                            progressDialog.Close();
                        });

                        GC.Collect();
                    });
                }
            }
            catch (Exception ex)
            {
                ErrorLog.ErrorMessageOutput(ex.ToString());
                MessageBox.Show("載入樣板圖片發生錯誤", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #22
0
        public LoginPageViewModel(INavigationService navigationService, IUserService userService)
        {
            _navigationService = navigationService;

            ProgressDialogPopup = new ProgressDialog();
            LoginCommand        = DelegateCommand.FromAsyncHandler(
                async() =>
            {
                try
                {
                    ProgressDialogPopup.Open(this);

                    var token = await userService.ValidateUserAsync(this.UserName, this.Password);

                    if (token != null)
                    {
                        ApplicationData.Current.RoamingSettings.Values[Constants.ACCESSTOKEN] = JsonConvert.SerializeObject(token);
                        var userInfo = await userService.GetUserInfoAsync(this.UserName);
                        if (userInfo != null)
                        {
                            ApplicationData.Current.RoamingSettings.Values[Constants.USERINFO] = JsonConvert.SerializeObject(userInfo);
                            navigationService.ClearHistory();
                            navigationService.Navigate("Main", string.Empty);
                        }
                    }

                    ProgressDialogPopup.Close();
                }
                catch (Exception ex)
                {
                    ProgressDialogPopup.Close();
                }
                finally
                {
                    IsLoggingIn = false;
                }
            },

                () => { return(!string.IsNullOrEmpty(this.username) && !string.IsNullOrEmpty(this.password)); });
        }
コード例 #23
0
        public LoginPageViewModel(INavigationService navigationService, IAccountService accountService)
        {
            _navigationService  = navigationService;
            _accountService     = accountService;
            ProgressDialogPopup = new ProgressDialog();

            LoginCommand = DelegateCommand.FromAsyncHandler(
                async() =>
            {
                try
                {
                    ProgressDialogPopup.Open(this);
                    IsLoggingIn = true;
                    var result  = await _accountService.SignInAsync(this.UserName, this.Password, this.ShouldSaveCredential);
                    if (result.Item1 != null)
                    {
                        string jsonUserInfo = JsonConvert.SerializeObject(result.Item1);
                        navigationService.Navigate("Main", jsonUserInfo);
                    }
                    else
                    {
                        ProgressDialogPopup.Close();
                        ErrorMessage = result.Item2;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    ProgressDialogPopup.Close();
                    IsLoggingIn = false;
                }
            },

                () => { return(!string.IsNullOrEmpty(this.username) && !string.IsNullOrEmpty(this.password)); });
        }
コード例 #24
0
        public async Task RunTaskAsync(string title, Action <CancellationToken, IProgress <int> > task, Action <int> progressUpdate, Action taskCompleted)
        {
            if (_task != null)
            {
                throw new Exception("A task is already running.");
            }

            cancellationTokenSource = new CancellationTokenSource();
            cancellationToken       = cancellationTokenSource.Token;

            TaskStarted?.Invoke(this, null);

            _progressDialog = new ProgressDialog(this, _owner, $"Task - {title}", Maximum, Interval);
            _progressDialog.Show();

            var progress = new Progress <int>(percent =>
            {
                progressUpdate(percent);
            });

            try
            {
                _task = Task.Run(() =>
                {
                    task(cancellationToken, progress);
                }, cancellationToken);

                // wait for worker task to finish.
                await _task;
            }
            catch (TaskCanceledException)
            {
                Console.WriteLine("Task cancelled.");
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }

            SystemSounds.Beep.Play();

            taskCompleted();

            _progressDialog.Close();

            TaskCompleted?.Invoke(this, null);

            _progressDialog = null;
            _task           = null;
        }
コード例 #25
0
        public override void Execute(params object[] args)
        {
            using (var dialog = new PageNumberingDialog())
            {
                if (dialog.ShowDialog(owner) == DialogResult.OK)
                {
                    using (one = new OneNote())
                    {
                        var section = one.GetSection();
                        ns = one.GetNamespace(section);

                        var pages = section.Elements(ns + "Page")
                                    .Select(e => new PageBasics
                        {
                            ID    = e.Attribute("ID").Value,
                            Name  = e.Attribute("name").Value,
                            Level = int.Parse(e.Attribute("pageLevel").Value)
                        })
                                    .ToList();

                        if (pages?.Count > 0)
                        {
                            logger.StartClock();

                            var index = 0;

                            if (dialog.CleanupNumbering)
                            {
                                cleaner = new RemovePageNumbersCommand();
                            }

                            using (progress = new ProgressDialog())
                            {
                                progress.SetMaximum(pages.Count);
                                progress.Show(owner);

                                ApplyNumbering(
                                    pages, ref index, pages[0].Level,
                                    dialog.NumericNumbering, string.Empty);

                                progress.Close();
                            }

                            logger.StopClock();
                            logger.WriteTime("numbered pages");
                        }
                    }
                }
            }
        }
コード例 #26
0
        private void Done()
        {
            // we have to hide the dialog first otherwise it will stick around until the auto connect has completed
            m_Progress.Hide();
            m_Progress.Close();

            if (m_Successful == true && Options.SearchForConnectionsAfterSuccessfulUpload == true)
            {
                OnAutoConnectRequest();
            }

            m_UploadButton.Enabled = true;
            pathSelector.Enabled   = true;
        }
コード例 #27
0
        protected virtual OptionResult RunAll(List <IMiniSimDescription> sims)
        {
            bool applyAll = ApplyAll || AutoApplyAll();

            ApplyAll = false;

            bool singleSelection = (sims.Count == 1);

            try
            {
                bool progressDisplayed = false;

                foreach (IMiniSimDescription sim in sims)
                {
                    if ((ApplyAll) && (ShowProgress) && (!progressDisplayed))
                    {
                        ProgressDialog.Show(Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Global:Processing", new object[0x0]), false);
                        progressDisplayed = true;
                    }

                    if (!Run(sim, singleSelection))
                    {
                        return(OptionResult.Failure);
                    }

                    if (applyAll)
                    {
                        ApplyAll = true;
                    }
                    else if (!mAskedAndAnswered)
                    {
                        mAskedAndAnswered = true;

                        if (sims.Count > 1)
                        {
                            if (AcceptCancelDialog.Show(Common.Localize("SimInteraction:ApplyAll")))
                            {
                                ApplyAll = true;
                            }
                        }
                    }
                }
            }
            finally
            {
                ProgressDialog.Close();
            }

            return(RunResult);
        }
コード例 #28
0
            private void ImportSectionLinks(string selectedItem)
            {
                var retstring = selectedItem;
                var pDialog   = new ProgressDialog();

                try
                {
                    var owner = new Win32Window(Process.GetCurrentProcess().MainWindowHandle);
                    pDialog.Show(owner);
                    var selTopic = _mindManager.ActiveDocument.Selection.PrimaryTopic;
                    if (selTopic != null)
                    {
                        var pageIds = OnenoteUtils.GetSectionPageIds(retstring);
                        int count   = pageIds.Count();
                        int block   = 100 / count;
                        pDialog.Progress = 100 % count;
                        string mmLink;
                        foreach (var pageId in pageIds)
                        {
                            mmLink = OnenoteUtils.GetMindManagerLink(pageId);
                            var hl = Utils.GetMindManagerLink(mmLink);

                            pDialog.Progress += block;
                            pDialog.Message   = hl.Title;
                            Topic topic = selTopic.AddSubTopic(hl.Title);
                            if (!string.IsNullOrEmpty(mmLink))
                            {
                                Hyperlink hyperlink = topic.Hyperlinks.AddHyperlink(hl.Text);
                                hyperlink.Arguments = hl.Argument;
                            }

                            Application.DoEvents();
                            //_MindManager.ActiveDocument.Save();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error importing section: " + ex.Message);
                }
                finally
                {
                    pDialog.Close();
                }
            }
コード例 #29
0
ファイル: AbstractLibrary.cs プロジェクト: gfdittmer/FindArt
        /// <summary>
        /// Creates Artist and Album objects from the
        /// provided library track paths
        /// </summary>
        /// <param name="paths">List of all track paths in the library</param>
        protected void readArtistsAndAlbums(List <string> paths)
        {
            ProgressDialog progressDialog = new ProgressDialog(0, paths.Count);

            progressDialog.Show();

            bool isProperStructure = detectProperFolderStructure(paths);

            int progressCounter = 0;

            foreach (var path in paths)
            {
                ArtistAlbumPair aaPair;
                if (isProperStructure)
                {
                    aaPair = Util.getArtistAndAlbumFromPath(path);
                }
                else
                {
                    aaPair = Util.getArtistAndAlbumFromTag(path);
                }

                Artist artist; Album album;
                artists.TryGetValue(aaPair.artist.ToLower(), out artist);
                if (artist == null)
                {
                    artist = new Artist(aaPair.artist);
                    album  = new Album(aaPair.album);
                    artist.addAlbum(album);
                    artists.Add(artist.ArtistName.ToLower(), artist);
                }
                else
                {
                    artist.Albums.TryGetValue(aaPair.album.ToLower(), out album);
                    if (album == null)
                    {
                        album = new Album(aaPair.album);
                        artist.addAlbum(album);
                    }
                }
                album.addTrackPath(path);
                progressDialog.updateLazily(++progressCounter);
            }
            progressDialog.Close();
        }
コード例 #30
0
        protected override void OnPerform()
        {
            try
            {
                if ((mCurrentOnly) && (mSim.CreatedSim != null))
                {
                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(mSim, new CASParts.Key(mSim.CreatedSim)))
                    {
                        builder.Builder.RemoveParts(mTypes);
                    }
                }
                else
                {
                    ProgressDialog.Show(Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Global:Processing", new object[0x0]), false);

                    SavedOutfit.Cache cache = new SavedOutfit.Cache(mSim);

                    foreach (SavedOutfit.Cache.Key outfit in cache.Outfits)
                    {
                        using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(mSim, outfit.mKey))
                        {
                            builder.Builder.RemoveParts(mTypes);
                        }
                    }
                }

                if (mSim.CreatedSim != null)
                {
                    SimOutfit currentOutfit = mSim.CreatedSim.CurrentOutfit;
                    if (currentOutfit != null)
                    {
                        ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, mSim.AgeGenderSpecies);
                    }
                }

                if (mPostPerform != null)
                {
                    mPostPerform();
                }
            }
            finally
            {
                ProgressDialog.Close();
            }
        }