Browse Source

Implement ComponentChangeService.ComponentRename in all Designers:

http://social.msdn.microsoft.com/forums/en-US/winformsdesigner/threads/

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/reports@6420 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Peter Forstmeier 15 years ago
parent
commit
49c0190dae
  1. 19
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/DataItemDesigner.cs
  2. 27
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/GroupeHeaderDesigner.cs
  3. 46
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/GroupedRowDesigner.cs
  4. 10
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/ImageDesigner.cs
  5. 10
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/LineDesigner.cs
  6. 12
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/RootDesigner/ReportRootDesigner.cs
  7. 19
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/RowItemDesigner.cs
  8. 10
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/ShapeDesigner.cs
  9. 18
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/TableDesigner.cs
  10. 27
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/TextItemDesigner.cs

19
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/DataItemDesigner.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.Reports.Addin.Designer
public class DataItemDesigner:ControlDesigner public class DataItemDesigner:ControlDesigner
{ {
private ISelectionService selectionService; private ISelectionService selectionService;
private IComponentChangeService componentChangeService;
public override void Initialize(IComponent component) public override void Initialize(IComponent component)
{ {
@ -49,6 +49,15 @@ namespace ICSharpCode.Reports.Addin.Designer
} }
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Invalidate();
}
}
private void GetService () private void GetService ()
{ {
selectionService = GetService(typeof(ISelectionService)) as ISelectionService; selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
@ -56,6 +65,11 @@ namespace ICSharpCode.Reports.Addin.Designer
{ {
selectionService.SelectionChanged += OnSelectionChanged; selectionService.SelectionChanged += OnSelectionChanged;
} }
componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
if (componentChangeService != null) {
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
}
} }
@ -66,6 +80,9 @@ namespace ICSharpCode.Reports.Addin.Designer
if (this.selectionService != null) { if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged; selectionService.SelectionChanged -= OnSelectionChanged;
} }
if (componentChangeService != null) {
componentChangeService.ComponentRename -= OnComponentRename;
}
base.Dispose(disposing); base.Dispose(disposing);
} }
#endregion #endregion

27
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/GroupeHeaderDesigner.cs

@ -20,6 +20,7 @@ namespace ICSharpCode.Reports.Addin.Designer
{ {
private ISelectionService selectionService; private ISelectionService selectionService;
private IComponentChangeService componentChangeService;
public GroupHeaderDesigner() public GroupHeaderDesigner()
{ {
@ -38,6 +39,14 @@ namespace ICSharpCode.Reports.Addin.Designer
} }
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Invalidate();
}
}
private void GetService () private void GetService ()
{ {
selectionService = GetService(typeof(ISelectionService)) as ISelectionService; selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
@ -45,6 +54,24 @@ namespace ICSharpCode.Reports.Addin.Designer
{ {
selectionService.SelectionChanged += OnSelectionChanged; selectionService.SelectionChanged += OnSelectionChanged;
} }
componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
if (componentChangeService != null) {
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
}
}
protected override void Dispose(bool disposing)
{
if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged;
}
if (componentChangeService != null) {
componentChangeService.ComponentRename -= OnComponentRename;
}
base.Dispose(disposing);
} }
} }

46
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/GroupedRowDesigner.cs

@ -18,6 +18,7 @@ namespace ICSharpCode.Reports.Addin.Designer
public class GroupedRowDesigner:RowItemDesigner public class GroupedRowDesigner:RowItemDesigner
{ {
private ISelectionService selectionService; private ISelectionService selectionService;
private IComponentChangeService componentChangeService;
public GroupedRowDesigner() public GroupedRowDesigner()
{ {
@ -27,6 +28,51 @@ namespace ICSharpCode.Reports.Addin.Designer
public override void Initialize(IComponent component) public override void Initialize(IComponent component)
{ {
base.Initialize(component); base.Initialize(component);
GetService();
}
private void GetService ()
{
selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
if (selectionService != null)
{
selectionService.SelectionChanged += OnSelectionChanged;
}
componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
if (componentChangeService != null) {
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
}
}
private void OnSelectionChanged(object sender, EventArgs e)
{
Control.Invalidate( );
}
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Text = e.NewName;
Control.Invalidate();
}
}
protected override void Dispose(bool disposing)
{
if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged;
}
if (componentChangeService != null) {
componentChangeService.ComponentRename -= OnComponentRename;
}
base.Dispose(disposing);
} }
} }
} }

10
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/ImageDesigner.cs

@ -39,6 +39,7 @@ namespace ICSharpCode.Reports.Addin.Designer
if (componentChangeService != null) { if (componentChangeService != null) {
componentChangeService.ComponentChanging += OnComponentChanging; componentChangeService.ComponentChanging += OnComponentChanging;
componentChangeService.ComponentChanged += OnComponentChanged; componentChangeService.ComponentChanged += OnComponentChanged;
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
} }
selectionService = GetService(typeof(ISelectionService)) as ISelectionService; selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
@ -63,6 +64,14 @@ namespace ICSharpCode.Reports.Addin.Designer
} }
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Invalidate();
}
}
private void OnSelectionChanged(object sender, EventArgs e) private void OnSelectionChanged(object sender, EventArgs e)
{ {
Control.Invalidate( ); Control.Invalidate( );
@ -74,6 +83,7 @@ namespace ICSharpCode.Reports.Addin.Designer
if (this.componentChangeService != null) { if (this.componentChangeService != null) {
componentChangeService.ComponentChanging -= OnComponentChanging; componentChangeService.ComponentChanging -= OnComponentChanging;
componentChangeService.ComponentChanged -= OnComponentChanged; componentChangeService.ComponentChanged -= OnComponentChanged;
componentChangeService.ComponentRename -= OnComponentRename;
} }
if (this.selectionService != null) { if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged; selectionService.SelectionChanged -= OnSelectionChanged;

10
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/LineDesigner.cs

@ -42,6 +42,7 @@ namespace ICSharpCode.Reports.Addin.Designer
if (componentChangeService != null) { if (componentChangeService != null) {
componentChangeService.ComponentChanging += OnComponentChanging; componentChangeService.ComponentChanging += OnComponentChanging;
componentChangeService.ComponentChanged += OnComponentChanged; componentChangeService.ComponentChanged += OnComponentChanged;
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
} }
selectionService = GetService(typeof(ISelectionService)) as ISelectionService; selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
@ -68,6 +69,14 @@ namespace ICSharpCode.Reports.Addin.Designer
} }
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Invalidate();
}
}
private void OnSelectionChanged(object sender, EventArgs e) private void OnSelectionChanged(object sender, EventArgs e)
{ {
Control.Invalidate( ); Control.Invalidate( );
@ -222,6 +231,7 @@ namespace ICSharpCode.Reports.Addin.Designer
if (this.componentChangeService != null) { if (this.componentChangeService != null) {
componentChangeService.ComponentChanging -= OnComponentChanging; componentChangeService.ComponentChanging -= OnComponentChanging;
componentChangeService.ComponentChanged -= OnComponentChanged; componentChangeService.ComponentChanged -= OnComponentChanged;
componentChangeService.ComponentRename -= OnComponentRename;
} }
if (this.selectionService != null) { if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged; selectionService.SelectionChanged -= OnSelectionChanged;

12
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/RootDesigner/ReportRootDesigner.cs

@ -18,9 +18,9 @@ using System.Drawing.Printing;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Forms.Design; using System.Windows.Forms.Design;
using ICSharpCode.Reports.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Reports.Core;
namespace ICSharpCode.Reports.Addin.Designer namespace ICSharpCode.Reports.Addin.Designer
{ {
/// <summary> /// <summary>
@ -264,12 +264,6 @@ namespace ICSharpCode.Reports.Addin.Designer
LoggingService.InfoFormatted("RootDesigner:OnComponentChanged"); LoggingService.InfoFormatted("RootDesigner:OnComponentChanged");
String str = String.Format("RootDesigner:OnComponentChanged <{0}> from <{1}> to <{2}>",ce.Component.ToString(),ce.OldValue,ce.NewValue); String str = String.Format("RootDesigner:OnComponentChanged <{0}> from <{1}> to <{2}>",ce.Component.ToString(),ce.OldValue,ce.NewValue);
LoggingService.InfoFormatted(str); LoggingService.InfoFormatted(str);
AbstractItem item = ce.Component as AbstractItem;
var member = ce.Member;
if (member.Name == "Name") {
item.Name = ce.NewValue.ToString();
}
BaseSection section = ce.Component as BaseSection; BaseSection section = ce.Component as BaseSection;
if (section != null) { if (section != null) {
@ -281,11 +275,9 @@ namespace ICSharpCode.Reports.Addin.Designer
} }
RecalculateSections(); RecalculateSections();
} }
} }
private void OnComponentChanging(object sender, ComponentChangingEventArgs ce) private void OnComponentChanging(object sender, ComponentChangingEventArgs ce)
{ {
System.Console.WriteLine("RootDesigner:OnComponentChanging"); System.Console.WriteLine("RootDesigner:OnComponentChanging");

19
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/RowItemDesigner.cs

@ -24,6 +24,7 @@ namespace ICSharpCode.Reports.Addin.Designer
{ {
private ISelectionService selectionService; private ISelectionService selectionService;
private IComponentChangeService componentChangeService;
public RowItemDesigner() public RowItemDesigner()
{ {
@ -53,6 +54,13 @@ namespace ICSharpCode.Reports.Addin.Designer
} }
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Invalidate();
}
}
private void GetService () private void GetService ()
{ {
selectionService = GetService(typeof(ISelectionService)) as ISelectionService; selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
@ -60,6 +68,12 @@ namespace ICSharpCode.Reports.Addin.Designer
{ {
selectionService.SelectionChanged += OnSelectionChanged; selectionService.SelectionChanged += OnSelectionChanged;
} }
componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
if (componentChangeService != null)
{
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
}
} }
@ -69,6 +83,11 @@ namespace ICSharpCode.Reports.Addin.Designer
if (this.selectionService != null) { if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged; selectionService.SelectionChanged -= OnSelectionChanged;
} }
if (componentChangeService != null) {
componentChangeService.ComponentRename -= OnComponentRename;
}
base.Dispose(disposing); base.Dispose(disposing);
} }
#endregion #endregion

10
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/ShapeDesigner.cs

@ -39,6 +39,7 @@ namespace ICSharpCode.Reports.Addin.Designer
if (componentChangeService != null) { if (componentChangeService != null) {
componentChangeService.ComponentChanging += OnComponentChanging; componentChangeService.ComponentChanging += OnComponentChanging;
componentChangeService.ComponentChanged += OnComponentChanged; componentChangeService.ComponentChanged += OnComponentChanged;
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
} }
selectionService = GetService(typeof(ISelectionService)) as ISelectionService; selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
@ -63,6 +64,14 @@ namespace ICSharpCode.Reports.Addin.Designer
} }
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Invalidate();
}
}
private void OnSelectionChanged(object sender, EventArgs e) private void OnSelectionChanged(object sender, EventArgs e)
{ {
Control.Invalidate( ); Control.Invalidate( );
@ -74,6 +83,7 @@ namespace ICSharpCode.Reports.Addin.Designer
if (this.componentChangeService != null) { if (this.componentChangeService != null) {
componentChangeService.ComponentChanging -= OnComponentChanging; componentChangeService.ComponentChanging -= OnComponentChanging;
componentChangeService.ComponentChanged -= OnComponentChanged; componentChangeService.ComponentChanged -= OnComponentChanged;
componentChangeService.ComponentRename -= OnComponentRename;
} }
if (this.selectionService != null) { if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged; selectionService.SelectionChanged -= OnSelectionChanged;

18
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/TableDesigner.cs

@ -22,6 +22,7 @@ namespace ICSharpCode.Reports.Addin.Designer
public class TableDesigner:ParentControlDesigner public class TableDesigner:ParentControlDesigner
{ {
private ISelectionService selectionService; private ISelectionService selectionService;
private IComponentChangeService componentChangeService;
public TableDesigner():base() public TableDesigner():base()
{ {
@ -70,6 +71,14 @@ namespace ICSharpCode.Reports.Addin.Designer
} }
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Invalidate();
}
}
private void GetService () private void GetService ()
{ {
selectionService = GetService(typeof(ISelectionService)) as ISelectionService; selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
@ -77,6 +86,11 @@ namespace ICSharpCode.Reports.Addin.Designer
{ {
selectionService.SelectionChanged += OnSelectionChanged; selectionService.SelectionChanged += OnSelectionChanged;
} }
componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
if (componentChangeService != null) {
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
}
} }
@ -99,6 +113,10 @@ namespace ICSharpCode.Reports.Addin.Designer
if (this.selectionService != null) { if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged; selectionService.SelectionChanged -= OnSelectionChanged;
} }
if (componentChangeService != null) {
componentChangeService.ComponentRename -= OnComponentRename;
}
base.Dispose(disposing); base.Dispose(disposing);
} }
#endregion #endregion

27
src/AddIns/Misc/Reports/ICSharpCode.Reports.Addin/Project/Designer/TextItemDesigner.cs

@ -23,8 +23,9 @@ namespace ICSharpCode.Reports.Addin.Designer
public class TextItemDesigner:ControlDesigner public class TextItemDesigner:ControlDesigner
{ {
ISelectionService selectionService; private ISelectionService selectionService;
BaseTextItem ctrl; private IComponentChangeService componentChangeService;
private BaseTextItem ctrl;
public override void Initialize(IComponent component) public override void Initialize(IComponent component)
{ {
@ -40,7 +41,14 @@ namespace ICSharpCode.Reports.Addin.Designer
if (selectionService != null) if (selectionService != null)
{ {
selectionService.SelectionChanged += OnSelectionChanged; selectionService.SelectionChanged += OnSelectionChanged;
}
componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
if (componentChangeService != null) {
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
} }
} }
@ -49,6 +57,17 @@ namespace ICSharpCode.Reports.Addin.Designer
Control.Invalidate( ); Control.Invalidate( );
} }
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Text = e.NewName;
Control.Invalidate();
}
}
#region SmartTag #region SmartTag
public override DesignerActionListCollection ActionLists { public override DesignerActionListCollection ActionLists {
@ -101,6 +120,10 @@ namespace ICSharpCode.Reports.Addin.Designer
if (this.selectionService != null) { if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged; selectionService.SelectionChanged -= OnSelectionChanged;
} }
if (componentChangeService != null) {
componentChangeService.ComponentRename -= OnComponentRename;
}
base.Dispose(disposing); base.Dispose(disposing);
} }
} }

Loading…
Cancel
Save