31 changed files with 3020 additions and 19 deletions
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
/* |
||||
* 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; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignableItems |
||||
{ |
||||
/// <summary>
|
||||
/// Description of AbstractItem.
|
||||
/// </summary>
|
||||
// [TypeDescriptionProvider(typeof(AbstractItemTypeProvider))]
|
||||
public abstract class AbstractItem:System.Windows.Forms.Control |
||||
{ |
||||
private Color frameColor = Color.Black; |
||||
|
||||
|
||||
protected AbstractItem() |
||||
{ |
||||
InitializeComponent(); |
||||
// TypeDescriptor.AddProvider(new AbstractItemTypeProvider(), typeof(AbstractItem));
|
||||
// VisibleInReport = true;
|
||||
} |
||||
|
||||
|
||||
protected void DrawControl (Graphics graphics,Rectangle borderRectangle) |
||||
{ |
||||
if (this.DrawBorder == true) { |
||||
graphics.DrawRectangle(new Pen(this.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 , |
||||
this.ClientRectangle.Top , |
||||
this.ClientRectangle.Width -1, |
||||
this.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;} |
||||
|
||||
// public bool VisibleInReport {get;set;}
|
||||
|
||||
#endregion
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute()] |
||||
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) |
||||
{ |
||||
base.OnPaint(e); |
||||
} |
||||
|
||||
public abstract void Draw(Graphics graphics); |
||||
|
||||
private void InitializeComponent() |
||||
{ |
||||
this.SuspendLayout(); |
||||
this.ResumeLayout(false); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
/* |
||||
* 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; |
||||
|
||||
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() |
||||
{ |
||||
base.FrameColor = Color.Black; |
||||
// TypeDescriptor.AddProvider(new SectionItemTypeProvider(), typeof(BaseSection));
|
||||
} |
||||
|
||||
|
||||
[System.ComponentModel.EditorBrowsableAttribute()] |
||||
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) |
||||
{ |
||||
base.OnPaint(e); |
||||
Draw(e.Graphics); |
||||
} |
||||
|
||||
|
||||
public override void Draw(Graphics graphics) |
||||
{ |
||||
base.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,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,373 @@
@@ -0,0 +1,373 @@
|
||||
// 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.Items; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ReportRootDesigner.
|
||||
/// </summary>
|
||||
|
||||
public class ReportRootDesigner: DocumentDesigner |
||||
{ |
||||
ICollection currentSelection; |
||||
private IDesignerHost host; |
||||
private MenuCommandService menuCommandService; |
||||
private IToolboxService toolboxService; |
||||
private ISelectionService selectionService; |
||||
private IComponentChangeService componentChangeService; |
||||
private List<BaseSection> sections; |
||||
private ReportSettings reportSettings; |
||||
private RootReportModel rootReportModel; |
||||
|
||||
public ReportRootDesigner() |
||||
{ |
||||
System.Console.WriteLine("Createb RootDesigner"); |
||||
} |
||||
|
||||
|
||||
private void ShowMessage(Exception e) |
||||
{ |
||||
base.DisplayError(e); |
||||
var uiService = (IUIService)host.GetService(typeof(IUIService)); |
||||
if (uiService != null) { |
||||
uiService.ShowError(e); |
||||
} |
||||
} |
||||
|
||||
// private new void DisplayError(Exception ex)
|
||||
// {
|
||||
// MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Fehler im Designer", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
// }
|
||||
|
||||
|
||||
private void InitializeGUI() |
||||
{ |
||||
reportSettings = host.Container.Components[1] as ReportSettings; |
||||
InitializeRootReportModel(); |
||||
} |
||||
|
||||
|
||||
private void InitializeRootReportModel () |
||||
{ |
||||
rootReportModel = host.Container.Components[0] as RootReportModel; |
||||
rootReportModel.PageMargin = CalculateMargins(); |
||||
rootReportModel.Page = new Rectangle(new Point(0,0),this.reportSettings.PageSize); |
||||
rootReportModel.Landscape = this.reportSettings.Landscape; |
||||
rootReportModel.Invalidate(); |
||||
} |
||||
|
||||
|
||||
private Margins CalculateMargins () |
||||
{ |
||||
return new Margins(this.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).
|
||||
//
|
||||
|
||||
this.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) |
||||
{ |
||||
/* |
||||
DesignerHelper.RemoveProperties(properties); |
||||
string [] s = new string[]{"Visible","BackColor","Text","MaximumSize","MinimumSize","Size", |
||||
"AutoScaleDimensions","DataBindings"}; |
||||
DesignerHelper.Remove(properties,s); |
||||
base.PostFilterProperties(properties); |
||||
*/ |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Events
|
||||
|
||||
private void OnSectionSizeChanged (object sender, EventArgs e) |
||||
{ |
||||
this.RecalculateSections(); |
||||
} |
||||
|
||||
|
||||
private void RecalculateSections() |
||||
{ |
||||
int locY = 50; |
||||
if (this.reportSettings == null) { |
||||
reportSettings = host.Container.Components[1] as ReportSettings; |
||||
} |
||||
|
||||
foreach (BaseSection s in sections) |
||||
{ |
||||
// s.Location = new Point(this.reportSettings.LeftMargin,locY);
|
||||
// locY = locY + s.Size.Height + GlobalsDesigner.GabBetweenSection;
|
||||
} |
||||
this.Control.Invalidate(); |
||||
} |
||||
|
||||
|
||||
|
||||
private void OnLoadComplete(object sender, EventArgs e) |
||||
{ |
||||
var host = (IDesignerHost)sender; |
||||
host.LoadComplete -= new EventHandler(this.OnLoadComplete); |
||||
InitializeGUI(); |
||||
} |
||||
|
||||
|
||||
private void OnComponentAdded(object sender, ComponentEventArgs ce) |
||||
{ |
||||
BaseSection section = ce.Component as BaseSection; |
||||
|
||||
if (section != null) { |
||||
this.sections.Add(section); |
||||
// section.SizeChanged += new EventHandler( OnSectionSizeChanged);
|
||||
// foreach (Control cc in section.Controls) {
|
||||
// AddToHost(cc);
|
||||
// this.host.Container.Add(cc);
|
||||
// }
|
||||
//
|
||||
// this.Control.Controls.Add(section);
|
||||
RecalculateSections(); |
||||
} |
||||
} |
||||
|
||||
|
||||
private void AddToHost (Control ctrl) |
||||
{ |
||||
if (ctrl.Controls.Count > 0) { |
||||
foreach (Control c1 in ctrl.Controls) { |
||||
AddToHost (c1); |
||||
} |
||||
} |
||||
this.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(); |
||||
} |
||||
} |
||||
|
||||
|
||||
private void OnComponentChanging(object sender, ComponentChangingEventArgs ce) |
||||
{ |
||||
System.Console.WriteLine("RootDesigner:OnComponentChanging"); |
||||
// Host.CreateTransaction();
|
||||
} |
||||
|
||||
|
||||
private 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,112 @@
@@ -0,0 +1,112 @@
|
||||
/* |
||||
* 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.Items; |
||||
using ICSharpCode.Reporting.Addin.Globals; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of RootReportModel.
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
|
||||
public class RootReportModel:RootDesignedComponent |
||||
{ |
||||
|
||||
bool showDebugFrame; |
||||
|
||||
public RootReportModel(){ |
||||
Console.WriteLine("create RootReportModel"); |
||||
} |
||||
|
||||
|
||||
[EditorBrowsableAttribute()] |
||||
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) |
||||
{ |
||||
base.OnPaint(pea); |
||||
if (this.showDebugFrame) { |
||||
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); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void Toggle () |
||||
{ |
||||
showDebugFrame = !this.showDebugFrame; |
||||
Invalidate(true); |
||||
} |
||||
|
||||
private void PrintMargin( Graphics graphics) |
||||
{ |
||||
string s = String.Format(System.Globalization.CultureInfo.CurrentCulture, |
||||
"[Size : {0}] [Landscape : {1}] [Bounds : {2}]", |
||||
this.Page,this.Landscape,this.PageMargin); |
||||
using (Font font = DesignerGlobals.DesignerFont){ |
||||
SizeF size = graphics.MeasureString(s,font); |
||||
graphics.DrawString(s,font, |
||||
new SolidBrush(Color.LightGray), |
||||
new Rectangle(this.PageMargin.Left + 100, |
||||
this.PageMargin.Top - (int)font.GetHeight() - 3, |
||||
(int)size.Width, |
||||
(int)size.Height)); |
||||
|
||||
var rectangle = new Rectangle(this.PageMargin.Left - 2,this.PageMargin.Top - 2, |
||||
this.Page.Width - this.PageMargin.Left - this.PageMargin.Right + 2, |
||||
this.Size.Height - this.PageMargin.Top - this.PageMargin.Bottom + 2); |
||||
graphics.DrawRectangle(new Pen(Color.LightGray,1),rectangle); |
||||
} |
||||
} |
||||
|
||||
|
||||
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,101 @@
@@ -0,0 +1,101 @@
|
||||
/* |
||||
* 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 OnPaintAdornments(PaintEventArgs pe) |
||||
{ |
||||
base.OnPaintAdornments(pe); |
||||
} |
||||
|
||||
|
||||
|
||||
protected override void OnDragDrop(DragEventArgs de) |
||||
{ |
||||
base.OnDragDrop(de); |
||||
IToolboxService it = (IToolboxService)this.GetService(typeof(IToolboxService)); |
||||
it.SetSelectedToolboxItem(null); |
||||
} |
||||
|
||||
|
||||
public override bool CanBeParentedTo(System.ComponentModel.Design.IDesigner parentDesigner) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
|
||||
protected override void PostFilterProperties(System.Collections.IDictionary properties) |
||||
{ |
||||
// DesignerHelper.RemoveProperties(properties);
|
||||
base.PostFilterProperties(properties); |
||||
} |
||||
|
||||
|
||||
private void OnSelectionChanged(object sender, EventArgs e) |
||||
{ |
||||
Control.Invalidate( ); |
||||
} |
||||
|
||||
|
||||
private 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,70 @@
@@ -0,0 +1,70 @@
|
||||
/* |
||||
* 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 ICSharpCode.Core; |
||||
using ICSharpCode.Reporting.Addin.Views; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignerBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Description of DesignerGenerator.
|
||||
/// </summary>
|
||||
public 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<ICSharpCode.SharpDevelop.Workbench.OpenedFile> GetSourceFiles(out ICSharpCode.SharpDevelop.Workbench.OpenedFile designerCodeFile) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void MergeFormChanges(System.CodeDom.CodeCompileUnit unit) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool InsertComponentEvent(System.ComponentModel.IComponent component, System.ComponentModel.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(); |
||||
} |
||||
} |
||||
|
||||
public DesignerView ViewContent { |
||||
get {return viewContent;} |
||||
|
||||
} |
||||
|
||||
#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,100 @@
@@ -0,0 +1,100 @@
|
||||
// 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"); |
||||
} |
||||
Console.WriteLine("---------InternalReportLoader------------"); |
||||
this.host = host; |
||||
this.generator = generator; |
||||
this.stream = stream; |
||||
} |
||||
|
||||
public void LoadOrCreateReport() |
||||
{ |
||||
Console.WriteLine("LoadOrCreateReport()"); |
||||
Application.UseWaitCursor = true; |
||||
try { |
||||
var component = this.host.CreateComponent(typeof(RootReportModel),"RootReportModel"); |
||||
var rootControl = component as RootReportModel; |
||||
UpdateStatusbar(); |
||||
ReportModel = CreateNamedSurface(); |
||||
rootControl.Size = this.ReportModel.ReportSettings.PageSize; |
||||
|
||||
} catch (Exception e) { |
||||
MessageService.ShowException(e,"LoadOrCreateReport"); |
||||
} finally { |
||||
Application.UseWaitCursor = false; |
||||
} |
||||
} |
||||
|
||||
|
||||
private void UpdateStatusbar () |
||||
{ |
||||
string message; |
||||
if (this.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(host,stream); |
||||
return deserializer.LoadObjectFromFileDefinition(); |
||||
} |
||||
|
||||
|
||||
public ReportModel ReportModel {get; private set;} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,157 @@
@@ -0,0 +1,157 @@
|
||||
// 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.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Reporting.Items; |
||||
using ICSharpCode.Reporting.Xml; |
||||
using ICSharpCode.SharpDevelop.Workbench; |
||||
using ICSharpCode.Reporting.Addin.XML; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignerBinding |
||||
{ |
||||
class ReportDefinitionDeserializer : ReportDefinitionParser |
||||
{ |
||||
IDesignerHost host; |
||||
ICSharpCode.Reporting.Addin.DesignableItems.ReportSettings reportSettings; |
||||
Stream stream; |
||||
|
||||
#region Constructor
|
||||
|
||||
public ReportDefinitionDeserializer(IDesignerHost host,Stream stream) |
||||
{ |
||||
if (host == null) { |
||||
throw new ArgumentNullException("host"); |
||||
} |
||||
if (stream == null) { |
||||
throw new ArgumentNullException("stream"); |
||||
} |
||||
Console.WriteLine("ReportDefinitionDeserializer"); |
||||
this.host = host; |
||||
this.stream = stream; |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
public ReportModel LoadObjectFromFileDefinition() |
||||
{ |
||||
Console.WriteLine("LoadObjectFromFileDefinition()"); |
||||
var xmlDocument = new XmlDocument(); |
||||
xmlDocument.Load(this.stream); |
||||
if (xmlDocument.FirstChild.NodeType == XmlNodeType.XmlDeclaration) |
||||
{ |
||||
XmlDeclaration xmlDeclaration = (XmlDeclaration)xmlDocument.FirstChild; |
||||
xmlDeclaration.Encoding = "utf-8"; |
||||
} |
||||
return LoadObjectFromXmlDocument(xmlDocument.DocumentElement); |
||||
} |
||||
|
||||
|
||||
private ReportModel LoadObjectFromXmlDocument(XmlElement elem) |
||||
{ |
||||
Console.WriteLine("LoadObjectFromXmlDocumen)"); |
||||
//ReportSettings
|
||||
var file =(OpenedFile) host.GetService(typeof(OpenedFile)); |
||||
|
||||
XmlNodeList nodes = elem.FirstChild.ChildNodes; |
||||
var rse = (XmlElement) nodes[0]; |
||||
// var reportModel = new ReportModel();
|
||||
// manipulate reportSettings if Filename differs
|
||||
var modelLoader = new ModelLoader(); |
||||
this.reportSettings = modelLoader.Load(rse) as ICSharpCode.Reporting.Addin.DesignableItems.ReportSettings; |
||||
|
||||
if (string.Compare(this.reportSettings.FileName, file.FileName, StringComparison.CurrentCulture) != 0) { |
||||
System.Diagnostics.Trace.WriteLine("LoadObjectFromXmlDocument - filename changed" ); |
||||
this.reportSettings.FileName = file.FileName; |
||||
} |
||||
var reportModel = new ReportModel(); |
||||
// reportModel.ReportSettings = this.reportSettings;
|
||||
|
||||
host.Container.Add(this.reportSettings); |
||||
|
||||
//Move to SectionCollection
|
||||
XmlNodeList sectionList = elem.LastChild.ChildNodes; |
||||
|
||||
foreach (XmlNode sectionNode in sectionList) { |
||||
try { |
||||
object o = this.Load(sectionNode as XmlElement,null); |
||||
BaseSection section = o as BaseSection; |
||||
// ConvertAbsolut2RelativePath(section.Controls,this.reportSettings.FileName);
|
||||
// ConvertAbsolut2RelativePath(section,this.reportSettings.FileName);
|
||||
// host.Container.Add(section);
|
||||
} catch (Exception e) { |
||||
MessageService.ShowException(e); |
||||
} |
||||
} |
||||
return reportModel; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
private static void ConvertAbsolut2RelativePath (System.Windows.Forms.Control.ControlCollection controls, string fileName) |
||||
{ |
||||
/* |
||||
foreach (Control control in controls) { |
||||
|
||||
if (control.Controls.Count > 0) { |
||||
ConvertAbsolut2RelativePath(control.Controls,fileName); |
||||
} |
||||
|
||||
BaseImageItem baseImageItem = control as BaseImageItem; |
||||
if (baseImageItem != null) { |
||||
baseImageItem.ReportFileName = fileName; |
||||
|
||||
if (Path.IsPathRooted(baseImageItem.ImageFileName)) { |
||||
Console.WriteLine("Absolut2RelativePath"); |
||||
Console.WriteLine("Image Filename {0}",fileName); |
||||
Console.WriteLine("Image Filename {0}",baseImageItem.ImageFileName); |
||||
string d = ICSharpCode.Reports.Core.Globals.FileUtility.GetRelativePath( |
||||
Path.GetDirectoryName(fileName), |
||||
Path.GetDirectoryName(baseImageItem.ImageFileName)); |
||||
|
||||
baseImageItem.RelativeFileName = d + Path.DirectorySeparatorChar + Path.GetFileName(baseImageItem.ImageFileName); |
||||
Console.WriteLine("Rel Filename {0}",baseImageItem.RelativeFileName); |
||||
} |
||||
} |
||||
} |
||||
*/ |
||||
} |
||||
|
||||
|
||||
protected override Type GetTypeByName(string ns, string name) |
||||
{ |
||||
Type t = typeof(BaseSection).Assembly.GetType(typeof(BaseSection).Namespace + "." + name); |
||||
return t; |
||||
} |
||||
|
||||
/* |
||||
#region Properties
|
||||
|
||||
public string ReportName { |
||||
get { return this.reportSettings.ReportName; } |
||||
} |
||||
|
||||
#endregion
|
||||
*/ |
||||
} |
||||
} |
@ -0,0 +1,157 @@
@@ -0,0 +1,157 @@
|
||||
/* |
||||
* 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.Collections.Generic; |
||||
using System.ComponentModel.Design.Serialization; |
||||
using System.IO; |
||||
using System.Xml; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Reporting.Items; |
||||
using ICSharpCode.Reporting.Xml; |
||||
using ICSharpCode.Reporting.Addin.Services; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.DesignerBinding |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ReportDesignerLoader.
|
||||
/// </summary>
|
||||
class ReportDesignerLoader: BasicDesignerLoader |
||||
{ |
||||
IDesignerLoaderHost host; |
||||
IDesignerGenerator generator; |
||||
ReportModel reportModel; |
||||
Stream stream; |
||||
|
||||
#region Constructors
|
||||
|
||||
public ReportDesignerLoader(IDesignerGenerator generator, Stream stream) |
||||
{ |
||||
Console.WriteLine("ReportDesignerLoader:Ctor"); |
||||
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) |
||||
{ |
||||
Console.WriteLine("PerformLoad -> no Code"); |
||||
var internalLoader = new InternalReportLoader(host,generator, stream); |
||||
internalLoader.LoadOrCreateReport(); |
||||
reportModel = internalLoader.ReportModel; |
||||
} |
||||
|
||||
|
||||
protected override void PerformFlush(IDesignerSerializationManager designerSerializationManager) |
||||
{ |
||||
LoggingService.Info("ReportDesignerLoader:PerformFlush"); |
||||
generator.MergeFormChanges((System.CodeDom.CodeCompileUnit)null); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Reportmodel
|
||||
|
||||
public ReportModel ReportModel { |
||||
get { return reportModel; } |
||||
} |
||||
|
||||
public static ReportModel CreateRenderableModel() |
||||
{ |
||||
Console.WriteLine("ReportDesignerLoader:CreateRenderableModel"); |
||||
/* |
||||
ReportModel m = new ReportModel(); |
||||
generator.MergeFormChanges((System.CodeDom.CodeCompileUnit)null); |
||||
XmlDocument doc = new XmlDocument(); |
||||
doc.LoadXml(generator.ViewContent.ReportFileContent); |
||||
ReportLoader rl = new ReportLoader(); |
||||
object root = rl.Load(doc.DocumentElement); |
||||
m = root as ReportModel; |
||||
|
||||
m.ReportSettings.FileName = generator.ViewContent.PrimaryFileName; |
||||
FilePathConverter.AdjustReportName(m); |
||||
return m; |
||||
*/ |
||||
return null; |
||||
} |
||||
|
||||
public XmlDocument CreateXmlModel() |
||||
{ |
||||
Console.WriteLine("ReportDesignerLoader:CreateXmlModel"); |
||||
/* |
||||
ReportModel m = new ReportModel(); |
||||
generator.MergeFormChanges((System.CodeDom.CodeCompileUnit)null); |
||||
XmlDocument xmlDocument = new XmlDocument(); |
||||
xmlDocument.LoadXml(generator.ViewContent.ReportFileContent); |
||||
return xmlDocument; |
||||
*/ |
||||
return null; |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Load Report from File
|
||||
/// </summary>
|
||||
/// <param name="baseType"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public class aaReportLoader : ModelLoader |
||||
{ |
||||
static Dictionary<Type, Type> baseToReport; |
||||
|
||||
public static Type GetReportType(Type baseType) |
||||
{ |
||||
Console.WriteLine("ReportLoader:GetReportType"); |
||||
if (baseType == null) return null; |
||||
if (baseToReport == null) { |
||||
baseToReport = new Dictionary<Type, Type>(); |
||||
foreach (Type t in typeof(BaseSection).Assembly.GetTypes()) { |
||||
|
||||
if (t.BaseType != null && t.BaseType.Name.StartsWith("Base", |
||||
StringComparison.InvariantCulture)) { |
||||
baseToReport[t.BaseType] = t; |
||||
} |
||||
} |
||||
} |
||||
Type r; |
||||
baseToReport.TryGetValue(baseType, out r); |
||||
return r ?? baseType; |
||||
} |
||||
|
||||
|
||||
protected override Type GetTypeByName(string ns, string name) |
||||
{ |
||||
return GetReportType(base.GetTypeByName(ns, name)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
/* |
||||
* 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>
|
||||
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;} |
||||
} |
||||
} |
||||
} |
@ -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,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,211 @@
@@ -0,0 +1,211 @@
|
||||
/* |
||||
* 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.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.DesignerBinding; |
||||
using ICSharpCode.Reporting.Addin.Services; |
||||
|
||||
namespace ICSharpCode.Reporting.Addin.Views |
||||
{ |
||||
/// <summary>
|
||||
/// Description of the view content
|
||||
/// </summary>
|
||||
public class DesignerView : AbstractViewContent |
||||
{ |
||||
readonly IDesignerGenerator generator; |
||||
bool unloading; |
||||
Panel panel; |
||||
ReportDesignerLoader loader; |
||||
DefaultServiceContainer defaultServiceContainer; |
||||
DesignSurface designSurface; |
||||
|
||||
public DesignerView() |
||||
{ |
||||
} |
||||
|
||||
|
||||
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); |
||||
|
||||
} |
||||
|
||||
|
||||
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(System.ComponentModel.Design.IMenuCommandService), |
||||
new ICSharpCode.Reporting.Addin.Services.MenuCommandService(panel,this.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"); |
||||
|
||||
this.loader = new ReportDesignerLoader(generator,stream); |
||||
this.designSurface.BeginLoad(this.loader); |
||||
if (!designSurface.IsLoaded) { |
||||
// throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
|
||||
LoggingService.Error("designer not loaded"); |
||||
} |
||||
|
||||
LoggingService.Info("ReportDesigner LoadDesigner_End"); |
||||
} |
||||
|
||||
|
||||
Panel CreatePanel () |
||||
{ |
||||
var ctl = new Panel(); |
||||
ctl.Dock = DockStyle.Fill; |
||||
ctl.BackColor = System.Drawing.Color.LightBlue; |
||||
return ctl; |
||||
} |
||||
|
||||
|
||||
DefaultServiceContainer 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() |
||||
{ |
||||
designSurface.Loading += DesignerLoading; |
||||
designSurface.Loaded += DesignerLoaded; |
||||
designSurface.Flushed += DesignerFlushed; |
||||
designSurface.Unloading += DesingerUnloading; |
||||
} |
||||
|
||||
|
||||
static WindowsFormsDesignerOptionService CreateDesignerOptions() |
||||
{ |
||||
var designerOptionService = new System.Windows.Forms.Design.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 DesignerEvents
|
||||
|
||||
void DesignerLoading(object sender, EventArgs e) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: DesignerLoader loading..."); |
||||
this.unloading = false; |
||||
} |
||||
|
||||
|
||||
void DesignerLoaded(object sender, LoadedEventArgs e) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: DesignerLoaded..."); |
||||
} |
||||
|
||||
void DesignerFlushed(object sender, EventArgs e) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: DesignerFlushed"); |
||||
} |
||||
|
||||
|
||||
void DesingerUnloading(object sender, EventArgs e) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: DesignernUnloading..."); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region Design surface manager (static)
|
||||
|
||||
static readonly DesignSurfaceManager designSurfaceManager = new DesignSurfaceManager(); |
||||
|
||||
static DesignSurface CreateDesignSurface(IServiceProvider serviceProvider) |
||||
{ |
||||
return designSurfaceManager.CreateDesignSurface(serviceProvider); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region overrides
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the view
|
||||
/// </summary>
|
||||
public override object Control { |
||||
get {return panel;} |
||||
} |
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new DesignerView object
|
||||
/// </summary>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Loads a new file into MyView
|
||||
/// </summary>
|
||||
|
||||
public override void Load(OpenedFile file, System.IO.Stream stream) |
||||
{ |
||||
LoggingService.Debug("ReportDesigner: Load from: " + file.FileName); |
||||
base.Load(file, stream); |
||||
LoadDesigner(stream); |
||||
} |
||||
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up all used resources
|
||||
/// </summary>
|
||||
public override void Dispose() |
||||
{ |
||||
// TODO: Clean up resources in this method
|
||||
// Control.Dispose();
|
||||
base.Dispose(); |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
|
||||
} |
@ -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); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue