コード例 #1
0
ファイル: ReportDataIO.cs プロジェクト: ewin66/CsharpProjects
        //把报表中的图片信息存储到报表所在的下一级目录(以报表名为名称)下。
        public virtual void SaveRptImage(DIYReport.ReportModel.RptObj.RptPictureBox pImage)
        {
            //pImage.Section.Report.Name
            string imagePath = System.IO.Path.GetFileNameWithoutExtension(pImage.Section.Report.ID.ToString());
            string filePath  = _CurrentProcessFilePath + @"\" + imagePath + @"\";
            bool   b         = System.IO.Directory.Exists(filePath);

            if (!b)
            {
                System.IO.Directory.CreateDirectory(filePath);
            }
            //string tt =pImage.Image..Name ;
            string fileName = filePath + pImage.Name + ".jpg";

            bool fb = System.IO.File.Exists(fileName);

            if (fb)
            {
            }
            try{
                if (pImage.Image != null)
                {
                    pImage.Image.Save(fileName);
                }
            }
            catch {
                //throw e;
            }
        }
コード例 #2
0
        /// <summary>
        /// 根据类型创建报表对象。
        /// </summary>
        /// <param name="name"></param>
        /// <param name="dispText"></param>
        /// <returns></returns>
        public static DIYReport.Interface.IRptSingleObj CreateObj(DIYReport.ReportModel.RptObjType pType, string dispText)
        {
            DIYReport.Interface.IRptSingleObj obj = null;
            switch (pType)
            {
            case DIYReport.ReportModel.RptObjType.Line:
                obj = new DIYReport.ReportModel.RptObj.RptLine(null);
                break;

            case DIYReport.ReportModel.RptObjType.Rect:
                obj = new DIYReport.ReportModel.RptObj.RptRect(null);
                break;

            case DIYReport.ReportModel.RptObjType.Text:
                obj = new DIYReport.ReportModel.RptObj.RptLable(null, dispText);
                break;

            case DIYReport.ReportModel.RptObjType.Express:
                obj = new DIYReport.ReportModel.RptObj.RptExpressBox(null, dispText);
                break;

            case DIYReport.ReportModel.RptObjType.Image:
                obj = new DIYReport.ReportModel.RptObj.RptPictureBox(null);
                break;

            case DIYReport.ReportModel.RptObjType.FieldImage:
                obj = new DIYReport.ReportModel.RptObj.RptDBPictureBox(null);
                break;

            case DIYReport.ReportModel.RptObjType.CheckBox:
                obj = new DIYReport.ReportModel.RptObj.RptCheckBox(null);
                break;

            case DIYReport.ReportModel.RptObjType.BarCode:
                obj = new DIYReport.ReportModel.RptObj.RptBarCode(null);
                break;

            case DIYReport.ReportModel.RptObjType.SubReport:
                obj = new DIYReport.ReportModel.RptObj.RptSubReport(null);
                break;

            case DIYReport.ReportModel.RptObjType.FieldTextBox:
                obj = new DIYReport.ReportModel.RptObj.RptFieldTextBox(null);
                break;

            case DIYReport.ReportModel.RptObjType.HViewSpecField:
                obj = new DIYReport.ReportModel.RptObj.RptHViewSpecFieldBox(null);
                break;

            case DIYReport.ReportModel.RptObjType.RichTextBox:
                obj = new DIYReport.ReportModel.RptObj.RptRichTextBox(null);
                break;

            default:
                Debug.Assert(false, "该控件类型目前还没有处理!", "");
                return(null);
            }
            return(obj);
        }
コード例 #3
0
        //画Image 图像
        private void drawImage(Graphics g, DIYReport.Interface.IRptSingleObj pObj)
        {
            DIYReport.ReportModel.RptObj.RptPictureBox pic = pObj as DIYReport.ReportModel.RptObj.RptPictureBox;
            RectangleF rct = RealRectangle(pObj);

            if (pic.Image != null)
            {
                g.DrawImage(pic.Image, rct.Left, rct.Top, rct.Width, rct.Height);
            }
        }
コード例 #4
0
ファイル: ReportDataIO.cs プロジェクト: ewin66/CsharpProjects
        //读报表中的图片信息
        public virtual void ReadRptImage(DIYReport.ReportModel.RptObj.RptPictureBox pImage)
        {
            string imagePath = System.IO.Path.GetFileNameWithoutExtension(_RptID.ToString());
            string filePath  = _CurrentProcessFilePath + @"\" + imagePath + @"\" + pImage.Name + ".jpg";
            bool   b         = System.IO.File.Exists(filePath);

            if (b)
            {
                Image im = System.Drawing.Image.FromFile(filePath);
                pImage.Image = im;
            }
        }
コード例 #5
0
 private void removeCtl(DesignControl pCtl)
 {
     //判断是否为图片文件并销毁图片
     if (pCtl.DataObj.Type == DIYReport.ReportModel.RptObjType.Image)
     {
         DIYReport.ReportModel.RptObj.RptPictureBox pic = pCtl.DataObj  as DIYReport.ReportModel.RptObj.RptPictureBox;
         if (pic.Image != null)
         {
             pic.Image.Dispose();
         }
     }
     //删除控件数据集合中的
     _DataObj.Remove(pCtl.DataObj);
     //从Section界面中删除8个热点
     foreach (FocusHandleCTL focus in pCtl.FocusList)
     {
         _Section.DeControls.Remove(focus);
     }
     pCtl.FocusList.Clear();
     //删除Section 上的控件集合(界面上的控件)
     _Section.DeControls.Remove(pCtl);
     //删除当前集合中的对该对象的引用
     base.Remove(pCtl);
 }
コード例 #6
0
ファイル: ReportDataIO.cs プロジェクト: ewin66/CsharpProjects
        private void fillInfoToRptObj(DIYReport.Interface.IRptSingleObj pRptObj, XmlNode pNode)
        {
            int x = PublicFun.ToInt(pNode.Attributes["Location-X"].Value);
            int y = PublicFun.ToInt(pNode.Attributes["Location-Y"].Value);

            pRptObj.Location = new Point(x, y);
            int width  = PublicFun.ToInt(pNode.Attributes["Size-Width"].Value);
            int height = PublicFun.ToInt(pNode.Attributes["Size-Height"].Value);

            pRptObj.Size      = new Size(width, height);
            pRptObj.LinePound = PublicFun.ToInt(pNode.Attributes["LinePound"].Value);
            if (pNode.Attributes["LineStyle"] != null)
            {
                int lineStyle = PublicFun.ToInt(pNode.Attributes["LineStyle"].Value);
                pRptObj.LineStyle = (System.Drawing.Drawing2D.DashStyle)lineStyle;
            }
            else
            {
                pRptObj.LineStyle = System.Drawing.Drawing2D.DashStyle.Solid;
            }
            pRptObj.BackgroundColor = Color.FromArgb(PublicFun.ToInt(pNode.Attributes["BackgroundColor"].Value));
            pRptObj.ForeColor       = Color.FromArgb(PublicFun.ToInt(pNode.Attributes["ForeColor"].Value));
            switch (pRptObj.Type)
            {
            case DIYReport.ReportModel.RptObjType.Line:
                DIYReport.ReportModel.RptObj.RptLine line = pRptObj as  DIYReport.ReportModel.RptObj.RptLine;
                if (pNode.Attributes["LineType"] != null)
                {
                    line.LineType = (DIYReport.ReportModel.LineType) int.Parse(pNode.Attributes["LineType"].Value);
                }
                break;

            case DIYReport.ReportModel.RptObjType.Text:
            case DIYReport.ReportModel.RptObjType.Express:
                //如果是文本对象,需要加载字体的颜色、形状
                DIYReport.Interface.IRptTextObj txt = pRptObj as DIYReport.Interface.IRptTextObj;
                txt.WordWrap = bool.Parse(pNode.Attributes["WordWrap"].Value);
                string sLimg = pNode.Attributes["Alignment"].Value;
                //得到字符对齐方式  //由于早期的报表是存储字符的,为了保持兼容性,也采取这种存储方式
                if (sLimg == "Near")
                {
                    txt.Alignment = StringAlignment.Near;
                }
                else if (sLimg == "Center")
                {
                    txt.Alignment = StringAlignment.Center;
                }
                else
                {
                    txt.Alignment = StringAlignment.Far;
                }

                txt.ShowFrame = bool.Parse(pNode.Attributes["ShowFrame"].Value);
                if (pNode.Attributes["FormatStyle"] != null)
                {
                    txt.FormatStyle = pNode.Attributes["FormatStyle"].Value;
                }
                string    fontName  = pNode.Attributes["Font-FamilyName"].Value;
                float     fontSize  = PublicFun.ToFloat(pNode.Attributes["Font-Size"].Value);
                bool      bold      = bool.Parse(pNode.Attributes["Font-Bold"].Value);
                bool      underline = bool.Parse(pNode.Attributes["Font-Underline"].Value);
                bool      italic    = bool.Parse(pNode.Attributes["Font-Italic"].Value);
                bool      strikeout = bool.Parse(pNode.Attributes["Font-Strikeout"].Value);
                FontStyle fontType  = FontStyle.Regular;
                //通过位运算得到字符stype 靠!怎么会采取这种存储方式呢,看来晚上是不能写的太晚~~~~~~~~
                if (bold)
                {
                    fontType = fontType | FontStyle.Bold;
                }
                if (underline)
                {
                    fontType = fontType | FontStyle.Underline;
                }
                if (italic)
                {
                    fontType = fontType | FontStyle.Italic;
                }


                Font f    = new Font(fontName, fontSize);
                Font font = new Font(f, fontType);
                txt.Font = font;
                if (txt.Type == DIYReport.ReportModel.RptObjType.Text)
                {
                    if (pNode.Attributes["Text"] != null)
                    {
                        DIYReport.ReportModel.RptObj.RptLable lab = txt as DIYReport.ReportModel.RptObj.RptLable;
                        lab.Text = pNode.Attributes["Text"].Value;
                    }
                }
                else
                {
                    DIYReport.ReportModel.RptObj.RptExpressBox box = txt as DIYReport.ReportModel.RptObj.RptExpressBox;
                    if (pNode.Attributes["ExpressType"] != null)
                    {
                        int exType = int.Parse(pNode.Attributes["ExpressType"].Value);
                        box.ExpressType = (DIYReport.ReportModel.ExpressType)exType;
                    }
                    if (pNode.Attributes["DataSource"] != null)
                    {
                        box.DataSource = pNode.Attributes["DataSource"].Value;
                    }
                    if (pNode.Attributes["FieldName"] != null)
                    {
                        box.FieldName = pNode.Attributes["FieldName"].Value;
                    }
                }
                break;

            case DIYReport.ReportModel.RptObjType.Image:
                DIYReport.ReportModel.RptObj.RptPictureBox pic = pRptObj as DIYReport.ReportModel.RptObj.RptPictureBox;
                //处理图片
                ReadRptImage(pic);
                break;

            default:
                break;
            }
        }
コード例 #7
0
ファイル: ReportDataIO.cs プロジェクト: ewin66/CsharpProjects
        private string rptObjString(DIYReport.Interface.IRptSingleObj pRptObj)
        {
            StringBuilder xmlSB = new StringBuilder();

            xmlSB.Append("<RptObj Name = '" + pRptObj.Name + "'");
            xmlSB.Append(" Type = '" + ((int)pRptObj.Type).ToString() + "'");
            xmlSB.Append(" Location-X='" + pRptObj.Location.X.ToString() + "'");
            xmlSB.Append(" Location-Y='" + pRptObj.Location.Y.ToString() + "'");
            xmlSB.Append(" Size-Width='" + pRptObj.Size.Width.ToString() + "'");
            xmlSB.Append(" Size-Height='" + pRptObj.Size.Height.ToString() + "'");
            xmlSB.Append(" LinePound ='" + pRptObj.LinePound.ToString() + "'");
            xmlSB.Append(" LineStyle ='" + ((int)pRptObj.LineStyle).ToString() + "'");
            xmlSB.Append(" BackgroundColor ='" + pRptObj.BackgroundColor.ToArgb().ToString() + "'");
            xmlSB.Append(" ForeColor ='" + pRptObj.ForeColor.ToArgb().ToString() + "'");
            switch (pRptObj.Type)
            {
            case DIYReport.ReportModel.RptObjType.Line:
                DIYReport.ReportModel.RptObj.RptLine obj = pRptObj as  DIYReport.ReportModel.RptObj.RptLine;
                xmlSB.Append(" LineType ='" + ((int)obj.LineType).ToString() + "'");
                break;

            case DIYReport.ReportModel.RptObjType.Rect:
                break;

            case DIYReport.ReportModel.RptObjType.Text:
            case DIYReport.ReportModel.RptObjType.Express:
                DIYReport.Interface.IRptTextObj txt = pRptObj as DIYReport.Interface.IRptTextObj;
                xmlSB.Append(" WordWrap ='" + txt.WordWrap.ToString() + "'");
                xmlSB.Append(" Alignment ='" + txt.Alignment.ToString() + "'");
                xmlSB.Append(" ShowFrame ='" + txt.ShowFrame.ToString() + "'");
                xmlSB.Append(" FormatStyle ='" + txt.FormatStyle + "'");

                xmlSB.Append(" Font-Bold='" + txt.Font.Bold.ToString() + "'");
                xmlSB.Append(" Font-FamilyName='" + txt.Font.FontFamily.Name + "'");
                xmlSB.Append(" Font-Underline='" + txt.Font.Underline.ToString() + "'");
                xmlSB.Append(" Font-Italic='" + txt.Font.Italic.ToString() + "'");
                xmlSB.Append(" Font-Strikeout='" + txt.Font.Strikeout.ToString() + "'");
                xmlSB.Append(" Font-Size='" + txt.Font.Size.ToString() + "'");

                if (txt.Type == DIYReport.ReportModel.RptObjType.Text)
                {
                    DIYReport.ReportModel.RptObj.RptLable lab = txt as DIYReport.ReportModel.RptObj.RptLable;
                    if (lab.Text != null && lab.Text.Trim() != "")
                    {
                        xmlSB.Append(" Text ='" + lab.Text + "'");
                    }
                }
                else
                {
                    DIYReport.ReportModel.RptObj.RptExpressBox box = txt as DIYReport.ReportModel.RptObj.RptExpressBox;
                    if (box.DataSource != null && box.DataSource.Trim() != "")
                    {
                        xmlSB.Append(" DataSource ='" + box.DataSource.Trim() + "'");
                    }
                    if (box.FieldName != null && box.FieldName.Trim() != "")
                    {
                        xmlSB.Append(" FieldName ='" + box.FieldName.Trim() + "'");
                    }
                    xmlSB.Append(" ExpressType ='" + ((int)box.ExpressType).ToString() + "'");
                }
                break;

            case DIYReport.ReportModel.RptObjType.Image:
                DIYReport.ReportModel.RptObj.RptPictureBox pic = pRptObj as DIYReport.ReportModel.RptObj.RptPictureBox;
                //等待处理图片
                SaveRptImage(pic);
                break;

            default:
                break;
            }
            xmlSB.Append(">");
            //write end rptObj
            xmlSB.Append("</RptObj>");
            return(xmlSB.ToString());
        }