Ejemplo n.º 1
0
        public object Format(PrintTemplate template, PrintTemplateItem item, long shopId)
        {
            var shop = ServiceContainer.GetService <ShopService>().GetById(shopId);

            if (shop == null || string.IsNullOrWhiteSpace(shop.Mark))
            {
                return("");
            }
            string file = System.IO.Path.Combine(EnvironmentDirHelper.DIR_DATA, shop.Mark + ".png");

            if (File.Exists(file) == false)
            {
                file = System.IO.Path.Combine(EnvironmentDirHelper.DIR_DATA, shop.Mark + ".jpg");
            }

            if (File.Exists(file) == false)
            {
                return(null);
            }
            var bi = new BitmapImage();

            bi.BeginInit();
            bi.UriSource = new Uri(file);
            bi.EndInit();
            return(bi);
        }
Ejemplo n.º 2
0
 public void ApplayStyleAndData(System.Windows.Style uiStyle, PrintTemplateItem item)
 {
     //创建UI
     this.UI = new Thumb {
         DataContext = this
     };
     this.UI.Style = uiStyle;
     this.UI.ApplyTemplate();
     Data = item;
     if (double.IsNaN(this.Data.X) || this.Data.X < 0)
     {
         this.Data.X = 0;
     }
     this.X = this.Data.X;
     if (double.IsNaN(this.Data.Y) || this.Data.Y < 0)
     {
         this.Data.Y = 0;
     }
     this.Y             = this.Data.Y;
     this.Width         = this.Data.Width;
     this.Height        = this.Data.Height;
     this.FontName      = this.Data.FontName;
     this.FontSize      = this.Data.FontSize;
     this.Format        = this.Data.Format;
     this.Type          = this.Data.Type;
     this.Value         = item.Value;
     this.Value1        = item.Value1;
     this.TextAlignment = item.TextAlignment;
     this.Opacity       = item.Opacity;
     this.ScaleFormat   = item.ScaleFormat;
     item.RunTimeTag    = this;
     AttachThumbEvents(this.UI);
 }
Ejemplo n.º 3
0
        public object Format(PrintTemplate template, PrintTemplateItem item, long shopId)
        {
            var shop = ServiceContainer.GetService <ShopService>().GetById(shopId);

            if (shop == null)
            {
                return("");
            }
            return(shop.Mark);
        }
Ejemplo n.º 4
0
        public object Format(PrintTemplate template, PrintTemplateItem item, OrderReturn or)
        {
            var ss = or.GoodsInfo.Split(new char[] { ',', ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (ss.Length > 0)
            {
                return(ss[0]);
            }
            throw new Exception("无法解析信息:" + or.GoodsInfo);
        }
Ejemplo n.º 5
0
        public object Format(PrintTemplate template, PrintTemplateItem item)
        {
            var af = template.AttachFiles.FirstOrDefault(obj => obj.Name == item.Format);

            if (af == null)
            {
                throw new Exception("图片不存在");
            }
            System.Drawing.Image i = null;
            using (var ms = new MemoryStream(af.Value, false))
            {
                i = System.Drawing.Image.FromStream(ms);
            }
            return(i);
        }
Ejemplo n.º 6
0
        public object Format(PrintTemplate template, PrintTemplateItem item)
        {
            if (string.IsNullOrWhiteSpace(item.Format))
            {
                item.Format = Brushes.Black.ToString();
            }
            int argb = int.Parse(item.Format.Replace("#", ""), System.Globalization.NumberStyles.HexNumber);

            System.Drawing.Color c   = System.Drawing.Color.FromArgb((int)(item.Opacity * 255), System.Drawing.Color.FromArgb(argb));
            System.Drawing.Pen   pen = new System.Drawing.Pen(c, (float)(item.Height > item.Width ? item.Width : item.Height));
            pen.DashStyle = item.Value == "是" ? System.Drawing.Drawing2D.DashStyle.Dot : System.Drawing.Drawing2D.DashStyle.Solid;
            pen.DashCap   = System.Drawing.Drawing2D.DashCap.Flat;
            pen.EndCap    = System.Drawing.Drawing2D.LineCap.Flat;
            pen.StartCap  = System.Drawing.Drawing2D.LineCap.Flat;
            return(pen);
        }
Ejemplo n.º 7
0
        public object Format(PrintTemplate template, PrintTemplateItem item, OrderGoods orderGoods)
        {
            string ma = "材质:";

            if (orderGoods.GoodsId < 1)
            {
                return(ma);
            }
            var gu = ServiceContainer.GetService <GoodsService>().GetById(orderGoods.GoodsId);

            if (gu != null)
            {
                return(ma + gu.Material);
            }

            return("");
        }
Ejemplo n.º 8
0
        public object Format(PrintTemplate template, PrintTemplateItem item)
        {
            if (string.IsNullOrWhiteSpace(item.Format) || string.IsNullOrWhiteSpace(item.Value))
            {
                throw new Exception("配置项参数不完整");
            }

            char[] cc = new char[int.Parse(item.Value)];
            for (int i = 0; i < cc.Length; i++)
            {
                int j = r.Next(item.Format.Length);
                cc[i] = item.Format[j];
            }
            if (cc[0] == '-' && cc.Length > 1)
            {
                cc[0] = item.Format.FirstOrDefault(c => c != '-');
            }

            return(item.Value1 + new string(cc));
        }
        /// <summary>
        /// 点击增加模板中的打印项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeliveryPrintTemplateItemType_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                FrameworkElement cb = sender as FrameworkElement;
                if (cb == null)
                {
                    return;
                }
                var deliveryTemplate = this.lstDeliveryPrintTemplates.SelectedItem as PrintTemplate;
                PrintTemplateItemTypeViewModel   vmItem        = cb.DataContext as PrintTemplateItemTypeViewModel;
                PrintTemplateItemViewModelCommon itemViewModel = PrintTemplateItemViewModelFactory.Create(deliveryTemplate, vmItem.Type, vmItem.Type);
                PrintTemplateItem item = new PrintTemplateItem();
                item.RunTimeTag = itemViewModel;
                item.Id         = Guid.NewGuid();
                item.Type       = vmItem.Type;
                item.X          = (int)this.imgDelivery.Width / 2;
                item.Y          = (int)this.imgDelivery.Height / 2;
                item.Width      = 100;
                item.Height     = 30;
                item.FontSize   = 12;
                item.FontName   = "黑体";
                item.Format     = itemViewModel.Format;
                item.Value      = itemViewModel.Value;
                item.Value1     = itemViewModel.Value1;
                itemViewModel.ApplayStyleAndData(this.FindResource("ThumbStyle") as Style, item);
                AttachThumbEvents(itemViewModel);
                //添加到界面
                this.cDeliveryHost.Children.Add(itemViewModel.UI);
                var layer = AdornerLayer.GetAdornerLayer(this.cDeliveryHost);
                layer.Add(new PrintTemplateItemAdorner(itemViewModel.UI));

                deliveryTemplate.Items.Add(item);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 10
0
        public object Format(PrintTemplate template, PrintTemplateItem item, OrderReturn or)
        {
            string vendorName = "";
            var    ss         = or.GoodsInfo.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (ss.Length > 0)
            {
                vendorName = ss[0];
            }
            if (string.IsNullOrWhiteSpace(vendorName))
            {
                return("");
            }
            var vens = ServiceContainer.GetService <VendorService>().GetVendorAddress_InCach(vendorName);

            if (string.IsNullOrWhiteSpace(vens))
            {
                return("");
            }
            var door = VendorService.FormatVendorDoor(vens);

            return(door);
        }
Ejemplo n.º 11
0
        protected override object FormatData(PrintTemplateItem printTemplateItem, PrintInfo pi)
        {
            //该用那个格式货程序
            var    group = PrintTemplateItemType.GetGroup(printTemplateItem.Type);
            object data  = null;

            if (group == PrintTemplateItemTypeGroup.PRINT)
            {
                data = PrintFormatterManager.Format(this.Template, printTemplateItem, pi);
            }
            else if (group == PrintTemplateItemTypeGroup.OTHER)
            {
                data = OtherFormatterManager.Format(this.Template, printTemplateItem);
            }
            else if (group == PrintTemplateItemTypeGroup.RETURN)
            {
                data = ReturnFormatterManager.Format(this.Template, printTemplateItem, this.Values[index]);
            }
            else
            {
                throw new Exception("商品模板不支类型:" + printTemplateItem.Type);
            }
            return(data);
        }
Ejemplo n.º 12
0
 protected abstract object FormatData(PrintTemplateItem printTemplateItem, PrintInfo pi);
Ejemplo n.º 13
0
        public static object Format(PrintTemplate template, PrintTemplateItem item, OrderGoods orderGoods)
        {
            var formtter = GetPrintDataFormatter(item.Type);

            return(formtter.Format(template, item, orderGoods));
        }
Ejemplo n.º 14
0
        public static object Format(PrintTemplate template, PrintTemplateItem item, long shopId)
        {
            var formatter = GetPrintDataFormatter(item.Type);

            return(formatter.Format(template, item, shopId));
        }
Ejemplo n.º 15
0
 public object Format(PrintTemplate template, PrintTemplateItem item, OrderReturn or)
 {
     return(ZXingUtil.CreateImage(or.Id.ToString(), item.Format, (int)item.Width, (int)item.Height, item.Value1 == "是" ? false : true, item.FontName, (float)item.FontSize));
 }
Ejemplo n.º 16
0
 public static object Format(PrintTemplate template, PrintTemplateItem item, OrderReturn or)
 {
     return(GetPrintDataFormatter(item.Type).Format(template, item, or));
 }
Ejemplo n.º 17
0
        public static object Format(PrintTemplate template, PrintTemplateItem item, PrintInfo printInfo)
        {
            var formtter = GetPrintDataFormatter(item.Type);

            return(formtter.Format(template, item, printInfo));
        }
Ejemplo n.º 18
0
 public object Format(PrintTemplate template, PrintTemplateItem item)
 {
     return(item.Format);
 }
Ejemplo n.º 19
0
 public object Format(PrintTemplate template, PrintTemplateItem item, PrintInfo printInfo)
 {
     return(printInfo.PrintTime.ToString(item.Format));
 }
Ejemplo n.º 20
0
 public object Format(PrintTemplate template, PrintTemplateItem item, OrderGoods orderGoods)
 {
     return("尺码:" + (220 + (int.Parse(orderGoods.Size) - 34) * 5).ToString() + "/1.5");
 }
Ejemplo n.º 21
0
 public object Format(PrintTemplate template, PrintTemplateItem item, OrderGoods orderGoods)
 {
     return("颜色:" + orderGoods.Color);
 }
Ejemplo n.º 22
0
 public object Format(PrintTemplate template, PrintTemplateItem item, OrderGoods orderGoods)
 {
     return("货号:" + (orderGoods.GoodsId > 0 ? orderGoods.Number : ""));
 }
Ejemplo n.º 23
0
 public object Format(PrintTemplate template, PrintTemplateItem item, OrderReturn or)
 {
     return(or.Id.ToString());
 }
Ejemplo n.º 24
0
 public object Format(PrintTemplate template, PrintTemplateItem item, PrintInfo printInfo)
 {
     return(printInfo.PageInfo);
 }