public MainWindow()
        {
            TaskbarItemInfo = new System.Windows.Shell.TaskbarItemInfo();
            TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.None;

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;

            InitializeComponent();
            viewModel = new MainScreenVM();
            DataContext = viewModel;
            viewModel.SearchBoxChanged += viewModel_SearchBoxChanged;
            viewModel.ProviderChanged  += viewModel_ProviderChanged;
            ImageList.SelectedItem = null;

            if (GlobalSettings.Instance.MainScreenWidth > 0)
            {
                this.Width = GlobalSettings.Instance.MainScreenWidth;
                this.Height = GlobalSettings.Instance.MainScreenHeight;
            }
        }
Exemple #2
0
        public void UpdateProgressBar(float curValue, float maxValue)
        {
            if (this.ClosedByUser)
            {
                return;
            }

            if (this.TaskbarItemInfo == null)
            {
                // taskbar progress object
                var taskbarinfo = new System.Windows.Shell.TaskbarItemInfo();
                taskbarinfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal;
                this.TaskbarItemInfo      = taskbarinfo;
            }

            var progValue = (curValue / maxValue);

            this.TaskbarItemInfo.ProgressValue = progValue;

            WaitReadyBrowser();
            if (renderer.Document != null)
            {
                if (!this.IsVisible)
                {
                    try
                    {
                        this.Show();
                        this.Focus();
                    }
                    catch
                    {
                        return;
                    }
                }

                var pbargraph = renderer.Document.GetElementById(ExternalConfig.progressbarid);
                if (pbargraph == null)
                {
                    if (renderer.Document != null)
                    {
                        var pbar         = renderer.Document.CreateElement(ExternalConfig.progressindicator);
                        var newpbargraph = renderer.Document.CreateElement(ExternalConfig.progressbar);
                        pbar.AppendChild(newpbargraph);
                        renderer.Document.Body.AppendChild(pbar);
                    }

                    pbargraph = renderer.Document.GetElementById(ExternalConfig.progressbarid);
                }

                SetProgressBarVisibility(true);

                var newWidthStyleProperty = String.Format("width:{0}%;", progValue * 100);
                if (pbargraph.Style == null)
                {
                    pbargraph.Style = newWidthStyleProperty;
                }
                else
                {
                    pbargraph.Style = Regex.Replace(pbargraph.Style, "width:.+?;", newWidthStyleProperty, RegexOptions.IgnoreCase);
                }
            }
        }
Exemple #3
0
 public HoughPupilFinder(string videoFileName, System.Windows.Controls.ProgressBar progressBar, System.Windows.Shell.TaskbarItemInfo taskbar,
                         SetStatusDelegate setStatus, FrameProcessedDelegate updateFrame, FramesProcessedDelegate framesProcessed)
     : base(videoFileName, progressBar, taskbar, setStatus, updateFrame, framesProcessed)
 {
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Storyboard animation;

            if (recordButton.IsChecked == false)
            {
                {
                    animation = this.FindResource("animateBackgroundReturn") as Storyboard;
                    this.BeginStoryboard(animation);
                }

                myrecorder.Stop();

                //((App)Application.Current).overlayWnd.Hide();
                this.Visibility = Visibility.Hidden;

                try
                {
                    var p = new PostWindow();
                    p.ShowDialog();

                    myrecorder.Reset();

                    var x = new System.Windows.Shell.TaskbarItemInfo();
                    x.ProgressState      = System.Windows.Shell.TaskbarItemProgressState.Normal;
                    this.TaskbarItemInfo = x;

                    this.Visibility = Visibility.Visible;
                    ((App)Application.Current).overlayWnd.Show();
                } catch (Exception ex)
                {
                    CrashHelpMe.CreateCrashReport(ex);

                    {
                        try
                        {
                            if (System.IO.File.Exists(myrecorder.FilePath))
                            {
                                var emergency_wav = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop), myrecorder.FileName + ".wav");
                                System.IO.File.Copy(myrecorder.FilePath, emergency_wav);

                                var x1 = new SpecialMessageBox();
                                x1.ShowMessage(this, "Unexpected error", "Due to an error, the MP3 may not have been saved.", String.Format("The app ran into a problem. As a precaution, the recording WAV file has been copied to your Desktop. You can continue editing the WAV file in Audacity, etc. from there.\n{0}", ex.Message));

                                System.Diagnostics.Process.Start("explorer.exe", "/select,\"" + emergency_wav + "\"");
                            }
                            else
                            {
                                var x1 = new SpecialMessageBox();
                                x1.ShowMessage(this, "Unexpected error", "Due to an error, the recording seems to have failed.", String.Format("The app ran into a problem. The WAV file may have failed to record.\n{0}", ex.Message));
                                System.Diagnostics.Process.Start("explorer.exe", "/select,\"" + ((App)Application.Current).Options.TempLocation + "\"");
                            }
                        }
                        catch (Exception ex2)
                        {
                            var x1 = new SpecialMessageBox();
                            x1.ShowMessage(this, "Unexpected error", "Due to an error, the MP3 may not have been saved.", String.Format("The app ran into a problem:\n{0}", ex2.Message));

                            System.Diagnostics.Process.Start("explorer.exe", "/select,\"" + myrecorder.FilePath + "\"");
                        }
                    }
                    Close();
                }
            }
            else
            {
                {
                    animation = this.FindResource("animateBackground") as Storyboard;
                    this.BeginStoryboard(animation);
                }

                {
                    Dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate() {
                        OverlayWindow ow = ((App)Application.Current).overlayWnd;
                        ow.animateBlink.Stop();
                    });
                }

                myrecorder.Record();

                var x = new System.Windows.Shell.TaskbarItemInfo();
                x.ProgressState      = System.Windows.Shell.TaskbarItemProgressState.Error;
                x.ProgressValue      = 1;
                this.TaskbarItemInfo = x;

                if (((App)Application.Current).Options.AutoMinimise)
                {
                    this.WindowState = WindowState.Minimized;
                }
            }

            updateUI();
        }