From 62cc51441ca8354f3ea3ea6e3874bb26f92b2d29 Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Sun, 30 Mar 2014 18:53:58 +0200 Subject: [PATCH] Cleanup Designer --- .../src/Designer/AbstractDesigner.cs | 32 +++++++++ .../src/Designer/LineDesigner.cs | 69 ++----------------- .../src/Designer/TextItemDesigner.cs | 40 +---------- .../src/Views/DesignerView.cs | 23 ++++--- 4 files changed, 54 insertions(+), 110 deletions(-) diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/AbstractDesigner.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/AbstractDesigner.cs index 930cd1ca51..c390898df4 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/AbstractDesigner.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/AbstractDesigner.cs @@ -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 { 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); + } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs index a22ecc5df2..60729b7061 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs @@ -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 } 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 } - #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 { 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 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 } */ dragging = false; - this.baseLine.Invalidate(); + baseLine.Invalidate(); } // Always call base class. @@ -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); - } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs index 0acfe72cf0..3f7be37d5f 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs @@ -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 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 } - 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 */ #endregion - protected override void Dispose(bool disposing) - { - if (SelectionService != null) { - SelectionService.SelectionChanged -= OnSelectionChanged; - } - - if (ComponentChangeService != null) { - ComponentChangeService.ComponentRename -= OnComponentRename; - } - base.Dispose(disposing); - } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Views/DesignerView.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Views/DesignerView.cs index 94f1f9d59b..6f3425b981 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Views/DesignerView.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Views/DesignerView.cs @@ -382,15 +382,6 @@ namespace ICSharpCode.Reporting.Addin.Views } - /// - /// Creates a new DesignerView object - /// - - - /// - /// Loads a new file into MyView - /// - 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 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 }