Beispiel #1
0
        private async void downloadUpdateButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Settings.Default.TrunkLocation))
            {
                MessageBoxEx.Show(this, "Trunk location is requried!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            if (_isCloning)
            {
                MessageBoxEx.Show(this, "Cloning already in progress!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            if (_isCompiling)
            {
                MessageBoxEx.Show(this, "Currently compiling TC! Please wait until this has finished.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            _isCloning = true;

            compileProgressBar.Visible      = true;
            compileProgressBar.ProgressType = eProgressItemType.Marquee;

            downloadUpdateButton.Enabled = false;

            if (new DirectoryInfo(Settings.Default.TrunkLocation).GetFiles().Length == 0)
            {
                var progress = new Progress <double>(prog => Invoke((MethodInvoker) delegate
                {
                    if (compileProgressBar.ProgressType == eProgressItemType.Marquee)
                    {
                        compileProgressBar.ProgressType = eProgressItemType.Standard;
                    }

                    compileProgressBar.Value = Convert.ToInt32(prog);
                }));

                await TrinityCoreRepository.Clone(Settings.Default.TrunkLocation, progress).ContinueWith(task =>
                {
                    Invoke((MethodInvoker) delegate
                    {
                        compileProgressBar.Visible   = false;
                        downloadUpdateButton.Enabled = true;

                        MessageBoxEx.Show(this, "Cloning has been completed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    });

                    _isCloning = false;
                });
            }
            else
            {
                outputTextBox.Text            = String.Empty;
                consoleTabControl.SelectedTab = outputTabItem;

                var progress = new Progress <string>(prog => Invoke((MethodInvoker) delegate
                {
                    outputTextBox.AppendText(prog + Environment.NewLine);
                }));

                await TrinityCoreRepository.Pull(Settings.Default.TrunkLocation, progress).ContinueWith(task =>
                {
                    Invoke((MethodInvoker) delegate
                    {
                        compileProgressBar.Visible   = false;
                        downloadUpdateButton.Enabled = true;

                        MessageBoxEx.Show(this, "The TrinityCore repository has been updated to the latest version.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    });

                    _isCloning = false;
                });
            }
        }
Beispiel #2
0
        private async void DownloadUpdateTC()
        {
            if (String.IsNullOrEmpty(Settings.Default.TrunkLocation))
            {
                if (_messageService.Show("You must first set your trunk location! Want to do this right now?", "Trunk location not set!", MessageButton.YesNo, MessageImage.Question) == MessageResult.Yes)
                {
                    SetTrunkLocation();
                }

                return;
            }

            if (_isCloning)
            {
                _messageService.ShowError("Cloning is already in progress!");

                return;
            }

            if (_isCompiling)
            {
                _messageService.ShowError("Currently compiling TrinityCore! Please wait until this has finished.");

                return;
            }

            Busy = true;
            BusyIndeterminate = true;

            _isCloning = true;

            if (new DirectoryInfo(Settings.Default.TrunkLocation).GetFiles().Length == 0)
            {
                var progress = new Progress <double>(prog => _dispatcherService.BeginInvoke(() =>
                {
                    if (BusyIndeterminate)
                    {
                        BusyIndeterminate = false;
                    }

                    if (prog - BusyProgress > 1 || prog >= 99)
                    {
                        BusyProgress = prog;
                    }
                }));

                bool cloneSuccess = await TrinityCoreRepository.Clone(Settings.Default.TrunkLocation, progress);

                _dispatcherService.Invoke(() =>
                {
                    if (cloneSuccess)
                    {
                        _messageService.Show("Cloning has been completed!", "Success", MessageButton.OK, MessageImage.Information);
                    }
                    else
                    {
                        _messageService.Show("Cloning could not be completed!", "Something went wrong", MessageButton.OK, MessageImage.Error);
                    }
                });

                _isCloning = false;
            }
            else
            {
                BusyIndeterminate = true;
                OutputText        = String.Empty;

                var progress = new Progress <string>(prog => _dispatcherService.BeginInvokeIfRequired(delegate
                {
                    OutputText += prog + Environment.NewLine;
                }));

                bool pullSuccess = await TrinityCoreRepository.Pull(Settings.Default.TrunkLocation, progress);

                _dispatcherService.Invoke(() =>
                {
                    if (pullSuccess)
                    {
                        _messageService.Show("The TrinityCore repository has been updated to the latest version.", "Success", MessageButton.OK, MessageImage.Information);
                    }
                    else
                    {
                        _messageService.Show("Pulling could not be completed!", "Something went wrong", MessageButton.OK, MessageImage.Error);
                    }
                });

                _isCloning = false;
            }

            BusyIndeterminate = false;
            BusyProgress      = 0;
            Busy = false;
        }