private void Reset() { size = this.screen.Size; var task = Win32Helper.TaskRect().Rect.Height; if (size.Height > SystemInformation.VirtualScreen.Height) { size.Height = SystemInformation.VirtualScreen.Height - task; size.Width = (ratio * size.Height).ToInt(); } if (size.Width > SystemInformation.VirtualScreen.Width) { size.Width = SystemInformation.VirtualScreen.Width - task; size.Height = (size.Width / ratio).ToInt(); } if (size.Width > Width && size.Height > Height) { Width = size.Width; Height = size.Height; Width = (size.Width * 1.1).ToInt(); Height = (size.Height * 1.1).ToInt(); } else if (size.Height > Height * 1.1) { Height = (size.Height * 1.1).ToInt(); } else if (size.Width > Width * 1.1) { Width = (size.Width * 1.1).ToInt(); } if (Height > SystemInformation.VirtualScreen.Height) { Height = SystemInformation.VirtualScreen.Height - task; } if (Width > SystemInformation.VirtualScreen.Width) { Width = SystemInformation.VirtualScreen.Width - task; } TextShow = string.Format("{0:F0}%", size.Width * 100.0 / screen.Width); rect = new Rectangle((Width - size.Width) / 2, (Height - size.Height) / 2, size.Width, size.Height); }
private void Timer() { IntPtr handle = this.CurrentHandle; IntPtr current = NativeMethods.GetForegroundWindow(); if (handle == Progress.Auto && Control.FromHandle(current) == null) { this.Fade(0.0, 0.2); } else if (handle != Progress.Auto && handle != Progress.Manual && handle != current) { this.Fade(0.0, 0.2); } else if (IDelay) { this.Fade(0.0, 0.2); } else {//显示进度条 this.Fade(1.0, 0.2); this.progressBar1.Maximum = this.states.Max; this.progressBar1.Value = this.states.Value; } if (base.Opacity != this._targetOpacity) { double num = base.Opacity + this._opacitySpeed; if ((this._opacitySpeed > 0.0 && num > this._targetOpacity) || (this._opacitySpeed < 0.0 && num < this._targetOpacity)) { num = this._targetOpacity; } base.Opacity = num; if (num > 0.0) { if (this._opacitySpeed > 0) { RECT rect = new RECT(); bool result = false; if (handle == Progress.Auto && Control.FromHandle(current) != null) { result = NativeMethods.GetWindowRect(current, ref rect); } else if (handle == Progress.Manual) { result = NativeMethods.GetWindowRect(current, ref rect); } else { result = NativeMethods.GetWindowRect(handle, ref rect); } //成功获取父窗体区域 if (result) { Win32Helper.ShowWindow(base.Handle); this.Location = new Point( rect.Left + (rect.Right - rect.Left) / 2 - this.Width / 2, rect.Top + (rect.Bottom - rect.Top) / 2 - this.Height / 2); } } else if (this._opacitySpeed < 0) { Win32Helper.ShowWindow(base.Handle); } else { THide(); } } else { THide(); } } else if (handle == Progress.Auto) { RECT rect = new RECT(); if (Control.FromHandle(current) != null && NativeMethods.GetWindowRect(current, ref rect)) { Win32Helper.ShowWindow(base.Handle); } } else if (handle == Progress.Manual) { RECT rect = new RECT(); if (NativeMethods.GetWindowRect(current, ref rect)) { Win32Helper.ShowWindow(base.Handle); } } lbCaption.Text = this.CurrentCaption; toolCancel.Visible = this.ShowCancel; }