예제 #1
0
        public void OpDlgTest()
        {
            var idlg = new IOperationsProgressDialog();

            idlg.StartProgressDialog(IntPtr.Zero, OPPROGDLGF.OPPROGDLG_DEFAULT);
            idlg.SetOperation(SPACTION.SPACTION_FORMATTING);
            idlg.SetMode(PDMODE.PDM_RUN);
            idlg.UpdateProgress(0, 0, 0, 0, 0, 100);
            var srcd  = new Vanara.Windows.Shell.ShellFolder(KNOWNFOLDERID.FOLDERID_Documents);
            var destd = new Vanara.Windows.Shell.ShellFolder(KNOWNFOLDERID.FOLDERID_Desktop);

            idlg.UpdateLocations(srcd.IShellItem, destd.IShellItem);
            var rnd = new Random();

            for (uint i = 0; i < 100; i++)
            {
                if (idlg.GetOperationStatus() == PDOPSTATUS.PDOPS_CANCELLED)
                {
                    break;
                }
                idlg.UpdateProgress(i * 1024, 102400, i * 1024, 102400, i, 100);
                Thread.Sleep(rnd.Next(50, 250));
            }
            idlg.StopProgressDialog();
        }
예제 #2
0
 protected override void RunDialogImpl(IntPtr hwndOwner)
 {
     instance.StartProgressDialog(hwndOwner, (PROGDLG)Options);
     if (action != OperationAction.None)
     {
         instance.SetOperation(action);
     }
     if (mode != OperationMode.None)
     {
         instance.SetMode(mode);
     }
     UpdateLocations();
     UpdateProgress();
 }
        /// <summary>
        /// Shows the dialog with the specified parent. If the parent is null, uses the active form.
        /// </summary>
        /// <param name="parent"></param>
        public void Show(IWin32Window parent)
        {
            if (parent == null)
            {
                parent = Form.ActiveForm;
            }
            IntPtr handle = (parent == null) ? IntPtr.Zero : parent.Handle;

            _nativeProgressDialog = (IOperationsProgressDialog)Activator.CreateInstance(_progressDialogType);
            _nativeProgressDialog.StartProgressDialog(handle, dialogFlags);
            _nativeProgressDialog.SetOperation(operationFlags);
            _nativeProgressDialog.SetMode(modeFlags);
            UpdateProgress();
            dialogStatus = DIALOGSTATUS.DLG_RUNNING;
        }
예제 #4
0
        private void RunProgressDialog(IntPtr owner, object argument)
        {
            if (_backgroundWorker.IsBusy)
            {
                throw new InvalidOperationException(Resources.ProgressDialogRunning);
            }

            _dialog = new Interop.OperationsProgressDialog();

            OperationsProgressDialogFlags flags = OperationsProgressDialogFlags.Normal;

            if (owner != IntPtr.Zero)
            {
                flags |= OperationsProgressDialogFlags.Modal;
            }

            ProgressBarStyle style = ProgressBarStyle;

            if (style == ProgressBarStyle.None)
            {
                flags |= OperationsProgressDialogFlags.NoProgressBar;
            }
            else if (style == ProgressBarStyle.MarqueeProgressBar)
            {
                flags |= OperationsProgressDialogFlags.MarqueeProgress;
            }

            if (ShowTimeRemaining)
            {
                flags |= OperationsProgressDialogFlags.AutoTime;
            }
            if (!ShowCancelButton)
            {
                flags |= OperationsProgressDialogFlags.NoCancel;
            }
            if (!MinimizeBox)
            {
                flags |= OperationsProgressDialogFlags.NoMinimize;
            }
            if (DontDisplaySourcePath)
            {
                flags |= OperationsProgressDialogFlags.DontDisplaySourcePath;
            }
            if (DontDisplayDestPath)
            {
                flags |= OperationsProgressDialogFlags.DontDisplayDestPath;
            }
            if (DontDisplayLocations)
            {
                flags |= OperationsProgressDialogFlags.DontDisplayLocations;
            }
            if (EnablePause)
            {
                flags |= OperationsProgressDialogFlags.EnablePause;
            }
            if (AllowUndo)
            {
                flags |= OperationsProgressDialogFlags.AllowUndo;
            }
            if (NoMultiDayEstimates)
            {
                flags |= OperationsProgressDialogFlags.NoMultiDayEstimates;
            }

            int hr = _dialog.StartProgressDialog(owner, flags);

            Marshal.ThrowExceptionForHR(hr);
            _backgroundWorker.RunWorkerAsync(argument);
        }