private void SlideForm_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) { if (SlideOutEnable) { e.Cancel = closeFlag; if (closeFlag) { currentMode = false; _timer.Enabled = true; _timer.Start(); if (SlideBegin != null) { SlideBegin.Invoke(this, new SlideFinishedEventArgs(SlideDirection.SlideOut)); } } } }
private void SlideForm_Load(System.Object sender, System.EventArgs e) { workRect = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea; sizeW = _attachedForm.Width; sizeH = _attachedForm.Height; //计算起点 if (xFrom == 0) { if (_DirectX == FlyXDirection.LeftToRight) { xFrom = workRect.Left - sizeW; } else { if (_DirectX == FlyXDirection.None) { xFrom = workRect.Right - sizeW; } else { xFrom = workRect.Right; } } } if (yFrom == 0) { if (_DirectY == FlyYDirection.TopToBottom) { yFrom = workRect.Top - sizeH; } else { if (_DirectY == FlyYDirection.None) { yFrom = workRect.Bottom - sizeH; } else { yFrom = workRect.Bottom; } } } //计算终点 if (_DirectY != FlyYDirection.None) { if (_DirectY == FlyYDirection.TopToBottom) { yTo = yFrom + sizeH; } else { yTo = yFrom - sizeH; } } else { yTo = yFrom; } if (_DirectX != FlyXDirection.None) { if (_DirectX == FlyXDirection.LeftToRight) { xTo = xFrom + sizeW; } else { xTo = xFrom - sizeW; } } else { xTo = xFrom; } //重置当前窗体位置 if (SlideInEnable) { _attachedForm.Location = new Point(xFrom, yFrom); closeFlag = true; //开始计时器 currentMode = true; _timer.Enabled = true; _timer.Start(); if (SlideBegin != null) { SlideBegin.Invoke(this, new SlideFinishedEventArgs(SlideDirection.SlideIn)); } } else { currentMode = false; _attachedForm.Location = new Point(xTo, yTo); currentMode = false; closeFlag = true; } }