public override void Draw(Graphics g, DIYReport.Interface.IRptSingleObj dataObj) { RptCheckBox checkBox = dataObj as RptCheckBox; if (checkBox == null) { return; } if (checkBox.BingField) { string fieleName = checkBox.Checked?RptDrawHelper.CHECK_BOX_FILE : RptDrawHelper.UN_CHECK_BOX_FILE; Image checkImage = RptDrawHelper.CreateBitmapFromResources(fieleName); base.DrawImageUnscaled(g, dataObj, checkImage); try{ checkImage.Dispose(); } catch {} } else { this.DrawBingFieldName(g, checkBox, checkBox.FieldName); } }
private void DrawRptSimpleObj(Graphics g, DIYReport.Interface.IRptSingleObj pObj, DataRow pDRow) { switch (pObj.Type) { case RptObjType.Text: case RptObjType.Express: drawTextObj(g, pObj, pDRow); break; case RptObjType.Line: drawLine(g, pObj); break; case RptObjType.Rect: drawRect(g, pObj); break; case RptObjType.Image: drawImage(g, pObj); break; default: Debug.Assert(false, "请确认报表的XML文件配制是否正确", "在标题这一项,对象" + pObj.Name + " 的类型不能设置成:" + pObj.Type.ToString() + "类型"); break; } }
// 在撤消操作中,如果碰到删除的操作,需要在撤消时重新增加回来 public void Add(IList pObjList) { DesignControl last = null; int selectHeight = this.Section.DataObj.Height; for (int i = 0; i < pObjList.Count; i++) { DIYReport.Interface.IRptSingleObj data = pObjList[i] as DIYReport.Interface.IRptSingleObj; data = data.Clone() as DIYReport.Interface.IRptSingleObj; if (data.Location.Y + data.Size.Height > selectHeight) { selectHeight = data.Location.Y + data.Size.Height; } DesignControl ctl = new DesignControl(data as DIYReport.Interface.IRptSingleObj); data.EndUpdate(); ctl.IsSelected = true; //ctl.IsMainSelected = true; this._DataObj.Add(data); this.Add(ctl); last = ctl; } if (last != null) { SetMainSelected(last); ShowFocusHandle(true); } if (selectHeight > this.Section.DataObj.Height) { this.Section.DataObj.Height = selectHeight; } }
public MySingleRptCtlData(DIYReport.Interface.IRptSingleObj ctrl) { _PropertyList = new Hashtable(); _CtrlFullName = ctrl.GetType().FullName; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(ctrl); foreach (PropertyDescriptor myProperty in properties) { try { if (!myProperty.PropertyType.IsSerializable) { continue; } object val = myProperty.GetValue(ctrl); if (val != null) { Type objType = val.GetType(); System.Reflection.MethodInfo methInfo = objType.GetMethod("Clone"); if (methInfo != null) { val = methInfo.Invoke(val, null); } } _PropertyList.Add(myProperty.Name, val); } catch (Exception ex) { DIYReport.TrackEx.Write("在进行剪贴板操作的时候,获取属性的值出错。" + ex.Message); } } }
private void disposeRptImage() { if (SectionList == null || SectionList.Count == 0) { return; } foreach (DIYReport.UserDIY.DesignSection section in this.SectionList) { foreach (DIYReport.UserDIY.DesignControl ctl in section.DesignControls) { DIYReport.Interface.IRptSingleObj obj = ctl.DataObj; if (obj.Type != DIYReport.ReportModel.RptObjType.Image) { continue; } System.Drawing.Image img = (obj as DIYReport.ReportModel.RptObj.RptPictureBox).Image; if (img != null) { try{ img.Dispose(); } catch { } } } } }
//在撤消操作中,如果碰到增加的操作,需要在撤消时删除掉 public void Remove(IList pObjList) { int i = 0; while (i < this.Count) { if (this[i] == null) { break; } bool b = false; DesignControl ctl = this[i] as DesignControl; for (int j = 0; j < pObjList.Count; j++) { DIYReport.Interface.IRptSingleObj data = pObjList[j] as DIYReport.Interface.IRptSingleObj; if (data != null && ctl.DataObj.Name == data.Name) { removeCtl(ctl); b = true; } } if (!b) { i++; } } }
/// <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); }
public override void Draw(Graphics g, DIYReport.Interface.IRptSingleObj dataObj) { SolidBrush brush = new SolidBrush(dataObj.ForeColor); Pen pen = new Pen(brush, dataObj.LinePound); pen.DashStyle = dataObj.LineStyle; g.DrawRectangle(pen, dataObj.InnerRect); }
//画边框 private void drawRect(Graphics g, DIYReport.Interface.IRptSingleObj pObj) { RectangleF rct = RealRectangle(pObj); SolidBrush brush = new SolidBrush(pObj.ForeColor); Pen pen = new Pen(brush, pObj.LinePound); pen.DashStyle = pObj.LineStyle; g.DrawRectangle(pen, rct.Left - 1, rct.Top - 3, rct.Width, rct.Height); }
//画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); } }
public DesignControl(DIYReport.Interface.IRptSingleObj pDataObj) { _IsSelected = false; _DataObj = pDataObj; (_DataObj as RptSingleObj).AfterValueChanged += new DIYReport.ReportModel.RptEventHandler(_DataObj_AfterValueChanged); InitializeComponent(); _FocusList = new FocusHandleList(this); updateByDataObj(); }
public override void Draw(Graphics g, DIYReport.Interface.IRptSingleObj dataObj) { RptRichTextBox obj = dataObj as RptRichTextBox; if (obj == null) { return; } this.DrawBingFieldName(g, obj, "@" + obj.FieldName); }
public override string GetObjectText(DIYReport.Interface.IRptSingleObj dataObj) { string txt = string.Empty; RptFieldTextBox exObj = dataObj as RptFieldTextBox; if (exObj != null) { txt = "@" + exObj.FieldName; } return(txt); }
public override void Draw(Graphics g, DIYReport.Interface.IRptSingleObj dataObj) { RptDBPictureBox picData = dataObj as RptDBPictureBox; if (picData == null) { return; } this.DrawBingFieldName(g, dataObj, "@" + picData.FieldName); }
public override string GetObjectText(DIYReport.Interface.IRptSingleObj dataObj) { RptLable obj = dataObj as RptLable; if (obj != null) { return(obj.Text); } else { return(string.Empty); } }
//得到绘制文件在页面上真正的位置 XML配制的Y坐标 + Section 的 Height protected virtual RectangleF RealRectangle(DIYReport.Interface.IRptSingleObj pRptObj) { RectangleF drawRct; RectangleF oldRct = pRptObj.Rect; int marginLeft = _DocMargin.Left, marginTop = _DocMargin.Top; //在这里如果存在每张报表只绘制一个title 的事情detail 的高度要做个计算才可以。 switch (pRptObj.Section.SectionType) { case DIYReport.SectionType.ReportTitle: drawRct = new RectangleF(marginLeft + oldRct.X, marginTop + oldRct.Y, oldRct.Width, oldRct.Height); return(drawRct); case DIYReport.SectionType.PageHead: drawRct = new RectangleF(marginLeft + oldRct.X, marginTop + oldRct.Y + _RptInfo.TitleHeight, oldRct.Width, oldRct.Height); return(drawRct); case DIYReport.SectionType.GroupHead: case DIYReport.SectionType.Detail: case DIYReport.SectionType.GroupFooter: drawRct = new RectangleF(marginLeft + oldRct.X, marginTop + oldRct.Y + _RptInfo.TitleHeight + _RptInfo.PageHeadHeight + _HasDrawDetailHeight, oldRct.Width, oldRct.Height); return(drawRct); case DIYReport.SectionType.PageFooter: drawRct = new RectangleF(marginLeft + oldRct.X, marginTop + oldRct.Y + _RptInfo.TitleHeight + _RptInfo.PageHeadHeight + REAL_DETAIL_HEIGHT, oldRct.Width, oldRct.Height); return(drawRct); case DIYReport.SectionType.ReportBottom: float rHeight; if (_IsLastPage && _RowPoint == 0) { rHeight = _RptInfo.BottomHeight; } else { rHeight = _HasDrawDetailHeight; } drawRct = new RectangleF(marginLeft + oldRct.X, marginTop + oldRct.Y + _RptInfo.TitleHeight + _RptInfo.PageHeadHeight + rHeight, oldRct.Width, oldRct.Height); return(drawRct); } return(oldRct); }
/// <summary> /// 绘制Unscaled图象 /// </summary> /// <param name="g"></param> /// <param name="dataObj"></param> /// <param name="image"></param> public void DrawImageUnscaled(Graphics g, DIYReport.Interface.IRptSingleObj dataObj, Image image) { SolidBrush brush = new SolidBrush(dataObj.ForeColor); System.Drawing.Rectangle drawRect = dataObj.InnerRect; if (image != null) { System.Drawing.Size iSize = image.Size; System.Drawing.Point drawPoint = new Point((dataObj.InnerRect.Width - iSize.Width) / 2, (dataObj.InnerRect.Height - iSize.Height) / 2); g.DrawImageUnscaled(image, drawPoint); } g.DrawRectangle(new Pen(brush, dataObj.LinePound), dataObj.InnerRect); }
//格式化选择的控件 private void FormatCtl(Rectangle pRect, CommandID cmdID) { DesignControlList ctlList = DesignerHost.SectionList.GetActiveSection().DesignControls; foreach (DesignControl ctl in ctlList) { if (!ctl.IsSelected) { continue; } DIYReport.Interface.IRptSingleObj dataObj = ctl.DataObj; if (cmdID.Equals(StandardCommands.AlignLeft)) { dataObj.Location = new Point(pRect.Left, ctl.Top); } else if (cmdID.Equals(StandardCommands.AlignTop)) { dataObj.Location = new Point(ctl.Left, pRect.Top); } else if (cmdID.Equals(StandardCommands.AlignRight)) { dataObj.Location = new Point(pRect.Right - ctl.Width, ctl.Top); } else if (cmdID.Equals(StandardCommands.AlignBottom)) { dataObj.Location = new Point(ctl.Left, pRect.Top + pRect.Height - ctl.Height); //ctl.Top = pRect.Top + pRect.Height - ctl.Height ; } else if (cmdID.Equals(StandardCommands.SizeToControlWidth)) { dataObj.Size = new Size(pRect.Width, ctl.Height); //ctl.Width = pRect.Width ; } else if (cmdID.Equals(StandardCommands.SizeToControlHeight)) { dataObj.Size = new Size(ctl.Width, pRect.Height); //ctl.Height = pRect.Height ; } else { Debug.Assert(false, "Command" + cmdID.ID.ToString() + "没有处理。"); return; } } DesignerHost.SectionList.GetActiveSection().DesignControls.ShowFocusHandle(true); }
/// <summary> /// 绘制绑定到非文本对象的字段信息。 /// </summary> /// <param name="g"></param> /// <param name="dataObj"></param> /// <param name="fieldName"></param> public void DrawBingFieldName(Graphics g, DIYReport.Interface.IRptSingleObj dataObj, string fieldName) { StringFormat strFormat = new StringFormat(); strFormat.FormatFlags = StringFormatFlags.LineLimit; SolidBrush brush = new SolidBrush(Color.Black); Font f = new System.Drawing.Font("Microsoft Sans Serif", 9F); SizeF fontSize = g.MeasureString("A", f); float fontFirstY = (dataObj.Size.Height - fontSize.Height) / 2; g.DrawString(fieldName, f, brush, new RectangleF(new PointF(0, fontFirstY), dataObj.Size), strFormat); Pen pen = new Pen(brush, dataObj.LinePound); pen.DashStyle = dataObj.LineStyle; g.DrawRectangle(pen, dataObj.InnerRect); }
/// <summary> /// 获取绘制报表对象的操作对象。(主要用在报表预浏和打印状态下的报表绘制) /// </summary> /// <param name="dataObj"></param> /// <returns></returns> public static DrawingRptObject GetPreviewDrawObject(DIYReport.Interface.IRptSingleObj dataObj) { DIYReport.ReportModel.RptObjType objType = dataObj.Type; DrawingRptObject dObj = _DrawPreviewObjLib[objType] as DrawingRptObject; if (dObj != null) { return(dObj); } switch (objType) { // case DIYReport.ReportModel.RptObjType.Line: // dObj = new DrawRptLine(); // break; // case DIYReport.ReportModel.RptObjType.Text: // dObj = new DrawRptLable(); // break; // case DIYReport.ReportModel.RptObjType.Express: // dObj = new DrawDesignRptFieldTextBox(); // break; // case DIYReport.ReportModel.RptObjType.Rect: // dObj = new DrawRptFrame(); // break; // case DIYReport.ReportModel.RptObjType.FieldImage: // dObj = new DrawBingFieldImage(); // break; // case DIYReport.ReportModel.RptObjType.Image: // dObj = new DrawRptPicrureBox(); // break; // case DIYReport.ReportModel.RptObjType.CheckBox: // dObj = new DrawRptCheckBox(); // break; case DIYReport.ReportModel.RptObjType.BarCode: dObj = new DrawRptBarCode(); break; // case DIYReport.ReportModel.RptObjType.SubReport: // dObj = new DrawRptSubReport(); // break; default: Debug.Assert(false, "该类型的绘制还没有处理。"); break; } _DrawPreviewObjLib[objType] = dObj; return(dObj); }
public void FormatCtl(Rectangle pRect, FormatCtlType pType) { foreach (DesignControl ctl in this) { if (ctl.IsSelected) { DIYReport.Interface.IRptSingleObj dataObj = ctl.DataObj; switch (pType) { case FormatCtlType.Left: dataObj.Location = new Point(pRect.Left, ctl.Top); break; case FormatCtlType.Top: dataObj.Location = new Point(ctl.Left, pRect.Top); //ctl.Top = pRect.Top ; break; case FormatCtlType.Right: dataObj.Location = new Point(pRect.Right - ctl.Width, ctl.Top); //ctl.Left = pRect.Right - ctl.Width ; break; case FormatCtlType.Bottom: dataObj.Location = new Point(ctl.Left, pRect.Top + pRect.Height - ctl.Height); //ctl.Top = pRect.Top + pRect.Height - ctl.Height ; break; case FormatCtlType.Width: dataObj.Size = new Size(pRect.Width, ctl.Height); //ctl.Width = pRect.Width ; break; case FormatCtlType.Height: dataObj.Size = new Size(ctl.Width, pRect.Height); //ctl.Height = pRect.Height ; break; default: break; } } } ShowFocusHandle(true); }
public MyClipbordData(IList cData) { _Ctls = new ArrayList(); if (cData == null) { return; } foreach (object ctl in cData) { DIYReport.Interface.IRptSingleObj rptObj = ctl as DIYReport.Interface.IRptSingleObj; if (rptObj == null) { continue; } MySingleRptCtlData ctlData = new MySingleRptCtlData(rptObj); _Ctls.Add(ctlData); } }
public override string GetObjectText(DIYReport.Interface.IRptSingleObj dataObj) { string txt = string.Empty; RptExpressBox exObj = dataObj as RptExpressBox; if (exObj != null) { if (exObj.ExpressType != ExpressType.Express) { txt = "@" + exObj.DataSource; } else { txt = "@" + exObj.DataSource + "(" + exObj.FieldName + ")"; } } return(txt); }
public override void Draw(Graphics g, DIYReport.Interface.IRptSingleObj dataObj) { RptSubReport subreport = dataObj as RptSubReport; if (subreport == null) { return; } string fieleName = RptDrawHelper.SUB_REPORT_FILE; Image reportImage = RptDrawHelper.CreateBitmapFromResources(fieleName); this.DrawImageUnscaled(g, subreport, reportImage); try{ reportImage.Dispose(); } catch {} }
public override void Draw(Graphics g, DIYReport.Interface.IRptSingleObj dataObj) { RptHViewSpecFieldBox exObj = dataObj as RptHViewSpecFieldBox; int cellWidth = exObj.CellWidth; int width = exObj.Size.Width; int count = width / cellWidth; SolidBrush brush = new SolidBrush(dataObj.ForeColor); Pen pen = new Pen(brush, dataObj.LinePound); pen.DashStyle = dataObj.LineStyle; g.DrawRectangle(pen, dataObj.InnerRect); Rectangle rect = exObj.InnerRect; for (int i = 1; i < count; i++) { g.DrawLine(pen, rect.X + cellWidth * i, rect.Y, rect.X + cellWidth * i, rect.Y + rect.Height); } }
//设置控件的属性值。 private static void setRptCtlProperties(DIYReport.Interface.IRptSingleObj rptObj, Hashtable propertyList) { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(rptObj); foreach (PropertyDescriptor myProperty in properties) { if (!propertyList.Contains(myProperty.Name)) { continue; } object val = propertyList[myProperty.Name]; try { myProperty.SetValue(rptObj, val); } catch (Exception ex) { DIYReport.TrackEx.Write("在进行剪贴板操作的时候,设置控件的属性值时出错。" + ex.Message); } } }
public override void Draw(Graphics g, DIYReport.Interface.IRptSingleObj dataObj) { RptBarCode codeInfo = dataObj as RptBarCode; if (codeInfo == null) { return; } IDrawBarCode drawLib = _DrawBarCodeObject[typeof(DrawCodeBarCode)] as IDrawBarCode; if (drawLib == null) { drawLib = new DrawCodeBarCode(); _DrawBarCodeObject[typeof(DrawCodeBarCode)] = drawLib; } drawLib.DrawBarCode(g, codeInfo); }
public override void Draw(Graphics g, DIYReport.Interface.IRptSingleObj dataObj) { RptPictureBox imageObj = dataObj as RptPictureBox; if (imageObj == null) { return; } // switch(image.DrawSizeModel){ // case System.Windows.Forms.PictureBoxSizeMode.AutoSize: // g.DrawImage( // // break; // default: // break; // } this.DrawImageUnscaled(g, imageObj, imageObj.Image); }
public override void Draw(Graphics g, DIYReport.Interface.IRptSingleObj dataObj) { SolidBrush brush = new SolidBrush(dataObj.ForeColor); DIYReport.ReportModel.RptObj.RptLine obj = dataObj as DIYReport.ReportModel.RptObj.RptLine; if (obj == null) { return; } Point p1 = new Point(0, 0); Point p2 = new Point(dataObj.Size.Width, dataObj.Size.Height); switch (obj.LineType) { case DIYReport.ReportModel.LineType.Horizon: //水平线 p2 = new Point(dataObj.Size.Width, 0); break; case DIYReport.ReportModel.LineType.Vertical: //垂直线 p2 = new Point(0, dataObj.Size.Height); break; case DIYReport.ReportModel.LineType.Bias: // 斜线 p2 = new Point(dataObj.Size.Width, dataObj.Size.Height); break; case DIYReport.ReportModel.LineType.Backlash: //反 斜线 p1 = new Point(0, dataObj.Size.Height); p2 = new Point(dataObj.Size.Width, 0); break; default: Debug.Assert(false, "该类型还没有设置!", ""); break; } Pen pen = new Pen(brush, dataObj.LinePound); pen.DashStyle = dataObj.LineStyle; g.DrawLine(pen, p1, p2); }
//实现该接口是为了实现用户操作的 Undo 和Redo 的操作 public void SetPropertyValue(ref IList pObjList) { //在改变对象属性的撤消动作中 目前只处理报表对象的位置和大小 ArrayList proList = new ArrayList(); foreach (DIYReport.Interface.IRptSingleObj obj in _DataObj) { for (int i = 0; i < pObjList.Count; i++) { DIYReport.Interface.IRptSingleObj utem = pObjList[i] as DIYReport.Interface.IRptSingleObj; if (utem != null && obj.Name == utem.Name) { proList.Add(obj.WiseClone()); obj.BeginUpdate(); obj.Location = utem.Location; obj.Size = utem.Size; obj.EndUpdate(); } } } pObjList = proList; }