/// <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_Remark_Click(object sender, RoutedEventArgs e) { MyUC.UC_TextElement element = new MyUC.UC_TextElement(); element.viewModel.Type = SeatManage.ClassModel.DimensionalElementTye.Text; element.viewModel.ElementLeft = 0; element.viewModel.ElementTop = 0; element.viewModel.ElementHeight = 80; element.viewModel.ElementWidth = 400; element.viewModel.FontSize = 50; element.viewModel.Text = "【座位二维码扫描】"; elementCanvas.Children.Add(element); CanvalNewSize(); }
/// <summary> /// 添加阅览室编号 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_RoomNo_Click(object sender, RoutedEventArgs e) { MyUC.UC_TextElement element = new MyUC.UC_TextElement(); element.viewModel.Type = SeatManage.ClassModel.DimensionalElementTye.ReadingRoomName; element.viewModel.ElementLeft = 0; element.viewModel.ElementTop = 0; element.viewModel.ElementHeight = 80; element.viewModel.ElementWidth = 500; element.viewModel.FontSize = 50; element.viewModel.Text = "A202第一期刊阅览室B区"; elementCanvas.Children.Add(element); CanvalNewSize(); }
/// <summary> /// 添加座位编号 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_SeatNo_Click(object sender, RoutedEventArgs e) { MyUC.UC_TextElement element = new MyUC.UC_TextElement(); element.viewModel.Type = SeatManage.ClassModel.DimensionalElementTye.SeatNo; element.viewModel.ElementLeft = 0; element.viewModel.ElementTop = 0; element.viewModel.ElementHeight = 100; element.viewModel.ElementWidth = 300; element.viewModel.FontSize = 100; element.viewModel.Text = "A01"; element.viewModel.TextAlignment = SeatManage.ClassModel.ElementTextAlignment.Center; elementCanvas.Children.Add(element); CanvalNewSize(); }
private void ElementGetFouce(MyUC.UC_TextElement 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; }
private void ElementMove(MouseEventArgs e, MyUC.UC_TextElement 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": { targetElement.viewModel.ElementWidth = (pCanvas.X - targetElement.viewModel.ElementLeft) < 100 ? 100 : pCanvas.X - targetElement.viewModel.ElementLeft; targetElement.viewModel.ElementHeight = (pCanvas.Y - targetElement.viewModel.ElementTop) < 50 ? 50 : pCanvas.Y - targetElement.viewModel.ElementTop; 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; } }