コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: bibonev/BuildView
        private void meshSmooth_Click(object sender, RoutedEventArgs e)
        {
            ProcessStartInfo start = new ProcessStartInfo();

            string PCLName         = Path.Combine(Path.GetTempPath(), "PCL_smooth.pcd");
            string PCLFilteredName = Path.Combine(Path.GetTempPath(), "PCL_filtered_smooth.pcd");

            start.WorkingDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
            start.Arguments        = "Smoothing";
            start.Arguments       += " \"" + PCLName + "\"";
            start.Arguments       += " \"" + PCLFilteredName + "\"";
            start.FileName         = "BuildViewCloudFliter.exe";
            start.WindowStyle      = ProcessWindowStyle.Hidden;
            start.CreateNoWindow   = true;


            ProgressDialogResult result = ProgressDialog.Execute(this, "Filtering data", (bw, we) =>
            {
                buildViewControl.model.ExportPcd(PCLName);

                using (Process proc = Process.Start(start))
                {
                    while (!proc.WaitForExit(1000))
                    {
                        if (ProgressDialog.CheckForPendingCancellation(bw, we))
                        {
                            proc.Kill();
                            return;
                        }
                    }
                }

                buildViewControl.model.ImportPcd(PCLFilteredName);
                buildViewControl.Buffers();
            }, ProgressDialogSettings.WithSubLabelAndCancel);

            if (result.OperationFailed)
            {
                System.Windows.MessageBox.Show("Processing failed.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else if (result.Cancelled)
            {
                File.Delete(PCLName);
                System.Windows.MessageBox.Show("Processing canceled successfully.", "Canceled", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                File.Delete(PCLName);
                File.Delete(PCLFilteredName);
                System.Windows.MessageBox.Show("Processing successfully executed.", "Successfull", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: fnwc/TV-Processor
        private void RunEntireFolder_Click(object sender, RoutedEventArgs e)
        {
            // clear output
            ClearMessages();

            // show progress handler
            var result = ProgressDialog.Execute(this, "Running Script...", (bw, we) =>
            {
                // tracking for progress
                int count = 0;
                var dirs  = _downloadingFolder.GetDirectories();

                // process all downloading folders (but not processing directory)
                foreach (var d in dirs)
                {
                    // increment count
                    count++;

                    // show progress
                    ProgressDialog.Report(bw, $"Matching {d.FullName}");

                    // match subdirectories
                    MatchDirectories(d, _downloadingFolder, out _downloadingDirectory, _processingFolder, out _processingDirectory);

                    // if we matched, process
                    if (_downloadingDirectory != null && _processingDirectory != null)
                    {
                        int pct = Convert.ToInt32((Convert.ToDecimal(count) / Convert.ToDecimal(dirs.Count())) * 100.0m);

                        // show progress
                        if (ProgressDialog.ReportWithCancellationCheck(bw, we, pct, $"Processing {d.FullName}"))
                        {
                            return;
                        }

                        // avoid default processing after the Cancel button has been pressed.
                        // This call will set the Cancelled flag on the result structure.
                        ProgressDialog.CheckForPendingCancellation(bw, we);

                        //process
                        ProcessDirectories();
                    }
                }
            }, new ProgressDialogSettings(true, true, false));

            // show results
            if (!result.OperationFailed)
            {
                ShowPostProcessMessages();
            }
        }
コード例 #3
0
        /// <summary>
        /// The eventhandler that gets injected in a call in InterpolateAutomatic_Click .
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void autoInterpolate_StartInterpolation(object sender, AutoInterpolationEventArgs e)
        {
            int    interpolatedFrames = 0;
            double result             = 0;

            interpolateMessageShown = false;

            ProgressDialogResult progressResult = ProgressDialog.Execute(this, "Interpolating", (bw, we) => {
                while (framesContainer.CursorIndex + interpolatedFrames < framesContainer.Count - 1 && result < e.ErrorValue)
                {
                    result = interpolationControl.InterpolateManual(framesContainer.CursorIndex + interpolatedFrames, e.ErrorValue);

                    if (result < e.ErrorValue)
                    {
                        interpolatedFrames++;
                        ProgressDialog.ReportWithCancellationCheck(bw, we, interpolatedFrames + " frames interpolated.");
                    }
                }
                ProgressDialog.CheckForPendingCancellation(bw, we);
            }, ProgressDialogSettings.WithSubLabelAndCancel);

            framesContainer.CursorIndex += interpolatedFrames;
            String response = "Interpolated a total of " + interpolatedFrames + " frames";

            if (progressResult.Cancelled)
            {
                response += " before the process was cancelled.";
            }
            else if (result >= e.ErrorValue)
            {
                response += " before the pixel error became too high.";
            }
            else
            {
                response += ".";
            }
            MessageBox.Show(response);
            this.projectstate.Saved = false;
        }
コード例 #4
0
ファイル: NewConvert.xaml.cs プロジェクト: msorescu/SpeedUp
        private void GenerateDefFilesButton_Click(object sender, RoutedEventArgs e)
        {
            if (!IsValidInputFields())
            {
                return;
            }
            _stopProgressDialog = false;
            ModuleId            = ModuleIDTextBox.Text;
            try
            {
                ProgressDialogResult result = ProgressDialog.Execute(this, "Loading data", (bw, we) =>
                {
                    //1.Creating Def files from template def files
                    if (ProgressDialog.ReportWithCancellationCheck(bw, we, 10,
                                                                   "Creating Def files from template def files...",
                                                                   1))
                    {
                        return;
                    }
                    Thread.Sleep(1000);
                    this.Dispatcher.Invoke((Action)(CreateNewDefFiles));
                    if (_stopProgressDialog)
                    {
                        ProgressDialog.CloseProgressDialog(bw, we);
                        return;
                    }
                    //2.Download Metadata
                    if (ProgressDialog.ReportWithCancellationCheck(bw, we, 20, "Downloading Metadata...", 2))
                    {
                        return;
                    }
                    Thread.Sleep(1000);

                    this.Dispatcher.Invoke((Action)(DownloadMlsMetadata));
                    if (_stopProgressDialog)
                    {
                        ProgressDialog.CloseProgressDialog(bw, we);
                        return;
                    }

                    //6.Generate search field
                    if (ProgressDialog.ReportWithCancellationCheck(bw, we, 60, "Generating Def Files...", 9))
                    {
                        return;
                    }
                    Thread.Sleep(1000);
                    this.Dispatcher.Invoke((Action)(GenerateSearchFields));
                    if (_stopProgressDialog)
                    {
                        ProgressDialog.CloseProgressDialog(bw, we);
                        return;
                    }
                    if (ProgressDialog.ReportWithCancellationCheck(bw, we, 100, "Done", 10))
                    {
                        return;
                    }
                    Thread.Sleep(1000);


                    //7.Status
                    //8.Property type

                    // So this check in order to avoid default processing after the Cancel button has been pressed.
                    // This call will set the Cancelled flag on the result structure.
                    ProgressDialog.CheckForPendingCancellation(bw, we);
                }, new ProgressDialogSettings(true, true, false));

                if (result.Cancelled)
                {
                    MessageBox.Show("Failed to generate Def files.");
                }
                else if (result.OperationFailed)
                {
                    MessageBox.Show("ProgressDialog failed.");
                }
                else
                {
                    MessageBox.Show("Def files have been successfully generated.");
                }
                if (!_stopProgressDialog)
                {
                    //Add Rets account info to db

                    using (TCSEntities tcsDb = new TCSEntities())
                    {
                        short moduleId = Convert.ToInt16(ModuleIDTextBox.Text);
                        if (!tcsDb.tcs_rets_connection_info.Any(x => x.module_id == moduleId))
                        {
                            tcs_rets_connection_info retsInfo = new tcs_rets_connection_info();
                            retsInfo.module_id    = moduleId;
                            retsInfo.account_type = 1;
                            retsInfo.rdc_code     = "N/A";
                            retsInfo.user_name    = LoginNameTextBox.Text;
                            retsInfo.password     = PasswordTextBox.Text;
                            retsInfo.user_agent   = UserAgentTextBox.Text;
                            retsInfo.ua_password  = UAPasswordTextBox.Text;
                            retsInfo.login_url    = LoginURLTextBox.Text;

                            tcsDb.AddTotcs_rets_connection_info(retsInfo);
                            tcsDb.SaveChanges();
                        }
                    }

                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to generate Def files. \r\n" + ex.Message);
            }
        }