Exemplo n.º 1
0
 /// <summary>
 /// 初始化页面
 /// </summary>
 private void InitPage()
 {
     _licenseTempleteInfo = GetLicenseTempleteInfo();
     if (_licenseTempleteInfo == null)
     {
         _licenseTempleteInfo              = new LicenseTempleteInfo();
         _licenseTempleteInfo.Guid         = Utility.NewGuid();
         _licenseTempleteInfo.ActivityGuid = CO_IA.Client.RiasPortal.ModuleContainer.Activity.Guid;
         LoadBarCodeFrom(CreateEmptyTemplateXml());
         SetAllBtnUnEnable();
     }
     else
     {
         LoadBarCodeFrom(_licenseTempleteInfo.TempXML);
         if (_licenseTempleteInfo.BGImage != null)
         {
             MemoryStream stream = new MemoryStream(_licenseTempleteInfo.BGImage);
             BitmapImage  bmp    = new BitmapImage();
             bmp.BeginInit();           //初始化
             bmp.StreamSource = stream; //设置源
             bmp.EndInit();             //初始化结束
             gbImg.ImageSource = bmp;   //设置图像Source
         }
         viewLicense();
     }
     InitUIFromBarCode(_licenseTemplete);
 }
Exemplo n.º 2
0
 public PrintPreviewLicense(List <ActivityEquipmentInfo> equList)
 {
     InitializeComponent();
     this._equList        = equList;
     _licenseTempleteInfo = GetLicenseTempleteInfo();
     if (_licenseTempleteInfo == null)
     {
         MessageBox.Show("本活动还未设置许可证模板,请先设置模板", "提示", MessageBoxButton.OK);
         return;
     }
     else
     {
         InitPage();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 创建许可证预览的Canvas
        /// </summary>
        /// <param name="equInfo">设备信息</param>
        /// <param name="tempInfo">许可证模板信息</param>
        /// <param name="isPrintBgImg">是否打印背景图片</param>
        /// <returns></returns>
        public static Canvas CreateLicenseViewCanvas(ActivityEquipmentInfo equInfo, LicenseTempleteInfo tempInfo, bool isPrintBgImg)
        {
            LicenseTemplete temp        = BarCodeFactory.CreateBarCodesFromXml(tempInfo.TempXML);
            LicenseViewInfo license     = new LicenseViewInfo(equInfo);
            Canvas          _viewCanvas = new Canvas();

            _viewCanvas.Height = temp.Height;
            _viewCanvas.Width  = temp.Width;
            if (isPrintBgImg)
            {
                ImageBrush image = new ImageBrush();
                if (tempInfo.BGImage != null)
                {
                    MemoryStream stream = new MemoryStream(tempInfo.BGImage);
                    BitmapImage  bmp    = new BitmapImage();
                    bmp.BeginInit();           //初始化
                    bmp.StreamSource = stream; //设置源
                    bmp.EndInit();             //初始化结束
                    image.ImageSource = bmp;   //设置图像Source
                }
                _viewCanvas.Background = image;
            }
            LicenseViewInfo viewInfo = new LicenseViewInfo(equInfo);

            _viewCanvas.DataContext = viewInfo;
            foreach (var item in temp.Items)
            {
                switch (item.Type)
                {
                case "Title":
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text     = item.Content + ":";
                    textBlock.FontSize = item.FontSize;
                    _viewCanvas.Children.Add(textBlock);
                    Canvas.SetTop(textBlock, item.Left);
                    Canvas.SetLeft(textBlock, item.Top);
                    break;

                case "Value":
                    TextBlock textBlockValue = new TextBlock();
                    textBlockValue.FontSize     = item.FontSize;
                    textBlockValue.Width        = temp.Width - item.Top - 10;
                    textBlockValue.TextWrapping = TextWrapping.Wrap;
                    _viewCanvas.Children.Add(textBlockValue);
                    Canvas.SetTop(textBlockValue, item.Left);
                    Canvas.SetLeft(textBlockValue, item.Top);
                    textBlockValue.SetBinding(TextBlock.TextProperty, new Binding(item.Column));
                    break;

                case "BarCode":
                    //初始化条码图片
                    //private Image _barCodeImage = CreateImage();
                    //_viewCanvas.Children.Add(_barCodeImage);
                    //Canvas.SetTop(_barCodeImage, item.Left);
                    //Canvas.SetLeft(_barCodeImage, item.Top);
                    break;
                }
            }

            return(_viewCanvas);
        }