Esempio n. 1
0
        /// <summary>
        /// Displays a progress dialog.
        ///
        /// There are two ways you can exit from this method:
        /// - The <see paramref="cancelButton" /> parameter is not <c>null</c> and the user clicked on cancel. The task completes.
        /// - The dialog has been closed by libvlc. The cancellationToken is cancelled. In that case, you must close your dialog and <c>throw new TaskCanceledException</c>
        /// </summary>
        /// <param name="userdata">The user data, as given to the <see cref="DialogsManagement.UseDialogManager" /> method.</param>
        /// <param name="dialogId">The dialog identifier, as given by LibVlc. The same identifier will be used in <see cref="IVlcDialogManager.UpdateProgress"/></param>
        /// <param name="title">The dialog title</param>
        /// <param name="text">The dialog message</param>
        /// <param name="indeterminate">A boolean indicating whether the progress is indeterminate.</param>
        /// <param name="position">The progress position (between 0.0 and 1.0)</param>
        /// <param name="cancelButton">The text to display on the "cancel" button, or <c>null</c> if the progress cannot be cancelled.</param>
        /// <param name="cancellationToken">The token that is cancelled when libvlc asks to cancel the dialog.</param>
        /// <exception cref="TaskCanceledException">When the cancellation token has been cancelled, and the dialog has been closed.</exception>
        /// <returns>The task that completes when the user cancels the dialog. Be careful, you cannot cancel the dialog if <see paramref="cancelButton" /> is null.</returns>
        public async Task DisplayProgressAsync(IntPtr userdata, IntPtr dialogId, string title, string text, bool indeterminate, float position,
                                               string cancelButton, CancellationToken cancellationToken)
        {
            // TODO : Warning: This code has never been tested... How to produce a progress dialog?

            // Create the progress dialog and store it in this instance. In theory, libvlc can manage several dialogs at the same time, using several dialogId,
            // but in practice, I don't know if that could happen.
            this.currentProgressController = await this.metroWindow.Dispatcher.InvokeAsync(() => this.metroWindow.ShowProgressAsync(title, text, cancelButton != null, new MetroDialogSettings
            {
                NegativeButtonText = cancelButton,
            })).Task.Unwrap();

            try
            {
                // Libvlc returns progress in the range 0-1
                this.currentProgressController.Minimum = 0;
                this.currentProgressController.Maximum = 1;

                // Set the progress in the dispatcher
                if (!indeterminate)
                {
                    await this.metroWindow.Dispatcher.InvokeAsync(() => this.currentProgressController.SetProgress(position)).Task;
                }

                var taskCompletionSource = new TaskCompletionSource <bool>();
                // Case 1 : libvlc asks to close the progress dialog
                var onCancellationTokenCancelled = (Action)(() =>
                {
                    taskCompletionSource.TrySetResult(false);
                });

                // Case 2 : The user has clicked on the cancel button
                this.currentProgressController.Canceled += (sender, args) =>
                {
                    taskCompletionSource.TrySetResult(true);
                };

                using (var registration = cancellationToken.Register(onCancellationTokenCancelled))
                {
                    // Wait for the progress dialog to finish
                    var isCanceledByUser = await taskCompletionSource.Task;

                    // Close the dialog
                    await this.metroWindow.Dispatcher.InvokeAsync(() => this.currentProgressController.CloseAsync()).Task.Unwrap();

                    if (isCanceledByUser)
                    {
                        // Case 1 : Throw the exception as required
                        throw new TaskCanceledException();
                    }
                }
            }
            finally
            {
                this.currentProgressController = null;
            }
        }
Esempio n. 2
0
        protected override async void ReadExcelFileAction()
        {
            ProgressDialogController progressDialogController = await _dialogCoordinator.ShowProgressAsync(this, "Please wait...", "Finding headings...");

            progressDialogController.Maximum = 100;

            await Task.Run(() =>
            {
                IEnumerable <ExcelRangeBase> dataColumn = _excelUsedRange.Single(cell => cell.Address == DataColumnHeading);

                IEnumerable <ExcelRangeBase> stageColumn = _excelUsedRange.Single(cell => cell.Address == StageColumnHeading);

                IEnumerable <ExcelRangeBase> timestampColumn = _excelUsedRange.Single(cell => cell.Address == TimestampColumnHeading);

                progressDialogController.SetMessage("Headings found...");
                progressDialogController.SetProgress(100);

                List <DataValueModel> values = new List <DataValueModel>();

                int numberOfRows = _excelWorksheet.Dimension.Rows;

                progressDialogController.SetMessage("Beginning to read Worksheet...");
                progressDialogController.SetProgress(0);
                progressDialogController.Maximum = numberOfRows;

                for (int currentRow = dataColumn.First().Start.Row; currentRow < numberOfRows; currentRow++)
                {
                    object dataCellValue      = _excelWorksheet.Cells[currentRow, dataColumn.First().Start.Column].Value;
                    object stageCellValue     = _excelWorksheet.Cells[currentRow, stageColumn.First().Start.Column].Value;
                    object timestampCellValue = _excelWorksheet.Cells[currentRow, timestampColumn.First().Start.Column].Value;

                    if (dataCellValue.IsNumeric() && stageCellValue != null && timestampCellValue != null && FilterRow(currentRow))
                    {
                        values.Add(new DataValueModel
                        {
                            Stage     = int.Parse(Regex.Match(_excelWorksheet.Cells[currentRow, stageColumn.First().Start.Column].Value.ToString(), @"\d+", RegexOptions.RightToLeft).Value),
                            Value     = double.Parse(_excelWorksheet.Cells[currentRow, dataColumn.First().Start.Column].Value.ToString()),
                            Timestamp = DateTime.Parse(_excelWorksheet.Cells[currentRow, timestampColumn.First().Start.Column].Value.ToString().Replace("\"", ""), CultureInfo.InvariantCulture)
                        });
                    }

                    progressDialogController.SetMessage($"Reading row {currentRow} of {numberOfRows}...");
                    progressDialogController.SetProgress(currentRow);
                }

                DataSetModel dataSetModel = new DataSetModel
                {
                    DataName = DataName,
                    DataUnitOfMeasurement = DataUnitOfMeasurement,
                    Values = values
                };

                MessengerInstance.Send((dataSetModel, _wellID), MessageTokenStrings.AddDataToManager);
            });

            await progressDialogController.CloseAsync();
        }
Esempio n. 3
0
        private async void MainVmNoticeEvent(object sender, NotificationEventArgs <Exception> e)
        {
            string message = e.Message;
            ProgressDialogController temp = await this.ShowProgressAsync("progress", message, true);

            await Task.Delay(2000);

            await temp.CloseAsync();
        }
Esempio n. 4
0
        private async void ButtonSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool isFilePathEmpty = string.IsNullOrEmpty(uploadFilePath);

                if (!isFilePathEmpty)
                {
                    ProgressDialogController controller = await this.ShowProgressAsync("Please wait...", "Uploading data");

                    controller.SetIndeterminate();
                    controller.SetCancelable(false);

                    string[] temp   = uploadFilePath.Split('.');
                    string   fileId = $"{myId}.{temp[temp.Length - 1]}";

                    string BaseDirectoryPath = AppDomain.CurrentDomain.BaseDirectory;
                    string filePath          = BaseDirectoryPath + $"Resources\\Images\\{fileId}";

                    Item   item     = Dynamodb.GetItem(myId, MyAWSConfigs.AdminDBTableName);
                    string oldImage = item["aPropic"];
                    Console.WriteLine("><><><><><><><><><><>" + oldImage);

                    //Delete old profile pic in local
                    //string oldFilePath = BaseDirectoryPath + $"Resources\\Images\\{oldImage}";
                    //DeleteOldPic(oldFilePath);

                    //Delete old profile pic in s3Bucket
                    S3Bucket.DeleteFile(oldImage, MyAWSConfigs.AdminS3BucketName);

                    item["aPropic"] = fileId;

                    await Task.Run(() => Models.S3Bucket.UploadFile(uploadFilePath, fileId, MyAWSConfigs.AdminS3BucketName));

                    MessageBox.Show(fileId);
                    await Task.Run(() => Models.Dynamodb.UpdateItem(item, Models.MyAWSConfigs.AdminDBTableName));

                    await controller.CloseAsync();

                    await this.ShowMessageAsync("Success", "Changed Successfully..", MessageDialogStyle.Affirmative);

                    //activity recorded
                    Models.ActivityLogs.Activity(Models.Components.AdminComponent, "User Changed Profile Picture");

                    //imgUploadImage.Source = null;
                }
                else
                {
                    await this.ShowMessageAsync("Error", "Please check all fields", MessageDialogStyle.Affirmative);
                }
            }
            catch
            {
                await this.ShowMessageAsync("Error", "Task not completed", MessageDialogStyle.Affirmative);
            }
        }
 protected virtual async Task ShowProgressAsync(string message, string title = null)
 {
     if (_controller != null)
     {
         MessageBox.Show("Progress bar for one place is not closed");
         return;
     }
     title       = title ?? CommonStrings.ACGeneralLabel;
     _controller = await _dialogCoordinator.ShowProgressAsync(this, title, message);
 }
Esempio n. 6
0
        public async void workerRun()
        {
            // Tidy the Log File & Notify User
            MetroWindow w = (MetroWindow)Application.Current.MainWindow;

            _progressDlg = await w.ShowProgressAsync("Tidying Log File", "NovaTrakt is tidying your log file.\r\nThis process may take a while if it is the first time it has been run.");

            _progressDlg.SetIndeterminate();
            worker.RunWorkerAsync();
        }
Esempio n. 7
0
        private async void UninstallDevice(object device)
        {
            if (device is EmuControllerDevice dev)
            {
                ProgressDialogController progressController = await parentWindow.ShowProgressAsync("Uninstalling device", "Please wait...", false, dialogSettings);

                dev.UninstallDevice();
                await progressController.CloseAsync();
            }
        }
        private async void OnSavePost()
        {
            ProgressDialogController progressController = await _dialogCoordinator.ShowProgressAsync(this, AppContext.Instance.ApplicationName, "Generating markdown...");

            progressController.SetIndeterminate();
            progressController.SetMessage($"Generating...{SelectedPost.Title.ToHtmlDecodedString()}");
            await SavePost(SelectedPost, true, progressController);

            await progressController.CloseAsync();
        }
Esempio n. 9
0
        public async Task CompareIntegrity()
        {
            string folderToScan;

            System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
            folderDialog.ShowNewFolderButton = false;
            folderDialog.Description         = "Select the folder you want to scan";
            if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                folderToScan = folderDialog.SelectedPath;
            }
            else
            {
                return;
            }

            string integrityFile;

            Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog();
            fileDialog.DefaultExt = ".integritul";
            fileDialog.Filter     = "Integritul Database Files (*.integritul)|*.integritul";
            fileDialog.Title      = "Select your integritul file";
            if (fileDialog.ShowDialog() == true)
            {
                integrityFile = fileDialog.FileName;
            }
            else
            {
                return;
            }
            ProgressDialogController progressDialog = await ShowProgressAsync("Please Wait", String.Empty);

            var progressHandler = new Progress <string>(value =>
            {
                progressDialog.SetMessage(value);
            });
            var progress = progressHandler as IProgress <string>;
            IEnumerable <ResultOfComparison> differences = new List <ResultOfComparison>();
            await Task.Run(() =>
            {
                differences = CompareFolder(folderToScan, integrityFile, progress);
            });

            await progressDialog.CloseAsync();

            if (differences.Any())
            {
                IShell shell = IoC.Get <IShell>();
                shell.ChangeScreen(new ResultOfComparisonViewModel(differences));
            }
            else
            {
                await ShowMessageAsync("All is equal", "Noting has changed", MessageDialogStyle.Affirmative);
            }
        }
Esempio n. 10
0
        private async void Messages_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            string newItem = e.NewItems.Cast <string>().FirstOrDefault();
            //var messageBoxResult = MessageBox.Show(this, newItem);

            ProgressDialogController temp = await this.ShowProgressAsync("progress", newItem, true);

            await Task.Delay(1000);

            await temp.CloseAsync();
        }
        public async void ShowProgress(string location, bool isSvn, string autoInstallName = null)
        {
            controller =
                await
                this.ShowProgressAsync(
                    Utility.GetMultiLanguageText("Updating"), Utility.GetMultiLanguageText("DownloadingData"));

            controller.SetIndeterminate();
            controller.SetCancelable(true);
            ListAssemblies(location, isSvn, autoInstallName);
        }
Esempio n. 12
0
        /// <summary>
        /// Saves the genre XMLS.
        /// </summary>
        /// <param name="progressResult">The progress result.</param>
        /// <param name="system">The system.</param>
        /// <returns></returns>
        /// <exception cref="Exception">Failed saving genre databases</exception>
        private async Task SaveGenreXmls(ProgressDialogController progressResult, string system)
        {
            progressResult.SetMessage("Saving genres..");

            if (!await _hyperspinManager.SaveCurrentGamesListToGenreXmlsAsync(system))
            {
                throw new Exception("Failed saving genre databases");
            }

            progressResult.SetMessage("Genre databases saved..");
        }
Esempio n. 13
0
        public async Task LockUi()
        {
            _lockProgressController = await this.ShowProgressAsync("Loading", "Please Wait...");

            _lockProgressController.SetIndeterminate();

            _lockProgress = new Progress <string>((update) =>
            {
                _lockProgressController.SetMessage(update);
            });
        }
        public async Task LockUi(string title, string message, object requestor)
        {
            _lockProgressController = await this.ShowProgressAsync(title, message);

            _lockProgressController.SetIndeterminate();

            _lockProgress = new Progress <string>((update) =>
            {
                _lockProgressController.SetMessage(update);
            });
        }
Esempio n. 15
0
        private async void GTAOLaunchButton_Click(object sender, RoutedEventArgs e)
        {
            MetroWindow metroWindow = (Application.Current.MainWindow as MetroWindow);

            this.GTAVLaunchProgress = await metroWindow.ShowProgressAsync("Launching Grand Theft Auto V", "Launching GTA Online with selected options. Please wait...", true);

            this.GTAVLaunchProgress.SetIndeterminate();

            string  gamePath  = SettingsHandler.GTAVDirectory;
            GTAVDRM targetDRM = SettingsHandler.IsSteamDRM ? GTAVDRM.Steam : GTAVDRM.Rockstar;

            this.GTAV             = new GTAV(gamePath, GTAVMode.Online, targetDRM);
            this.GTAV.GTAVExited += this.GTAVProcessExited;


            GTAOOptions gameOptions = new GTAOOptions
            {
                StraightToFreemode = (bool)this.OptionsToggleButton_StraightToFreemode.IsChecked
            };
            bool optionSetSuccess = await this.GTAV.SetOptions(gameOptions);

            if (!optionSetSuccess)
            {
                MessageDialogResult res = await metroWindow.ShowMessageAsync("Unable to set options",
                                                                             "Could not set launch options. Continue with launch?",
                                                                             MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No" });

                if (res == MessageDialogResult.Negative)
                {
                    await this.GTAVLaunchProgress.CloseAsync();

                    return;
                }
            }

            bool launchSuccess = this.GTAV.StartGTAO(gameOptions);

            if (launchSuccess)
            {
                this.GTAV.GTAVStarted += this.GTAVProcessStarted;

                this.GTAVLaunchProgress.SetTitle("Waiting for Grand Theft Auto V to launch");
                this.GTAVLaunchProgress.SetMessage("Waiting for Grand Theft Auto V to launch...");

                this.GTAVLaunchProgress.SetCancelable(true);
                this.GTAVLaunchProgress.Canceled += this.GTAVCancelWaitLaunch;
            }
            else
            {
                await this.GTAVLaunchProgress.CloseAsync();

                await metroWindow.ShowMessageAsync("Failed to launch Grand Theft Auto V", "Couldn't launch GTA Online. Please double check GTAV's directory/copy under Settings.", MessageDialogStyle.Affirmative);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Saves the XML asynchronous.
        /// </summary>
        /// <param name="dbName">Name of the database.</param>
        /// <param name="progressResult">The progress result.</param>
        /// <param name="system">The system.</param>
        /// <returns></returns>
        /// <exception cref="Exception">Failed saving database</exception>
        private async Task SaveXmlAsync(string dbName, ProgressDialogController progressResult, string system)
        {
            progressResult.SetMessage("Saving Database");

            if (!await _hyperspinManager.SaveCurrentGamesListToXmlAsync(system, dbName))
            {
                throw new Exception("Failed saving database");
            }

            progressResult.SetMessage(dbName + " Database saved.");
        }
Esempio n. 17
0
        /// <summary>
        /// Saves the favorites to text asynchronous.
        /// </summary>
        /// <param name="dbName">Name of the database.</param>
        /// <param name="progressResult">The progress result.</param>
        /// <param name="system">The system.</param>
        /// <returns></returns>
        /// <exception cref="Exception">Failed saving database</exception>
        private async Task SaveFavoritesAsync(ProgressDialogController progressResult, string system)
        {
            progressResult.SetMessage("Saving Favorites");

            if (!await _hyperspinManager.SaveFavorites(system))
            {
                ;
            }

            progressResult.SetMessage(system + " favorites saved.");
        }
Esempio n. 18
0
        public async void AddAction(WorkerTask task)
        {
            Tasks.Add(task);
            if (!LoadDataWorker.IsBusy)
            {
                progressDialog = await DialogManager.ShowProgressAsync(Application.Current.MainWindow as MetroWindow, task.Title, task.Description);

                progressDialog.SetIndeterminate();
                LoadDataWorker.RunWorkerAsync();
            }
        }
Esempio n. 19
0
        private void initTimer()
        {
            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += async(object sender, EventArgs e) => {
                if (controller == null && !Inject)
                {
                    controller = await this.ShowProgressAsync("等待", "等待游戏启动.....", true, Settings);

                    controller.SetIndeterminate();
                }
                if (controller != null)
                {
                    if (controller.IsCanceled)
                    {
                        timer.Stop();
                        await controller.CloseAsync();

                        controller = null;
                    }
                }
                var Proce = Process.GetProcessesByName("League of Legends");
                if (Proce.Length >= 1)
                {
                    var Game = Proce[0];
                    if (CurrentId == Game.Id)
                    {
                        if (controller != null)
                        {
                            await controller.CloseAsync();

                            controller = null;
                        }
                        return;
                    }
                    else
                    {
                        Inject = false;
                    }

                    Debug.WriteLine(System.IO.Path.GetFullPath("LOL Trace.dll"));

                    WinApi.Inject(Game.Id, Encoding.Default.GetBytes(System.IO.Path.GetFullPath("LOL Trace.dll")));
                    Inject    = true;
                    CurrentId = Game.Id;
                    InjectCount++;
                    _ = await this.ShowMessageAsync("成功", $"累计给你注入了 {InjectCount} 次!");
                }
                else
                {
                    Inject = false;
                }
            };
        }
Esempio n. 20
0
        public ProgressDialog(string title, string message, bool isCancelable, ProgressDialogController ctrl)
        {
            if (ctrl == null)
            {
                throw new ArgumentNullException(nameof(ctrl));
            }

            this.ctrl         = ctrl;
            this.title        = title;
            this.message      = message;
            this.isCancelable = isCancelable;
        }
Esempio n. 21
0
        private async void cargar_prestashop()
        {
            var metroWindow = this;

            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogOptions.ColorScheme;
            ProgressDialogController ProgressAlert = null;
            LeerPedidos carga_data = null;

            try
            {
                dg1.Columns[13].Visibility = Visibility.Collapsed;

                carga_data = new LeerPedidos();

                ProgressAlert = await this.ShowProgressAsync(Ent_Msg.msgcargando, "Espere un momento por favor, cargando pedidos");  //show message

                ProgressAlert.SetIndeterminate();
                string _cargar_data = await Task.Run(() => (Ent_Global._err_con_mysql)?"" : carga_data.ImportaDataPrestaShop());

                if (_cargar_data.Length == 0)
                {
                    //await Task.Run(() => refrescagrilla_prestashop());
                    dt = await Task.Run(() => Dat_Liquidacion.liquidacionXfacturar());

                    await ProgressAlert.CloseAsync();

                    dg1.AutoGenerateColumns = false;
                    dg1.ItemsSource         = dt.DefaultView;
                    totales(dt);
                }
                else
                {
                    dt = await Task.Run(() => Dat_Liquidacion.liquidacionXfacturar());

                    //await ProgressAlert.CloseAsync();
                    dg1.AutoGenerateColumns = false;
                    dg1.ItemsSource         = dt.DefaultView;
                    totales(dt);

                    await ProgressAlert.CloseAsync();

                    await metroWindow.ShowMessageAsync(Ent_Msg.msginfomacion, "ERROR EN LA IMPORTACION DE DATOS.. POR FAVOR CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + _cargar_data + ")", MessageDialogStyle.Affirmative, metroWindow.MetroDialogOptions);
                }
            }
            catch (Exception exc)
            {
                await ProgressAlert.CloseAsync();

                await metroWindow.ShowMessageAsync(Ent_Msg.msginfomacion, "ERROR EN LA IMPORTACION DE DATOS.. POR FAVOR CONSULTE CON SISTEMAS..==>> TIPO DE ERROR (" + exc.Message + ")", MessageDialogStyle.Affirmative, metroWindow.MetroDialogOptions);

                //throw;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Asks the user if he is sure about that and starts to rebuild the index
        /// </summary>
        private async void BuildIndexInTheBg()
        {
            var parentWindow = (MetroWindow)Window.GetWindow(this);

            SearchEngine.Instance.ChangedBuildingIndexProgress += ChangedBuildingIndexProgress;
            _controller = await parentWindow.ShowProgressAsync("Building index...", "Browsing through your files...");

            _controller.SetIndeterminate();
            var tmp = new Task(() => SearchEngine.Instance.BuildIndex());

            tmp.Start();
        }
Esempio n. 23
0
        private async Task FooProgress()
        {
            // Show...
            ProgressDialogController controller = await dialogCoordinator.ShowProgressAsync(this, "HEADER", "MESSAGE");

            controller.SetIndeterminate();

            // Do your work...

            // Close...
            await controller.CloseAsync();
        }
Esempio n. 24
0
 /// <summary>
 /// 获取Progress对象
 /// </summary>
 public static async Task <ProgressDialogController> GetProgress(string title, string message)
 {
     if (Progress == null || !Progress.IsOpen)
     {
         Progress = await MainWindow.ShowProgressAsync(title, message);
     }
     else
     {
         Progress.SetMessage(message);
     }
     return(Progress);
 }
Esempio n. 25
0
            public async Task OpenProgressDialog(string title, string message, bool isCancellable = false)
            {
                Console.WriteLine("Open Progress Dialog.");
                if (multiple)
                {
                    return;
                }
                ProgressDlgCtl = await w.ShowProgressAsync(title, message, isCancellable) as ProgressDialogController;

                ProgressDlgCtl.SetIndeterminate();
                multiple = true;
            }
Esempio n. 26
0
        public async void ShowProgressMessage(string message, string header = "")
        {
            // Show...
            ProgressDialogController controller = await _dialogCoordinator.ShowProgressAsync(this, header, message);

            controller.SetIndeterminate();

            // Do your work...

            // Close...
            await controller.CloseAsync();
        }
        /// <summary>
        /// The event handler for the create mod pack button
        /// </summary>
        /// <remarks>
        /// This is originally the help button, but has been repurposed
        /// </remarks>
        private async void ModPackWizard_CreateModPack(object sender, System.Windows.RoutedEventArgs e)
        {
            _progressController = await this.ShowProgressAsync(UIMessages.ModPackCreationMessage, UIMessages.PleaseStandByMessage);

            var wizPages = modPackWizard.Items;

            var modPackData = new ModPackData
            {
                Name         = ModPackName.Text,
                Author       = ModPackAuthor.Text,
                Version      = VersionNumber,
                Description  = ModPackDescription.Text,
                ModPackPages = new List <ModPackData.ModPackPage>()
            };

            var pageIndex = 0;

            foreach (var wizPageItem in wizPages)
            {
                var wizPage = wizPageItem as WizardPage;

                if (wizPage.Content is WizardModPackControl control)
                {
                    if (control.ModGroupList.Count > 0)
                    {
                        modPackData.ModPackPages.Add(new ModPackData.ModPackPage
                        {
                            PageIndex = pageIndex,
                            ModGroups = control.ModGroupList
                        });
                    }
                }
                pageIndex++;
            }

            if (modPackData.ModPackPages.Count > 0)
            {
                var progressIndicator = new Progress <double>(ReportProgress);
                var texToolsModPack   = new TTMP(new DirectoryInfo(Properties.Settings.Default.ModPack_Directory), XivStrings.TexTools);
                await texToolsModPack.CreateWizardModPack(modPackData, progressIndicator);

                ModPackFileName = $"{ModPackName.Text}";
            }
            else
            {
                ModPackFileName = "NoData";
            }

            await _progressController.CloseAsync();

            DialogResult = true;
        }
Esempio n. 28
0
        private async void DownloadFileButton_OnClick(object sender, RoutedEventArgs e)
        {
            FileInfoEx fileInfoEx = FilesDataGrid.SelectedItem as FileInfoEx;

            if (fileInfoEx != null)
            {
                ProgressDialogController controller = await this.ShowProgressAsync("Загрузка файла", "Подождите идет загрузка файла на компьютер...");

                controller.SetIndeterminate();

                try
                {
                    string directoryPath = ConfigurationSettings.AppSettings["DownloadFilesFolder"];

                    DirectoryInfo directoryInfo;
                    if (!Directory.Exists(directoryPath))
                    {
                        directoryInfo = Directory.CreateDirectory(directoryPath);
                    }
                    else
                    {
                        directoryInfo = new DirectoryInfo(directoryPath);
                    }

                    string filePath = Path.Combine(directoryInfo.FullName, fileInfoEx.OriginalFileName);

                    using (FileTransferServiceClient client = new FileTransferServiceClient())
                        using (FileStream stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None))
                        {
                            FileDataDownload download;

                            do
                            {
                                download = await client.DownloadAsync(fileInfoEx);

                                if (download.Data != null)
                                {
                                    stream.Write(download.Data, 0, download.Data.Length);
                                }
                            } while (!download.IsLastPart);
                        }

                    await this.ShowMessageAsync("Загрузка файла", "Файл был успешно загружен на компьютер!");
                }
                catch (Exception exception)
                {
                    await this.ShowMessageAsync("Ошибка", exception.Message);
                }

                await controller.CloseAsync();
            }
        }
        /// <inheritdoc />
        public MetroProgressController(ProgressDialogController controller)
        {
            _controller                       = controller;
            _closeSubscription                = Observable.FromEventPattern <EventHandler, EventArgs>(
                add => _controller.Closed    += add,
                remove => _controller.Closed -= remove
                ).Select(s => s.EventArgs).Subscribe(arg => _whenClosed.OnNext(arg));

            _cancelSubscription                 = Observable.FromEventPattern <EventHandler, EventArgs>(
                add => _controller.Canceled    += add,
                remove => _controller.Canceled -= remove
                ).Select(s => s.EventArgs).Subscribe(arg => _whenCanceled.OnNext(arg));
        }
Esempio n. 30
0
        public PdfDocument CopyPages(PdfDocument from, PdfDocument to, ProgressDialogController ctrl, FileInfo _in, FileInfo _out)
        {
            for (int i = 0; i < from.PageCount; i++)
            {
                ctrl.SetTitle($"Adding pages to {_out.Name}");
                ctrl.SetMessage($"{i+1}/{from.PageCount} pages from {_in.Name}");
                to.AddPage(from.Pages[i]);
                var progress = (((((i + 1f) * 100f)) / ((from.PageCount) * (100f))));
                ctrl.SetProgress(progress);
            }

            return(to);
        }