Browse Source

Cleanup Designer

reports
Peter Forstmeier 11 years ago
parent
commit
62cc51441c
  1. 32
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/AbstractDesigner.cs
  2. 69
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs
  3. 40
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs
  4. 23
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Views/DesignerView.cs

32
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/AbstractDesigner.cs

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
using System;
using System.ComponentModel.Design;
using System.Windows.Forms.Design;
using ICSharpCode.Reporting.Addin.DesignableItems;
namespace ICSharpCode.Reporting.Addin.Designer
{
@ -22,12 +23,43 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -22,12 +23,43 @@ namespace ICSharpCode.Reporting.Addin.Designer
{
base.Initialize(component);
SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
SelectionService.SelectionChanged += OnComponentSelected;
ComponentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
ComponentChangeService.ComponentRename += OnComponentRename;
}
void OnComponentSelected(object sender, EventArgs e)
{
Control.Invalidate();
}
void OnComponentRename(object sender, ComponentRenameEventArgs e)
{
if (e.Component == Component) {
if ((!String.IsNullOrEmpty(e.NewName)) && (e.NewName != Control.Name)) {
var c = Component as AbstractItem;;
c.Name = e.NewName;
Control.Invalidate();
}
}
}
protected ISelectionService SelectionService {get; private set;}
protected IComponentChangeService ComponentChangeService {get;private set;}
protected override void Dispose(bool disposing)
{
if (ComponentChangeService != null) {
ComponentChangeService.ComponentRename -= OnComponentRename;
}
if (SelectionService != null) {
SelectionService.SelectionChanged -= OnComponentSelected;
}
base.Dispose(disposing);
}
}
}

69
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs

@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
*/
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Reporting.Addin.DesignableItems;
@ -34,13 +33,9 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -34,13 +33,9 @@ namespace ICSharpCode.Reporting.Addin.Designer
}
base.Initialize(component);
baseLine = (BaseLineItem)component;
ComponentChangeService.ComponentChanging += OnComponentChanging;
ComponentChangeService.ComponentChanged += OnComponentChanged;
ComponentChangeService.ComponentRename += OnComponentRename;
SelectionService.SelectionChanged += OnSelectionChanged;
}
protected override void PostFilterProperties(System.Collections.IDictionary properties)
{
TypeProviderHelper.RemoveProperties(properties);
@ -48,41 +43,6 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -48,41 +43,6 @@ namespace ICSharpCode.Reporting.Addin.Designer
}
#region events
private void OnComponentChanging (object sender,ComponentChangingEventArgs e)
{
// System.Console.WriteLine("changing");
// System.Console.WriteLine("{0}",this.baseLine.ClientRectangle);
Control.Invalidate( );
}
void OnComponentChanged(object sender,ComponentChangedEventArgs e)
{
Console.WriteLine("{0}",this.baseLine.ClientRectangle);
Control.Invalidate( );
}
void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Invalidate();
Control.Invalidate( );
}
}
void OnSelectionChanged(object sender, EventArgs e)
{
Control.Invalidate( );
}
#endregion
protected override void OnPaintAdornments(PaintEventArgs pe)
{
var label = Control as BaseLineItem;
@ -139,8 +99,8 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -139,8 +99,8 @@ namespace ICSharpCode.Reporting.Addin.Designer
{
System.Console.WriteLine("DragBegib");
Point p = this.baseLine.PointToClient(new Point(x, y));
overFromPoint = GetHandle(this.baseLine.FromPoint).Contains(p);
this.overToPoint = GetHandle(this.baseLine.ToPoint).Contains(p);
overFromPoint = GetHandle(baseLine.FromPoint).Contains(p);
this.overToPoint = GetHandle(baseLine.ToPoint).Contains(p);
if (overFromPoint || overToPoint )
{
dragging = true;
@ -166,10 +126,10 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -166,10 +126,10 @@ namespace ICSharpCode.Reporting.Addin.Designer
if (dragging)
{
Point p = this.baseLine.PointToClient(new Point(x, y));
if (this.overToPoint) {
this.baseLine.ToPoint = p;
if (overToPoint) {
baseLine.ToPoint = p;
} else {
this.baseLine.FromPoint = p;
baseLine.FromPoint = p;
}
// this.baseLine.Invalidate();
@ -210,7 +170,7 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -210,7 +170,7 @@ namespace ICSharpCode.Reporting.Addin.Designer
}
*/
dragging = false;
this.baseLine.Invalidate();
baseLine.Invalidate();
}
// Always call base class.
@ -221,20 +181,5 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -221,20 +181,5 @@ namespace ICSharpCode.Reporting.Addin.Designer
#endregion
protected override void Dispose(bool disposing)
{
if (ComponentChangeService != null) {
ComponentChangeService.ComponentChanging -= OnComponentChanging;
ComponentChangeService.ComponentChanged -= OnComponentChanged;
ComponentChangeService.ComponentRename -= OnComponentRename;
}
if (SelectionService != null) {
SelectionService.SelectionChanged -= OnSelectionChanged;
}
base.Dispose(disposing);
}
}
}

40
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs

@ -7,9 +7,6 @@ @@ -7,9 +7,6 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using ICSharpCode.Reporting.Addin.DesignableItems;
using ICSharpCode.Reporting.Addin.TypeProvider;
@ -21,16 +18,7 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -21,16 +18,7 @@ namespace ICSharpCode.Reporting.Addin.Designer
public class TextItemDesigner:AbstractDesigner
{
BaseTextItem ctrl;
public override void Initialize(IComponent component)
{
base.Initialize(component);
SelectionService.SelectionChanged += OnSelectionChanged;
ComponentChangeService.ComponentRename += OnComponentRename;
ctrl = (BaseTextItem) component;
}
protected override void PostFilterProperties(System.Collections.IDictionary properties)
{
TypeProviderHelper.RemoveProperties(properties);
@ -38,21 +26,6 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -38,21 +26,6 @@ namespace ICSharpCode.Reporting.Addin.Designer
}
void OnSelectionChanged(object sender, EventArgs e)
{
Control.Invalidate( );
}
void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == Component) {
Control.Name = e.NewName;
Control.Invalidate();
}
}
#region SmartTag
// public override DesignerActionListCollection ActionLists {
@ -100,16 +73,5 @@ namespace ICSharpCode.Reporting.Addin.Designer @@ -100,16 +73,5 @@ namespace ICSharpCode.Reporting.Addin.Designer
*/
#endregion
protected override void Dispose(bool disposing)
{
if (SelectionService != null) {
SelectionService.SelectionChanged -= OnSelectionChanged;
}
if (ComponentChangeService != null) {
ComponentChangeService.ComponentRename -= OnComponentRename;
}
base.Dispose(disposing);
}
}
}

23
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Views/DesignerView.cs

@ -382,15 +382,6 @@ namespace ICSharpCode.Reporting.Addin.Views @@ -382,15 +382,6 @@ namespace ICSharpCode.Reporting.Addin.Views
}
/// <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);
@ -398,6 +389,20 @@ namespace ICSharpCode.Reporting.Addin.Views @@ -398,6 +389,20 @@ namespace ICSharpCode.Reporting.Addin.Views
LoadDesigner(stream);
SetupSecondaryView();
}
public override void Save(OpenedFile file, Stream stream)
{
if (IsDirty) {
if (hasUnmergedChanges) {
MergeFormChanges();
}
using(var writer = new StreamWriter(stream)) {
writer.Write(ReportFileContent);
}
}
}
#endregion
}

Loading…
Cancel
Save