Пример #1
0
        /// <summary>
        /// Starts the progress dialog box
        /// </summary>
        /// <param name="callback">Callback function which to be performed on each step</param>
        /// <remarks>This method automatically calls <see cref="Stop"/> upon <see cref="Complete"/> >= <see cref="Total"/></remarks>
        public void Start( ProgressOperationCallback callback )
        {
            //	ppd->StartProgressDialog(hwndParent, punk, PROGDLG_AUTOTIME, NULL); // Display and enable automatic estimated time remaining.
            this.m_ipDialog.StartProgressDialog(
                this.m_hwnd,
                null,
                (uint)( this.m_flags ),
                IntPtr.Zero );

            this.m_dlgClosed = false;

            //	// Reset because CalcTotalUnitsToDo() took a long time and the estimated time
            //	// is based on the time between ::StartProgressDialog() and the first
            //	// ::SetProgress() call.
            //	ppd->Timer(PDTIMER_RESET, NULL);
            this.m_ipDialog.Timer( PDTIMER_RESET, null );

            //	for (nIndex = 0; nIndex < nTotal; nIndex++) {
            //for( ulong i=0; i<this.m_dwTotal; i++ ) {
            while( this.m_dwTotal > this.m_dwComplete ) {
                //
                //	ppd->SetLine(2, L"I'm processing item n", FALSE, NULL);
                if( OnBeforeProgressUpdate != null )
                    OnBeforeProgressUpdate( this, EventArgs.Empty );

                //	dwComplete += DoSlowOperation();
                if( callback != null )
                    this.m_dwComplete = callback();
                else
                    this.m_dwComplete++;
                //
                //	ppd->SetProgress(dwCompleted, dwTotal);
                if( this.m_useULong )
                    this.m_ipDialog.SetProgress64( this.m_dwComplete, this.m_dwTotal );
                else
                    this.m_ipDialog.SetProgress( (uint)this.m_dwComplete, (uint)this.m_dwTotal );
                //	if (TRUE == ppd->HasUserCancelled())
                //		break;
                if( this.m_ipDialog.HasUserCancelled() ) {
                    // raise an event if required
                    if( OnUserCancelled != null ) {
                        OnUserCancelled( this, EventArgs.Empty );
                    }
                    break;
                }
            }
            //}

            this.Stop();
        }
Пример #2
0
        /// <summary>
        /// Starts the progress dialog box
        /// </summary>
        /// <param name="callback">Callback function which to be performed on each step</param>
        /// <remarks>This method automatically calls <see cref="Stop"/> upon <see cref="Complete"/> >= <see cref="Total"/></remarks>
        public void Start(ProgressOperationCallback callback)
        {
            //	ppd->StartProgressDialog(hwndParent, punk, PROGDLG_AUTOTIME, NULL); // Display and enable automatic estimated time remaining.
            this.m_ipDialog.StartProgressDialog(
                this.m_hwnd,
                null,
                (uint)(this.m_flags),
                IntPtr.Zero);

            this.m_dlgClosed = false;

            //	// Reset because CalcTotalUnitsToDo() took a long time and the estimated time
            //	// is based on the time between ::StartProgressDialog() and the first
            //	// ::SetProgress() call.
            //	ppd->Timer(PDTIMER_RESET, NULL);
            this.m_ipDialog.Timer(PDTIMER_RESET, null);

            //	for (nIndex = 0; nIndex < nTotal; nIndex++) {
            //for( ulong i=0; i<this.m_dwTotal; i++ ) {
            while (this.m_dwTotal > this.m_dwComplete)
            {
                //
                //	ppd->SetLine(2, L"I'm processing item n", FALSE, NULL);
                if (OnBeforeProgressUpdate != null)
                {
                    OnBeforeProgressUpdate(this, EventArgs.Empty);
                }

                //	dwComplete += DoSlowOperation();
                if (callback != null)
                {
                    this.m_dwComplete = callback();
                }
                else
                {
                    this.m_dwComplete++;
                }
                //
                //	ppd->SetProgress(dwCompleted, dwTotal);
                if (this.m_useULong)
                {
                    this.m_ipDialog.SetProgress64(this.m_dwComplete, this.m_dwTotal);
                }
                else
                {
                    this.m_ipDialog.SetProgress((uint)this.m_dwComplete, (uint)this.m_dwTotal);
                }
                //	if (TRUE == ppd->HasUserCancelled())
                //		break;
                if (this.m_ipDialog.HasUserCancelled())
                {
                    // raise an event if required
                    if (OnUserCancelled != null)
                    {
                        OnUserCancelled(this, EventArgs.Empty);
                    }
                    break;
                }
            }
            //}

            this.Stop();
        }