Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 62cc514

Browse files
Cleanup Designer
1 parent c97c181 commit 62cc514

4 files changed

Lines changed: 54 additions & 110 deletions

File tree

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System;
1010
using System.ComponentModel.Design;
1111
using System.Windows.Forms.Design;
12+
using ICSharpCode.Reporting.Addin.DesignableItems;
1213

1314
namespace ICSharpCode.Reporting.Addin.Designer
1415
{
@@ -22,12 +23,43 @@ public override void Initialize(System.ComponentModel.IComponent component)
2223
{
2324
base.Initialize(component);
2425
SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
26+
SelectionService.SelectionChanged += OnComponentSelected;
2527
ComponentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
28+
ComponentChangeService.ComponentRename += OnComponentRename;
29+
}
30+
31+
32+
void OnComponentSelected(object sender, EventArgs e)
33+
{
34+
Control.Invalidate();
35+
}
36+
37+
38+
void OnComponentRename(object sender, ComponentRenameEventArgs e)
39+
{
40+
if (e.Component == Component) {
41+
if ((!String.IsNullOrEmpty(e.NewName)) && (e.NewName != Control.Name)) {
42+
var c = Component as AbstractItem;;
43+
c.Name = e.NewName;
44+
Control.Invalidate();
45+
}
46+
}
2647
}
2748

2849

2950
protected ISelectionService SelectionService {get; private set;}
3051

3152
protected IComponentChangeService ComponentChangeService {get;private set;}
53+
54+
protected override void Dispose(bool disposing)
55+
{
56+
if (ComponentChangeService != null) {
57+
ComponentChangeService.ComponentRename -= OnComponentRename;
58+
}
59+
if (SelectionService != null) {
60+
SelectionService.SelectionChanged -= OnComponentSelected;
61+
}
62+
base.Dispose(disposing);
63+
}
3264
}
3365
}

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

Lines changed: 7 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
using System;
1010
using System.ComponentModel;
11-
using System.ComponentModel.Design;
1211
using System.Drawing;
1312
using System.Windows.Forms;
1413
using ICSharpCode.Reporting.Addin.DesignableItems;
@@ -34,55 +33,16 @@ public override void Initialize(IComponent component)
3433
}
3534
base.Initialize(component);
3635
baseLine = (BaseLineItem)component;
37-
38-
ComponentChangeService.ComponentChanging += OnComponentChanging;
39-
ComponentChangeService.ComponentChanged += OnComponentChanged;
40-
ComponentChangeService.ComponentRename += OnComponentRename;
41-
SelectionService.SelectionChanged += OnSelectionChanged;
4236
}
4337

38+
4439
protected override void PostFilterProperties(System.Collections.IDictionary properties)
4540
{
4641
TypeProviderHelper.RemoveProperties(properties);
4742
base.PostFilterProperties(properties);
4843
}
4944

5045

51-
#region events
52-
53-
private void OnComponentChanging (object sender,ComponentChangingEventArgs e)
54-
{
55-
// System.Console.WriteLine("changing");
56-
// System.Console.WriteLine("{0}",this.baseLine.ClientRectangle);
57-
Control.Invalidate( );
58-
}
59-
60-
61-
void OnComponentChanged(object sender,ComponentChangedEventArgs e)
62-
{
63-
Console.WriteLine("{0}",this.baseLine.ClientRectangle);
64-
Control.Invalidate( );
65-
}
66-
67-
68-
void OnComponentRename(object sender,ComponentRenameEventArgs e) {
69-
if (e.Component == this.Component) {
70-
Control.Name = e.NewName;
71-
Control.Invalidate();
72-
Control.Invalidate( );
73-
}
74-
}
75-
76-
77-
void OnSelectionChanged(object sender, EventArgs e)
78-
{
79-
Control.Invalidate( );
80-
}
81-
82-
83-
#endregion
84-
85-
8646
protected override void OnPaintAdornments(PaintEventArgs pe)
8747
{
8848
var label = Control as BaseLineItem;
@@ -139,8 +99,8 @@ protected override void OnMouseDragBegin(int x, int y)
13999
{
140100
System.Console.WriteLine("DragBegib");
141101
Point p = this.baseLine.PointToClient(new Point(x, y));
142-
overFromPoint = GetHandle(this.baseLine.FromPoint).Contains(p);
143-
this.overToPoint = GetHandle(this.baseLine.ToPoint).Contains(p);
102+
overFromPoint = GetHandle(baseLine.FromPoint).Contains(p);
103+
this.overToPoint = GetHandle(baseLine.ToPoint).Contains(p);
144104
if (overFromPoint || overToPoint )
145105
{
146106
dragging = true;
@@ -166,10 +126,10 @@ protected override void OnMouseDragMove(int x, int y)
166126
if (dragging)
167127
{
168128
Point p = this.baseLine.PointToClient(new Point(x, y));
169-
if (this.overToPoint) {
170-
this.baseLine.ToPoint = p;
129+
if (overToPoint) {
130+
baseLine.ToPoint = p;
171131
} else {
172-
this.baseLine.FromPoint = p;
132+
baseLine.FromPoint = p;
173133
}
174134

175135
// this.baseLine.Invalidate();
@@ -210,7 +170,7 @@ protected override void OnMouseDragEnd(bool cancel)
210170
}
211171
*/
212172
dragging = false;
213-
this.baseLine.Invalidate();
173+
baseLine.Invalidate();
214174
}
215175

216176
// Always call base class.
@@ -221,20 +181,5 @@ protected override void OnMouseDragEnd(bool cancel)
221181

222182
#endregion
223183

224-
225-
protected override void Dispose(bool disposing)
226-
{
227-
228-
if (ComponentChangeService != null) {
229-
ComponentChangeService.ComponentChanging -= OnComponentChanging;
230-
ComponentChangeService.ComponentChanged -= OnComponentChanged;
231-
ComponentChangeService.ComponentRename -= OnComponentRename;
232-
}
233-
if (SelectionService != null) {
234-
SelectionService.SelectionChanged -= OnSelectionChanged;
235-
}
236-
237-
base.Dispose(disposing);
238-
}
239184
}
240185
}

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

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
* To change this template use Tools | Options | Coding | Edit Standard Headers.
88
*/
99
using System;
10-
using System.ComponentModel;
11-
using System.ComponentModel.Design;
12-
using ICSharpCode.Reporting.Addin.DesignableItems;
1310
using ICSharpCode.Reporting.Addin.TypeProvider;
1411

1512

@@ -21,38 +18,14 @@ namespace ICSharpCode.Reporting.Addin.Designer
2118
public class TextItemDesigner:AbstractDesigner
2219
{
2320

24-
BaseTextItem ctrl;
25-
26-
public override void Initialize(IComponent component)
27-
{
28-
base.Initialize(component);
29-
SelectionService.SelectionChanged += OnSelectionChanged;
30-
ComponentChangeService.ComponentRename += OnComponentRename;
31-
ctrl = (BaseTextItem) component;
32-
}
33-
21+
3422
protected override void PostFilterProperties(System.Collections.IDictionary properties)
3523
{
3624
TypeProviderHelper.RemoveProperties(properties);
3725
base.PostFilterProperties(properties);
3826
}
3927

4028

41-
void OnSelectionChanged(object sender, EventArgs e)
42-
{
43-
Control.Invalidate( );
44-
}
45-
46-
47-
void OnComponentRename(object sender,ComponentRenameEventArgs e) {
48-
if (e.Component == Component) {
49-
Control.Name = e.NewName;
50-
Control.Invalidate();
51-
}
52-
}
53-
54-
55-
5629
#region SmartTag
5730

5831
// public override DesignerActionListCollection ActionLists {
@@ -100,16 +73,5 @@ private void SetProperty (string prop, object value)
10073
*/
10174
#endregion
10275

103-
protected override void Dispose(bool disposing)
104-
{
105-
if (SelectionService != null) {
106-
SelectionService.SelectionChanged -= OnSelectionChanged;
107-
}
108-
109-
if (ComponentChangeService != null) {
110-
ComponentChangeService.ComponentRename -= OnComponentRename;
111-
}
112-
base.Dispose(disposing);
113-
}
11476
}
11577
}

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,22 +382,27 @@ public override object Control {
382382
}
383383

384384

385-
/// <summary>
386-
/// Creates a new DesignerView object
387-
/// </summary>
388-
389-
390-
/// <summary>
391-
/// Loads a new file into MyView
392-
/// </summary>
393-
394385
public override void Load(OpenedFile file, System.IO.Stream stream)
395386
{
396387
LoggingService.Debug("ReportDesigner: Load from: " + file.FileName);
397388
base.Load(file, stream);
398389
LoadDesigner(stream);
399390
SetupSecondaryView();
400391
}
392+
393+
394+
public override void Save(OpenedFile file, Stream stream)
395+
{
396+
if (IsDirty) {
397+
if (hasUnmergedChanges) {
398+
MergeFormChanges();
399+
}
400+
using(var writer = new StreamWriter(stream)) {
401+
writer.Write(ReportFileContent);
402+
}
403+
}
404+
}
405+
401406
#endregion
402407
}
403408

0 commit comments

Comments
 (0)