/// <summary>
        ///复制元素
        /// </summary>
        /// <param name="newX"></param>
        /// <param name="newY"></param>
        /// <param name="newAngle"></param>
        private void ElementCopy(double newX, double newY, double newAngle)
        {
            if (viewModel.NowEditViewElement.Type == SeatManage.ClassModel.DimensionalElementTye.ReadingRoomName || viewModel.NowEditViewElement.Type == SeatManage.ClassModel.DimensionalElementTye.SeatNo || viewModel.NowEditViewElement.Type == SeatManage.ClassModel.DimensionalElementTye.Text)
            {
                MyUC.UC_TextElement element = new MyUC.UC_TextElement();
                element.viewModel.TextAlignment = viewModel.NowEditViewElement.TextAlignment;

                element.viewModel.Color         = viewModel.NowEditViewElement.Color;
                element.viewModel.FontSize      = viewModel.NowEditViewElement.FontSize;
                element.viewModel.Text          = viewModel.NowEditViewElement.Text;
                element.viewModel.ElementHeight = viewModel.NowEditViewElement.ElementHeight;
                element.viewModel.ElementWidth  = viewModel.NowEditViewElement.ElementWidth;
                element.viewModel.Type          = viewModel.NowEditViewElement.Type;
                if (element.viewModel.Type == SeatManage.ClassModel.DimensionalElementTye.SeatNo)
                {
                    foreach (FrameworkElement fe in elementCanvas.Children)
                    {
                        if (fe is MyUC.UC_TextElement && (fe as MyUC.UC_TextElement).viewModel.Type == SeatManage.ClassModel.DimensionalElementTye.SeatNo)
                        {
                            element.viewModel.Order++;
                        }
                    }
                }

                element.viewModel.ElementLeft = newX;
                element.viewModel.ElementTop  = newY;
                element.viewModel.Angle       = newAngle;

                elementCanvas.Children.Add(element);
                CanvalNewSize();
                ElementGetFouce(element);
            }
            else
            {
                MyUC.UC_Element element = new MyUC.UC_Element();
                element.viewModel.ImagePath     = viewModel.NowEditViewElement.ImagePath;
                element.viewModel.ElementHeight = viewModel.NowEditViewElement.ElementHeight;
                element.viewModel.ElementWidth  = viewModel.NowEditViewElement.ElementWidth;
                element.viewModel.Type          = viewModel.NowEditViewElement.Type;
                if (element.viewModel.Type == SeatManage.ClassModel.DimensionalElementTye.SeatCode)
                {
                    foreach (FrameworkElement fe in elementCanvas.Children)
                    {
                        if (fe is MyUC.UC_Element && (fe as MyUC.UC_Element).viewModel.Type == SeatManage.ClassModel.DimensionalElementTye.SeatCode)
                        {
                            element.viewModel.Order++;
                        }
                    }
                }

                element.viewModel.ElementLeft = newX;
                element.viewModel.ElementTop  = newY;
                element.viewModel.Angle       = newAngle;

                elementCanvas.Children.Add(element);
                CanvalNewSize();
                ElementGetFouce(element);
            }
        }
 /// <summary>
 /// 添加二维码
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_AddCode_Click(object sender, RoutedEventArgs e)
 {
     MyUC.UC_Element element = new MyUC.UC_Element();
     element.viewModel.ImagePath   = AppDomain.CurrentDomain.BaseDirectory + "CodeImage.png";
     element.viewModel.Type        = SeatManage.ClassModel.DimensionalElementTye.SeatCode;
     element.viewModel.ElementLeft = 0;
     element.viewModel.ElementTop  = 0;
     elementCanvas.Children.Add(element);
     CanvalNewSize();
 }
        /// <summary>
        /// 添加装饰图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_AddImage_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = false;
            ofd.Filter      = "装饰图片|*.jpg;*.bmp;*.jpeg;*.png";
            ofd.ShowDialog();
            if (!string.IsNullOrEmpty(ofd.FileName))
            {
                MyUC.UC_Element element = new MyUC.UC_Element();
                element.viewModel.ImagePath   = ofd.FileName;
                element.viewModel.Type        = SeatManage.ClassModel.DimensionalElementTye.Image;
                element.viewModel.ElementLeft = 0;
                element.viewModel.ElementTop  = 0;
                elementCanvas.Children.Add(element);
                CanvalNewSize();
            }
        }
        /// <summary>
        /// 获取焦点
        /// </summary>
        /// <param name="targetElement"></param>
        private void ElementGetFouce(MyUC.UC_Element targetElement)
        {
            foreach (UserControl fe in elementCanvas.Children)
            {
                fe.BorderThickness = new Thickness(0);
            }
            targetElement.BorderThickness  = new Thickness(5);
            viewModel.NowEditViewElement   = targetElement.viewModel;
            cb_Angle.SelectedValue         = viewModel.NowEditViewElement.Angle;
            cb_TextAlignment.SelectedValue = viewModel.NowEditViewElement.TextAlignment;
            g_color.Visibility             = System.Windows.Visibility.Collapsed;
            g_Other.Visibility             = System.Windows.Visibility.Collapsed;
            g_Text.Visibility = System.Windows.Visibility.Collapsed;
            switch (targetElement.viewModel.Type)
            {
            case SeatManage.ClassModel.DimensionalElementTye.Background:
            case SeatManage.ClassModel.DimensionalElementTye.Image:
                break;

            case SeatManage.ClassModel.DimensionalElementTye.ReadingRoomName:
                g_Text.Visibility  = System.Windows.Visibility.Visible;
                g_color.Visibility = System.Windows.Visibility.Visible;
                break;

            case SeatManage.ClassModel.DimensionalElementTye.SeatCode:
                g_Other.Visibility = System.Windows.Visibility.Visible;
                break;

            case SeatManage.ClassModel.DimensionalElementTye.SeatNo:
                g_Text.Visibility  = System.Windows.Visibility.Visible;
                g_color.Visibility = System.Windows.Visibility.Visible;
                g_Other.Visibility = System.Windows.Visibility.Visible;
                break;

            case SeatManage.ClassModel.DimensionalElementTye.Text:
                g_Text.Visibility  = System.Windows.Visibility.Visible;
                g_color.Visibility = System.Windows.Visibility.Visible;
                break;
            }
            //this.DataContext = viewModel;
        }
        /// <summary>
        /// 鼠标移动拖拽
        /// </summary>
        /// <param name="e"></param>
        /// <param name="targetElement"></param>
        private void ElementMove(MouseEventArgs e, MyUC.UC_Element targetElement)
        {
            ElementGetFouce(targetElement);
            Point pCanvas = e.GetPosition(elementCanvas);

            pCanvas.X = pCanvas.X % 1 == 0 ? pCanvas.X : pCanvas.X - (pCanvas.X % 1);
            pCanvas.Y = pCanvas.Y % 1 == 0 ? pCanvas.Y : pCanvas.Y - (pCanvas.Y % 1);
            switch (mouseDownType)
            {
            case "Move":
            {
                double newX = pCanvas.X - ptargetElement.X;
                double newY = pCanvas.Y - ptargetElement.Y;
                newX = newX % viewModel.MinXY == 0 ? newX : newX - (newX % viewModel.MinXY);
                newY = newY % viewModel.MinXY == 0 ? newY : newY - (newY % viewModel.MinXY);
                targetElement.viewModel.ElementLeft = newX < 0 ? 0 : newX;
                targetElement.viewModel.ElementTop  = newY < 0 ? 0 : newY;
                viewModel.TemplateWidth             = (newX + targetElement.Width) > viewModel.TemplateWidth ? newX + targetElement.Width : viewModel.TemplateWidth;
                viewModel.TemplateHeight            = (newY + targetElement.Height) > viewModel.TemplateHeight ? newY + targetElement.Height : viewModel.TemplateHeight;
                VB_Element.Height = viewModel.TemplateHeight * daltaSliderValue / 30;
                VB_Element.Width  = viewModel.TemplateWidth * daltaSliderValue / 30;
            }
            break;

            case "Deform":
            {
                double newWidth  = (pCanvas.X - targetElement.viewModel.ElementLeft) > (pCanvas.Y - targetElement.viewModel.ElementTop) ? ((pCanvas.X - targetElement.viewModel.ElementLeft) < 100 ? 100 : pCanvas.X - targetElement.viewModel.ElementLeft) : ((pCanvas.Y - targetElement.viewModel.ElementTop) < 100 ? 100 : pCanvas.Y - targetElement.viewModel.ElementTop);
                double newHeight = ((newWidth / targetElement.viewModel.ElementWidth) * targetElement.viewModel.ElementHeight);
                targetElement.viewModel.ElementWidth  = newWidth;
                targetElement.viewModel.ElementHeight = newHeight;
                viewModel.TemplateWidth  = pCanvas.X > viewModel.TemplateWidth ? pCanvas.X : viewModel.TemplateWidth;
                viewModel.TemplateHeight = pCanvas.Y > viewModel.TemplateHeight ? pCanvas.X : viewModel.TemplateHeight;
                VB_Element.Height        = viewModel.TemplateHeight * daltaSliderValue / 30;
                VB_Element.Width         = viewModel.TemplateWidth * daltaSliderValue / 30;
            }
            break;
            }
        }