61 changed files with 5281 additions and 53 deletions
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 17.02.2014 |
||||
* Time: 20:07 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.Reporting.Addin.DesignerBinding; |
||||
using ICSharpCode.Reporting.Addin.Views; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Commands |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ViewCommands.
|
||||
/// </summary>
|
||||
public class CreateDesignerCommand : AbstractMenuCommand |
||||
{ |
||||
readonly OpenedFile openedFile; |
||||
|
||||
public CreateDesignerCommand() { |
||||
MessageService.ShowMessage("Not implemented at the moment","Reporting"); |
||||
} |
||||
|
||||
public CreateDesignerCommand (OpenedFile openedFile) { |
||||
if (openedFile == null) |
||||
throw new ArgumentNullException("openedFile"); |
||||
this.openedFile = openedFile; |
||||
} |
||||
|
||||
public override void Run(){ |
||||
var generator = new DesignerGenerator(); |
||||
|
||||
DesignerView = new DesignerView(openedFile, generator); |
||||
} |
||||
|
||||
public DesignerView DesignerView {get; private set;} |
||||
} |
||||
} |
||||
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 15.03.2014 |
||||
* Time: 19:30 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using ICSharpCode.Reporting.Addin.TypeProvider; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignableItems |
||||
{ |
||||
/// <summary>
|
||||
/// Description of AbstractItem.
|
||||
/// </summary>
|
||||
// [TypeDescriptionProvider(typeof(AbstractItemTypeProvider))]
|
||||
public abstract class AbstractItem:System.Windows.Forms.Control |
||||
{ |
||||
Color frameColor = Color.Black; |
||||
|
||||
|
||||
protected AbstractItem() |
||||
{ |
||||
InitializeComponent(); |
||||
TypeDescriptor.AddProvider(new AbstractItemTypeProvider(), typeof(AbstractItem)); |
||||
} |
||||
|
||||
|
||||
protected void DrawControl (Graphics graphics,Rectangle borderRectangle) |
||||
{ |
||||
if (DrawBorder == true) { |
||||
graphics.DrawRectangle(new Pen(frameColor),borderRectangle); |
||||
} |
||||
System.Windows.Forms.ControlPaint.DrawBorder3D(graphics, this.ClientRectangle, |
||||
System.Windows.Forms.Border3DStyle.Etched); |
||||
} |
||||
|
||||
|
||||
#region Property's
|
||||
|
||||
protected Rectangle DrawingRectangle { |
||||
get { |
||||
|
||||
return new Rectangle(this.ClientRectangle.Left , |
||||
ClientRectangle.Top , |
||||
ClientRectangle.Width -1, |
||||
ClientRectangle.Height -1); |
||||
} |
||||
} |
||||
|
||||
|
||||
[Category("Border")] |
||||
public Color FrameColor { |
||||
get { return frameColor; } |
||||
set { |
||||
frameColor = value; |
||||
this.Invalidate(); |
||||
} |
||||
} |
||||
|
||||
|
||||
[Category("Border"), |
||||
Description("Draw a Border around the Item")] |
||||
public bool DrawBorder {get;set;} |
||||
|
||||
|
||||
protected new Size DefaultSize {get;set;} |
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public abstract void Draw(Graphics graphics); |
||||
|
||||
private void InitializeComponent() |
||||
{ |
||||
SuspendLayout(); |
||||
ResumeLayout(false); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,159 @@
@@ -0,0 +1,159 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.03.2014 |
||||
* Time: 17:54 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using System.Drawing.Drawing2D; |
||||
using ICSharpCode.Reporting.Addin.Designer; |
||||
using ICSharpCode.Reporting.Addin.TypeProvider; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignableItems |
||||
{ |
||||
[Designer(typeof(LineDesigner))] |
||||
public class BaseLineItem:AbstractItem |
||||
{ |
||||
Point fromPoint; |
||||
Point toPoint; |
||||
LineCap startLineCap; |
||||
LineCap endLineCap; |
||||
DashCap dashLineCap; |
||||
DashStyle dashStyle; |
||||
float thickness; |
||||
|
||||
public BaseLineItem() |
||||
{ |
||||
this.thickness = 1; |
||||
this.dashStyle = DashStyle.Solid; |
||||
this.Size = new Size(50,10); |
||||
TypeDescriptor.AddProvider(new LineItemTypeProvider(), typeof(BaseLineItem)); |
||||
this.SetStartEndPoint(); |
||||
} |
||||
|
||||
void SetStartEndPoint () |
||||
{ |
||||
fromPoint = new Point(ClientRectangle.Left + 10,ClientRectangle.Height / 2); |
||||
toPoint = new Point(ClientRectangle.Left + ClientRectangle.Width - 10, |
||||
ClientRectangle.Height/ 2); |
||||
Invalidate(); |
||||
} |
||||
|
||||
|
||||
|
||||
// [System.ComponentModel.EditorBrowsableAttribute()]
|
||||
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) |
||||
{ |
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality; |
||||
base.OnPaint(e); |
||||
Draw(e.Graphics); |
||||
} |
||||
|
||||
|
||||
public override void Draw(Graphics graphics) |
||||
{ |
||||
if (graphics == null) { |
||||
throw new ArgumentNullException("graphics"); |
||||
} |
||||
using (Pen p = new Pen(this.ForeColor,this.Thickness)) { |
||||
p.SetLineCap(this.StartLineCap,this.EndLineCap,this.DashLineCap); |
||||
graphics.DrawLine(p,this.fromPoint,this.toPoint); |
||||
} |
||||
} |
||||
|
||||
|
||||
public Point FromPoint { |
||||
get { return fromPoint; } |
||||
set { |
||||
Point x = value; |
||||
if (!this.ClientRectangle.Contains(x)) { |
||||
this.fromPoint = new Point(x.X - this.Location.X, |
||||
x.Y - this.Location.Y); |
||||
} else { |
||||
this.fromPoint = x; |
||||
} |
||||
this.Invalidate(); |
||||
} |
||||
} |
||||
|
||||
|
||||
public Point ToPoint { |
||||
get { return toPoint; } |
||||
set { |
||||
Point x = value; |
||||
if (!ClientRectangle.Contains(x)) { |
||||
this.toPoint = new Point(x.X - this.Location.X, |
||||
x.Y - this.Location.Y); |
||||
} |
||||
else { |
||||
toPoint = x; |
||||
} |
||||
Invalidate(); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
// [Browsable(true),
|
||||
// Category("Appearance"),
|
||||
// Description("LineStyle")]
|
||||
public DashStyle DashStyle { |
||||
get { return dashStyle; } |
||||
set { |
||||
dashStyle = value; |
||||
this.Invalidate(); |
||||
} |
||||
} |
||||
|
||||
|
||||
// [Browsable(true),
|
||||
// Category("Appearance"),
|
||||
// Description("Thickness of Line")]
|
||||
public float Thickness { |
||||
get { return thickness; } |
||||
set { |
||||
thickness = value; |
||||
this.Invalidate(); |
||||
} |
||||
} |
||||
|
||||
// [Browsable(true),
|
||||
// Category("Appearance"),
|
||||
// Description("LineCap at Startposition")]
|
||||
public LineCap StartLineCap { |
||||
get { return startLineCap; } |
||||
set { |
||||
startLineCap = value; |
||||
this.Invalidate(); |
||||
} |
||||
} |
||||
|
||||
// [Browsable(true),
|
||||
// Category("Appearance"),
|
||||
// Description("Linecap at Endposition")]
|
||||
public LineCap EndLineCap { |
||||
get { return endLineCap; } |
||||
set { |
||||
endLineCap = value; |
||||
this.Invalidate(); |
||||
} |
||||
} |
||||
|
||||
// [Browsable(true),
|
||||
// Category("Appearance"),
|
||||
// Description("Dashlinecap")]
|
||||
public DashCap DashLineCap { |
||||
get { return dashLineCap; } |
||||
set { |
||||
dashLineCap = value; |
||||
this.Invalidate(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 15.03.2014 |
||||
* Time: 19:24 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using ICSharpCode.Reporting.Addin.TypeProvider; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignableItems |
||||
{ |
||||
/// <summary>
|
||||
/// Description of BaseSection.
|
||||
/// </summary>
|
||||
[TypeDescriptionProvider(typeof(SectionItemTypeProvider))] |
||||
[Designer(typeof(ICSharpCode.Reporting.Addin.Designer.SectionDesigner))] |
||||
public class BaseSection:AbstractItem |
||||
{ |
||||
|
||||
public BaseSection():base() |
||||
{ |
||||
FrameColor = Color.Black; |
||||
TypeDescriptor.AddProvider(new SectionItemTypeProvider(), typeof(BaseSection)); |
||||
} |
||||
|
||||
|
||||
// [EditorBrowsableAttribute()]
|
||||
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) |
||||
{ |
||||
base.OnPaint(e); |
||||
Draw(e.Graphics); |
||||
} |
||||
|
||||
|
||||
public override void Draw(Graphics graphics) |
||||
{ |
||||
DrawControl(graphics, Rectangle.Inflate(this.ClientRectangle, -2, -2)); |
||||
} |
||||
|
||||
|
||||
#region Propertys
|
||||
|
||||
[Browsable(false)] |
||||
public int SectionOffset {get;set;} |
||||
|
||||
[Browsable(false)] |
||||
public int SectionMargin {get;set;} |
||||
|
||||
public bool PageBreakAfter {get;set;} |
||||
|
||||
public bool CanGrow {get;set;} |
||||
|
||||
public bool CanShrink {get;set;} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,178 @@
@@ -0,0 +1,178 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.03.2014 |
||||
* Time: 20:30 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using ICSharpCode.Reporting.BaseClasses; |
||||
using ICSharpCode.Reporting.Globals; |
||||
using ICSharpCode.Reporting.Addin.Designer; |
||||
using ICSharpCode.Reporting.Addin.TypeProvider; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignableItems |
||||
{ |
||||
/// <summary>
|
||||
/// Description of BaseTextItem.
|
||||
/// </summary>
|
||||
[Designer(typeof(TextItemDesigner))] |
||||
public class BaseTextItem:AbstractItem |
||||
{ |
||||
|
||||
string formatString; |
||||
StringFormat stringFormat; |
||||
StringTrimming stringTrimming; |
||||
ContentAlignment contentAlignment; |
||||
|
||||
|
||||
public BaseTextItem():base() |
||||
{ |
||||
DefaultSize = GlobalValues.PreferedSize; |
||||
Size = GlobalValues.PreferedSize; |
||||
BackColor = Color.White; |
||||
contentAlignment = ContentAlignment.TopLeft; |
||||
TypeDescriptor.AddProvider(new TextItemTypeProvider(), typeof(BaseTextItem)); |
||||
} |
||||
|
||||
|
||||
[EditorBrowsableAttribute()] |
||||
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) |
||||
{ |
||||
base.OnPaint(e); |
||||
this.Draw(e.Graphics); |
||||
} |
||||
|
||||
|
||||
public override void Draw(Graphics graphics) |
||||
{ |
||||
if (graphics == null) { |
||||
throw new ArgumentNullException("graphics"); |
||||
} |
||||
using (var backgroundBrush = new SolidBrush(this.BackColor)){ |
||||
graphics.FillRectangle(backgroundBrush, base.DrawingRectangle); |
||||
} |
||||
|
||||
var designTrimmimg = StringTrimming.EllipsisCharacter; |
||||
|
||||
if (stringTrimming != StringTrimming.None) { |
||||
designTrimmimg = stringTrimming; |
||||
} |
||||
|
||||
stringFormat = TextDrawer.BuildStringFormat(designTrimmimg, contentAlignment); |
||||
using (var textBrush = new SolidBrush(ForeColor)) { |
||||
TextDrawer.DrawString(graphics, Text, Font, textBrush, ClientRectangle, stringFormat); |
||||
} |
||||
DrawControl(graphics, base.DrawingRectangle); |
||||
} |
||||
|
||||
|
||||
|
||||
// [EditorAttribute(typeof(DefaultTextEditor),
|
||||
// typeof(System.Drawing.Design.UITypeEditor) )]
|
||||
public override string Text { |
||||
get { return base.Text; } |
||||
set { base.Text = value; |
||||
this.Invalidate(); |
||||
} |
||||
} |
||||
|
||||
|
||||
#region Format and alignment
|
||||
|
||||
// [Browsable(true),
|
||||
// Category("Appearance"),
|
||||
// Description("String to format Number's Date's etc")]
|
||||
// [DefaultValue("entry1")]
|
||||
// [TypeConverter(typeof(FormatStringConverter))]
|
||||
|
||||
public string FormatString { |
||||
get { return formatString; } |
||||
set { |
||||
formatString = value; |
||||
Invalidate(); |
||||
} |
||||
} |
||||
|
||||
|
||||
[Browsable(false)] |
||||
public StringFormat StringFormat { |
||||
get { return stringFormat; } |
||||
set { |
||||
stringFormat = value; |
||||
Invalidate(); |
||||
} |
||||
} |
||||
|
||||
|
||||
[Category("Appearance")] |
||||
public StringTrimming StringTrimming { |
||||
get { return stringTrimming; } |
||||
set { |
||||
stringTrimming = value; |
||||
Invalidate(); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
// [Category("Appearance")]
|
||||
// [EditorAttribute(typeof(ContentAlignmentEditor),
|
||||
// typeof(UITypeEditor) )]
|
||||
public ContentAlignment ContentAlignment { |
||||
get { return contentAlignment; } |
||||
set { |
||||
contentAlignment = value; |
||||
Invalidate(); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region RighToLeft
|
||||
|
||||
[Category("Appearance")] |
||||
public System.Windows.Forms.RightToLeft RTL |
||||
{ |
||||
get { return base.RightToLeft; } |
||||
set { base.RightToLeft = value; } |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region DataType
|
||||
|
||||
// [Browsable(true),
|
||||
// Category("Databinding"),
|
||||
// Description("Datatype of the underlying Column")]
|
||||
// [DefaultValue("System.String")]
|
||||
// [TypeConverter(typeof(DataTypeStringConverter))]
|
||||
|
||||
public string DataType {get;set;} |
||||
|
||||
#endregion
|
||||
|
||||
#region Expression
|
||||
|
||||
// [Browsable(true),
|
||||
// Category("Expression"),
|
||||
// Description("Enter a valid Expression")]
|
||||
// [EditorAttribute(typeof(DefaultTextEditor),
|
||||
// typeof(System.Drawing.Design.UITypeEditor) )]
|
||||
public string Expression {get;set;} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region CanGrow/CanShrink
|
||||
|
||||
public bool CanGrow {get;set;} |
||||
|
||||
public bool CanShrink {get;set;} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,150 @@
@@ -0,0 +1,150 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 15.03.2014 |
||||
* Time: 18:15 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using System.IO; |
||||
using ICSharpCode.Reporting.Globals; |
||||
using ICSharpCode.Reporting.Addin.Designer; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignableItems |
||||
{ |
||||
|
||||
[Designer(typeof(ReportSettingsDesigner))] |
||||
public class ReportSettings:Component |
||||
{ |
||||
|
||||
public ReportSettings() |
||||
{ |
||||
this.pageSize = GlobalValues.DefaultPageSize; |
||||
BaseValues(); |
||||
} |
||||
|
||||
|
||||
void BaseValues() |
||||
{ |
||||
|
||||
// this.UseStandardPrinter = true;
|
||||
// this.GraphicsUnit = GraphicsUnit.Pixel;
|
||||
// this.Padding = new Padding(5);
|
||||
// this.DefaultFont = GlobalValues.DefaultFont;
|
||||
this.ReportType = GlobalEnums.ReportType.FormSheet; |
||||
//
|
||||
this.DataModel = GlobalEnums.PushPullModel.FormSheet; |
||||
//
|
||||
// this.CommandType = System.Data.CommandType.Text;
|
||||
// this.ConnectionString = String.Empty;
|
||||
// this.CommandText = String.Empty;
|
||||
//
|
||||
// this.TopMargin = GlobalValues.DefaultPageMargin.Left;
|
||||
// this.BottomMargin = GlobalValues.DefaultPageMargin.Bottom;
|
||||
// this.LeftMargin = GlobalValues.DefaultPageMargin.Left;
|
||||
// this.RightMargin = GlobalValues.DefaultPageMargin.Right;
|
||||
//
|
||||
// this.availableFields = new AvailableFieldsCollection();
|
||||
// this.groupingsCollection = new GroupColumnCollection();
|
||||
this.SortColumnsCollection = new SortColumnCollection(); |
||||
this.GroupColumnsCollection = new GroupColumnCollection(); |
||||
// this.sqlParameters = new SqlParameterCollection();
|
||||
ParameterCollection = new ParameterCollection(); |
||||
// this.NoDataMessage = "No Data for this Report";
|
||||
} |
||||
|
||||
|
||||
private string reportName; |
||||
|
||||
// [Category("Base Settings")]
|
||||
// [DefaultValueAttribute ("")]
|
||||
public string ReportName |
||||
{ |
||||
get { |
||||
if (string.IsNullOrEmpty(reportName)) { |
||||
reportName = GlobalValues.DefaultReportName; |
||||
} |
||||
return reportName; |
||||
} |
||||
set { |
||||
if (reportName != value) { |
||||
reportName = value; |
||||
} |
||||
} |
||||
} |
||||
|
||||
private string fileName; |
||||
// [Category("Base Settings")]
|
||||
// [XmlIgnoreAttribute]
|
||||
public string FileName |
||||
{ |
||||
get { |
||||
if (String.IsNullOrEmpty(fileName)) { |
||||
fileName = GlobalValues.PlainFileName; |
||||
} |
||||
return Path.GetFullPath(fileName); |
||||
} |
||||
set { |
||||
fileName = value; |
||||
} |
||||
} |
||||
|
||||
|
||||
// [Category("Page Settings")]
|
||||
public int BottomMargin {get;set;} |
||||
|
||||
|
||||
// [Category("Page Settings")]
|
||||
public int TopMargin {get;set;} |
||||
|
||||
|
||||
|
||||
// [Category("Page Settings")]
|
||||
public int LeftMargin {get;set;} |
||||
|
||||
|
||||
|
||||
// [Category("Page Settings")]
|
||||
public int RightMargin {get;set;} |
||||
|
||||
private Size pageSize; |
||||
|
||||
public Size PageSize { |
||||
get { |
||||
if (!Landscape) { |
||||
return pageSize; |
||||
} else { |
||||
return new Size(pageSize.Height,pageSize.Width); |
||||
} |
||||
} |
||||
set { pageSize = value; } |
||||
} |
||||
|
||||
// [Category("Page Settings")]
|
||||
// public Size PageSize {get;set;}
|
||||
|
||||
// [Category("Page Settings")]
|
||||
public bool Landscape {get;set;} |
||||
|
||||
// [Category("Data")]
|
||||
public GlobalEnums.PushPullModel DataModel {get;set;} |
||||
|
||||
|
||||
// [Browsable(true), Category("Base Settings")]
|
||||
public GlobalEnums.ReportType ReportType {get;set;} |
||||
|
||||
|
||||
// [Category("Parameters")]
|
||||
// [EditorAttribute ( typeof(ParameterCollectionEditor),
|
||||
// typeof(System.Drawing.Design.UITypeEditor) )]
|
||||
|
||||
public ParameterCollection ParameterCollection {get; private set;} |
||||
|
||||
public SortColumnCollection SortColumnsCollection {get;private set;} |
||||
|
||||
public GroupColumnCollection GroupColumnsCollection {get;private set;} |
||||
} |
||||
} |
||||
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.03.2014 |
||||
* Time: 18:22 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel.Design; |
||||
using System.Windows.Forms.Design; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of AbstractDesigner.
|
||||
/// </summary>
|
||||
public class AbstractDesigner:ControlDesigner |
||||
{ |
||||
|
||||
public override void Initialize(System.ComponentModel.IComponent component) |
||||
{ |
||||
base.Initialize(component); |
||||
SelectionService = GetService(typeof(ISelectionService)) as ISelectionService; |
||||
SelectionService.SelectionChanged += OnComponentSelected; |
||||
ComponentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); |
||||
ComponentChangeService.ComponentRename += OnComponentRename; |
||||
} |
||||
|
||||
|
||||
void OnComponentSelected(object sender, EventArgs e) |
||||
{ |
||||
Control.Invalidate(); |
||||
} |
||||
|
||||
|
||||
void OnComponentRename(object sender, ComponentRenameEventArgs e) |
||||
{ |
||||
if (e.Component == Component) { |
||||
if ((!String.IsNullOrEmpty(e.NewName)) && (e.NewName != Control.Name)) { |
||||
var c = Component as AbstractItem;; |
||||
c.Name = e.NewName; |
||||
Control.Invalidate(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
protected ISelectionService SelectionService {get; private set;} |
||||
|
||||
protected IComponentChangeService ComponentChangeService {get;private set;} |
||||
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (ComponentChangeService != null) { |
||||
ComponentChangeService.ComponentRename -= OnComponentRename; |
||||
} |
||||
if (SelectionService != null) { |
||||
SelectionService.SelectionChanged -= OnComponentSelected; |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,185 @@
@@ -0,0 +1,185 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.03.2014 |
||||
* Time: 17:56 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
using ICSharpCode.Reporting.Addin.TypeProvider; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of LineDesigner.
|
||||
/// </summary>
|
||||
public class LineDesigner:AbstractDesigner |
||||
{ |
||||
BaseLineItem baseLine; |
||||
bool dragging; |
||||
bool overToPoint; |
||||
bool overFromPoint; |
||||
|
||||
|
||||
public override void Initialize(IComponent component) |
||||
{ |
||||
if (component == null) { |
||||
throw new ArgumentNullException("component"); |
||||
} |
||||
base.Initialize(component); |
||||
baseLine = (BaseLineItem)component; |
||||
} |
||||
|
||||
|
||||
protected override void PostFilterProperties(System.Collections.IDictionary properties) |
||||
{ |
||||
TypeProviderHelper.RemoveProperties(properties); |
||||
base.PostFilterProperties(properties); |
||||
} |
||||
|
||||
|
||||
protected override void OnPaintAdornments(PaintEventArgs pe) |
||||
{ |
||||
var label = Control as BaseLineItem; |
||||
|
||||
if (SelectionService != null) |
||||
{ |
||||
if (SelectionService.GetComponentSelected(label)) |
||||
{ |
||||
// Paint grab handles.
|
||||
var grapRectangle = GetHandle(label.FromPoint); |
||||
ControlPaint.DrawGrabHandle(pe.Graphics, grapRectangle, true, true); |
||||
grapRectangle = GetHandle(label.ToPoint); |
||||
ControlPaint.DrawGrabHandle(pe.Graphics, grapRectangle, true, true); |
||||
|
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
static Rectangle GetHandle(Point pt) |
||||
{ |
||||
var handle = new Rectangle(pt, new Size(7, 7)); |
||||
handle.Offset(-3, -3); |
||||
return handle; |
||||
} |
||||
|
||||
|
||||
protected override void OnSetCursor( ) |
||||
{ |
||||
// Get mouse cursor position relative to
|
||||
// the control's coordinate space.
|
||||
|
||||
var label = (BaseLineItem) Control; |
||||
var p = label.PointToClient(Cursor.Position); |
||||
|
||||
// Display a resize cursor if the mouse is
|
||||
// over a grab handle; otherwise show a
|
||||
// normal arrow.
|
||||
if (GetHandle(label.FromPoint).Contains(p) || |
||||
GetHandle(label.ToPoint).Contains(p)) |
||||
{ |
||||
Cursor.Current = Cursors.SizeAll; |
||||
} |
||||
else |
||||
{ |
||||
Cursor.Current = Cursors.Default; |
||||
} |
||||
} |
||||
|
||||
|
||||
#region Drag handling state and methods
|
||||
|
||||
protected override void OnMouseDragBegin(int x, int y) |
||||
{ |
||||
System.Console.WriteLine("DragBegib"); |
||||
Point p = this.baseLine.PointToClient(new Point(x, y)); |
||||
overFromPoint = GetHandle(baseLine.FromPoint).Contains(p); |
||||
this.overToPoint = GetHandle(baseLine.ToPoint).Contains(p); |
||||
if (overFromPoint || overToPoint ) |
||||
{ |
||||
dragging = true; |
||||
// PropertyDescriptor pd =
|
||||
// TypeDescriptor.GetProperties(this.baseLine)["FromPoint"];
|
||||
// pd.SetValue(this.baseLine, p);
|
||||
// dragDirection = overToPoint;
|
||||
// Point current = dragDirection ?
|
||||
// (label.Origin + label.Direction) :
|
||||
// label.Origin;
|
||||
// dragOffset = current - new Size(p);
|
||||
} |
||||
else |
||||
{ |
||||
dragging = false; |
||||
base.OnMouseDragBegin(x, y); |
||||
} |
||||
} |
||||
|
||||
|
||||
protected override void OnMouseDragMove(int x, int y) |
||||
{ |
||||
if (dragging) |
||||
{ |
||||
Point p = this.baseLine.PointToClient(new Point(x, y)); |
||||
if (overToPoint) { |
||||
baseLine.ToPoint = p; |
||||
} else { |
||||
baseLine.FromPoint = p; |
||||
} |
||||
|
||||
// this.baseLine.Invalidate();
|
||||
// this.dragOffset = p;
|
||||
} |
||||
else |
||||
{ |
||||
base.OnMouseDragMove(x, y); |
||||
} |
||||
} |
||||
|
||||
|
||||
protected override void OnMouseDragEnd(bool cancel) |
||||
{ |
||||
if (dragging) |
||||
{ |
||||
// Update property via PropertyDescriptor to
|
||||
// make sure that VS.NET notices.
|
||||
|
||||
// PropertyDescriptor pd =
|
||||
// TypeDescriptor.GetProperties(this.baseLine)["ToPoint"];
|
||||
// pd.SetValue(this.baseLine, this.dragOffset);
|
||||
/* |
||||
DirectionalLabel label = (DirectionalLabel) Control; |
||||
if (dragDirection) |
||||
{ |
||||
Size d = label.Direction; |
||||
PropertyDescriptor pd = |
||||
TypeDescriptor.GetProperties(label)["Direction"]; |
||||
pd.SetValue(label, d); |
||||
} |
||||
else |
||||
{ |
||||
Point o = label.Origin; |
||||
PropertyDescriptor pd = |
||||
TypeDescriptor.GetProperties(label)["Origin"]; |
||||
pd.SetValue(label, o); |
||||
} |
||||
*/ |
||||
dragging = false; |
||||
baseLine.Invalidate(); |
||||
} |
||||
|
||||
// Always call base class.
|
||||
base.OnMouseDragEnd(cancel); |
||||
|
||||
} |
||||
//
|
||||
|
||||
#endregion
|
||||
|
||||
} |
||||
} |
||||
@ -0,0 +1,363 @@
@@ -0,0 +1,363 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.Drawing; |
||||
using System.Drawing.Design; |
||||
using System.Drawing.Printing; |
||||
using System.Windows.Forms; |
||||
using System.Windows.Forms.Design; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
using ICSharpCode.Reporting.Addin.Globals; |
||||
using ICSharpCode.Reporting.Addin.TypeProvider; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ReportRootDesigner.
|
||||
/// </summary>
|
||||
|
||||
public class ReportRootDesigner: DocumentDesigner |
||||
{ |
||||
ICollection currentSelection; |
||||
IDesignerHost host; |
||||
MenuCommandService menuCommandService; |
||||
IToolboxService toolboxService; |
||||
ISelectionService selectionService; |
||||
IComponentChangeService componentChangeService; |
||||
List<BaseSection> sections; |
||||
ICSharpCode.Reporting.Items.ReportSettings reportSettings; |
||||
RootReportModel rootReportModel; |
||||
|
||||
|
||||
void ShowMessage(Exception e) |
||||
{ |
||||
DisplayError(e); |
||||
var uiService = (IUIService)host.GetService(typeof(IUIService)); |
||||
if (uiService != null) { |
||||
uiService.ShowError(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
void InitializeGUI() |
||||
{ |
||||
reportSettings = host.Container.Components[1] as ICSharpCode.Reporting.Items.ReportSettings; |
||||
InitializeRootReportModel(); |
||||
} |
||||
|
||||
|
||||
void InitializeRootReportModel () |
||||
{ |
||||
rootReportModel = host.Container.Components[0] as RootReportModel; |
||||
rootReportModel.PageMargin = CalculateMargins(); |
||||
rootReportModel.Page = new Rectangle(new Point(0,0), reportSettings.PageSize); |
||||
rootReportModel.Landscape = this.reportSettings.Landscape; |
||||
rootReportModel.Invalidate(); |
||||
} |
||||
|
||||
|
||||
Margins CalculateMargins () |
||||
{ |
||||
return new Margins(reportSettings.LeftMargin,reportSettings.RightMargin, |
||||
reportSettings.TopMargin,reportSettings.BottomMargin); |
||||
} |
||||
|
||||
#region overrides
|
||||
|
||||
public override void Initialize(IComponent component) |
||||
{ |
||||
base.Initialize(component); |
||||
sections = new List<BaseSection>(); |
||||
|
||||
// We need to listen to change events. If a shape changes,
|
||||
// we need to invalidate our view.
|
||||
//
|
||||
|
||||
this.componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); |
||||
if (this.componentChangeService != null) |
||||
{ |
||||
this.componentChangeService.ComponentAdded += new ComponentEventHandler(OnComponentAdded); |
||||
// this.componentChangeService.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
|
||||
// this.componentChangeService.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved);
|
||||
this.componentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); |
||||
this.componentChangeService.ComponentChanging += new ComponentChangingEventHandler(OnComponentChanging); |
||||
} |
||||
|
||||
|
||||
// Add the menu commands we support. We must be a member of the VSIP program to
|
||||
// define new menu items, but we can handle any item located within the StandardCommands
|
||||
// class because Visual Studio already defines them.
|
||||
//
|
||||
|
||||
menuCommandService = (MenuCommandService)GetService(typeof(MenuCommandService)); |
||||
/* |
||||
if (menuCommandService != null) |
||||
{ |
||||
/* |
||||
m_menuCommands = new MenuCommand[] |
||||
{ |
||||
new MenuCommand(new EventHandler(OnMenuCut), StandardCommands.Cut), |
||||
new MenuCommand(new EventHandler(OnMenuCopy), StandardCommands.Copy), |
||||
// new ImmediateMenuCommand(new EventHandler(OnMenuPasteStatus), new EventHandler(OnMenuPaste), StandardCommands.Paste),
|
||||
new MenuCommand(new EventHandler(OnMenuDelete), StandardCommands.Delete) |
||||
}; |
||||
|
||||
foreach(MenuCommand mc in m_menuCommands) |
||||
{ |
||||
m_menuCommandService.AddCommand(mc); |
||||
} |
||||
|
||||
System.Console.WriteLine("RootDesigner menuService set"); |
||||
} |
||||
*/ |
||||
// Select our base shape. By default there is nothing selected but that looks
|
||||
// strange (the property grid is empty).
|
||||
//
|
||||
|
||||
selectionService = (ISelectionService)GetService(typeof(ISelectionService)); |
||||
if (this.selectionService != null) |
||||
{ |
||||
this.selectionService.SetSelectedComponents(new object[] {component}, SelectionTypes.Replace); |
||||
this.selectionService.SelectionChanged += new EventHandler(OnSelectionChanged); |
||||
} |
||||
|
||||
this.host = (IDesignerHost)GetService(typeof(IDesignerHost)); |
||||
|
||||
this.menuCommandService = (MenuCommandService)host.GetService(typeof(MenuCommandService)); |
||||
if (host != null) |
||||
{ |
||||
host.LoadComplete += new EventHandler(OnLoadComplete); |
||||
} |
||||
//Dragdropp only allowed in Section
|
||||
this.Control.AllowDrop = false; |
||||
} |
||||
|
||||
|
||||
public override SelectionRules SelectionRules { |
||||
get { |
||||
return SelectionRules.BottomSizeable; |
||||
} |
||||
} |
||||
|
||||
|
||||
protected override void PostFilterProperties(IDictionary properties) |
||||
{ |
||||
|
||||
TypeProviderHelper.RemoveProperties(properties); |
||||
var s = new string[]{"Visible","BackColor", |
||||
"Text","MaximumSize","MinimumSize", |
||||
"Size","AutoScaleDimensions", |
||||
"DataBindings"}; |
||||
TypeProviderHelper.Remove(properties,s); |
||||
base.PostFilterProperties(properties); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Events
|
||||
|
||||
void OnSectionSizeChanged (object sender, EventArgs e) |
||||
{ |
||||
RecalculateSections(); |
||||
} |
||||
|
||||
|
||||
void RecalculateSections() |
||||
{ |
||||
int locY = 50; |
||||
if (reportSettings == null) { |
||||
reportSettings = host.Container.Components[1] as ICSharpCode.Reporting.Items.ReportSettings; |
||||
} |
||||
|
||||
foreach (BaseSection section in sections) |
||||
{ |
||||
section.Location = new Point(reportSettings.LeftMargin,locY); |
||||
locY = locY + section.Size.Height + DesignerGlobals.GabBetweenSection; |
||||
} |
||||
Control.Invalidate(); |
||||
} |
||||
|
||||
|
||||
|
||||
void OnLoadComplete(object sender, EventArgs e) |
||||
{ |
||||
var host = (IDesignerHost)sender; |
||||
host.LoadComplete -= OnLoadComplete; |
||||
InitializeGUI(); |
||||
} |
||||
|
||||
|
||||
void OnComponentAdded(object sender, ComponentEventArgs ce) |
||||
{ |
||||
var section = ce.Component as BaseSection; |
||||
|
||||
if (section != null) { |
||||
sections.Add(section); |
||||
section.SizeChanged += new EventHandler( OnSectionSizeChanged); |
||||
Console.Write("reportRootDesigner:OnComponentAdded"); |
||||
foreach (Control ctrl in section.Controls) { |
||||
AddToHost(ctrl); |
||||
host.Container.Add(ctrl); |
||||
} |
||||
Control.Controls.Add(section); |
||||
RecalculateSections(); |
||||
} |
||||
} |
||||
|
||||
|
||||
void AddToHost (Control ctrl) |
||||
{ |
||||
foreach (Control c1 in ctrl.Controls) { |
||||
AddToHost (c1); |
||||
} |
||||
host.Container.Add(ctrl as IComponent); |
||||
} |
||||
|
||||
|
||||
private void OnComponentChanged(object sender, ComponentChangedEventArgs ce) |
||||
{ |
||||
LoggingService.InfoFormatted("RootDesigner:OnComponentChanged"); |
||||
String str = String.Format("RootDesigner:OnComponentChanged <{0}> from <{1}> to <{2}>",ce.Component.ToString(),ce.OldValue,ce.NewValue); |
||||
LoggingService.InfoFormatted(str); |
||||
|
||||
var section = ce.Component as BaseSection; |
||||
if (section != null) { |
||||
foreach (BaseSection s in sections) |
||||
{ |
||||
if (s.Name == section.Name) { |
||||
s.Size = section.Size; |
||||
} |
||||
} |
||||
RecalculateSections(); |
||||
} |
||||
} |
||||
|
||||
|
||||
void OnComponentChanging(object sender, ComponentChangingEventArgs ce) |
||||
{ |
||||
System.Console.WriteLine("RootDesigner:OnComponentChanging"); |
||||
// Host.CreateTransaction();
|
||||
} |
||||
|
||||
|
||||
void OnSelectionChanged(object sender, EventArgs e) |
||||
{ |
||||
currentSelection = ((ISelectionService)sender).GetSelectedComponents(); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
public IDesignerHost Host { |
||||
get { |
||||
if (this.host == null) { |
||||
this.host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); |
||||
} |
||||
return host; } |
||||
} |
||||
|
||||
|
||||
public IToolboxService ToolboxService |
||||
{ |
||||
get |
||||
{ |
||||
if (toolboxService == null) |
||||
{ |
||||
toolboxService = (IToolboxService)this.GetService(typeof(IToolboxService)); |
||||
} |
||||
return toolboxService; |
||||
} |
||||
} |
||||
|
||||
|
||||
public ISelectionService SelectionService { |
||||
get { |
||||
if (this.selectionService == null) { |
||||
this.selectionService = (ISelectionService)this.GetService(typeof(ISelectionService)); |
||||
} |
||||
return selectionService; } |
||||
} |
||||
|
||||
|
||||
public IComponentChangeService ComponentChangeService { |
||||
get { |
||||
if (this.componentChangeService == null) { |
||||
this.componentChangeService = (IComponentChangeService)this.GetService(typeof(IComponentChangeService)); |
||||
} |
||||
return componentChangeService; } |
||||
} |
||||
|
||||
public MenuCommandService MenuCommandService { |
||||
get { |
||||
if (this.menuCommandService == null) { |
||||
this.menuCommandService = (MenuCommandService)Host.GetService(typeof(IMenuCommandService)); |
||||
} |
||||
return (MenuCommandService)host.GetService(typeof(IMenuCommandService)); |
||||
} |
||||
} |
||||
|
||||
|
||||
public ICollection CurrentSelection { |
||||
get { return currentSelection; } |
||||
} |
||||
|
||||
|
||||
#region Dispose
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) |
||||
{ |
||||
var componentService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); |
||||
if (componentService != null) |
||||
{ |
||||
componentService.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged); |
||||
componentService.ComponentChanging -= new ComponentChangingEventHandler(OnComponentChanging); |
||||
} |
||||
|
||||
ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService)); |
||||
if (ss != null) |
||||
{ |
||||
ss.SelectionChanged -= new EventHandler(OnSelectionChanged); |
||||
} |
||||
/* |
||||
if (m_menuCommands != null && m_menuCommandService != null) |
||||
{ |
||||
foreach(MenuCommand mc in m_menuCommands) |
||||
{ |
||||
m_menuCommandService.RemoveCommand(mc); |
||||
} |
||||
m_menuCommands = null; |
||||
} |
||||
*/ |
||||
} |
||||
|
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 15.03.2014 |
||||
* Time: 18:16 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ReportSettingsDesigner.
|
||||
/// </summary>
|
||||
public class ReportSettingsDesigner:ComponentDesigner |
||||
{ |
||||
static string settingsName = "ReportSettings"; |
||||
public ReportSettingsDesigner() |
||||
{ |
||||
} |
||||
|
||||
public override void Initialize(IComponent component) |
||||
{ |
||||
base.Initialize(component); |
||||
component.Site.Name = ReportSettingsDesigner.settingsName; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,122 @@
@@ -0,0 +1,122 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 24.02.2014 |
||||
* Time: 19:51 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.Drawing; |
||||
using System.Drawing.Printing; |
||||
using ICSharpCode.Reporting.Addin.Globals; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of RootReportModel.
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
|
||||
public class RootReportModel:RootDesignedComponent |
||||
{ |
||||
|
||||
|
||||
[EditorBrowsableAttribute()] |
||||
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) |
||||
{ |
||||
base.OnPaint(pea); |
||||
PrintMargin(pea.Graphics); |
||||
using (Font font = DesignerGlobals.DesignerFont) { |
||||
foreach(System.Windows.Forms.Control ctrl in this.Controls) |
||||
{ |
||||
pea.Graphics.DrawString(ctrl.Name, |
||||
font, |
||||
Brushes.LightGray, |
||||
ctrl.Location.X,ctrl.Location.Y - (int)font.GetHeight() - 3); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
void PrintMargin( Graphics graphics) |
||||
{ |
||||
string header = String.Format(System.Globalization.CultureInfo.CurrentCulture, |
||||
"[Size : {0}] [Landscape : {1}] [Bounds : {2}]", |
||||
Page.Size, Landscape, PageMargin); |
||||
using (var font = DesignerGlobals.DesignerFont){ |
||||
SizeF size = graphics.MeasureString(header,font); |
||||
graphics.DrawString(header,font, |
||||
new SolidBrush(Color.LightGray), |
||||
new Rectangle( |
||||
3, |
||||
3 + (int)font.GetHeight(), |
||||
(int)size.Width, |
||||
(int)size.Height)); |
||||
|
||||
var rect = new Rectangle(PageMargin.Left - 2,PageMargin.Top - 2, |
||||
Page.Width - PageMargin.Left - PageMargin.Right + 2, |
||||
Size.Height - PageMargin.Top - PageMargin.Bottom + 2); |
||||
graphics.DrawRectangle(new Pen(Color.LightGray,1),rect); |
||||
// e.FillRectangle(new SolidBrush(SystemColors.Window),rect);
|
||||
} |
||||
} |
||||
|
||||
|
||||
void old_PrintMargin( Graphics graphics) |
||||
{ |
||||
string header = String.Format(System.Globalization.CultureInfo.CurrentCulture, |
||||
"[Size : {0}] [Landscape : {1}] [Bounds : {2}]", |
||||
this.Page,this.Landscape,this.PageMargin); |
||||
using (var font = DesignerGlobals.DesignerFont){ |
||||
SizeF size = graphics.MeasureString(header,font); |
||||
graphics.DrawString(header,font, |
||||
new SolidBrush(Color.LightGray), |
||||
new Rectangle(PageMargin.Left + 100, |
||||
this.PageMargin.Top - (int)font.GetHeight() - 3, |
||||
(int)size.Width, |
||||
(int)size.Height)); |
||||
|
||||
var rect = new Rectangle(PageMargin.Left - 2,PageMargin.Top - 2, |
||||
Page.Width - PageMargin.Left - PageMargin.Right + 2, |
||||
Size.Height - PageMargin.Top - PageMargin.Bottom + 2); |
||||
graphics.DrawRectangle(new Pen(Color.LightGray,1),rect); |
||||
} |
||||
} |
||||
|
||||
|
||||
public Margins PageMargin {get;set;} |
||||
|
||||
public Rectangle Page {get;set;} |
||||
|
||||
public bool Landscape {get;set;} |
||||
} |
||||
|
||||
|
||||
[Designer(typeof(ReportRootDesigner), typeof(IRootDesigner))] |
||||
public class RootDesignedComponent : System.Windows.Forms.UserControl |
||||
{ |
||||
public RootDesignedComponent() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
|
||||
private void InitializeComponent() |
||||
{ |
||||
this.SuspendLayout(); |
||||
//
|
||||
// UserControl1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||
this.BackColor = System.Drawing.SystemColors.Window; |
||||
this.Name = "UserControl1"; |
||||
this.Size = new System.Drawing.Size(800, 800); |
||||
this.ResumeLayout(false); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,88 @@
@@ -0,0 +1,88 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 15.03.2014 |
||||
* Time: 19:26 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design; |
||||
using System.Drawing.Design; |
||||
using System.Windows.Forms; |
||||
using System.Windows.Forms.Design; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SectionDesigner.
|
||||
/// </summary>
|
||||
public class SectionDesigner:ParentControlDesigner |
||||
{ |
||||
BaseSection section; |
||||
ISelectionService selectionService; |
||||
|
||||
public override void Initialize(IComponent component) |
||||
{ |
||||
if (component == null) { |
||||
throw new ArgumentNullException("component"); |
||||
} |
||||
base.Initialize(component); |
||||
this.section = (BaseSection)component; |
||||
if (String.IsNullOrEmpty(component.Site.Name)) { |
||||
component.Site.Name = section.Name; |
||||
} else { |
||||
section.Name = component.Site.Name; |
||||
} |
||||
GetService (); |
||||
} |
||||
|
||||
|
||||
public override SelectionRules SelectionRules { |
||||
get { |
||||
return SelectionRules.BottomSizeable|SelectionRules.TopSizeable; |
||||
} |
||||
} |
||||
|
||||
|
||||
protected override void OnDragDrop(DragEventArgs de) |
||||
{ |
||||
base.OnDragDrop(de); |
||||
var it = (IToolboxService)this.GetService(typeof(IToolboxService)); |
||||
it.SetSelectedToolboxItem(null); |
||||
} |
||||
|
||||
|
||||
public override bool CanBeParentedTo(System.ComponentModel.Design.IDesigner parentDesigner) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
|
||||
void OnSelectionChanged(object sender, EventArgs e) |
||||
{ |
||||
Control.Invalidate( ); |
||||
} |
||||
|
||||
|
||||
void GetService () |
||||
{ |
||||
selectionService = GetService(typeof(ISelectionService)) as ISelectionService; |
||||
if (selectionService != null) |
||||
{ |
||||
selectionService.SelectionChanged += OnSelectionChanged; |
||||
} |
||||
} |
||||
|
||||
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (this.selectionService != null) { |
||||
selectionService.SelectionChanged -= OnSelectionChanged; |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.03.2014 |
||||
* Time: 20:24 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using ICSharpCode.Reporting.Addin.TypeProvider; |
||||
|
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of TextItemDesigner.
|
||||
/// </summary>
|
||||
public class TextItemDesigner:AbstractDesigner |
||||
{ |
||||
|
||||
|
||||
protected override void PostFilterProperties(System.Collections.IDictionary properties) |
||||
{ |
||||
TypeProviderHelper.RemoveProperties(properties); |
||||
base.PostFilterProperties(properties); |
||||
} |
||||
|
||||
|
||||
#region SmartTag
|
||||
|
||||
// public override DesignerActionListCollection ActionLists {
|
||||
// get {
|
||||
// var actions = new DesignerActionListCollection ();
|
||||
// actions.Add (new TextBasedDesignerActionList(this.Component));
|
||||
// return actions;
|
||||
// }
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ContextMenu
|
||||
/* |
||||
public override DesignerVerbCollection Verbs { |
||||
get { |
||||
var verbs = new DesignerVerbCollection(); |
||||
var v1 = new DesignerVerb ("TextEditor",OnRunTextEditor); |
||||
verbs.Add (v1); |
||||
return verbs; |
||||
} |
||||
} |
||||
|
||||
|
||||
private void OnRunTextEditor (object sender,EventArgs e) |
||||
{ |
||||
IStringBasedEditorDialog ed = new TextEditorDialog (ctrl.Text,ctrl.Name); |
||||
if (ed.ShowDialog() == DialogResult.OK) { |
||||
ctrl.Text = ed.TextValue; |
||||
this.SetProperty ("Name",ed.TextValue); |
||||
} |
||||
} |
||||
|
||||
|
||||
private void SetProperty (string prop, object value) |
||||
{ |
||||
PropertyDescriptor p = TypeDescriptor.GetProperties(Control)[prop]; |
||||
if (p == null) { |
||||
throw new ArgumentException (this.ctrl.Text); |
||||
} else { |
||||
p.SetValue (Control,value); |
||||
} |
||||
} |
||||
|
||||
*/ |
||||
#endregion
|
||||
|
||||
} |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 11.02.2014 |
||||
* Time: 20:19 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
using System.IO; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.Reporting.Addin.Commands; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignerBinding { |
||||
|
||||
|
||||
public class ReportDesignerBinding:IDisplayBinding { |
||||
|
||||
|
||||
public bool IsPreferredBindingForFile(FileName fileName) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
|
||||
public bool CanCreateContentForFile(FileName fileName) |
||||
{ |
||||
return Path.GetExtension(fileName).Equals(".srd", StringComparison.OrdinalIgnoreCase); |
||||
} |
||||
|
||||
|
||||
public double AutoDetectFileContent(FileName fileName, System.IO.Stream fileContent, string detectedMimeType) |
||||
{ |
||||
throw new System.NotImplementedException(); |
||||
} |
||||
|
||||
|
||||
public IViewContent CreateContentForFile(OpenedFile file) |
||||
{ |
||||
if (file.IsDirty) { |
||||
MessageService.ShowMessage("ReportWizard not available at the Moment","New ReportDesigner"); |
||||
return null; |
||||
// var cmd = new ReportWizardCommand(file);
|
||||
// cmd.Run();
|
||||
// if (cmd.Canceled) {
|
||||
// return null;
|
||||
// }
|
||||
// file.SetData(cmd.GeneratedReport.ToArray());
|
||||
} |
||||
|
||||
var viewCmd = new CreateDesignerCommand(file); |
||||
viewCmd.Run(); |
||||
LoggingService.Info("return DesignerView"); |
||||
return viewCmd.DesignerView; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,114 @@
@@ -0,0 +1,114 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 22.02.2014 |
||||
* Time: 19:36 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
using ICSharpCode.Reporting.Addin.Globals; |
||||
using ICSharpCode.Reporting.Addin.Views; |
||||
using ICSharpCode.Reporting.Addin.XML; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignerBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Description of DesignerGenerator.
|
||||
/// </summary>
|
||||
class DesignerGenerator:IDesignerGenerator |
||||
{ |
||||
DesignerView viewContent; |
||||
|
||||
public DesignerGenerator() |
||||
{ |
||||
LoggingService.Info("Create DesignerGenerator"); |
||||
} |
||||
|
||||
#region IDesignerGenerator implementation
|
||||
|
||||
public void Attach(DesignerView viewContent) |
||||
{ |
||||
if (viewContent == null) |
||||
throw new ArgumentNullException("viewContent"); |
||||
LoggingService.Info("DesignerGenerator:Attach"); |
||||
this.viewContent = viewContent; |
||||
} |
||||
|
||||
|
||||
public void Detach() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public System.Collections.Generic.IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void MergeFormChanges(System.CodeDom.CodeCompileUnit unit) |
||||
{ |
||||
var writer = InternalMergeFormChanges(); |
||||
viewContent.ReportFileContent = writer.ToString(); |
||||
} |
||||
|
||||
|
||||
StringWriter InternalMergeFormChanges() |
||||
{ |
||||
var writer = new StringWriterWithEncoding(System.Text.Encoding.UTF8); |
||||
var xml = XmlHelper.CreatePropperWriter(writer); |
||||
|
||||
var reportDesignerWriter = new ReportDesignerWriter(); |
||||
XmlHelper.CreatePropperDocument(xml); |
||||
|
||||
foreach (IComponent component in viewContent.Host.Container.Components) { |
||||
if (!(component is Control)) { |
||||
reportDesignerWriter.Save(component,xml); |
||||
} |
||||
} |
||||
xml.WriteEndElement(); |
||||
xml.WriteStartElement("SectionCollection"); |
||||
|
||||
// we look only for Sections
|
||||
foreach (var component in viewContent.Host.Container.Components) { |
||||
var b = component as BaseSection; |
||||
if (b != null) { |
||||
reportDesignerWriter.Save(component,xml); |
||||
} |
||||
} |
||||
//SectionCollection
|
||||
xml.WriteEndElement(); |
||||
//Reportmodel
|
||||
xml.WriteEndElement(); |
||||
xml.WriteEndDocument(); |
||||
xml.Close(); |
||||
return writer; |
||||
} |
||||
|
||||
|
||||
public DesignerView ViewContent { |
||||
get {return viewContent;} |
||||
|
||||
} |
||||
|
||||
public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public System.CodeDom.Compiler.CodeDomProvider CodeDomProvider { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 22.02.2014 |
||||
* Time: 19:51 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.CodeDom; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.Reporting.Addin.Views; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignerBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Description of IDesignerGenerator.
|
||||
/// </summary>
|
||||
public interface IDesignerGenerator |
||||
{ |
||||
System.CodeDom.Compiler.CodeDomProvider CodeDomProvider { |
||||
get; |
||||
} |
||||
void Attach(DesignerView viewContent); |
||||
void Detach(); |
||||
DesignerView ViewContent { get; } |
||||
/// <summary>
|
||||
/// Gets the collection of OpenedFiles that contain code which belongs
|
||||
/// to the designed form, not including resource files.
|
||||
/// </summary>
|
||||
/// <param name="designerCodeFile">Receives the file which contains the code to be modified by the forms designer.</param>
|
||||
/// <returns>A collection of OpenedFiles that contain code which belongs to the designed form.</returns>
|
||||
/// <remarks>The returned collection must include the <paramref name="designerCodeFile"/>.</remarks>
|
||||
IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile); |
||||
void MergeFormChanges(CodeCompileUnit unit); |
||||
bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position); |
||||
} |
||||
} |
||||
@ -0,0 +1,91 @@
@@ -0,0 +1,91 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Reporting.Items; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.Reporting.Addin.Designer; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignerBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ReportLoader.
|
||||
/// </summary>
|
||||
class InternalReportLoader |
||||
{ |
||||
readonly IDesignerLoaderHost host; |
||||
readonly Stream stream; |
||||
readonly IDesignerGenerator generator; |
||||
|
||||
public InternalReportLoader(IDesignerLoaderHost host,IDesignerGenerator generator, Stream stream) |
||||
{ |
||||
if (host == null) { |
||||
throw new ArgumentNullException("host"); |
||||
} |
||||
|
||||
if (generator == null) { |
||||
throw new ArgumentNullException("generator"); |
||||
} |
||||
if (stream == null) { |
||||
throw new ArgumentNullException("stream"); |
||||
} |
||||
this.host = host; |
||||
this.generator = generator; |
||||
this.stream = stream; |
||||
} |
||||
|
||||
public ReportModel LoadOrCreateReport() |
||||
{ |
||||
Application.UseWaitCursor = true; |
||||
var rootComponent = host.CreateComponent(typeof(RootReportModel),"RootReportModel"); |
||||
var rootControl = rootComponent as RootReportModel; |
||||
UpdateStatusbar(); |
||||
var reportModel = CreateNamedSurface(); |
||||
rootControl.Size = reportModel.ReportSettings.PageSize; |
||||
Application.UseWaitCursor = false; |
||||
return reportModel; |
||||
} |
||||
|
||||
|
||||
void UpdateStatusbar () |
||||
{ |
||||
string message; |
||||
if (generator.ViewContent.PrimaryFile.IsDirty) { |
||||
message = String.Format("Create Report <{0}> ...",Path.GetFileName(this.generator.ViewContent.PrimaryFile.FileName)); |
||||
} else { |
||||
message = String.Format("Load Report <{0}> ...",Path.GetFileName(this.generator.ViewContent.PrimaryFile.FileName)); |
||||
} |
||||
SD.StatusBar.SetMessage(message); |
||||
} |
||||
|
||||
|
||||
ReportModel CreateNamedSurface () |
||||
{ |
||||
var deserializer = new ReportDefinitionDeserializer(); |
||||
var document = ReportDefinitionDeserializer.LoadXmlFromStream(stream); |
||||
var reportModel = deserializer.CreateModelFromXml(document.DocumentElement,host); |
||||
return reportModel; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.ComponentModel.Design; |
||||
using System.IO; |
||||
using System.Reflection; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Reporting.Factories; |
||||
using ICSharpCode.Reporting.Items; |
||||
using ICSharpCode.Reporting.Xml; |
||||
using ICSharpCode.Reporting.Addin.XML; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignerBinding |
||||
{ |
||||
class ReportDefinitionDeserializer : ReportDefinitionParser |
||||
{ |
||||
|
||||
public static XmlDocument LoadXmlFromStream(Stream stream) |
||||
{ |
||||
Console.Write("LoadXml"); |
||||
if (stream == null) |
||||
throw new ArgumentNullException("stream"); |
||||
var xmlDocument = new XmlDocument(); |
||||
xmlDocument.Load(stream); |
||||
if (xmlDocument.FirstChild.NodeType == XmlNodeType.XmlDeclaration) { |
||||
var xmlDeclaration = (XmlDeclaration)xmlDocument.FirstChild; |
||||
xmlDeclaration.Encoding = "utf-8"; |
||||
} |
||||
return xmlDocument; |
||||
} |
||||
|
||||
|
||||
public ReportModel CreateModelFromXml(XmlElement elem,IDesignerHost host) |
||||
{ |
||||
var reportSettings = CreateReportSettings(elem); |
||||
var reportModel = ReportModelFactory.Create(); |
||||
reportModel.ReportSettings = reportSettings; |
||||
|
||||
host.Container.Add(reportSettings); |
||||
|
||||
//Move to SectionCollection
|
||||
XmlNodeList sectionList = elem.LastChild.ChildNodes; |
||||
|
||||
foreach (XmlNode sectionNode in sectionList) { |
||||
try { |
||||
object o = this.Load(sectionNode as XmlElement,null); |
||||
var section = o as ICSharpCode.Reporting.Addin.DesignableItems.BaseSection; |
||||
host.Container.Add(section); |
||||
} catch (Exception e) { |
||||
MessageService.ShowException(e); |
||||
} |
||||
} |
||||
return reportModel; |
||||
} |
||||
|
||||
|
||||
static ReportSettings CreateReportSettings(XmlElement elem) |
||||
{ |
||||
XmlNodeList nodes = elem.FirstChild.ChildNodes; |
||||
var reportSettingsNode = (XmlElement)nodes[0]; |
||||
var modelLoader = new ModelLoader(); |
||||
return modelLoader.Load(reportSettingsNode) as ReportSettings; |
||||
} |
||||
|
||||
|
||||
protected override Type GetTypeByName(string ns, string name) |
||||
{ |
||||
var a = Assembly.GetExecutingAssembly(); |
||||
Type t = a.GetType("ICSharpCode.Reporting.Addin.DesignableItems" + "." + name); |
||||
// Type t = typeof(BaseSection).Assembly.GetType(typeof(BaseSection).Namespace + "." + name);
|
||||
|
||||
return t; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,85 @@
@@ -0,0 +1,85 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 24.02.2014 |
||||
* Time: 20:02 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.IO; |
||||
using System.Xml; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Reporting.Factories; |
||||
using ICSharpCode.Reporting.Items; |
||||
using ICSharpCode.Reporting.Addin.Services; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignerBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ReportDesignerLoader.
|
||||
/// </summary>
|
||||
public class ReportDesignerLoader: BasicDesignerLoader |
||||
{ |
||||
IDesignerLoaderHost host; |
||||
readonly IDesignerGenerator generator; |
||||
Stream stream; |
||||
|
||||
#region Constructors
|
||||
|
||||
public ReportDesignerLoader(IDesignerGenerator generator, Stream stream){ |
||||
if (stream == null) |
||||
throw new ArgumentNullException("stream"); |
||||
if (generator == null) { |
||||
throw new ArgumentNullException("generator"); |
||||
} |
||||
this.generator = generator; |
||||
this.stream = stream; |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Overriden methods of BasicDesignerLoader
|
||||
|
||||
public override void BeginLoad(IDesignerLoaderHost host){ |
||||
LoggingService.Info("ReportDesignerLoader:BeginLoad"); |
||||
if (host == null) { |
||||
throw new ArgumentNullException("host"); |
||||
} |
||||
this.host = host; |
||||
host.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService((IServiceProvider)host)); |
||||
host.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService((IServiceProvider)host)); |
||||
base.BeginLoad(host); |
||||
} |
||||
|
||||
|
||||
protected override void PerformLoad(IDesignerSerializationManager serializationManager){ |
||||
LoggingService.Info("ReportDesignerLoader:PerformLoad"); |
||||
var internalLoader = new InternalReportLoader(host,generator, stream); |
||||
internalLoader.LoadOrCreateReport(); |
||||
} |
||||
|
||||
|
||||
protected override void PerformFlush(IDesignerSerializationManager designerSerializationManager){ |
||||
LoggingService.Info("ReportDesignerLoader:PerformFlush"); |
||||
generator.MergeFormChanges((System.CodeDom.CodeCompileUnit)null); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Serialize to Xml
|
||||
|
||||
public XmlDocument SerializeModel() |
||||
{ |
||||
generator.MergeFormChanges((System.CodeDom.CodeCompileUnit)null); |
||||
var doc = new XmlDocument(); |
||||
doc.LoadXml(generator.ViewContent.ReportFileContent); |
||||
return doc; |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 24.02.2014 |
||||
* Time: 19:55 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Drawing; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Globals |
||||
{ |
||||
/// <summary>
|
||||
/// Description of DesignerGlobals.
|
||||
/// </summary>
|
||||
static class DesignerGlobals{ |
||||
|
||||
public static Font DesignerFont |
||||
{ |
||||
get { |
||||
return new Font("Microsoft Sans Serif", |
||||
8, |
||||
FontStyle.Regular, |
||||
GraphicsUnit.Point); |
||||
} |
||||
} |
||||
|
||||
public static int GabBetweenSection{ |
||||
get {return 15;} |
||||
} |
||||
|
||||
/* |
||||
public static void DrawString(Graphics graphics,string text, |
||||
Font font,Brush brush, |
||||
RectangleF rectangle, |
||||
StringFormat format) |
||||
{ |
||||
if (graphics == null) { |
||||
throw new ArgumentNullException("graphics"); |
||||
} |
||||
|
||||
graphics.DrawString(text, |
||||
font, |
||||
brush, |
||||
rectangle, |
||||
format); |
||||
} |
||||
*/ |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 16.03.2014 |
||||
* Time: 18:24 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Globals |
||||
{ |
||||
/// <summary>
|
||||
/// Description of StringWriterWithEncoding.
|
||||
/// </summary>
|
||||
class StringWriterWithEncoding:System.IO.StringWriter |
||||
{ |
||||
private readonly Encoding encoding; |
||||
|
||||
public StringWriterWithEncoding(Encoding encoding) |
||||
{ |
||||
if (encoding == null) { |
||||
throw new ArgumentNullException("encoding"); |
||||
} |
||||
this.encoding = encoding; |
||||
} |
||||
|
||||
public override Encoding Encoding { |
||||
get { return encoding; } |
||||
} |
||||
|
||||
} |
||||
} |
||||
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.ComponentModel.Design.Serialization; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Services |
||||
{ |
||||
/// <summary>
|
||||
/// Description of DefaultMemberRelationshipService.
|
||||
/// </summary>
|
||||
class DefaultMemberRelationshipService:MemberRelationshipService |
||||
{ |
||||
|
||||
public override bool SupportsRelationship(MemberRelationship source, MemberRelationship relationship) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,112 @@
@@ -0,0 +1,112 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.02.2014 |
||||
* Time: 17:54 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.ComponentModel.Design; |
||||
using ICSharpCode.Core; |
||||
|
||||
internal class DefaultServiceContainer : IServiceContainer, IDisposable |
||||
{ |
||||
IServiceContainer serviceContainer; |
||||
Hashtable services = new Hashtable(); |
||||
bool inDispose; |
||||
|
||||
public DefaultServiceContainer () { |
||||
serviceContainer = new ServiceContainer(); |
||||
LoggingService.Info("Init ServiceContaier"); |
||||
} |
||||
|
||||
#region IServiceContainer implementation
|
||||
public void AddService(Type serviceType, object serviceInstance) |
||||
{ |
||||
if (IsServiceMissing(serviceType)) { |
||||
serviceContainer.AddService(serviceType, serviceInstance); |
||||
services.Add(serviceType, serviceInstance); |
||||
} |
||||
} |
||||
public void AddService(Type serviceType, object serviceInstance, bool promote) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
public void AddService(Type serviceType, ServiceCreatorCallback callback) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void AddService(Type serviceType, ServiceCreatorCallback callback, bool promote) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
|
||||
public void RemoveService(System.Type serviceType, bool promote) |
||||
{ |
||||
if (inDispose) |
||||
return; |
||||
serviceContainer.RemoveService(serviceType, promote); |
||||
if (services.Contains(serviceType)) |
||||
services.Remove(serviceType); |
||||
} |
||||
|
||||
public void RemoveService(System.Type serviceType) |
||||
{ |
||||
if (inDispose == true) |
||||
return; |
||||
serviceContainer.RemoveService(serviceType); |
||||
if (services.Contains(serviceType)) |
||||
services.Remove(serviceType); |
||||
} |
||||
#endregion
|
||||
|
||||
#region IServiceProvider implementation
|
||||
public object GetService(Type serviceType) |
||||
{ |
||||
// System.Console.WriteLine("calling <{0}>",serviceType.ToString());
|
||||
if (LoggingService.IsInfoEnabled && IsServiceMissing(serviceType)) { |
||||
// LoggingService.InfoFormatted("request missing service : {0} from Assembly {1} is not aviable.", serviceType, serviceType.Assembly.FullName);
|
||||
// System.Console.WriteLine("Missing <{0}>",serviceType);
|
||||
// System.Console.WriteLine("\t found");
|
||||
} else { |
||||
// System.Console.WriteLine("\tmissing");
|
||||
// LoggingService.DebugFormatted("get service : {0} from Assembly {1}.", serviceType, serviceType.Assembly.FullName);
|
||||
// System.Console.WriteLine("Missing <{0}>",serviceType);
|
||||
} |
||||
return serviceContainer.GetService(serviceType); |
||||
} |
||||
#endregion
|
||||
|
||||
bool IsServiceMissing(Type serviceType) |
||||
{ |
||||
return serviceContainer.GetService(serviceType) == null; |
||||
} |
||||
|
||||
#region IDisposable implementation
|
||||
public void Dispose() |
||||
{ |
||||
inDispose = true; |
||||
foreach (DictionaryEntry o in services) { |
||||
if (o.Value == this) { |
||||
continue; |
||||
} |
||||
// || o.GetType().Assembly != Assembly.GetCallingAssembly()
|
||||
IDisposable disposeMe = o.Value as IDisposable; |
||||
if (disposeMe != null) { |
||||
try { |
||||
disposeMe.Dispose(); |
||||
} catch (Exception e) { |
||||
ICSharpCode.Core.MessageService.ShowException(e, "Exception while disposing " + disposeMe); |
||||
} |
||||
} |
||||
} |
||||
services.Clear(); |
||||
services = null; |
||||
inDispose = false; |
||||
} |
||||
#endregion
|
||||
} |
||||
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.ComponentModel.Design; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Services |
||||
{ |
||||
/// <summary>
|
||||
/// This class implements the IDesignerSerializationService interface.
|
||||
/// A designer loader that does not derive from the CodeDOMDesignerLoader class
|
||||
/// (e.g. the XmlDesignerLoader) need to create an instance of this class
|
||||
/// and it to the available services otherwise cut/copy and paste will not work.
|
||||
/// </summary>
|
||||
class DesignerSerializationService : IDesignerSerializationService |
||||
{ |
||||
readonly IServiceProvider serviceProvider; |
||||
public DesignerSerializationService(IServiceProvider serviceProvider) |
||||
{ |
||||
if (serviceProvider == null) { |
||||
throw new ArgumentNullException("serviceProvider"); |
||||
} |
||||
this.serviceProvider = serviceProvider; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Deserializes the serialization data object and returns a
|
||||
/// collection of objects represented by that data.
|
||||
/// </summary>
|
||||
public ICollection Deserialize(object serializationData) |
||||
{ |
||||
var host = (IDesignerHost)this.serviceProvider.GetService(typeof(IDesignerHost)); |
||||
if (host != null) { |
||||
var serializationService = (ComponentSerializationService)serviceProvider.GetService(typeof(ComponentSerializationService)); |
||||
return serializationService.Deserialize((SerializationStore)serializationData,host.Container); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Serializes a collection of objects and stores them in a
|
||||
/// serialization data object.
|
||||
/// </summary>
|
||||
public object Serialize(ICollection objects) |
||||
{ |
||||
if (objects == null) { |
||||
throw new ArgumentNullException("objects"); |
||||
} |
||||
var serializationService = (ComponentSerializationService)serviceProvider.GetService(typeof(ComponentSerializationService)); |
||||
SerializationStore store = serializationService.CreateStore(); |
||||
foreach (object value in objects) { |
||||
serializationService.Serialize(store, value); |
||||
} |
||||
store.Close(); |
||||
return store; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,77 @@
@@ -0,0 +1,77 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.02.2014 |
||||
* Time: 18:31 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel.Design; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Services |
||||
{ |
||||
class HelpService : IHelpService |
||||
{ |
||||
string f1Keyword; |
||||
string generalKeyword; |
||||
|
||||
|
||||
public HelpService() |
||||
{ |
||||
LoggingService.Info("Create HelpService"); |
||||
} |
||||
|
||||
public void AddContextAttribute(string name, string value, HelpKeywordType keywordType) |
||||
{ |
||||
switch (keywordType) { |
||||
case HelpKeywordType.F1Keyword: |
||||
f1Keyword = value; |
||||
return; |
||||
case HelpKeywordType.GeneralKeyword: |
||||
generalKeyword = value; |
||||
return; |
||||
} |
||||
} |
||||
|
||||
public void ClearContextAttributes() |
||||
{ |
||||
} |
||||
|
||||
public IHelpService CreateLocalContext(HelpContextType contextType) |
||||
{ |
||||
return this; |
||||
} |
||||
|
||||
public void RemoveContextAttribute(string name, string value) |
||||
{ |
||||
// System.Console.WriteLine("child removeing {0} : {1}",name,value);
|
||||
// object att = helpGUI.RemoveContextAttributeFromView(name,value);
|
||||
// ContextAttributes.Remove(att);;
|
||||
} |
||||
|
||||
public void RemoveLocalContext(IHelpService localContext) |
||||
{ |
||||
} |
||||
|
||||
public void ShowHelpFromKeyword(string helpKeyword) |
||||
{ |
||||
HelpProvider.ShowHelpByKeyword(helpKeyword); |
||||
} |
||||
public void ShowGeneralHelp() |
||||
{ |
||||
ShowHelpFromKeyword(generalKeyword); |
||||
} |
||||
public void ShowHelp() |
||||
{ |
||||
// HelpProvider.ShowHelp(f1Keyword);
|
||||
} |
||||
|
||||
public void ShowHelpFromUrl(string helpUrl) |
||||
{ |
||||
FileService.OpenFile("browser://" + helpUrl); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,87 @@
@@ -0,0 +1,87 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.ComponentModel.Design; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using System.Windows.Forms.Design; |
||||
|
||||
using ICSharpCode.Core.WinForms; |
||||
using ICSharpCode.Reporting.Items; |
||||
using ICSharpCode.Reporting.Addin.Designer; |
||||
using CommandID = System.ComponentModel.Design.CommandID; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Services |
||||
{ |
||||
class MenuCommandService : System.ComponentModel.Design.MenuCommandService |
||||
{ |
||||
|
||||
Control panel; |
||||
|
||||
public MenuCommandService(Control panel, IServiceProvider serviceProvider) : base(serviceProvider) |
||||
{ |
||||
this.panel = panel; |
||||
// this.InitializeGlobalCommands( );
|
||||
} |
||||
|
||||
/* |
||||
private void InitializeGlobalCommands() |
||||
{ |
||||
//Most commands like Delete, Cut, Copy and paste are all added to the MenuCommandService
|
||||
// by the other services like the DesignerHost. Commands like ViewCode and ShowProperties
|
||||
// need to be added by the IDE because only the IDE would know how to perform those actions.
|
||||
// This allows people to call MenuCommandSerice.GlobalInvoke( StandardCommands.ViewCode );
|
||||
// from designers and what not. .Net Control Designers like the TableLayoutPanelDesigner
|
||||
// build up their own context menus instead of letting the MenuCommandService build it.
|
||||
// The context menus they build up are in the format that Visual studio expects and invokes
|
||||
// the ViewCode and Properties commands by using GlobalInvoke.
|
||||
|
||||
// AbstractFormsDesignerCommand viewCodeCommand = new ViewCode();
|
||||
// AbstractFormsDesignerCommand propertiesCodeCommand = new ShowProperties();
|
||||
// this.AddCommand( new MenuCommand(viewCodeCommand.CommandCallBack, viewCodeCommand.CommandID));
|
||||
// this.AddCommand( new MenuCommand(propertiesCodeCommand.CommandCallBack, propertiesCodeCommand.CommandID));
|
||||
} |
||||
*/ |
||||
public override void ShowContextMenu(CommandID menuID, int x, int y) |
||||
{ |
||||
string contextMenuPath = "/SharpDevelop/ReportDesigner/ContextMenus/"; |
||||
var selectionService = (ISelectionService)base.GetService(typeof(ISelectionService)); |
||||
|
||||
if (selectionService != null) { |
||||
if (menuID == MenuCommands.TraySelectionMenu) { |
||||
contextMenuPath += "TraySelectionMenu"; |
||||
} |
||||
else if (selectionService.PrimarySelection is RootReportModel) { |
||||
System.Console.WriteLine("found Root"); |
||||
contextMenuPath += "ContainerMenu"; |
||||
} |
||||
else if (selectionService.PrimarySelection is BaseSection) { |
||||
System.Console.WriteLine("found baseSection"); |
||||
contextMenuPath += "ContainerMenu"; |
||||
} |
||||
else { |
||||
contextMenuPath += "SelectionMenu"; |
||||
} |
||||
|
||||
Point p = panel.PointToClient(new Point(x, y)); |
||||
MenuService.ShowContextMenu(this, contextMenuPath, panel, p.X, p.Y); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,87 @@
@@ -0,0 +1,87 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 16.03.2014 |
||||
* Time: 17:57 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Diagnostics; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Services |
||||
{ |
||||
/// <summary>
|
||||
/// Description of NameCreationService.
|
||||
/// </summary>
|
||||
public class NameCreationService: INameCreationService |
||||
{ |
||||
public NameCreationService() |
||||
{ |
||||
} |
||||
|
||||
string INameCreationService.CreateName(IContainer container, Type type) |
||||
{ |
||||
|
||||
var cc = container.Components; |
||||
int min = Int32.MaxValue; |
||||
int max = Int32.MinValue; |
||||
int count = 0; |
||||
|
||||
for (int i = 0; i < cc.Count; i++) |
||||
{ |
||||
var comp = cc[i] as Component; |
||||
if (comp.GetType() == type) |
||||
{ |
||||
count++; |
||||
|
||||
string name = comp.Site.Name; |
||||
if(name.StartsWith(type.Name,StringComparison.InvariantCultureIgnoreCase)) |
||||
{ |
||||
try |
||||
{ |
||||
int value = Int32.Parse(name.Substring(type.Name.Length)); |
||||
|
||||
if (value < min) |
||||
min = value; |
||||
|
||||
if (value > max) |
||||
max = value; |
||||
} |
||||
catch (Exception ex) |
||||
{ |
||||
Trace.WriteLine(ex.ToString()); |
||||
} |
||||
} |
||||
} |
||||
}// for
|
||||
|
||||
if (count == 0) |
||||
return type.Name + "1"; |
||||
|
||||
else if (min > 1) |
||||
{ |
||||
int j = min - 1; |
||||
|
||||
return type.Name + j.ToString(); |
||||
} |
||||
else |
||||
{ |
||||
int j = max + 1; |
||||
|
||||
return type.Name + j.ToString(); |
||||
} |
||||
} |
||||
|
||||
bool INameCreationService.IsValidName(string name) |
||||
{ |
||||
return true; |
||||
} |
||||
void INameCreationService.ValidateName(string name) |
||||
{ |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,330 @@
@@ -0,0 +1,330 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.02.2014 |
||||
* Time: 18:25 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.ComponentModel.Design; |
||||
using System.Drawing.Design; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Services |
||||
{ |
||||
public delegate void ToolboxEventHandler(object sender, ToolboxEventArgs tea); |
||||
|
||||
public class ToolboxEventArgs : EventArgs |
||||
{ |
||||
ToolboxItem item = null; |
||||
string category = null; |
||||
IDesignerHost host = null; |
||||
|
||||
public ToolboxEventArgs(ToolboxItem item, string category, IDesignerHost host) |
||||
{ |
||||
this.item = item; |
||||
this.category = category; |
||||
this.host = host; |
||||
} |
||||
|
||||
public ToolboxItem Item { |
||||
get { |
||||
return item; |
||||
} |
||||
} |
||||
|
||||
public string Category { |
||||
get { |
||||
return category; |
||||
} |
||||
} |
||||
|
||||
public IDesignerHost Host { |
||||
get { |
||||
return host; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
/// <summary>
|
||||
/// Description of ToolboxService.
|
||||
/// </summary>
|
||||
public class ToolboxService:IToolboxService |
||||
{ |
||||
ArrayList toolboxItems = new ArrayList(); |
||||
ToolboxItem selectedItem; |
||||
|
||||
public ToolboxService() |
||||
{ |
||||
LoggingService.Info("Create Tolboxservice"); |
||||
} |
||||
|
||||
public CategoryNameCollection CategoryNames { |
||||
get { |
||||
return new CategoryNameCollection(new string [] {"Reporting"});; |
||||
} |
||||
} |
||||
|
||||
public string SelectedCategory { |
||||
get { |
||||
System.Console.WriteLine("ToolboxSerivce:SelectedCategory"); |
||||
return String.Empty; |
||||
} |
||||
set { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public void AddCreator(ToolboxItemCreatorCallback creator, string format) |
||||
{ |
||||
this.AddCreator(creator,format,null); |
||||
} |
||||
|
||||
public void AddCreator(ToolboxItemCreatorCallback creator, string format, IDesignerHost host) |
||||
{ |
||||
// System.Console.WriteLine(" AddCreator for");
|
||||
// System.Console.WriteLine("\t {0} / {1} / {2}",creator.ToString(),format,host.ToString());
|
||||
} |
||||
|
||||
public void AddLinkedToolboxItem(ToolboxItem toolboxItem, IDesignerHost host) |
||||
{ |
||||
AddItemToToolbox(toolboxItem,null,host); |
||||
} |
||||
|
||||
public void AddLinkedToolboxItem(ToolboxItem toolboxItem, string category, IDesignerHost host) |
||||
{ |
||||
AddItemToToolbox(toolboxItem, category, host); |
||||
} |
||||
|
||||
public void AddToolboxItem(ToolboxItem toolboxItem) |
||||
{ |
||||
AddItemToToolbox(toolboxItem,null,null); |
||||
} |
||||
|
||||
public void AddToolboxItem(ToolboxItem toolboxItem, string category) |
||||
{ |
||||
AddItemToToolbox(toolboxItem,category,null); |
||||
} |
||||
|
||||
void AddItemToToolbox(ToolboxItem toolboxItem, string category, IDesignerHost host) |
||||
{ |
||||
toolboxItems.Add(toolboxItem); |
||||
System.Console.WriteLine("{0}",toolboxItems.Count); |
||||
FireToolboxItemAdded(toolboxItem, category, host); |
||||
} |
||||
|
||||
public ToolboxItem DeserializeToolboxItem(object serializedObject) |
||||
{ |
||||
System.Console.WriteLine("DeserializeToolboxItem throw exception"); |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ToolboxItem DeserializeToolboxItem(object serializedObject, IDesignerHost host) |
||||
{ |
||||
ToolboxItem item = (ToolboxItem) ((System.Windows.Forms.IDataObject)serializedObject).GetData(typeof(ToolboxItem)); |
||||
return item; |
||||
} |
||||
|
||||
public ToolboxItem GetSelectedToolboxItem() |
||||
{ |
||||
return selectedItem; |
||||
} |
||||
|
||||
public ToolboxItem GetSelectedToolboxItem(IDesignerHost host) |
||||
{ |
||||
return this.selectedItem; |
||||
} |
||||
|
||||
public ToolboxItemCollection GetToolboxItems() |
||||
{ |
||||
ToolboxItem[] items = new ToolboxItem[toolboxItems.Count]; |
||||
toolboxItems.CopyTo(items); |
||||
return new ToolboxItemCollection(items); |
||||
} |
||||
|
||||
public ToolboxItemCollection GetToolboxItems(IDesignerHost host) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ToolboxItemCollection GetToolboxItems(string category) |
||||
{ |
||||
System.Console.WriteLine("ddddd"); |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public ToolboxItemCollection GetToolboxItems(string category, IDesignerHost host) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool IsSupported(object serializedObject, IDesignerHost host) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public bool IsSupported(object serializedObject, ICollection filterAttributes) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public bool IsToolboxItem(object serializedObject) |
||||
{ |
||||
System.Console.WriteLine("gggggg"); |
||||
if (serializedObject is System.Windows.Forms.IDataObject) { |
||||
if (((System.Windows.Forms.IDataObject)serializedObject).GetDataPresent(typeof(ToolboxItem))) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public bool IsToolboxItem(object serializedObject, IDesignerHost host) |
||||
{ |
||||
System.Console.WriteLine("Toolbox:IsToolboxItem"); |
||||
// needed for Toolbox drag & drop
|
||||
if (serializedObject is System.Windows.Forms.IDataObject) { |
||||
if (((System.Windows.Forms.IDataObject)serializedObject).GetDataPresent(typeof(ToolboxItem))) { |
||||
ToolboxItem item = (ToolboxItem) ((System.Windows.Forms.IDataObject)serializedObject).GetData(typeof(ToolboxItem)); |
||||
// if (host != null) {
|
||||
// ArrayList list = (ArrayList)toolboxByHost[host];
|
||||
// if (list != null && list.Contains(item)) {
|
||||
// return true;
|
||||
// }
|
||||
// list = (ArrayList)toolboxByHost[ALL_HOSTS];
|
||||
// if (list != null && list.Contains(item)) {
|
||||
return true; |
||||
// }
|
||||
// }
|
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public void Refresh() |
||||
{ |
||||
System.Console.WriteLine("Toolbox:Refresh()"); |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void RemoveCreator(string format) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void RemoveCreator(string format, IDesignerHost host) |
||||
{ |
||||
System.Console.WriteLine("Toolbox:removeCreator"); |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void RemoveToolboxItem(ToolboxItem toolboxItem) |
||||
{ |
||||
this.toolboxItems.Remove(toolboxItem); |
||||
FireToolboxItemRemoved(toolboxItem, null, null); |
||||
} |
||||
|
||||
public void RemoveToolboxItem(ToolboxItem toolboxItem, string category) |
||||
{ |
||||
System.Console.WriteLine("RemoveToolboxItem"); |
||||
toolboxItems.Remove(toolboxItem); |
||||
FireToolboxItemRemoved(toolboxItem, null, null); |
||||
} |
||||
|
||||
public void SelectedToolboxItemUsed() |
||||
{ |
||||
FireSelectedItemUsed(); |
||||
} |
||||
|
||||
public object SerializeToolboxItem(ToolboxItem toolboxItem) |
||||
{ |
||||
System.Console.WriteLine("nnnn"); |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool SetCursor() |
||||
{ |
||||
if (selectedItem == null) { |
||||
return false; |
||||
} |
||||
if (selectedItem.DisplayName == "Pointer") { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public void SetSelectedToolboxItem(ToolboxItem toolboxItem) |
||||
{ |
||||
if (toolboxItem != selectedItem) { |
||||
FireSelectedItemChanging(); |
||||
selectedItem = toolboxItem; |
||||
FireSelectedItemChanged(); |
||||
} |
||||
} |
||||
|
||||
#region EvenHelpers
|
||||
/* |
||||
void FireSelectedCategoryChanging() |
||||
{ |
||||
if (SelectedCategoryChanging != null) { |
||||
SelectedCategoryChanging(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
*/ |
||||
|
||||
void FireSelectedItemChanged() |
||||
{ |
||||
if (SelectedItemChanged != null) { |
||||
SelectedItemChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
void FireSelectedItemChanging() |
||||
{ |
||||
if (SelectedItemChanging != null) { |
||||
SelectedItemChanging(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
/* |
||||
void FireSelectedCategoryChanged() |
||||
{ |
||||
if (SelectedCategoryChanged != null) { |
||||
SelectedCategoryChanged(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
*/ |
||||
|
||||
void FireSelectedItemUsed() |
||||
{ |
||||
if (SelectedItemUsed != null) { |
||||
SelectedItemUsed(this, EventArgs.Empty); |
||||
} |
||||
} |
||||
|
||||
void FireToolboxItemAdded(ToolboxItem item, string category, IDesignerHost host) |
||||
{ |
||||
if (ToolboxItemAdded != null) { |
||||
ToolboxItemAdded(this, new ToolboxEventArgs(item, category, host)); |
||||
} |
||||
} |
||||
|
||||
void FireToolboxItemRemoved(ToolboxItem item, string category, IDesignerHost host) |
||||
{ |
||||
if (ToolboxItemAdded != null) { |
||||
ToolboxItemRemoved(this, new ToolboxEventArgs(item, category, host)); |
||||
} |
||||
} |
||||
// public event EventHandler SelectedCategoryChanging;
|
||||
// public event EventHandler SelectedCategoryChanged;
|
||||
public event EventHandler SelectedItemChanging; |
||||
public event EventHandler SelectedItemChanged; |
||||
public event EventHandler SelectedItemUsed; |
||||
public event ToolboxEventHandler ToolboxItemAdded; |
||||
public event ToolboxEventHandler ToolboxItemRemoved; |
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel.Design; |
||||
using System.Reflection; |
||||
|
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Services |
||||
{ |
||||
class TypeDiscoveryService : ITypeDiscoveryService |
||||
{ |
||||
public TypeDiscoveryService() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the list of available types.
|
||||
/// </summary>
|
||||
/// <param name="baseType">The base type to match. Can be null.</param>
|
||||
/// <param name="excludeGlobalTypes">Determines whether types
|
||||
/// from all referenced assemblies should be checked.</param>
|
||||
public ICollection GetTypes(Type baseType, bool excludeGlobalTypes) |
||||
{ |
||||
var types = new List<Type>(); |
||||
|
||||
if (baseType == null) { |
||||
baseType = typeof(object); |
||||
} |
||||
|
||||
LoggingService.Debug("TypeDiscoveryService.GetTypes for " + baseType.FullName |
||||
+ "excludeGlobalTypes=" + excludeGlobalTypes.ToString()); |
||||
//seek in all assemblies
|
||||
//allow to work designers like columns editor in datagridview
|
||||
// Searching types can cause additional assemblies to be loaded, so we need to use
|
||||
// ToArray to prevent an exception if the collection changes.
|
||||
|
||||
foreach (Assembly asm in TypeResolutionService.DesignerAssemblies.ToArray()) { |
||||
if (excludeGlobalTypes) { |
||||
// if (GacInterop.IsWithinGac(asm.Location)) {
|
||||
// continue;
|
||||
// }
|
||||
} |
||||
AddDerivedTypes(baseType, asm, types); |
||||
} |
||||
LoggingService.Debug("TypeDiscoveryService returns " + types.Count + " types"); |
||||
|
||||
// TODO - Don't look in all assemblies.
|
||||
// Should use the current project and its referenced assemblies
|
||||
// as well as System.Windows.Forms.
|
||||
|
||||
return types; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the types derived from baseType from the assembly and adds them to the list.
|
||||
/// </summary>
|
||||
void AddDerivedTypes(Type baseType, Assembly assembly, IList<Type> list) |
||||
{ |
||||
foreach (Type t in assembly.GetExportedTypes()) { |
||||
if (t.IsSubclassOf(baseType)) { |
||||
//LoggingService.Debug("TypeDiscoveryService. Adding type=" + t.FullName);
|
||||
list.Add(t); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 24.02.2014 |
||||
* Time: 19:02 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel.Design; |
||||
using System.Reflection; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Services |
||||
{ |
||||
/// <summary>
|
||||
/// Description of Class1.
|
||||
/// </summary>
|
||||
|
||||
class TypeResolutionService : ITypeResolutionService |
||||
{ |
||||
readonly static List<Assembly> designerAssemblies = new List<Assembly>(); |
||||
|
||||
/// <summary>
|
||||
/// List of assemblies used by the form designer. This static list is not an optimal solution,
|
||||
/// but better than using AppDomain.CurrentDomain.GetAssemblies(). See SD2-630.
|
||||
/// </summary>
|
||||
public static List<Assembly> DesignerAssemblies { |
||||
get { |
||||
return designerAssemblies; |
||||
} |
||||
} |
||||
|
||||
static TypeResolutionService() |
||||
{ |
||||
DesignerAssemblies.Add(typeof(object).Assembly); |
||||
DesignerAssemblies.Add(typeof(Uri).Assembly); |
||||
DesignerAssemblies.Add(typeof(System.Drawing.Point).Assembly); |
||||
DesignerAssemblies.Add(typeof(System.Windows.Forms.Design.AnchorEditor).Assembly); |
||||
DesignerAssemblies.Add(typeof(TypeResolutionService).Assembly); |
||||
} |
||||
|
||||
public Assembly GetAssembly(AssemblyName name) |
||||
{ |
||||
return LoadAssembly(name, false); |
||||
} |
||||
|
||||
public Assembly GetAssembly(AssemblyName name, bool throwOnError) |
||||
{ |
||||
return LoadAssembly(name, throwOnError); |
||||
} |
||||
|
||||
static Assembly LoadAssembly(AssemblyName name, bool throwOnError) |
||||
{ |
||||
try { |
||||
return Assembly.Load(name); |
||||
} catch (System.IO.FileLoadException) { |
||||
if (throwOnError) |
||||
throw; |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public string GetPathOfAssembly(AssemblyName name) |
||||
{ |
||||
Assembly assembly = GetAssembly(name); |
||||
if (assembly != null) { |
||||
return assembly.Location; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public Type GetType(string name) |
||||
{ |
||||
return GetType(name, false, false); |
||||
} |
||||
|
||||
public Type GetType(string name, bool throwOnError) |
||||
{ |
||||
return GetType(name, throwOnError, false); |
||||
} |
||||
|
||||
public Type GetType(string name, bool throwOnError, bool ignoreCase) |
||||
{ |
||||
if (name == null || name.Length == 0) { |
||||
return null; |
||||
} |
||||
#if DEBUG
|
||||
if (!name.StartsWith("System.",StringComparison.InvariantCultureIgnoreCase)) { |
||||
LoggingService.Debug("TypeResolutionService: Looking for " + name); |
||||
} |
||||
#endif
|
||||
try { |
||||
|
||||
Type type = Type.GetType(name, false, ignoreCase); |
||||
|
||||
if (type == null) { |
||||
lock (designerAssemblies) { |
||||
foreach (Assembly asm in DesignerAssemblies) { |
||||
Type t = asm.GetType(name, false); |
||||
if (t != null) { |
||||
return t; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (throwOnError && type == null) |
||||
throw new TypeLoadException(name + " not found by TypeResolutionService"); |
||||
|
||||
return type; |
||||
} catch (Exception e) { |
||||
LoggingService.Error(e); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public void ReferenceAssembly(AssemblyName name) |
||||
{ |
||||
LoggingService.Warn("TODO: Add Assembly reference : " + name); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,105 @@
@@ -0,0 +1,105 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.02.2014 |
||||
* Time: 18:10 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Services |
||||
{ |
||||
/// <summary>
|
||||
/// Description of UIService.
|
||||
/// </summary>
|
||||
class UIService : System.Windows.Forms.Design.IUIService |
||||
{ |
||||
IDictionary styles = new Hashtable(); |
||||
|
||||
public IDictionary Styles { |
||||
get { |
||||
return styles; |
||||
} |
||||
} |
||||
|
||||
public UIService() |
||||
{ |
||||
styles["DialogFont"] = Control.DefaultFont; |
||||
styles["HighlightColor"] = Color.LightYellow; |
||||
} |
||||
|
||||
public void SetUIDirty() |
||||
{ |
||||
|
||||
} |
||||
|
||||
#region ComponentEditor functions
|
||||
public bool CanShowComponentEditor(object component) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public bool ShowComponentEditor(object component, IWin32Window parent) |
||||
{ |
||||
throw new System.NotImplementedException("Cannot display component editor for " + component); |
||||
} |
||||
#endregion
|
||||
|
||||
#region Dialog functions
|
||||
public IWin32Window GetDialogOwnerWindow() |
||||
{ |
||||
return SD.WinForms.MainWin32Window; |
||||
} |
||||
|
||||
public DialogResult ShowDialog(Form form) |
||||
{ |
||||
return form.ShowDialog(GetDialogOwnerWindow()); |
||||
} |
||||
#endregion
|
||||
|
||||
#region Show error functions
|
||||
public void ShowError(Exception ex) |
||||
{ |
||||
MessageService.ShowError(ex.ToString()); |
||||
} |
||||
|
||||
public void ShowError(string message) |
||||
{ |
||||
MessageService.ShowError(message); |
||||
} |
||||
|
||||
public void ShowError(Exception ex, string message) |
||||
{ |
||||
MessageService.ShowError(message + Environment.NewLine + ex.ToString()); |
||||
} |
||||
#endregion
|
||||
|
||||
#region Show Message functions
|
||||
public void ShowMessage(string message) |
||||
{ |
||||
ShowMessage(message, "", MessageBoxButtons.OK); |
||||
} |
||||
|
||||
public void ShowMessage(string message, string caption) |
||||
{ |
||||
ShowMessage(message, caption, MessageBoxButtons.OK); |
||||
} |
||||
|
||||
public DialogResult ShowMessage(string message, string caption, MessageBoxButtons buttons) |
||||
{ |
||||
return MessageBox.Show(GetDialogOwnerWindow(), message, caption, buttons); |
||||
} |
||||
#endregion
|
||||
|
||||
public bool ShowToolWindow(Guid toolWindow) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.03.2014 |
||||
* Time: 12:25 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Drawing.Design; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Toolbox |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SideTabItemDesigner.
|
||||
/// </summary>
|
||||
public class SideTabItemDesigner : SharpDevelopSideTabItem |
||||
{ |
||||
///<summary>create a tabitem from a toolboxitem. It init Icon and name from the tag</summary>
|
||||
public SideTabItemDesigner(ToolboxItem tag) : base(tag.DisplayName, tag) |
||||
{ |
||||
if (tag == null) { |
||||
throw new ArgumentNullException("tag"); |
||||
} |
||||
CanBeRenamed = false; |
||||
this.Icon = tag.Bitmap; |
||||
ReloadToolBox(); |
||||
} |
||||
|
||||
///<summary>create a tabitem from a toolboxitem. It init Icon from the tag</summary>
|
||||
public SideTabItemDesigner(string name, ToolboxItem tag) : base(name, tag) |
||||
{ |
||||
CanBeRenamed = false; |
||||
this.Icon = tag.Bitmap; |
||||
ReloadToolBox(); |
||||
} |
||||
|
||||
///<summary>create a default tabitem : a pointer icon with an empty toolboxitem</summary>
|
||||
public SideTabItemDesigner() : base("Pointer") |
||||
{ |
||||
CanBeRenamed = false; |
||||
CanBeDeleted = false; |
||||
var pointerBitmap = new Bitmap(IconService.GetBitmap("Icons.16x16.FormsDesigner.PointerIcon"), 16, 16); |
||||
this.Icon = pointerBitmap; |
||||
this.Tag = null; |
||||
ReloadToolBox(); |
||||
} |
||||
|
||||
///<summary>it force to reload toolboxitem into the ToolboxService when the hostchange</summary>
|
||||
public void ReloadToolBox() |
||||
{ |
||||
if (this.Name != "Pointer") { |
||||
// ToolboxProvider.ToolboxService.AddToolboxItem(this.Tag as ToolboxItem);
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,175 @@
@@ -0,0 +1,175 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.03.2014 |
||||
* Time: 12:31 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Drawing.Design; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Widgets.SideBar; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Toolbox |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ToolboxProvider.
|
||||
/// </summary>
|
||||
static class ToolboxProvider |
||||
{ |
||||
static SideTab standardSideTab; |
||||
static int viewCount; |
||||
static bool initialised; |
||||
|
||||
public static void AddViewContent(IViewContent viewContent) |
||||
{ |
||||
if (viewContent == null) |
||||
throw new ArgumentNullException("viewContent"); |
||||
|
||||
if (!initialised) |
||||
Initialise(); |
||||
|
||||
// Make sure the standard workflow sidebar exists
|
||||
if (standardSideTab == null) { |
||||
LoggingService.Debug("Creating Reporting Sidetab"); |
||||
standardSideTab = CreateReportingSidetab(); |
||||
} |
||||
ViewCount++; |
||||
} |
||||
|
||||
static void Initialise() |
||||
{ |
||||
initialised = true; |
||||
} |
||||
|
||||
|
||||
static SideTab CreateReportingSidetab () |
||||
{ |
||||
var sideTab = new SideTab("ReportDesigner"); |
||||
sideTab.CanSaved = false; |
||||
sideTab.Items.Add(CreateToolboxPointer(sideTab)); |
||||
|
||||
// TextItem
|
||||
var toolboxItem = new ToolboxItem(typeof(BaseTextItem)) { |
||||
DisplayName = ResourceService.GetString("SharpReport.Toolbar.TextBox"), |
||||
Bitmap = IconService.GetBitmap("Icons.16.16.SharpReport.Textbox") |
||||
}; |
||||
sideTab.Items.Add(new SideTabItemDesigner(toolboxItem)); |
||||
|
||||
//Grahics
|
||||
// Line
|
||||
toolboxItem = new ToolboxItem(typeof(BaseLineItem)) { |
||||
DisplayName = ResourceService.GetString("SharpReport.Toolbar.Line"), |
||||
Bitmap = IconService.GetBitmap("Icons.16.16.SharpReport.Line") |
||||
}; |
||||
|
||||
sideTab.Items.Add(new SideTabItemDesigner(toolboxItem)); |
||||
|
||||
/* |
||||
//GroupHeader
|
||||
tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.GroupHeader)); |
||||
tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.NameSpace"); |
||||
tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.GroupHeader"); |
||||
sideTab.Items.Add(new SideTabItemDesigner(tb)); |
||||
|
||||
|
||||
//GroupFooter
|
||||
tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.GroupFooter)); |
||||
tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.NameSpace"); |
||||
tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.GroupFooter"); |
||||
sideTab.Items.Add(new SideTabItemDesigner(tb)); |
||||
|
||||
// Row
|
||||
tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseRowItem)); |
||||
tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Table"); |
||||
tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.DataRow"); |
||||
sideTab.Items.Add(new SideTabItemDesigner(tb)); |
||||
|
||||
//BaseTable
|
||||
// tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Table");
|
||||
tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Table"); |
||||
tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseTableItem)); |
||||
tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Table"); |
||||
sideTab.Items.Add(new SideTabItemDesigner(tb)); |
||||
|
||||
|
||||
//BaseDataItem
|
||||
tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseDataItem)); |
||||
tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.DataField"); |
||||
// tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Column");
|
||||
tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Column"); |
||||
sideTab.Items.Add(new SideTabItemDesigner(tb)); |
||||
|
||||
//Grahics
|
||||
// Line
|
||||
tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseLineItem)); |
||||
tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Line"); |
||||
tb.Bitmap = WinFormsResourceService.GetIcon("Icons.16.16.SharpReport.Line").ToBitmap(); |
||||
sideTab.Items.Add(new SideTabItemDesigner(tb)); |
||||
|
||||
// Rectangle
|
||||
tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseRectangleItem)); |
||||
tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Rectangle"); |
||||
tb.Bitmap = GlobalValues.RectangleBitmap(); |
||||
sideTab.Items.Add(new SideTabItemDesigner(tb)); |
||||
|
||||
// Circle
|
||||
tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseCircleItem)); |
||||
tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Circle"); |
||||
tb.Bitmap = GlobalValues.CircleBitmap(); |
||||
sideTab.Items.Add(new SideTabItemDesigner(tb)); |
||||
|
||||
|
||||
// Image
|
||||
tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseImageItem)); |
||||
tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Image"); |
||||
tb.Bitmap = WinFormsResourceService.GetIcon("Icons.16x16.ResourceEditor.bmp").ToBitmap(); |
||||
sideTab.Items.Add(new SideTabItemDesigner(tb)); |
||||
*/ |
||||
return sideTab; |
||||
} |
||||
|
||||
|
||||
static SideTabItem CreateToolboxPointer(SideTab sideTab) |
||||
{ |
||||
var pointer = new SharpDevelopSideTabItem("Pointer") { |
||||
CanBeRenamed = false, |
||||
CanBeDeleted = false, |
||||
Icon = new Bitmap(IconService.GetBitmap("Icons.16x16.FormsDesigner.PointerIcon"), 16, 16), |
||||
Tag = null |
||||
}; |
||||
return pointer; |
||||
} |
||||
|
||||
|
||||
static SharpDevelopSideBar reportingSideBar; |
||||
|
||||
public static SharpDevelopSideBar ReportingSideBar { |
||||
get { |
||||
if (reportingSideBar == null) { |
||||
reportingSideBar = new SharpDevelopSideBar(); |
||||
reportingSideBar.Tabs.Add(standardSideTab); |
||||
ReportingSideBar.ActiveTab = standardSideTab; |
||||
} |
||||
return reportingSideBar; |
||||
} |
||||
} |
||||
|
||||
|
||||
static int ViewCount { |
||||
get { return viewCount; } |
||||
set { |
||||
viewCount = value; |
||||
|
||||
if (viewCount == 0) { |
||||
standardSideTab = null; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 18.03.2014 |
||||
* Time: 20:05 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.TypeProvider |
||||
{ |
||||
/// <summary>
|
||||
/// Description of AbstractItemTypeProvider.
|
||||
/// </summary>
|
||||
|
||||
class AbstractItemTypeProvider : TypeDescriptionProvider { |
||||
public AbstractItemTypeProvider() : base(TypeDescriptor.GetProvider(typeof(AbstractItem))) |
||||
{ |
||||
} |
||||
|
||||
public AbstractItemTypeProvider(TypeDescriptionProvider parent): base(parent) |
||||
{ |
||||
} |
||||
|
||||
|
||||
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) |
||||
{ |
||||
ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType, instance); |
||||
return new AbstractItemTypeDescriptor(td, instance); |
||||
} |
||||
} |
||||
|
||||
internal class AbstractItemTypeDescriptor : CustomTypeDescriptor |
||||
{ |
||||
// private AbstractItem _instance;
|
||||
|
||||
public AbstractItemTypeDescriptor(ICustomTypeDescriptor parent, object instance) |
||||
: base(parent) |
||||
{ |
||||
// _instance = instance as AbstractItem;
|
||||
} |
||||
|
||||
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties() |
||||
{ |
||||
return GetProperties(null); |
||||
} |
||||
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) |
||||
{ |
||||
PropertyDescriptorCollection props = base.GetProperties(attributes); |
||||
List<PropertyDescriptor> allProperties = new List<PropertyDescriptor>(); |
||||
|
||||
foreach (PropertyDescriptor p in props) |
||||
{ |
||||
allProperties.Add(p); |
||||
} |
||||
return new PropertyDescriptorCollection(allProperties.ToArray()); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.03.2014 |
||||
* Time: 18:02 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.TypeProvider |
||||
{ |
||||
/// <summary>
|
||||
/// Description of LineItemTypeProvider.
|
||||
/// </summary>
|
||||
class LineItemTypeProvider : TypeDescriptionProvider |
||||
{ |
||||
public LineItemTypeProvider() : base(TypeDescriptor.GetProvider(typeof(AbstractItem))) |
||||
{ |
||||
} |
||||
|
||||
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) |
||||
{ |
||||
ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType,instance); |
||||
return new LineItemTypeDescriptor(td, instance); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
class LineItemTypeDescriptor : CustomTypeDescriptor |
||||
{ |
||||
|
||||
|
||||
public LineItemTypeDescriptor(ICustomTypeDescriptor parent, object instance) |
||||
: base(parent) |
||||
{ |
||||
|
||||
} |
||||
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties() |
||||
{ |
||||
return GetProperties(null); |
||||
} |
||||
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) |
||||
{ |
||||
PropertyDescriptorCollection props = base.GetProperties(attributes); |
||||
List<PropertyDescriptor> allProperties = new List<PropertyDescriptor>(); |
||||
|
||||
TypeProviderHelper.AddDefaultProperties(allProperties,props); |
||||
|
||||
PropertyDescriptor prop = null; |
||||
prop = props.Find("ForeColor",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("FromPoint",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("ToPoint",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("StartLineCap",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("EndLineCap",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("dashLineCap",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("DashStyle",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("Thickness",true); |
||||
allProperties.Add(prop); |
||||
|
||||
return new PropertyDescriptorCollection(allProperties.ToArray()); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 17.03.2014 |
||||
* Time: 20:18 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.TypeProvider |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SectionItemTypeProvider.
|
||||
/// </summary>
|
||||
class SectionItemTypeProvider : TypeDescriptionProvider |
||||
{ |
||||
public SectionItemTypeProvider() : base(TypeDescriptor.GetProvider(typeof(AbstractItem))) |
||||
{ |
||||
} |
||||
|
||||
|
||||
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) |
||||
{ |
||||
ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType,instance); |
||||
return new SectionItemDescriptor(td, instance); |
||||
} |
||||
} |
||||
|
||||
|
||||
class SectionItemDescriptor : CustomTypeDescriptor |
||||
{ |
||||
|
||||
|
||||
public SectionItemDescriptor(ICustomTypeDescriptor parent, object instance) |
||||
: base(parent) |
||||
{ |
||||
} |
||||
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties() |
||||
{ |
||||
return GetProperties(null); |
||||
} |
||||
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) |
||||
{ |
||||
PropertyDescriptorCollection props = base.GetProperties(attributes); |
||||
List<PropertyDescriptor> allProperties = new List<PropertyDescriptor>(); |
||||
|
||||
TypeProviderHelper.AddDefaultProperties(allProperties,props); |
||||
PropertyDescriptor prop = null; |
||||
|
||||
prop = props.Find("SectionOffset",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("SectionMargin",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("DrawBorder",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("PageBreakAfter",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("Controls",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("FrameColor",true); |
||||
allProperties.Add(prop); |
||||
return new PropertyDescriptorCollection(allProperties.ToArray()); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.03.2014 |
||||
* Time: 20:38 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.TypeProvider |
||||
{ |
||||
/// <summary>
|
||||
/// Description of TextItemTypeProvider.
|
||||
/// </summary>
|
||||
class TextItemTypeProvider : TypeDescriptionProvider |
||||
{ |
||||
public TextItemTypeProvider() : base(TypeDescriptor.GetProvider(typeof(AbstractItem))) |
||||
{ |
||||
} |
||||
|
||||
|
||||
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) |
||||
{ |
||||
ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType,instance); |
||||
return new TextItemTypeDescriptor(td, instance); |
||||
} |
||||
} |
||||
|
||||
|
||||
class TextItemTypeDescriptor : CustomTypeDescriptor |
||||
{ |
||||
// BaseTextItem instance;
|
||||
|
||||
public TextItemTypeDescriptor(ICustomTypeDescriptor parent, object instance) |
||||
: base(parent) |
||||
{ |
||||
// instance = instance as BaseTextItem;
|
||||
} |
||||
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties() |
||||
{ |
||||
return GetProperties(null); |
||||
} |
||||
|
||||
|
||||
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) |
||||
{ |
||||
var props = base.GetProperties(attributes); |
||||
var allProperties = new List<PropertyDescriptor>(); |
||||
|
||||
TypeProviderHelper.AddDefaultProperties(allProperties,props); |
||||
|
||||
TypeProviderHelper.AddTextBasedProperties(allProperties,props); |
||||
|
||||
var prop = props.Find("Text", true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("DrawBorder",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("FrameColor",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("ForeColor",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("Visible",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("Expression",true); |
||||
allProperties.Add(prop); |
||||
|
||||
return new PropertyDescriptorCollection(allProperties.ToArray()); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,132 @@
@@ -0,0 +1,132 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 17.03.2014 |
||||
* Time: 20:20 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.TypeProvider |
||||
{ |
||||
/// <summary>
|
||||
/// Description of TypeProviderHelper.
|
||||
/// </summary>
|
||||
static class TypeProviderHelper |
||||
{ |
||||
|
||||
public static void RemoveProperties (IDictionary properties) |
||||
{ |
||||
if (properties == null){ |
||||
throw new ArgumentNullException("properties"); |
||||
} |
||||
properties.Remove("AccessibleDescription"); |
||||
properties.Remove("AccessibleName"); |
||||
properties.Remove("AccessibleRole"); |
||||
properties.Remove("AllowDrop"); |
||||
properties.Remove("Anchor"); |
||||
properties.Remove("AutoScroll"); |
||||
properties.Remove("AutoSize"); |
||||
properties.Remove("BackgroundImage"); |
||||
properties.Remove("BackgroundImageLayout"); |
||||
properties.Remove("Cursor"); |
||||
properties.Remove("CausesValidation"); |
||||
properties.Remove("ContextMenuStrip"); |
||||
properties.Remove("DataBindings"); |
||||
properties.Remove("Dock"); |
||||
|
||||
properties.Remove("Enabled"); |
||||
|
||||
properties.Remove("ImeMode"); |
||||
properties.Remove("Locked"); |
||||
properties.Remove("Padding"); |
||||
properties.Remove("RightToLeft"); |
||||
properties.Remove("TabIndex"); |
||||
properties.Remove("TabStop"); |
||||
properties.Remove("Tag"); |
||||
properties.Remove("UseWaitCursor"); |
||||
properties.Remove("Visible"); |
||||
} |
||||
|
||||
public static void Remove (IDictionary properties,string[] toRemove) |
||||
{ |
||||
if (properties == null){ |
||||
throw new ArgumentNullException("properties"); |
||||
} |
||||
if (toRemove == null) { |
||||
throw new ArgumentNullException("toRemove"); |
||||
} |
||||
foreach (String str in toRemove) |
||||
{ |
||||
properties.Remove(str); |
||||
} |
||||
} |
||||
|
||||
public static void AddDefaultProperties (List<PropertyDescriptor> allProperties, |
||||
PropertyDescriptorCollection props ) |
||||
{ |
||||
PropertyDescriptor prop = props.Find("Location",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("Size",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("BackColor",true); |
||||
allProperties.Add(prop); |
||||
|
||||
// prop = props.Find ("VisibleInReport",true);
|
||||
// allProperties.Add(prop);
|
||||
|
||||
|
||||
// need this for Contextmenu's
|
||||
prop = props.Find("ContextMenu",true); |
||||
allProperties.Add(prop); |
||||
} |
||||
|
||||
public static void AddTextBasedProperties (List<PropertyDescriptor> allProperties, |
||||
PropertyDescriptorCollection props) |
||||
{ |
||||
PropertyDescriptor prop = props.Find("Font",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("FormatString",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("StringTrimming",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("ContentAlignment",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("CanGrow",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("CanShrink",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("DataType",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("RTL",true); |
||||
allProperties.Add(prop); |
||||
} |
||||
|
||||
public static void AddGraphicProperties (List<PropertyDescriptor> allProperties, |
||||
PropertyDescriptorCollection props) |
||||
{ |
||||
PropertyDescriptor prop = null; |
||||
prop = props.Find("ForeColor",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("DashStyle",true); |
||||
allProperties.Add(prop); |
||||
|
||||
prop = props.Find("Thickness",true); |
||||
allProperties.Add(prop); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,409 @@
@@ -0,0 +1,409 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 22.02.2014 |
||||
* Time: 19:21 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
|
||||
using System.Collections; |
||||
using System.ComponentModel.Design; |
||||
|
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.Drawing.Design; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
using System.Windows.Forms.Design; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.Reporting.Addin.DesignableItems; |
||||
using ICSharpCode.Reporting.Addin.DesignerBinding; |
||||
using ICSharpCode.Reporting.Addin.Services; |
||||
using ICSharpCode.Reporting.Addin.Toolbox; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Views |
||||
{ |
||||
/// <summary>
|
||||
/// Description of the view content
|
||||
/// </summary>
|
||||
public class DesignerView : AbstractViewContent,IHasPropertyContainer, IToolsHost |
||||
{ |
||||
readonly IDesignerGenerator generator; |
||||
bool unloading; |
||||
bool hasUnmergedChanges; |
||||
bool shouldUpdateSelectableObjects; |
||||
bool isFormsDesignerVisible; |
||||
string reportFileContent; |
||||
Panel panel; |
||||
ReportDesignerLoader loader; |
||||
DefaultServiceContainer defaultServiceContainer; |
||||
DesignSurface designSurface; |
||||
|
||||
public DesignerView (OpenedFile openedFile,IDesignerGenerator generator) : base(openedFile){ |
||||
if (openedFile == null) { |
||||
throw new ArgumentNullException("openedFile"); |
||||
} |
||||
LoggingService.Info("DesignerView: Load from: " + openedFile.FileName); |
||||
|
||||
TabPageText = ResourceService.GetString("SharpReport.Design"); |
||||
|
||||
this.generator = generator; |
||||
this.generator.Attach(this); |
||||
//Start Toolbox
|
||||
ToolboxProvider.AddViewContent(this); |
||||
} |
||||
|
||||
|
||||
void LoadDesigner (Stream stream) { |
||||
LoggingService.Info("ReportDesigner LoadDesigner_Start"); |
||||
panel = CreatePanel(); |
||||
defaultServiceContainer = CreateAndInitServiceContainer(); |
||||
|
||||
LoggingService.Info("Create DesignSurface and add event's"); |
||||
designSurface = CreateDesignSurface(defaultServiceContainer); |
||||
SetDesignerEvents(); |
||||
|
||||
var ambientProperties = new AmbientProperties(); |
||||
defaultServiceContainer.AddService(typeof(AmbientProperties), ambientProperties); |
||||
|
||||
defaultServiceContainer.AddService(typeof(ITypeResolutionService), new TypeResolutionService()); |
||||
defaultServiceContainer.AddService(typeof(ITypeDiscoveryService),new TypeDiscoveryService()); |
||||
|
||||
defaultServiceContainer.AddService(typeof(IMenuCommandService), |
||||
new ICSharpCode.Reporting.Addin.Services.MenuCommandService(panel, designSurface)); |
||||
|
||||
defaultServiceContainer.AddService(typeof(MemberRelationshipService),new DefaultMemberRelationshipService()); |
||||
defaultServiceContainer.AddService(typeof(OpenedFile),base.PrimaryFile); |
||||
|
||||
LoggingService.Info("Load DesignerOptionService"); |
||||
var designerOptionService = CreateDesignerOptions(); |
||||
defaultServiceContainer.AddService( typeof( DesignerOptionService ), designerOptionService ); |
||||
|
||||
LoggingService.Info("Create ReportDesignerLoader"); |
||||
|
||||
loader = new ReportDesignerLoader(generator, stream); |
||||
designSurface.BeginLoad(this.loader); |
||||
if (!designSurface.IsLoaded) { |
||||
// throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
|
||||
LoggingService.Error("designer not loaded"); |
||||
} |
||||
//-------------
|
||||
|
||||
defaultServiceContainer.AddService(typeof(INameCreationService),new NameCreationService()); |
||||
|
||||
|
||||
var selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService)); |
||||
selectionService.SelectionChanged += SelectionChangedHandler; |
||||
/* |
||||
undoEngine = new ReportDesignerUndoEngine(Host); |
||||
*/ |
||||
var componentChangeService = (IComponentChangeService)this.designSurface.GetService(typeof(IComponentChangeService)); |
||||
|
||||
|
||||
componentChangeService.ComponentChanged += OnComponentChanged; |
||||
componentChangeService.ComponentAdded += OnComponentListChanged; |
||||
componentChangeService.ComponentRemoved += OnComponentListChanged; |
||||
componentChangeService.ComponentRename += OnComponentListChanged; |
||||
|
||||
this.Host.TransactionClosed += TransactionClose; |
||||
|
||||
UpdatePropertyPad(); |
||||
|
||||
hasUnmergedChanges = false; |
||||
|
||||
LoggingService.Info("ReportDesigner LoadDesigner_End"); |
||||
} |
||||
|
||||
|
||||
static Panel CreatePanel () |
||||
{ |
||||
var ctl = new Panel(); |
||||
ctl.Dock = DockStyle.Fill; |
||||
ctl.BackColor = System.Drawing.Color.LightBlue; |
||||
return ctl; |
||||
} |
||||
|
||||
|
||||
static DefaultServiceContainer CreateAndInitServiceContainer() |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: CreateAndInitServiceContainer..."); |
||||
var serviceContainer = new DefaultServiceContainer(); |
||||
serviceContainer.AddService(typeof(IUIService), new UIService()); |
||||
serviceContainer.AddService(typeof(IToolboxService),new ToolboxService()); |
||||
serviceContainer.AddService(typeof(IHelpService), new HelpService()); |
||||
return serviceContainer; |
||||
} |
||||
|
||||
|
||||
void SetDesignerEvents() |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: SetDesignerEvents..."); |
||||
|
||||
designSurface.Loading += DesignerLoading; |
||||
designSurface.Loaded += DesignerLoaded; |
||||
designSurface.Flushed += DesignerFlushed; |
||||
designSurface.Unloading += DesingerUnloading; |
||||
} |
||||
|
||||
|
||||
static WindowsFormsDesignerOptionService CreateDesignerOptions() |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: CreateDesignerOptions..."); |
||||
|
||||
var designerOptionService = new WindowsFormsDesignerOptionService(); |
||||
designerOptionService.Options.Properties.Find("UseSmartTags", true).SetValue(designerOptionService, true); |
||||
designerOptionService.Options.Properties.Find("ShowGrid", true).SetValue(designerOptionService, false); |
||||
designerOptionService.Options.Properties.Find("UseSnapLines", true).SetValue(designerOptionService, true); |
||||
return designerOptionService; |
||||
} |
||||
|
||||
#region ComponentChangeService
|
||||
|
||||
void OnComponentChanged (object sender, ComponentChangedEventArgs e) |
||||
{ |
||||
// BaseImageItem item = e.Component as BaseImageItem;
|
||||
//
|
||||
// if (item != null) {
|
||||
// item.ReportFileName = this.loader.ReportModel.ReportSettings.FileName;
|
||||
// }
|
||||
|
||||
bool loading = this.loader != null && this.loader.Loading; |
||||
LoggingService.Debug("ReportDesignerView: ComponentChanged: " + (e.Component == null ? "<null>" : e.Component.ToString()) + ", Member=" + (e.Member == null ? "<null>" : e.Member.Name) + ", OldValue=" + (e.OldValue == null ? "<null>" : e.OldValue.ToString()) + ", NewValue=" + (e.NewValue == null ? "<null>" : e.NewValue.ToString()) + "; Loading=" + loading + "; Unloading=" + this.unloading); |
||||
if (!loading && !unloading) { |
||||
this.MakeDirty(); |
||||
} |
||||
// MergeFormChanges();
|
||||
} |
||||
|
||||
|
||||
void OnComponentListChanged(object sender, EventArgs e) |
||||
{ |
||||
bool loading = this.loader != null && this.loader.Loading; |
||||
LoggingService.Debug("ReportDesigner: Component added/removed/renamed, Loading=" + loading + ", Unloading=" + this.unloading); |
||||
if (!loading && !unloading) { |
||||
shouldUpdateSelectableObjects = true; |
||||
MakeDirty(); |
||||
} |
||||
} |
||||
|
||||
void MakeDirty() |
||||
{ |
||||
hasUnmergedChanges = true; |
||||
PrimaryFile.MakeDirty(); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region SelectionService
|
||||
|
||||
void SelectionChangedHandler(object sender, EventArgs args) |
||||
{ |
||||
var selectionService = (ISelectionService)sender; |
||||
var abstractItem = selectionService.PrimarySelection as AbstractItem; |
||||
if (abstractItem != null) { |
||||
if (String.IsNullOrEmpty(abstractItem.Site.Name)) { |
||||
abstractItem.Site.Name = abstractItem.Name; |
||||
} |
||||
} |
||||
UpdatePropertyPadSelection((ISelectionService)sender); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region Transaction
|
||||
|
||||
void TransactionClose(object sender, DesignerTransactionCloseEventArgs e) |
||||
{ |
||||
if (shouldUpdateSelectableObjects) { |
||||
// update the property pad after the transaction is *really* finished
|
||||
// (including updating the selection)
|
||||
// WorkbenchSingleton.SafeThreadAsyncCall(UpdatePropertyPad);
|
||||
shouldUpdateSelectableObjects = false; |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region IToolsHost
|
||||
|
||||
object IToolsHost.ToolsContent { |
||||
get { |
||||
return ToolboxProvider.ReportingSideBar; |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region HasPropertyContainer implementation
|
||||
|
||||
PropertyContainer propertyContainer = new PropertyContainer(); |
||||
|
||||
public PropertyContainer PropertyContainer { |
||||
get { |
||||
return propertyContainer; |
||||
} |
||||
} |
||||
|
||||
|
||||
void UpdatePropertyPad() |
||||
{ |
||||
if (isFormsDesignerVisible && Host != null) { |
||||
propertyContainer.Host = Host; |
||||
propertyContainer.SelectableObjects = Host.Container.Components; |
||||
var selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService)); |
||||
if (selectionService != null) { |
||||
UpdatePropertyPadSelection(selectionService); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
void UpdatePropertyPadSelection(ISelectionService selectionService) |
||||
{ |
||||
ICollection selection = selectionService.GetSelectedComponents(); |
||||
var selArray = new object[selection.Count]; |
||||
selection.CopyTo(selArray, 0); |
||||
propertyContainer.SelectedObjects = selArray; |
||||
} |
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region DesignerEvents
|
||||
|
||||
void DesignerLoading(object sender, EventArgs e) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: Event > DesignerLoader loading..."); |
||||
this.unloading = false; |
||||
} |
||||
|
||||
|
||||
void DesignerLoaded(object sender, LoadedEventArgs e) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: Event > DesignerLoaded..."); |
||||
this.unloading = false; |
||||
|
||||
if (e.HasSucceeded) { |
||||
|
||||
SetupDesignSurface(); |
||||
isFormsDesignerVisible = true; |
||||
generator.MergeFormChanges(null); |
||||
// StartReportExplorer ();
|
||||
|
||||
LoggingService.Debug("FormsDesigner loaded, setting ActiveDesignSurface to " + this.designSurface.ToString()); |
||||
designSurfaceManager.ActiveDesignSurface = this.designSurface; |
||||
UpdatePropertyPad(); |
||||
} |
||||
} |
||||
|
||||
void DesignerFlushed(object sender, EventArgs e) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: Event > DesignerFlushed"); |
||||
} |
||||
|
||||
|
||||
void DesingerUnloading(object sender, EventArgs e) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: Event > DesignernUnloading..."); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Design surface manager (static)
|
||||
|
||||
static readonly DesignSurfaceManager designSurfaceManager = new DesignSurfaceManager(); |
||||
|
||||
static DesignSurface CreateDesignSurface(IServiceProvider serviceProvider) |
||||
{ |
||||
return designSurfaceManager.CreateDesignSurface(serviceProvider); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region IDesignerHost implementation
|
||||
|
||||
public IDesignerHost Host { |
||||
get { |
||||
return this.designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost; |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region UI
|
||||
|
||||
void SetupDesignSurface() |
||||
{ |
||||
var ctrl = designSurface.View as Control; |
||||
ctrl.Parent = panel; |
||||
ctrl.Dock = DockStyle.Fill; |
||||
} |
||||
|
||||
|
||||
void MergeFormChanges() |
||||
{ |
||||
LoggingService.Info("MergeFormChanges"); |
||||
this.designSurface.Flush(); |
||||
generator.MergeFormChanges(null); |
||||
hasUnmergedChanges = false; |
||||
} |
||||
|
||||
void SetupSecondaryView() |
||||
{ |
||||
var xmlView = new XmlView(generator,this); |
||||
SecondaryViewContents.Add(xmlView); |
||||
var preview = new WpfPreview(loader,this); |
||||
SecondaryViewContents.Add(preview); |
||||
} |
||||
|
||||
public string ReportFileContent { |
||||
get { |
||||
if (IsDirty) { |
||||
MergeFormChanges(); |
||||
} |
||||
return reportFileContent; } |
||||
set { reportFileContent = value; } |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region overrides
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the view
|
||||
/// </summary>
|
||||
public override object Control { |
||||
get {return panel;} |
||||
} |
||||
|
||||
|
||||
public override void Load(OpenedFile file, System.IO.Stream stream) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: Load from: " + file.FileName); |
||||
base.Load(file, stream); |
||||
LoadDesigner(stream); |
||||
SetupSecondaryView(); |
||||
} |
||||
|
||||
|
||||
public override void Save(OpenedFile file, Stream stream) |
||||
{ |
||||
if (IsDirty) { |
||||
if (hasUnmergedChanges) { |
||||
MergeFormChanges(); |
||||
} |
||||
using(var writer = new StreamWriter(stream)) { |
||||
writer.Write(ReportFileContent); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 24.03.2014 |
||||
* Time: 20:02 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Reporting.Items; |
||||
using ICSharpCode.Reporting.WpfReportViewer; |
||||
using ICSharpCode.Reporting.Xml; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.Reporting.Addin.DesignerBinding; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Views |
||||
{ |
||||
/// <summary>
|
||||
/// Description of the view content
|
||||
/// </summary>
|
||||
public class WpfPreview : AbstractSecondaryViewContent |
||||
{ |
||||
ReportDesignerLoader designerLoader; |
||||
|
||||
ICSharpCode.Reporting.WpfReportViewer.WpfReportViewer viewer = new ICSharpCode.Reporting.WpfReportViewer.WpfReportViewer(); |
||||
|
||||
public WpfPreview(ReportDesignerLoader loader,IViewContent content):base(content) |
||||
{ |
||||
LoggingService.Info("Create WpfPreview"); |
||||
this.designerLoader = loader; |
||||
TabPageText = "WpfPreview"; |
||||
} |
||||
|
||||
protected override void LoadFromPrimary() |
||||
{ |
||||
LoggingService.Info("LoadFrompromary"); |
||||
|
||||
var xml = designerLoader.SerializeModel(); |
||||
var modelLoader = new ModelLoader(); |
||||
var reportmodel = modelLoader.Load(xml.DocumentElement) as ReportModel; |
||||
var reportingFactory = new ReportingFactory(); |
||||
var reportCreator = reportingFactory.ReportCreator(reportmodel); |
||||
reportCreator.BuildExportList(); |
||||
var previewViewModel = new PreviewViewModel (reportingFactory.ReportModel.ReportSettings,reportCreator.Pages); |
||||
viewer.SetBinding(previewViewModel); |
||||
} |
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the view
|
||||
/// </summary>
|
||||
public override object Control { |
||||
get { |
||||
return viewer; |
||||
} |
||||
} |
||||
|
||||
protected override void SaveToPrimary() |
||||
{ |
||||
LoggingService.Info("WpfPreview:SaveToPrimary is not implemented"); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,79 @@
@@ -0,0 +1,79 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 17.03.2014 |
||||
* Time: 20:08 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.Reporting.Addin.DesignerBinding; |
||||
|
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Views |
||||
{ |
||||
/// <summary>
|
||||
/// Description of XmlView.
|
||||
/// </summary>
|
||||
class XmlView : AbstractSecondaryViewContent |
||||
{ |
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the view
|
||||
/// </summary>
|
||||
RichTextBox richTextBox = new RichTextBox(); |
||||
IDesignerGenerator generator; |
||||
|
||||
public XmlView(IDesignerGenerator generator,IViewContent content):base(content){ |
||||
if (generator == null) { |
||||
throw new ArgumentNullException("generator"); |
||||
} |
||||
if (content == null) { |
||||
throw new ArgumentNullException("content"); |
||||
} |
||||
this.generator = generator; |
||||
this.TabPageText = "XmlView"; |
||||
richTextBox.Dock = DockStyle.Fill; |
||||
richTextBox.BackColor = System.Drawing.SystemColors.Desktop; |
||||
richTextBox.ForeColor = System.Drawing.Color.White; |
||||
} |
||||
|
||||
#region overrides
|
||||
|
||||
protected override void LoadFromPrimary() |
||||
{ |
||||
richTextBox.Text = generator.ViewContent.ReportFileContent; |
||||
} |
||||
|
||||
protected override void SaveToPrimary() |
||||
{ |
||||
// throw new NotImplementedException();
|
||||
} |
||||
|
||||
|
||||
public override object Control { |
||||
get { |
||||
return richTextBox; |
||||
} |
||||
} |
||||
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up all used resources
|
||||
/// </summary>
|
||||
public sealed override void Dispose() |
||||
{ |
||||
try { |
||||
if (this.richTextBox != null) { |
||||
this.richTextBox.Dispose(); |
||||
} |
||||
} finally { |
||||
base.Dispose(); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 16.03.2014 |
||||
* Time: 18:31 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.ComponentModel; |
||||
using System.Reflection; |
||||
using System.Xml; |
||||
using System.Xml.Serialization; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.XML |
||||
{ |
||||
/// <summary>
|
||||
/// Description of MycroWriter.
|
||||
/// </summary>
|
||||
public class MycroWriter |
||||
{ |
||||
protected virtual string GetTypeName(Type t) |
||||
{ |
||||
return t.Name; |
||||
} |
||||
|
||||
public void Save(object obj, XmlWriter writer) |
||||
{ |
||||
Type t = obj.GetType(); |
||||
|
||||
// writer.WriteStartElement(GetTypeName(t));
|
||||
// System.Console.WriteLine("\tSave <{0}>",GetTypeName(t));
|
||||
|
||||
writer.WriteStartElement(obj.GetType().Name); |
||||
|
||||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(obj); |
||||
PropertyInfo [] propertyInfos = new PropertyInfo[properties.Count]; |
||||
|
||||
for (int i = 0;i < properties.Count ; i ++){ |
||||
propertyInfos[i] = t.GetProperty(properties[i].Name); |
||||
} |
||||
|
||||
foreach (PropertyInfo info in propertyInfos) { |
||||
if (info == null){ |
||||
continue; |
||||
} |
||||
if (!info.CanRead) continue; |
||||
|
||||
if (info.GetCustomAttributes(typeof(XmlIgnoreAttribute), true).Length != 0) continue; |
||||
object val = info.GetValue(obj, null); |
||||
if (val == null) continue; |
||||
if (val is ICollection) { |
||||
// PropertyInfo pinfo = t.GetProperty(info.Name);
|
||||
// Console.WriteLine("pinfo {0}",pinfo.Name);
|
||||
if (info.Name.StartsWith("Contr")) { |
||||
writer.WriteStartElement("Items"); |
||||
} else { |
||||
writer.WriteStartElement(info.Name); |
||||
} |
||||
foreach (object element in (ICollection)val) { |
||||
Save(element, writer); |
||||
} |
||||
|
||||
writer.WriteEndElement(); |
||||
} else { |
||||
if (!info.CanWrite) continue; |
||||
|
||||
TypeConverter c = TypeDescriptor.GetConverter(info.PropertyType); |
||||
if (c.CanConvertFrom(typeof(string)) && c.CanConvertTo(typeof(string))) { |
||||
try { |
||||
writer.WriteElementString(info.Name, c.ConvertToInvariantString(val)); |
||||
} catch (Exception ex) { |
||||
writer.WriteComment(ex.ToString()); |
||||
} |
||||
} else if (info.PropertyType == typeof(Type)) { |
||||
writer.WriteElementString(info.Name, ((Type)val).AssemblyQualifiedName); |
||||
} else { |
||||
// System.Diagnostics.Trace.WriteLine("Serialize Pagelayout");
|
||||
// writer.WriteStartElement(info.Name);
|
||||
// Save(val, writer);
|
||||
// writer.WriteEndElement();
|
||||
} |
||||
} |
||||
} |
||||
writer.WriteEndElement(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,246 @@
@@ -0,0 +1,246 @@
|
||||
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.ComponentModel; |
||||
using System.Diagnostics; |
||||
using System.Reflection; |
||||
using System.Xml; |
||||
using ICSharpCode.Reporting.Xml; |
||||
|
||||
|
||||
namespace ICSharpCode.Reporting.Addin.XML |
||||
{ |
||||
|
||||
/// <summary>
|
||||
/// See http://www.codeproject.com/dotnet/MycroXaml.asp
|
||||
/// </summary>
|
||||
///
|
||||
public abstract class ReportDefinitionParser |
||||
{ |
||||
public object Load(XmlElement element,object obj) |
||||
{ |
||||
return ProcessNode(element, obj); |
||||
} |
||||
|
||||
protected abstract Type GetTypeByName(string ns, string name); |
||||
|
||||
|
||||
protected object ProcessNode(XmlNode node, object parent) |
||||
{ |
||||
object ret=null; |
||||
if (node is XmlElement) |
||||
{ |
||||
// instantiate the class
|
||||
string ns=node.Prefix; |
||||
string cname=node.LocalName; |
||||
|
||||
Type t=GetTypeByName(ns, cname); |
||||
|
||||
if (t == null) { |
||||
t = GetTypeByName (ns,"ErrorItem"); |
||||
} |
||||
Trace.Assert(t != null, "Type "+cname+" could not be determined."); |
||||
// Debug.WriteLine("Looking for " + cname + " and got " + t.FullName);
|
||||
// Console.WriteLine("ReportDefinitionParser - Looking for " + cname + " and got " + t.FullName);
|
||||
try |
||||
{ |
||||
ret=Activator.CreateInstance(t); |
||||
} |
||||
catch(Exception e) |
||||
{ |
||||
Trace.Fail("Type "+cname+" could not be instantiated:\r\n"+e.Message); |
||||
} |
||||
|
||||
// support the ISupportInitialize interface
|
||||
if (ret is ISupportInitialize) { |
||||
((ISupportInitialize)ret).BeginInit(); |
||||
} |
||||
|
||||
// If the instance implements the IMicroXaml interface, then it may need
|
||||
// access to the parser.
|
||||
if (ret is IMycroXaml) { |
||||
((IMycroXaml)ret).Initialize(parent); |
||||
} |
||||
|
||||
// implements the class-property-class model
|
||||
ProcessAttributes(node, ret, t); |
||||
ProcessChildProperties(node, ret); |
||||
|
||||
// support the ISupportInitialize interface
|
||||
if (ret is ISupportInitialize) { |
||||
((ISupportInitialize)ret).EndInit(); |
||||
} |
||||
|
||||
// If the instance implements the IMicroXaml interface, then it has the option
|
||||
// to return an object that replaces the instance created by the parser.
|
||||
if (ret is IMycroXaml) { |
||||
ret=((IMycroXaml)ret).ReturnedObject; |
||||
} |
||||
} |
||||
return ret; |
||||
} |
||||
|
||||
protected void ProcessChildProperties(XmlNode node, object parent) |
||||
{ |
||||
Type t=parent.GetType(); |
||||
|
||||
// children of a class must always be properties
|
||||
foreach(XmlNode child in node.ChildNodes) |
||||
{ |
||||
if (child is XmlElement) |
||||
{ |
||||
string pname=child.LocalName; |
||||
//HACK we get a 'Items' Element and should set it to property 'Controls'
|
||||
if (String.Equals(pname,"Items")) { |
||||
pname = "Controls"; |
||||
} |
||||
PropertyInfo pi=t.GetProperty(pname); |
||||
|
||||
if (pi==null) |
||||
{ |
||||
// Special case--we're going to assume that the child is a class instance
|
||||
// not associated with the parent object
|
||||
// Trace.Fail("Unsupported property: "+pname);
|
||||
System.Console.WriteLine("Unsupported property: "+pname); |
||||
continue; |
||||
} |
||||
|
||||
// a property can only have one child node unless it's a collection
|
||||
foreach(XmlNode grandChild in child.ChildNodes) |
||||
{ |
||||
// System.Console.Write("grandchild {0}",grandChild.Value);
|
||||
if (grandChild is XmlText) { |
||||
SetPropertyToString(parent, pi, child.InnerText); |
||||
break; |
||||
} |
||||
else if (grandChild is XmlElement) |
||||
{ |
||||
object propObject=pi.GetValue(parent, null); |
||||
object obj=ProcessNode(grandChild, propObject); |
||||
System.Windows.Forms.Control parentControl = parent as System.Windows.Forms.Control; |
||||
System.Windows.Forms.Control childControl = obj as System.Windows.Forms.Control; |
||||
// we have the Items Section
|
||||
if ((parentControl != null) && (childControl != null)){ |
||||
parentControl.Controls.Add(childControl); |
||||
} |
||||
|
||||
// A null return is valid in cases where a class implementing the IMicroXaml interface
|
||||
// might want to take care of managing the instance it creates itself. See DataBinding
|
||||
else if (obj != null) |
||||
{ |
||||
|
||||
// support for ICollection objects
|
||||
if (propObject is ICollection) |
||||
{ |
||||
MethodInfo mi=t.GetMethod("Add", new Type[] {obj.GetType()}); |
||||
if (mi != null) |
||||
{ |
||||
try |
||||
{ |
||||
mi.Invoke(obj, new object[] {obj}); |
||||
} |
||||
catch(Exception e) |
||||
{ |
||||
Trace.Fail("Adding to collection failed:\r\n"+e.Message); |
||||
} |
||||
} |
||||
else if (propObject is IList) |
||||
{ |
||||
try |
||||
{ |
||||
((IList)propObject).Add(obj); |
||||
} |
||||
catch(Exception e) |
||||
{ |
||||
Trace.Fail("List/Collection add failed:\r\n"+e.Message); |
||||
} |
||||
} |
||||
} |
||||
else if (!pi.CanWrite) { |
||||
Trace.Fail("Unsupported read-only property: "+pname); |
||||
} |
||||
else |
||||
{ |
||||
// direct assignment if not a collection
|
||||
try |
||||
{ |
||||
pi.SetValue(parent, obj, null); |
||||
} |
||||
catch(Exception e) |
||||
{ |
||||
Trace.Fail("Property setter for "+pname+" failed:\r\n"+e.Message); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected void ProcessAttributes(XmlNode node, object ret, Type type) |
||||
{ |
||||
// process attributes
|
||||
foreach(XmlAttribute attr in node.Attributes) |
||||
{ |
||||
string pname=attr.Name; |
||||
string pvalue=attr.Value; |
||||
|
||||
// it's either a property or an event
|
||||
PropertyInfo pi=type.GetProperty(pname); |
||||
|
||||
if (pi != null) |
||||
{ |
||||
// it's a property!
|
||||
|
||||
SetPropertyToString(ret, pi, pvalue); |
||||
} |
||||
else |
||||
{ |
||||
// who knows what it is???
|
||||
Trace.Fail("Failed acquiring property information for "+pname); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void SetPropertyToString(object obj, PropertyInfo pi, string value) |
||||
{ |
||||
// it's string, so use a type converter.
|
||||
TypeConverter tc=TypeDescriptor.GetConverter(pi.PropertyType); |
||||
try |
||||
{ |
||||
if (tc.CanConvertFrom(typeof(string))) |
||||
{ |
||||
object val=tc.ConvertFromInvariantString(value); |
||||
// Console.WriteLine("\tRDP -> SetPropertyToString {0} - {1}",pi.Name,value.ToString());
|
||||
pi.SetValue(obj, val, null); |
||||
} else if (pi.PropertyType == typeof(Type)) { |
||||
pi.SetValue(obj, Type.GetType(value), null); |
||||
} |
||||
} |
||||
catch(Exception e) |
||||
{ |
||||
String s = String.Format("Property setter for {0} failed {1}\r\n",pi.Name, |
||||
e.Message); |
||||
System.Console.WriteLine("MycroParser : {0}",s); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 16.03.2014 |
||||
* Time: 18:28 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.XML |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ReportDesignerWriter.
|
||||
/// </summary>
|
||||
class ReportDesignerWriter:MycroWriter |
||||
{ |
||||
public ReportDesignerWriter() { |
||||
Console.WriteLine("ReportDesignerWriter"); |
||||
Console.WriteLine(); |
||||
} |
||||
protected override string GetTypeName(Type t) |
||||
{ |
||||
if (t.BaseType != null && t.BaseType.Name.StartsWith("Base",StringComparison.InvariantCultureIgnoreCase)) { |
||||
// return t.BaseType.Name;
|
||||
} |
||||
return t.Name; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 16.03.2014 |
||||
* Time: 18:25 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.IO; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.XML |
||||
{ |
||||
static class XmlHelper |
||||
{ |
||||
public static XmlTextWriter CreatePropperWriter (StringWriter writer) |
||||
{ |
||||
var xml = new XmlTextWriter(writer); |
||||
xml.Formatting = Formatting.Indented; |
||||
xml.Indentation = 4; |
||||
return xml; |
||||
} |
||||
|
||||
|
||||
public static void CreatePropperDocument (XmlTextWriter writer) |
||||
{ |
||||
writer.WriteStartDocument(); |
||||
writer.WriteStartElement("ReportModel"); |
||||
writer.WriteStartElement("ReportSettings"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,143 @@
@@ -0,0 +1,143 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.03.2014 |
||||
* Time: 20:35 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Drawing.Text; |
||||
|
||||
namespace ICSharpCode.Reporting.BaseClasses |
||||
{ |
||||
/// <summary>
|
||||
/// Description of TextDrawer.
|
||||
/// </summary>
|
||||
public sealed class TextDrawer |
||||
{ |
||||
|
||||
private TextDrawer() |
||||
{ |
||||
} |
||||
|
||||
|
||||
public static void DrawString(Graphics graphics,string text, |
||||
Font font,Brush brush, |
||||
RectangleF rectangle, |
||||
StringFormat format) |
||||
{ |
||||
if (graphics == null) { |
||||
throw new ArgumentNullException("graphics"); |
||||
} |
||||
|
||||
graphics.DrawString(text, |
||||
font, |
||||
brush, |
||||
rectangle, |
||||
format); |
||||
} |
||||
|
||||
|
||||
public static void DrawString (Graphics graphics,string text) |
||||
|
||||
{ |
||||
if (graphics == null) { |
||||
throw new ArgumentNullException("graphics"); |
||||
} |
||||
// if (decorator == null) {
|
||||
// throw new ArgumentNullException("decorator");
|
||||
// }
|
||||
|
||||
// StringFormat stringFormat = BuildStringFormat(decorator.StringTrimming,decorator.ContentAlignment);
|
||||
//
|
||||
// if (decorator.RightToLeft ==System.Windows.Forms.RightToLeft.Yes) {
|
||||
// stringFormat.FormatFlags = stringFormat.FormatFlags | StringFormatFlags.DirectionRightToLeft;
|
||||
// }
|
||||
|
||||
var formattedString = text; |
||||
// if (! String.IsNullOrEmpty(decorator.FormatString)) {
|
||||
// formattedString = StandardFormatter.FormatOutput(text,decorator.FormatString,decorator.DataType,String.Empty);
|
||||
// }
|
||||
|
||||
graphics.TextRenderingHint = TextRenderingHint.AntiAlias; |
||||
|
||||
// graphics.DrawString (formattedString,decorator.Font,
|
||||
// new SolidBrush(decorator.ForeColor),
|
||||
// new Rectangle(decorator.Location.X,
|
||||
// decorator.Location.Y,
|
||||
// decorator.Size.Width,
|
||||
// decorator.Size.Height),
|
||||
// stringFormat);
|
||||
} |
||||
|
||||
|
||||
public static StringFormat BuildStringFormat(StringTrimming stringTrimming,ContentAlignment alignment) |
||||
{ |
||||
StringFormat format = StringFormat.GenericTypographic; |
||||
format.Trimming = stringTrimming; |
||||
format.FormatFlags = StringFormatFlags.LineLimit; |
||||
|
||||
if (alignment <= ContentAlignment.MiddleCenter){ |
||||
switch (alignment){ |
||||
case ContentAlignment.TopLeft:{ |
||||
format.Alignment = StringAlignment.Near; |
||||
format.LineAlignment = StringAlignment.Near; |
||||
return format; |
||||
} |
||||
case ContentAlignment.TopCenter:{ |
||||
format.Alignment = StringAlignment.Center; |
||||
format.LineAlignment = StringAlignment.Near; |
||||
return format; |
||||
} |
||||
case (ContentAlignment.TopCenter | ContentAlignment.TopLeft):{ |
||||
return format; |
||||
} |
||||
case ContentAlignment.TopRight:{ |
||||
format.Alignment = StringAlignment.Far; |
||||
format.LineAlignment = StringAlignment.Near; |
||||
return format; |
||||
} |
||||
case ContentAlignment.MiddleLeft:{ |
||||
format.Alignment = StringAlignment.Near; |
||||
format.LineAlignment = StringAlignment.Center; |
||||
return format; |
||||
} |
||||
case ContentAlignment.MiddleCenter:{ |
||||
format.Alignment = StringAlignment.Center; |
||||
format.LineAlignment = StringAlignment.Center; |
||||
return format; |
||||
} |
||||
} |
||||
return format; |
||||
} |
||||
if (alignment <= ContentAlignment.BottomLeft){ |
||||
if (alignment == ContentAlignment.MiddleRight){ |
||||
format.Alignment = StringAlignment.Far; |
||||
format.LineAlignment = StringAlignment.Center; |
||||
return format; |
||||
} |
||||
if (alignment != ContentAlignment.BottomLeft){ |
||||
return format; |
||||
} |
||||
} |
||||
else{ |
||||
if (alignment != ContentAlignment.BottomCenter){ |
||||
if (alignment == ContentAlignment.BottomRight) |
||||
{ |
||||
format.Alignment = StringAlignment.Far; |
||||
format.LineAlignment = StringAlignment.Far; |
||||
} |
||||
return format; |
||||
} |
||||
format.Alignment = StringAlignment.Center; |
||||
format.LineAlignment = StringAlignment.Far; |
||||
return format; |
||||
} |
||||
format.Alignment = StringAlignment.Near; |
||||
format.LineAlignment = StringAlignment.Far; |
||||
return format; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 16.03.2014 |
||||
* Time: 17:24 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using ICSharpCode.Reporting.Globals; |
||||
using ICSharpCode.Reporting.Items; |
||||
|
||||
namespace ICSharpCode.Reporting.Factories |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ReportModelFactory.
|
||||
/// </summary>
|
||||
public static class ReportModelFactory |
||||
{ |
||||
public static ReportModel Create() |
||||
{ |
||||
ReportModel m = new ReportModel(); |
||||
foreach (GlobalEnums.ReportSection sec in Enum.GetValues(typeof(GlobalEnums.ReportSection))) { |
||||
m.SectionCollection.Add (SectionFactory.Create(sec.ToString())); |
||||
} |
||||
return m; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 16.03.2014 |
||||
* Time: 17:06 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using ICSharpCode.Reporting.Items; |
||||
|
||||
namespace ICSharpCode.Reporting.Factories |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SectionFactory.
|
||||
/// </summary>
|
||||
sealed class SectionFactory |
||||
{ |
||||
private SectionFactory () |
||||
{ |
||||
|
||||
} |
||||
public static BaseSection Create(string name) { |
||||
if (name == null) |
||||
throw new ArgumentNullException("name"); |
||||
|
||||
return new BaseSection(name); |
||||
} |
||||
|
||||
} |
||||
} |
||||
Loading…
Reference in new issue