Exemplo n.º 1
0
        private void RepConnectionWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs args)
        {
            try
            {
                switch ((Model.ServerStatus.ServerStatusENumSwitch)args.Result)
                {
                case Model.ServerStatus.ServerStatusENumSwitch.ServerIsConnected:
                    _repConnectionWorker.CancelAsync();
                    _progressForm.Close();
                    _status = true;
                    break;

                case Model.ServerStatus.ServerStatusENumSwitch.ConnectionFailed:
                    _progressForm.Close();
                    _repConnectionWorker.CancelAsync();
                    break;
                }
            }
            catch
            {
                DisplayPanelServerError.Text = @"|  Ошибка соединения: Произошел сбой при переподключении. Попробуйте переподключиться вручную.";
                DisplayPanel.ForeColor       = Color.PaleVioletRed;
                DisplayPanelServerError.Font = new Font("Segoe UI Symbo", 12F, FontStyle.Regular);
            }
        }
Exemplo n.º 2
0
        public static void ExecAsync(Action<IProgressReporter> userMethod, string caption, bool cancellable)
        {
            var syncContext = SynchronizationContext.Current;
            Debug.Assert(syncContext is WindowsFormsSynchronizationContext);

            Action wrapper = delegate {
                Debug.Assert(syncContext is WindowsFormsSynchronizationContext);
                isRunning = true;
                try {
                    using (var dialog = new ProgressForm {
                        Caption = caption,
                        Maximum = -1,
                        CanCancel = cancellable
                    })
                    using (var waiter = new ManualResetEvent(false)) {
                        ThreadPool.QueueUserWorkItem(delegate {
                            try {
                                userMethod(dialog);
                            } catch (Exception ex) {
                                syncContext.Post(delegate {
                                    var task = Char.ToLower(caption[0]) + caption.Substring(1).TrimEnd('.');
                                    XtraMessageBox.Show("An error occurred while " + task + ".\r\n\r\n" + ex, "Shomrei Torah Schedulizer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    dialog.Close();
                                }, null);
                                return;
                            } finally { waiter.Set(); }
                            syncContext.Post(_ => dialog.Close(), null);
                        });

                        if (waiter.WaitOne(TimeSpan.FromSeconds(.5), false))
                            return;	//If it finishes very quickly, don't show progress.  Otherwise, we get an annoying focus bounce whenever we switch cells

                        dialog.ShowDialog();
                    }
                } finally {
                    isRunning = false;
                    if (pendingActions.Count > 0)
                        BeginInvoke(pendingActions.Dequeue());
                }
            };

            if (isRunning)
                pendingActions.Enqueue(wrapper);
            else {
                isRunning = true;	//In case we get called again in this message loop before the wrapper starts
                BeginInvoke(wrapper);
            }
        }
Exemplo n.º 3
0
 public void StopProgress()
 {
     if (form != null && !form.IsDisposed)
     {
         form.Close();
     }
 }
Exemplo n.º 4
0
        private bool GenerateSpriteSignatures(ref ClientItems items)
        {
            if (items.SignatureCalculated)
            {
                return(true);
            }

            ProgressForm progress = new ProgressForm();

            progress.StartPosition = FormStartPosition.Manual;
            progress.Location      = new Point(Location.X + ((Width - progress.Width) / 2), Location.Y + ((Height - progress.Height) / 2));
            progress.bar.Minimum   = 0;
            progress.bar.Maximum   = items.Count;
            progress.Show(this);
            progress.progressLbl.Text = "Calculating image signatures...";

            foreach (ClientItem clientItem in items.Values)
            {
                clientItem.GenerateSignature();

                if (progress.bar.Value % 20 == 0)
                {
                    Application.DoEvents();
                }

                progress.bar.Value++;
            }

            items.SignatureCalculated = true;
            progress.Close();
            return(true);
        }
Exemplo n.º 5
0
        private async void buttonEditUser_Click(object sender, EventArgs e)
        {
            ClearErrorProvidres();
            BuildUser();
            try
            {
                AuthenticationServiceClient client = new AuthenticationServiceClient();
                Form frm = new ProgressForm();
                frm.Show();

                OperationResult serviceResult = await client.UpdateUserAsync(user);

                frm.Close();
                if (CheckServiceResult(serviceResult))
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
            catch (FaultException <Models.Faults.InvalidRoleFault> exc)
            {
                MessageBox.Show(exc.Message);
            }
            catch (FaultException exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Exemplo n.º 6
0
 private void bExtractAll_Click(object sender, EventArgs e)
 {
     if (SaveAllDialog.ShowDialog() == DialogResult.OK)
     {
         var pf = new ProgressForm(false);
         pf.Text = "Unpacking archive";
         pf.EnableCancel();
         pf.SetProgressRange(Files.Length);
         pf.Show();
         var count = 0;
         try
         {
             foreach (var fe in Files)
             {
                 fe.Extract(SaveAllDialog.SelectedPath, true, br, ContainsFileNameBlobs);
                 pf.UpdateProgress(count++);
                 Application.DoEvents();
             }
         }
         catch (fommCancelException)
         {
             MessageBox.Show("Operation cancelled", "Message");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error");
         }
         pf.Unblock();
         pf.Close();
     }
 }
Exemplo n.º 7
0
        private async void CreateUserButtonClick(object sender, EventArgs e)
        {
            ClearErrorProvidres();
            if (!ValidateUserData())
            {
                return;
            }

            User user = BuildNewUser();

            try
            {
                AuthenticationServiceClient client = new AuthenticationServiceClient();
                Form frm = new ProgressForm();
                frm.Show();
                OperationResult serviceResult = await client.CreateUserAsync(user, textBoxPassword.Text);

                frm.Close();
                if (CheckServiceResult(serviceResult))
                {
                    Close();
                }
            }
            catch (FaultException <InvalidRoleFault> exc)
            {
                MessageBox.Show(exc.Message);
            }
            catch (FaultException exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Exemplo n.º 8
0
        public static bool ShowMainOnline(DataSet ds, bool isLoadLastGame)
        {
            App.Model.Db.Game dbGame = App.Model.Db.Game.CreateGame(Ap.Cxt, ds);
            if (dbGame == null)
            {
                return(false);
            }

            Ap.NewGame();
            MainOnline mainOnlineForm = new InfinityChess.WinForms.MainOnline();

            frmProgress = ProgressForm.Show(mainOnlineForm, "Loading...");

            mainOnlineForm.Game        = Ap.Game;
            mainOnlineForm.Game.DbGame = dbGame;

            if (isLoadLastGame)
            {
                SetUserEngine(mainOnlineForm.Game);
            }

            mainOnlineForm.Show();
            mainOnlineForm.LoadGame();

            frmProgress.Close();

            ActivateMainForm(mainOnlineForm);

            return(true);
        }
Exemplo n.º 9
0
        public static bool LoadGameByChallengeID(int challengeID)
        {
            DataSet ds = SocketClient.AddGameData(challengeID, PlayingModeData.Instance.ChessTypeID);

            if (ds == null || ds.Tables.Count == 0)
            {
                return(false);
            }

            Ap.NewGame();
            MainOnline mainOnlineForm = new InfinityChess.WinForms.MainOnline();

            frmProgress = ProgressForm.Show(mainOnlineForm, "Loading...");

            mainOnlineForm.Game = Ap.Game;
            mainOnlineForm.Show();
            mainOnlineForm.Game.DbGame = App.Model.Db.Game.CreateGame(Ap.Cxt, ds);

            if (mainOnlineForm.Game.DbGame != null)
            {
                mainOnlineForm.NewGame();
            }

            frmProgress.Close();

            ActivateMainForm(mainOnlineForm);
            return(true);
        }
        private async void buttonChangePassword_Click(object sender, EventArgs e)
        {
            ClearErrorProvidres();
            if (!ValidateUserData())
            {
                return;
            }
            try
            {
                AuthenticationServiceClient client = new AuthenticationServiceClient();
                Form frm = new ProgressForm();
                frm.Show();
                OperationResult serviceResult = await client.ChangePasswordAsync(user, textBoxNewPassword.Text);

                frm.Close();
                if (serviceResult.Success)
                {
                    Close();
                }
                if (serviceResult.Errors.Contains(OperationErrors.PassErr))
                {
                    errorProviderNewPassword.SetError(textBoxNewPassword, "Password is not valid!");
                }
            }
            catch (FaultException exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Exemplo n.º 11
0
        public void OnCompleteReport(object sender, RunWorkerCompletedEventArgs e)
        {
            progressForm.Close();
            conn.Dispose();

            var       result       = (Tuple <string, IWorkbook>)e.Result;
            string    errorMessage = result.Item1;
            IWorkbook workBook     = result.Item2;

            mainForm.Enable();

            if (!string.IsNullOrEmpty(errorMessage))
            {
                var errorMessageForm = new QueryForm(errorMessage);
                errorMessageForm.Text = "Ошибки при выполнении запроса";
                errorMessageForm.ShowDialog();
            }
            else if (workBook != null)
            {
                openSaveFileForm = new OpenSaveFileForm(workBook);
                openSaveFileForm.ShowDialog((Form)mainForm);
            }

            loader.Dispose();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Exports the page to DB using a WS
        /// </summary>
        /// <param name="page">Page.</param>
        /// <param name="mode">Export mode.</param>
        public void ExportTransition(Page page)
        {
            PageReport report;

            try
            {
                _form.Show();
                report = _transition.ExportPage(page);
            }
            finally
            {
                _form.Close();
            }

            ShowReport(report, true);
        }
Exemplo n.º 13
0
        private void AfterRecordProcessing(CancellationToken token, Task task)
        {
            _frmProgress.Close();
            if (token.IsCancellationRequested)
            {
                ObjectSpace.Rollback();
                XtraMessageBox.Show(
                    Resources.ExcelImportWizard_BgWorkerRunWorkerCompleted_The_task_has_been_cancelled,
                    Resources.ExcelImportWizard_BgWorkerRunWorkerCompleted_Work_Canceled, MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
            }
            else if (task.Exception != null && task.Exception.InnerExceptions.Any())
            {
                ObjectSpace.Rollback();
                XtraMessageBox.Show(
                    Resources.ExcelImportWizard_BgWorkerRunWorkerCompleted_Error__Details__ +
                    Tracing.Tracer.FormatExceptionReport(task.Exception),
                    Resources.ExcelImportWizard_BgWorkerRunWorkerCompleted_Error, MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
            else
            {
                ObjectSpace.CommitChanges();
                XtraMessageBox.Show(
                    Resources.ExcelImportWizard_BgWorkerRunWorkerCompleted_The_task_has_been_completed__Results__);
            }

            WizardControl.SelectedPage = completionWizardPage1;
        }
        private async void SearchUserButton_Click(object sender, EventArgs e)
        {
            try
            {
                AuthenticationServiceClient client = new AuthenticationServiceClient();
                string roleName = comboBoxRole.Text;
                if (roleName.ToLower().Equals("all roles"))
                {
                    roleName = "";
                }
                Form frm = new ProgressForm();
                frm.Show();
                User[] users = await client.SearchUserAsync(textBoxLogin.Text, textBoxFullName.Text, roleName);

                frm.Close();
                dataGridViewSearch.DataSource = new BindingList <ClientUser>(users.Select(user => new ClientUser(user)).ToList());
                if (users.Length == 0)
                {
                    MessageBox.Show("Users not found!");
                }
            }
            catch (FaultException exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Exemplo n.º 15
0
 private void bExtractAll_Click(object sender, EventArgs e)
 {
     if (SaveAllDialog.ShowDialog() == DialogResult.OK)
     {
         ProgressForm pf = new ProgressForm("Unpacking archive", false);
         pf.EnableCancel();
         pf.SetProgressRange(Files.Length);
         pf.Show();
         int count = 0;
         try
         {
             foreach (BSAFileEntry fe in Files)
             {
                 fe.Extract(SaveAllDialog.SelectedPath, true, br, ContainsFileNameBlobs);
                 pf.UpdateProgress(count++);
                 Application.DoEvents();
             }
         }
         catch (fommCancelException)
         {
             MessageBox.Show("Operation cancelled", "Message");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error");
         }
         pf.Unblock();
         pf.Close();
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// 后台线程任务完成后的操作
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BackFinishedWork(object sender, RunWorkerCompletedEventArgs e)
 {
     if (progressForm.Visible == true)
     {
         progressForm.Close();
     }
     this.BackWorkCompleted?.Invoke(null, exception);
 }
        private async void dataGridViewSearch_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 3 && e.RowIndex < dataGridViewSearch.RowCount && e.RowIndex >= 0)
            {
                ClientUser   clientUser = (ClientUser)dataGridViewSearch.Rows[e.RowIndex].DataBoundItem;
                User         user       = MapToServiceUser(clientUser);
                EditUserForm form       = new EditUserForm(user, _user);
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    dataGridViewSearch.Rows[e.RowIndex].Cells[0].Value = user.Login;
                    dataGridViewSearch.Rows[e.RowIndex].Cells[1].Value = user.FullName;
                    dataGridViewSearch.Rows[e.RowIndex].Cells[2].Value = user.Roles.First().RoleName;
                }
            }
            else
            if (e.ColumnIndex == 4 && e.RowIndex < dataGridViewSearch.RowCount && e.RowIndex >= 0)
            {
                ClientUser clientUser = (ClientUser)dataGridViewSearch.Rows[e.RowIndex].DataBoundItem;
                if (clientUser.Id == _user.Id)
                {
                    MessageBox.Show(this, "You can not delete yourself!");
                    return;
                }
                User         user         = MapToServiceUser(clientUser);
                DialogResult dialogResult = MessageBox.Show(
                    this,
                    string.Format("Are you sure to delete '{0}' user?", user.FullName),
                    "Delete user",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Information,
                    MessageBoxDefaultButton.Button1);

                if (dialogResult == DialogResult.Yes)
                {
                    try
                    {
                        AuthenticationServiceClient client = new AuthenticationServiceClient();
                        Form frm = new ProgressForm();
                        frm.Show();
                        OperationResult serviceResult = await client.DeleteUserAsync(user);

                        frm.Close();
                        if (!serviceResult.Success)
                        {
                            MessageBox.Show(this, "Users not found!");
                        }
                        else
                        {
                            dataGridViewSearch.Rows.RemoveAt(e.RowIndex);
                        }
                    }
                    catch (FaultException exc)
                    {
                        MessageBox.Show(exc.Message);
                    }
                }
            }
        }
Exemplo n.º 18
0
 protected void CloseLoading()
 {
     if (frm != null || !frm.IsDisposed)
     {
         if (this.InvokeRequired)
         {
             this.Invoke(new Action(() =>
             {
                 frm.Close();
                 this.Enabled = true;
             }));
         }
         else
         {
             frm.Close();
             this.Enabled = true;
         }
     }
 }
Exemplo n.º 19
0
 static void Main()
 {
     //Application.EnableVisualStyles();
     //Application.SetCompatibleTextRenderingDefault(false);
     //Application.Run(new Form1());
     progressForm = new ProgressForm();
     progressForm.Show();
     doWork();
     progressForm.Close();
 }
Exemplo n.º 20
0
        //public string gameExists(GameImport gi)
        //{
        //    IGame duplicate = PluginHelper.DataManager.GetAllGames().ToList()
        //        .Find(x => x.GetAllCustomFields().ToList().Any(y => y.Name.Equals("gogId") && y.Value.Equals(gi._gogId)));
        //    if (duplicate != null)
        //    {
        //        return duplicate.ApplicationPath;
        //    } else
        //    {
        //        return null;
        //    }
        //}

        //##################    Add games to collection    ##################

        public async void startImport()
        {
            ProgressForm progressForm = new ProgressForm();

            progressForm.Show();
            await progressForm.ShowProgress(gameImport_doWork, "Importing  Games");

            progressForm.Close();
            progressForm.Dispose();
        }
Exemplo n.º 21
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            if (btnStart.Enabled == false || btnStop.Enabled == true)
            {
                MessageBox.Show("请先停止抓取!");
                return;
            }

            #region 进度提示窗口设置
            ProgressForm progressForm = new ProgressForm();
            progressForm.Size             = new Size(600, 80);
            progressForm.StartPosition    = FormStartPosition.Manual;
            progressForm.Location         = new Point(this.DesktopLocation.X + this.Width / 2 - progressForm.Size.Width / 2, this.DesktopLocation.Y + this.Height / 2 - progressForm.Size.Height / 2);
            progressForm.FormBorderStyle  = FormBorderStyle.FixedToolWindow;
            progressForm.progress.Maximum = 100;
            progressForm.progress.Minimum = 0;
            progressForm.progress.Value   = 0;
            progressForm.Show(this);
            this.Enabled = false;
            #endregion

            using (StreamWriter writer = new StreamWriter("TitleUrl.txt"))
            {
                for (int i = 0; i < dataGridViewTitleURL.Rows.Count - 1; i++)
                {
                    string title = dataGridViewTitleURL.Rows[i].Cells[0].Value.ToString();
                    string url   = dataGridViewTitleURL.Rows[i].Cells[1].Value.ToString();
                    await writer.WriteLineAsync(title);

                    await writer.WriteLineAsync(url);

                    //更新进度条
                    progressForm.progress.Value = 50 * i / dataGridViewTitleURL.Rows.Count;
                    progressForm.Text           = "任务进度:" + progressForm.progress.Value + "%";
                }
            }

            using (StreamWriter writer = new StreamWriter("Urls.txt"))
            {
                int i = 0;
                foreach (string url in urls)
                {
                    await writer.WriteLineAsync(url);

                    i++;
                    //更新进度条
                    progressForm.progress.Value = 50 + 50 * i / urls.Count;
                    progressForm.Text           = "任务进度:" + progressForm.progress.Value + "%";
                }
            }

            progressForm.Close();
            MessageBox.Show("保存数据完成!");
            this.Enabled = true;
        }
Exemplo n.º 22
0
    public static void RunWithMargueProgress(this Action action)
    {
        var progressForm = new ProgressForm();

        progressForm.Show();
        Task.Factory.StartNew(action)
        .ContinueWith(t =>
        {
            progressForm.Close();
            progressForm.Dispose();
        }, TaskScheduler.FromCurrentSynchronizationContext());
    }
Exemplo n.º 23
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            #region 进度提示窗口设置
            ProgressForm progressForm = new ProgressForm();
            progressForm.Size             = new Size(600, 80);
            progressForm.StartPosition    = FormStartPosition.Manual;
            progressForm.Location         = new Point(this.DesktopLocation.X + this.Width / 2 - progressForm.Size.Width / 2, this.DesktopLocation.Y + this.Height / 2 - progressForm.Size.Height / 2);
            progressForm.FormBorderStyle  = FormBorderStyle.FixedToolWindow;
            progressForm.progress.Maximum = 100;
            progressForm.progress.Minimum = 0;
            progressForm.progress.Value   = 0;
            progressForm.Show(this);
            this.Enabled = false;
            #endregion

            using (StreamReader reader = new StreamReader("TitleUrl.txt"))
            {
                while (!reader.EndOfStream)
                {
                    string title = await reader.ReadLineAsync();

                    string url = await reader.ReadLineAsync();

                    try
                    {
                        titleURL.Add(title, url);
                    }
                    catch (Exception)
                    {
                        // 异常:
                        //   T:System.ArgumentNullException:
                        //     key 为 null。
                        //
                        //   T:System.ArgumentException:
                        //     System.Collections.Generic.Dictionary`2 中已存在具有相同键的元素。
                    }

                    //更新进度条
                    if (progressForm.progress.Value < 90)
                    {
                        progressForm.progress.Value++;
                        progressForm.Text = "正在加载离线数据:" + progressForm.progress.Value + "%";
                    }
                }
            }

            progressForm.progress.Value = 100;
            progressForm.Text           = "任务进度:" + progressForm.progress.Value + "%";
            progressForm.Close();
            this.Enabled = true;
        }
Exemplo n.º 24
0
        //##################    Scaning gog.com for games owned    ##################

        private async void GetGames()
        {
            platforms = new Dictionary <int, string>();

            int i = 0;

            foreach (IPlatform platform in PluginHelper.DataManager.GetAllPlatforms())
            {
                platforms.Add(i, platform.Name);
                i++;
            }

            ImportOptions options = new ImportOptions(this);

            options.Show();
            await options.ok.Task;

            options.Close();
            this.skipByTitle  = options.skipByTitle;
            this.skipImported = options.skipImported;
            this.mode         = options.mode;
            this.galaxyPath   = options.galaxyPath;
            this.platform     = options.platform;
            options.Dispose();

            await Scan_Library();

            MessageBox.Show("Skip " + skipGogId.Count.ToString() + " games already imported and " + skipTitle.Count.ToString() + " games by title.");

            ProgressForm progressForm = new ProgressForm();

            progressForm.Show();
            await progressForm.ShowProgress(GetGames_doWork, "Collecting Game Information");

            progressForm.Close();
            progressForm.Dispose();

            if (mode.Equals(Mode.startWithGalaxy))
            {
                GameImportForm importForm = new GameImportForm(this);
                importForm.Show();
            }
            else if (mode.Equals(Mode.linkToDownload))
            {
                GameImportForm2 importForm = new GameImportForm2(this);
                importForm.Show();
            }

            webClient.Dispose();
        }
Exemplo n.º 25
0
 internal void OnFinishProgress(Report report)
 {
   if (ShowProgress)
   {
     if (FinishProgress != null)
       FinishProgress(report, EventArgs.Empty);
     else if (FProgress != null)
     {
       FProgress.Close();
       FProgress.Dispose();
       FProgress = null;
     }
   }  
 }
Exemplo n.º 26
0
        private void OnCompleteReport(object sender, RunWorkerCompletedEventArgs e)
        {
            progressForm.Close();
            conn.Dispose();
            var       result   = (Tuple <string, IWorkbook>)e.Result;
            IWorkbook workBook = result.Item2;

            mainForm.Enable();

            openSaveFileForm = new OpenSaveFileForm(workBook);
            openSaveFileForm.ShowDialog((Form)mainForm);

            reportLoader.Dispose();
        }
Exemplo n.º 27
0
 private void bExtract_Click(object sender, EventArgs e)
 {
     if (lvFiles.SelectedItems.Count == 0)
     {
         return;
     }
     if (lvFiles.SelectedItems.Count == 1)
     {
         var fe = (BSAFileEntry)lvFiles.SelectedItems[0].Tag;
         SaveSingleDialog.FileName = fe.FileName;
         if (SaveSingleDialog.ShowDialog() == DialogResult.OK)
         {
             fe.Extract(SaveSingleDialog.FileName, false, br, ContainsFileNameBlobs);
             SaveSingleDialog.InitialDirectory = Path.GetDirectoryName(SaveSingleDialog.FileName);
         }
     }
     else
     {
         if (SaveAllDialog.ShowDialog() == DialogResult.OK)
         {
             var pf = new ProgressForm(false);
             pf.Text = "Unpacking archive";
             pf.EnableCancel();
             pf.SetProgressRange(lvFiles.SelectedItems.Count);
             pf.Show();
             var count = 0;
             try
             {
                 foreach (ListViewItem lvi in lvFiles.SelectedItems)
                 {
                     var fe = (BSAFileEntry)lvi.Tag;
                     fe.Extract(SaveAllDialog.SelectedPath, true, br, ContainsFileNameBlobs);
                     pf.UpdateProgress(count++);
                     Application.DoEvents();
                 }
             }
             catch (fommException)
             {
                 MessageBox.Show("Operation cancelled", "Message");
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Error");
             }
             pf.Unblock();
             pf.Close();
         }
     }
 }
Exemplo n.º 28
0
        public static void ShowMainOnline(int challengeID, ChallengeStatusE status, int gameID)
        {
            Ap.NewGame();
            MainOnline mainOnlineForm = new InfinityChess.WinForms.MainOnline();

            frmProgress = ProgressForm.Show(mainOnlineForm, "Loading...");

            mainOnlineForm.Game = Ap.Game;
            mainOnlineForm.Show();
            mainOnlineForm.LoadGame(challengeID, status, gameID);

            frmProgress.Close();

            ActivateMainForm(mainOnlineForm);
        }
Exemplo n.º 29
0
        void Game_AfterLoadGame(object sender, EventArgs e)
        {
            RefreshGameInfo();

            if (frmProgress == null)
            {
                return;
            }

            if (frmProgress.IsDisposed)
            {
                return;
            }

            frmProgress.Close();
        }
Exemplo n.º 30
0
 public static void DownloadFileVisual(string url, string path)
 {
     using (var webClient = WebClientHelper.GetWebClient())
     {
         var frm = new ProgressForm();
         frm.Text = Language.Misc_DownloadFileVisual_Downloading;
         webClient.DownloadProgressChanged += (sender, e) =>
         { frm.mainProgressBar.Value = e.ProgressPercentage; };
         webClient.DownloadFileCompleted += (sender, args) =>
         {
             frm.AllowClose = true;
             frm.Close();
         };
         webClient.DownloadFileAsync(new Uri(url), path);
         frm.ShowDialog(frmMain.defaultInstance);
     }
 }
Exemplo n.º 31
0
 public void Close()
 {
     try
     {
         if (TaskDialog.IsPlatformSupported && modernDialog != null)
         {
             modernDialog.Close();
         }
         else if (defaultDialog != null)
         {
             defaultDialog.Close();
         }
     }
     catch (InvalidOperationException)
     {
         modernDialog.Dispose();
     }
 }
Exemplo n.º 32
0
 public void LoadBook()
 {
     try
     {
         ProgressForm frm = ProgressForm.Show(this, "Loading Book....");
         if (!this.Game.Book.Load(Options.Instance.CurrentBookFilePath))
         {
             MessageForm.Error(this.ParentForm, MsgE.ErrorInvalidFileFormat);
         }
         frm.Close();
     }
     catch (FormatException ex)
     {
         TestDebugger.Instance.WriteError(ex);
         MessageForm.Error(this.ParentForm, MsgE.ErrorInvalidFileFormat);
         return;
     }
 }
Exemplo n.º 33
0
	//
	// invokeFileSyncHandlerDirectlyButton_Click
	//
	// Perform a file synchronization directly.
	//
	// Parameters:
	//  sender - The source Button object for this event.
	//  e - The EventArgs object that contains the event data.
	//
	private void invokeFileSyncHandlerDirectlyButton_Click(object sender, System.EventArgs e)
	{
		hresultLabel.Text = "";
		try
		{
			SynrcSync fileSync = new SynrcSync();
			//fileSync.InvokeDirectly = true;
			fileSync.syncStatus += new SynrcSync.SyncStatusDelegate(OnFileSyncStatus);
			fileSync.syncError += new SynrcSync.SyncErrorDelegate(OnSyncError);
			progressForm = new ProgressForm();
			progressForm.Show();
			int retval = 0;// fileSync.Sync();
			hresultLabel.Text = "HRESULT is 0x" + retval.ToString("x");
		}
		catch (Exception ex)
		{
			MessageBox.Show("Exception from invocation: " + ex.Message);
			if (progressForm != null)
			{
				progressForm.Close();
			}
		}
	}
Exemplo n.º 34
0
 private void bExtract_Click(object sender, EventArgs e)
 {
   if (lvFiles.SelectedItems.Count == 0)
   {
     return;
   }
   if (lvFiles.SelectedItems.Count == 1)
   {
     var fe = (BSAFileEntry) lvFiles.SelectedItems[0].Tag;
     SaveSingleDialog.FileName = fe.FileName;
     if (SaveSingleDialog.ShowDialog() == DialogResult.OK)
     {
       fe.Extract(SaveSingleDialog.FileName, false, br, ContainsFileNameBlobs);
       SaveSingleDialog.InitialDirectory = Path.GetDirectoryName(SaveSingleDialog.FileName);
     }
   }
   else
   {
     if (SaveAllDialog.ShowDialog() == DialogResult.OK)
     {
       var pf = new ProgressForm(false);
       pf.Text = "Unpacking archive";
       pf.EnableCancel();
       pf.SetProgressRange(lvFiles.SelectedItems.Count);
       pf.Show();
       var count = 0;
       try
       {
         foreach (ListViewItem lvi in lvFiles.SelectedItems)
         {
           var fe = (BSAFileEntry) lvi.Tag;
           fe.Extract(SaveAllDialog.SelectedPath, true, br, ContainsFileNameBlobs);
           pf.UpdateProgress(count++);
           Application.DoEvents();
         }
       }
       catch (fommException)
       {
         MessageBox.Show("Operation cancelled", "Message");
       }
       catch (Exception ex)
       {
         MessageBox.Show(ex.Message, "Error");
       }
       pf.Unblock();
       pf.Close();
     }
   }
 }