Example #1
0
        private async void ShowWizardX()
        {
            var _win = new AddDriveWizard();

            _win.DataContext = new WizardData()
            {
                DriveCode = "2018_00", DriveLetter = @"e:\", MaxImagesInDirectory = 0
            };
            if (_win.ShowDialog() == true)
            {
                var cnf = new ConfigurationData();
                var lg  = new Logger();
                try
                {
                    DriveCode            = ((WizardData)_win.DataContext).DriveCode;
                    DriveTitle           = ((WizardData)_win.DataContext).DriveTitle;
                    DriveLetter          = ((WizardData)_win.DataContext).DriveLetter;
                    MaxImagesInDirectory = ((WizardData)_win.DataContext).MaxImagesInDirectory;
                    IsSecret             = ((WizardData)_win.DataContext).IsSecret;
                    SaveImages           = ((WizardData)_win.DataContext).SaveImages;
                    SaveThumbnails       = ((WizardData)_win.DataContext).SaveThumbnails;
                    SaveThumbnailsToDb   = ((WizardData)_win.DataContext).SaveThumbnailsToDb;
                    SaveMedia            = ((WizardData)_win.DataContext).SaveMedia;
                    var worker = new Worker();
                    cancelTokenSource = new CancellationTokenSource();
                    token             = cancelTokenSource.Token;
                    if (App.Current.Windows.OfType <MainWindow>().FirstOrDefault() is MainWindow)
                    {
                        var progress = new Progress <int>(value => (App.Current.Windows.OfType <MainWindow>().FirstOrDefault()).progressBar.Value = value);
                        var id       = await worker.Work(progress, token, CreateDestinationX);

                        var Log = lg.GetLog();
                        if (!string.IsNullOrWhiteSpace(Log))
                        {
                            System.Windows.Forms.MessageBox.Show(Log);
                        }
                    }
                }
                catch (Exception er)
                {
                    System.Windows.Forms.MessageBox.Show(er.Message);
                    if (!string.IsNullOrWhiteSpace(lg.GetLog()))
                    {
                        System.Windows.Forms.MessageBox.Show(lg.GetLog());
                    }
                }
            }


            var result = _win.DialogResult.Value;
        }
Example #2
0
        public async void ShowWizard()
        {
            var _win = new AddDriveWizard();

            _win.DataContext = new WizardData()
            {
                DriveCode = "2018_00", DriveLetter = @"e:\", MaxImagesInDirectory = 0
            };


            if (_win.ShowDialog() == true)
            {
                var cnf = new ConfigurationData();
                var lg  = new Logger();

                try
                {
                    DriveCode  = ((WizardData)_win.DataContext).DriveCode;
                    DriveTitle = ((WizardData)_win.DataContext).DriveTitle;

                    DriveLetter          = ((WizardData)_win.DataContext).DriveLetter;
                    MaxImagesInDirectory = ((WizardData)_win.DataContext).MaxImagesInDirectory;
                    IsSecret             = ((WizardData)_win.DataContext).IsSecret;
                    byte SaveImages         = ((WizardData)_win.DataContext).SaveImages;
                    byte SaveThumbnails     = ((WizardData)_win.DataContext).SaveThumbnails;
                    byte SaveThumbnailsToDb = ((WizardData)_win.DataContext).SaveThumbnailsToDb;
                    byte SaveMedia          = ((WizardData)_win.DataContext).SaveMedia;
                    //var fm = new FileManager(cnf, lg);

                    //IDataManager dm = new DataManager(cnf, fm, lg, MaxImagesInDirectory);
                    //string drvLetter = DriveLetter;
                    //Dictionary<string, object> addParams = new Dictionary<string, object>();
                    //addParams.Add("IsSecret", IsSecret);

                    // CrtDrv(dm, drvLetter, DriveTitle, DriveCode, addParams);

                    //-----------
                    var worker = new Worker();

                    cancelTokenSource = new CancellationTokenSource();
                    token             = cancelTokenSource.Token;

                    if (App.Current.Windows.OfType <MainWindow>().FirstOrDefault() is MainWindow)
                    {
                        var progress = new Progress <int>(value => (App.Current.Windows.OfType <MainWindow>().FirstOrDefault()).progressBar.Value = value);
                        var id       = await worker.Work(progress, token, CreateDestination);

                        //------------


                        // _drivesViewModel.Load();
                        System.Windows.Forms.MessageBox.Show("Обработка Завершена");
                        //  progressBar.Value = 0;
                        var Log = lg.GetLog();
                        if (!string.IsNullOrWhiteSpace(Log))
                        {
                            System.Windows.Forms.MessageBox.Show(Log);
                        }
                    }
                }
                catch (Exception er)
                {
                    System.Windows.Forms.MessageBox.Show(er.Message);
                    if (!string.IsNullOrWhiteSpace(lg.GetLog()))
                    {
                        System.Windows.Forms.MessageBox.Show(lg.GetLog());
                    }
                }
            }


            var result = _win.DialogResult.Value;
        }