Exemplo n.º 1
0
        private void Window_Click(object sender, RoutedEventArgs e)
        {
            // 为子窗体的宽和高生成随机数目的是避免子窗体互相重叠.
            Random ro = new Random();

            height = ro.Next(500);
            width  = ro.Next(500);
            Button btn = e.Source as Button;

            if (btn != null)
            {
                switch (btn.Tag as string)
                {
                case "Ellipse Window":
                    EllipseWindow ellipseWindow = new EllipseWindow();

                    // 显示椭圆子窗体
                    ellipseWindow.Left = this.Left + this.Width + width;
                    ellipseWindow.Top  = this.Top + this.Height + height;
                    ellipseWindow.Show();
                    break;

                case "Rounded Corners Window":
                    RoundedCornersWindow roundedCornersWindow = new RoundedCornersWindow();

                    // 显示圆角子窗体
                    roundedCornersWindow.Left = this.Left + this.Width + width;
                    roundedCornersWindow.Top  = this.Top + this.Height + height;

                    roundedCornersWindow.Show();
                    break;

                case "Triangle Corners Window":
                    TriangleCornersWindow triangleCornersWindow = new TriangleCornersWindow();

                    // 显示三角形子窗体
                    triangleCornersWindow.Left = this.Left + this.Width + width;
                    triangleCornersWindow.Top  = this.Top + this.Height + height;

                    triangleCornersWindow.Show();
                    break;

                case "Popup Corners Window":
                    PopupCornersWindow popupCornersWindow = new PopupCornersWindow();

                    // 显示对话子窗体
                    popupCornersWindow.Left = this.Left + this.Width + width;
                    popupCornersWindow.Top  = this.Top + this.Height + height;

                    popupCornersWindow.Show();
                    break;

                case "Picture Based Windows":
                    PictureBasedWindow picturebasedWindows = new PictureBasedWindow();

                    // 显示图片背景子窗体
                    picturebasedWindows.Left = this.Left + this.Width + width;
                    picturebasedWindows.Top  = this.Top + this.Height + height;

                    picturebasedWindows.Show();
                    break;

                default:
                    break;
                }
            }
        }
        private void Window_Click(object sender, RoutedEventArgs e)
        {
            // 为子窗体的宽和高生成随机数目的是避免子窗体互相重叠.
            Random ro = new Random();
            height = ro.Next(500);
            width = ro.Next(500);
            Button btn = e.Source as Button;
            if (btn != null)
            {
                switch (btn.Tag as string)
                {
                    case "Ellipse Window":
                        EllipseWindow ellipseWindow = new EllipseWindow();

                        // 显示椭圆子窗体
                        ellipseWindow.Left = this.Left + this.Width + width;
                        ellipseWindow.Top = this.Top + this.Height + height;
                        ellipseWindow.Show();
                        break;
                    case "Rounded Corners Window":
                        RoundedCornersWindow roundedCornersWindow = new RoundedCornersWindow();

                        // 显示圆角子窗体
                        roundedCornersWindow.Left = this.Left + this.Width + width;
                        roundedCornersWindow.Top = this.Top + this.Height + height;

                        roundedCornersWindow.Show();
                        break;
                    case "Triangle Corners Window":
                        TriangleCornersWindow triangleCornersWindow = new TriangleCornersWindow();

                        // 显示三角形子窗体
                        triangleCornersWindow.Left = this.Left + this.Width + width;
                        triangleCornersWindow.Top = this.Top + this.Height + height;

                        triangleCornersWindow.Show();
                        break;
                    case "Popup Corners Window":
                        PopupCornersWindow popupCornersWindow = new PopupCornersWindow();

                        // 显示对话子窗体
                        popupCornersWindow.Left = this.Left + this.Width + width;
                        popupCornersWindow.Top = this.Top + this.Height + height;

                        popupCornersWindow.Show();
                        break;
                    case "Picture Based Windows":
                        PictureBasedWindow picturebasedWindows = new PictureBasedWindow();

                        // 显示图片背景子窗体
                        picturebasedWindows.Left = this.Left + this.Width + width;
                        picturebasedWindows.Top = this.Top + this.Height + height;

                        picturebasedWindows.Show();
                        break;

                    default:
                        break;
                }
            }
        }