示例#1
0
        /// <summary>
        /// 构造xml
        /// </summary>
        /// <param name="_licenseTemplete"></param>
        /// <returns></returns>
        private string GetXmlByLicenseTemplete(LicenseTemplete _licenseTemplete)
        {
            //创建xml对象
            XDocument doc = new XDocument();
            //创建根节点
            XElement root = new XElement("BarCodes");

            doc.Add(root);
            //创建BarCode
            XElement barCodeElement = new XElement("BarCode");

            barCodeElement.SetAttributeValue("Height", _licenseTemplete.Height);
            barCodeElement.SetAttributeValue("Width", _licenseTemplete.Width);
            barCodeElement.SetAttributeValue("Name", _licenseTemplete.Name);
            barCodeElement.SetAttributeValue("IsUsed", _licenseTemplete.IsUsed);
            root.Add(barCodeElement);

            foreach (LicenseTempleteItem item in _licenseTemplete.Items)
            {
                //创建Control
                XElement CcontrolElement = new XElement("Control");
                switch (item.Type)
                {
                case "Title":
                case "Value":
                    CcontrolElement.SetAttributeValue("Top", item.Top);
                    CcontrolElement.SetAttributeValue("Left", item.Left);
                    CcontrolElement.SetAttributeValue("FontSize", item.FontSize);
                    CcontrolElement.SetAttributeValue("Column", item.Column);
                    CcontrolElement.SetAttributeValue("Content", item.Content);
                    CcontrolElement.SetAttributeValue("Type", item.Type);
                    break;

                case "BarCode":
                    CcontrolElement.SetAttributeValue("Top", item.Top);
                    CcontrolElement.SetAttributeValue("Left", item.Left);
                    CcontrolElement.SetAttributeValue("FontSize", "0");
                    CcontrolElement.SetAttributeValue("Column", "");
                    CcontrolElement.SetAttributeValue("Content", "");
                    CcontrolElement.SetAttributeValue("Type", item.Type);
                    break;
                }
                barCodeElement.Add(CcontrolElement);
            }
            return(doc.ToString());
        }
示例#2
0
        private void _btnSave_Click(object sender, RoutedEventArgs e)
        {
            LicenseTemplete _editingBarCode = new LicenseTemplete();

            _editingBarCode.Name   = _txtTemplateName.Text;
            _editingBarCode.Height = double.Parse(_txtHeight.Text);
            _editingBarCode.Width  = double.Parse(_txtWidth.Text);
            if ((_isUsed.SelectedItem as ComboBoxItem).Content.ToString() == "在用")
            {
                _editingBarCode.IsUsed = true;
            }
            _editingBarCode.Items = new List <LicenseTempleteItem>();
            foreach (var item in _ctrlList)
            {
                LicenseTempleteItem barCodeItem = new LicenseTempleteItem();
                barCodeItem.Top  = Canvas.GetLeft(item);
                barCodeItem.Left = Canvas.GetTop(item);
                if (item is Image)
                {
                    barCodeItem.Type = "BarCode";
                }
                else
                {
                    TextBlock tb = item as TextBlock;
                    barCodeItem.Type     = (tb.Text.Substring(tb.Text.Length - 1) == "值" && tb.Text.Substring(tb.Text.Length - 2) != "价值") ? "Value" : "Title";
                    barCodeItem.FontSize = tb.FontSize;
                    barCodeItem.Column   = tb.Tag.ToString();
                    barCodeItem.Content  = tb.Text;
                }
                _editingBarCode.Items.Add(barCodeItem);
            }
            _licenseTempleteInfo.TempXML = GetXmlByLicenseTemplete(_editingBarCode);
            PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.StationPlan.I_CO_IA_StationPlan>(
                channel =>
            {
                channel.SaveLicenseTempleteInfo(_licenseTempleteInfo);
                MessageBox.Show("保存成功", "提示", MessageBoxButton.OK);
                viewLicense();
            });
            SetAllBtnEnable();
        }
示例#3
0
        /// <summary>
        /// 初始化面板
        /// </summary>
        private void InitPanel(LicenseTemplete pBarCode)
        {
            //清空显示字段列表
            foreach (var i in _lstCol.Items)
            {
                CheckBox checkBox = ((ContentControl)(i)).Content as CheckBox;
                checkBox.IsChecked = false;
            }

            //清空控件列表
            _ctrlList = new List <FrameworkElement>();

            //初始化面板
            _canvasPanel.Children.Clear();
            _canvasPanel.Height  = pBarCode.Height;
            _borderCanvas.Height = pBarCode.Height + 2;
            _canvasPanel.Width   = pBarCode.Width;
            _borderCanvas.Width  = pBarCode.Width + 2;
            //初始化边框
            CreateBorder();

            //初始化条码图片
            //_barCodeImage = CreateImage();
            _canvasPanel.Children.Add(_barCodeImage);
            _ctrlList.Add(_barCodeImage);

            //设置页面属性
            _txtHeight.Text       = _canvasPanel.Height.ToString(CultureInfo.InvariantCulture);
            _txtWidth.Text        = _canvasPanel.Width.ToString(CultureInfo.InvariantCulture);
            _txtTemplateName.Text = pBarCode.Name;
            if (pBarCode.IsUsed)
            {
                _isUsed.SelectedItem = _isUsedItem;
                // _isUsedItem.IsSelected = true;
            }
            else
            {
                _isUsed.SelectedItem = _notUsedItem;
                //_notUsedItem.IsSelected = true;
            }
        }
示例#4
0
        // <summary>
        /// 根据BarCode(条形码)初始化模板编辑页面
        /// </summary>
        /// <param name="pBarCode">条码模板</param>
        private void InitUIFromBarCode(LicenseTemplete pBarCode)
        {
            if (pBarCode == null)
            {
                return;
            }

            InitPanel(pBarCode);

            foreach (var item in pBarCode.Items)
            {
                switch (item.Type)
                {
                case "Title":
                case "Value":
                    TextBlock textBlock = new TextBlock();
                    textBlock.Text     = item.Content;
                    textBlock.Tag      = item.Column;
                    textBlock.FontSize = item.FontSize;
                    _canvasPanel.Children.Add(textBlock);
                    _ctrlList.Add(textBlock);
                    Canvas.SetTop(textBlock, item.Left);
                    Canvas.SetLeft(textBlock, item.Top);
                    foreach (var i in _lstCol.Items)
                    {
                        CheckBox checkBox = ((ContentControl)(i)).Content as CheckBox;
                        if (checkBox.Tag.ToString() == item.Column)
                        {
                            checkBox.IsChecked = true;
                        }
                    }
                    break;

                case "BarCode":
                    Canvas.SetTop(_barCodeImage, item.Left);
                    Canvas.SetLeft(_barCodeImage, item.Top);
                    break;
                }
            }
        }
示例#5
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);
        }
示例#6
0
 /// <summary>
 /// 从xml加载条码模板
 /// </summary>
 /// <param name="xml">条码模板XML</param>
 private void LoadBarCodeFrom(string xml)
 {
     _licenseTemplete = BarCodeFactory.CreateBarCodesFromXml(xml.ToString());
 }