private void OnPrintKeyValueChanged(PropertyChangedFromTextBoxEventArgs property) { BarCodeControl c = (BarCodeControl)property.PrintControl; PropertyModel p = property.Property; TextBox textBox = property.TextBox; DependencyObject d = DependencyHelper.FindVisualChildByName(c, "pText"); if (d != null) { Type t = d.GetType(); if (t == typeof(TextBlock)) { TextBlock r = d as TextBlock; string value = (string)Convert.ChangeType(p.Value, typeof(string)); if (CommonRule.HasChinese(p.Value.ToString())) { p.Value = c.PrintKeyValue; textBox.Text = c.PrintKeyValue; return; } r.Text = value; c.PrintKeyValue = r.Text; } } }
private void OnHeightChanged(PropertyChangedFromTextBoxEventArgs property) { PropertyModel p = property.Property; BarCodeControl c = (BarCodeControl)property.PrintControl; c.Height = (double)Convert.ChangeType(p.Value, typeof(double)); }
private void OnDirecChanged(PropertyChangedFromTextBoxEventArgs property) { PropertyModel p = property.Property; BarCodeControl c = (BarCodeControl)property.PrintControl; RotateTransform r = (RotateTransform)c.RenderTransform; if (r != null) { r.CenterX = c.Width / 2; r.CenterY = c.Height / 2; r.Angle = ((int)p.Value) * 90; } }
private void OnTextChanged(PropertyChangedFromTextBoxEventArgs property) { PropertyModel p = property.Property; BarCodeControl c = (BarCodeControl)property.PrintControl; DependencyObject d = DependencyHelper.FindVisualChildByName(c, p.Name); if (d != null) { Type t = d.GetType(); if (t == typeof(TextBlock)) { TextBlock r = d as TextBlock; int i = (int)Convert.ChangeType(p.Value, typeof(int)); if (i == 66) { r.Visibility = Visibility.Visible; } else { r.Visibility = Visibility.Collapsed; } } } }
/// <summary> /// XML创建界面 /// </summary> /// <param name="p"></param> private void CreateInterfaceByXML(PrintFactoryModel p) { //清空界面 canvasSpace.Children.Clear(); ZoomableCanvasScale = 4; PrintLable.Width = p.Width; PrintLable.Height = p.Height; UpdateScale(ScaleList[ZoomableCanvasScale], PrintLable.Width, PrintLable.Height); tbScale.Text = string.Format("{0}*", ScaleList[ZoomableCanvasScale]); foreach (PrintItemModel item in p.PrintItems) { switch (item.PrintFunctionName) { case "PrintBarcode": { BarCodeControl b = new BarCodeControl(); UpdatePrintControlData(item, b); PropertyModel o = GetPropertyItemByName(b.Propertys, "pDirec"); RotateTransform r = (RotateTransform)b.RenderTransform; if (r != null) { r.CenterX = b.Width / 2; r.CenterY = b.Height / 2; r.Angle = (int)Convert.ChangeType(o.Value, typeof(int)) * 90; } canvasSpace.Children.Add(b); break; } case "PrintTextWorld": { TextWorldControl b = new TextWorldControl(); UpdatePrintControlData(item, b); PropertyModel o = GetPropertyItemByName(b.Propertys, "fSpin"); RotateTransform r = (RotateTransform)b.RenderTransform; if (r != null) { int flag = (int)Convert.ChangeType(o.Value, typeof(int)); if (flag < 5) { r.CenterX = 0; r.CenterY = b.Height / 2; r.Angle = (flag - 1) * 90; } else { r.CenterX = b.Width / 2; r.CenterY = b.Height / 2; r.Angle = (flag - 5) * 90; } } canvasSpace.Children.Add(b); break; } case "PrintPCX": { PictureControl b = new PictureControl(); UpdatePrintControlData(item, b, false); canvasSpace.Children.Add(b); break; } case "PrintRectangle": { RectangleControl b = new RectangleControl(); UpdatePrintControlData(item, b); PropertyModel thickness = GetPropertyItemByName(b.Propertys, "thickness"); if (thickness != null) { Rectangle d = b.Content as Rectangle; if (d != null) { d.StrokeThickness = (double)Convert.ChangeType(thickness.Value, typeof(double)); } } canvasSpace.Children.Add(b); break; } case "PrintLineOr": { LineOrControl b = new LineOrControl(); UpdatePrintControlData(item, b); canvasSpace.Children.Add(b); break; } case "PrintBar2DQR": { Bar2DQRControl b = new Bar2DQRControl(); UpdatePrintControlData(item, b); b.MaxWidth = b.Width = b.MaxHeight = b.Height = item.Width; PropertyModel temp = b.Propertys.FirstOrDefault(x => { return(x.Name == "r"); }); if (temp != null) { b.CurrentEnlarge = (int)Convert.ChangeType(temp.Value, typeof(int)); } PropertyModel o = GetPropertyItemByName(b.Propertys, "o"); RotateTransform r = (RotateTransform)b.RenderTransform; if (r != null) { r.CenterX = b.Width / 2; r.CenterY = b.Height / 2; r.Angle = (int)Convert.ChangeType(o.Value, typeof(int)) * 90; } canvasSpace.Children.Add(b); break; } } } }