Пример #1
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));
        }
Пример #2
0
 public static extern int LoadString(SafeModuleHandle hInstance, uint uID, StringBuilder lpBuffer, int nBufferMax);
Пример #3
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 = CrystalLib.Toolset.Dialogs.Interop.ProgressDialogFlags.Normal;
            if( owner != IntPtr.Zero )
                flags |= CrystalLib.Toolset.Dialogs.Interop.ProgressDialogFlags.Modal;
            switch( ProgressBarStyle )
            {
            case ProgressBarStyle.None:
                flags |= CrystalLib.Toolset.Dialogs.Interop.ProgressDialogFlags.NoProgressBar;
                break;
            case ProgressBarStyle.MarqueeProgressBar:
                if( NativeMethods.IsWindowsVistaOrLater )
                    flags |= CrystalLib.Toolset.Dialogs.Interop.ProgressDialogFlags.MarqueeProgress;
                else
                    flags |= CrystalLib.Toolset.Dialogs.Interop.ProgressDialogFlags.NoProgressBar; // Older than Vista doesn't support marquee.
                break;
            }
            if( ShowTimeRemaining )
                flags |= CrystalLib.Toolset.Dialogs.Interop.ProgressDialogFlags.AutoTime;
            if( !ShowCancelButton )
                flags |= CrystalLib.Toolset.Dialogs.Interop.ProgressDialogFlags.NoCancel;
            if( !MinimizeBox )
                flags |= CrystalLib.Toolset.Dialogs.Interop.ProgressDialogFlags.NoMinimize;

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