Exemplo n.º 1
0
        public AboutInfo Invoke()
        {
            try
            {
                AboutInfo aboutInfo = DriveService.GetAbout();

                return(aboutInfo);
            }
            catch (Exception exception)
            {
                Log.Error(exception);

                return(null);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }