/// <summary> /// Closes the dialog. /// </summary> public async void Close() { if (_nativeProgressDialog != null && dialogStatus != DIALOGSTATUS.DLG_DISPOSED) { _nativeProgressDialog.StopProgressDialog(); dialogStatus = DIALOGSTATUS.DLG_DISPOSED; await Task.Delay(900); Marshal.FinalReleaseComObject(_nativeProgressDialog); _nativeProgressDialog = null; } }
/// <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; }
/// <summary> /// Initializes the dialog. /// </summary> public OperationsProgressDialog() { dialogStatus = DIALOGSTATUS.DLG_NOTSTARTED; _progressDialogType = Type.GetTypeFromCLSID(new Guid(CLSID_ProgressDialog)); _IShellItemType = Type.GetTypeFromCLSID(new Guid(CLSID_IShellItem)); dialogFlags = PROGDLG.PROGDLG_NORMAL; operationFlags = SPACTION.SPACTION_NONE; modeFlags = PDMODE.PDM_DEFAULT; currentProgress = 0; totalProgress = 100; currentSize = 0; totalSize = 100; currentItems = 0; totalItems = 100; estimateValue = false; SHCreateItemFromParsingName("https://andai.heliohost.org/packages.php", IntPtr.Zero, typeof(IShellItem).GUID, out sourceItem); SHCreateItemFromParsingName(Environment.CurrentDirectory, IntPtr.Zero, typeof(IShellItem).GUID, out destItem); SHCreateItemFromParsingName(Environment.CurrentDirectory, IntPtr.Zero, typeof(IShellItem).GUID, out currentItem); }