private void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _dialog.StopProgressDialog();
            Marshal.ReleaseComObject(_dialog);
            _dialog = null;
            if (_currentAnimationModuleHandle != null)
            {
                _currentAnimationModuleHandle.Dispose();
                _currentAnimationModuleHandle = null;
            }

            if (_ownerHandle != IntPtr.Zero)
            {
                NativeMethods.EnableWindow(_ownerHandle, true);
            }

            var cancellationTokenSource = _cancellationTokenSource;

            if (!(cancellationTokenSource is null))
            {
                cancellationTokenSource.Dispose();
                _cancellationTokenSource = null;
            }

            OnRunWorkerCompleted(new RunWorkerCompletedEventArgs((!e.Cancelled && e.Error == null) ? e.Result : null, e.Error, e.Cancelled));
        }
Esempio n. 2
0
        private void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _dialog.StopProgressDialog();
            Marshal.ReleaseComObject(_dialog);
            _dialog = null;

            OnRunWorkerCompleted(new RunWorkerCompletedEventArgs((!e.Cancelled && e.Error == null) ? e.Result : null, e.Error, e.Cancelled));
        }
Esempio n. 3
0
        private void RunProgressDialog(IntPtr owner, object argument)
        {
            if (_backgroundWorker.IsBusy)
            {
                throw new InvalidOperationException("The progress dialog is already running.");
            }

            _cancellationPending = false;
            _dialog = new Interop.ProgressDialog();
            _dialog.SetTitle(WindowTitle);

            if (CancellationText.Length > 0)
            {
                _dialog.SetCancelMsg(CancellationText, null);
            }
            _dialog.SetLine(1, Text, UseCompactPathsForText, IntPtr.Zero);
            _dialog.SetLine(2, Description, UseCompactPathsForDescription, IntPtr.Zero);

            var flags = Interop.ProgressDialogFlags.Normal;

            if (owner != IntPtr.Zero)
            {
                flags |= Interop.ProgressDialogFlags.Modal;
            }
            switch (ProgressBarStyle)
            {
            case ProgressBarStyle.None:
                flags |= Interop.ProgressDialogFlags.NoProgressBar;
                break;

            case ProgressBarStyle.MarqueeProgressBar:
                if (NativeMethods.IsWindowsVistaOrLater)
                {
                    flags |= Interop.ProgressDialogFlags.MarqueeProgress;
                }
                else
                {
                    flags |= Interop.ProgressDialogFlags.NoProgressBar; // Older than Vista doesn't support marquee.
                }
                break;
            }
            if (ShowTimeRemaining)
            {
                flags |= Interop.ProgressDialogFlags.AutoTime;
            }
            if (!ShowCancelButton)
            {
                flags |= Interop.ProgressDialogFlags.NoCancel;
            }
            if (!MinimizeBox)
            {
                flags |= Interop.ProgressDialogFlags.NoMinimize;
            }

            _dialog.StartProgressDialog(owner, null, flags, IntPtr.Zero);
            _backgroundWorker.RunWorkerAsync(argument);
        }
Esempio n. 4
0
        private void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _dialog.StopProgressDialog();
            Marshal.ReleaseComObject(_dialog);
            _dialog = null;
            if (_currentAnimationModuleHandle != null)
            {
                _currentAnimationModuleHandle.Dispose();
                _currentAnimationModuleHandle = null;
            }

            OnRunWorkerCompleted(new RunWorkerCompletedEventArgs((!e.Cancelled && e.Error == null) ? e.Result : null, e.Error, e.Cancelled));
        }
Esempio n. 5
0
        private void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            _dialog.StopProgressDialog();
            Marshal.ReleaseComObject(_dialog);
            _dialog = null;
            if( _currentAnimationModuleHandle != null )
            {
                _currentAnimationModuleHandle.Dispose();
                _currentAnimationModuleHandle = null;
            }

            OnRunWorkerCompleted(new RunWorkerCompletedEventArgs((!e.Cancelled && e.Error == null) ? e.Result : null, e.Error, e.Cancelled));
        }
Esempio n. 6
0
        private void RunProgressDialog(IntPtr owner, object argument)
        {
            if( _backgroundWorker.IsBusy )
                throw new InvalidOperationException(Properties.Resources.ProgressDialogRunning);

            if( Animation != null )
            {
                try
                {
                    _currentAnimationModuleHandle = Animation.LoadLibrary();
                }
                catch( Win32Exception ex )
                {
                    throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.AnimationLoadErrorFormat, ex.Message), ex);
                }
                catch( System.IO.FileNotFoundException ex )
                {
                    throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.AnimationLoadErrorFormat, ex.Message), ex);
                }
            }

            _cancellationPending = false;
            _dialog = new Interop.ProgressDialog();
            _dialog.SetTitle(WindowTitle);
            if( Animation != null )
                _dialog.SetAnimation(_currentAnimationModuleHandle, (ushort)Animation.ResourceId);

            if( CancellationText.Length > 0 )
                _dialog.SetCancelMsg(CancellationText, null);
            _dialog.SetLine(1, Text, UseCompactPathsForText, IntPtr.Zero);
            _dialog.SetLine(2, Description, UseCompactPathsForDescription, IntPtr.Zero);

            Interop.ProgressDialogFlags flags = Ookii.Dialogs.Wpf.Interop.ProgressDialogFlags.Normal;
            if( owner != IntPtr.Zero )
                flags |= Ookii.Dialogs.Wpf.Interop.ProgressDialogFlags.Modal;
            switch( ProgressBarStyle )
            {
            case ProgressBarStyle.None:
                flags |= Ookii.Dialogs.Wpf.Interop.ProgressDialogFlags.NoProgressBar;
                break;
            case ProgressBarStyle.MarqueeProgressBar:
                if( NativeMethods.IsWindowsVistaOrLater )
                    flags |= Ookii.Dialogs.Wpf.Interop.ProgressDialogFlags.MarqueeProgress;
                else
                    flags |= Ookii.Dialogs.Wpf.Interop.ProgressDialogFlags.NoProgressBar; // Older than Vista doesn't support marquee.
                break;
            }
            if( ShowTimeRemaining )
                flags |= Ookii.Dialogs.Wpf.Interop.ProgressDialogFlags.AutoTime;
            if( !ShowCancelButton )
                flags |= Ookii.Dialogs.Wpf.Interop.ProgressDialogFlags.NoCancel;
            if( !MinimizeBox )
                flags |= Ookii.Dialogs.Wpf.Interop.ProgressDialogFlags.NoMinimize;

            _dialog.StartProgressDialog(owner, null, flags, IntPtr.Zero);
            _backgroundWorker.RunWorkerAsync(argument);
        }
Esempio n. 7
0
        private void RunProgressDialog(IntPtr owner, object argument)
        {
            if (_backgroundWorker.IsBusy)
            {
                throw new InvalidOperationException(Properties.Resources.ProgressDialogRunning);
            }

            if (Animation != null)
            {
                try
                {
                    _currentAnimationModuleHandle = Animation.LoadLibrary();
                }
                catch (Win32Exception ex)
                {
                    throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.AnimationLoadErrorFormat, ex.Message), ex);
                }
                catch (System.IO.FileNotFoundException ex)
                {
                    throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.AnimationLoadErrorFormat, ex.Message), ex);
                }
            }

            _cancellationPending = false;
            _dialog = new Interop.ProgressDialog();
            _dialog.SetTitle(WindowTitle);
            if (Animation != null)
            {
                _dialog.SetAnimation(_currentAnimationModuleHandle, (ushort)Animation.ResourceId);
            }

            if (CancellationText.Length > 0)
            {
                _dialog.SetCancelMsg(CancellationText, null);
            }
            _dialog.SetLine(1, Text, UseCompactPathsForText, IntPtr.Zero);
            _dialog.SetLine(2, Description, UseCompactPathsForDescription, IntPtr.Zero);

            Interop.ProgressDialogFlags flags = Ookii.Dialogs.Interop.ProgressDialogFlags.Normal;
            if (owner != IntPtr.Zero)
            {
                flags |= Ookii.Dialogs.Interop.ProgressDialogFlags.Modal;
            }
            switch (ProgressBarStyle)
            {
            case ProgressBarStyle.None:
                flags |= Ookii.Dialogs.Interop.ProgressDialogFlags.NoProgressBar;
                break;

            case ProgressBarStyle.MarqueeProgressBar:
                if (NativeMethods.IsWindowsVistaOrLater)
                {
                    flags |= Ookii.Dialogs.Interop.ProgressDialogFlags.MarqueeProgress;
                }
                else
                {
                    flags |= Ookii.Dialogs.Interop.ProgressDialogFlags.NoProgressBar; // Older than Vista doesn't support marquee.
                }
                break;
            }
            if (ShowTimeRemaining)
            {
                flags |= Ookii.Dialogs.Interop.ProgressDialogFlags.AutoTime;
            }
            if (!ShowCancelButton)
            {
                flags |= Ookii.Dialogs.Interop.ProgressDialogFlags.NoCancel;
            }
            if (!MinimizeBox)
            {
                flags |= Ookii.Dialogs.Interop.ProgressDialogFlags.NoMinimize;
            }

            _dialog.StartProgressDialog(owner, null, flags, IntPtr.Zero);
            _backgroundWorker.RunWorkerAsync(argument);
        }