public void ShowPopup(System.Drawing.Rectangle parentRectangle) { try { timerClosePopup.Stop(); timerMinimizePopup.Stop(); _isClosingPopup = false; _isMinimizingPopup = false; if (_isShowingPopup || _isMaximizingPopup) { return; } if (_isMaximized) { return; } try { _isShowingPopup = true; _isMinimized = false; _isMinimizedByUser = false; _hasError = false; if (DriveService.IsSignedIn) { AboutInfo aboutInfo = DriveService.GetAbout(); string quotaBytesUsed = Math.Divide(aboutInfo.QuotaBytesUsedAggregate, 1073741824, 1).ToString(); string quotaBytesTotal = Math.Divide(aboutInfo.QuotaBytesTotal, 1073741824, 1).ToString(); string quotaBytesUsedInTrash = Math.Divide(aboutInfo.QuotaBytesUsedInTrash, 1073741824, 1).ToString(); labelStatus.Text = aboutInfo.Name + " Using " + quotaBytesUsed + " GB of " + quotaBytesTotal + " GB - " + quotaBytesUsedInTrash + " GB in Trash"; } _parentRectangle = parentRectangle; Width = _maxWidth; Height = _maxHeight; WindowState = FormWindowState.Normal; if (_parentRectangle.IsEmpty && !HwndBounds.IsEmpty) { _parentRectangle = HwndBounds; } if (_parentRectangle.IsEmpty) { _parentRectangle = Screen.PrimaryScreen.WorkingArea; } else { bool found = false; foreach (Screen screen in Screen.AllScreens) { if (screen.Bounds.Contains(HwndBounds)) { _parentRectangle = screen.WorkingArea; found = true; } } if (!found) { _parentRectangle = Screen.PrimaryScreen.WorkingArea; } } Height = MinimumSize.Height; int left = _parentRectangle.Right - Width - _parenRightOffset; int top = _parentRectangle.Bottom - Height - _parentBottomOffset; if (left < 0) { left = 0; } if (top < 0) { top = 0; } Left = left; Top = top; } finally { timerShowPopup.Start(); } } catch (Exception exception) { Log.Error(exception, false); } }
protected virtual void UpdateProgress(StatusType status, long bytesProcessed, long totalBytes, Exception exception) { try { _TotalBytes = totalBytes; if (status == StatusType.Completed) { _BytesProcessed = _TotalBytes; _PercentCompleted = 100; _RemainingTime = new TimeSpan(0); if (!Processed) { InvokeOnProgressChanged(); } _Status = StatusType.Completed; } else if (status == StatusType.Failed) { _RemainingTime = new TimeSpan(0); if (!Processed) { InvokeOnProgressChanged(); } if (IsCancellationRequested) { _Status = StatusType.Cancelled; } else { _Status = StatusType.Failed; if (exception != null) { _ExceptionMessage = exception.Message; } if (String.IsNullOrEmpty(_ExceptionMessage)) { _ExceptionMessage = "Unknown error"; } } } else { _Status = IsCancellationRequested ? StatusType.Cancelling : status; if (_BytesProcessed < bytesProcessed) { _BytesProcessed = bytesProcessed; try { _PercentCompleted = Convert.ToInt32(Math.IsWhatPercentOf(_BytesProcessed, _TotalBytes, 0)); } catch { } try { _RemainingTime = StopWatch.RemainingTimeSpan(_BytesProcessed, _TotalBytes); } catch { } } } if (Processed) { CloseFileStream(); } } catch (Exception exception2) { Log.Error(exception2, false); } }