diff --git a/data/resources/StringResources.jp.resources b/data/resources/StringResources.jp.resources deleted file mode 100644 index 710f4bdd50..0000000000 Binary files a/data/resources/StringResources.jp.resources and /dev/null differ diff --git a/data/resources/StringResources.pt.resources b/data/resources/StringResources.pt.resources deleted file mode 100644 index 13ba7ae59a..0000000000 Binary files a/data/resources/StringResources.pt.resources and /dev/null differ diff --git a/samples/SharpReport/ReportSamples/MainForm.Designer.cs b/samples/SharpReport/ReportSamples/MainForm.Designer.cs index eabccca6a4..2b2f773aa0 100644 --- a/samples/SharpReport/ReportSamples/MainForm.Designer.cs +++ b/samples/SharpReport/ReportSamples/MainForm.Designer.cs @@ -46,9 +46,12 @@ namespace ReportSamples this.missingConnectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.pushModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.emlpoyeesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components); this.unboundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.unboundToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.unboundPullModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.multipageUnboundPullModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.unboundPuskModelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.errorProvider1 = new System.Windows.Forms.ErrorProvider(this.components); this.menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit(); this.SuspendLayout(); @@ -127,14 +130,13 @@ namespace ReportSamples this.emlpoyeesToolStripMenuItem.Text = "Employees-Push"; this.emlpoyeesToolStripMenuItem.Click += new System.EventHandler(this.EmployeesPushClick); // - // errorProvider1 - // - this.errorProvider1.ContainerControl = this; - // // unboundToolStripMenuItem // this.unboundToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.unboundToolStripMenuItem1}); + this.unboundToolStripMenuItem1, + this.unboundPullModelToolStripMenuItem, + this.multipageUnboundPullModelToolStripMenuItem, + this.unboundPuskModelToolStripMenuItem}); this.unboundToolStripMenuItem.Name = "unboundToolStripMenuItem"; this.unboundToolStripMenuItem.Size = new System.Drawing.Size(62, 20); this.unboundToolStripMenuItem.Text = "Unbound"; @@ -142,10 +144,35 @@ namespace ReportSamples // unboundToolStripMenuItem1 // this.unboundToolStripMenuItem1.Name = "unboundToolStripMenuItem1"; - this.unboundToolStripMenuItem1.Size = new System.Drawing.Size(152, 22); + this.unboundToolStripMenuItem1.Size = new System.Drawing.Size(218, 22); this.unboundToolStripMenuItem1.Text = "Unbound"; this.unboundToolStripMenuItem1.Click += new System.EventHandler(this.UnboundToolStripMenuItem1Click); // + // unboundPullModelToolStripMenuItem + // + this.unboundPullModelToolStripMenuItem.Name = "unboundPullModelToolStripMenuItem"; + this.unboundPullModelToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.unboundPullModelToolStripMenuItem.Text = "UnboundPullModel"; + this.unboundPullModelToolStripMenuItem.Click += new System.EventHandler(this.UnboundPullModelToolStripMenuItemClick); + // + // multipageUnboundPullModelToolStripMenuItem + // + this.multipageUnboundPullModelToolStripMenuItem.Name = "multipageUnboundPullModelToolStripMenuItem"; + this.multipageUnboundPullModelToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.multipageUnboundPullModelToolStripMenuItem.Text = "MultipageUnboundPullModel"; + this.multipageUnboundPullModelToolStripMenuItem.Click += new System.EventHandler(this.MultipageUnboundPullModelToolStripMenuItemClick); + // + // unboundPuskModelToolStripMenuItem + // + this.unboundPuskModelToolStripMenuItem.Name = "unboundPuskModelToolStripMenuItem"; + this.unboundPuskModelToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.unboundPuskModelToolStripMenuItem.Text = "UnboundPushModel"; + this.unboundPuskModelToolStripMenuItem.Click += new System.EventHandler(this.UnboundPuskModelToolStripMenuItemClick); + // + // errorProvider1 + // + this.errorProvider1.ContainerControl = this; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -161,6 +188,9 @@ namespace ReportSamples this.ResumeLayout(false); this.PerformLayout(); } + private System.Windows.Forms.ToolStripMenuItem unboundPuskModelToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem multipageUnboundPullModelToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem unboundPullModelToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem unboundToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem unboundToolStripMenuItem; private System.Windows.Forms.ErrorProvider errorProvider1; diff --git a/samples/SharpReport/ReportSamples/MainForm.cs b/samples/SharpReport/ReportSamples/MainForm.cs index 2e5ccd6bf4..01dff8bb5a 100644 --- a/samples/SharpReport/ReportSamples/MainForm.cs +++ b/samples/SharpReport/ReportSamples/MainForm.cs @@ -85,6 +85,7 @@ namespace ReportSamples } } + #region unbound private void OpenUnbound() { try{ OpenFileDialog dg = new OpenFileDialog(); @@ -92,8 +93,8 @@ namespace ReportSamples dg.Title = "Select a report file: "; if (dg.ShowDialog() == DialogResult.OK){ SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine(); - mn.SectionRendering += new EventHandler(OnTestPrinting); - mn.SectionRendered += new EventHandler(OnTestPrinted); + mn.SectionRendering += new EventHandler(UnboundPrinting); + mn.SectionRendered += new EventHandler(UnboundPrinted); mn.PreviewStandartReport(dg.FileName.ToString()); } @@ -103,18 +104,19 @@ namespace ReportSamples } } - private void OnTestPrinting (object sender,SectionRenderEventArgs e) { - System.Console.WriteLine(""); - System.Console.WriteLine("--------------"); - System.Console.WriteLine("MainForm:OnTestPrinting on PageNr <{0}>",e.PageNumber); - System.Console.WriteLine("\t SectionInUse <{0}>",e.CurrentSection); - System.Console.WriteLine("\t <{0}> Items",e.Section.Items.Count); - - + private void UnboundPrinting (object sender,SectionRenderEventArgs e) { +// System.Console.WriteLine(""); +// System.Console.WriteLine("--------------"); +// System.Console.WriteLine("MainForm:OnTestPrinting <{0}> for PageNr <{1}>",e.CurrentSection,e.PageNumber); +// System.Console.WriteLine("\t <{0}> Items",e.Section.Items.Count); +// +// switch (e.CurrentSection) { case GlobalEnums.enmSection.ReportHeader: - System.Console.WriteLine("I found the ReportHeader"); + System.Console.WriteLine("\tI found the ReportHeader"); break; + + case GlobalEnums.enmSection.ReportPageHeader: BaseTextItem t = (BaseTextItem)e.Section.Items.Find("reportTextItem1"); @@ -131,13 +133,23 @@ namespace ReportSamples bb.DbValue = "Hello World"; } - System.Console.WriteLine("I found the Pageheader"); + System.Console.WriteLine("\tI found the Pageheader"); break; + case GlobalEnums.enmSection.ReportDetail: - System.Console.WriteLine("I found the ReportDetail"); + System.Console.WriteLine("\tI found the ReportDetail"); + BaseDataItem bdi = (BaseDataItem)e.Section.Items.Find("reportDbTextItem1"); + if (bdi != null) { + bdi.BackColor = Color.LightGray; + bdi.Location = new Point(200,5); + bdi.DbValue = "Unbound Field in DetailSection"; + } + + break; + case GlobalEnums.enmSection.ReportPageFooter: - System.Console.WriteLine("I found the PageFooter"); + System.Console.WriteLine("\tI found the PageFooter"); BaseReportItem b = (BaseReportItem)e.Section.Items.Find("pageNumber1"); if (b != null) { b.BackColor = Color.AliceBlue; @@ -146,21 +158,26 @@ namespace ReportSamples MessageBox.Show (s); } break; + case GlobalEnums.enmSection.ReportFooter: - System.Console.WriteLine("I found the ReportFooter"); + System.Console.WriteLine("\tI found the ReportFooter"); break; + default: - break; } System.Console.WriteLine(""); } - private void OnTestPrinted (object sender,SectionRenderEventArgs e) { - System.Console.WriteLine("MainForm:OnTestPrinted for <{0}>",e.CurrentSection); + private void UnboundPrinted (object sender,SectionRenderEventArgs e) { +// System.Console.WriteLine("MainForm:Rendering done for <{0}>",e.CurrentSection); System.Console.WriteLine("----------"); } + #endregion + + + ///Preferd Method to initialise the /// hav a look to /// @@ -275,5 +292,22 @@ namespace ReportSamples { this.OpenUnbound(); } + + void UnboundPullModelToolStripMenuItemClick(object sender, System.EventArgs e){ + SimpleUnboundPullModel sm = new SimpleUnboundPullModel(); + sm.Run(); + } + + void MultipageUnboundPullModelToolStripMenuItemClick(object sender, System.EventArgs e) + { + MultiPageUnboundPullModel mp = new MultiPageUnboundPullModel(); + mp.Run(); + } + + void UnboundPuskModelToolStripMenuItemClick(object sender, System.EventArgs e) + { + UnboundPushModel u = new UnboundPushModel(); + u.Run(); + } } } diff --git a/samples/SharpReport/ReportSamples/MultipageUnboundPullModel.cs b/samples/SharpReport/ReportSamples/MultipageUnboundPullModel.cs new file mode 100644 index 0000000000..4aaff798e0 --- /dev/null +++ b/samples/SharpReport/ReportSamples/MultipageUnboundPullModel.cs @@ -0,0 +1,119 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 29.06.2006 + * Time: 13:02 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; + +using System.Windows.Forms; + +using SharpReportCore; + +namespace ReportSamples{ + /// + /// Description of MultipageUnboundPullModel. + /// + public class MultiPageUnboundPullModel{ + int rowNr; + int rowsPerPage; + System.DateTime startTime; + System.DateTime endTime; + + public MultiPageUnboundPullModel(){ + } + + public void Run() { + try{ + OpenFileDialog dg = new OpenFileDialog(); + dg.Filter = "SharpReport files|*.srd"; + dg.Title = "Select a report file: "; + if (dg.ShowDialog() == DialogResult.OK){ + SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine(); + mn.SectionRendering += new EventHandler(MultipagePrinting); + mn.SectionRendered += new EventHandler(MultipagePrinted); + this.startTime = System.DateTime.Now; + + mn.PreviewStandartReport(dg.FileName.ToString()); + } + } + catch(Exception er){ + MessageBox.Show(er.ToString(),"MainForm"); + } + } + + + private void MultipagePrinting (object sender,SectionRenderEventArgs e) { + System.Console.WriteLine("UnboundPullPrinting"); + CheckItems(e.Section.Items); + switch (e.CurrentSection) { + case GlobalEnums.enmSection.ReportHeader: + System.Console.WriteLine("\tReportHeader"); + break; + + case GlobalEnums.enmSection.ReportPageHeader: + + System.Console.WriteLine("\tPageheader"); + System.Console.WriteLine(""); + this.rowsPerPage = 0; + break; + + case GlobalEnums.enmSection.ReportDetail: + + this.rowNr ++; + this.rowsPerPage ++; + System.Console.WriteLine("\tReportDetail"); + RowItem ri = e.Section.Items[0] as RowItem; + if (ri != null) { + if (this.rowNr %2 == 0) { + ri.DrawBorder = true; + } else { + ri.DrawBorder = false; + } + } + break; + + case GlobalEnums.enmSection.ReportPageFooter: + System.Console.WriteLine("\tPageFooter"); + BaseDataItem bdi = e.Section.Items.Find("ItemsPerPage") as BaseDataItem; + if (bdi != null) { + bdi.DbValue = this.rowsPerPage.ToString(); + } + break; + + case GlobalEnums.enmSection.ReportFooter: + System.Console.WriteLine("\tReportFooter"); + this.endTime = System.DateTime.Now; + + BaseDataItem b = e.Section.Items.Find("reportDbTextItem1")as BaseDataItem; + if (b != null) { + b.FormatString = "t"; + b.DbValue = (this.endTime - this.startTime).ToString(); + } + + break; + + default: + break; + } + } + + private void MultipagePrinted (object sender,SectionRenderEventArgs e) { +// System.Console.WriteLine("---Rendering done <{0}>-----",e.CurrentSection); + } + + private void CheckItems (ReportItemCollection items) { +// System.Console.WriteLine("\t<{0}> Items",items.Count ); + foreach (BaseReportItem i in items) { + IContainerItem container = i as IContainerItem; + if (container != null) { +// System.Console.WriteLine("\t\tContainer found"); + CheckItems (container.Items); + } + } + } + } +} diff --git a/samples/SharpReport/ReportSamples/ReportSamples.csproj b/samples/SharpReport/ReportSamples/ReportSamples.csproj index a9f9b69473..f3eb5a777c 100644 --- a/samples/SharpReport/ReportSamples/ReportSamples.csproj +++ b/samples/SharpReport/ReportSamples/ReportSamples.csproj @@ -48,6 +48,9 @@ MainForm.cs + + + diff --git a/samples/SharpReport/ReportSamples/SimpleUnboundPullModel.cs b/samples/SharpReport/ReportSamples/SimpleUnboundPullModel.cs new file mode 100644 index 0000000000..085082899f --- /dev/null +++ b/samples/SharpReport/ReportSamples/SimpleUnboundPullModel.cs @@ -0,0 +1,98 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 29.06.2006 + * Time: 09:21 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; +using System.Windows.Forms; + +using SharpReportCore; +namespace ReportSamples +{ + /// + /// Description of SimpleUnboundPullModel. + /// + public class SimpleUnboundPullModel{ + int rowNr; + + public SimpleUnboundPullModel(){ + + } + public void Run() { + try{ + OpenFileDialog dg = new OpenFileDialog(); + dg.Filter = "SharpReport files|*.srd"; + dg.Title = "Select a report file: "; + if (dg.ShowDialog() == DialogResult.OK){ + SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine(); + mn.SectionRendering += new EventHandler(SimplePullPrinting); + mn.SectionRendered += new EventHandler(SimplePullPrinted); + mn.PreviewStandartReport(dg.FileName.ToString()); + + } + } + catch(Exception er){ + MessageBox.Show(er.ToString(),"MainForm"); + } + } + private void SimplePullPrinting (object sender,SectionRenderEventArgs e) { + System.Console.WriteLine("UnboundPullPrinting"); + CheckItems(e.Section.Items); + switch (e.CurrentSection) { + case GlobalEnums.enmSection.ReportHeader: + System.Console.WriteLine("\tI found the ReportHeader"); + break; + + case GlobalEnums.enmSection.ReportPageHeader: + + System.Console.WriteLine("\tI found the Pageheader"); + break; + + case GlobalEnums.enmSection.ReportDetail: + System.Console.WriteLine("\tI found the ReportDetail"); + this.rowNr ++; + RowItem ri = e.Section.Items[0] as RowItem; + if (ri != null) { + if (this.rowNr %2 == 0) { + ri.DrawBorder = true; + } else { + ri.DrawBorder = false; + } + } + break; + + case GlobalEnums.enmSection.ReportPageFooter: + System.Console.WriteLine("\tI found the PageFooter"); + break; + + case GlobalEnums.enmSection.ReportFooter: + System.Console.WriteLine("\tI found the ReportFooter"); + break; + + default: + break; + } + } + + private void SimplePullPrinted (object sender,SectionRenderEventArgs e) { +//// System.Console.WriteLine("MainForm:Rendering done for <{0}>",e.CurrentSection); +// System.Console.WriteLine("----------"); + } + + private void CheckItems (ReportItemCollection items) { +// System.Console.WriteLine("\t<{0}> Items",items.Count ); + foreach (BaseReportItem i in items) { + IContainerItem container = i as IContainerItem; + if (container != null) { +// System.Console.WriteLine("\t\tContainer found"); + CheckItems (container.Items); + } + } + } + } +} diff --git a/samples/SharpReport/ReportSamples/UnboundPushModel.cs b/samples/SharpReport/ReportSamples/UnboundPushModel.cs new file mode 100644 index 0000000000..ce78f8b00c --- /dev/null +++ b/samples/SharpReport/ReportSamples/UnboundPushModel.cs @@ -0,0 +1,129 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 10.07.2006 + * Time: 13:15 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Data; +using System.Windows.Forms; + +using SharpReportCore; + +namespace ReportSamples +{ + /// + /// Description of UnboundPushModel. + /// + public class UnboundPushModel + { + int rowNr; + + public UnboundPushModel() + { + } + + public void Run() { + string reportFileName; + try + { + OpenFileDialog dg = new OpenFileDialog(); + dg.Filter = "SharpReport files|*.srd"; + dg.Title = "Select a report file: "; + if (dg.ShowDialog() == DialogResult.OK){ + SharpReportCore.SharpReportEngine engine = new SharpReportCore.SharpReportEngine(); + reportFileName = dg.FileName.ToString(); + DataTable table = SelectData(); + + if (table != null) { + engine.SectionRendering += new EventHandler(PushPrinting); + engine.SectionRendered += new EventHandler(PushPrinted); + engine.PreviewPushDataReport(reportFileName,table); +// engine.PrintPushDataReport(reportFileName,table); + } + } + } + catch (Exception){ + } + } + + + + private DataTable SelectData() + { + OpenFileDialog dg = new OpenFileDialog(); + dg.Filter = "SharpReport files|*.xsd"; + dg.Title = "Select a '.xsdfile: "; + if (dg.ShowDialog() == DialogResult.OK){ + DataSet ds = new DataSet(); + ds.ReadXml(dg.FileName); + return ds.Tables[0]; + } + return null; + } + + private void PushPrinting (object sender,SectionRenderEventArgs e) { + System.Console.WriteLine("UnboundPushModel"); + CheckItems(e.Section.Items); + switch (e.CurrentSection) { + case GlobalEnums.enmSection.ReportHeader: + System.Console.WriteLine("\tReportHeader"); + break; + + case GlobalEnums.enmSection.ReportPageHeader: + + System.Console.WriteLine("\tPageheader"); + System.Console.WriteLine(""); + break; + + case GlobalEnums.enmSection.ReportDetail: + + this.rowNr ++; + System.Console.WriteLine("\tReportDetail"); + RowItem ri = e.Section.Items[0] as RowItem; + if (ri != null) { + if (this.rowNr %2 == 0) { + ri.DrawBorder = true; + } else { + ri.DrawBorder = false; + } + } + break; + + case GlobalEnums.enmSection.ReportPageFooter: + System.Console.WriteLine("\tPageFooter"); + break; + + case GlobalEnums.enmSection.ReportFooter: + System.Console.WriteLine("\tReportFooter"); + BaseDataItem b = e.Section.Items.Find("ReportDbTextItem")as BaseDataItem; + if (b != null) { + b.DbValue = this.rowNr.ToString(); + } + + break; + + default: + break; + } + } + + private void PushPrinted (object sender,SectionRenderEventArgs e) { +// System.Console.WriteLine("---Rendering done <{0}>-----",e.CurrentSection); + } + + private void CheckItems (ReportItemCollection items) { + foreach (BaseReportItem i in items) { +// System.Console.WriteLine("\tItem {0}",i.Name); + IContainerItem container = i as IContainerItem; + if (container != null) { +// System.Console.WriteLine("\t\tContainer found"); + CheckItems (container.Items); + } + } + } + } +} diff --git a/samples/SharpReport/Unbound/MultiPageUnboundPullModel.srd b/samples/SharpReport/Unbound/MultiPageUnboundPullModel.srd new file mode 100644 index 0000000000..ec59972661 --- /dev/null +++ b/samples/SharpReport/Unbound/MultiPageUnboundPullModel.srd @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/samples/SharpReport/Unbound/PushModel/EmployesData.xsd b/samples/SharpReport/Unbound/PushModel/EmployesData.xsd new file mode 100644 index 0000000000..25171a12e6 Binary files /dev/null and b/samples/SharpReport/Unbound/PushModel/EmployesData.xsd differ diff --git a/samples/SharpReport/Unbound/PushModel/UnboundEmployees.srd b/samples/SharpReport/Unbound/PushModel/UnboundEmployees.srd new file mode 100644 index 0000000000..900921d70c --- /dev/null +++ b/samples/SharpReport/Unbound/PushModel/UnboundEmployees.srd @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/samples/SharpReport/Unbound/UnboundPullModel.srd b/samples/SharpReport/Unbound/UnboundPullModel.srd new file mode 100644 index 0000000000..f02e44474a --- /dev/null +++ b/samples/SharpReport/Unbound/UnboundPullModel.srd @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/NameService.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/NameService.cs index 71d6abafb3..db0c7721b4 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/NameService.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/NameService.cs @@ -34,6 +34,10 @@ namespace SharpReport { public string CreateName (ReportItemCollection collection, string typeName) { + + if (String.IsNullOrEmpty(typeName)) { + throw new ArgumentNullException("typeName"); + } string name = Char.ToLower(typeName[0], CultureInfo.InvariantCulture) + typeName.Substring(1); @@ -42,7 +46,6 @@ namespace SharpReport { while (collection.Find(name + number.ToString(CultureInfo.InvariantCulture)) != null) { ++number; } - return name + number.ToString(); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs index bd5b563f04..ca639ea0a5 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs @@ -188,7 +188,8 @@ namespace SharpReport.Designer{ baseReportItem.Name = nameService.CreateName(itemCollection, baseReportItem.Name); - +System.Console.WriteLine("Report:CustomizeItem Name {0}",baseReportItem.Name); + if (baseReportItem.Parent == this.selectedSection) { baseReportItem.Location = new Point(iddea.ItemAtPoint.X,iddea.ItemAtPoint.Y); } else { diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSectionControlbase.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSectionControlbase.cs index 9279a5ea91..7b87ca33b6 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSectionControlbase.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSectionControlbase.cs @@ -339,8 +339,9 @@ namespace SharpReport.Designer{ private bool CheckDraggedControl (DragEventArgs dea) { string str = this.DragObjectToString (dea); + System.Console.WriteLine("ReportSectionControlBase"); + System.Console.WriteLine("valid {0}",this.designableFactory.Contains(str)); return this.designableFactory.Contains(str); - } private bool CheckDragElement (System.Windows.Forms.DragEventArgs dea) { diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SideTab/BuildSideTab.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SideTab/BuildSideTab.cs index e7978d0bae..f40fbbb287 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SideTab/BuildSideTab.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SideTab/BuildSideTab.cs @@ -96,6 +96,8 @@ namespace SharpReport // GlobalValues.RectangleBitmap()); tab.Items.Add (t); + + // bitmap = ResourceService.GetIcon("Icons.16.16.SharpReport.Line").ToBitmap(); t = sideTab.SideTabItemFactory.CreateSideTabItem( ResourceService.GetString("SharpReport.Toolbar.Line"), GlobalEnums.ReportItemType.ReportLineItem.ToString(), @@ -105,6 +107,15 @@ namespace SharpReport GlobalEnums.ReportItemType.ReportCircleItem.ToString(), GlobalValues.CircleBitmap()); tab.Items.Add (t); + + //Test + /* + t = sideTab.SideTabItemFactory.CreateSideTabItem( "Table", + GlobalEnums.ReportItemType.ReportTableItem.ToString(), + ResourceService.GetBitmap("Icons.16x16.SharpQuery.Table")); + tab.Items.Add (t); + */ + // } private void AddFunctionElements (AxSideTab tab) { diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs index efd5740c4e..bade07e18e 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs @@ -77,6 +77,19 @@ namespace SharpReport.Designer } + + + public static void DrawHeadLine (Control ctrl, PaintEventArgs pea) { + + StringFormat fmt = SharpReportCore.GlobalValues.StandartStringFormat(); + fmt.LineAlignment = StringAlignment.Near; + pea.Graphics.DrawString(ctrl.Name, + ctrl.Font, + new SolidBrush(ctrl.ForeColor), + new Rectangle(7,0,pea.ClipRectangle.Width,(int)ctrl.Font.GetHeight(pea.Graphics) + 2), + fmt); + } + /// /// Set the Controls to selected = false, so the Focusrectangle is /// not draw diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/RectTracker.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/RectTracker.cs index 9a9b3d5de4..d0b1b2c5c9 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/RectTracker.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/RectTracker.cs @@ -281,6 +281,7 @@ namespace SharpReport.Designer // convert cursor position to client co-ordinates // do hittest and normalize hit int nHandle = (int)HitTestHandles(MousePoint); + System.Console.WriteLine("RectTracker SetCursor {0}",nHandle); if (nHandle < 0) return false; diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs index 9eeafb7cbd..41feb0858f 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs @@ -50,14 +50,8 @@ namespace SharpReport.Designer{ new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1), base.FocusRectangle); } + ControlHelper.DrawHeadLine(this,pea); - StringFormat fmt = GlobalValues.StandartStringFormat(); - fmt.LineAlignment = StringAlignment.Near; - pea.Graphics.DrawString(this.Name, - this.Font, - new SolidBrush(this.ForeColor), - new Rectangle(7,0,pea.ClipRectangle.Width,(int)this.Font.GetHeight(pea.Graphics) + 2), - fmt); } public override string ToString() { @@ -84,7 +78,7 @@ namespace SharpReport.Designer{ // ReportRectangleControl // this.BackColor = System.Drawing.Color.White; - this.Name = "RowItem"; + this.Name = "Row"; this.Size = new System.Drawing.Size(72, 40); } #endregion diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTableControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTableControl.cs new file mode 100644 index 0000000000..a85d1c8978 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTableControl.cs @@ -0,0 +1,118 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 09.07.2006 + * Time: 15:39 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.ComponentModel; +using System.Drawing; +using System.Windows.Forms; + +using SharpReportCore; + +namespace SharpReport.Designer +{ + /// + /// Description of ReportTableControl. + /// + public class ReportTableControl:ContainerControl + { + private RectangleShape shape = new RectangleShape(); + private bool drawBorder; + public ReportTableControl() + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + this.SetStyle(ControlStyles.DoubleBuffer | + ControlStyles.UserPaint | + ControlStyles.AllPaintingInWmPaint | + ControlStyles.ResizeRedraw, + true); + this.UpdateStyles(); + int h,w; + h = GlobalValues.PreferedSize.Height * 3 + 30; + w = (GlobalValues.PreferedSize.Width * 2) + 10; + +// this.Size = new Size(w,h); + } + + #region overrides + protected override void OnPaint(PaintEventArgs pea){ + + + base.OnPaint(pea); + base.DrawEdges (pea, + new Rectangle(0,5, + this.ClientSize.Width - 1,this.ClientSize.Height - 6) ); + + ControlHelper.DrawHeadLine(this,pea); + } + + + + public override string ToString() { + + return this.GetType().Name; + } + + + + #endregion + + public bool DrawBorder { + set { + drawBorder = value; + this.Invalidate(); + } + } + #region FormsDesigner + + /// + /// Designer variable used to keep track of non-visual components. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Disposes resources used by the control. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) { + if (components != null) { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// 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. + /// + private void InitializeComponent() + { + + this.SuspendLayout(); + + // + // ReportTableControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + + this.Name = "Table"; + this.Size = new System.Drawing.Size(200,40); + this.ResumeLayout(false); + } + + #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 d4ae82201f..ff08245be7 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs @@ -38,6 +38,7 @@ namespace SharpReport.ReportItems.Functions { this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (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 8b6f7dbdff..ec75be62a4 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs @@ -44,6 +44,7 @@ namespace SharpReport.ReportItems.Functions { this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportCircleItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportCircleItem.cs index 05d6449390..df9c8a319f 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportCircleItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportCircleItem.cs @@ -34,10 +34,11 @@ namespace SharpReport.ReportItems{ public ReportCircleItem() : base(){ visualControl = new ReportCircleControl(); - ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); +// ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportImageItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportImageItem.cs index 6498a581b6..326d073fd3 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportImageItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportImageItem.cs @@ -37,6 +37,7 @@ namespace SharpReport.ReportItems { this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnControlChanged); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); base.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (BasePropertyChange); diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportLineItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportLineItem.cs index 2862d989b3..4777eae801 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportLineItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportLineItem.cs @@ -33,10 +33,11 @@ namespace SharpReport.ReportItems{ /// public ReportLineItem():base() { visualControl = new ReportLineControl(); - ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); +// ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportRectangleItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportRectangleItem.cs index 0a60a0cd03..0ff3e2870a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportRectangleItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/GraphicBased/ReportRectangleItem.cs @@ -35,10 +35,11 @@ namespace SharpReport.ReportItems{ public ReportRectangleItem():base() { visualControl = new ReportRectangleControl(); - ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); +// ItemsHelper.UpdateBaseFromGraphicControl (this.visualControl,this); this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs index 85e3bc396f..78d0bafb09 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs @@ -25,14 +25,13 @@ namespace SharpReport { internal static void UpdateBaseFromTextControl (ReportObjectControlBase control, BaseReportItem item) { - + item.Size = control.Size; - item.Location = control.Location; + item.Location = new System.Drawing.Point (control.Location.X,control.Location.Y); item.Name = control.Name; item.BackColor = control.BackColor; item.ForeColor = control.ForeColor; item.Font = control.Font; - } internal static void UpdateBaseFromGraphicControl (AbstractGraphicControl control, @@ -63,5 +62,7 @@ namespace SharpReport { control.DashStyle = item.DashStyle; control.Thickness = item.Thickness; } + + } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs index 8ea05ec9e0..735de782ef 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs @@ -44,10 +44,11 @@ namespace SharpReport.ReportItems{ visualControl.ContentAlignment = base.ContentAlignment; visualControl.StringTrimming = base.StringTrimming; - ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); +// ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportRowItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportRowItem.cs index 965837f8b9..e591f8d4f0 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportRowItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportRowItem.cs @@ -38,10 +38,11 @@ namespace SharpReport.ReportItems private void Setup(){ visualControl = new ReportRowControl(); - ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); +// ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnAppereanceChanged); @@ -61,19 +62,20 @@ namespace SharpReport.ReportItems 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 (! base.Suspend) { ItemsHelper.UpdateControlFromTextBase (this.visualControl,this); this.HandlePropertyChanged(e.PropertyName); } } - + #endregion private void UpdateChilds () { @@ -88,6 +90,7 @@ namespace SharpReport.ReportItems #region EventHandling for this Class + private void OnAdd (object sender, CollectionItemEventArgs e){ IDesignable des = e.Item as IDesignable; if (des != null) { @@ -155,8 +158,9 @@ namespace SharpReport.ReportItems PropertyChanged (this,new PropertyChangedEventArgs(info)); } } - } + + #endregion #region IDesignable @@ -219,6 +223,8 @@ namespace SharpReport.ReportItems return this.GetType().Name; } + + #endregion /* diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTableItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTableItem.cs new file mode 100644 index 0000000000..521a0166a9 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTableItem.cs @@ -0,0 +1,158 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 09.07.2006 + * Time: 15:51 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.ComponentModel; + +using SharpReport.Designer; +using SharpReportCore; + +namespace SharpReport.ReportItems{ + /// + /// Description of ReportTableItem. + /// + public class ReportTableItem:TableItem ,IDesignable{ + private ReportTableControl visualControl; + + + #region Constructor + public ReportTableItem():this (GlobalValues.UnboundName){ + + } + + public ReportTableItem (string tableName):base(tableName) { + Setup(); + } + + private void Setup (){ + visualControl = new ReportTableControl(); +// ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); +// + this.visualControl.Click += new EventHandler(OnControlSelect); + this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); + + +// //Event from Tracker + this.visualControl.PropertyChanged += new PropertyChangedEventHandler (ControlPropertyChange); +// + base.PropertyChanged += new PropertyChangedEventHandler (BasePropertyChange); +// + base.Items.Added += OnAdd; + base.Items.Removed += OnRemove; + System.Console.WriteLine("ReporttableItem ctrlName {0}",this.visualControl.Name); + } + #endregion + + #region List Handling + private void ChildSelected(object sender, EventArgs e){ + if (Selected != null) + Selected(sender,e); + } + + private void ChildPropertyChange (object sender, PropertyChangedEventArgs e){ + if (! base.Suspend) { + ItemsHelper.UpdateControlFromTextBase (this.visualControl,this); + this.HandlePropertyChanged(e.PropertyName); + } + } + + private void OnAdd (object sender, CollectionItemEventArgs 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 e){ + + IDesignable des = e.Item as IDesignable; + if (des != null) { + this.visualControl.Controls.Remove(des.VisualControl); + des.Selected -= ChildSelected; + this.HandlePropertyChanged("OnChildControlRemoved"); + } + } + + #endregion + public override string ToString() { + return this.GetType().Name; + } + #region Events from Control + //Tracker + + private void ControlPropertyChange (object sender, PropertyChangedEventArgs e){ + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + this.HandlePropertyChanged(e.PropertyName); + } + + private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ + ItemsHelper.UpdateControlFromTextBase (this.visualControl,this); + this.visualControl.DrawBorder = base.DrawBorder; + this.HandlePropertyChanged(e.PropertyName); + } + + + private void OnControlChanged (object sender, EventArgs e) { + this.SuspendLayout(); + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + + this.ResumeLayout(); + this.HandlePropertyChanged("OnControlChanged"); + + } + + private void OnAppereanceChanged (object sender, EventArgs e) { + this.SuspendLayout(); + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + this.ResumeLayout(); +// UpdateChilds(); + + this.HandlePropertyChanged("OnControlChanged"); + } + + private void OnControlSelect(object sender, EventArgs e){ + if (Selected != null) + System.Console.WriteLine("fire selected"); + Selected(this,e); + } + + /// + /// A Property in ReportItem has changed, inform the Designer + /// to set the View's 'IsDirtyFlag' to true + /// + + 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 Selected; + #endregion + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs index 4105b46f74..735786bb96 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs @@ -36,9 +36,12 @@ namespace SharpReport.ReportItems { visualControl.ContentAlignment = base.ContentAlignment; visualControl.StringTrimming = base.StringTrimming; - ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); +// ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); + this.visualControl.Click += new EventHandler(OnControlSelect); + this.visualControl.LocationChanged += new EventHandler (OnControlChanged); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); @@ -49,11 +52,10 @@ namespace SharpReport.ReportItems { base.PropertyChanged += new PropertyChangedEventHandler (BasePropertyChange); } - + #endregion - #region events //Tracker @@ -67,7 +69,6 @@ namespace SharpReport.ReportItems { this.visualControl.ContentAlignment = base.ContentAlignment; this.visualControl.StringTrimming = base.StringTrimming; this.visualControl.DrawBorder = base.DrawBorder; - this.HandlePropertyChanged(e.PropertyName); } @@ -76,7 +77,7 @@ namespace SharpReport.ReportItems { base.SuspendLayout(); ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); base.ResumeLayout(); - this.HandlePropertyChanged("OnControlSelected"); + this.HandlePropertyChanged("OnControlChanged"); } @@ -113,7 +114,7 @@ namespace SharpReport.ReportItems { this.HandlePropertyChanged("Location"); } } - + public override Font Font { get { return base.Font; diff --git a/src/AddIns/Misc/SharpReport/SharpReport/SharpReport.csproj b/src/AddIns/Misc/SharpReport/SharpReport/SharpReport.csproj index 678de30687..e849ffbadd 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/SharpReport.csproj +++ b/src/AddIns/Misc/SharpReport/SharpReport/SharpReport.csproj @@ -90,6 +90,8 @@ + +
diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseClasses/DataTypeHelper.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseClasses/DataTypeHelper.cs new file mode 100644 index 0000000000..01e4ffc5e6 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseClasses/DataTypeHelper.cs @@ -0,0 +1,81 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 27.06.2006 + * Time: 09:12 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; + +namespace SharpReportCore +{ + /// + /// Description of DataType. + /// + internal class DataTypeHelper{ + + //TODO why not use + // TypeCode tc = Type.GetTypeCode( Type.GetType("System.String")); + + internal static TypeCode TypeCodeFromString (string type) { + TypeCode tc; + + if (type == null) { + type = "System.String"; + } + + if (type.StartsWith("System.")){ + type = type.Substring(7); + } + + switch (type){ + case "DateTime": + tc = TypeCode.DateTime; + break; + + case "Boolean": + tc = TypeCode.Boolean; + break; + + + case "String": + case "Char": + tc = TypeCode.String; + break; + + case "Decimal": + tc = TypeCode.Decimal; + break; + case "Integer": + case "Int16": + case "Int32": + tc = TypeCode.Int32; + break; + case "Float": + case "Single": + case "Double": + tc = TypeCode.Double; + break; + + default: + tc = TypeCode.Object; + break; + } + return tc; + } + + static internal bool IsNumber(TypeCode tc){ + + switch (tc){ + case TypeCode.Int32: + case TypeCode.Double: + case TypeCode.Decimal: + return true; + default: // user error + return false; + } + } + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs index c05ff37e96..647d0832d9 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs @@ -33,13 +33,16 @@ namespace SharpReportCore { private string dataType; private string nullValue; + #region Constructor public BaseDataItem():base() { + this.dataType = "System.String"; } public BaseDataItem(string columnName):base(){ this.columnName = columnName; + this.dataType = "System.String"; } #endregion @@ -63,12 +66,17 @@ namespace SharpReportCore { public override void Render(SharpReportCore.ReportPageEventArgs rpea) { - // this.DbValue is formatted in the BeforePrintEvent catched in AbstractRenderer +// TypeCode tc = Type.GetTypeCode( Type.GetType(this.dataType)); + + // TODO this.DbValue should beformatted in the BeforePrintEvent string toPrint = CheckForNullValue(); - base.Text = base.FireFormatOutput(toPrint,this.FormatString,""); -// System.Console.WriteLine("\tBaseDataItem <{0}> / <{1}>",this.Name,this.Text); + + base.Text = base.FormatOutput(toPrint, + this.FormatString, + DataTypeHelper.TypeCodeFromString (this.dataType), + this.nullValue); base.Render (rpea); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseFunction.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseFunction.cs index 8ce9328e4e..6cb1046b1e 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseFunction.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseFunction.cs @@ -26,6 +26,7 @@ namespace SharpReportCore { public BaseFunction():base() { this.localisedName = "SharpReport.Toolbar.Functions"; } + public BaseFunction(string friendlyName) { this.localisedName = friendlyName; @@ -38,7 +39,7 @@ namespace SharpReportCore { #region properties - + [Browsable(false)] public string LocalisedName { get { return localisedName; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs index fd9992fc38..1cb2f28926 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs @@ -31,33 +31,12 @@ namespace SharpReportCore { public event EventHandler ItemPrinting; public event EventHandler ItemPrinted; - public event EventHandler FormatOutput; public event EventHandler Disposed; public BaseReportItem() :base(){ } - #region Event's handling - /// - /// Format a string according to his datatype - /// - /// The String to Format - /// the formatString - /// Value to return when there is null in toFormat - /// - protected string FireFormatOutput(string toFormat,string format, string nullValue) { - if (FormatOutput != null) { - FormatOutputEventArgs ea = new FormatOutputEventArgs (toFormat, - format, - nullValue); - FormatOutput (this,ea); - return ea.FormatedValue; - } - return toFormat; - } - - #endregion #region EventHandling diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs index bfaf0c8399..b08c0c93b2 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs @@ -28,20 +28,30 @@ namespace SharpReportCore { private string formatString = String.Empty; private StringFormat stringFormat; private StringTrimming stringTrimming; - private TextDrawer textDrawer = new TextDrawer(); + private TextDrawer textDrawer; + private StandardFormatter standartFormatter; private ContentAlignment contentAlignment; private RectangleShape shape = new RectangleShape(); #region Constructor public BaseTextItem():base() { - this.stringFormat = StringFormat.GenericTypographic; - this.contentAlignment = ContentAlignment.MiddleLeft; - this.stringTrimming = StringTrimming.EllipsisCharacter; + this.stringFormat = StringFormat.GenericTypographic; + this.contentAlignment = ContentAlignment.MiddleLeft; + this.stringTrimming = StringTrimming.EllipsisCharacter; + this.textDrawer = new TextDrawer(); + this.standartFormatter = new StandardFormatter(); } #endregion + protected string FormatOutput(string valueToFormat,string formatString, + TypeCode typeCode, string nullValue ){ + + return standartFormatter.FormatItem(valueToFormat,formatString, + typeCode,nullValue); + } + public override void Render(ReportPageEventArgs rpea) { @@ -119,7 +129,7 @@ namespace SharpReportCore { this.stringTrimming,this.contentAlignment); - rpea.LocationAfterDraw = new PointF (this.Location.X + this.Size.Width, + rpea.LocationAfterDraw = new Point (this.Location.X + this.Size.Width, this.Location.Y + this.Size.Height); } @@ -164,7 +174,7 @@ namespace SharpReportCore { } [Category("Appearance")] - public System.Drawing.ContentAlignment ContentAlignment { + public virtual System.Drawing.ContentAlignment ContentAlignment { get { return this.contentAlignment; } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs index 3970b77d41..6a2037dfc9 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs @@ -27,16 +27,18 @@ namespace SharpReportCore { static string fnName = "SharpReport.Toolbar.Functions.PageNumber"; public BasePageNumber():base(fnName) { +// System.Console.WriteLine("!! PageNr created with name {0}",this.Name); } public override void Render(ReportPageEventArgs rpea) { base.Render(rpea); - string formattedString = base.FireFormatOutput(rpea.PageNumber.ToString(CultureInfo.InvariantCulture), - base.FormatString,""); + string formattedString = base.FormatOutput(rpea.PageNumber.ToString(CultureInfo.InvariantCulture), + this.FormatString, + TypeCode.Int32, + "xxxx"); - RectangleF rect = base.PrepareRectangle (rpea,formattedString); //Printout the textpart base.PrintTheStuff (rpea,this.Text,rect); @@ -44,13 +46,13 @@ namespace SharpReportCore { StringFormat fmt = StringFormat; fmt.Alignment = StringAlignment.Far; - fmt.LineAlignment = StringAlignment.Near; - rpea.PrintPageEventArgs.Graphics.DrawString(rpea.PageNumber.ToString(CultureInfo.InvariantCulture), - this.Font, - Brushes.Black, - rect, - fmt); - + fmt.LineAlignment = StringAlignment.Center; + + rpea.PrintPageEventArgs.Graphics.DrawString(formattedString, + this.Font, + Brushes.Black, + rect, + fmt); base.NotiyfyAfterPrint (rpea.LocationAfterDraw); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs index 8401c81d3f..9ffd5284eb 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs @@ -9,6 +9,7 @@ //------------------------------------------------------------------------------ using System; using System.Drawing; +using System.ComponentModel; using System.Globalization; /// /// BaseClass for Today's Date @@ -28,9 +29,17 @@ namespace SharpReportCore { public override void Render(ReportPageEventArgs rpea) { base.Render(rpea); - - string formattedString = FormatAsDate(System.DateTime.Now.ToString(),base.FormatString); + string f; + if (String.IsNullOrEmpty(this.FormatString)) { + f = "d"; + } else { + f = this.FormatString; + } + string formattedString = base.FormatOutput(System.DateTime.Now.ToString(CultureInfo.CurrentCulture), + f, + TypeCode.DateTime, + ""); RectangleF rect = base.PrepareRectangle (rpea,formattedString); //Printout the textPart @@ -39,42 +48,30 @@ namespace SharpReportCore { //here we print the functionpart allway's with Stringalignment.Far StringFormat fmt = StringFormat; fmt.Alignment = StringAlignment.Far; - fmt.LineAlignment = StringAlignment.Near; - + fmt.LineAlignment = StringAlignment.Center; rpea.PrintPageEventArgs.Graphics.DrawString(formattedString, - this.Font, - Brushes.Black, - rect, - fmt); + this.Font, + Brushes.Black, + rect, + fmt); - // goon + // goon base.NotiyfyAfterPrint (rpea.LocationAfterDraw); } public override string ToString() { return "BaseToday"; } - - - #region privates - private string FormatAsDate (string toFormat,string formatWith) { - if (toFormat.Length == 0) { - return String.Empty; - } - if (formatWith.Length == 0) { - return toFormat; + + [Browsable(false)] + public override ContentAlignment ContentAlignment { + get { + return base.ContentAlignment; } - try { - DateTime date = DateTime.Parse (toFormat.Trim(), - CultureInfo.CurrentCulture.DateTimeFormat); - string str = date.ToString(formatWith, - DateTimeFormatInfo.CurrentInfo); - return str; - } catch (Exception) { - throw; + set { + base.ContentAlignment = value; } - } - #endregion + } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs index c26753c0ca..9a12aa2234 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs @@ -62,15 +62,15 @@ namespace SharpReportCore { if (this.image != null) { if (this.scaleImageToSize) { g.DrawImageUnscaled(image,0,0); - rpea.LocationAfterDraw = new PointF (this.Location.X + this.image.Width, + rpea.LocationAfterDraw = new Point (this.Location.X + this.image.Width, this.Location.Y + this.image.Height); } else { SizeF measureSize = base.MeasureReportItem (rpea,this); RectangleF rect = base.DrawingRectangle (rpea,measureSize); g.DrawImage(image, rect); - rpea.LocationAfterDraw = new PointF (this.Location.X + rect.Width, - this.Location.Y + rect.Height); + rpea.LocationAfterDraw = new Point (this.Location.X + (int)rect.Width, + this.Location.Y + (int)rect.Height); } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs index 728b91fe2d..a1a22d294d 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs @@ -11,17 +11,28 @@ using System; using System.ComponentModel; using System.Windows.Forms; -namespace SharpReportCore.BaseItems { +namespace SharpReportCore { /// /// Description of TableItem. /// public class TableItem :BaseReportItem,IContainerItem{ private Padding padding; -// private string tableName; + private string tableName; + private ReportItemCollection items; - public TableItem(){ + public TableItem():this (GlobalValues.UnboundName){ + } + + public TableItem(string tableName){ + this.tableName = tableName; + } + + #region overrides + public override string ToString(){ + return this.GetType().Name; } + #endregion /* @@ -35,7 +46,10 @@ namespace SharpReportCore.BaseItems { // } } */ + + #region Interface implementation of 'IContainerItem' + public System.Windows.Forms.Padding Padding { get { return this.padding; @@ -48,7 +62,10 @@ namespace SharpReportCore.BaseItems { public ReportItemCollection Items { get { - throw new NotImplementedException(); + if (this.items == null) { + this.items = new ReportItemCollection(); + } + return this.items; } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseSettings.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseSettings.cs index 8aeb98dc2e..84afeb6396 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseSettings.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseSettings.cs @@ -110,7 +110,6 @@ namespace SharpReportCore { protected void NotifyPropertyChanged(string info) { if (this.initDone) { if (PropertyChanged != null) { - System.Console.WriteLine("BaseSettings : PropertyChanged {0}",info); PropertyChanged (this,new PropertyChangedEventArgs (info)); } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Events/ReportPageEventArgs.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Events/ReportPageEventArgs.cs index eaf4abca17..048a5194a1 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Events/ReportPageEventArgs.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Events/ReportPageEventArgs.cs @@ -31,12 +31,12 @@ namespace SharpReportCore { int pageNumber; bool forceNewPage; - PointF locationAfterDraw; + Point locationAfterDraw; public ReportPageEventArgs(PrintPageEventArgs e, int pageNumber, bool forceNewPage, - PointF locationAfterDraw){ + Point locationAfterDraw){ this.printEventArgs = e; this.pageNumber = pageNumber; @@ -67,7 +67,7 @@ namespace SharpReportCore { } - public PointF LocationAfterDraw { + public Point LocationAfterDraw { get { return locationAfterDraw; } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs index 31289577e5..fbd9f390bd 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs @@ -48,7 +48,8 @@ namespace SharpReportCore { ReportLineItem, ReportCircleItem, PageNumber, - TodaysDate + TodaysDate, + ReportTableItem } /// /// FormSheet means a blank form with Labels, Lines and Checkboxes diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs index 744a7fe316..61ab5eb45a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs @@ -33,6 +33,7 @@ namespace SharpReportCore { private static string xsdExtension = "xsd"; private static string sharpReportStandartFileName = "SharpReport1"; private const string unbound = "unbound"; + private const string tableName = "Table"; private const int enlargeControl = 5; #region some usefull functions and methodes @@ -169,6 +170,13 @@ namespace SharpReportCore { public static string UnboundName { get {return unbound;} } + + public static string TableName { + get { + return tableName; + } + } + #endregion #region Message's diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs index d1875d244f..e7bd94a933 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractDataRenderer.cs @@ -37,6 +37,7 @@ namespace SharpReportCore{ } #endregion + protected int DoItems (ReportPageEventArgs rpea) { IContainerItem container = null; bool hasContainer = false; @@ -72,9 +73,9 @@ namespace SharpReportCore{ item.Parent = section; } item.SectionOffset = section.SectionOffset; - base.DrawSingleItem (rpea,item); + item.Render(rpea); drawPoint.Y = section.SectionOffset + section.Size.Height; - rpea.LocationAfterDraw = new PointF (rpea.LocationAfterDraw.X,section.SectionOffset + section.Size.Height); + rpea.LocationAfterDraw = new Point (rpea.LocationAfterDraw.X,section.SectionOffset + section.Size.Height); } if ((section.CanGrow == false)&& (section.CanShrink == false)) { diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs index 886a31c686..310b6ce08e 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs @@ -33,16 +33,16 @@ namespace SharpReportCore { private ReportSettings reportSettings; private int sectionInUse; - - private Point detailStart; - private Point detailEnds; - private DefaultFormatter defaultFormatter; + + private StandardFormatter standartFormatter; private bool cancel; - public event EventHandler SectionRendering; + public event EventHandler Rendering; public event EventHandler SectionRendered; + public Page page; + protected AbstractRenderer(ReportModel model){ if (model == null) { throw new MissingModelException(); @@ -50,7 +50,7 @@ namespace SharpReportCore { this.reportSettings = model.ReportSettings; this.sections = model.SectionCollection; Init(); - defaultFormatter = new DefaultFormatter(); + standartFormatter = new StandardFormatter(); } public virtual void SetupRenderer () { @@ -64,12 +64,13 @@ namespace SharpReportCore { // Events from ReportDocument reportDocument.QueryPageSettings += new QueryPageSettingsEventHandler (ReportQueryPage); reportDocument.BeginPrint += new PrintEventHandler(ReportBegin); + reportDocument.PrintPage += new PrintPageEventHandler(ReportPageStart); reportDocument.EndPrint += new PrintEventHandler(ReportEnd); - + // homemade events - reportDocument.PrintPageBodyStart += new EventHandler (BodyStart); + reportDocument.BodyStart += new EventHandler (BodyStart); - reportDocument.PrintPageBodyEnd += new EventHandler (OnBodyEnd); + reportDocument.BodyEnd += new EventHandler (BodyEnd); // reportDocument.RenderReportHeader += new EventHandler (PrintReportHeader); @@ -93,11 +94,12 @@ namespace SharpReportCore { private void OnSectionPrinting (object sender,SectionEventArgs e) { - if (this.SectionRendering != null) { + if (this.Rendering != null) { SectionRenderEventArgs ea = new SectionRenderEventArgs (e.Section, this.reportDocument.PageNumber,0, (GlobalEnums.enmSection)this.sectionInUse); - this.SectionRendering(this,ea); + BaseSection s = (BaseSection)sender; + this.Rendering(this,ea); } } @@ -107,12 +109,15 @@ namespace SharpReportCore { SectionRenderEventArgs ea = new SectionRenderEventArgs (e.Section, this.reportDocument.PageNumber,0, (GlobalEnums.enmSection)this.sectionInUse); + this.SectionRendered(this,ea); } } #endregion + #region SharpReport Events + protected virtual void PrintReportHeader (object sender, ReportPageEventArgs e) { SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportHeader, CultureInfo.InvariantCulture); @@ -124,14 +129,28 @@ namespace SharpReportCore { CultureInfo.InvariantCulture); this.AddSectionEvents(); } + protected virtual void BodyStart (object sender,ReportPageEventArgs rpea) { +// System.Console.WriteLine("\tAbstract - PrintBodyStart"); + this.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail, + CultureInfo.InvariantCulture); + + } + protected virtual void PrintDetail (object sender,ReportPageEventArgs rpea) { SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail, CultureInfo.InvariantCulture); - this.AddSectionEvents(); +// this.AddSectionEvents(); // System.Console.WriteLine("\tAbstract - PrintDetail"); } + + protected virtual void BodyEnd (object sender,ReportPageEventArgs rpea) { +// System.Console.WriteLine("\tAbstarct - PrintBodyEnd"); + this.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportFooter, + CultureInfo.InvariantCulture); + } + protected virtual void PrintPageEnd (object sender,ReportPageEventArgs rpea) { SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter, CultureInfo.InvariantCulture); @@ -146,6 +165,8 @@ namespace SharpReportCore { this.AddSectionEvents(); } + #endregion + protected static void PageBreak(ReportPageEventArgs pea) { if (pea == null) { throw new ArgumentNullException("pea"); @@ -154,117 +175,120 @@ namespace SharpReportCore { pea.ForceNewPage = true; } - protected bool CheckPageBreakAfter () { - if (this.CurrentSection.PageBreakAfter) { - return true; - } - return false; - } - protected int CalculateDrawAreaHeight(ReportPageEventArgs rpea){ - if (rpea == null) { - throw new ArgumentNullException("rpea"); - } - int to = rpea.PrintPageEventArgs.MarginBounds.Height ; - - if (rpea.PageNumber ==1) { - to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,CultureInfo.InvariantCulture)].Size.Height; - } - - to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,CultureInfo.InvariantCulture)].Size.Height; - - to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter,CultureInfo.InvariantCulture)].Size.Height; - return to; - } - + #region Debugg Code /// /// Use this function to draw controlling rectangles + /// For debugging only /// - protected static void DebugRectangle (ReportPageEventArgs rpea,Rectangle rectangle) { + public static void DebugRectangle (PrintPageEventArgs rpea,Rectangle rectangle) { if (rpea == null) { throw new ArgumentNullException("rpea"); } - rpea.PrintPageEventArgs.Graphics.DrawRectangle (Pens.Black,rectangle); + rpea.Graphics.DrawRectangle (Pens.Black,rectangle); } - /// - /// Calculates the rectangle wich can be used by Detail - /// - /// - protected Rectangle DetailRectangle (ReportPageEventArgs rpea) { - if (rpea == null) { - throw new ArgumentNullException("rpea"); - } - sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail, - CultureInfo.InvariantCulture); + public void DebugFooterRectangle (ReportPageEventArgs rpea) { + Rectangle r = new Rectangle( this.page.ReportFooterRectangle.Left, + rpea.LocationAfterDraw.Y, + this.page.ReportFooterRectangle.Width, + this.page.ReportFooterRectangle.Height); - Rectangle rect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left, - this.detailStart.Y , - rpea.PrintPageEventArgs.MarginBounds.Width, - detailEnds.Y - detailStart.Y - (3 * gap)); - return rect; + Rectangle s = new Rectangle (this.page.ReportFooterRectangle.Left, + rpea.LocationAfterDraw.Y, + + this.page.ReportFooterRectangle.Width, + this.page.PageFooterRectangle.Top - rpea.LocationAfterDraw.Y -1); + + AbstractRenderer.DebugRectangle(rpea.PrintPageEventArgs,r); + AbstractRenderer.DebugRectangle(rpea.PrintPageEventArgs,s); } - protected PointF MeasureReportHeader (ReportPageEventArgs rpea) { - if (rpea == null) { + #endregion + + protected Rectangle MeasureReportHeader (PrintPageEventArgs ppea) { + if (ppea == null) { throw new ArgumentNullException("rpea"); } - PointF endAt = new PointF(); - if (rpea.PageNumber == 1) { + + Rectangle rect = new Rectangle(); + if (this.reportDocument.PageNumber == 1) { + sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportHeader, CultureInfo.InvariantCulture); + if (this.CurrentSection.Items.Count > 0) { this.CurrentSection.SectionOffset = reportSettings.DefaultMargins.Top; - FitSectionToItems (this.CurrentSection,rpea); - endAt = new PointF (0, - reportSettings.DefaultMargins.Top + this.CurrentSection.Size.Height + Gap); + FitSectionToItems (this.CurrentSection,ppea); + + rect = new Rectangle(reportSettings.DefaultMargins.Left, + reportSettings.DefaultMargins.Top, + ppea.MarginBounds.Width, + this.CurrentSection.Size.Height + Gap); } else { - endAt = new PointF(0,reportSettings.DefaultMargins.Top); + + rect = new Rectangle (reportSettings.DefaultMargins.Left, + reportSettings.DefaultMargins.Top, + ppea.MarginBounds.Width, + 0); } } - return endAt; + return rect; } /// /// Section start at this PointF /// ReportPageEventArgs - protected PointF MeasurePageHeader (PointF startat,ReportPageEventArgs rpea) { + private Rectangle MeasurePageHeader (Rectangle startAfter,PrintPageEventArgs rpea) { if (rpea == null) { throw new ArgumentNullException("rpea"); } + sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader, CultureInfo.InvariantCulture); - if (rpea.PageNumber == 1) { - this.CurrentSection.SectionOffset = (int)startat.Y + Gap; + if (this.reportDocument.PageNumber == 1){ + this.CurrentSection.SectionOffset = (int)startAfter.Top + Gap; } else { this.CurrentSection.SectionOffset = reportSettings.DefaultMargins.Top; } FitSectionToItems (this.CurrentSection,rpea); - return new PointF (0, - this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height + Gap); + return new Rectangle (startAfter.Left, + startAfter.Bottom + Gap, + rpea.MarginBounds.Width, + this.CurrentSection.Size.Height + Gap); } - protected PointF MeasurePageEnd (ReportPageEventArgs e) { + + private Rectangle MeasurePageFooter (PrintPageEventArgs e) { sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter, CultureInfo.InvariantCulture); this.CurrentSection.SectionOffset = reportSettings.PageSettings.Bounds.Height - reportSettings.DefaultMargins.Top - reportSettings.DefaultMargins.Bottom; FitSectionToItems (this.CurrentSection,e); - this.DetailEnds = new Point (0,this.CurrentSection.SectionOffset); - return new PointF(0,this.CurrentSection.SectionOffset); + return new Rectangle(reportSettings.DefaultMargins.Left, + this.CurrentSection.SectionOffset, + e.MarginBounds.Width, + this.CurrentSection.Size.Height); + + } - protected PointF MeasureReportFooter (ReportPageEventArgs e) { + private Rectangle MeasureReportFooter (PrintPageEventArgs ppea) { sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportFooter, CultureInfo.InvariantCulture); - FitSectionToItems (this.CurrentSection,e); - return new PointF(0,this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height); + FitSectionToItems (this.CurrentSection,ppea); + return new Rectangle (reportSettings.DefaultMargins.Left, + this.CurrentSection.SectionOffset, + ppea.MarginBounds.Width, + this.CurrentSection.Size.Height); } + + protected virtual int RenderSection (ReportPageEventArgs rpea) { Point drawPoint = new Point(0,0); @@ -276,10 +300,10 @@ namespace SharpReportCore { item.Parent = this.CurrentSection; } item.SectionOffset = this.CurrentSection.SectionOffset; - this.DrawSingleItem (rpea,item); - + item.Render(rpea); drawPoint.Y = this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height; - rpea.LocationAfterDraw = new PointF (rpea.LocationAfterDraw.X,this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height); + rpea.LocationAfterDraw = new Point (rpea.LocationAfterDraw.X, + this.CurrentSection.SectionOffset + this.CurrentSection.Size.Height); } @@ -292,41 +316,17 @@ namespace SharpReportCore { return drawPoint.Y; } - - protected void DrawSingleItem (ReportPageEventArgs rpea,BaseReportItem item){ - item.SuspendLayout(); - item.FormatOutput -= new EventHandler (FormatBaseReportItem); - item.FormatOutput += new EventHandler (FormatBaseReportItem); - item.Render(rpea); - item.ResumeLayout(); - } - - // Called by FormatOutPutEvent of the BaseReportItem - void FormatBaseReportItem (object sender, FormatOutputEventArgs rpea) { - BaseDataItem baseDataItem = sender as BaseDataItem; - - if (baseDataItem != null) { - if (!String.IsNullOrEmpty(baseDataItem.FormatString)) { - - rpea.FormatedValue = defaultFormatter.FormatItem (baseDataItem); - } else { - rpea.FormatedValue = rpea.ValueToFormat; - } - } - } - - #region privates - protected void FitSectionToItems (BaseSection section,ReportPageEventArgs rpea){ + protected void FitSectionToItems (BaseSection section,PrintPageEventArgs rpea){ if (section == null) { throw new ArgumentNullException("section"); } if (rpea == null) { throw new ArgumentNullException("rpea"); } - Rectangle orgRect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left, + Rectangle orgRect = new Rectangle (rpea.MarginBounds.Left, section.SectionOffset, - rpea.PrintPageEventArgs.MarginBounds.Width, + rpea.MarginBounds.Width, section.Size.Height); if ((section.CanGrow == true)||(section.CanShrink == true)) { @@ -337,7 +337,7 @@ namespace SharpReportCore { } } - private static void AdjustItems (BaseSection section,ReportPageEventArgs e){ + private static void AdjustItems (BaseSection section,PrintPageEventArgs e){ int toFit = section.Size.Height; foreach (BaseReportItem rItem in section.Items) { @@ -350,7 +350,7 @@ namespace SharpReportCore { } } - private static void AdjustSection (BaseSection section,ReportPageEventArgs e){ + private static void AdjustSection (BaseSection section,PrintPageEventArgs e){ foreach (BaseReportItem rItem in section.Items) { if (!AbstractRenderer.CheckItemInSection (section,rItem,e)){ @@ -365,7 +365,7 @@ namespace SharpReportCore { } - private static bool CheckItemInSection (BaseSection section,BaseReportItem item ,ReportPageEventArgs e) { + private static bool CheckItemInSection (BaseSection section,BaseReportItem item ,PrintPageEventArgs e) { Rectangle secRect = new Rectangle (0,0,section.Size.Width,section.Size.Height); SizeF size = AbstractRenderer.MeasureReportItem(item,e); Rectangle itemRect = new Rectangle (item.Location.X, @@ -379,7 +379,7 @@ namespace SharpReportCore { } private static SizeF MeasureReportItem(IItemRenderer item, - ReportPageEventArgs e) { + PrintPageEventArgs e) { SizeF sizeF = new SizeF (); BaseTextItem myItem = item as BaseTextItem; if (myItem != null) { @@ -392,24 +392,64 @@ namespace SharpReportCore { BaseDataItem it = item as BaseDataItem; str = it.DbValue; } - - sizeF = e.PrintPageEventArgs.Graphics.MeasureString(str, - myItem.Font, - myItem.Size.Width, - myItem.StringFormat); + + sizeF = e.Graphics.MeasureString(str, + myItem.Font, + myItem.Size.Width, + myItem.StringFormat); } else { sizeF = new SizeF (item.Size.Width,item.Size.Height); } - + return sizeF; } #endregion - #region virtuals + #region PrintDocument Events + private void ReportPageStart (object sender, PrintPageEventArgs e) { + if (this.page == null) { + throw new ArgumentException("page"); + } + + Rectangle r1; + + if (this.reportDocument.PageNumber == 1) { + r1 = this.MeasureReportHeader(e); + page.ReportHeaderRectangle = r1; + } else { + r1 = new Rectangle (reportSettings.DefaultMargins.Left, + reportSettings.DefaultMargins.Top, + e.MarginBounds.Width, + 0); + } + page.ReportHeaderRectangle = r1; +// System.Console.WriteLine("ReportHeader {0}",page.ReportHeaderRectangle); + page.PageHeaderRectangle = this.MeasurePageHeader(r1,e); +// System.Console.WriteLine("PageHeader {0}",page.PageHeaderRectangle); + page.PageFooterRectangle = this.MeasurePageFooter (e); + +// System.Console.WriteLine("DrawArea {0}",page.DetailArea); + +// System.Console.WriteLine("PageFooter {0}",page.PageFooterRectangle); + page.ReportFooterRectangle = this.MeasureReportFooter(e); +// System.Console.WriteLine("ReportFooter {0}",page.ReportFooterRectangle); +// System.Console.WriteLine("DetailStarts {0}",page.DetailStart); +// System.Console.WriteLine(""); +// AbstractRenderer.DebugRectangle (e,page.PageHeaderRectangle); +// AbstractRenderer.DebugRectangle (e,page.DetailArea); +// AbstractRenderer.DebugRectangle (e,page.PageFooterRectangle); + } protected virtual void ReportQueryPage (object sender,QueryPageSettingsEventArgs qpea) { qpea.PageSettings.Margins = reportSettings.DefaultMargins; + + if (this.reportDocument.PageNumber == 1) { + page = new Page (true); + } else { + page = new Page (false); + } + } @@ -418,20 +458,7 @@ namespace SharpReportCore { } - protected virtual void BodyStart (object sender,ReportPageEventArgs rpea) { -// System.Console.WriteLine("\tAbstract - PrintBodyStart"); - this.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail, - CultureInfo.InvariantCulture); - - } - - - protected virtual void OnBodyEnd (object sender,ReportPageEventArgs rpea) { -// System.Console.WriteLine("\tAbstarct - PrintBodyEnd"); - this.SectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportFooter, - CultureInfo.InvariantCulture); - } protected virtual void ReportEnd (object sender,PrintEventArgs e) { // System.Console.WriteLine("\tAbstract - ReportEnd"); @@ -439,6 +466,7 @@ namespace SharpReportCore { #endregion + #region property's public ReportDocument ReportDocument { @@ -488,23 +516,17 @@ namespace SharpReportCore { } } - protected Point DetailEnds { + protected Page Page { get { - return detailEnds; + return page; } set { - detailEnds = value; + page = value; } } - protected Point DetailStart { - get { - return detailStart; - } - set { - detailStart = value; - } - } + + #endregion #region IDispoable diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/FormatOutputEventArgs.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/FormatOutputEventArgs.cs deleted file mode 100644 index 90099a7e1e..0000000000 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/FormatOutputEventArgs.cs +++ /dev/null @@ -1,65 +0,0 @@ - -// -/// -/// created by - Forstmeier Peter -/// Peter Forstmeier (Peter.Forstmeier@t-online.de) -/// created on - 12.06.2005 18:17:46 -/// - -using System; - /// - /// This Delegate is used to format the output from TextBased Items - /// -namespace SharpReportCore { - - public class FormatOutputEventArgs : System.EventArgs { - - /// - /// Default constructor - initializes all fields to default values - /// - private string format; - private string valueToFormat; - private string nullValue; - private string formatedValue; - - public FormatOutputEventArgs() { - } - - public FormatOutputEventArgs(string valueToFormat,string format, string nullValue ) - { - this.format = format; - this.nullValue = nullValue; - this.valueToFormat = valueToFormat; - } - - #region Property's - public string Format { - get { - return format; - } - } - public string NullValue { - get { - return nullValue; - } - } - public string ValueToFormat { - get { - return valueToFormat; - } - } - - public string FormatedValue { - get { - return formatedValue; - } - set { - formatedValue = value; - } - } - - - #endregion - - } -} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/AbstractFormatter.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/AbstractFormatter.cs deleted file mode 100644 index f0faa0858e..0000000000 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/AbstractFormatter.cs +++ /dev/null @@ -1,55 +0,0 @@ - -// -// SharpDevelop ReportEditor -// -// Copyright (C) 2005 Peter Forstmeier -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// Peter Forstmeier (Peter.Forstmeier@t-online.de) - -using System; - - /// - /// Base Class for all Formatters - /// - /// - /// created by - Forstmeier Peter - /// created on - 27.03.2005 18:09:29 - /// -namespace SharpReportCore { - public class AbstractFormatter : object { - - /// - /// Default constructor - initializes all fields to default values - /// - public AbstractFormatter() { - } - - protected bool CheckFormat (string format) { - if (String.IsNullOrEmpty(format)) { - return false; - } - return true; - } - - protected bool CheckValue (string toFormat) { - if (String.IsNullOrEmpty(toFormat)) { - return false; - } - return true; - } - } -} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/DefaultFormatter.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/DefaultFormatter.cs deleted file mode 100644 index d1763096ce..0000000000 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Formatter/DefaultFormatter.cs +++ /dev/null @@ -1,183 +0,0 @@ -// -// SharpDevelop ReportEditor -// -// Copyright (C) 2005 Peter Forstmeier -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// Peter Forstmeier (Peter.Forstmeier@t-online.de) -using System; -using System.Globalization; -//using System.Windows.Forms; - -/// -/// This Class handles the formatting of Output Values depending on there -/// Type and DbValue -/// -/// -/// created by - Forstmeier Peter -/// created on - 30.03.2005 09:14:20 -/// -namespace SharpReportCore{ - public class DefaultFormatter : AbstractFormatter { - - - public DefaultFormatter() { - } - - ///Looks witch formatting Class to use, call the approbiate formatter - /// and update the DbValue with the formatted String value - /// - ///A ReportDataItem - /// - public string FormatItem (BaseDataItem item) { - - if (item == null) { - throw new ArgumentNullException("item"); - } - string retValue = String.Empty; - - switch (item.DataType) { - - case "System.DateTime" : - retValue = DateValues(item.DbValue,item.FormatString); - break; - - case "System.Int16": - retValue = IntegerValues ("16",item.DbValue,item.FormatString); - break; - - case "System.Int32" : - retValue = IntegerValues ("32",item.DbValue,item.FormatString); - break; - case "System.Decimal": - retValue = DecimalValues (item.DbValue,item.FormatString); - break; - - case "System.Boolean": - retValue = BoolValue (item.DbValue,item.FormatString); - break; - default: - retValue = item.DbValue; - break; - } - return retValue; - } - - public string BoolValue (string toFormat, string format){ - string str = String.Empty; - if (base.CheckFormat(format) == true) { - - if (base.CheckValue (toFormat)) { - try { - bool b = bool.Parse (toFormat); - str = b.ToString (CultureInfo.CurrentCulture); - - } catch (System.FormatException) { -// string s = String.Format("\tBool Value < {0} > {1}",toFormat,e.Message); -// System.Console.WriteLine("\t\t{0}",s); - } - } - } else { - str = toFormat; - } - return str; - } - - public string IntegerValues(string valueType,string toFormat, string format) { - string str = String.Empty; - if (base.CheckFormat(format) == true) { - if (base.CheckValue (toFormat)) { - try { - int number; - switch (valueType) { - case "16": - number = Int16.Parse (toFormat, - System.Globalization.NumberStyles.Any, - CultureInfo.CurrentCulture.NumberFormat); - break; - case "32" : - number = Int32.Parse (toFormat, - System.Globalization.NumberStyles.Any, - CultureInfo.CurrentCulture.NumberFormat); - break; - default: - throw new ArgumentException("DefaultFormater:IntegerValues Unknown intType "); - - } - str = number.ToString (format,CultureInfo.CurrentCulture); - - } catch (System.FormatException) { -// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message); -// System.Console.WriteLine("\t{0}",s); - } - return str; - } else { - str = (0.0M).ToString(CultureInfo.CurrentCulture); - } - - } else { - str = toFormat; - } - return str; - } - - public string DecimalValues(string toFormat, string format) { - string str = String.Empty; - if (base.CheckFormat(format) == true) { - - if (base.CheckValue (toFormat)) { - try { - decimal dec = Decimal.Parse(toFormat, - System.Globalization.NumberStyles.Any, - CultureInfo.CurrentCulture.NumberFormat); - str = dec.ToString (format,CultureInfo.CurrentCulture); - - } catch (System.FormatException) { -// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message); -// System.Console.WriteLine("\t{0}",s); - } - return str; - } else { - str = (0.0M).ToString(CultureInfo.CurrentCulture); - } - - } else { - str = toFormat; - } - return str; - } - - public string DateValues(string toFormat, string format) { - - if (base.CheckFormat(format) == true) { - try { - DateTime date = DateTime.Parse (toFormat.Trim(), - CultureInfo.CurrentCulture.DateTimeFormat); - string str = date.ToString(format, - DateTimeFormatInfo.CurrentInfo); - - return str.Trim(); - } catch (System.FormatException) { -// string s = String.Format("< {0} > {1}",toFormat,e.Message); -// System.Console.WriteLine("\t\tDateValue {0}",s); - } - } else { - return toFormat.Trim(); - } - return toFormat.Trim(); - } - } -} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Page.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Page.cs new file mode 100644 index 0000000000..b42d998101 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Page.cs @@ -0,0 +1,140 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 30.06.2006 + * Time: 17:12 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Drawing; + +namespace SharpReportCore{ + /// + /// Description of Page. + /// + public class Page{ + Rectangle reportHeaderRectangle; + Rectangle pageHeaderRectangle; + Rectangle detailRectangle; + Rectangle pageFooterRectangle; + Rectangle reportFooterRectangle; + + bool firstpage; + + public Page(bool firstPage){ + this.firstpage = firstPage; + } + + + public Rectangle ReportHeaderRectangle { + get { + return reportHeaderRectangle; + } + set { + reportHeaderRectangle = value; + } + } + + public Rectangle PageHeaderRectangle { + get { + return pageHeaderRectangle; + } + set { + pageHeaderRectangle = value; + } + } + + public Rectangle DetailRectangle { + get { + return detailRectangle; + } + set { + detailRectangle = value; + } + } + + + public Rectangle PageFooterRectangle { + get { + return pageFooterRectangle; + } + set { + pageFooterRectangle = value; + } + } + + public Rectangle ReportFooterRectangle { + get { + return reportFooterRectangle; + } + set { + reportFooterRectangle = value; + } + } + + public Point DetailStart{ + get { + return new Point(this.pageHeaderRectangle.Left, + this.pageHeaderRectangle.Bottom); + } + } + + public Point DetailEnds{ + get { + return new Point(this.pageFooterRectangle.Left,this.pageFooterRectangle.Top); + } + } + /* + /// + /// Calculates the rectangle wich can be used by Detail + /// + /// + + protected Rectangle old_DetailRectangle (ReportPageEventArgs rpea) { + if (rpea == null) { + throw new ArgumentNullException("rpea"); + } + + sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail, + CultureInfo.InvariantCulture); + Rectangle rect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left, + this.page.DetailStart.Y , + rpea.PrintPageEventArgs.MarginBounds.Width, + page.DetailEnds.Y - this.page.DetailStart.Y - (3 * gap)); + System.Console.WriteLine("Page DetRec {0} base DetRec {1}",page.DetailArea,rect); + return rect; + } + */ + /* + protected int CalculateDrawAreaHeight(ReportPageEventArgs rpea){ + if (rpea == null) { + throw new ArgumentNullException("rpea"); + } + int to = rpea.PrintPageEventArgs.MarginBounds.Height ; + if (this.reportDocument.PageNumber == 1){ + to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,CultureInfo.InvariantCulture)].Size.Height; + } + + to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,CultureInfo.InvariantCulture)].Size.Height; + + to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter,CultureInfo.InvariantCulture)].Size.Height; + return to; + } + */ + /// + /// This rectangle starts directly after PageHeader and ends bevore PageFooter + /// + public Rectangle DetailArea { + get { + return new Rectangle (this.DetailStart.X, + this.DetailStart.Y, + this.pageHeaderRectangle.Width, + (this.pageFooterRectangle.Top -1) - (this.pageHeaderRectangle.Bottom + 1)); + } + + } + + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs index df7802fd5b..a728548099 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs @@ -74,52 +74,60 @@ namespace SharpReportCore { #region Draw the different report Sections - private PointF DoReportHeader (ReportPageEventArgs rpea){ - PointF endAt = base.MeasureReportHeader (rpea); + private void DoReportHeader (ReportPageEventArgs rpea){ base.RenderSection (rpea); base.DoItems(rpea); - - return endAt; } - - private PointF DoPageHeader (PointF startAt,ReportPageEventArgs rpea){ - PointF endAt = base.MeasurePageHeader (startAt,rpea); + private void DoPageHeader (ReportPageEventArgs rpea){ + this.CurrentSection.SectionOffset = base.Page.PageHeaderRectangle.Location.Y; base.RenderSection (rpea); base.DoItems(rpea); - return endAt; } + private void DoPageEnd (ReportPageEventArgs rpea){ -// System.Console.WriteLine("DataRenderer:DoPageEnd"); - base.MeasurePageEnd (rpea); +// System.Console.WriteLine("DoPageEnd"); + this.CurrentSection.SectionOffset = base.Page.PageFooterRectangle.Location.Y; base.RenderSection (rpea); base.DoItems(rpea); } //TODO how should we handle ReportFooter, print it on an seperate page ???? private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){ -// System.Console.WriteLine("DoReportFooter"); - base.MeasureReportFooter(rpea); + this.CurrentSection.SectionOffset = (int)rpea.LocationAfterDraw.Y; base.RenderSection (rpea); base.DoItems(rpea); } + private bool IsRoomForFooter(Point loc) { + Rectangle r = new Rectangle( base.Page.ReportFooterRectangle.Left, + loc.Y, + base.Page.ReportFooterRectangle.Width, + base.Page.ReportFooterRectangle.Height); + + Rectangle s = new Rectangle (base.Page.ReportFooterRectangle.Left, + loc.Y, + + base.Page.ReportFooterRectangle.Width, + base.Page.PageFooterRectangle.Top - loc.Y -1); + return s.Contains(r); + } + #endregion #region test protected override void PrintReportHeader (object sender, ReportPageEventArgs e) { base.PrintReportHeader (sender,e); - this.currentPoint = DoReportHeader (e); + DoReportHeader (e); base.RemoveSectionEvents(); } protected override void PrintPageHeader (object sender, ReportPageEventArgs e) { base.PrintPageHeader (sender,e); - this.currentPoint = DoPageHeader (this.currentPoint,e); - base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y +1); + DoPageHeader(e); base.RemoveSectionEvents(); } @@ -128,12 +136,15 @@ namespace SharpReportCore { base.PrintPageEnd(sender,rpea); this.DoPageEnd (rpea); base.RemoveSectionEvents(); + } protected override void PrintReportFooter(object sender, ReportPageEventArgs rpea){ - System.Console.WriteLine("DataRenderer:PrintReportFooter"); +// DebugFooterRectangle(rpea); + this.CurrentSection.SectionOffset = (int)rpea.LocationAfterDraw.Y; base.PrintReportFooter(sender, rpea); - DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height), + DoReportFooter (new PointF(0, + base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height), rpea); base.RemoveSectionEvents(); } @@ -167,22 +178,23 @@ namespace SharpReportCore { protected override void BodyStart(object sender, ReportPageEventArgs rpea) { -// System.Console.WriteLine("DataRenderer:PrintBodyStart"); + System.Console.WriteLine(""); + System.Console.WriteLine("BodyStart"); base.BodyStart (sender,rpea); this.currentPoint = new PointF (base.CurrentSection.Location.X, - this.DetailStart.Y); + base.page.DetailStart.Y); - base.CurrentSection.SectionOffset = (int)this.DetailStart.Y + AbstractRenderer.Gap; + base.CurrentSection.SectionOffset = (int)this.page.DetailStart.Y + AbstractRenderer.Gap; + System.Console.WriteLine("\tAdd SectionEvents"); + base.AddSectionEvents(); } protected override void PrintDetail(object sender, ReportPageEventArgs rpea){ Rectangle sectionRect; bool firstOnPage = true; -// System.Console.WriteLine("RenderDataReport:PrintDetail"); + base.PrintDetail(sender, rpea); - -// base.DebugRectangle(rpea,base.DetailRectangle(rpea)); // no loop if there is no data if (! this.dataNavigator.HasMoreData ) { rpea.PrintPageEventArgs.HasMorePages = false; @@ -190,14 +202,12 @@ namespace SharpReportCore { } // first element - if (rpea.PageNumber == 1) { + if (this.ReportDocument.PageNumber ==1) { this.dataNavigator.MoveNext(); } do { - this.dataNavigator.Fill (base.CurrentSection.Items); - base.RenderSection (rpea); if (!firstOnPage) { @@ -206,15 +216,17 @@ namespace SharpReportCore { } - base.FitSectionToItems (base.CurrentSection,rpea); + base.FitSectionToItems (base.CurrentSection,rpea.PrintPageEventArgs); sectionRect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left, base.CurrentSection.SectionOffset, rpea.PrintPageEventArgs.MarginBounds.Width, base.CurrentSection.Size.Height); - if (!base.DetailRectangle(rpea).Contains(sectionRect)) { + if (!base.Page.DetailArea.Contains(sectionRect)) { AbstractRenderer.PageBreak(rpea); + System.Console.WriteLine("DataRenderer:RemoveEvents reason "); + this.RemoveSectionEvents(); return; } @@ -224,20 +236,33 @@ namespace SharpReportCore { if (this.dataNavigator.CurrentRow < this.dataNavigator.Count -1) { if (base.CurrentSection.PageBreakAfter) { - AbstractRenderer.PageBreak(rpea);; + AbstractRenderer.PageBreak(rpea); + System.Console.WriteLine("DataRenderer:RemoveEvents reason "); + this.RemoveSectionEvents(); + return; } } } while (this.dataNavigator.MoveNext()); - this.RemoveSectionEvents(); + + this.ReportDocument.DetailsDone = true; + + // test for reportfooter + if (!IsRoomForFooter (rpea.LocationAfterDraw)) { + AbstractRenderer.PageBreak(rpea); + } + } - protected override void OnBodyEnd(object sender, ReportPageEventArgs rpea) { -// System.Console.WriteLine("PrintBodyEnd ????"); - base.OnBodyEnd (sender,rpea); -// DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height), -// rpea); + protected override void BodyEnd(object sender, ReportPageEventArgs rpea) { + System.Console.WriteLine(""); + System.Console.WriteLine("BodyEnd "); + + base.BodyEnd (sender,rpea); + System.Console.WriteLine("\tRemoveEvents reason "); + base.RemoveSectionEvents(); + rpea.PrintPageEventArgs.HasMorePages = false; } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs index e0b8a20ea3..75925ae667 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderFormSheetReport.cs @@ -20,14 +20,8 @@ // Peter Forstmeier (Peter.Forstmeier@t-online.de) using System; -using System.Data; using System.Drawing; -using System.Globalization; using System.Drawing.Printing; -using System.Windows.Forms; -using System.Xml; - -using SharpReportCore; /// /// Runs the Report @@ -48,73 +42,70 @@ namespace SharpReportCore { #region Draw the different report Sections - private PointF DoReportHeader (ReportPageEventArgs rpea){ - PointF endAt = base.MeasureReportHeader (rpea); + private void DoReportHeader (ReportPageEventArgs rpea){ base.RenderSection (rpea); - - if (base.CheckPageBreakAfter()) { - AbstractRenderer.PageBreak(rpea); - base.CurrentSection.PageBreakAfter = false; - return new PointF(); - } - return endAt; } - private PointF DoPageHeader (PointF startAt,ReportPageEventArgs rpea){ - - PointF endAt = base.MeasurePageHeader (startAt,rpea); + private void DoPageHeader (PointF startAt,ReportPageEventArgs rpea){ + this.CurrentSection.SectionOffset = base.Page.PageHeaderRectangle.Location.Y; base.RenderSection (rpea); - return endAt; } private void DoPageEnd (ReportPageEventArgs rpea){ + base.PrintPageEnd(this,rpea); - base.MeasurePageEnd (rpea); + this.CurrentSection.SectionOffset = base.Page.PageFooterRectangle.Location.Y; base.RenderSection (rpea); - } + + //TODO how should we handle ReportFooter, print it on an seperate page ???? private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){ - base.MeasureReportFooter(rpea); + this.CurrentSection.SectionOffset = base.Page.ReportFooterRectangle.Location.Y; base.RenderSection (rpea); this.RemoveSectionEvents(); } #endregion - #region test + #region print all the sections protected override void PrintReportHeader (object sender, ReportPageEventArgs e) { base.PrintReportHeader (sender,e); - this.currentPoint = DoReportHeader (e); + DoReportHeader (e); } protected override void PrintPageHeader (object sender, ReportPageEventArgs e) { base.PrintPageHeader (sender,e); - this.currentPoint = DoPageHeader (this.currentPoint,e); - base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y); + DoPageHeader (this.currentPoint,e); } - - #endregion - - - #region event's - - /// /// Detail Section /// /// /// protected override void BodyStart (object sender,ReportPageEventArgs rpea) { +// System.Console.WriteLine("BodyStart"); base.BodyStart (sender,rpea); - base.CurrentSection.SectionOffset = (int)this.currentPoint.Y + AbstractRenderer.Gap; - - FitSectionToItems (base.CurrentSection,rpea); - base.RenderSection (rpea); + this.currentPoint = new PointF (base.CurrentSection.Location.X, + base.page.DetailStart.Y); } + + protected override void PrintDetail(object sender, ReportPageEventArgs rpea){ + base.PrintDetail(sender, rpea); + this.CurrentSection.SectionOffset = base.Page.PageHeaderRectangle.Bottom; + base.RenderSection(rpea); + base.RemoveSectionEvents(); + } + + protected override void PrintReportFooter(object sender, ReportPageEventArgs rpea){ + base.PrintReportFooter(sender, rpea); + base.RenderSection(rpea); + base.RemoveSectionEvents(); + } + /// /// Print the PageFooter /// @@ -123,12 +114,18 @@ namespace SharpReportCore { protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) { this.DoPageEnd (rpea); } + #endregion + + + #region event's + + - protected override void OnBodyEnd (object sender,ReportPageEventArgs rpea) { + protected override void BodyEnd (object sender,ReportPageEventArgs rpea) { - base.OnBodyEnd (sender,rpea); + base.BodyEnd (sender,rpea); this.DoReportFooter (new PointF(0,base.CurrentSection.SectionOffset + base.CurrentSection.Size.Height), rpea); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs index 6bc24ed2a1..94ba4e7b77 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs @@ -18,10 +18,16 @@ using SharpReportCore; namespace SharpReportCore { public class ReportDocument : PrintDocument { + /// + /// Fired just before the DetailSection ist printed + /// + /// + public event EventHandler BodyStart; - public event EventHandler PrintPageBodyStart; - - public event EventHandler PrintPageBodyEnd; + /// + /// Fired if all Details 8data) are printed + /// + public event EventHandler BodyEnd; @@ -30,14 +36,16 @@ namespace SharpReportCore { public event EventHandler RenderDetails; public event EventHandler RenderPageEnd; public event EventHandler RenderReportEnd; + int pageNumber; + bool detailsDone; public ReportDocument():base() { } - #region overriede's + #region Overrides protected override void OnQueryPageSettings(QueryPageSettingsEventArgs e){ base.OnQueryPageSettings(e); @@ -49,65 +57,146 @@ namespace SharpReportCore { } protected override void OnPrintPage(PrintPageEventArgs e){ - base.OnPrintPage(e); pageNumber ++; - + base.OnPrintPage(e); + + ReportPageEventArgs pea = new ReportPageEventArgs (e,pageNumber, - false,new PointF (0,0)); - GeneratePage (pea); + false,Point.Empty); + + + // ReportHeader only on first page + if (this.pageNumber == 1) { + if (this.RenderReportHeader != null) { + this.RenderReportHeader(this,pea); + } + } + + // allway draw PageHeader + if (this.RenderPageHeader != null) { + this.RenderPageHeader (this,pea); + } + + // Details - if (pea.PrintPageEventArgs.HasMorePages == false) { - if (this.RenderReportEnd != null) { - this.RenderReportEnd(this,pea); + if (BodyStart != null) { + BodyStart (this,pea); + } +// + if (this.RenderDetails != null) { + this.RenderDetails(this,pea); + } + + + if (pea.ForceNewPage) { + if (RenderPageEnd != null) { + RenderPageEnd (this,pea); + return; } -// this.OnEndPrint (new PrintEventArgs()); + pea.ForceNewPage = false; + return; + } + + if (BodyEnd != null) { + BodyEnd (this,pea); + } + + // ReportFooter + if (this.detailsDone) { + this.RenderReportEnd(this,pea); + + if (pea.ForceNewPage) { + e.HasMorePages = true; + pea.ForceNewPage = false; + + } + } + + + //PageFooter + if (RenderPageEnd != null) { + RenderPageEnd (this,pea); + e.HasMorePages = false; + return; } } - protected override void OnEndPrint(PrintEventArgs e){ - base.OnEndPrint(e); - } - - #endregion - private void GeneratePage (SharpReportCore.ReportPageEventArgs page) { + /* + protected override void OnPrintPage(PrintPageEventArgs e){ + pageNumber ++; + base.OnPrintPage(e); + + + ReportPageEventArgs pea = new ReportPageEventArgs (e,pageNumber, + false,Point.Empty); + + // ReportHeader only on first page if (this.pageNumber == 1) { if (this.RenderReportHeader != null) { - this.RenderReportHeader(this,page); + this.RenderReportHeader(this,pea); } } + // allway draw PageHeader + if (this.RenderPageHeader != null) { - this.RenderPageHeader (this,page); + this.RenderPageHeader (this,pea); } + // Details - // print PageFooter before DetailSection - //so it's much easyer to calculate size of DetailSection - if (RenderPageEnd != null) { - RenderPageEnd (this,page); + if (!this.detailsDone) { + if (BodyStart != null) { + BodyStart (this,pea); + } + + if (this.RenderDetails != null) { + this.RenderDetails(this,pea); + } } - - if (PrintPageBodyStart != null) { - PrintPageBodyStart (this,page); + if (pea.ForceNewPage) { + if (RenderPageEnd != null) { + RenderPageEnd (this,pea); + return; + } + pea.ForceNewPage = false; + return; } - if (this.RenderDetails != null) { - this.RenderDetails(this,page); - } + // ReportFooter + + if (this.detailsDone) { + if (BodyEnd != null) { + BodyEnd (this,pea); + this.RenderReportEnd(this,pea); + + if (pea.ForceNewPage) { + e.HasMorePages = true; + pea.ForceNewPage = false; - if (page.PrintPageEventArgs.HasMorePages == false) { - if (PrintPageBodyEnd != null) { - PrintPageBodyEnd (this,page); + } } } + //PageFooter + if (RenderPageEnd != null) { + RenderPageEnd (this,pea); + e.HasMorePages = false; + return; + } } - - + */ + + protected override void OnEndPrint(PrintEventArgs e){ + base.OnEndPrint(e); + } + + #endregion + #region Property's @@ -117,6 +206,13 @@ namespace SharpReportCore { } } + public bool DetailsDone { + set { + detailsDone = value; + } + } + + #endregion } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandardFormatter.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandardFormatter.cs new file mode 100644 index 0000000000..05880e8aa6 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandardFormatter.cs @@ -0,0 +1,158 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Peter + * Date: 26.06.2006 + * Time: 09:42 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Globalization; +/// +/// This Class handles the formatting of Output Values depending on there +/// Type and DbValue +/// +namespace SharpReportCore { + + public class StandardFormatter : object { + + + public StandardFormatter() { + } + + //TODO why not TypeCode tc = Type.GetTypeCode( Type.GetType(this.dataType)); + + public string FormatItem (string valueToFormat,string formatString, + TypeCode typeCode,string nullValue) { + string retValue = String.Empty; + + if (String.IsNullOrEmpty(formatString)) { + retValue = valueToFormat; + return retValue; + } + + switch (typeCode) { + case TypeCode.Int16: + case TypeCode.Int32: + retValue = IntegerValues (valueToFormat,formatString); + break; + case TypeCode.DateTime: + retValue = DateValues(valueToFormat,formatString); + break; + case TypeCode.Boolean: + retValue = BoolValue (valueToFormat,formatString); + break; + case TypeCode.Decimal: + retValue = DecimalValues (valueToFormat,formatString); + break; + + case TypeCode.Double: + case TypeCode.Single: + break; + + case TypeCode.String: + case TypeCode.Char: + retValue = valueToFormat; + break; + default: + retValue = valueToFormat; + break; + } + + return retValue; + } + + + ///Looks witch formatting Class to use, call the approbiate formatter + /// and update the DbValue with the formatted String value + /// + ///A ReportDataItem + /// + public string FormatItem (BaseDataItem item) { + + if (item == null) { + throw new ArgumentNullException("item"); + } + return FormatItem(item.DbValue,item.FormatString, + Type.GetTypeCode( Type.GetType(item.DataType)), + item.NullValue); + + } + + private string BoolValue (string toFormat, string format){ + string str = String.Empty; + try { + bool b = bool.Parse (toFormat); + str = b.ToString (CultureInfo.CurrentCulture); + } catch (System.FormatException) { +// string s = String.Format("\tBool Value < {0} > {1}",toFormat,e.Message); +// System.Console.WriteLine("\t\t{0}",s); + } + return str; + } + + private string IntegerValues(string toFormat, string format) { + string str = String.Empty; + if (StandardFormatter.CheckValue (toFormat)) { + try { + int number = Int32.Parse (toFormat, + System.Globalization.NumberStyles.Any, + CultureInfo.CurrentCulture.NumberFormat); + + str = number.ToString (format,CultureInfo.CurrentCulture); + } catch (System.FormatException) { +// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message); +// System.Console.WriteLine("\t{0}",s); + } + return str; + } else { + str = (0.0M).ToString(CultureInfo.CurrentCulture); + } + return str; + } + + private string DecimalValues(string toFormat, string format) { + string str = String.Empty; + if (StandardFormatter.CheckValue (toFormat)) { + try { + decimal dec = Decimal.Parse(toFormat, + System.Globalization.NumberStyles.Any, + CultureInfo.CurrentCulture.NumberFormat); + str = dec.ToString (format,CultureInfo.CurrentCulture); + + } catch (System.FormatException) { +// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message); +// System.Console.WriteLine("\t{0}",s); + } + return str; + } else { + str = (0.0M).ToString(CultureInfo.CurrentCulture); + } + return str; + } + + private string DateValues(string toFormat, string format) { + try { + DateTime date = DateTime.Parse (toFormat.Trim(), + CultureInfo.CurrentCulture.DateTimeFormat); + string str = date.ToString(format, + DateTimeFormatInfo.CurrentInfo); + + return str.Trim(); + } catch (System.FormatException) { +// string s = String.Format("< {0} > {1}",toFormat,e.Message); +// System.Console.WriteLine("\t\tDateValue {0}",s); + } + + return toFormat.Trim(); + } + + private static bool CheckValue (string toFormat) { + if (String.IsNullOrEmpty(toFormat)) { + return false; + } + return true; + } + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs index c68019cbb1..69608e2b09 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs @@ -495,7 +495,6 @@ namespace SharpReportCore{ return reportType; } set { - System.Console.WriteLine("ReportType set to {0}",value); if (reportType != value) { reportType = value; this.NotifyPropertyChanged("ReportType"); @@ -626,7 +625,7 @@ namespace SharpReportCore{ set { if (dataModel != value) { dataModel = value; - System.Console.WriteLine("DataModel type = {0}",this.dataModel.ToString()); + if (this.dataModel != GlobalEnums.enmPushPullModel.FormSheet) { this.reportType = GlobalEnums.enmReportType.DataReport; } else { diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj index e23e486911..aa736918a1 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj @@ -83,8 +83,6 @@ - - @@ -94,7 +92,6 @@ - @@ -135,6 +132,9 @@ + + + @@ -152,7 +152,6 @@ - diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs index 0d37a3e22c..2df8fd6934 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs @@ -134,7 +134,6 @@ namespace SharpReportCore { } private void InitDataContainer (ReportSettings settings) { - System.Console.WriteLine("Engine:InitDataContainer ReportType <{0}>",settings.ReportType); if (settings.ReportType == GlobalEnums.enmReportType.DataReport) { if (settings.CommandText != null) { try { @@ -217,7 +216,7 @@ namespace SharpReportCore { default: throw new SharpReportException ("SharpReportmanager:SetupRenderer -> Unknown Reporttype"); } - abstr.SectionRendering += new EventHandler(OnSectionPrinting); + abstr.Rendering += new EventHandler(OnSectionPrinting); abstr.SectionRendered +=new EventHandler(OnSectionPrinted); return abstr; } catch (Exception) { @@ -228,8 +227,9 @@ namespace SharpReportCore { private void OnSectionPrinting (object sender,SectionRenderEventArgs e) { if (this.SectionRendering != null) { + System.Console.WriteLine(""); this.SectionRendering(this,e); - } + } } private void OnSectionPrinted (object sender,SectionRenderEventArgs e) { @@ -260,6 +260,8 @@ namespace SharpReportCore { if (this.dataManager.DataSource != null) { abstr = new RendererFactory().Create (model,dataManager); } + abstr.Rendering += new EventHandler(OnSectionPrinting); + abstr.SectionRendered +=new EventHandler(OnSectionPrinted); return abstr; } @@ -344,10 +346,6 @@ namespace SharpReportCore { model = ModelFromFile (fileName); if (CheckReportParameters (model,reportParameters)) { renderer = SetupStandartRenderer (model); - // -// renderer.SectionRendering += new EventHandler(OnTestPrinting); -// System.Console.WriteLine("Event should be set"); - if (renderer != null) { PreviewControl.ShowPreview(renderer,1.5,false); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs index dbbc31d49a..10705f7518 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs @@ -101,6 +101,7 @@ namespace ReportGenerator { } else { section.Items.Add (this.parentItem); IContainerItem containerItem = this.parentItem as IContainerItem; + this.parentItem.Parent = section; if ( containerItem != null) { this.AddItemsToParent (containerItem,this.ReportItemCollection); @@ -171,16 +172,15 @@ namespace ReportGenerator { protected void AdjustAllNames () { foreach (BaseSection sec in this.reportModel.SectionCollection) { - AdjustNames(sec.Items); + BuildProperNames(sec.Items); } } - private void AdjustNames (ReportItemCollection items) { - + private void BuildProperNames (ReportItemCollection items) { foreach (IItemRenderer item in items) { IContainerItem it = item as IContainerItem; if (it != null) { - AdjustNames (it.Items); + BuildProperNames (it.Items); } item.Name = nameService.CreateName(items,item.Name); } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Resources/CSharp-Mode.xshd b/src/Libraries/ICSharpCode.TextEditor/Project/Resources/CSharp-Mode.xshd index 3ee8b4b650..3606145fbf 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Resources/CSharp-Mode.xshd +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Resources/CSharp-Mode.xshd @@ -17,13 +17,16 @@ # - - /// + + ///@!/@ //@!/@ + + //// + /* diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManager.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManager.cs index 14bf93cd82..9fa3b40209 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManager.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManager.cs @@ -64,20 +64,25 @@ namespace ICSharpCode.TextEditor.Document /// public void ToggleMarkAt(int lineNr) { + Bookmark newMark; + if (factory != null) + newMark = factory.CreateBookmark(document, lineNr); + else + newMark = new Bookmark(document, lineNr); + + Type newMarkType = newMark.GetType(); + for (int i = 0; i < bookmark.Count; ++i) { Bookmark mark = bookmark[i]; - if (mark.LineNumber == lineNr && mark.CanToggle) { + + if (mark.LineNumber == lineNr && mark.CanToggle && mark.GetType() == newMarkType) { bookmark.RemoveAt(i); OnRemoved(new BookmarkEventArgs(mark)); OnChanged(EventArgs.Empty); return; } } - Bookmark newMark; - if (factory != null) - newMark = factory.CreateBookmark(document, lineNr); - else - newMark = new Bookmark(document, lineNr); + bookmark.Add(newMark); OnAdded(new BookmarkEventArgs(newMark)); OnChanged(EventArgs.Empty); diff --git a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG index 2fccc15821..4fe3666c04 100644 --- a/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG +++ b/src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG @@ -1886,7 +1886,7 @@ EmbeddedStatement (statement as IfElseStatement).ElseIfSections.AddRange((elseStatement as IfElseStatement).ElseIfSections); (statement as IfElseStatement).FalseStatement = (elseStatement as IfElseStatement).FalseStatement; } .) - | "switch" (. List switchSections = new List(); SwitchSection switchSection; .) + | "switch" (. List switchSections = new List(); .) "(" Expr ")" "{" SwitchSections "}" (. statement = new SwitchStatement(expr, switchSections); .) diff --git a/src/Main/Base/Project/Src/Commands/BuildCommands.cs b/src/Main/Base/Project/Src/Commands/BuildCommands.cs index e8a68875cb..1459b355f1 100644 --- a/src/Main/Base/Project/Src/Commands/BuildCommands.cs +++ b/src/Main/Base/Project/Src/Commands/BuildCommands.cs @@ -66,28 +66,35 @@ namespace ICSharpCode.SharpDevelop.Project.Commands public event EventHandler BuildComplete; } - public class Build : AbstractBuildMenuCommand + public sealed class Build : AbstractBuildMenuCommand { public override void StartBuild() { + ProjectService.RaiseEventStartBuild(); ProjectService.OpenSolution.Build(CallbackMethod); } public override void AfterBuild() { - ProjectService.OnEndBuild(); + ProjectService.RaiseEventEndBuild(); } } - public class Rebuild : Build + public sealed class Rebuild : AbstractBuildMenuCommand { public override void StartBuild() { + ProjectService.RaiseEventStartBuild(); ProjectService.OpenSolution.Rebuild(CallbackMethod); } + + public override void AfterBuild() + { + ProjectService.RaiseEventEndBuild(); + } } - public class Clean : AbstractBuildMenuCommand + public sealed class Clean : AbstractBuildMenuCommand { public override void StartBuild() { @@ -95,7 +102,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands } } - public class Publish : AbstractBuildMenuCommand + public sealed class Publish : AbstractBuildMenuCommand { public override void StartBuild() { @@ -138,22 +145,24 @@ namespace ICSharpCode.SharpDevelop.Project.Commands public override void StartBuild() { + ProjectService.RaiseEventStartBuild(); this.ProjectToBuild.Build(CallbackMethod, AdditionalProperties); } public override void AfterBuild() { - ProjectService.OnEndBuild(); + ProjectService.RaiseEventEndBuild(); } } - public class RebuildProject : BuildProject + public sealed class RebuildProject : BuildProject { public RebuildProject() {} public RebuildProject(IProject targetProject) : base(targetProject) {} public override void StartBuild() { + ProjectService.RaiseEventStartBuild(); this.ProjectToBuild.Rebuild(CallbackMethod, AdditionalProperties); } } diff --git a/src/Main/Base/Project/Src/Dom/CecilReader.cs b/src/Main/Base/Project/Src/Dom/CecilReader.cs index 414caa9258..7aa1150c47 100644 --- a/src/Main/Base/Project/Src/Dom/CecilReader.cs +++ b/src/Main/Base/Project/Src/Dom/CecilReader.cs @@ -313,7 +313,9 @@ namespace ICSharpCode.SharpDevelop.Dom } m.ReturnType = CreateType(this.ProjectContent, m, method.ReturnType.ReturnType); - if (this.ClassType != ClassType.Interface) { + if (this.ClassType == ClassType.Interface) { + m.Modifiers = ModifierEnum.Public | ModifierEnum.Abstract; + } else { m.Modifiers = TranslateModifiers(method); } AddParameters(m, method.Parameters); diff --git a/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeNode.cs b/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeNode.cs index f9653635f8..be0573509d 100644 --- a/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeNode.cs +++ b/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeNode.cs @@ -99,6 +99,7 @@ namespace ICSharpCode.SharpDevelop.Gui public virtual void ActivateItem() { + this.Toggle(); } public virtual void CheckedChanged() diff --git a/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs b/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs index 14bbf4a019..c9e9956292 100644 --- a/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs +++ b/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs @@ -151,7 +151,7 @@ namespace ICSharpCode.SharpDevelop.Gui protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { - if (!SelectedNode.IsEditing) { + if (SelectedNode == null || !SelectedNode.IsEditing) { switch (keyData) { case Keys.F2: StartLabelEdit(SelectedNode as ExtTreeNode); @@ -186,9 +186,15 @@ namespace ICSharpCode.SharpDevelop.Gui bool inRefresh; protected override void OnBeforeExpand(TreeViewCancelEventArgs e) { + if (mouseClickNum == 2) { + mouseClickNum = 0; // only intercept first occurrance, don't prevent expansion by ActivateItem on double click + e.Cancel = true; + return; + } base.OnBeforeExpand(e); - if (e.Node == null) + if (e.Node == null) { return; + } try { if (e.Node is ExtTreeNode) { if (((ExtTreeNode)e.Node).IsInitialized == false) { @@ -224,9 +230,13 @@ namespace ICSharpCode.SharpDevelop.Gui } } - protected override void OnBeforeCollapse(TreeViewCancelEventArgs e) { + if (mouseClickNum == 2) { + mouseClickNum = 0; // only intercept first occurrance, don't prevent collapsing by ActivateItem on double click + e.Cancel = true; + return; + } base.OnBeforeCollapse(e); if (e.Node is ExtTreeNode) { ((ExtTreeNode)e.Node).Collapsing(); @@ -268,8 +278,11 @@ namespace ICSharpCode.SharpDevelop.Gui } } + int mouseClickNum; // 0 if mouse button is not pressed, otherwise click number (1=normal, 2=double click) + protected override void OnMouseDown(MouseEventArgs e) { + mouseClickNum = e.Clicks; base.OnMouseDown(e); TreeNode node = GetNodeAt(e.X, e.Y); if (node != null) { @@ -283,6 +296,12 @@ namespace ICSharpCode.SharpDevelop.Gui } } + protected override void OnMouseUp(MouseEventArgs e) + { + mouseClickNum = 0; + base.OnMouseUp(e); + } + protected override void OnBeforeSelect(TreeViewCancelEventArgs e) { // setting the context menu must be done by BeforeSelect because diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs index da2a856952..c1220f313e 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/NewFileDialog.cs @@ -373,7 +373,7 @@ namespace ICSharpCode.SharpDevelop.Gui return true; } - public void SaveFile(FileDescriptionTemplate newfile, string content) + public void SaveFile(FileDescriptionTemplate newfile, string content, byte[] binaryContent) { string parsedFileName = StringParser.Parse(newfile.Name); // Parse twice so that tags used in included standard header are parsed @@ -382,9 +382,16 @@ namespace ICSharpCode.SharpDevelop.Gui parsedFileName = parsedFileName.Substring(1); if (newfile.IsDependentFile && Path.IsPathRooted(parsedFileName)) { Directory.CreateDirectory(Path.GetDirectoryName(parsedFileName)); - File.WriteAllText(parsedFileName, parsedContent, ParserService.DefaultFileEncoding); + if (binaryContent != null) + File.WriteAllBytes(parsedFileName, binaryContent); + else + File.WriteAllText(parsedFileName, parsedContent, ParserService.DefaultFileEncoding); ParserService.ParseFile(parsedFileName, parsedContent); } else { + if (binaryContent != null) { + LoggingService.Warn("binary file was skipped"); + return; + } IWorkbenchWindow window = FileService.NewFile(Path.GetFileName(parsedFileName), StringParser.Parse(newfile.Language), parsedContent); if (window == null) { return; @@ -486,7 +493,11 @@ namespace ICSharpCode.SharpDevelop.Gui ScriptRunner scriptRunner = new ScriptRunner(); foreach (FileDescriptionTemplate newfile in item.Template.FileDescriptionTemplates) { - SaveFile(newfile, scriptRunner.CompileScript(item.Template, newfile)); + if (newfile.ContentData != null) { + SaveFile(newfile, null, newfile.ContentData); + } else { + SaveFile(newfile, scriptRunner.CompileScript(item.Template, newfile), null); + } } DialogResult = DialogResult.OK; } diff --git a/src/Main/Base/Project/Src/Gui/IWorkbench.cs b/src/Main/Base/Project/Src/Gui/IWorkbench.cs index d7df9739b9..04e2b64196 100644 --- a/src/Main/Base/Project/Src/Gui/IWorkbench.cs +++ b/src/Main/Base/Project/Src/Gui/IWorkbench.cs @@ -90,6 +90,11 @@ namespace ICSharpCode.SharpDevelop.Gui /// /// Is called, when a workbench view was opened /// + /// + /// WorkbenchSingleton.WorkbenchCreated += delegate { + /// WorkbenchSingleton.Workbench.ViewOpened += ...; + /// }; + /// event ViewContentEventHandler ViewOpened; /// diff --git a/src/Main/Base/Project/Src/Gui/Pads/FileScout.cs b/src/Main/Base/Project/Src/Gui/Pads/FileScout.cs index fdc538fa64..e9d92740f2 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/FileScout.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/FileScout.cs @@ -365,21 +365,18 @@ namespace ICSharpCode.SharpDevelop.Gui { base.OnAfterLabelEdit(e); - if(e.Label == null) { + if (e.Label == null || !FileService.CheckFileName(e.Label)) { e.CancelEdit = true; return; } - string filename = ((FileListItem)Items[e.Item]).FullName; - string newname = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar + e.Label; + string oldFileName = ((FileListItem)Items[e.Item]).FullName; + string newFileName = Path.Combine(Path.GetDirectoryName(oldFileName), e.Label); - try { - File.Move(filename, newname); - ((FileListItem)Items[e.Item]).FullName = newname; - } catch(Exception ex) { + if (FileService.RenameFile(oldFileName, newFileName, false)) { + ((FileListItem)Items[e.Item]).FullName = newFileName; + } else { e.CancelEdit = true; - - MessageService.ShowError(ex, "Rename failed"); } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs index 4427778001..2616f7fc55 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SolutionNodeCommands.cs @@ -52,8 +52,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands newProject.Location = FileUtility.GetRelativePath(solutionFolderNode.Solution.Directory, fileName); ProjectService.AddProject(solutionFolderNode, newProject); NodeBuilders.AddProjectNode((TreeNode)solutionFolderNode, newProject).EnsureVisible(); - solutionFolderNode.Solution.ApplySolutionConfigurationToProjects(); - solutionFolderNode.Solution.ApplySolutionPlatformToProjects(); + solutionFolderNode.Solution.ApplySolutionConfigurationAndPlatformToProjects(); } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs index c117c5a17a..30fed9d8ef 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/ProjectNode.cs @@ -147,13 +147,12 @@ namespace ICSharpCode.SharpDevelop.Project // } // } string newFileName = Path.Combine(project.Directory, newName + Path.GetExtension(project.FileName)); - if (File.Exists(newFileName)) { - MessageService.ShowError("The file " + newFileName + " already exists."); + + if (!FileService.RenameFile(project.FileName, newFileName, false)) { return; } if (project.AssemblyName == project.Name) project.AssemblyName = newName; - FileService.RenameFile(project.FileName, newFileName, false); if (File.Exists(project.FileName + ".user")) FileService.RenameFile(project.FileName + ".user", newFileName + ".user", false); foreach (IProject p in ProjectService.OpenSolution.Projects) { diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionItemNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionItemNode.cs index 21d4cbf95f..f192c15351 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionItemNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionItemNode.cs @@ -128,7 +128,9 @@ namespace ICSharpCode.SharpDevelop.Project } string newFileName = Path.Combine(Path.GetDirectoryName(this.FileName), newName); - FileService.RenameFile(this.FileName, newFileName, false); + if (!FileService.RenameFile(this.FileName, newFileName, false)) { + return; + } solution.Save(); } public override object AcceptVisitor(ProjectBrowserTreeNodeVisitor visitor, object data) diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionNode.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionNode.cs index c240b21ec1..d605bb6f97 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionNode.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/SolutionNode.cs @@ -60,11 +60,9 @@ namespace ICSharpCode.SharpDevelop.Project if (!FileService.CheckFileName(newName)) return; string newFileName = Path.Combine(solution.Directory, newName + ".sln"); - if (File.Exists(newFileName)) { - MessageService.ShowErrorFormatted("${res:Global.FileAlreadyExists}", newFileName); + if (!FileService.RenameFile(solution.FileName, newFileName, false)) { return; } - FileService.RenameFile(solution.FileName, newFileName, false); solution.FileName = newFileName; solution.Name = newName; } finally { diff --git a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs index 3c41bd5701..3a2b3a29b5 100644 --- a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs +++ b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs @@ -52,12 +52,6 @@ namespace ICSharpCode.SharpDevelop.Gui } } - static WorkbenchSingleton() - { - PropertyService.PropertyChanged += new PropertyChangedEventHandler(TrackPropertyChanges); - ResourceService.LanguageChanged += delegate { workbench.RedrawAllComponents(); }; - } - /// /// This method handles the redraw all event for specific changed IDE properties /// @@ -82,6 +76,9 @@ namespace ICSharpCode.SharpDevelop.Gui workbench = new DefaultWorkbench(); MessageService.MainForm = workbench; + PropertyService.PropertyChanged += new PropertyChangedEventHandler(TrackPropertyChanges); + ResourceService.LanguageChanged += delegate { workbench.RedrawAllComponents(); }; + caller = new STAThreadCaller(workbench); workbench.InitializeWorkspace(); diff --git a/src/Main/Base/Project/Src/Internal/Templates/File/FileDescriptionTemplate.cs b/src/Main/Base/Project/Src/Internal/Templates/File/FileDescriptionTemplate.cs index 6145f2c11d..7c55f2311d 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/File/FileDescriptionTemplate.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/File/FileDescriptionTemplate.cs @@ -19,7 +19,11 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates { string name; string language; + + // Either content or contentData is set, the other is null string content; + byte[] contentData; + string buildAction; string copyToOutputDirectory; string dependentUpon; @@ -42,7 +46,11 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates if (xml.HasAttribute("src")) { string fileName = Path.Combine(hintPath, StringParser.Parse(xml.GetAttribute("src"))); try { - content = File.ReadAllText(fileName); + if (xml.HasAttribute("binary") && bool.Parse(xml.GetAttribute("binary"))) { + contentData = File.ReadAllBytes(fileName); + } else { + content = File.ReadAllText(fileName); + } } catch (Exception e) { content = "Error reading content from " + fileName + ":\n" + e.ToString(); LoggingService.Warn(content); @@ -95,6 +103,12 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates } } + public byte[] ContentData { + get { + return contentData; + } + } + public string BuildAction { get { return buildAction ?? ""; diff --git a/src/Main/Base/Project/Src/Internal/Templates/File/ScriptRunner.cs b/src/Main/Base/Project/Src/Internal/Templates/File/ScriptRunner.cs index 382b960b81..b76df9ddae 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/File/ScriptRunner.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/File/ScriptRunner.cs @@ -33,6 +33,8 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates public string CompileScript(FileTemplate item, FileDescriptionTemplate file) { + if (file.Content == null) + throw new ArgumentException("file must have textual content"); Match m = scriptRegex.Match(file.Content); m = m.NextMatch(); if (m.Success) { diff --git a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs index 28cfea7103..78d57cddc4 100644 --- a/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs +++ b/src/Main/Base/Project/Src/Internal/Templates/Project/ProjectDescriptor.cs @@ -202,11 +202,15 @@ namespace ICSharpCode.SharpDevelop.Internal.Templates if (!Directory.Exists(Path.GetDirectoryName(fileName))) { Directory.CreateDirectory(Path.GetDirectoryName(fileName)); } - Properties properties = ((Properties)PropertyService.Get("ICSharpCode.TextEditor.Document.Document.DefaultDocumentAggregatorProperties", new Properties())); - - StreamWriter sr = new StreamWriter(File.Create(fileName), Encoding.GetEncoding(properties.Get("Encoding", 1252))); - sr.Write(StringParser.Parse(StringParser.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}}))); - sr.Close(); + if (file.ContentData != null) { + // Binary content + File.WriteAllBytes(fileName, file.ContentData); + } else { + // Textual content + StreamWriter sr = new StreamWriter(File.Create(fileName), ParserService.DefaultFileEncoding); + sr.Write(StringParser.Parse(StringParser.Parse(file.Content, new string[,] { {"ProjectName", projectCreateInformation.ProjectName}, {"FileName", fileName}}))); + sr.Close(); + } } catch (Exception ex) { StringParser.Properties["fileName"] = fileName; MessageService.ShowError(ex, "${res:ICSharpCode.SharpDevelop.Internal.Templates.ProjectDescriptor.FileCouldntBeWrittenError}"); diff --git a/src/Main/Base/Project/Src/Project/Solution/Solution.cs b/src/Main/Base/Project/Src/Project/Solution/Solution.cs index 501aa1d2bd..551ce6b7a3 100644 --- a/src/Main/Base/Project/Src/Project/Solution/Solution.cs +++ b/src/Main/Base/Project/Src/Project/Solution/Solution.cs @@ -496,12 +496,21 @@ namespace ICSharpCode.SharpDevelop.Project public ProjectSection GetSolutionConfigurationsSection() { - foreach (ProjectSection sec in Sections) { + foreach (ProjectSection sec in this.Sections) { if (sec.Name == "SolutionConfigurationPlatforms") return sec; } ProjectSection newSec = new ProjectSection("SolutionConfigurationPlatforms", "preSolution"); - Sections.Insert(0, newSec); + this.Sections.Insert(0, newSec); + foreach (ProjectSection sec in this.Sections) { + if (sec.Name == "SolutionConfiguration") { + this.Sections.Remove(sec); + foreach (SolutionItem item in sec.Items) { + newSec.Items.Add(new SolutionItem(item.Name + "|Any CPU", item.Location + "|Any CPU")); + } + break; + } + } return newSec; } @@ -513,6 +522,49 @@ namespace ICSharpCode.SharpDevelop.Project } ProjectSection newSec = new ProjectSection("ProjectConfigurationPlatforms", "postSolution"); Sections.Add(newSec); + foreach (ProjectSection sec in this.Sections) { + if (sec.Name == "ProjectConfiguration") { + this.Sections.Remove(sec); + foreach (SolutionItem item in sec.Items) { + string name = item.Name; + string location = item.Location; + if (!name.Contains("|")) { + int pos = name.LastIndexOf('.'); + if (pos > 0) { + string firstpart = name.Substring(0, pos); + string lastpart = name.Substring(pos); + if (lastpart == ".0") { + pos = firstpart.LastIndexOf('.'); + if (pos > 0) { + lastpart = name.Substring(pos); + firstpart = name.Substring(0, pos); + } + } + name = firstpart + "|Any CPU" + lastpart; + } + + pos = location.LastIndexOf('|'); + if (pos < 0) { + location += "|Any CPU"; + } else { + string platform = location.Substring(pos+1); + bool found = false; + foreach (IProject p in this.Projects) { + if (p.GetPlatformNames().Contains(platform)) { + found = true; + break; + } + } + if (!found) { + location = location.Substring(0, pos) + "|Any CPU"; + } + } + } + newSec.Items.Add(new SolutionItem(name, location)); + } + break; + } + } return newSec; } @@ -575,17 +627,34 @@ namespace ICSharpCode.SharpDevelop.Project public void ApplySolutionConfigurationToProjects() { - // TODO: Use assignments from project configuration section - foreach (IProject p in Projects) { - p.Configuration = preferences.ActiveConfiguration; - } + ApplySolutionConfigurationAndPlatformToProjects(); } public void ApplySolutionPlatformToProjects() { - // TODO: Use assignments from project configuration section + ApplySolutionConfigurationAndPlatformToProjects(); + } + + public void ApplySolutionConfigurationAndPlatformToProjects() + { + string conf = preferences.ActiveConfiguration; + string plat = preferences.ActivePlatform; + ProjectSection prjSec = GetProjectConfigurationsSection(); + Dictionary dict = new Dictionary(); + foreach (SolutionItem item in prjSec.Items) { + dict[item.Name] = item.Location; + } + string searchKeyPostFix = "." + conf + "|" + plat + ".Build.0"; foreach (IProject p in Projects) { - p.Platform = preferences.ActivePlatform; + string searchKey = p.IdGuid + searchKeyPostFix; + string targetConfPlat; + if (dict.TryGetValue(searchKey, out targetConfPlat)) { + p.Configuration = AbstractProject.GetConfigurationNameFromKey(targetConfPlat); + p.Platform = AbstractProject.GetPlatformNameFromKey(targetConfPlat); + } else { + p.Configuration = conf; + p.Platform = plat; + } } } diff --git a/src/Main/Base/Project/Src/Services/File/FileService.cs b/src/Main/Base/Project/Src/Services/File/FileService.cs index 94cbb088bf..43345353e5 100644 --- a/src/Main/Base/Project/Src/Services/File/FileService.cs +++ b/src/Main/Base/Project/Src/Services/File/FileService.cs @@ -192,14 +192,20 @@ namespace ICSharpCode.Core return false; if (!eargs.OperationAlreadyDone) { try { - if (isDirectory) { - if (Directory.Exists(oldName)) { - Directory.Move(oldName, newName); + if (isDirectory && Directory.Exists(oldName)) { + + if (Directory.Exists(newName)) { + MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}")); + return false; } - } else { - if (File.Exists(oldName)) { - File.Move(oldName, newName); + Directory.Move(oldName, newName); + + } else if (File.Exists(oldName)) { + if (File.Exists(newName)) { + MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}")); + return false; } + File.Move(oldName, newName); } } catch (Exception e) { if (isDirectory) { diff --git a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs index 2e70ede5f9..d6dac81aee 100644 --- a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs +++ b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs @@ -279,8 +279,7 @@ namespace ICSharpCode.SharpDevelop.Project static void ApplyConfigurationAndReadPreferences() { - openSolution.ApplySolutionConfigurationToProjects(); - openSolution.ApplySolutionPlatformToProjects(); + openSolution.ApplySolutionConfigurationAndPlatformToProjects(); foreach (IProject project in openSolution.Projects) { string file = GetPreferenceFileName(project.FileName); if (FileUtility.IsValidFileName(file) && File.Exists(file)) { @@ -483,23 +482,25 @@ namespace ICSharpCode.SharpDevelop.Project } } - static void OnStartBuild(EventArgs e) + public static void RaiseEventStartBuild() { if (StartBuild != null) { - StartBuild(null, e); + StartBuild(null, EventArgs.Empty); } } - public static void OnEndBuild() + public static void RaiseEventEndBuild() { - OnEndBuild(new EventArgs()); + if (EndBuild != null) { + EndBuild(null, EventArgs.Empty); + } } - static void OnEndBuild(EventArgs e) + // TODO: Remove me in Serralongue + [Obsolete("Use RaiseEventEndBuild instead")] + public static void OnEndBuild() { - if (EndBuild != null) { - EndBuild(null, e); - } + RaiseEventEndBuild(); } public static void RemoveSolutionFolder(string guid) diff --git a/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/AbstractClassImplementorCodeGenerator.cs b/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/AbstractClassImplementorCodeGenerator.cs index 258d9aa140..d9d88ba18f 100644 --- a/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/AbstractClassImplementorCodeGenerator.cs +++ b/src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/AbstractClassImplementorCodeGenerator.cs @@ -35,7 +35,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands foreach (IProperty property in currentClass.DefaultReturnType.GetProperties()) { if (property.IsAbstract) { AttributedNode node = CodeGenerator.ConvertMember(property, classFinderContext); - node.Modifier &= ~Modifier.Abstract; + node.Modifier &= ~(Modifier.Abstract | Modifier.Virtual); node.Modifier |= Modifier.Override; nodes.Add(node); } @@ -43,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands foreach (IMethod method in currentClass.DefaultReturnType.GetMethods()) { if (method.IsAbstract) { AttributedNode node = CodeGenerator.ConvertMember(method, classFinderContext); - node.Modifier &= ~Modifier.Abstract; + node.Modifier &= ~(Modifier.Abstract | Modifier.Virtual); node.Modifier |= Modifier.Override; nodes.Add(node); } diff --git a/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Gui/SearchAndReplacePanel.cs b/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Gui/SearchAndReplacePanel.cs index 024ac464f1..9f6cc5dc7e 100644 --- a/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Gui/SearchAndReplacePanel.cs +++ b/src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Gui/SearchAndReplacePanel.cs @@ -42,11 +42,13 @@ namespace SearchAndReplace SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("Resources.FindPanel.xfrm")); Get