diff --git a/src/AddIns/Misc/SharpReport/SharpReport/AutoReport.cs b/src/AddIns/Misc/SharpReport/SharpReport/AutoReport.cs index 182e88cc24..9a676bb61a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/AutoReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/AutoReport.cs @@ -18,6 +18,7 @@ using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using SharpReport; +using SharpReport.Designer; using SharpReportCore; using SharpReport.ReportItems; @@ -37,22 +38,13 @@ namespace SharpReport { public class AutoReport : object,IDisposable { SharpReport.Designer.IDesignableFactory iDesignableFactory; - private NameService nameService; - + public AutoReport() { iDesignableFactory = new SharpReport.Designer.IDesignableFactory(); - nameService = new NameService(); } - - #region System.IDisposable interface implementation - public void Dispose() { - } - #endregion - - - #region Build report's + #region Build ReportItemsCollection /// <summary> /// Build BaseDataItems from a schemaDataTable @@ -61,7 +53,7 @@ namespace SharpReport { /// <param name="schemaTable">SchemaDefinition Datatable</param> /// <returns>Collection of BaseDataItems</returns> - public ReportItemCollection ReportItemsFromTable (ReportModel model,DataTable schemaTable) { + public ReportItemCollection DataItemsFromTable (ReportModel model,DataTable schemaTable) { ReportItemCollection itemCol = new ReportItemCollection(); for (int i = 0;i < schemaTable.Rows.Count;i++){ @@ -77,39 +69,15 @@ namespace SharpReport { return itemCol; } - ///<summary> - /// Build a <see cref="ColumnCollection"></see> this collection holds all the fields - /// comming from the DataSource - ///</summary> - - public ColumnCollection AbstractColumnsFromDataSet(DataSet dataSet) { - if (dataSet.Tables.Count > 1) { - MessageService.ShowError ("AutoBuildFromDataSet : at this time no more than one table is allowed " + dataSet.Tables.Count.ToString()); - throw new ArgumentException ("Too much Tables in DataSet"); - } - - ColumnCollection collection = new ColumnCollection(); - foreach (DataTable tbl in dataSet.Tables) { - DataColumn col; - for (int i = 0;i < tbl.Columns.Count ;i++ ) { - col = tbl.Columns[i]; - AbstractColumn abstrColumn = new AbstractColumn(); - abstrColumn.ColumnName = col.ColumnName; - abstrColumn.DataType = col.DataType; - collection.Add (abstrColumn); - } - } - return collection; - } /// <summary> - /// Build BaseDataItems from a *.xsd File + /// Build BaseDataItems from a *.xsd (Schema) File /// </summary> /// <param name="model">a valid ReportModel</param> /// <param name="dataSet">DataSet from *.xsd File</param> /// <returns> Collection of BaseDataItems</returns> - public ReportItemCollection ReportItemsFromSchema (ReportModel model,DataSet dataSet) { + public ReportItemCollection DataItemsFromSchema (ReportModel model,DataSet dataSet) { if (dataSet.Tables.Count > 1) { MessageService.ShowError ("AutoBuildFromDataSet : at this time no more than one table is allowed " + dataSet.Tables.Count.ToString()); throw new ArgumentException ("Too much Tables in DataSet"); @@ -131,26 +99,61 @@ namespace SharpReport { } return itemCol; } + + #endregion + + #region Build report's + + ///<summary> + /// Build a <see cref="ColumnCollection"></see> this collection holds all the fields + /// comming from the DataSource + ///</summary> + + public ColumnCollection AbstractColumnsFromDataSet(DataSet dataSet) { + if (dataSet.Tables.Count > 1) { + MessageService.ShowError ("AutoBuildFromDataSet : at this time no more than one table is allowed " + dataSet.Tables.Count.ToString()); + throw new ArgumentException ("Too much Tables in DataSet"); + } + + ColumnCollection collection = new ColumnCollection(); + foreach (DataTable tbl in dataSet.Tables) { + DataColumn col; + for (int i = 0;i < tbl.Columns.Count ;i++ ) { + col = tbl.Columns[i]; + AbstractColumn abstrColumn = new AbstractColumn(); + abstrColumn.ColumnName = col.ColumnName; + abstrColumn.DataType = col.DataType; + collection.Add (abstrColumn); + } + } + return collection; + } + + + + public ReportItemCollection AutoDataColumns(ReportItemCollection col) { if (col != null) { ReportItemCollection itemCol = new ReportItemCollection(); - ReportDataItem oldItem = null; + ReportDataItem sourceItem = null; for (int i = 0;i < col.Count ;i++ ){ - ReportDataItem newItem = new ReportDataItem(); - oldItem = (ReportDataItem)col[i]; - newItem.VisualControl.Text = oldItem.ColumnName; - newItem.ColumnName = oldItem.ColumnName; - newItem.DbValue = oldItem.DbValue; - newItem.BaseTableName = oldItem.BaseTableName; - newItem.DataType = oldItem.DataType; - newItem.Location = new Point (i * 30,5); - itemCol.Add(newItem); + ReportDataItem destItem = new ReportDataItem(); + sourceItem = (ReportDataItem)col[i]; + + destItem.VisualControl.Text = sourceItem.ColumnName; + destItem.ColumnName = sourceItem.ColumnName; + destItem.DbValue = sourceItem.DbValue; + destItem.BaseTableName = sourceItem.BaseTableName; + destItem.DataType = sourceItem.DataType; + destItem.Location = new Point (i * 30,5); + itemCol.Add(destItem); } return itemCol; } else { throw new ArgumentNullException ("AutoReport:ReportItemCollection"); } } + #endregion #region HeaderColumns @@ -163,7 +166,7 @@ namespace SharpReport { /// <param name="setOnTop">Locate the Columns of Top or an Bottom of the Section</param> /// <returns>a Collection of BaseTextItems</returns> - public ReportItemCollection AutoHeaderFromTable (BaseSection section,DataTable schemaTable,bool setOnTop) { + public ReportItemCollection HeaderColumnsFromTable (BaseSection section,DataTable schemaTable,bool setOnTop) { ReportItemCollection itemCol = new ReportItemCollection(); for (int i = 0;i < schemaTable.Rows.Count;i++){ DataRow r = schemaTable.Rows[i]; @@ -185,7 +188,7 @@ namespace SharpReport { } - public ReportItemCollection AutoHeaderFromReportItems(ReportItemCollection reportItemCollection,BaseSection section,bool setOnTop) { + public ReportItemCollection HeaderColumnsFromReportItems(ReportItemCollection reportItemCollection,BaseSection section,bool setOnTop) { if (reportItemCollection == null) { throw new ArgumentNullException ("reportItemCollection"); } @@ -215,6 +218,58 @@ namespace SharpReport { } #endregion + /* + #region Standarts for all reports (Headlines etc) + + /// <summary> + /// Insert a <see cref="ReportTextItem"></see> in the PageHeader with + /// the <see cref="ReportModel.ReportSettings.ReportName"></see> as + /// text + /// </summary> + /// <param name="model">ReportModel</param> + public void CreatePageHeader (ReportModel model) { + BaseSection section = model.PageHeader; + section.SuspendLayout(); + SharpReport.Designer.IDesignableFactory gf = new SharpReport.Designer.IDesignableFactory(); + BaseTextItem item = (BaseTextItem)gf.Create ("ReportTextItem"); + item.SuspendLayout(); + item.Text = model.ReportSettings.ReportName; + item.Font = CopyFont(model.ReportSettings.DefaultFont); + item.Location = new Point (0,0); + item.Size = new Size (item.Size.Width,item.Font.Height + SharpReportCore.GlobalValues.EnlargeControl); + section.Items.Add (item); + item.ResumeLayout(); + section.ResumeLayout(); + } + + ///<summary> + /// Insert Function 'PageNumber' in Section PageFooter + /// </summary> + /// <param name="model">ReportModel</param> + + public void CreatePageNumber (ReportModel model) { + BaseSection section = model.PageFooter; + section.SuspendLayout(); + FunctionFactory gf = new FunctionFactory(); + PageNumber pageNumber = (PageNumber)gf.Create ("PageNumber"); + pageNumber.SuspendLayout(); + + pageNumber.Text = ResourceService.GetString("SharpReport.Toolbar.Functions.PageNumber"); + pageNumber.Location = new Point (0,0); + section.Items.Add(pageNumber); + pageNumber.ResumeLayout(); + section.ResumeLayout(); + } + + #endregion + */ + + + + #region System.IDisposable interface implementation + public void Dispose() { + } + #endregion } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/IDesignable.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/IDesignable.cs index de09d4baff..545e540044 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/IDesignable.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/IDesignable.cs @@ -40,8 +40,6 @@ namespace SharpReport.Designer{ } event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - -// event EventHandler <GroupChangedEventArgs> GroupChanged; event EventHandler <EventArgs> Selected; } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/NameService.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/NameService.cs index 511bf8cceb..71d6abafb3 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/NameService.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/NameService.cs @@ -15,7 +15,7 @@ using System.ComponentModel; using SharpReportCore; /// <summary> -/// Build proper (unique) Names for all added Item's +/// Build a proper (unique) Names for all added Item's /// </summary> /// <remarks> /// created by - Forstmeier Peter diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs index 87fe1c690c..ef682aa3bf 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs @@ -29,12 +29,12 @@ namespace SharpReport.Designer{ private SharpReport.Designer.ReportFooter visualFooter; private SharpReport.Designer.ReportPageFooter visualPageFooter; private SharpReport.Designer.ReportDetail visualDetail; - + // Generic selected object in report private IBaseRenderer selectedObject; - + // Section selected in report private ReportSection selectedSection; @@ -91,6 +91,12 @@ namespace SharpReport.Designer{ base.Dispose(disposing); } + private void SetDefaultValues() { + foreach (BaseSection sec in this.sectionCollection) { + sec.SectionMargin = this.reportSettings.DefaultMargins.Left; + sec.Parent = null; + } + } private void InitSectionCollection () { sectionCollection = new ReportSectionCollection(); @@ -99,13 +105,13 @@ namespace SharpReport.Designer{ detail = new ReportSection(visualDetail); pageFooter = new ReportSection(visualPageFooter); footer = new ReportSection(visualFooter); - + header.Name = header.VisualControl.GetType().Name; pageHeader.Name = pageHeader.VisualControl.GetType().Name; detail.Name = detail.VisualControl.GetType().Name; footer.Name = footer.VisualControl.GetType().Name; pageFooter.Name = pageFooter.VisualControl.GetType().Name; - + sectionCollection.Add(header); sectionCollection.Add(pageHeader); sectionCollection.Add(detail); @@ -131,7 +137,7 @@ namespace SharpReport.Designer{ visualPageFooter.ReportItemsHandling += new ItemDragDropEventHandler (OnAddReportItem); visualFooter.ReportItemsHandling += new ItemDragDropEventHandler (OnAddReportItem); } - + private Rectangle SectionClientArea (SharpReport.Designer.ReportSectionControlBase ctrl) { Rectangle rect = new Rectangle(); rect.X = ctrl.Location.X; @@ -141,89 +147,152 @@ namespace SharpReport.Designer{ return rect; } + private void SetParent(BaseReportItem child,Point pointOf) { + foreach (BaseReportItem i in this.SelectedSection.Items) { + Rectangle r = new Rectangle (i.Location,i.Size); + if (r.Contains(pointOf)) { + child.Parent = i as IContainerItem; + return; + } + } + child.Parent = this.SelectedSection; + } - protected void OnAddReportItem (object sender,ItemDragDropEventArgs e) { - if (e.Action != ItemDragDropEventArgs.enmAction.Add) { - throw new NotSupportedException ("Only add allowed in Report.OnAddReportItem"); + + private IContainerItem FindParent(ItemDragDropEventArgs iddea) { + foreach (BaseReportItem i in this.SelectedSection.Items) { + Rectangle r = new Rectangle (i.Location,i.Size); + if (r.Contains(iddea.ItemAtPoint)) { + return i as IContainerItem; + } } + return null; + } + + + private BaseReportItem BuildDraggedItem (ItemDragDropEventArgs iddea) { + GlobalEnums.ReportItemType rptType = (GlobalEnums.ReportItemType) + GlobalEnums.StringToEnum(typeof(GlobalEnums.ReportItemType),iddea.ItemName); - ReportSectionControlBase b = (ReportSectionControlBase)sender; + SharpReport.Designer.IDesignableFactory gf = new SharpReport.Designer.IDesignableFactory(); + return gf.Create (rptType.ToString()); + } + + private void CustomizeItem ( ItemDragDropEventArgs iddea, + ReportItemCollection itemCollection, + BaseReportItem baseReportItem) { + + GlobalEnums.ReportItemType rptType = (GlobalEnums.ReportItemType) + GlobalEnums.StringToEnum(typeof(GlobalEnums.ReportItemType),iddea.ItemName); - // Find Selected Section - if (b != null) { - selectedSection = (ReportSection)sectionCollection.Find(b.GetType().Name); + baseReportItem.Name = nameService.CreateName(itemCollection, + baseReportItem.Name); + + + if (baseReportItem.Parent == this.selectedSection) { + baseReportItem.Location = new Point(iddea.ItemAtPoint.X,iddea.ItemAtPoint.Y); } else { - throw new NullReferenceException("No Section in Report.OnAddReportItem"); + BaseReportItem br = (BaseReportItem)this.FindParent(iddea); + baseReportItem.Location = new Point(iddea.ItemAtPoint.X - br.Location.X,10); + } + } + + + private void AdjustDesignable (BaseReportItem item) { + IDesignable designable = item as IDesignable; + designable.VisualControl.Name = item.Name; + } + + + private void SetVisualControl (BaseReportItem item){ + Control ctrl = null; + if (item.Parent == null) { + ctrl = this.selectedSection.VisualControl.Body; + } else { + if (item.Parent is ReportControlBase) { + ReportControlBase rb = item.Parent as ReportControlBase; + ctrl = rb.Body; + } } - //ReportItem from Factory - GlobalEnums.ReportItemType rptType = (GlobalEnums.ReportItemType) - GlobalEnums.StringToEnum(typeof(GlobalEnums.ReportItemType),e.ItemName); - - BaseReportItem baseReportItem = null; - try { - SharpReport.Designer.IDesignableFactory gf = new SharpReport.Designer.IDesignableFactory(); - - baseReportItem = gf.Create (rptType.ToString()); - IDesignable iDesignable = baseReportItem as IDesignable; - - if (iDesignable != null) { - iDesignable.Location = e.ItemAtPoint; - iDesignable.Name = nameService.CreateName(this.selectedSection.Items, - rptType.ToString()); - - } else { - string str = String.Format("<{0}> does not implement IDesignable"); - MessageService.ShowError(str); + if (ctrl != null) { + IDesignable designable = item as IDesignable; + if (designable != null) { + ctrl.Controls.Add(designable.VisualControl); + this.AdjustControl(designable); + ctrl.Invalidate(); } - - } catch (Exception ee) { - MessageService.ShowError(ee,ee.Message); } - if (baseReportItem == null) { - string str = String.Format("Unable to create <0> ",rptType.ToString()); - MessageService.ShowError(str); + } + + private ReportSection SectionByName ( ReportSectionControlBase item) { + if (item != null) { + return (ReportSection)sectionCollection.Find(item.GetType().Name); + } + throw new NullReferenceException("No Section in Report.OnAddReportItem"); + } + + private void AdjustControl (IDesignable ctrl) { + ctrl.VisualControl.BringToFront(); + ctrl.VisualControl.Focus(); + } + + + private void OnAddReportItem (object sender,ItemDragDropEventArgs iddea) { + + if (iddea.Action != ItemDragDropEventArgs.enmAction.Add) { + throw new NotSupportedException (); } - //If all went well until now + selectedSection = SectionByName ((ReportSectionControlBase)sender); + + BaseReportItem baseReportItem = BuildDraggedItem(iddea); + if (baseReportItem != null) { - // set usefull values + + SetParent (baseReportItem,iddea.ItemAtPoint); + IItemRenderer itemRenderer = baseReportItem as IItemRenderer; - try { - //Insert Item into selectedSection.Items - if (selectedSection != null) { - baseReportItem.Parent = selectedSection; - try { - IItemRenderer aa = baseReportItem as IItemRenderer; - if (aa != null) { - selectedSection.Items.Add(aa); - } else { - throw new NullReferenceException("Report:OnAddReportItem "); + + if (itemRenderer != null) { + SetVisualControl (baseReportItem); + if (baseReportItem.Parent != null) { + if (baseReportItem.Parent == this.selectedSection) { + // we have a 'TopLevel' Control + baseReportItem.Parent = selectedSection; + this.selectedSection.Items.Added += OnItemCollectionAdd; + this.selectedSection.Items.Add(itemRenderer); + CustomizeItem (iddea,selectedSection.Items,baseReportItem); + } else { + IContainerItem parent = baseReportItem.Parent as IContainerItem; + if (parent != null) { + parent.Items.Added += OnItemCollectionAdd; + parent.Items.Add (itemRenderer); + CustomizeItem (iddea,parent.Items,baseReportItem); } - - } catch (Exception) { - throw; } } - } catch (Exception ee) { - throw ee; + + } else { + throw new NullReferenceException("Report:OnAddReportItem "); } + AdjustDesignable(baseReportItem); }else { - throw new Exception("No Item created in Report.OnAddReportItem"); - } - - try { - selectedObject = (IItemRenderer)baseReportItem; - } catch (Exception ex) { - MessageService.ShowError(ex,ex.Message); + string str = String.Format("Unable to create <0> ",iddea.ItemName); + MessageService.ShowError(str); } - + selectedObject = (IBaseRenderer)baseReportItem; if (DesignViewChanged != null) { - DesignViewChanged (this,e); + DesignViewChanged (this,iddea); } } - #region property's + private void OnItemCollectionAdd(object sender, CollectionItemEventArgs<IItemRenderer> e){ + SharpReport.Designer.IDesignable iDesignable = e.Item as SharpReport.Designer.IDesignable; + iDesignable.Selected += new EventHandler <EventArgs>(this.ItemSelected); + } + + #region property's public ReportSectionCollection SectionCollection { @@ -258,8 +327,12 @@ namespace SharpReport.Designer{ } set { reportSettings = value; + SetDefaultValues(); } } + + + #endregion #region events @@ -297,7 +370,7 @@ namespace SharpReport.Designer{ - + #region Windows Forms Designer generated code /// <summary> /// This method is required for Windows Forms designer support. diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs index d209e33921..04d6fd7586 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs @@ -27,12 +27,14 @@ namespace SharpReport.Designer private SharpReport.Designer.Report reportControl; private Ruler.ctrlRuler ctrlRuler1; - private System.Drawing.GraphicsUnit graphicsUnit = GraphicsUnit.Point; + private System.Drawing.GraphicsUnit graphicsUnit; private ReportModel reportModel; public event PropertyChangedEventHandler DesignerDirty; + + public BaseDesignerControl() { InitializeComponent(); @@ -48,12 +50,32 @@ namespace SharpReport.Designer reportModel = new ReportModel (graphicsUnit); this.ReportControl.ReportSettings = reportModel.ReportSettings; } - + #region public'c //if languages change, we need a way to chage the headlines here as well + public void Localise() { reportControl.Localise(); } + public void RemoveSelectedItem () { + if (this.SelectedObject == null) { + return; + } + BaseReportItem item = this.SelectedObject as BaseReportItem; + + if ((item.Parent == this.SelectedSection)|| (item.Parent == null)){ + this.SelectedSection.Items.Remove (item); + } else { + IContainerItem con = item.Parent as IContainerItem; + if (con != null) { + con.Items.Remove (item); + } + } + } + + + #endregion + #region overrides protected override void Dispose(bool disposing ) { @@ -106,13 +128,13 @@ namespace SharpReport.Designer public ReportModel ReportModel { get { + reportModel.ReportSettings = reportControl.ReportSettings; reportModel.SectionCollection.Clear(); foreach (ReportSection section in reportControl.SectionCollection) { reportModel.SectionCollection.Add (section); } - return this.reportModel; - + return reportModel; } set { this.reportModel = value; diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ItemsDragDropEventArgs.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ItemsDragDropEventArgs.cs index ffc7cd73fb..8603e68ed0 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ItemsDragDropEventArgs.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ItemsDragDropEventArgs.cs @@ -33,10 +33,8 @@ namespace SharpReport.Designer { string itemName; enmAction action; Point itemAtPoint; - - public ItemDragDropEventArgs(enmAction action, Point itemAtPoint, string itemName) - { + public ItemDragDropEventArgs(enmAction action, Point itemAtPoint, string itemName){ this.action = action; this.itemAtPoint = itemAtPoint; this.itemName = itemName; diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportDetail.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportDetail.cs index bdf9499f12..5ab718f756 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportDetail.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportDetail.cs @@ -32,7 +32,6 @@ namespace SharpReport.Designer{ ControlStyles.ResizeRedraw, true); this.UpdateStyles(); -// base.ItemSelected += new SelectedEventHandler (OnItemSelected); base.ItemDragDrop += new ItemDragDropEventHandler (ItemsChanging); } @@ -47,11 +46,7 @@ namespace SharpReport.Designer{ ReportItemsHandling (this,e); } } - -// protected void OnItemSelected (object sender,EventArgs e) { -// MessageBox.Show ("On Item selected" + sender.ToString()); -// } -// + #region Windows Forms Designer generated code /// <summary> diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs index b786fe7685..ecb949513e 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs @@ -37,6 +37,7 @@ namespace SharpReport{ public event EventHandler <EventArgs> ItemSelected; public event EventHandler <EventArgs> Selected; + #region Constructors internal ReportSection() : base(){ @@ -51,7 +52,6 @@ namespace SharpReport{ internal ReportSection(SharpReport.Designer.ReportSectionControlBase visualControl) : base(){ this.Initialize(); this.VisualControl = visualControl; -// this.visualControl.ItemSelected += new SelectedEventHandler (OnItemSelectfrom); base.SectionOffset = 0; } @@ -59,7 +59,7 @@ namespace SharpReport{ private void Initialize(){ base.Items.Added += OnItemAddeded; - base.Items.Removed += OnItemRemoveded; + base.Items.Removed += OnRemoveTopLevelItem; } internal ReportSectionControlBase VisualControl{ @@ -85,58 +85,72 @@ namespace SharpReport{ } } + void SerializeItemProperties (XmlDocument doc, + XmlElement xmlControl, + BaseReportItem item,PropertyInfo [] prop) { + XmlElement xmlProperty; + XmlAttribute attPropValue; + + foreach (PropertyInfo p in prop) { + AttributeCollection attributes = TypeDescriptor.GetProperties(item)[p.Name].Attributes; + XmlIgnoreAttribute xmlIgnoreAttribute = (XmlIgnoreAttribute)attributes[typeof(XmlIgnoreAttribute)]; + if (xmlIgnoreAttribute == null){ + + xmlProperty = xmlControl.OwnerDocument.CreateElement (p.Name); + if (p.PropertyType == typeof(Font)) { + XmlFormReader.BuildFontElement (item.Font,xmlProperty); + } + else { + attPropValue = xmlControl.OwnerDocument.CreateAttribute ("value"); + attPropValue.InnerText = Convert.ToString(p.GetValue(item,null)); + xmlProperty.Attributes.Append(attPropValue); + } + xmlControl.AppendChild(xmlProperty); + } + } + + } + + private XmlElement SerializeControl (XmlDocument doc,BaseReportItem item) { + Type type = item.GetType(); + PropertyInfo [] prop = type.GetProperties(); + XmlElement xmlControl = doc.CreateElement ("control"); + XmlAttribute typeAttr = doc.CreateAttribute ("type"); + typeAttr.InnerText = type.FullName; + + xmlControl.Attributes.Append(typeAttr); + + XmlAttribute baseAttr = doc.CreateAttribute ("basetype"); + baseAttr.InnerText = type.BaseType.ToString(); + xmlControl.Attributes.Append(baseAttr); + SerializeItemProperties (doc,xmlControl,item,prop); + return xmlControl; + + } /// <summary> /// Read all ReportItenms of Section /// </summary> /// <param name="doc"></param> - private void ReportItemsToXml (XmlElement ctrlElement) { - - foreach (BaseReportItem it in base.Items) { - Type type = it.GetType(); - PropertyInfo [] prop = type.GetProperties(); - - XmlElement ctrl = ctrlElement.OwnerDocument.CreateElement ("control"); - XmlAttribute typeAttr = ctrlElement.OwnerDocument.CreateAttribute ("type"); - typeAttr.InnerText = type.FullName; - ctrl.Attributes.Append(typeAttr); - - XmlAttribute baseAttr = ctrlElement.OwnerDocument.CreateAttribute ("basetype"); - baseAttr.InnerText = type.BaseType.ToString(); - ctrl.Attributes.Append(baseAttr); + private XmlElement ReportItemsToXml (XmlDocument doc,ReportItemCollection items) { + XmlElement xmlControls = doc.CreateElement ("controls"); + + foreach (BaseReportItem item in items) { + XmlElement xmlControl = SerializeControl (doc,item); - XmlElement xmlProperty; - XmlAttribute attPropValue; + IContainerItem iContainer = item as IContainerItem; - foreach (PropertyInfo p in prop) { - AttributeCollection attributes = TypeDescriptor.GetProperties(it)[p.Name].Attributes; - XmlIgnoreAttribute xmlIgnoreAttribute = (XmlIgnoreAttribute)attributes[typeof(XmlIgnoreAttribute)]; - if (xmlIgnoreAttribute == null){ - - xmlProperty = ctrl.OwnerDocument.CreateElement (p.Name); - if (p.PropertyType == typeof(Font)) { - XmlFormReader.BuildFontElement (it.Font,xmlProperty); - } - else { - attPropValue = ctrl.OwnerDocument.CreateAttribute ("value"); - attPropValue.InnerText = Convert.ToString(p.GetValue(it,null)); - xmlProperty.Attributes.Append(attPropValue); - } - ctrl.AppendChild(xmlProperty); - } + if (iContainer != null) { + xmlControl.AppendChild ( ReportItemsToXml(doc,iContainer.Items)); } - ctrlElement.AppendChild(ctrl); + xmlControls.AppendChild(xmlControl); } + return xmlControls; } - private void SectionItemToXml (XmlElement xmlSection) { - Type type = this.GetType(); - PropertyInfo [] prop = type.GetProperties(); - - XmlAttribute att = xmlSection.OwnerDocument.CreateAttribute ("name"); - - att.InnerText = this.VisualControl.GetType().Name; - xmlSection.Attributes.Append(att); + private void SerializeSectionProperties (XmlDocument doc, + XmlElement section, + PropertyInfo [] prop) { XmlElement xmlProperty; XmlAttribute attPropValue; @@ -144,16 +158,31 @@ namespace SharpReport{ foreach (PropertyInfo p in prop) { if (this.CheckForXmlIgnore(p) == null ) { if (p.CanWrite) { - xmlProperty = xmlSection.OwnerDocument.CreateElement (p.Name); - attPropValue = xmlSection.OwnerDocument.CreateAttribute ("value"); + xmlProperty = doc.CreateElement (p.Name); + attPropValue = doc.CreateAttribute ("value"); attPropValue.InnerText = Convert.ToString(p.GetValue(this,null)); xmlProperty.Attributes.Append(attPropValue); - xmlSection.AppendChild(xmlProperty); + section.AppendChild(xmlProperty); } } } } + private XmlElement SectionItemToXml (XmlDocument doc) { + XmlElement section = doc.CreateElement ("section"); + + Type type = this.GetType(); + PropertyInfo [] prop = type.GetProperties(); + + XmlAttribute att = section.OwnerDocument.CreateAttribute ("name"); + + att.InnerText = this.VisualControl.GetType().Name; + section.Attributes.Append(att); + this.SerializeSectionProperties (doc,section,prop); + + return section; + } + #endregion @@ -161,31 +190,27 @@ namespace SharpReport{ #region iStoreable Interface public XmlDocument GetXmlData(){ //Only a temp DocumentObject - XmlDocument doc = SharpReportCore.XmlHelper.BuildXmlDocument (); - XmlElement root = doc.CreateElement ("Sections"); + XmlDocument xmlDocument = SharpReportCore.XmlHelper.BuildXmlDocument (); + XmlElement xmlRoot = xmlDocument.CreateElement ("Sections"); - doc.AppendChild(root); + xmlDocument.AppendChild(xmlRoot); - //Read the 'section' - XmlElement section = doc.CreateElement ("section"); - SectionItemToXml (section); + XmlElement xmlSection = SectionItemToXml (xmlDocument); //Then read all ReportItems of this Section - XmlElement xmlControls = doc.CreateElement ("controls"); - ReportItemsToXml (xmlControls); - section.AppendChild(xmlControls); - //and Append this to RootElement - root.AppendChild(section); - doc.AppendChild(root); - return doc; + XmlElement xmlControls = ReportItemsToXml (xmlDocument,base.Items); + xmlSection.AppendChild(xmlControls); + + xmlRoot.AppendChild(xmlSection); + xmlDocument.AppendChild(xmlRoot); + + return xmlDocument; } #endregion - public void OnItemSelect(object sender, EventArgs e){ - if (!base.Suspend) { if (ItemSelected != null) ItemSelected(sender, e); @@ -224,27 +249,12 @@ namespace SharpReport{ public void OnSelect(){ if (Selected != null) Selected(this,EventArgs.Empty); - } - - private void OnItemAddeded(object sender, CollectionItemEventArgs<IItemRenderer> e){ - AddItem(e.Item); - } - - private void OnItemRemoveded(object sender, CollectionItemEventArgs<IItemRenderer> e){ - //We have to Convert to IDesignable to - //get the VisualControl - SharpReport.Designer.IDesignable iDes = e.Item as SharpReport.Designer.IDesignable; - if (iDes != null) { - try { - this.VisualControl.Body.Controls.Remove (iDes.VisualControl); - } catch (Exception) { - throw new SystemException("ReportSection:OnItemRemoveded"); - } - } } + + private void OnItemAddeded(object sender, CollectionItemEventArgs<IItemRenderer> e){ + + SharpReport.Designer.IDesignable iDesignable = e.Item as SharpReport.Designer.IDesignable; - private void AddItem(IItemRenderer item){ - SharpReport.Designer.IDesignable iDesignable = item as SharpReport.Designer.IDesignable; if (iDesignable != null) { if (this.VisualControl != null) { iDesignable.Selected += new EventHandler <EventArgs>(this.ReportItemSelected); @@ -256,6 +266,18 @@ namespace SharpReport{ } } + private void OnRemoveTopLevelItem(object sender, CollectionItemEventArgs<IItemRenderer> e){ + //We have to Convert to IDesignable to + //get the VisualControl + + SharpReport.Designer.IDesignable iDes = e.Item as SharpReport.Designer.IDesignable; + if (iDes != null) { + this.VisualControl.Body.Controls.Remove (iDes.VisualControl); + } + } + + + public void Render (ReportSettings settings, SharpReportCore.ReportPageEventArgs e) { base.Render (e); @@ -297,6 +319,9 @@ namespace SharpReport{ } } + + + [Browsable(false)] [XmlIgnoreAttribute] public override bool Visible { diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSectionControlbase.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSectionControlbase.cs index e58b74e0be..1f100cbadd 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSectionControlbase.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSectionControlbase.cs @@ -8,6 +8,7 @@ */ using System; +using System.Globalization; using System.Drawing; using System.Windows.Forms; using System.ComponentModel; @@ -17,7 +18,7 @@ using SharpReport.ReportItems; namespace SharpReport.Designer{ /// <summary> - /// BaseControl for <see cref="ReportSection"></see> + /// BaseControl for <see cref="ReportSection"></see> /// </summary> /// @@ -29,12 +30,14 @@ namespace SharpReport.Designer{ private Ruler.ctrlRuler ctrlRuler1; private System.Windows.Forms.Panel bodyPanel; - private string caption = String.Empty; + private string caption; private bool mouseDown; private bool dragAllowed; private int currentY; + private IDesignableFactory designableFactory; + private BaseReportItem draggedItem; public event EventHandler <EventArgs> ItemSelected; @@ -49,13 +52,13 @@ namespace SharpReport.Designer{ ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); - this.UpdateStyles(); + this.UpdateStyles(); caption = this.Name; + this.designableFactory = new IDesignableFactory(); } - void ReportSectionLoad(object sender, System.EventArgs e) - { + void ReportSectionLoad(object sender, System.EventArgs e){ titleLabel.Text = this.GetType().Name; } @@ -64,46 +67,35 @@ namespace SharpReport.Designer{ } - private void BodyPanelPaint(object sender, PaintEventArgs e) { - Graphics g = e.Graphics; - g.Clear(this.Body.BackColor); - System.Windows.Forms.ControlPaint.DrawGrid (e.Graphics, - this.Body.ClientRectangle, - GlobalValues.GridSize, - Color.Gray); + private void BodyPanelPaint(object sender, PaintEventArgs pea) { + pea.Graphics.Clear(this.Body.BackColor); + ControlPaint.DrawGrid (pea.Graphics, + this.Body.ClientRectangle, + GlobalValues.GridSize, + Color.Gray); } - private void TitelLabelPaint(object sender, PaintEventArgs e) { - e.Graphics.Clear (this.BackColor); + private void TitelLabelPaint(object sender, PaintEventArgs pea) { + pea.Graphics.Clear (this.BackColor); using (Brush brush = new SolidBrush(Color.Black)) { - e.Graphics.DrawString (caption, - this.Font, - brush, - new PointF(0,0)); + pea.Graphics.DrawString (caption, + this.Font, + brush, + new PointF(0,0)); } } void SplitPanelMouseDown(object sender, System.Windows.Forms.MouseEventArgs e){ - mouseDown = true; + mouseDown = true; currentY = e.Y; } - void SplitPanelMouseMove(object sender, System.Windows.Forms.MouseEventArgs e){ -// System.Console.WriteLine("MoseMove"); - if (mouseDown) - { -// if (this.Height + (e.Y - currentY) > titlePanel.Height) -// this.Height = this.Height + (e.Y - currentY); - } - } - - void SplitPanelMouseUp(object sender, System.Windows.Forms.MouseEventArgs e) - { + void SplitPanelMouseUp(object sender, System.Windows.Forms.MouseEventArgs mea){ if (mouseDown){ - this.Height = this.Height + (e.Y - currentY); + this.Height = this.Height + (mea.Y - currentY); if (SectionChanged != null) { SectionChanged (this,new SectionChangedEventArgs (null,null)); } @@ -121,7 +113,7 @@ namespace SharpReport.Designer{ public Control Head { - get { + get { return this.titlePanel; } } @@ -144,6 +136,7 @@ namespace SharpReport.Designer{ if (ItemSelected != null) { ItemSelected (this,new EventArgs()); } + if (ItemDragDrop != null) { ItemDragDropEventArgs ea = new ItemDragDropEventArgs (ItemDragDropEventArgs.enmAction.Add, pointAt, @@ -155,58 +148,65 @@ namespace SharpReport.Designer{ #endregion #region overrides - protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) { - base.OnPaint(e); + base.OnPaint(pea); using (Pen p = new Pen(Color.Gray,5)){ - e.Graphics.DrawRectangle(p, 0, 0, this.Width - 1, this.Height - 1); + pea.Graphics.DrawRectangle(p, 0, 0, this.Width - 1, this.Height - 1); } } protected override void OnResize (EventArgs e) { base.OnResize (e); } - + #endregion #region dragdrop - protected bool CheckDragElement (System.Windows.Forms.DragEventArgs e) { - bool drag = false; - if (e.Data.GetDataPresent(typeof(System.String))){ - Object item = (object)e.Data.GetData(typeof(System.String)); - string str = Convert.ToString(item); - try { - GlobalEnums.StringToEnum (typeof(GlobalEnums.ReportItemType),str); - e.Effect = DragDropEffects.Copy; - drag = true; - } catch (Exception ex) { - e.Effect = DragDropEffects.None; - drag = false; - throw ex; - } finally { - - } + private string DragObjectToString (DragEventArgs dea) { + if (dea.Data.GetDataPresent(typeof(System.String))){ + return Convert.ToString (dea.Data.GetData(typeof(System.String)), + CultureInfo.InvariantCulture); } else { - e.Effect = DragDropEffects.None; + return String.Empty; + } + } + + private bool CheckDraggedControl (DragEventArgs dea) { + string str = this.DragObjectToString (dea); + return this.designableFactory.Contains(str); + + } + + private bool CheckDragElement (System.Windows.Forms.DragEventArgs dea) { + bool drag; + if (CheckDraggedControl(dea)) { + dea.Effect = DragDropEffects.Copy; + drag = true; + } else { + dea.Effect = DragDropEffects.None; drag = false; } return drag; } - void BodyPanelDragDrop(object sender, System.Windows.Forms.DragEventArgs e){ - if (e.Data.GetDataPresent(typeof(System.String))){ - Object item = (object)e.Data.GetData(typeof(System.String)); + + + void BodyPanelDragDrop(object sender, System.Windows.Forms.DragEventArgs dea){ + if (dea.Data.GetDataPresent(typeof(System.String))){ + Object item = (object)dea.Data.GetData(typeof(System.String)); + FiredDragDropItem (Convert.ToString(item), - this.Body.PointToClient (Cursor.Position)); + this.Body.PointToClient (Cursor.Position)); } } - void BodyPanelDragEnter(object sender, System.Windows.Forms.DragEventArgs e){ -// System.Console.WriteLine("BodyPanelDragEnter"); - dragAllowed = CheckDragElement(e); - this.Body.Invalidate(); + void BodyPanelDragEnter(object sender, System.Windows.Forms.DragEventArgs dea){ + dragAllowed = CheckDragElement(dea); + string s = DragObjectToString (dea); + this.draggedItem = this.designableFactory.Create(s); } void BodyPanelDragLeave(object sender, System.EventArgs e){ @@ -214,41 +214,40 @@ namespace SharpReport.Designer{ this.Body.Invalidate(); } - private void BodyPanelDragOver(object sender, System.Windows.Forms.DragEventArgs e){ - System.Console.WriteLine("ReportSectionControlBase:BodyDragOver"); -// if (this.bodyPanel.Controls.Count > 0) { -// if (PerformHitTest()) { -// -// } else { -//// System.Console.WriteLine("\t\t no Hit"); -// -// } -// -// } - - if (dragAllowed) { - e.Effect = DragDropEffects.Copy; + private void BodyPanelDragOver(object sender, System.Windows.Forms.DragEventArgs dea){ + IContainerItem parentControl = this.IsValidContainer(dea); + if (parentControl != null) { + if (parentControl.IsValidChild(this.draggedItem)) { + dea.Effect = DragDropEffects.Copy; + } else { + dea.Effect = DragDropEffects.None; + } + } else { - e.Effect = DragDropEffects.None; + if (dragAllowed) { + dea.Effect = DragDropEffects.Copy; + } else { + dea.Effect = DragDropEffects.None; + } } + } - /* - bool PerformHitTest() { - - Point p = this.bodyPanel.PointToClient(Control.MousePosition); + private IContainerItem IsValidContainer(DragEventArgs dea) { + Point point = new Point(dea.X,dea.Y); + for (int i = 0; i < this.bodyPanel.Controls.Count; i++) { Control c = this.bodyPanel.Controls[i]; - Rectangle r = new Rectangle(c.Left,c.Top,c.ClientRectangle.Width,c.ClientRectangle.Height); - if (r.Contains (p)) { - this.ItemSelected(c,EventArgs.Empty); - return true; - } + Rectangle r = c.ClientRectangle; + + if (r.Contains(c.PointToClient(point))) { + IContainerItem ia = c as IContainerItem; + return ia; + } } - - return false; + return null; } - */ + #endregion @@ -270,9 +269,9 @@ namespace SharpReport.Designer{ // bodyPanel // this.bodyPanel.AllowDrop = true; - this.bodyPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.bodyPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.bodyPanel.BackColor = System.Drawing.SystemColors.Window; this.bodyPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.bodyPanel.Location = new System.Drawing.Point(24, 20); @@ -313,7 +312,6 @@ namespace SharpReport.Designer{ this.splitPanel.Size = new System.Drawing.Size(432, 4); this.splitPanel.TabIndex = 7; this.splitPanel.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SplitPanelMouseUp); - this.splitPanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SplitPanelMouseMove); this.splitPanel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SplitPanelMouseDown); // // titlePanel @@ -353,5 +351,5 @@ namespace SharpReport.Designer{ } - + } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SideTab/BuildSideTab.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SideTab/BuildSideTab.cs index d53bc91bf2..857701fdb7 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SideTab/BuildSideTab.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SideTab/BuildSideTab.cs @@ -71,6 +71,12 @@ namespace SharpReport GlobalEnums.ReportItemType.ReportTextItem.ToString(), bitmap); tab.Items.Add (t); + + t = sideTab.SideTabItemFactory.CreateSideTabItem( "DataRow", + GlobalEnums.ReportItemType.ReportRowItem.ToString(), + ResourceService.GetBitmap("Icons.16x16.SharpQuery.Table")); + tab.Items.Add (t); + t = sideTab.SideTabItemFactory.CreateSideTabItem( ResourceService.GetString("SharpReport.Toolbar.DataField"), GlobalEnums.ReportItemType.ReportDataItem.ToString(), ResourceService.GetBitmap("Icons.16x16.SharpQuery.Column")); @@ -82,10 +88,12 @@ namespace SharpReport GlobalEnums.ReportItemType.ReportImageItem.ToString(), bitmap); tab.Items.Add (t); - t = sideTab.SideTabItemFactory.CreateSideTabItem( ResourceService.GetString("SharpReport.Toolbar.Rectangle"), GlobalEnums.ReportItemType.ReportRectangleItem.ToString(), - GlobalValues.RectangleBitmap()); + ResourceService.GetBitmap("Icons.16x16.SharpReport.Rectangle")); +// t = sideTab.SideTabItemFactory.CreateSideTabItem( ResourceService.GetString("SharpReport.Toolbar.Rectangle"), +// GlobalEnums.ReportItemType.ReportRectangleItem.ToString(), +// GlobalValues.RectangleBitmap()); tab.Items.Add (t); bitmap = ResourceService.GetIcon("Icons.16.16.SharpReport.Line").ToBitmap(); diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs new file mode 100644 index 0000000000..28b5015426 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs @@ -0,0 +1,80 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 03.03.2006 + * Time: 08:28 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Windows.Forms; +namespace SharpReport.Designer +{ + /// <summary> + /// Description of ControlHelper. + /// </summary> + public class ControlHelper{ + Control control; + + public ControlHelper(Control control){ + if (control == null) { + throw new ArgumentNullException("control"); + } + this.control = control; + } + + public Rectangle BuildFocusRectangle { + get { + return new Rectangle(this.control.ClientRectangle.Left, + this.control.ClientRectangle.Top, + this.control.ClientRectangle.Width -1, + this.control.ClientRectangle.Height -1); + } + } + + + + public void DrawEdges (PaintEventArgs e) { + + int arc = 5; + Rectangle r = this.BuildFocusRectangle; + using (Pen p = new Pen (Color.Black)) { + + e.Graphics.DrawRectangle (p, + r); + } + + using (Pen pb = new Pen(this.control.BackColor)){ + //top + + int leftLine = r.Left + arc; + int rightLine = r.Left + r.Width - arc; + int botLine = r.Top + r.Height; + //top + e.Graphics.DrawLine (pb, + leftLine,r.Top, + rightLine, r.Top); + + //bottom + e.Graphics.DrawLine (pb, + leftLine,botLine, + rightLine,botLine); + //left + + int top = r.Top + arc; + int down = r.Top + r.Height - arc; + e.Graphics.DrawLine(pb, + r.Left,top, + r.Left,down); + //right + e.Graphics.DrawLine(pb, + r.Left + r.Width,top, + r.Left + r.Width,down); + + } + } + + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs index 6ab2dab348..43a5a6251f 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs @@ -22,8 +22,8 @@ namespace SharpReport.Designer{ public abstract class ReportControlBase : ReportObjectControlBase{ private System.Windows.Forms.Label lblTopLeft; private System.Windows.Forms.Label lblBottomRight; - - const string contextMenuPath = "/SharpReport/ContextMenu/Items"; + private ControlHelper controlHelper; + private const string contextMenuPath = "/SharpReport/ContextMenu/Items"; private enum SizeDirection{ None, @@ -46,6 +46,7 @@ namespace SharpReport.Designer{ this.UpdateStyles(); lblTopLeft.Visible = false; lblBottomRight.Visible = false; + controlHelper = new ControlHelper((Control)this); } private void ReportControlBaseEnter(object sender, System.EventArgs e){ @@ -94,15 +95,7 @@ namespace SharpReport.Designer{ mouseDown = SizeDirection.None; base.OnControlChanged(); } - - private Rectangle BuildFocusRectangle(){ - return new Rectangle(this.ClientRectangle.Left, - this.ClientRectangle.Top, - this.ClientRectangle.Width -1, - this.ClientRectangle.Height -1); - - } - + private void DrawDecorations(Graphics g){ // it is not said that the // focused object in all the app @@ -112,48 +105,13 @@ namespace SharpReport.Designer{ if (lblBottomRight.Visible){ g.Clear(this.Body.BackColor); ControlPaint.DrawFocusRectangle(g, - this.BuildFocusRectangle()); + controlHelper.BuildFocusRectangle); } } - + protected override void OnPaint(System.Windows.Forms.PaintEventArgs e){ base.OnPaint(e); - int arc = 5; - Rectangle r = this.BuildFocusRectangle(); - using (Pen p = new Pen (Color.Black)) { - - e.Graphics.DrawRectangle (p, - r); - } - - using (Pen pb = new Pen(this.BackColor)){ - //top - - int leftLine = r.Left + arc; - int rightLine = r.Left + r.Width - arc; - int botLine = r.Top + r.Height; - //top - e.Graphics.DrawLine (pb, - leftLine,r.Top, - rightLine, r.Top); - - //bottom - e.Graphics.DrawLine (pb, - leftLine,botLine, - rightLine,botLine); - //left - - int top = r.Top + arc; - int down = r.Top + r.Height - arc; - e.Graphics.DrawLine(pb, - r.Left,top, - r.Left,down); - //right - e.Graphics.DrawLine(pb, - r.Left + r.Width,top, - r.Left + r.Width,down); - - } + controlHelper.DrawEdges(e); this.DrawDecorations(e.Graphics); } @@ -161,17 +119,6 @@ namespace SharpReport.Designer{ base.OnResize(e); this.Invalidate(); } - /* - private Image Line(){ - Bitmap b = new Bitmap (8,1); - using (Graphics g = Graphics.FromImage (b)){ - using (Pen p = new Pen(Color.Black,1)){ - g.DrawLine(p,0,0,8,0); - } - } - return (Image)b; - } - */ #region Windows Forms Designer generated code /// <summary> diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs index 496a486fb9..785a7374bc 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs @@ -8,50 +8,25 @@ */ using System; -using System.ComponentModel; using System.Windows.Forms; -using System.Drawing; + using SharpReportCore; -namespace SharpReport.Designer -{ + +namespace SharpReport.Designer{ /// <summary> /// Description of ReportDbTextItem. /// </summary> - internal class ReportDbTextControl : ReportControlBase - { - - private TextDrawer textDrawer = new TextDrawer(); - - public ReportDbTextControl() - { - + + internal class ReportDbTextControl : ReportTextControl{ + public ReportDbTextControl():base(){ InitializeComponent(); - this.SetStyle(ControlStyles.DoubleBuffer | - ControlStyles.UserPaint | - ControlStyles.AllPaintingInWmPaint | - ControlStyles.ResizeRedraw, - true); - this.UpdateStyles(); - + this.Size = GlobalValues.PreferedSize; + base.Name = this.Name; } - - - protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) - { - base.OnPaint(e); - Graphics g = e.Graphics; - - // we can draw in the control as we draw in preview - - StringFormat fmt = base.StringFormat; - fmt.Alignment = base.StringAlignment; - textDrawer.DrawString(g, - this.Text, - this.Font, - new SolidBrush(this.ForeColor), - (RectangleF)this.ClientRectangle, - fmt); + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){ + base.Text = this.Text; + base.OnPaint(pea); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs index 9bdc7d4fea..358a4f38ea 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs @@ -9,9 +9,8 @@ //------------------------------------------------------------------------------ using System; -using System.Windows.Forms; using System.Drawing; - +using System.Windows.Forms; using SharpReport.Designer; /// <summary> diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs new file mode 100644 index 0000000000..e6973c4c22 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs @@ -0,0 +1,74 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 01.03.2006 + * Time: 14:29 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.ComponentModel; +using System.Windows.Forms; + +using SharpReportCore; + +namespace SharpReport.Designer{ + + /// <summary> + /// Description of ReportTableControl. + /// </summary> + + public class ReportRowControl:ReportControlBase{ + ControlHelper controlHelper; + + public ReportRowControl():base(){ + InitializeComponent(); + this.SetStyle(ControlStyles.DoubleBuffer | + ControlStyles.UserPaint | + ControlStyles.AllPaintingInWmPaint | + ControlStyles.ResizeRedraw, + true); + this.UpdateStyles(); + + this.Size = new Size((GlobalValues.PreferedSize.Width * 2) + 10, + GlobalValues.PreferedSize.Height + 10); + + controlHelper = new ControlHelper((Control)this); + } + #region overrides + protected override void OnPaint(System.Windows.Forms.PaintEventArgs e){ + base.OnPaint(e); + TextDrawer tx = new TextDrawer(); + + tx.DrawString(e.Graphics,this.Name, + this.Font, + new SolidBrush(this.ForeColor), + new Rectangle(1,0,e.ClipRectangle.Width,(int)this.Font.GetHeight(e.Graphics) + 2), + new StringFormat()); + } + + public override string ToString() { + return this.Name; + } + + #endregion + + #region Windows Forms Designer generated code + /// <summary> + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// </summary> + private void InitializeComponent() { + // + // ReportRectangleControl + // + this.BackColor = System.Drawing.Color.White; + this.Name = "RowItem"; + this.Size = new System.Drawing.Size(72, 40); + } + #endregion + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs index 12a55c2627..3ef7f7761f 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs @@ -8,29 +8,29 @@ */ using System; -using System.ComponentModel; -using System.Windows.Forms; using System.Drawing; +using System.Windows.Forms; using SharpReportCore; -namespace SharpReport.Designer -{ +namespace SharpReport.Designer{ /// <summary> /// Description of ReportTextItem. /// </summary> internal class ReportTextControl : ReportControlBase{ private TextDrawer textDrawer = new TextDrawer(); + public ReportTextControl(){ InitializeComponent(); - + this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); this.UpdateStyles(); + this.Size = GlobalValues.PreferedSize; } @@ -44,15 +44,22 @@ namespace SharpReport.Designer } - protected override void OnPaint(System.Windows.Forms.PaintEventArgs e){ - base.OnPaint(e); - Graphics g = e.Graphics; + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){ + + base.OnPaint(pea); + Graphics graphics = pea.Graphics; StringFormat fmt = GlobalValues.StandartStringFormat(); fmt.Alignment = this.StringAlignment; + string str; - textDrawer.DrawString(g, - this.Text, + if (String.IsNullOrEmpty(this.Text)) { + str = this.Name; + } else { + str = this.Text; + } + textDrawer.DrawString(graphics, + str, this.Font, new SolidBrush(this.ForeColor), (RectangleF)this.ClientRectangle, @@ -72,7 +79,7 @@ namespace SharpReport.Designer // this.BackColor = System.Drawing.Color.White; this.Name = "ReportTextItem"; - this.Size = new System.Drawing.Size(120, 20); + this.Size = new System.Drawing.Size(120, 60); } #endregion diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs index 386a0530e6..9e7fb1c526 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs @@ -44,7 +44,7 @@ namespace SharpReport.ReportItems.Functions { base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (BasePropertyChange); - ItemsHelper.UpdateTextControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); this.Text = functionName; this.visualControl.FunctionValue = String.Empty; @@ -61,13 +61,13 @@ namespace SharpReport.ReportItems.Functions { private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ if (initDone == true) { - ItemsHelper.UpdateTextBase(this.visualControl,this); + ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); } } private void OnControlChanged (object sender, EventArgs e) { - ItemsHelper.UpdateTextControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); this.HandlePropertyChanged("OnControlChanged"); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs index b7b5a0513d..ab87b7dd0d 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs @@ -48,7 +48,7 @@ namespace SharpReport.ReportItems.Functions { this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (BasePropertyChange); - ItemsHelper.UpdateTextControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); this.Text = functionName; GrapFromBase(); @@ -64,13 +64,13 @@ namespace SharpReport.ReportItems.Functions { #region events private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ if (initDone == true) { - ItemsHelper.UpdateTextBase(this.visualControl,this); + ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); } } private void OnControlChanged (object sender, EventArgs e) { - ItemsHelper.UpdateTextControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); this.HandlePropertyChanged("OnControlChanged"); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportCircleItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportCircleItem.cs index cff1e69848..5c54a81962 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportCircleItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportCircleItem.cs @@ -17,7 +17,7 @@ using SharpReport.Designer; namespace SharpReport.ReportItems{ - public class ReportCircleItem : BaseCircleItem,SharpReport.Designer.IDesignable{ + public class ReportCircleItem : BaseCircleItem,IDesignable{ /// <summary> /// This Class draws a Circle ///All this Graphical Classes derive from <see cref="BaseGraphicItem"></see> @@ -42,7 +42,7 @@ namespace SharpReport.ReportItems{ this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (BasePropertyChange); - ItemsHelper.UpdateGraphicControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.initDone = true; } @@ -50,12 +50,12 @@ namespace SharpReport.ReportItems{ private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ if (initDone == true) { - ItemsHelper.UpdateGraphicBase (this.visualControl,this); + ItemsHelper.UpdateControlFromGraphicBase (this.visualControl,this); } } private void OnControlChanged (object sender, EventArgs e) { - ItemsHelper.UpdateGraphicControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.HandlePropertyChanged("OnControlChanged"); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportImageItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportImageItem.cs index 456ab73b85..6e45fcc239 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportImageItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportImageItem.cs @@ -37,7 +37,7 @@ namespace SharpReport.ReportItems { this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (BasePropertyChange); - ItemsHelper.UpdateGraphicControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.initDone = true; } @@ -71,7 +71,7 @@ namespace SharpReport.ReportItems { } private void OnControlChanged (object sender, EventArgs e) { - ItemsHelper.UpdateGraphicControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.HandlePropertyChanged("OnControlChanged"); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportLineItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportLineItem.cs index a47f10ff12..623562b019 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportLineItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportLineItem.cs @@ -41,7 +41,7 @@ namespace SharpReport.ReportItems{ this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (BasePropertyChange); - ItemsHelper.UpdateGraphicControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.initDone = true; } @@ -49,12 +49,12 @@ namespace SharpReport.ReportItems{ private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ if (initDone == true) { - ItemsHelper.UpdateGraphicBase (this.visualControl,this); + ItemsHelper.UpdateControlFromGraphicBase (this.visualControl,this); } } private void OnControlChanged (object sender, EventArgs e) { - ItemsHelper.UpdateGraphicControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.HandlePropertyChanged("OnControlChanged"); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportRectangleItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportRectangleItem.cs index 25c69eeda6..d767b66d28 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportRectangleItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportRectangleItem.cs @@ -47,7 +47,7 @@ namespace SharpReport.ReportItems{ this.VisualControl.DragEnter += new DragEventHandler (OnDragEnter); base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (BasePropertyChange); - ItemsHelper.UpdateGraphicControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.initDone = true; } @@ -61,12 +61,12 @@ namespace SharpReport.ReportItems{ private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ if (initDone == true) { - ItemsHelper.UpdateGraphicBase (this.visualControl,this); + ItemsHelper.UpdateControlFromGraphicBase (this.visualControl,this); } } private void OnControlChanged (object sender, EventArgs e) { - ItemsHelper.UpdateGraphicControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.HandlePropertyChanged("OnControlChanged"); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs index d3cc23fb5a..2d4f3934c0 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs @@ -23,7 +23,7 @@ namespace SharpReport { public class ItemsHelper : object { - public static void UpdateTextControl (ReportObjectControlBase control, + public static void UpdateBaseFromTextControl (ReportObjectControlBase control, BaseReportItem item) { item.SuspendLayout(); @@ -36,10 +36,10 @@ namespace SharpReport { item.ResumeLayout(); } - public static void UpdateGraphicControl (AbstractGraphicControl control, + public static void UpdateBaseFromGraphicControl (AbstractGraphicControl control, BaseGraphicItem item) { - ItemsHelper.UpdateTextControl (control,item); + ItemsHelper.UpdateBaseFromTextControl (control,item); item.SuspendLayout(); item.Thickness = control.Thickness; item.DashStyle = control.DashStyle; @@ -47,36 +47,33 @@ namespace SharpReport { } - public static void UpdateTextBase (ReportObjectControlBase control, + public static void UpdateControlFromTextBase (ReportObjectControlBase control, BaseReportItem item) { -// control.SuspendLayout(); -// item.SuspendLayout(); + control.SuspendLayout(); + item.SuspendLayout(); control.BackColor = item.BackColor; control.ForeColor = item.ForeColor; control.Location = item.Location; control.Size = item.Size; control.Font = item.Font; + control.Name = item.Name; BaseTextItem b = item as BaseTextItem; if (b != null) { control.StringAlignment = b.StringAlignment; } -// item.ResumeLayout(); -// control.ResumeLayout(); + item.ResumeLayout(); + control.ResumeLayout(); } - public static void UpdateGraphicBase (AbstractGraphicControl control, + public static void UpdateControlFromGraphicBase (AbstractGraphicControl control, BaseGraphicItem item) { - ItemsHelper.UpdateTextBase(control,item); -// control.SuspendLayout(); -// item.SuspendLayout(); + ItemsHelper.UpdateControlFromTextBase(control,item); control.Location = item.Location; control.DashStyle = item.DashStyle; control.Thickness = item.Thickness; -// item.ResumeLayout(); -// control.ResumeLayout(); } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs index 8eca5d249e..bb0d3adc23 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs @@ -1,6 +1,6 @@ /* * Created by SharpDevelop. - * User: Forstmeier Helmut + * User: Forstmeier Peter * Date: 13.11.2004 * Time: 22:48 * @@ -19,29 +19,27 @@ namespace SharpReport.ReportItems{ /// This class reads a Column from a DataSource /// </summary> - public class ReportDataItem : BaseDataItem ,SharpReport.Designer.IDesignable{ + public class ReportDataItem : BaseDataItem ,IDesignable{ + private ReportDbTextControl visualControl; bool initDone; #region Constructors - public ReportDataItem() : base(){ - Setup(); - if (base.ColumnName != null) { - this.visualControl.Text = base.ColumnName; - } else { - visualControl.Text = base.UnboundText; - } + public ReportDataItem() : this(String.Empty){ } - + public ReportDataItem(string columnName):base(columnName){ Setup(); - visualControl.Text = base.ColumnName; } + #endregion + #region SetUp private void Setup(){ visualControl = new ReportDbTextControl(); + + this.visualControl.Text = base.ColumnName; this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); @@ -50,8 +48,8 @@ namespace SharpReport.ReportItems{ this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (BasePropertyChange); - ItemsHelper.UpdateTextControl (this.visualControl,this); - this.Text = visualControl.Name; + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + this.Text = base.ColumnName; GrapFromBase(); this.initDone = true; } @@ -65,12 +63,6 @@ namespace SharpReport.ReportItems{ #endregion #region overrides - public override void Dispose() { - base.Dispose(); - this.visualControl.Dispose(); - } - - public override string ToString(){ return this.Name; } @@ -80,17 +72,17 @@ namespace SharpReport.ReportItems{ #region events's private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ if (initDone == true) { - ItemsHelper.UpdateTextBase(this.visualControl,this); + ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); } } private void OnControlChanged (object sender, EventArgs e) { - ItemsHelper.UpdateTextControl (this.visualControl,this); + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); this.HandlePropertyChanged("OnControlChanged"); } - public void OnControlSelect(object sender, EventArgs e){ + private void OnControlSelect(object sender, EventArgs e){ if (Selected != null) Selected(this,e); } @@ -173,7 +165,7 @@ namespace SharpReport.ReportItems{ #region IDesignable - + [System.Xml.Serialization.XmlIgnoreAttribute] [Browsable(false)] public ReportObjectControlBase VisualControl { @@ -181,9 +173,36 @@ namespace SharpReport.ReportItems{ return visualControl; } } - + public new event PropertyChangedEventHandler PropertyChanged; public event EventHandler <EventArgs> Selected; #endregion + + /* + #region IDisposable + public override void Dispose(){ + this.Dispose(true); + GC.SuppressFinalize(this); + } + + ~ReportDataItem() + { + Dispose(false); + } + + protected override void Dispose(bool disposing){ + try { + if (disposing) { + // Free other state (managed objects). + if (this.visualControl != null) { + this.visualControl.Dispose(); + } + } + } finally { + base.Dispose(); + } + } + #endregion + */ } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportRowItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportRowItem.cs new file mode 100644 index 0000000000..b33e2a3005 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportRowItem.cs @@ -0,0 +1,192 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 01.03.2006 + * Time: 14:35 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.ComponentModel; + +using SharpReport.Designer; +using SharpReportCore; + +namespace SharpReport.ReportItems +{ + + /// <summary> + /// Description of ReportTableItem. + /// </summary> + public class ReportRowItem : RowItem ,IDesignable{ + private ReportRowControl visualControl; + private bool initDone; + + #region Constructor + public ReportRowItem():this (GlobalValues.UnboundName){ + } + + public ReportRowItem (string tableName):base(tableName) { + Setup(); + } + + #endregion + + #region Setup + private void Setup(){ + + visualControl = new ReportRowControl(); + + this.visualControl.Click += new EventHandler(OnControlSelect); + this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); + this.visualControl.FontChanged += new EventHandler (OnControlChanged); + this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); + + this.visualControl.BackColorChanged += new EventHandler (OnAppereanceChanged); + + base.PropertyChanged += new PropertyChangedEventHandler (BasePropertyChange); + + base.Items.Added += OnAdd; + base.Items.Removed += OnRemove; + ItemsHelper.UpdateControlFromTextBase (this.visualControl,this); + this.initDone = true; + } + #endregion + + + #region Events for Childs + private void ChildSelected(object sender, EventArgs e){ + if (Selected != null) + Selected(sender,e); + } + + private void OnChildControlChanged (object sender, EventArgs e) { + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + this.HandlePropertyChanged("OnChildControlChanged"); + } + + private void ChildPropertyChange (object sender, PropertyChangedEventArgs e){ + if (initDone == true) { + ItemsHelper.UpdateControlFromTextBase (this.visualControl,this); + } + } + + #endregion + + private void UpdateChilds () { + foreach (BaseReportItem br in this.Items) { + br.BackColor = this.BackColor; + } + } + + #region EventHandling for this Class + + private void OnAdd (object sender, CollectionItemEventArgs<IItemRenderer> e){ + IDesignable des = e.Item as IDesignable; + if (des != null) { + this.visualControl.Controls.Add (des.VisualControl); + des.Selected += ChildSelected; + des.PropertyChanged += ChildPropertyChange; + } + } + + private void OnRemove (object sender, CollectionItemEventArgs<IItemRenderer> e){ + + IDesignable des = e.Item as IDesignable; + if (des != null) { + this.visualControl.Controls.Remove(des.VisualControl); + des.Selected -= ChildSelected; + this.HandlePropertyChanged("OnChildControlRemoved"); + } + } + + + private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ + if (initDone == true) { + ItemsHelper.UpdateControlFromTextBase (this.visualControl,this); + } + } + + + private void OnControlChanged (object sender, EventArgs e) { + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + this.HandlePropertyChanged("OnControlChanged"); + } + + private void OnAppereanceChanged (object sender, EventArgs e) { + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + UpdateChilds(); + this.HandlePropertyChanged("OnControlChanged"); + } + private void OnControlSelect(object sender, EventArgs e){ + if (Selected != null) + Selected(this,e); + } + + /// <summary> + /// A Property in ReportItem has changed, inform the Designer + /// to set the View's 'IsDirtyFlag' to true + /// </summary> + + protected void HandlePropertyChanged(string info) { + if ( !base.Suspend) { + if (PropertyChanged != null) { + PropertyChanged (this,new PropertyChangedEventArgs(info)); + } + } + + } + #endregion + + #region IDesignable + + [System.Xml.Serialization.XmlIgnoreAttribute] + [Browsable(false)] + public ReportObjectControlBase VisualControl { + get { + return visualControl; + } + } + + public new event PropertyChangedEventHandler PropertyChanged; + public event EventHandler <EventArgs> Selected; + #endregion + + #region overrides + + public override string ToString(){ + return this.Name; + } + + #endregion + + /* + #region IDisposable + public override void Dispose(){ + this.Dispose(true); + GC.SuppressFinalize(this); + } + + ~ReportRowItem() + { + Dispose(false); + } + + protected override void Dispose(bool disposing){ + try { + if (disposing) { + + } + } finally { + if (this.visualControl != null) { + this.visualControl.Dispose(); + this.visualControl = null; + } + base.Dispose(); + } + } + #endregion +*/ + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs index 1e6f26c956..d8c6777819 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs @@ -14,7 +14,6 @@ using System.Drawing.Printing; using SharpReportCore; using SharpReport.Designer; -using SharpReport.ReportItems; namespace SharpReport.ReportItems { /// <summary> @@ -25,7 +24,7 @@ namespace SharpReport.ReportItems { - public class ReportTextItem : BaseTextItem,SharpReport.Designer.IDesignable{ + public class ReportTextItem : BaseTextItem,IDesignable { private ReportTextControl visualControl; @@ -41,27 +40,20 @@ namespace SharpReport.ReportItems { this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); - base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (BasePropertyChange); - ItemsHelper.UpdateTextControl (this.visualControl,this); + base.PropertyChanged += new PropertyChangedEventHandler (BasePropertyChange); +// ItemsHelper.UpdateTextControl (this.visualControl,this); + this.Text = visualControl.Name; - GrapFromBase(); + visualControl.StringFormat = base.StandartStringFormat; + + ItemsHelper.UpdateControlFromTextBase (this.visualControl,this); this.initDone = true; } - private void GrapFromBase() { - this.visualControl.SuspendLayout(); - visualControl.StringFormat = base.StandartStringFormat; - this.visualControl.ResumeLayout(); - } #endregion #region overrides - public override void Dispose() { - base.Dispose(); - this.visualControl.Dispose(); - } - public override string ToString(){ return this.Name; @@ -71,18 +63,21 @@ namespace SharpReport.ReportItems { #region events private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ + System.Console.WriteLine("Text:BasePropertyChanged"); if (initDone == true) { - ItemsHelper.UpdateTextBase(this.visualControl,this); + ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); } } private void OnControlChanged (object sender, EventArgs e) { - ItemsHelper.UpdateTextControl (this.visualControl,this); + System.Console.WriteLine("Text:OnControlChanged"); + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); this.HandlePropertyChanged("OnControlSelected"); } - public void OnControlSelect(object sender, EventArgs e){ + private void OnControlSelect(object sender, EventArgs e){ + System.Console.WriteLine("Text:OnControlSelect"); if (Selected != null) Selected(this,e); } @@ -93,6 +88,7 @@ namespace SharpReport.ReportItems { /// </summary> protected void HandlePropertyChanged(string info) { + System.Console.WriteLine("Text:HandlePropertyChanged"); if ( !base.Suspend) { if (PropertyChanged != null) { PropertyChanged (this,new PropertyChangedEventArgs(info)); @@ -171,5 +167,32 @@ namespace SharpReport.ReportItems { public event EventHandler <EventArgs> Selected; #endregion + + /* + #region IDisposable + public override void Dispose(){ + this.Dispose(true); + GC.SuppressFinalize(this); + } + + ~ReportTextItem() + { + Dispose(false); + } + + protected override void Dispose(bool disposing){ + try { + if (disposing) { + // Free other state (managed objects). + if (this.visualControl != null) { + this.visualControl.Dispose(); + } + } + } finally { + base.Dispose(); + } + } + #endregion + */ } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/SharpReport.csproj b/src/AddIns/Misc/SharpReport/SharpReport/SharpReport.csproj index aade2fb0a6..03c4d31708 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/SharpReport.csproj +++ b/src/AddIns/Misc/SharpReport/SharpReport/SharpReport.csproj @@ -84,6 +84,9 @@ <Compile Include="Configuration\AssemblyInfo.cs" /> <Compile Include="Designer\SectionControls\ReportSection.cs" /> <Compile Include="Designer\SideTab\BuildSideTab.cs" /> + <Compile Include="Designer\VisualControls\ReportRowControl.cs" /> + <Compile Include="ReportItems\TextBased\ReportRowItem.cs" /> + <Compile Include="Designer\VisualControls\ControlHelper.cs" /> </ItemGroup> <ItemGroup> <Folder Include="Designer" /> diff --git a/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs b/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs index 1bdb6b0d48..4d75a53730 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs @@ -111,40 +111,11 @@ namespace SharpReport{ } - private void AddItemsToSection (BaseSection section,ReportItemCollection collection) { - - if ((section == null)|| (collection == null) ) { - throw new ArgumentNullException ("section"); - } - if (collection == null) { - throw new ArgumentNullException("collection"); - } - // if there are already items in the section, - // the we have to append the Items, means whe have to enlarge the section - if (section.Items.Count > 0) { - section.Size = new Size (section.Size.Width, - section.Size.Height + GlobalValues.DefaultSectionHeight); - - // Adjust the Location - foreach (IItemRenderer i in collection) { - i.Location = new Point (i.Location.X,GlobalValues.DefaultSectionHeight); - } - } - - for (int i = 0;i < collection.Count ;i ++ ) { - BaseReportItem r = (BaseReportItem)collection[i]; - r.Parent = section.Name; - section.Items.Add (r); - } - } - - private Font CopyFont (Font orgF) { - Font f = new Font(orgF.Name,orgF.Size,orgF.Style,orgF.Unit); - return f; - } #endregion + + #region Standarts for all reports (Headlines etc) /// <summary> @@ -163,6 +134,7 @@ namespace SharpReport{ item.Font = CopyFont(model.ReportSettings.DefaultFont); item.Location = new Point (0,0); item.Size = new Size (item.Size.Width,item.Font.Height + SharpReportCore.GlobalValues.EnlargeControl); + item.Parent = section; section.Items.Add (item); item.ResumeLayout(); section.ResumeLayout(); @@ -182,119 +154,20 @@ namespace SharpReport{ pageNumber.Text = ResourceService.GetString("SharpReport.Toolbar.Functions.PageNumber"); pageNumber.Location = new Point (0,0); + pageNumber.Parent = section; section.Items.Add(pageNumber); pageNumber.ResumeLayout(); section.ResumeLayout(); - } - + } #endregion - #region HeaderColumns - /* - /// <summary> - /// Builds ColumHeaders for Reports, we take the ColumnNames as Text Property - /// </summary> - /// <param name="model">A valid(filled) reportModel</param> - /// <param name="section">The Section to use for headerLines</param> - /// <param name="schemaTable">SchemaTable witch contains the Column Informations</param> - - public void HeaderColumnsFromTable (BaseSection section,DataTable schemaTable) { - if (section == null) { - throw new ArgumentException("SharpReportManager:CreateColumnHeadersFromTable <section>"); - } - using (AutoReport auto = new AutoReport()){ - try { - ReportItemCollection headerCol = auto.AutoHeaderFromTable (section,schemaTable,false); - AddItemsToSection (section,headerCol); - } catch (Exception) { - throw; - } - } - } - */ - ///<summary> - /// Create ColumHeaders for Reports - /// </summary> - /// <param name="section">A ReportSection whre to build the Hedarlines</param> - ///<param name="collection">A <see cref="ReportitemCollection"></see> - /// containing the basic informations</param> - - public void HeaderColumnsFromReportItems (BaseSection section,ReportItemCollection collection) { - using (AutoReport auto = new AutoReport()){ - try { - ReportItemCollection colDetail = auto.AutoHeaderFromReportItems (collection,section,false); - section.SuspendLayout(); - AddItemsToSection (section,colDetail); - section.ResumeLayout(); - } catch(Exception) { - throw; - } - } - } - #endregion - - - #region Create report from Query - - /* - /// <summary> - /// Create Columns from SchemaTable - /// </summary> - ///<param name="model">a valid reportModel</param> - ///<param name="schemaTable">DataTable witch contaisn SchemaDefinitions</param> - /// - - public void DataColumnsFromTable (ReportModel model,DataTable schemaTable) { - if ((model == null)||(schemaTable.Rows.Count == 0) ) { - throw new ArgumentException ("Invalid Arguments in SharpReportmanager:CreateColumnsFromFile"); - } - - using (AutoReport auto = new AutoReport()){ - try { - ReportItemCollection colDetail = auto.ReportItemsFromTable (model, - schemaTable); - BaseSection section = model.DetailSection; - section.SuspendLayout(); - AddItemsToSection (section,colDetail); - section.ResumeLayout(); - } catch (Exception) { - throw; - } - } - } - */ - #endregion - - #region Create Reports from .Xsd Files - - - ///<summary> - /// Create the DataColumns - /// </summary> - /// <param name="section">A ReportSection where to build the - /// <see cref="ReportDataItem"></see> - /// DataItems</param> - ///<param name="collection">A reportItemcollection containing the basic informations</param> - public void DataColumnsFromReportItems (BaseSection section,ReportItemCollection collection) { - using (AutoReport auto = new AutoReport()){ - try { - ReportItemCollection colDetail = auto.AutoDataColumns (collection); - section.SuspendLayout(); - AddItemsToSection (section,colDetail); - section.ResumeLayout(); - }catch (Exception) { - throw; - } - } + private Font CopyFont (Font orgF) { + Font f = new Font(orgF.Name,orgF.Size,orgF.Style,orgF.Unit); + return f; } - #endregion - - - #region Preview - public AbstractRenderer GetRendererForStandartReports (ReportModel model) { if (model == null) { throw new ArgumentNullException("model"); diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Visitors/AbstractVisitor.cs b/src/AddIns/Misc/SharpReport/SharpReport/Visitors/AbstractVisitor.cs index fd6411c8fe..1275f0893b 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Visitors/AbstractVisitor.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Visitors/AbstractVisitor.cs @@ -7,29 +7,38 @@ // the code is regenerated. // </autogenerated> //------------------------------------------------------------------------------ - +using System; +using System.Xml; + +using SharpReport.Designer; + +using SharpReportCore; namespace SharpReport.Visitors { - using System; - using System.Xml; - using SharpReport.Designer; /// <summary> - /// Abstracte klasse fr alle Visitor's + /// Abstract Class for Designer Visitor /// </summary> /// <remarks> /// created by - Forstmeier Peter /// created on - 02.12.2004 16:53:00 /// </remarks> public class AbstractVisitor : object, SharpReport.Designer.IDesignerVisitor { + private readonly string nodesQuery = "controls/control"; + private string fileName; + private XmlFormReader xmlFormReader; - /// <summary> - /// Default constructor - initializes all fields to default values - /// </summary> public AbstractVisitor() { } + public AbstractVisitor(string fileName){ + this.fileName = fileName; + xmlFormReader = new XmlFormReader() ; + } + + + /// <summary> /// All classes how use this baseclass have to override this method /// </summary> @@ -40,7 +49,29 @@ namespace SharpReport.Visitors public virtual void Visit(SharpReport.Designer.BaseDesignerControl designer) { } - } - + + + #region Properties + protected string FileName { + get { + return fileName; + } + } + + protected XmlFormReader XmlFormReader { + get { + return xmlFormReader; + } + } + + protected string NodesQuery { + get { + return nodesQuery; + } + } + + #endregion + + } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Visitors/LoadReportVisitor.cs b/src/AddIns/Misc/SharpReport/SharpReport/Visitors/LoadReportVisitor.cs index 24e99e119b..d43c4500fc 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Visitors/LoadReportVisitor.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Visitors/LoadReportVisitor.cs @@ -30,14 +30,10 @@ using SharpReport.ReportItems; namespace SharpReport.Visitors { public class LoadReportVisitor : SharpReport.Visitors.AbstractVisitor { - private string fileName; - SharpReport.Designer.BaseDesignerControl designer; - SharpReportCore.XmlFormReader xmlFormReader; - IDesignableFactory designableFactory = new IDesignableFactory(); + IDesignableFactory designableFactory ; - public LoadReportVisitor(string filename) { - this.fileName = filename; + public LoadReportVisitor(string fileName):base(fileName) { designableFactory = new IDesignableFactory(); } @@ -47,21 +43,20 @@ namespace SharpReport.Visitors { /// <param name='designer'>SharpReportDesigner</param> public override void Visit(SharpReport.Designer.BaseDesignerControl designer){ - if (designer != null) { - XmlDocument xmlDoc; - try { - xmlDoc = XmlHelper.OpenSharpReport (fileName); - this.designer = designer; - xmlFormReader = new XmlFormReader(); - SetDesigner (xmlDoc); - AdjustSectionsWidth(); - } catch (Exception ) { - throw ; - } - } else { - System.ArgumentNullException e = new System.ArgumentNullException ("LoadReportVisitor:Visit -> No valid designer"); - throw e; + if (designer == null) { + throw new ArgumentNullException("designer"); + } + + XmlDocument xmlDoc; + try { + xmlDoc = XmlHelper.OpenSharpReport (base.FileName); + this.designer = designer; + SetDesigner (xmlDoc); + AdjustSectionsWidth(); + } catch (Exception ) { + throw ; } + } private void AdjustSectionsWidth() { @@ -73,11 +68,6 @@ namespace SharpReport.Visitors { } } - private XmlDocument LoadFromFile (string fileName) { - XmlDocument xmlDoc = new XmlDocument(); - xmlDoc.Load (fileName); - return xmlDoc; - } private void SetDesigner (XmlDocument doc){ @@ -88,51 +78,75 @@ namespace SharpReport.Visitors { private void SetSections (XmlDocument doc) { + XmlNodeList sectionNodes = doc.DocumentElement.ChildNodes; //Start with node(1) XmlNode node; BaseSection baseSection = null; for (int i = 1;i < sectionNodes.Count ; i++ ) { node = sectionNodes[i]; - - if (node is XmlElement) { - XmlElement sectionElem = (XmlElement)node; + XmlElement sectionElem = node as XmlElement; + if (sectionElem != null) { baseSection = (BaseSection)designer.ReportModel.SectionCollection.Find(sectionElem.GetAttribute("name")); if (baseSection != null) { baseSection.SuspendLayout(); - XmlHelper.SetSectionValues (xmlFormReader,sectionElem,baseSection); - XmlNodeList ctrlList = sectionElem.SelectNodes ("controls/control"); - if (ctrlList.Count > 0) { - foreach (XmlNode ctrlNode in ctrlList) { - if (ctrlNode is XmlElement) { - XmlElement ctrlElem = (XmlElement)ctrlNode; - IItemRenderer rpt = null; - try { - rpt = designableFactory.Create(ctrlElem.GetAttribute("type")); - BaseReportItem br = (BaseReportItem)rpt; - br.Parent = baseSection; - baseSection.Items.Add (rpt); - XmlHelper.BuildControl (xmlFormReader,ctrlElem,br); - } - catch (Exception ) { - string s = String.Format ("Unable to create <{0}>",ctrlElem.GetAttribute("type").ToString()); - throw new SharpReportException (s); - } - } - } - } + XmlHelper.SetSectionValues (base.XmlFormReader,sectionElem,baseSection); + XmlNodeList ctrlList = sectionElem.SelectNodes (base.NodesQuery); + SetReportItems(baseSection,null,ctrlList); baseSection.ResumeLayout(); } else { - SharpReportException ex = new SharpReportException ("Wrong Section Name <" + sectionElem.GetAttribute("name") + ">"); - throw ex; + throw new MissingSectionException(); } - }else { - throw new System.Xml.XmlException ("Report : SetSection Wrong Node in Report"); + } else { + throw new MissingSectionException(); } baseSection.ResumeLayout(); } baseSection.ResumeLayout(); } + + + void SetReportItems(BaseSection baseSection, + IContainerItem parentContainer,XmlNodeList ctrlList) { + + BaseReportItem baseReportItem; + //BaseReportItem parentItem; + foreach (XmlNode ctrlNode in ctrlList) { + XmlElement ctrlElem = ctrlNode as XmlElement; + if (ctrlElem != null) { + IItemRenderer itemRenderer = null; + try { + itemRenderer = designableFactory.Create(ctrlElem.GetAttribute("type")); + + baseReportItem = (BaseReportItem)itemRenderer; + if (parentContainer == null) { +// System.Console.WriteLine("\tParent of {0} is Section",baseReportItem.Name); + baseReportItem.Parent = baseSection; + baseSection.Items.Add (baseReportItem); + } else { +// System.Console.WriteLine("\tParent of <{0}> is Container",baseReportItem.Name); + baseReportItem.Parent = parentContainer; + parentContainer.Items.Add(baseReportItem); + + } + + XmlHelper.BuildControl (base.XmlFormReader,ctrlElem,baseReportItem); + + IContainerItem iContainer = baseReportItem as IContainerItem; + + XmlNodeList newList = ctrlNode.SelectNodes (base.NodesQuery); + if (newList.Count > 0) { +// System.Console.WriteLine("\t recusiv call for <{0}> with {1} childs ", +// baseReportItem,newList.Count); + SetReportItems (baseSection,iContainer,newList); + } + } + catch (Exception ) { + throw new UnkownItemException(); + } + } + } + } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Visitors/SaveReportVisitor.cs b/src/AddIns/Misc/SharpReport/SharpReport/Visitors/SaveReportVisitor.cs index 110bd06417..fc964f4ee8 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Visitors/SaveReportVisitor.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Visitors/SaveReportVisitor.cs @@ -25,7 +25,7 @@ namespace SharpReport.Visitors{ private XmlDocument xmlDoc; - public SaveReportVisitor () { + public SaveReportVisitor ():base() { } diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ItemContextCommands.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ItemContextCommands.cs index 750d435fa1..75f06ebb52 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ItemContextCommands.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ItemContextCommands.cs @@ -44,17 +44,7 @@ namespace SharpReportAddin.Commands { /// public override void Run(){ if (this.IsEnabled){ - try { - IItemRenderer iItemRenderer = base.View.DesignerControl.SelectedObject as IItemRenderer; - if (iItemRenderer != null) { - if (base.View.DesignerControl.SelectedSection.Items.Contains(iItemRenderer)) { - base.View.DesignerControl.SelectedSection.Items.Remove (iItemRenderer); - base.View.IsDirty = true; - } - } - } catch (Exception ) { - throw; - } + base.View.DesignerControl.RemoveSelectedItem (); } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs index 261ac13aa9..673138d4ac 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs @@ -49,7 +49,7 @@ namespace SharpReportAddin { /// Clear the selected Section /// </summary> public void ClearNodeSection () { - System.Console.WriteLine("ClearNodeSection"); +// System.Console.WriteLine("ClearNodeSection"); if (this.SelectedNode is SectionTreeNode) { if (this.SelectedNode.Nodes.Count > 0) { this.SelectedNode.Nodes.Clear(); @@ -221,8 +221,45 @@ namespace SharpReportAddin { } #region PadEvents - private void OnWindowChange (object sender,EventArgs e) { + try { + if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent is SharpReportView) { + if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null || WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent == null) { + return; + } + WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving -= OnViewSaving; + WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving += OnViewSaving; + + PadDescriptor pad = WorkbenchSingleton.Workbench.GetPad(typeof(FieldsExplorer)); + + SharpReportView v = + WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent + as SharpReportView; + + if (v != null) { + this.reportModel = v.ReportManager.BaseDesignControl.ReportModel; + if (this.reportModel != null) { + this.Fill(); + WorkbenchSingleton.Workbench.ShowPad(pad); + } + + } else { + WorkbenchSingleton.Workbench.WorkbenchLayout.HidePad(pad); + } + + } else { + System.Console.WriteLine(" NO view"); } + } catch (Exception) { + + } + } + + private void old_OnWindowChange (object sender,EventArgs e) { +// System.Console.WriteLine("FieldsExplorer:OnWindowChange"); +// System.Console.WriteLine("active control {0}",WorkbenchSingleton.ActiveControl.ToString()); +// ICSharpCode.SharpDevelop.Gui.DefaultWorkbench dw = (ICSharpCode.SharpDevelop.Gui.DefaultWorkbench)sender; + + try { if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null || WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent == null) { return; @@ -235,10 +272,11 @@ namespace SharpReportAddin { SharpReportView v = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as SharpReportView; - + if (v != null) { this.reportModel = v.ReportManager.BaseDesignControl.ReportModel; if (this.reportModel != null) { + this.Fill(); WorkbenchSingleton.Workbench.ShowPad(pad); pad.BringPadToFront(); @@ -522,6 +560,10 @@ namespace SharpReportAddin { } } + public void RedrawContent() { + + } + public string[] Shortcut { get { return null; @@ -537,10 +579,6 @@ namespace SharpReportAddin { } - public void RedrawContent() { - this.Invalidate (); - } - // ********* Own events protected virtual void OnTitleChanged(EventArgs e) { @@ -565,7 +603,7 @@ namespace SharpReportAddin { public FieldsExplorer() { WorkbenchSingleton.Workbench.ActiveWorkbenchWindowChanged += OnWindowChange; - + LabelEdit = true; AllowDrop = true; HideSelection = false; diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs index 29bb7e0f9b..1246977a35 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs @@ -39,7 +39,8 @@ namespace SharpReportAddin { if (view != null) { try { ReportGenerator.CreateReport cmd = new ReportGenerator.CreateReport(view.DesignerControl.ReportModel); - cmd.Run(); + cmd.Run(); + cmd = null; view.FileName = view.DesignerControl.ReportModel.ReportSettings.FileName; view.UpdateView(true); view.Selected(); diff --git a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs index 24b46d552d..16f82dffc2 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs @@ -55,17 +55,16 @@ namespace SharpReportAddin{ panel.AutoScroll = true; CreateTabControl(); BuildToolBarItems(); - if (PropertyPad.Grid != null) { PropertyPad.Grid.SelectedObject = designerControl.ReportModel.ReportSettings; PropertyPad.Grid.Refresh(); } - + //Activate the FieldsExplorer - Pad PadDescriptor pad = WorkbenchSingleton.Workbench.GetPad(typeof(FieldsExplorer)); if (pad != null) { pad.CreatePad(); - } + } } catch (Exception) { throw; } @@ -192,6 +191,7 @@ namespace SharpReportAddin{ private BaseDesignerControl CreateDesignerControl() { BaseDesignerControl ctrl = reportManager.BaseDesignControl; + ctrl.ReportControl.Width = ctrl.ReportModel.ReportSettings.PageSettings.Bounds.Width; ctrl.ReportControl.AutoScroll = true; ctrl.Dock = DockStyle.Fill; @@ -453,6 +453,7 @@ namespace SharpReportAddin{ } public override void RedrawContent() { +// this.WorkbenchWindow.WindowDeselected += new EventHandler(OnDeselected); SetHeadLines(); } @@ -490,6 +491,7 @@ namespace SharpReportAddin{ public SharpReportView():base() { if (GlobalValues.IsValidPrinter()) { InitView(); + this.UpdateView(false); } else { MessageService.ShowError(ResourceService.GetString("Sharpreport.Error.NoPrinter")); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs index 48d6901b85..f4ea37d402 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs @@ -27,12 +27,11 @@ using SharpReportCore; namespace SharpReportCore { public class BaseDataItem : SharpReportCore.BaseTextItem,IItemRenderer { - - private const string unbound = "(unbound)"; - private string columnName = String.Empty; - private string baseTableName = String.Empty; - private string dbValue = String.Empty; - private string dataType = String.Empty; + private string columnName; + private string baseTableName; + private string dbValue; + private string dataType; + private string nullValue; /// <summary> /// Default constructor - initializes all fields to default values /// </summary> @@ -42,10 +41,30 @@ namespace SharpReportCore { public BaseDataItem(string columnName){ this.columnName = columnName; } + #region privates + //TODO Need a much better handling for 'null' values + + private string CheckForNullValue() { + if (String.IsNullOrEmpty(this.dbValue)) { + if (String.IsNullOrEmpty(this.nullValue)) { + return GlobalValues.UnboundName; + + } else + return this.nullValue; + } + return this.dbValue; + } + + #endregion + public override void Render(SharpReportCore.ReportPageEventArgs rpea) { + // this.DbValue is formatted in the BeforePrintEvent catched in AbstractRenderer - string formattedString = base.FireFormatOutput(this.dbValue,this.FormatString,""); + + string toPrint = CheckForNullValue(); + string formattedString = base.FireFormatOutput(toPrint,this.FormatString,""); +// System.Console.WriteLine("\t\tBaseDataItem:Render {0} ",formattedString); RectangleF rect = base.PrepareRectangle (rpea,formattedString); base.PrintTheStuff (rpea,formattedString,rect); base.NotiyfyAfterPrint (rpea.LocationAfterDraw); @@ -72,10 +91,14 @@ namespace SharpReportCore { public virtual string ColumnName { get { + if (String.IsNullOrEmpty(columnName)) { + this.columnName = GlobalValues.UnboundName; + } return columnName; } set { columnName = value; + this.Text = this.columnName; } } @@ -118,11 +141,15 @@ namespace SharpReportCore { baseTableName = value; } } - [XmlIgnoreAttribute] - [Browsable(false)] - public string UnboundText { + [Browsable(true), + Category("Databinding"), + Description("Display Value for empty Field")] + public string NullValue { get { - return unbound; + return nullValue; + } + set { + nullValue = value; } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs index 74aaafb188..d97ef1c282 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs @@ -21,16 +21,14 @@ namespace SharpReportCore { /// </summary> public class BaseReportItem : SharpReportCore.BaseReportObject, - IItemRenderer,IComponent{ + IItemRenderer{ - private int offset; - private int margin; + private int xOffset; private bool drawBorder; private Color foreColor; private Font font; - private ISite site; - + public event EventHandler <FormatOutputEventArgs> FormatOutput; public event EventHandler Disposed; @@ -62,10 +60,8 @@ namespace SharpReportCore { #region virtual method's protected RectangleF DrawingRectangle (ReportPageEventArgs e,SizeF measureSize) { - PointF upperLeft = new PointF (this.Location.X + this.Margin, - this.Location.Y + this.Offset); - - + PointF upperLeft = new PointF (this.Location.X , + this.Location.Y + this.SectionOffset); SizeF lowerRight = new SizeF(0,0); if ((this.CanGrow == true )||(this.CanShrink == true)){ @@ -83,43 +79,16 @@ namespace SharpReportCore { #endregion - - - #region System.ComponentModel.IComponent interface implementation - public System.ComponentModel.ISite Site { - get { - return site; - } - set { - site = value; - } - } - - - #endregion - - - #region Properties [XmlIgnoreAttribute] - public int Margin { - get { - return margin; - } - set { - margin = value; - } - } - - - [XmlIgnoreAttribute] - public int Offset { + [Browsable(false)] + public int XOffset { get { - return offset; + return xOffset; } set { - offset = value; + xOffset = value; } } @@ -142,7 +111,6 @@ namespace SharpReportCore { } set { foreColor = value; -// base.NotifyPropertyChanged ("ForeColor",true); base.NotifyPropertyChanged ("ForeColor"); } } @@ -154,7 +122,6 @@ namespace SharpReportCore { } set { this.font = value; -// NotifyPropertyChanged ("Font",true); NotifyPropertyChanged ("Font"); } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs index 11bc7995f0..db0b9d59cd 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs @@ -16,8 +16,8 @@ using System.ComponentModel; using System.Drawing; /// <summary> -/// This is the BaseClass for <see cref="ReportSection"></see> -/// and <see cref="ReportItem"></see> +/// This is the BaseClass for all +/// <see cref="ReportItem"></see> /// </summary> /// <remarks> /// created by - Forstmeier Peter @@ -41,7 +41,6 @@ namespace SharpReportCore { private Color backColor; private int sectionOffset; - private int sectionMargin; public event EventHandler<EventArgs> BeforePrinting; public event EventHandler<AfterPrintEventArgs> AfterPrinting; @@ -70,12 +69,15 @@ namespace SharpReportCore { public void ResumeLayout () { suspend = false; } + + #region properties public virtual bool Visible { get { return visible; } set { visible = value; + NotifyPropertyChanged ("Visible"); } } @@ -85,6 +87,7 @@ namespace SharpReportCore { } set { canGrow = value; + NotifyPropertyChanged ("CanGrow"); } } public virtual bool CanShrink { @@ -93,16 +96,11 @@ namespace SharpReportCore { } set { canShrink = value; + NotifyPropertyChanged ("CanShrink"); } } - [XmlIgnoreAttribute] - [Browsable(false)] - public bool Suspend { - get { - return suspend; - } - } + public virtual string Name { get { @@ -110,6 +108,7 @@ namespace SharpReportCore { } set { name = value; + NotifyPropertyChanged ("Name"); } } @@ -119,79 +118,85 @@ namespace SharpReportCore { } set { pageBreakAfter = value; + NotifyPropertyChanged ("PageBreakAfter"); } } + + public virtual bool PageBreakBefore { get { return pageBreakBefore; } set { pageBreakBefore = value; + NotifyPropertyChanged ("PageBreakBefore"); } } - [Browsable(false)] - [XmlIgnoreAttribute] - public virtual object Parent { + + + + public virtual Size Size { get { - return parent; + return size; } set { - parent = value; + size = value; + NotifyPropertyChanged ("Size"); } } - [XmlIgnoreAttribute] - [Browsable(false)] - public virtual int SectionMargin { + public virtual Point Location { get { - return sectionMargin; + return location; } set { - sectionMargin = value; + location = value; + NotifyPropertyChanged ("Location"); } } - [XmlIgnoreAttribute] - [Browsable(false)] - public virtual int SectionOffset { + public virtual Color BackColor { get { - return sectionOffset; + return backColor; } set { - sectionOffset = value; + backColor = value; + NotifyPropertyChanged ("BackColor"); } } - public virtual Size Size { + [XmlIgnoreAttribute] + [Browsable(false)] + public virtual int SectionOffset { get { - return size; + return sectionOffset; } set { - size = value; - NotifyPropertyChanged ("Size"); + sectionOffset = value; } } - public virtual Point Location { + [Browsable(false)] + [XmlIgnoreAttribute] + public virtual object Parent { get { - return location; + return parent; } set { - location = value; - NotifyPropertyChanged ("Location"); + parent = value; } } - public virtual Color BackColor { + [XmlIgnoreAttribute] + [Browsable(false)] + public bool Suspend { get { - return backColor; - } - set { - backColor = value; - NotifyPropertyChanged ("BackColor"); + return suspend; } } + #endregion + #region EventHandling public void NotiyfyAfterPrint (PointF afterPrintLocation) { if (this.AfterPrinting != null) { AfterPrintEventArgs rea = new AfterPrintEventArgs (afterPrintLocation); @@ -205,7 +210,7 @@ namespace SharpReportCore { } } - + #endregion #region SharpReportCore.IBaseRenderer interface implementation public virtual void Render(ReportPageEventArgs rpea) { diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs index d453321857..950b6b90eb 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs @@ -9,16 +9,19 @@ //------------------------------------------------------------------------------ using System; using System.ComponentModel; +//using System.Windows.Forms; +using System.Xml.Serialization; + /// <summary> -/// This Class is the BaseClass for all ReportSections +/// This Class is the BaseClass for <see cref="ReportSection"></see> /// </summary> -/// <remarks> -/// created by - Forstmeier Helmut -/// created on - 01.09.2005 13:12:32 -/// </remarks> + + namespace SharpReportCore { public class BaseSection : SharpReportCore.BaseReportObject { + private int sectionMargin; + private ReportItemCollection items; #region Constructors @@ -28,11 +31,37 @@ namespace SharpReportCore { public BaseSection (string sectionName) :base(){ this.Name = sectionName; - } #endregion + + + #region properties + + + public int SectionMargin { + get { + return this.sectionMargin; + } + set { + this.sectionMargin = value; + } + } + + + + [Browsable(false)] + public ReportItemCollection Items{ + get { + if (this.items == null) { + items = new ReportItemCollection(); + } + return items; + } + } + #endregion + #region System.IDisposable interface implementation public override void Dispose () { Dispose(true); @@ -57,19 +86,5 @@ namespace SharpReportCore { } #endregion - - #region properties - - [Browsable(false)] - public ReportItemCollection Items{ - get { - if (this.items == null) { - items = new ReportItemCollection(); - } - return items; - } - } - #endregion - } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs index a70e79eaa5..a00e0d6b93 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs @@ -27,6 +27,7 @@ namespace SharpReportCore { private StringAlignment stringAlignment = StringAlignment.Near; private StringFormat standartStringFormat; private TextDrawer textDrawer = new TextDrawer(); + public BaseTextItem() { this.standartStringFormat = GlobalValues.StandartStringFormat(); @@ -34,7 +35,7 @@ namespace SharpReportCore { public override void Render(ReportPageEventArgs rpea) { if (rpea == null) { - throw new ArgumentNullException("rpea","BasetextItem:Render"); + throw new ArgumentNullException("rpea"); } base.Render(rpea); RectangleF rect = PrepareRectangle (rpea,this.Text); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs index 6f132c7a67..36cb6ca0d5 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs @@ -23,7 +23,7 @@ using System.Drawing; /// created on - 29.09.2005 11:57:30 /// </remarks> namespace SharpReportCore { - public class BaseRectangleItem : SharpReportCore.BaseGraphicItem,IContainer { + public class BaseRectangleItem : SharpReportCore.BaseGraphicItem { private ArrayList arrayList; RectangleShape shape = new RectangleShape(); @@ -51,30 +51,6 @@ namespace SharpReportCore { } - - #region System.ComponentModel.IContainer interface implementation - public System.ComponentModel.ComponentCollection Components { - get { - IComponent[] datalist = new BaseReportItem[arrayList.Count]; - arrayList.CopyTo(datalist,0); - return new ComponentCollection(datalist); - } - } - - public void Remove(System.ComponentModel.IComponent component) { - throw new NotImplementedException(); - } - - public void Add(System.ComponentModel.IComponent component, string name) { - throw new NotImplementedException(); - } - - public void Add(System.ComponentModel.IComponent component) { - throw new NotImplementedException(); - } - #endregion - - #region System.IDisposable interface implementation // public override void Dispose() { // base.Dispose(); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs new file mode 100644 index 0000000000..a5043507bc --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs @@ -0,0 +1,170 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Peter + * Date: 03.03.2006 + * Time: 09:00 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.ComponentModel; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace SharpReportCore{ + /// <summary> + /// Description of BaseRowItem. + /// </summary> + + public class RowItem:BaseReportItem,IContainerItem{ + private string tableName; + + ReportItemCollection items; + Padding padding; + + public RowItem():this (String.Empty){ + } + + + public RowItem(string tableName){ + this.tableName = tableName; + this.Items.Added += OnAdded; + } + + void OnAdded (object sender, CollectionItemEventArgs<IItemRenderer> e){ + + System.Console.WriteLine(""); + System.Console.WriteLine("RowItem:OnAdded"); + } + + #region overrides + private void Decorate (ReportPageEventArgs rpea,Rectangle border) { + using (SolidBrush brush = new SolidBrush(base.BackColor)) { + rpea.PrintPageEventArgs.Graphics.FillRectangle(brush,border); + } + if (base.DrawBorder == true) { + using (Pen pen = new Pen(Color.Black, 1)) { + rpea.PrintPageEventArgs.Graphics.DrawRectangle (pen,border); + } + } + } + + protected RectangleF PrepareRectangle (ReportPageEventArgs e) { + SizeF measureSize = new SizeF ((SizeF)this.Size); + RectangleF rect = base.DrawingRectangle (e,measureSize); + return rect; + } + + + public override void Render(ReportPageEventArgs rpea){ + System.Console.WriteLine("Render RowItem"); + if (rpea == null) { + throw new ArgumentNullException("rpea"); + } + + base.Render(rpea); + RectangleF rect = PrepareRectangle (rpea); + + Decorate (rpea,System.Drawing.Rectangle.Ceiling (rect)); + + foreach (BaseReportItem childItem in this.items) { + Point loc = new Point (childItem.Location.X,childItem.Location.Y); + + childItem.Location = new Point(this.Location.X + childItem.Location.X, + this.SectionOffset + this.Location.Y); + + + + childItem.Render (rpea); + childItem.Location = new Point(loc.X,loc.Y); + } + + base.NotiyfyAfterPrint (rpea.LocationAfterDraw); + } + + public override string ToString(){ + return "RowItem"; + } + + #endregion + + + #region properties + + public string TableName { + get { + + return tableName; + } + set { + tableName = value; + } + } + + + + + #endregion + + #region IContainerControl + + public Padding Padding { + get { + return padding; + } + set { + padding = value; + } + } + + public bool IsValidChild(BaseReportItem childControl){ +// BaseDataItem bdi = childControl as BaseDataItem; + BaseReportItem bdi = childControl as BaseDataItem; + if (bdi != null) { + return true; + } else { + return false; + } + } + + public ReportItemCollection Items{ + get { + if (this.items == null) { + this.items = new ReportItemCollection(); + } + return this.items; + } + } + #endregion + /* + #region IDisposable + public override void Dispose(){ + this.Dispose(true); + GC.SuppressFinalize(this); + } + + ~RowItem() + { + Dispose(false); + } + + protected override void Dispose(bool disposing){ + try { + if (disposing) { + // Free other state (managed objects). + if (this.baseDataItemCollection != null) { + this.BaseDataItemCollection.Clear(); + this.baseDataItemCollection = null; + } + } + } finally { + base.Dispose(); + } + } + #endregion + */ + + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseSettings.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseSettings.cs index a047f14c97..9c2dfe7fb2 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseSettings.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseSettings.cs @@ -19,10 +19,11 @@ // // Peter Forstmeier (Peter.Forstmeier@t-online.de) using System; -using System.ComponentModel; using System.Drawing; using System.Drawing.Printing; -using System.IO; +using System.ComponentModel; +using System.Windows.Forms; + using System.Xml.Serialization; /// <summary> @@ -42,20 +43,21 @@ namespace SharpReportCore { private PageSettings pageSettings; private bool useStandartPrinter; - private bool includeSettings; - + //if file is read, supress events private bool initDone; private GraphicsUnit graphicsUnit; private Margins defaultMargins = new Margins (50,50,50,50); - + private Size gridSize; + private Padding padding; public event EventHandler PropertyChanged; public event EventHandler FileNameChanged; #region Constructor public BaseSettings():this(new PageSettings(),"","") { BaseValues(); + this.initDone = true; } public BaseSettings(PageSettings pageSettings , string reportName,string fileName){ @@ -83,8 +85,9 @@ namespace SharpReportCore { } void BaseValues() { this.useStandartPrinter = true; - this.includeSettings = false; this.graphicsUnit = GraphicsUnit.Millimeter; + this.gridSize = GlobalValues.GridSize; + this.padding = new Padding(5); } private static string MakePoperFilename (string file) { @@ -104,10 +107,8 @@ namespace SharpReportCore { #endregion protected void NotifyPropertyChanged() { - if (this.initDone) { - if (PropertyChanged != null) { - PropertyChanged (this,new EventArgs()); - } + if (PropertyChanged != null) { + PropertyChanged (this,new EventArgs()); } } @@ -134,23 +135,6 @@ namespace SharpReportCore { } } - ///<summary> - /// printout ReportSettings at ReportHeaderPage - /// </summary> - [Category("Base Settings")] - [DefaultValueAttribute (false)] - public bool IncludeSettings { - get { - return includeSettings; - } - set { - if (includeSettings != value) { - includeSettings = value; - this.NotifyPropertyChanged(); - } - } - } - [Category("Base Settings")] [DefaultValueAttribute ("")] public string ReportName { @@ -231,6 +215,10 @@ namespace SharpReportCore { } } + + #endregion + + #region DesignerSettings [Category("Designer Settings")] [DefaultValueAttribute (System.Drawing.GraphicsUnit.Millimeter)] public System.Drawing.GraphicsUnit GraphicsUnit { @@ -244,6 +232,34 @@ namespace SharpReportCore { } } } + [Category("Designer Settings")] + public Size GridSize { + get { + return gridSize; + } + set { + if (this.gridSize != value) { + this.gridSize = value; + this.NotifyPropertyChanged(); + } + } + } + + [Category("Designer Settings")] + public Padding Padding { + get { + return padding; + } + set { + if (this.padding != value) { + this.padding = value; + this.NotifyPropertyChanged(); + } + + } + } + #endregion + } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs index 1321e9b4a4..ecf2572da7 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs @@ -132,7 +132,49 @@ namespace SharpReportCore{ } - + /// <summary> + /// This class holds all the available Sections of an Report + /// </summary> + public class BaseDataItemCollection: List<BaseDataItem>{ + public event EventHandler<CollectionItemEventArgs<BaseDataItem>> Added; + public event EventHandler<CollectionItemEventArgs<BaseDataItem>> Removed; + + public BaseDataItem Find (string columnName) { + for (int i = 0;i < this.Count ; i ++) { + BaseDataItem col = this[i]; + if (String.Compare(col.Name.ToLower(CultureInfo.CurrentCulture), + columnName.ToLower(CultureInfo.CurrentCulture))== 0){ + return col; + } + } + return null; + } + + public new void Add(BaseDataItem item){ + base.Add(item); + this.OnAdded (item); + } + + + + public new bool Remove(BaseDataItem item) + { + if (base.Remove (item)) { + this.OnRemoved(item); + return true; + } + return false; + } + void OnAdded(BaseDataItem item){ + if (Added != null) + Added(this, new CollectionItemEventArgs<BaseDataItem>(item)); + } + + void OnRemoved( BaseDataItem item){ + if (Removed != null) + Removed(this, new CollectionItemEventArgs<BaseDataItem>(item)); + } + } [Serializable()] public class ColumnCollection: List<AbstractColumn>{ @@ -161,12 +203,6 @@ namespace SharpReportCore{ public CultureInfo Culture { get { return culture; } -// set -// { -// if (value == null) -// value = CultureInfo.CurrentCulture; -// culture = value; -// } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs index 955b0324eb..f85dbcd31a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs @@ -23,22 +23,9 @@ using System.Globalization; /// </remarks> namespace SharpReportCore { - public class DataManager : IDataContainer,IEnumerator,IDisposable { - - /* - /// <summary> - /// Operand to use when filtering... - /// </summary> - public enum FilterOperand { - Equals, - NotEquals, - Includes, - NotIncludes, - } - */ - - int currentRow = -1; + public class DataManager :IDisposable { + ReportSettings reportSettings; object dataSource; string dataMember; @@ -277,6 +264,7 @@ namespace SharpReportCore { this.ListChanged (this,e); } } + private void NotifyGroupChanging () { if (this.GroupChanging!= null) { this.GroupChanging (this,EventArgs.Empty); @@ -350,18 +338,19 @@ namespace SharpReportCore { return true; } - public void Skip() { - this.dataViewStrategy.CurrentRow ++; - } - - +// public void Skip() { +// this.dataViewStrategy.CurrentRow ++; +// } +// + /* public void FetchData(ReportItemCollection collection) { foreach (IItemRenderer item in collection) { this.dataViewStrategy.Fill(item); } this.NotifyGroupChanged(); } - + */ + /* /// <summary> /// Indicate's if the current <see cref="GroupSeperator"></see> has ChildRows /// </summary> @@ -370,6 +359,7 @@ namespace SharpReportCore { return this.dataViewStrategy.HasChilds; } } + */ /// <summary> /// Returns a <see cref="SharpArrayList"></see>, be carefull, this list is only a Indexlist @@ -393,8 +383,13 @@ namespace SharpReportCore { } } #endregion + // Nur zum testen - + public DataNavigator GetNavigator { + get { + return new DataNavigator(this.dataViewStrategy); + } + } #region System.Collections.IEnumerator interface implementation @@ -404,21 +399,15 @@ namespace SharpReportCore { } } - public void Reset() { - this.dataViewStrategy.Reset(); - this.currentRow = -1; - } +// public void Reset() { +// this.dataViewStrategy.Reset(); +// } +// +// public bool MoveNext() { +// return this.dataViewStrategy.MoveNext(); +// } + - public bool MoveNext() { - try { - this.currentRow ++; - this.dataViewStrategy.CurrentRow = this.currentRow; - return true; - } catch (Exception) { - return false; - } - - } #endregion public bool IsGrouped { diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataNavigator.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataNavigator.cs new file mode 100644 index 0000000000..d955b5ae90 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataNavigator.cs @@ -0,0 +1,69 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 23.03.2006 + * Time: 13:18 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.ComponentModel; +namespace SharpReportCore +{ + /// <summary> + /// Description of DataNavigator. + /// </summary> + + public class DataNavigator{ + IDataViewStrategy store; + public event EventHandler <ListChangedEventArgs> ListChanged; + public DataNavigator(IDataViewStrategy store){ + this.store = store; + this.store.ListChanged += new EventHandler<ListChangedEventArgs> (OnListChanged); + } + + private void OnListChanged (object sender,System.ComponentModel.ListChangedEventArgs e) { + if (this.ListChanged != null) { + this.ListChanged (this,e); + } + } + + public void Fill (ReportItemCollection collection) { + foreach (IItemRenderer item in collection) { + this.store.Fill(item); + } + } + + /// <summary> + /// Indicate's if the current <see cref="GroupSeperator"></see> has ChildRows + /// </summary> + public bool HasChilds { + get { + return this.store.HasChilds; + } + } + + public int CurrentRow { + get {return store.CurrentRow;} + } + + public int Count { + get {return store.Count;} + } + + public bool MoveNext () { + return this.store.MoveNext(); + } + + public void Reset() { + store.Reset(); + } + + public object Current { + get { + return store.Current; + } + } + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/BaseListStrategy.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/BaseListStrategy.cs index 38209cf79b..f03b69c423 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/BaseListStrategy.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/BaseListStrategy.cs @@ -13,7 +13,6 @@ using System.Globalization; using System.ComponentModel; using System.Collections; using System.Collections.Generic; -using SharpReportCore; /// <summary> /// BaseClass for all Datahandling Strategies @@ -24,7 +23,7 @@ using SharpReportCore; /// </remarks> namespace SharpReportCore { - public abstract class BaseListStrategy :IDataViewStrategy { + public abstract class BaseListStrategy :IDataViewStrategy,IEnumerator { private bool isSorted; private bool isFiltered; private bool isGrouped; @@ -179,6 +178,23 @@ namespace SharpReportCore { System.Console.WriteLine("-----End of <CheckSortArray>-----------"); } + public virtual void Reset() { + this.indexList.CurrentPosition = -1; + this.NotifyResetList(); + } + + public virtual object Current { + get { + + throw new NotImplementedException(); + } + } + + public virtual bool MoveNext(){ + return(++this.indexList.CurrentPosition<this.indexList.Count); + } + + #region SharpReportCore.IDataViewStrategy interface implementation @@ -196,13 +212,12 @@ namespace SharpReportCore { public virtual int CurrentRow { get { - return 0; + return this.indexList.CurrentPosition; } set { - if (value > this.indexList.Count){ - throw new IndexOutOfRangeException (); + if ((value > -1)|| (value > this.indexList.Count)){ + this.indexList.CurrentPosition = value; } - this.indexList.CurrentPosition = value; } } @@ -252,9 +267,7 @@ namespace SharpReportCore { this.indexList.Clear(); } - public virtual void Reset() { - this.NotifyResetList(); - } + public virtual void Bind() { diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/CollectionStrategy.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/CollectionStrategy.cs index f1a26a2a4b..856814305e 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/CollectionStrategy.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/CollectionStrategy.cs @@ -7,20 +7,18 @@ // the code is regenerated. // </autogenerated> //------------------------------------------------------------------------------ +using System; +using System.Globalization; +using System.ComponentModel; +using System.Collections; -namespace SharpReportCore { - - using System; - using System.Globalization; - using System.ComponentModel; - using System.Collections; - using SharpReportCore; - - /// <summary> - /// This Class handles all List's with IList - /// Access to Data is allway#s done by using the 'IndexList' - /// </summary> +/// <summary> +/// This Class handles all List's with IList +/// Access to Data is allway#s done by using the 'IndexList' +/// </summary> + +namespace SharpReportCore { public class CollectionStrategy : BaseListStrategy { // Holds the plain Data diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs index b9faf19617..4f3b73b905 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs @@ -13,17 +13,16 @@ using System.Collections; using System.Data; using System.ComponentModel; -using SharpReportCore; + +/// <summary> +/// This class handles DataTables +/// </summary> +/// <remarks> +/// created by - Forstmeier Peter +/// created on - 23.10.2005 15:12:06/// +///</remarks> namespace SharpReportCore { - - /// <summary> - /// This class handles DataTables - /// </summary> - /// <remarks> - /// created by - Forstmeier Peter - /// created on - 23.10.2005 15:12:06 - /// </remarks> public class TableStrategy : BaseListStrategy { DataTable table; @@ -139,6 +138,31 @@ namespace SharpReportCore { #endregion + #region IEnumerator + public override bool MoveNext(){ + return base.MoveNext(); + } + + public override void Reset() { + base.Reset(); + this.view.Sort = ""; + this.view.RowFilter = ""; + + } + + public override object Current{ + get { + if (base.CurrentRow < 0) { + return null; + } else { + return row = this.view[((BaseComparer)base.IndexList[base.CurrentRow]).ListIndex]; + } + } + } + + #endregion + + #region IDataViewStrategy interface implementation public override void Bind() { @@ -183,6 +207,9 @@ namespace SharpReportCore { public override void Fill (IItemRenderer item) { try { base.Fill(item); + if (this.Current == null) { + System.Console.WriteLine("ow is null"); + } if (this.row != null) { BaseDataItem baseDataItem = item as BaseDataItem; if (baseDataItem != null) { @@ -190,19 +217,12 @@ namespace SharpReportCore { } } - } catch (System.NullReferenceException) { - + } catch (Exception) { + throw; } } - - public override void Reset() { - this.CurrentRow = 0; - this.view.Sort = ""; - this.view.RowFilter = ""; - base.Reset(); - } - + public override ColumnCollection AvailableFields { get { ColumnCollection c = base.AvailableFields; @@ -226,10 +246,11 @@ namespace SharpReportCore { get{ return base.IndexList.CurrentPosition; } + + /* set { base.CurrentRow = value; - - if (base.IndexList.Count > 0) { + if ((value > -1) && (value < base.IndexList.Count)){ BaseComparer bc = (BaseComparer)base.IndexList[value]; GroupSeperator sep = bc as GroupSeperator; @@ -239,9 +260,11 @@ namespace SharpReportCore { row = this.view[((BaseComparer)base.IndexList[value]).ListIndex]; } } + */ } #endregion + #region IDisposable public override void Dispose(){ diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/MissingSectionException.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/MissingSectionException.cs new file mode 100644 index 0000000000..1574829203 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/MissingSectionException.cs @@ -0,0 +1,38 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 12.03.2006 + * Time: 22:46 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Runtime.Serialization; +/// <summary> +/// Description of MissingSectionException. +/// </summary> +namespace SharpReportCore{ + + [Serializable()] + public class MissingSectionException: System.Exception + { + + public MissingSectionException():base(){ + + } + public MissingSectionException(string errorMessage) :base (errorMessage){ + + } + public MissingSectionException(string errorMessage, + Exception exception):base (errorMessage,exception){ + + } + + protected MissingSectionException(SerializationInfo info, + StreamingContext context) : base(info, context){ + // Implement type-specific serialization constructor logic. + } + } +} + diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/SharpReportWrongItemException.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/SharpReportWrongItemException.cs index e57eca3c34..6738db2038 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/SharpReportWrongItemException.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/SharpReportWrongItemException.cs @@ -11,7 +11,7 @@ using System; using System.Runtime.Serialization; /// <summary> -/// This Exception is throwen +/// This Exception is throw if an unknown Items should be created /// </summary> /// <remarks> /// created by - Forstmeier Peter diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs index c9f1cee56f..31289577e5 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs @@ -42,6 +42,7 @@ namespace SharpReportCore { public enum ReportItemType { ReportTextItem, ReportDataItem, + ReportRowItem, ReportRectangleItem, ReportImageItem, ReportLineItem, @@ -98,10 +99,11 @@ namespace SharpReportCore { /// type to its internal representation. public static object StringToEnum( Type type, string value ) { - foreach ( FieldInfo fi in type.GetFields() ) - if ( fi.Name == value ) - return fi.GetValue( null ); // We use null because - + foreach ( FieldInfo fi in type.GetFields() ){ + if ( fi.Name == value ){ + return fi.GetValue( null ); + } + } throw new Exception( string.Format(CultureInfo.CurrentCulture, "Can't convert {0} to {1}", value, diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs index 9bebfeb4d2..b058c679c0 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs @@ -32,6 +32,7 @@ namespace SharpReportCore { private static string sharpReportExtension = ".srd"; private static string xsdExtension = "xsd"; private static string sharpReportStandartFileName = "SharpReport1"; + private const string unbound = "unbound"; private const int enlargeControl = 5; #region some usefull functions and methodes @@ -120,6 +121,12 @@ namespace SharpReportCore { } } + public static Size PreferedSize { + get { + return new Size(100,20); + } + } + /// <summary> /// Size of Grids in Sections, used by the Designer @@ -134,7 +141,7 @@ namespace SharpReportCore { } #endregion - #region propertys + #region String Constant's public static string SharpReportString { get { return sharpReportString; @@ -158,6 +165,10 @@ namespace SharpReportCore { return sharpReportStandartFileName + sharpReportExtension; } } + + public static string UnboundName { + get {return unbound;} + } #endregion #region Message's diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IContainerItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IContainerItem.cs new file mode 100644 index 0000000000..194c37caf0 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IContainerItem.cs @@ -0,0 +1,28 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 06.03.2006 + * Time: 09:45 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Windows.Forms; +using System.Collections.ObjectModel; +namespace SharpReportCore +{ + /// <summary> + /// Description of IContainerControl. + /// </summary> + public interface IContainerItem{ + + bool IsValidChild (BaseReportItem childControl); + + Padding Padding + {get;set;} + + ReportItemCollection Items + {get;} + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataContainer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataContainer.cs index 19de9ee45d..36469050d5 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataContainer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataContainer.cs @@ -13,19 +13,20 @@ namespace SharpReportCore { /// Setup the Databinding, return true if databinding was ok /// </summary> bool DataBind(); - /// <summary> - /// Move to next row - /// </summary> - /// <returns></returns> - void Skip(); +// /// <summary> +// /// Move to next row +// /// </summary> +// /// <returns></returns> +// void Skip(); /// <summary> /// reste Datasource,move to position 0 /// </summary> void Reset (); - /// <summary> - /// Reads one row of data and fill the - /// <see cref="ReportItemCollection"></see> - void FetchData (ReportItemCollection collection); + +// /// <summary> +// /// Reads one row of data and fill the +// /// <see cref="ReportItemCollection"></see> +// void FetchData (ReportItemCollection collection); int Count { get; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataViewStrategy.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataViewStrategy.cs index 995aa65b98..06eaf6d059 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataViewStrategy.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataViewStrategy.cs @@ -5,20 +5,17 @@ using System.Collections; using System.ComponentModel; namespace SharpReportCore{ - public interface IDataViewStrategy:IDisposable{ + public interface IDataViewStrategy:IEnumerator,IDisposable{ /// <summary> /// Sort the DataSource /// </summary> void Sort (); + /// <summary> - /// Reset Datasource to first position - /// </summary> - void Reset(); - /// <summary> - /// Establish Databinding - /// Allway'S call this method before any other operations - /// </summary> +// /// Establish Databinding +// /// Allway's call this method before any other operations +// /// </summary> void Bind(); /// <summary> /// Fill's a <see cref="IItemRenderer"></see> with Data from the CurrentRow diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs new file mode 100644 index 0000000000..62a73a381d --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs @@ -0,0 +1,121 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Peter + * Date: 23.03.2006 + * Time: 11:18 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; + +namespace SharpReportCore{ + /// <summary> + /// Description of AbstractDataRenderer. + /// </summary> + public class AbstractDataRenderer : AbstractRenderer{ + DataManager dataManager; + DataNavigator navigator; + public AbstractDataRenderer(ReportModel model,DataManager dataManager):base(model){ + if (dataManager == null) { + throw new ArgumentNullException("dataManager"); + } + this.dataManager = dataManager; + } + + protected override void ReportBegin(object sender, ReportPageEventArgs e) + { + base.ReportBegin(sender, e); + } + + + + protected override void BeginPrintPage(object sender, ReportPageEventArgs e) + { + base.BeginPrintPage(sender, e); + } + + + protected override int RenderSection(BaseSection section, ReportPageEventArgs rpea){ + + bool hasContainer = false; + IContainerItem container = null; + foreach (BaseReportItem item in section.Items) { + container = item as IContainerItem; + if (container != null) { + hasContainer = true; + break; + } + } + if (hasContainer) { + return DoContainerControl(section,container,rpea); + } else { + return base.RenderSection(section, rpea); + } + + } + + private int DoContainerControl (BaseSection section, + IContainerItem container, + ReportPageEventArgs rpea) { + + if (container == null) { + return section.Size.Height; + } + + this.DataNavigator.Fill(container.Items); + Point drawPoint = new Point(0,0); + if (section.Visible){ + section.Render (rpea); + + foreach (BaseReportItem item in section.Items) { + if (item.Parent == null) { + item.Parent = section; + } + item.SectionOffset = section.SectionOffset; + base.DrawSingleItem (rpea,item); + drawPoint.Y = section.SectionOffset + section.Size.Height; + rpea.LocationAfterDraw = new PointF (rpea.LocationAfterDraw.X,section.SectionOffset + section.Size.Height); + + } + if ((section.CanGrow == false)&& (section.CanShrink == false)) { + return section.Size.Height; + + } + + return drawPoint.Y; + } + return drawPoint.Y; + } + + #region Properties + + protected DataManager DataManager { + get { + return dataManager; + } + } + + protected DataNavigator DataNavigator{ + get {return this.navigator;} + set {this.navigator = value;} + } + + #endregion + + #region IDisposable + public override void Dispose() + { + if (this.dataManager != null) { + this.dataManager.Dispose(); + this.dataManager = null; + } + if (this.navigator != null) { + this.navigator= null; + } + base.Dispose(); + } + #endregion + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs index d1a3c576a3..77c3e3cf4d 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs @@ -109,13 +109,13 @@ namespace SharpReportCore { /// </summary> protected void DebugRectangle (ReportPageEventArgs rpea,Rectangle rectangle) { -// if (rpea == null) { -// throw new ArgumentNullException("rpea"); -// } -// if (rectangle == null) { -// throw new ArgumentNullException("rectangle"); -// } -// e.PrintPageEventArgs.Graphics.DrawRectangle (Pens.Black,rect); + if (rpea == null) { + throw new ArgumentNullException("rpea"); + } + + System.Console.WriteLine("Debug Rectangle {0}",rectangle); + rpea.PrintPageEventArgs.Graphics.DrawRectangle (Pens.Black,rectangle); + } /// <summary> @@ -159,7 +159,7 @@ namespace SharpReportCore { ///</summary> /// <param name="startAt">Section start at this PointF</param> /// <param name="e">ReportPageEventArgs</param> - protected PointF DrawPageheader (PointF startat,ReportPageEventArgs e) { + protected PointF DrawPageHeader (PointF startat,ReportPageEventArgs e) { float offset = 0F; BaseSection section = null; sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,CultureInfo.InvariantCulture); @@ -177,52 +177,53 @@ namespace SharpReportCore { } - protected int RenderSection (BaseSection section,ReportPageEventArgs rpea) { + + protected virtual int RenderSection (BaseSection section,ReportPageEventArgs rpea) { + Point drawPoint = new Point(0,0); if (section.Visible){ section.Render (rpea); - foreach (BaseReportItem rItem in section.Items) { - rItem.SuspendLayout(); - rItem.Parent = section; - if (section.SectionMargin == 0) { - rItem.Margin = reportSettings.DefaultMargins.Left; + foreach (BaseReportItem item in section.Items) { + if (item.Parent == null) { + item.Parent = section; } - else { - rItem.Margin = section.SectionMargin; - } - rItem.Offset = section.SectionOffset; - - rItem.FormatOutput -= new EventHandler<FormatOutputEventArgs> (FormatBaseReportItem); - rItem.FormatOutput += new EventHandler<FormatOutputEventArgs> (FormatBaseReportItem); + item.SectionOffset = section.SectionOffset; + this.DrawSingleItem (rpea,item); - rItem.Render(rpea); - drawPoint.Y = section.SectionOffset + section.Size.Height; rpea.LocationAfterDraw = new PointF (rpea.LocationAfterDraw.X,section.SectionOffset + section.Size.Height); - rItem.ResumeLayout(); + } + if ((section.CanGrow == false)&& (section.CanShrink == false)) { return section.Size.Height; - } return drawPoint.Y; } return drawPoint.Y; } - + + + protected void DrawSingleItem (ReportPageEventArgs rpea,BaseReportItem item){ + item.SuspendLayout(); + item.FormatOutput -= new EventHandler<FormatOutputEventArgs> (FormatBaseReportItem); + item.FormatOutput += new EventHandler<FormatOutputEventArgs> (FormatBaseReportItem); + item.Render(rpea); + item.ResumeLayout(); + } // Called by FormatOutPutEvent of the BaseReportItem void FormatBaseReportItem (object sender, FormatOutputEventArgs rpea) { + System.Console.WriteLine("FormatBaseReportItem"); BaseDataItem baseDataItem = sender as BaseDataItem; if (baseDataItem != null) { - rpea.FormatedValue = defaultFormatter.FormatItem (baseDataItem); + if (!String.IsNullOrEmpty(baseDataItem.FormatString)) { + rpea.FormatedValue = defaultFormatter.FormatItem (baseDataItem); + System.Console.WriteLine("\tFormated Value = {0}",rpea.FormatedValue); + } } -// if (sender is BaseDataItem) { -// BaseDataItem i = (BaseDataItem)sender; -// e.FormatedValue = defaultFormatter.FormatItem (i); -// } } @@ -416,7 +417,7 @@ namespace SharpReportCore { #endregion #region IDispoable - public void Dispose(){ + public virtual void Dispose(){ if (this.reportDocument != null) { this.reportDocument.Dispose(); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/DefaultFormatter.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/DefaultFormatter.cs index 75bb60710c..dbfecf2bbd 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/DefaultFormatter.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/DefaultFormatter.cs @@ -43,6 +43,7 @@ namespace SharpReportCore{ ///<param name="item">A ReportDataItem</param> /// public string FormatItem (BaseDataItem item) { + System.Console.WriteLine("FormatItem {0} / {1}",item.DataType,item.FormatString); if (item == null) { throw new ArgumentNullException("item"); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs index 0f632c400a..f6305e89e5 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs @@ -21,9 +21,11 @@ // Peter Forstmeier (Peter.Forstmeier@t-online.de) using System; -using System.Globalization; + using System.Data; using System.Drawing; +using System.ComponentModel; +using System.Globalization; using System.Drawing.Printing; using SharpReportCore; @@ -38,20 +40,15 @@ using SharpReportCore; /// namespace SharpReportCore { - public class RenderDataReport : SharpReportCore.AbstractRenderer { - - private DataManager dataManager; +// public class RenderDataReport : AbstractRenderer { + public class RenderDataReport : AbstractDataRenderer { + private PointF currentPoint; - - public RenderDataReport(ReportModel model):base (model){ - } + private DataNavigator dataNavigator; - public RenderDataReport(ReportModel model,DataManager dataManager):base (model){ - this.dataManager = dataManager; - System.Console.WriteLine("ReenderDataReport"); - System.Console.WriteLine("connect to groupingevents"); - this.dataManager.GroupChanged += new EventHandler<GroupChangedEventArgs>(OnGroupChanged); - this.dataManager.GroupChanging += new EventHandler <EventArgs> (OnGroupChanging); + public RenderDataReport(ReportModel model,DataManager dataManager):base (model,dataManager){ + base.DataManager.GroupChanged += new EventHandler<GroupChangedEventArgs>(OnGroupChanged); + base.DataManager.GroupChanging += new EventHandler <EventArgs> (OnGroupChanging); } @@ -64,6 +61,13 @@ namespace SharpReportCore { System.Console.WriteLine("OnGroupChanging"); } + + private void OnListChanged (object sender,System.ComponentModel.ListChangedEventArgs e) { + System.Console.WriteLine("List Changed sender <{0}> reason <{1}>", + sender.ToString(), + e.ListChangedType); + } + #region overrides @@ -73,13 +77,16 @@ namespace SharpReportCore { protected override void ReportBegin(object sender, ReportPageEventArgs e) { base.ReportBegin (sender,e); - //allways reset the dataManager before printing - if (this.dataManager != null) { - this.dataManager.Reset(); - } + + base.DataManager.ListChanged += new EventHandler<ListChangedEventArgs> (OnListChanged); + dataNavigator = base.DataManager.GetNavigator; + dataNavigator.ListChanged += new EventHandler<ListChangedEventArgs> (OnListChanged); + dataNavigator.Reset(); + base.DataNavigator = dataNavigator; } protected override void BeginPrintPage(object sender, ReportPageEventArgs rpea) { + if (rpea == null) { throw new ArgumentNullException("rpea"); } @@ -93,7 +100,7 @@ namespace SharpReportCore { } //Draw Pageheader - currentPoint = base.DrawPageheader (currentPoint,rpea); + currentPoint = base.DrawPageHeader (currentPoint,rpea); base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y); } @@ -115,57 +122,36 @@ namespace SharpReportCore { section.SectionOffset, e.PrintPageEventArgs.MarginBounds.Width, section.Size.Height); - DebugRectangle (e,detailRect); +// DebugRectangle (e,detailRect); // no loop if there is no data - if (! dataManager.HasMoreData ) { + if (! base.DataManager.HasMoreData ) { e.PrintPageEventArgs.HasMorePages = false; return; } - - - // here starts the page - bool goon = true; - do { - try { - if (dataManager.HasMoreData) { - - dataManager.FetchData (base.CurrentSection.Items); -// offset = base.RenderSection (section,e); - base.RenderSection (section,e); - section.SectionOffset = section.SectionOffset + section.Size.Height + 2 * base.Gap; - base.FitSectionToItems (base.CurrentSection,e); - - sectionRect = new Rectangle (e.PrintPageEventArgs.MarginBounds.Left, - section.SectionOffset, - e.PrintPageEventArgs.MarginBounds.Width, - section.Size.Height); - - dataManager.Skip(); - } else { - e.PrintPageEventArgs.HasMorePages = false; - goon = false; - } - - } catch (Exception) { - e.PrintPageEventArgs.HasMorePages = false; - goon = false; - } + + while (dataNavigator.MoveNext()) { + dataNavigator.Fill (base.CurrentSection.Items); + base.RenderSection (section,e); + + section.SectionOffset = section.SectionOffset + section.Size.Height + 2 * base.Gap; + base.FitSectionToItems (base.CurrentSection,e); + + sectionRect = new Rectangle (e.PrintPageEventArgs.MarginBounds.Left, + section.SectionOffset, + e.PrintPageEventArgs.MarginBounds.Width, + section.Size.Height); + + if (!detailRect.Contains(sectionRect)) { + base.PageBreak(e,section); + return; + } } - while (detailRect.Contains(sectionRect)&& goon); - - // is there is anymore data + e.PrintPageEventArgs.HasMorePages = false; - if (dataManager.HasMoreData ) { - base.PageBreak(e,section); - return; - } else { - e.PrintPageEventArgs.HasMorePages = false; - } - //Did we have a pagebreak if (base.CurrentSection.PageBreakAfter) { base.PageBreak(e,section); @@ -175,7 +161,6 @@ namespace SharpReportCore { } - protected override void PrintBodyEnd(object sender, ReportPageEventArgs e) { base.PrintBodyEnd (sender,e); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs index 8101295157..42cfc1691a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs @@ -75,7 +75,7 @@ namespace SharpReportCore { } //Draw Pageheader - currentPoint = base.DrawPageheader (currentPoint,e); + currentPoint = base.DrawPageHeader (currentPoint,e); base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y); } @@ -96,7 +96,7 @@ namespace SharpReportCore { Rectangle detailRect = base.DetailRectangle (e); FitSectionToItems (section,e); base.RenderSection (section,e); - DebugRectangle (e,detailRect); +// DebugRectangle (e,detailRect); } @@ -122,7 +122,7 @@ namespace SharpReportCore { base.CurrentSection.SectionOffset , e.PrintPageEventArgs.MarginBounds.Width, base.CurrentSection.Size.Height); - DebugRectangle (e,r); +// DebugRectangle (e,r); int off = base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height + base.Gap; //ReportFooter @@ -138,7 +138,7 @@ namespace SharpReportCore { base.CurrentSection.Size.Height); base.RenderSection (section,e); - DebugRectangle (e,rr); +// DebugRectangle (e,rr); } #endregion diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs index 6f490de6c5..831171577e 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs @@ -73,14 +73,12 @@ namespace SharpReportCore { } public void ReportDocumentQueryPage (object sender, QueryPageSettingsEventArgs e) { -// System.Console.WriteLine("\tReportDocument QueryPage"); if (QueryPage != null) { QueryPage (this,e); } } public void ReportDocumentPrintPage (object sender, PrintPageEventArgs e) { - System.Console.WriteLine("\tReportDocument PrintPage"); pageNr ++; ReportPageEventArgs pea = new ReportPageEventArgs (e,pageNr,false,new PointF (0,0)); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs index 2b909a56ea..57803b103c 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs @@ -46,6 +46,7 @@ namespace SharpReportCore { foreach (GlobalEnums.enmSection sec in Enum.GetValues(typeof(GlobalEnums.enmSection))) { sectionCollection.Add (sectionFactory.Create(sec.ToString())); } + } public ReportModel(GraphicsUnit graphicsUnit):this() { diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj index 667da7b18e..db99fa6889 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj @@ -126,6 +126,11 @@ <Compile Include="DataManager\SqlQueryChecker.cs" /> <Compile Include="Exceptions\MissingModelException.cs" /> <Compile Include="Interfaces\IHierarchyInterfaces.cs" /> + <Compile Include="BaseItems\RowItem.cs" /> + <Compile Include="Interfaces\IContainerItem.cs" /> + <Compile Include="Exceptions\MissingSectionException.cs" /> + <Compile Include="Printing\AbstractDataRenderer.cs" /> + <Compile Include="DataManager\DataNavigator.cs" /> </ItemGroup> <ItemGroup> <Folder Include="BaseItems" /> diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/IVisitor.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/IVisitor.cs index 7bb6e6adcf..bab00013b7 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/IVisitor.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/IVisitor.cs @@ -8,8 +8,7 @@ */ using System; -//using SharpReport.Designer; -//using SharpReportCore; + namespace SharpReportCore{ diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs index 36b9070e62..90eca5d864 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs @@ -97,8 +97,7 @@ namespace SharpReportCore { } } }else { - SharpReportException ex = new SharpReportException ("Wrong Section Name <" + sectionElem.GetAttribute("name") + ">"); - throw ex; + throw new MissingSectionException(); } }else { throw new System.Xml.XmlException ("Report : SetSection Wrong Node in Report"); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs index 4adb86f141..bd882edb09 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs @@ -43,11 +43,7 @@ namespace SharpReportCore { /// <returns>"Report is SharpReport or not</returns>/returns> /// public static bool IsSharpReport (XmlElement elem) { - bool isOk = false; - if (elem.Name.Equals (SharpReportCore.GlobalValues.SharpReportString)) { - isOk = true; - } - return isOk; + return (elem.Name.Equals (SharpReportCore.GlobalValues.SharpReportString)); } /// <summary> @@ -128,18 +124,17 @@ namespace SharpReportCore { try { XmlNodeList nodeList = ctrlElem.ChildNodes; foreach (XmlNode node in nodeList) { - if (node is XmlElement) { - XmlElement elem = (XmlElement)node; - if (elem.HasAttribute("value")) { - if (elem.Name == "Font") { + XmlElement elem = node as XmlElement; + if (elem != null) { + if (elem.HasAttribute("value")) { + if (elem.Name == "Font") { + item.Font = XmlFormReader.MakeFont (elem.GetAttribute("value")); + } -// MessageBox.Show ("FOnt " + elem.GetAttribute("value").ToString(),"BuildCOntrol"); - item.Font = XmlFormReader.MakeFont (elem.GetAttribute("value")); + reader.SetValue (item,elem.Name,elem.GetAttribute("value")); } - reader.SetValue (item,elem.Name,elem.GetAttribute("value")); } } - } } catch (Exception) { throw; } diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/GeneratorCommands.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/GeneratorCommands.cs index 5352870271..d066066585 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/GeneratorCommands.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/GeneratorCommands.cs @@ -68,10 +68,12 @@ namespace ReportGenerator{ dataModel = model.DataModel; switch (dataModel) { case GlobalEnums.enmPushPullModel.PullData: + customizer.Set("DataRow",GlobalEnums.ReportItemType.ReportRowItem); GeneratePullDataReport generatePullDataReport = new GeneratePullDataReport(customizer,model); generatePullDataReport.GenerateReport(); break; case GlobalEnums.enmPushPullModel.PushData: + customizer.Set("DataRow",GlobalEnums.ReportItemType.ReportRowItem); GeneratePushDataReport generatePushDataReport = new GeneratePushDataReport(customizer,model); generatePushDataReport.GenerateReport(); break; diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs index 2dc23152b4..dbbc31d49a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs @@ -36,10 +36,12 @@ namespace ReportGenerator { private ReportGenerator reportGenerator; private Properties customizer; private SharpReportManager manager; + private BaseReportItem parentItem; + private NameService nameService ; + private AutoReport autoReport; + private ReportItemCollection collection; - public AbstractReportGenerator() { - } - + public AbstractReportGenerator(Properties customizer,ReportModel reportModel){ if (reportModel == null) { throw new ArgumentNullException("reportModel"); @@ -49,9 +51,20 @@ namespace ReportGenerator { } this.customizer = customizer; this.reportModel = reportModel; + this.nameService = new NameService(); + this.autoReport = new AutoReport(); reportGenerator = (ReportGenerator)customizer.Get("Generator"); manager = new SharpReportManager(); + if (this.customizer.Get("DataRow") != null) { + SharpReport.Designer.IDesignableFactory bf = new SharpReport.Designer.IDesignableFactory(); + this.parentItem = bf.Create (this.customizer.Get("DataRow").ToString()); + + IContainerItem con = this.parentItem as IContainerItem; + if (con != null) { + con.Padding = reportModel.ReportSettings.Padding; + } + } } #region ReportGenerator.IReportGenerator interface implementation @@ -59,11 +72,13 @@ namespace ReportGenerator { if (this.reportModel == null) { throw new MissingModelException(); } + BuildStandartSections(); manager.CreatePageHeader (this.reportModel); manager.CreatePageNumber(this.reportModel); } + #endregion @@ -74,16 +89,100 @@ namespace ReportGenerator { } } - protected void AdjustAll () { - AdjustNames(reportModel); + + protected void BuildDataSection (BaseSection section) { + + if (section == null) { + throw new ArgumentException("section"); + } + + if (this.parentItem == null) { + DataColumnsFromReportItems (section); + } else { + section.Items.Add (this.parentItem); + IContainerItem containerItem = this.parentItem as IContainerItem; + this.parentItem.Parent = section; + if ( containerItem != null) { + this.AddItemsToParent (containerItem,this.ReportItemCollection); + } + } + } + + private void DataColumnsFromReportItems (BaseSection section) { + + try { + ReportItemCollection colDetail = autoReport.AutoDataColumns (this.ReportItemCollection); + section.SuspendLayout(); + AddItemsToSection (section,colDetail); + section.ResumeLayout(); + }catch (Exception) { + throw; + } + + } + + protected void HeaderColumnsFromReportItems (BaseSection section) { + + try { + ReportItemCollection colDetail = autoReport.HeaderColumnsFromReportItems (this.ReportItemCollection,section,false); + section.SuspendLayout(); + AddItemsToSection (section,colDetail); + section.ResumeLayout(); + } catch(Exception) { + throw; + } + } + + + + + private void AddItemsToParent (IContainerItem container,ReportItemCollection collection) { + for (int i = 0;i < collection.Count ;i ++ ) { + BaseReportItem r = (BaseReportItem)collection[i]; + r.Location = new Point (r.Location.X,container.Padding.Top); + r.Parent = container; + container.Items.Add (r); + } + } + + private void AddItemsToSection (BaseSection section,ReportItemCollection collection) { + + if (section == null ) { + throw new ArgumentNullException ("section"); + } + if (collection == null) { + throw new ArgumentNullException("collection"); + } + // if there are already items in the section, + // then we have to append the Items, means whe have to enlarge the section + if (section.Items.Count > 0) { + section.Size = new Size (section.Size.Width, + section.Size.Height + GlobalValues.DefaultSectionHeight); + } + + for (int i = 0;i < collection.Count ;i ++ ) { + BaseReportItem r = (BaseReportItem)collection[i]; + r.Parent = section; + r.Location = new Point (r.Location.X,GlobalValues.DefaultSectionHeight); + section.Items.Add (r); + } + } + + + protected void AdjustAllNames () { + foreach (BaseSection sec in this.reportModel.SectionCollection) { + AdjustNames(sec.Items); + } } - private static void AdjustNames (ReportModel model) { - NameService nameService = new NameService(); - foreach (BaseSection section in model.SectionCollection) { - foreach (IItemRenderer item in section.Items) { - item.Name = nameService.CreateName(section.Items,item.Name); + private void AdjustNames (ReportItemCollection items) { + + foreach (IItemRenderer item in items) { + IContainerItem it = item as IContainerItem; + if (it != null) { + AdjustNames (it.Items); } + item.Name = nameService.CreateName(items,item.Name); } } @@ -94,22 +193,30 @@ namespace ReportGenerator { return customizer; } } + public ReportGenerator ReportGenerator { get { return reportGenerator; } } + public ReportModel ReportModel { get { return reportModel; } } - public SharpReportManager Manager { + + + public ReportItemCollection ReportItemCollection { get { - return manager; + if (collection == null) { + this.collection = new ReportItemCollection(); + } + return collection; } } + #endregion public void Dispose(){ @@ -123,12 +230,16 @@ namespace ReportGenerator { protected void Dispose(bool disposing){ if (disposing) { - // Free other state (managed objects). - if (this.manager != null) { - this.manager.Dispose(); - } + + } + if (this.manager != null) { + this.manager.Dispose(); + this.manager = null; + } + if (this.autoReport != null) { + this.autoReport.Dispose(); + this.autoReport = null; } - // Release unmanaged resources. // Set large fields to null. // Call Dispose on your base class. diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GenerateFormSheetReport.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GenerateFormSheetReport.cs index c1bdf062d7..6f9b1c0d35 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GenerateFormSheetReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GenerateFormSheetReport.cs @@ -15,23 +15,30 @@ using SharpReportCore; namespace ReportGenerator { /// <summary> - /// Description of GenerateFormSheetReport. + /// This class generates a plain Formsheet /// </summary> public class GenerateFormSheetReport:AbstractReportGenerator { public GenerateFormSheetReport(Properties customizer, ReportModel reportModel):base(customizer,reportModel){ + if (customizer == null) { + throw new ArgumentException("customizer"); + } + if (reportModel == null) { + throw new ArgumentException("reportModel"); + } if (base.ReportModel.ReportSettings.DataModel != GlobalEnums.enmPushPullModel.FormSheet) { throw new ArgumentException ("Wrong DataModel in GeneratePullDataReport"); } + base.ReportItemCollection.Clear(); } public override void GenerateReport() { base.ReportModel.ReportSettings.ReportType = GlobalEnums.enmReportType.FormSheet; base.ReportModel.ReportSettings.DataModel = GlobalEnums.enmPushPullModel.FormSheet; base.GenerateReport(); - base.AdjustAll(); + base.AdjustAllNames(); } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePullDataReport.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePullDataReport.cs index 2fab2e32ae..6f09153e31 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePullDataReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePullDataReport.cs @@ -25,12 +25,22 @@ using System.Windows.Forms; namespace ReportGenerator { public class GeneratePullDataReport : AbstractReportGenerator { + public GeneratePullDataReport(Properties customizer, ReportModel reportModel):base(customizer,reportModel){ + if (customizer == null) { + throw new ArgumentException("customizer"); + } + if (reportModel == null) { + throw new ArgumentException("reportModel"); + } + if (base.ReportModel.ReportSettings.DataModel != GlobalEnums.enmPushPullModel.PullData) { throw new ArgumentException ("Wrong DataModel in GeneratePullDataReport"); } + base.ReportItemCollection.Clear(); + base.ReportItemCollection.AddRange((ReportItemCollection)base.Customizer.Get ("ReportItemCollection")); } #region ReportGenerator.IReportGenerator interface implementation @@ -39,25 +49,26 @@ namespace ReportGenerator { base.ReportModel.ReportSettings.ReportType = GlobalEnums.enmReportType.DataReport; base.ReportModel.ReportSettings.DataModel = GlobalEnums.enmPushPullModel.PullData; - ReportItemCollection col = (ReportItemCollection)base.Customizer.Get ("ReportItemCollection"); - ColumnCollection columnCollection = (ColumnCollection)base.Customizer.Get ("ColumnCollection"); - this.ReportModel.ReportSettings.AvailableFieldsCollection = columnCollection; + + this.ReportModel.ReportSettings.AvailableFieldsCollection = + (ColumnCollection)base.Customizer.Get ("ColumnCollection");; base.GenerateReport(); - base.Manager.HeaderColumnsFromReportItems (base.ReportModel.PageHeader,col); - base.Manager.DataColumnsFromReportItems (base.ReportModel.DetailSection,col); + base.HeaderColumnsFromReportItems (base.ReportModel.PageHeader); + base.BuildDataSection (base.ReportModel.DetailSection); using (TableLayout layout = new TableLayout(base.ReportModel)){ layout.BuildLayout(); } - base.AdjustAll(); + base.AdjustAllNames(); } catch (Exception) { throw; } } + #endregion } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePushDataReport.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePushDataReport.cs index 9c9422c86f..b34fbab4fe 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePushDataReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePushDataReport.cs @@ -32,9 +32,18 @@ namespace ReportGenerator { public GeneratePushDataReport(Properties customizer, ReportModel reportModel):base(customizer,reportModel){ + if (customizer == null) { + throw new ArgumentException("customizer"); + } + if (reportModel == null) { + throw new ArgumentException("reportModel"); + } if (base.ReportModel.ReportSettings.DataModel != GlobalEnums.enmPushPullModel.PushData) { throw new ArgumentException ("Wrong DataModel in GeneratePushReport"); } + //we can't use the customizer here + base.ReportItemCollection.Clear(); + base.ReportItemCollection.AddRange(base.ReportGenerator.ReportItemCollection); } public override void GenerateReport() { @@ -42,17 +51,15 @@ namespace ReportGenerator { base.ReportModel.ReportSettings.ReportType = GlobalEnums.enmReportType.DataReport; base.ReportModel.ReportSettings.DataModel = GlobalEnums.enmPushPullModel.PushData; - //we can't use the customizer here - ReportItemCollection col = base.ReportGenerator.ReportItemCollection; base.ReportModel.ReportSettings.AvailableFieldsCollection = base.ReportGenerator.ColumnCollection; base.GenerateReport(); - base.Manager.HeaderColumnsFromReportItems (base.ReportModel.PageHeader,col); - base.Manager.DataColumnsFromReportItems (base.ReportModel.DetailSection,col); + base.HeaderColumnsFromReportItems (base.ReportModel.PageHeader); + base.BuildDataSection (base.ReportModel.DetailSection); using (TableLayout layout = new TableLayout(base.ReportModel)){ layout.BuildLayout(); } - base.AdjustAll(); + base.AdjustAllNames(); } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportGenerator.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportGenerator.cs index 16115b0b3c..3eac71eefa 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportGenerator.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportGenerator.cs @@ -9,8 +9,10 @@ //------------------------------------------------------------------------------ using System; -using System.Globalization; using System.Drawing; +using System.ComponentModel; +using System.Globalization; + using System.Data; using System.Data.OleDb; @@ -32,7 +34,7 @@ using SharpQuery.SchemaClass; using System.Windows.Forms; namespace ReportGenerator { - public class ReportGenerator : object { + public class ReportGenerator : object,IDisposable { //BaseSettingsPanel @@ -246,5 +248,36 @@ namespace ReportGenerator { #endregion + #region IDisposable + public void Dispose(){ + this.Dispose(true); + GC.SuppressFinalize(this); + } + + ~ReportGenerator(){ + Dispose(false); + } + + protected void Dispose(bool disposing){ + if (disposing) { + if (this.reportItemCollection != null) { + this.reportItemCollection.Clear(); + this.reportItemCollection = null; + } + if (this.columnCollection == null) { + this.columnCollection.Clear(); + this.columnCollection = null; + } + if (this.sharpQueryProcedure != null) { + this.sharpQueryProcedure = null; + } + } + + // Release unmanaged resources. + // Set large fields to null. + // Call Dispose on your base class. + } + #endregion + } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportLayouts/AbstractLayout.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportLayouts/AbstractLayout.cs index 42c6ca68c4..e907643c7e 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportLayouts/AbstractLayout.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportLayouts/AbstractLayout.cs @@ -9,6 +9,7 @@ //------------------------------------------------------------------------------ using System; using System.Drawing; +using System.Drawing.Printing; using System.ComponentModel; using SharpReportCore; @@ -16,10 +17,7 @@ using SharpReportCore; /// <summary> /// This class is the BaseClass for all Layout's /// </summary> - /// <remarks> - /// created by - Susanne Jooss - /// created on - 10.09.2005 19:07:17 - /// </remarks> + namespace ReportGenerator { public class AbstractLayout : IReportLayout,IDisposable { ReportModel reportModel; @@ -53,12 +51,34 @@ namespace ReportGenerator { throw new NotImplementedException("AbstractLayout:BuildLayout must be overriden"); } #endregion + + #region Properties + public ReportModel ReportModel { get { return reportModel; } } + public ReportSettings ReportSettings { + get { + return reportModel.ReportSettings; + } + } + + public PageSettings PageSettings { + get { + return reportModel.ReportSettings.PageSettings; + } + } + + public int UseablePageWidth { + get { + return this.PageSettings.Bounds.Width - this.ReportSettings.DefaultMargins.Left - this.ReportSettings.DefaultMargins.Right; + } + } + #endregion + #region System.IDisposable interface implementation public void Dispose() { diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportLayouts/TableLayout.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportLayouts/TableLayout.cs index b169c130cc..2e2c86f43f 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportLayouts/TableLayout.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/ReportLayouts/TableLayout.cs @@ -11,7 +11,8 @@ using System; using System.Drawing; using System.Drawing.Printing; using System.ComponentModel; - +using System.Windows.Forms; + using SharpReportCore; /// <summary> /// This class build a TableLayout @@ -29,22 +30,25 @@ namespace ReportGenerator { #region ReportGenerator.IReportLayout interface implementation public override void BuildLayout() { - ReportSettings settings = base.ReportModel.ReportSettings; - PageSettings page = base.ReportModel.ReportSettings.PageSettings; defaultFont = base.ReportModel.ReportSettings.DefaultFont; - - int gesWidth = page.Bounds.Width - settings.DefaultMargins.Left - settings.DefaultMargins.Right; + // first we build the DetailSection BaseSection sec = base.ReportModel.DetailSection; - this.colWidth = gesWidth / sec.Items.Count; + IContainerItem container = (IContainerItem)sec.Items[0]; + + Padding gap; + if (container != null) { + gap = container.Padding; + } else { + gap = base.ReportModel.ReportSettings.Padding; + } + + this.colWidth = (Convert.ToInt32(base.UseablePageWidth / sec.Items.Count)) - gap.Left; - // we use GlobalValues.GridSize.Width as Gap - //between to controls - FormatSection (base.ReportModel.DetailSection,this.colWidth, - 0,GlobalValues.GridSize.Width); + 0,gap); //ReportHeader sec = base.ReportModel.ReportHeader; @@ -56,17 +60,17 @@ namespace ReportGenerator { // here we build the PageHeader, we use the columnsWidth from Details // but we start at position 1 in ItemsCollection sec = base.ReportModel.PageHeader; - this.colWidth = gesWidth / (sec.Items.Count - 1); + this.colWidth = base.UseablePageWidth / (sec.Items.Count - 1); FormatSection (sec,this.colWidth, - 1,GlobalValues.GridSize.Width); + 1,base.ReportModel.ReportSettings.Padding); base.FormatSingleEntry(sec.Items[0], - this.colWidth,new Point(settings.DefaultMargins.Left,0),defaultFont); + this.colWidth,new Point(base.ReportSettings.DefaultMargins.Left,0),defaultFont); //PageFooter sec = base.ReportModel.PageFooter; base.FormatSingleEntry(sec.Items[0], - this.colWidth,new Point(settings.DefaultMargins.Left,0),defaultFont); + this.colWidth,new Point(base.ReportSettings.DefaultMargins.Left,0),defaultFont); //ReportFooter sec = base.ReportModel.ReportFooter; @@ -76,23 +80,40 @@ namespace ReportGenerator { } #endregion - private void FormatSection (BaseSection section, - int itemWidth,int startAt, - int gap){ + private void FormatItems (ReportItemCollection collection, int leftMargin, + int itemWidth,int startAt,Padding gap) { - IItemRenderer rItem; - ReportItemCollection collection = section.Items; - int leftMargin = base.ReportModel.ReportSettings.DefaultMargins.Left; int pos = 0; + BaseReportItem item; for (int i = startAt;i < collection.Count ;i++ ) { - rItem = collection[i]; - rItem.Location = new Point (leftMargin + (pos * itemWidth),rItem.Location.Y); - rItem.Size = new Size (itemWidth - gap,rItem.Size.Height + GlobalValues.EnlargeControl); - rItem.Font = defaultFont; + item = (BaseReportItem)collection[i]; + + item.SuspendLayout(); + + item.Location = new Point (leftMargin + gap.Left + (pos * itemWidth),item.Location.Y); + item.Size = new Size (itemWidth - gap.Left,item.Size.Height + GlobalValues.EnlargeControl); + item.Font = defaultFont; + IContainerItem con = item as IContainerItem; + + if (con != null) { + item.Size = new Size (base.UseablePageWidth,item.Size.Height); + int colWidth = item.Size.Width / (con.Items.Count); + FormatItems (con.Items,0,colWidth,0,gap); + } pos ++; + item.ResumeLayout(); } } + private void FormatSection (BaseSection section, + int itemWidth,int startAt, + Padding gap){ + + int leftMargin = section.SectionMargin; + FormatItems (section.Items,leftMargin,itemWidth,startAt,gap); + + } + } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/PushModelPanel.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/PushModelPanel.cs index b60aaeee55..00d40ae1d2 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/PushModelPanel.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/PushModelPanel.cs @@ -80,11 +80,11 @@ namespace ReportGenerator using (AutoReport auto = new AutoReport()){ ReportModel model = generator.FillReportModel (new ReportModel()); columnCollection = auto.AbstractColumnsFromDataSet (ds); - reportItems = auto.ReportItemsFromSchema(model,ds); + reportItems = auto.DataItemsFromSchema(model,ds); if (reportItems != null) { foreach (ReportDataItem item in reportItems) { - this.checkedListBox.Items.Add (item.MappingName,CheckState.Checked); + this.checkedListBox.Items.Add (item.MappingName,CheckState.Unchecked); } } } @@ -108,12 +108,9 @@ namespace ReportGenerator } public override bool ReceiveDialogMessage(DialogMessage message){ -// base.EnableNext = true; -// base.EnableFinish = true; + if (message == DialogMessage.Activated) { -// base.EnableNext = true; -// base.EnableFinish = true; -// base.IsLastPanel = true; + } else if (message == DialogMessage.Finish) { @@ -128,7 +125,7 @@ namespace ReportGenerator base.EnableFinish = true; base.IsLastPanel = true; //We can't use the customizer here, because Resultpanel is called later on - // and null's the proerties + // and null's the properties generator.ReportItemCollection = itemCollection; generator.ColumnCollection = columnCollection; } diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs index 186fdeeda2..ec34d96bac 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs @@ -143,7 +143,7 @@ namespace ReportGenerator{ private void CreateCollections (DataSet dataSet) { using (AutoReport auto = new AutoReport()){ abstractColumns = auto.AbstractColumnsFromDataSet (dataSet); - colDetail = auto.ReportItemsFromSchema(this.model,dataSet); + colDetail = auto.DataItemsFromSchema(this.model,dataSet); } } diff --git a/src/Main/StartUp/Project/Resources/BitmapResources.resources b/src/Main/StartUp/Project/Resources/BitmapResources.resources index 385353603b..3a554b5532 100644 Binary files a/src/Main/StartUp/Project/Resources/BitmapResources.resources and b/src/Main/StartUp/Project/Resources/BitmapResources.resources differ