DesktopHelper.UI.CalendarForm.ShowForm C# (CSharp) Метод

ShowForm() публичный Метод

显示窗体
public ShowForm ( AnchorStyles StopAanhor, int x, int y ) : void
StopAanhor AnchorStyles
x int
y int
Результат void
        public void ShowForm(AnchorStyles StopAanhor, int x, int y)
        {
            try
            {
                tabControl.SelectedIndex = 0;
                btnToday_Click(null, null);

                #region
                switch (StopAanhor)
                {
                    case AnchorStyles.Top:
                        if (x > this.Width / 2)
                        {
                            if ((rectangle_Screen.Right - x) > this.Width / 2)
                            {
                                this.rectangle_This = new Rectangle(x + 28 - this.Width / 2, y + 58, this.Width, this.Height);
                            }
                            else
                            {
                                this.rectangle_This = new Rectangle(x - this.Width + 56, y + 58, this.Width, this.Height);
                            }
                        }
                        else
                        {
                            this.rectangle_This = new Rectangle(x, y + 58, this.Width, this.Height);
                        }
                        break;
                    case AnchorStyles.Left:
                        if (y > this.Height / 2)
                        {
                            if ((rectangle_Screen.Bottom - y) > this.Height / 2)
                            {
                                this.rectangle_This = new Rectangle(x + 58, y + 28 - this.Height / 2, this.Width, this.Height);
                            }
                            else
                            {
                                this.rectangle_This = new Rectangle(x + 58, y - this.Height + 56, this.Width, this.Height);
                            }
                        }
                        else
                        {
                            this.rectangle_This = new Rectangle(x + 58, y, this.Width, this.Height);
                        }
                        break;
                    case AnchorStyles.Right:
                        if (y > this.Height / 2)
                        {
                            if ((rectangle_Screen.Bottom - y) > this.Height / 2)
                            {
                                this.rectangle_This = new Rectangle(x - this.Width, y + 28 - this.Height / 2, this.Width, this.Height);
                            }
                            else
                            {
                                this.rectangle_This = new Rectangle(x - this.Width, y - this.Height + 56, this.Width, this.Height);
                            }
                        }
                        else
                        {
                            this.rectangle_This = new Rectangle(x - this.Width, y, this.Width, this.Height);
                        }
                        break;
                    case AnchorStyles.Bottom:
                        if (x > this.Width / 2)
                        {
                            if ((rectangle_Screen.Right - x) > this.Width / 2)
                            {
                                this.rectangle_This = new Rectangle(x + 28 - this.Width / 2, y - this.Height, this.Width, this.Height);
                            }
                            else
                            {
                                this.rectangle_This = new Rectangle(x - this.Width + 56, y - this.Height, this.Width, this.Height);
                            }
                        }
                        else
                        {
                            this.rectangle_This = new Rectangle(x, y - this.Height, this.Width, this.Height);
                        }
                        break;
                }
                #endregion

                this.SetBounds(rectangle_This.X, rectangle_This.Y, rectangle_This.Width, rectangle_This.Height);//设置当前窗体的边界
                ShowWindow(this.Handle, 4, AW_SLIDE + AW_VER_NEGATIVE);//动态显示本窗体
            }
            catch(Exception ex)
            {
                log.WriteLog(ex.ToString());
            }
        }