private void OnPrintKeyValueChanged(PropertyChangedFromTextBoxEventArgs property) { PropertyModel p = property.Property; Bar2DQRControl c = (Bar2DQRControl)property.PrintControl; c.PrintKeyValue = (string)p.Value; }
private void OnAmplificationChangd(PropertyChangedFromTextBoxEventArgs property) { PropertyModel p = property.Property; Bar2DQRControl c = (Bar2DQRControl)property.PrintControl; int e = (int)Convert.ChangeType(p.Value, typeof(int)); c.MinHeight = c.MaxHeight = c.Height = c.MinWidth = c.MaxWidth = c.Width = e * (1 + c.PrintKeyValue.Length); c.CurrentEnlarge = e; }
private void OnRotateChanged(PropertyChangedFromTextBoxEventArgs property) { PropertyModel p = property.Property; Bar2DQRControl c = (Bar2DQRControl)property.PrintControl; int flag = (int)p.Value; RotateTransform r = (RotateTransform)c.RenderTransform; if (r != null) { r.CenterX = c.Width / 2; r.CenterY = c.Height / 2; r.Angle = (flag) * 90; } }
/// <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; } } } }