コード例 #1
0
        /// <summary>
        /// 生成显示图片的PictureBox
        /// </summary>
        /// <param name="type"></param>
        /// <param name="exinfo"></param>
        private void GenerateImagePictureBox(string type, ExportInfo exinfo = null)
        {
            GetExportInfoValue(exinfo);
            PrintPreviewPictureBox PicBox = null;

            try
            {
                switch (type)
                {
                case "image":
                    PicBox = new PrintPreviewImagePictureBox(PreviewControlPanel, exinfo);
                    break;

                case "qrcode":
                    PicBox = new PrintPreviewQRCodePictureBox(PreviewControlPanel, exinfo);
                    break;

                case "barcode":
                    PicBox = new PrintPreviewBarCodePictureBox(PreviewControlPanel, exinfo);
                    break;

                case "background":
                    PicBox = new PrintPreviewBackgroundPictureBox(PreviewControlPanel, exinfo);
                    break;
                }
                PicBox.GeneratePictureBoxFillImage(exinfo);
            }
            finally
            {
                if (PicBox != null)
                {
                    PicBox.Dispose();
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// 从ExportInfo中获取控件信息内容
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="control"></param>
 /// <param name="exinfo"></param>
 public static void GetInfoFromExportInfo <T>(this T control, ExportInfo exinfo) where T : Control, IPrintPreviewControl
 {
     control.Font      = exinfo.ForeFont;
     control.ForeColor = exinfo.ForeColor;
     control.BackColor = exinfo.BackColor;
     control.Location  = exinfo.Location;
 }
コード例 #3
0
 /// <summary>
 /// 增加打印纸张信息到XML文件
 /// </summary>
 /// <param name="xmldoc"></param>
 /// <param name="root"></param>
 private void AddPrintPaperInfoToXmlDocument(XmlDocument xmldoc, XmlElement root)
 {
     using (ExportInfo ei = new ExportInfo())
     {
         ei.AddNodeToXMLNode(xmldoc, root, "PrintPaper", new string[] { "PaperSizeName," + (cmb_PrintPaperSize.SelectedItem as PaperSize).PaperName, "Width," + PreviewControlPanel.Width, "Height," + PreviewControlPanel.Height });
     }
 }
コード例 #4
0
ファイル: ExportInfo.cs プロジェクト: lypvc/AnyTablePrint
        /// <summary>
        /// 从XML获取信息
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public ExportInfo GetInfoFromXML(XmlElement parent)
        {
            ExportInfo retinfo = new ExportInfo();

            try
            {
                retinfo.taginfo.Type = GetNodeValue(parent, "Taginfo", "Type");
                retinfo.taginfo.Info = GetNodeValue(parent, "Taginfo", "Info");
                retinfo.location.X   = Convert.ToInt32(GetNodeValue(parent, "Location", "X"));
                retinfo.location.Y   = Convert.ToInt32(GetNodeValue(parent, "Location", "Y"));
                retinfo.size.Width   = Convert.ToInt32(GetNodeValue(parent, "Size", "Width"));
                retinfo.size.Height  = Convert.ToInt32(GetNodeValue(parent, "Size", "Height"));
                string    FontName  = GetNodeValue(parent, "ForeFont", "Name");
                FontStyle FontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), GetNodeValue(parent, "ForeFont", "Style"));
                float     FontSize  = (float)Convert.ToDouble(GetNodeValue(parent, "ForeFont", "Size"));
                retinfo.foreFont  = new Font(FontName, FontSize, FontStyle);
                retinfo.foreColor = Color.FromName(GetNodeValue(parent, "ForeColor", "Name"));
                retinfo.backColor = Color.FromName(GetNodeValue(parent, "BackColor", "Name"));
                return(retinfo);
            }
            catch (Exception)
            {
                retinfo.Dispose();
                return(null);
            }
        }
コード例 #5
0
 /// <summary>
 /// 从ExportInfo中获取控件信息内容
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="control"></param>
 /// <param name="exinfo"></param>
 public static void GetInfoFromExportInfo <T>(this T control, ExportInfo exinfo) where T : Control, IPrintPreviewControl
 {
     control.ForeColor = exinfo.foreColor;
     control.Font      = exinfo.foreFont;
     control.BackColor = exinfo.backColor;
     control.PanelForm.SetShowStringText(exinfo.taginfo.Info);
     control.PanelForm.SetWidthText(exinfo.size.Width.ToString());
     control.PanelForm.SetHeightText(exinfo.size.Height.ToString());
     control.Location = exinfo.location;
 }
コード例 #6
0
 /// <summary>
 /// 图片填充PictureBox
 /// </summary>
 /// <param name="exinfo"></param>
 public override void GeneratePictureBoxFillImage(ExportInfo exinfo)
 {
     if (string.IsNullOrEmpty(exinfo.TagInfo.Info))
     {
         MessageBox.Show(this, "二维码内容不能为空");
         return;
     }
     PicImage = GetQRCodeByZXingNet(exinfo.TagInfo.Info, BelongPanel.Width, BelongPanel.Height);
     AddPictureBox(PicImage, exinfo);
 }
コード例 #7
0
 /// <summary>
 /// 图片填充PictureBox
 /// </summary>
 /// <param name="exinfo"></param>
 public override void GeneratePictureBoxFillImage(ExportInfo exinfo = null)
 {
     if (String.IsNullOrEmpty(PanelForm.GetShowStringValue()))
     {
         MessageBox.Show(this, "条码内容不能为空!");
         return;
     }
     PicImage = GetBarCodeByZXingNet(PanelForm.GetShowStringValue(), PanelForm.GetWidthValue(), PanelForm.GetHeightValue());
     AddPictureBox(PicImage, new TagInfo("barcode", PanelForm.GetShowStringValue()));
 }
コード例 #8
0
 /// <summary>
 /// 添加PictureBox到Panel
 /// </summary>
 protected void AddPictureBox(Image img, ExportInfo exinfo)
 {
     PicBoxFillImage(img, exinfo);
     if (ResetMode)
     {
         ResetMode = false;
     }
     else
     {
         AddControlEvent();
     }
 }
コード例 #9
0
 /// <summary>
 /// 增加控件信息到XML文件
 /// </summary>
 /// <param name="xmldoc"></param>
 /// <param name="c"></param>
 private void AddControlInfoToXmlDocument(XmlDocument xmldoc, Control c)
 {
     using (ExportInfo exportinfo = new ExportInfo())
     {
         exportinfo.backColor = c.BackColor;
         exportinfo.foreColor = c.ForeColor;
         exportinfo.foreFont  = c.Font;
         exportinfo.location  = c.Location;
         exportinfo.size      = c.Size;
         exportinfo.taginfo   = c.Tag as TagInfo;
         exportinfo.AddIntoXMLDocument(ref xmldoc);
     }
 }
コード例 #10
0
        /// <summary>
        /// 图片填充PictureBox
        /// </summary>
        /// <param name="exinfo"></param>
        public override void GeneratePictureBoxFillImage(ExportInfo exinfo = null)
        {
            OpenFileDialog openFileDialog = null;

            if (exinfo != null)
            {
                PicImage = Image.FromFile(exinfo.taginfo.Info);
                PicImage = ZoomPicture(PicImage, PanelForm.GetWidthValue(), PanelForm.GetHeightValue());
            }
            else
            {
                openFileDialog = OpenFileDialogSelectImage();
            }
            AddPictureBox(PicImage, new TagInfo("image", openFileDialog.FileName));
        }
コード例 #11
0
 /// <summary>
 /// 填充控件信息
 /// </summary>
 private void PicBoxFillImage(Image img, ExportInfo exinfo)
 {
     if (exinfo.TagInfo.Type == "background")
     {
         SendToBack();
     }
     else
     {
         SizeMode = PictureBoxSizeMode.StretchImage;
         Image    = img;
         BringToFront();
     }
     Size = Exinfo.Size;
     Tag  = exinfo.TagInfo.Info;
 }
コード例 #12
0
        /// <summary>
        /// 生成显示文本的Label控件
        /// </summary>
        /// <param name="exinfo"></param>
        private void GeneratePrintPreviewLabel(ExportInfo exinfo = null)
        {
            GetExportInfoValue(exinfo);
            PrintPreviewLabel previewLabel = null;

            try
            {
                previewLabel = new PrintPreviewLabel(PreviewControlPanel, exinfo);
                previewLabel.AddLabel();
            }
            finally
            {
                if (previewLabel != null)
                {
                    previewLabel.Dispose();
                }
            }
        }
コード例 #13
0
ファイル: PrintForm.cs プロジェクト: Peashoot/AnyTablePrint
        /// <summary>
        /// 生成显示图片的PictureBox
        /// </summary>
        private PrintPreviewPictureBox GenerateImagePictureBox(ExportInfo exinfo = null)
        {
            GetExportInfoValue(exinfo);
            PrintPreviewPictureBox tempPicBox = null;
            PrintPreviewPictureBox PicBox     = null;

            try
            {
                switch (exinfo.TagInfo.Type)
                {
                case "image":
                    tempPicBox = new PrintPreviewImagePictureBox(PreviewControlPanel, exinfo);
                    break;

                case "qrcode":
                    tempPicBox = new PrintPreviewQRCodePictureBox(PreviewControlPanel, exinfo);
                    break;

                case "barcode":
                    tempPicBox = new PrintPreviewBarCodePictureBox(PreviewControlPanel, exinfo);
                    break;

                case "background":
                    tempPicBox = new PrintPreviewBackgroundPictureBox(PreviewControlPanel, exinfo);
                    break;
                }
                tempPicBox.Resize += new EventHandler(tempPreviewPicBox_Resize);
                ShowExinfo(exinfo);
                tempPicBox.GeneratePictureBoxFillImage(exinfo);
                ControlDetail = string.Empty;
                PicBox        = tempPicBox;
                tempPicBox    = null;
            }
            finally
            {
                if (tempPicBox != null)
                {
                    tempPicBox.Dispose();
                }
            }
            return(PicBox);
        }
コード例 #14
0
 public PrintPreviewLabel(Panel panel, ExportInfo exinfo = null)
     : base()
 {
     try
     {
         BelongPanel = panel;
         ExpandArray = new int[4];
         MenuStrip   = new ControlContextMenuStrip();
         panel.Controls.Add(this);
         Exinfo = exinfo;
         if (Exinfo != null)
         {
             this.GetInfoFromExportInfo(Exinfo);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message);
     }
 }
コード例 #15
0
        /// <summary>
        /// 从XML文件中获取控件信息和打印信息
        /// </summary>
        /// <param name="xmldoc"></param>
        /// <returns></returns>
        private List <ExportInfo> GetXmlDocumentInfo(XmlDocument xmldoc)
        {
            XmlElement        root       = xmldoc.DocumentElement;
            List <ExportInfo> exportlist = new List <ExportInfo>();

            using (ExportInfo ei = new ExportInfo())
            {
                foreach (XmlNode node in root.ChildNodes)
                {
                    if (node.Name != "PrintPaper")
                    {
                        exportlist.Add(ei.GetInfoFromXML(((XmlElement)node)));
                    }
                }
                cmb_PrintPaperSize.Text = ei.GetNodeValue(root, "PrintPaper", "PaperSizeName");
                SetWidthText(ei.GetNodeValue(root, "PrintPaper", "Width"));
                SetHeightText(ei.GetNodeValue(root, "PrintPaper", "Height"));
            }
            PreviewControlPanel.Size = new Size(GetWidthValue(), GetHeightValue());
            return(exportlist);
        }
コード例 #16
0
 public PrintPreviewPictureBox(Panel panel, ExportInfo exinfo = null)
     : base()
 {
     try
     {
         BelongPanel = panel;
         PanelForm   = panel.Parent as PrintForm;
         if (PanelForm == null)
         {
             throw new Exception("Can't get PanelForm.");
         }
         ExpandArray = new int[4];
         MenuStrip   = new ControlContextMenuStrip();
         panel.Controls.Add(this);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message);
     }
     if (exinfo != null)
     {
         this.GetInfoFromExportInfo(exinfo);
     }
 }
コード例 #17
0
ファイル: PrintForm.cs プロジェクト: Peashoot/AnyTablePrint
        /// <summary>
        /// 生成显示文本的Label控件
        /// </summary>
        private PrintPreviewLabel GeneratePrintPreviewLabel(ExportInfo exinfo = null)
        {
            GetExportInfoValue(exinfo);
            PrintPreviewLabel tempPreviewLabel = null;
            PrintPreviewLabel previewLabel     = null;

            try
            {
                tempPreviewLabel = new PrintPreviewLabel(PreviewControlPanel, exinfo);
                ShowExinfo(exinfo);
                tempPreviewLabel.AddLabel();
                ControlDetail    = string.Empty;
                previewLabel     = tempPreviewLabel;
                tempPreviewLabel = null;
            }
            finally
            {
                if (tempPreviewLabel != null)
                {
                    tempPreviewLabel.Dispose();
                }
            }
            return(previewLabel);
        }
コード例 #18
0
 public PrintPreviewQRCodePictureBox(Panel panel, ExportInfo exinfo)
     : base(panel, exinfo)
 {
 }
コード例 #19
0
 public PrintPreviewBarCodePictureBox(Panel panel, ExportInfo exinfo = null) : base(panel, exinfo)
 {
 }
コード例 #20
0
ファイル: PrintForm.cs プロジェクト: Peashoot/AnyTablePrint
 /// <summary>
 /// 显示控件信息
 /// </summary>
 private void ShowExinfo(ExportInfo exinfo)
 {
     ControlDetail = exinfo.TagInfo.Info;
     ControlWidth  = exinfo.Size.Width;
     ControlHeight = exinfo.Size.Height;
 }
コード例 #21
0
 /// <summary>
 /// 获取图片填充PictureBox
 /// </summary>
 /// <param name="exinfo"></param>
 public abstract void GeneratePictureBoxFillImage(ExportInfo exinfo = null);
コード例 #22
0
 /// <summary>
 /// 设置宽高和文本信息
 /// </summary>
 /// <param name="exinfo"></param>
 private void GetExportInfoValue(ExportInfo exinfo)
 {
     exinfo.size.Width   = GetWidthValue();
     exinfo.size.Height  = GetHeightValue();
     exinfo.taginfo.Info = GetShowStringValue();
 }
コード例 #23
0
 /// <summary>
 /// 初始化成员对象
 /// </summary>
 private void InitMember()
 {
     _exinfo      = new ExportInfo();
     _printHelper = new PrintPreviewHelper(PreviewControlPanel);
 }
コード例 #24
0
ファイル: PrintForm.cs プロジェクト: Peashoot/AnyTablePrint
 /// <summary>
 /// 设置宽高和文本信息
 /// </summary>
 private void GetExportInfoValue(ExportInfo exinfo)
 {
     exinfo.Size.Width   = ControlWidth;
     exinfo.Size.Height  = ControlHeight;
     exinfo.TagInfo.Info = ControlDetail;
 }
コード例 #25
0
 /// <summary>
 /// 设置PictureBox背景
 /// </summary>
 /// <param name="exinfo"></param>
 public override void GeneratePictureBoxFillImage(ExportInfo exinfo)
 {
     AddPictureBox(null, exinfo);
 }
コード例 #26
0
 public PrintPreviewBackgroundPictureBox(Panel panel, ExportInfo exinfo)
     : base(panel, exinfo)
 {
 }
コード例 #27
0
 /// <summary>
 /// 设置PictureBox背景
 /// </summary>
 /// <param name="exinfo"></param>
 public override void GeneratePictureBoxFillImage(ExportInfo exinfo = null)
 {
     AddPictureBox(null, new TagInfo("background", BackColor.Name));
 }
コード例 #28
0
        /// <summary>
        /// 图片填充PictureBox
        /// </summary>
        /// <param name="exinfo"></param>
        public override void GeneratePictureBoxFillImage(ExportInfo exinfo)
        {
            OpenFileDialog openFileDialog = OpenFileDialogSelectImage();

            AddPictureBox(PicImage, exinfo);
        }