Пример #1
0
        /// <summary>
        /// 高度值改变
        /// </summary>
        /// <param name="property"></param>
        private void OnHeightChanged(PropertyChangedFromTextBoxEventArgs property)
        {
            PropertyModel    p       = property.Property;
            TextBox          textBox = property.TextBox;
            TextWorldControl c       = (TextWorldControl)property.PrintControl;
            double           ex      = (double)Convert.ChangeType(p.Value, typeof(double));

            if (ex < c.MinHeight)
            {
                ex = c.MinHeight;
            }
            double h = c.Height;

            c.Height = ex;
            c.Width  = c.Width * (c.Height / h);
            p.Value  = ex;
            if (textBox != null)
            {
                textBox.Text = ex.ToString();
            }
        }
Пример #2
0
        private void OnSpinChanged(PropertyChangedFromTextBoxEventArgs property)
        {
            PropertyModel    p   = property.Property;
            TextWorldControl c   = (TextWorldControl)property.PrintControl;
            int             flag = (int)p.Value;
            RotateTransform r    = (RotateTransform)c.RenderTransform;

            if (r != null)
            {
                if (flag < 5)
                {
                    r.CenterX = 0;
                    r.CenterY = c.Height / 2;
                    r.Angle   = (flag - 1) * 90;
                }
                else
                {
                    r.CenterX = c.Width / 2;
                    r.CenterY = c.Height / 2;
                    r.Angle   = (flag - 5) * 90;
                }
            }
        }
Пример #3
0
        /// <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;
                }
                }
            }
        }