1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.ComponentModel;
6
using System.ComponentModel.Design;
7
using System.Windows.Forms;
8
using System.Windows.Forms.Design;
10
using ICSharpCode.Reports.Core;
11
using ICSharpCode.Reports.Core.Dialogs;
12
using ICSharpCode.Reports.Core.Interfaces;
14
namespace ICSharpCode.Reports.Addin.Designer
17
/// Description of ReportItemDesigner.
19
public class TextItemDesigner:ControlDesigner
22
private ISelectionService selectionService;
23
private IComponentChangeService componentChangeService;
24
private BaseTextItem ctrl;
26
public override void Initialize(IComponent component)
28
base.Initialize(component);
30
this.ctrl = (BaseTextItem) component;
33
protected override void PostFilterProperties(System.Collections.IDictionary properties)
35
DesignerHelper.RemoveProperties(properties);
36
base.PostFilterProperties(properties);
40
private void GetService ()
42
selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
43
if (selectionService != null)
45
selectionService.SelectionChanged += OnSelectionChanged;
49
componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
50
if (componentChangeService != null) {
51
componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
57
private void OnSelectionChanged(object sender, EventArgs e)
59
Control.Invalidate( );
63
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
64
if (e.Component == this.Component) {
65
Control.Name = e.NewName;
74
public override DesignerActionListCollection ActionLists {
76
DesignerActionListCollection actions = new DesignerActionListCollection ();
77
actions.Add (new TextBasedDesignerActionList(this.Component));
86
public override DesignerVerbCollection Verbs {
88
DesignerVerbCollection verbs = new DesignerVerbCollection();
89
DesignerVerb v1 = new DesignerVerb ("TextEditor",OnRunTextEditor);
96
private void OnRunTextEditor (object sender,EventArgs e)
98
IStringBasedEditorDialog ed = new TextEditorDialog (ctrl.Text,ctrl.Name);
99
if (ed.ShowDialog() == DialogResult.OK) {
100
ctrl.Text = ed.TextValue;
101
this.SetProperty ("Name",ed.TextValue);
106
private void SetProperty (string prop, object value)
108
PropertyDescriptor p = TypeDescriptor.GetProperties(Control)[prop];
110
throw new ArgumentException (this.ctrl.Text);
112
p.SetValue (Control,value);
119
protected override void Dispose(bool disposing)
121
if (this.selectionService != null) {
122
selectionService.SelectionChanged -= OnSelectionChanged;
125
if (componentChangeService != null) {
126
componentChangeService.ComponentRename -= OnComponentRename;
128
base.Dispose(disposing);