Can someone please explain, how I can programmatically change the text, that is shown, when I drag activities onto the designer surface
By default, the class name is shown (for example in the designer rehosting example).
Can someone please explain, how I can programmatically change the text, that is shown, when I drag activities onto the designer surface
By default, the class name is shown (for example in the designer rehosting example).
how to change the text shown when dragging activities from the toolbox
Eric Harmon
Matt, thanks for your help. Unfortunately your code did not work in my case.
I tried your code in the OnPaint of a customized activity, that I have added to the Designer Rehosting example, that you will find at
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnlong/html/WFDsgnRehst.asp
The class name is still shown in the designer when I drag items from the toolbox and not "the custom display text".
I have the feeling that the reason has something to do with the ToolboxService class in the above example. However, I cannot figure out, what to change to see my own text when dragging toolbox items.
I cannot change QualifiedName, because it is readonly and I also cannot overwrite it.
Did you manage to change the QualifiedName property
The Text property also is not working. It does not show Text, it always shows the class name.
Arturo Moreno
Hi Mario,
Are you still stuck because of this problem Do let us know and we will be happy to help.
Thanks
Saurabh
James Mayer
Thanks for your help. However, it dit not help to change the name property.
I am using the designer rehosting example from MSDN.
I have tried the following:
public class OrActivity : System.Workflow.ComponentModel.CompositeActivity, IActivityEventListener<ActivityExecutionStatusChangedEventArgs>
{
public OrActivity() : base("Composite Activity")
{
this.Name = "Composite Activity";
}
The designer still displays the class name when dragging items from the toolbox and not my custom text "Custom Activity".
You mentioned an override of the designer.
How can I change the text displayed during drag-and-drop from the toolbox in my designers code
Srinivas Govada
HI. Mario
as default action, the activity designer will display the QualifiedName ,but text property.
if you want to change the display text during drag-and-drop from the tool box in designer.
you need to override the OnPaint
there is a sample code like below.
protected override void OnPaint(System.Workflow.ComponentModel.Design.ActivityDesignerPaintEventArgs e)
{
if(!this.IsRootDesigner && this.ParentDesigner == null) // it is important. at dragdrop from toolbox mode.
{
/// paint the custom designer layout and representation that you wanted at drag-and-drop from toolbox time.
string _actionDisplayName = "the custom display text";
frameRect = new Rectangle(this.Location.X, this.Location.Y, this.Size.Width, this.Size.Height);
Rectangle shadowRect = new Rectangle(frameRect.X, frameRect.Y, frameRect.Width+3, frameRect.Height+2);
pageRect = new Rectangle(frameRect.X + 10, frameRect.Y + 22, frameRect.Width - 8, frameRect.Height - 28);
Rectangle titleRect = new Rectangle(frameRect.X + 20, frameRect.Y + 5, frameRect.Width - 40, 15);
Rectangle imageRect = new Rectangle(frameRect.X + 3, frameRect.Y + 5, 16, 16);
Brush titleBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Top + 25), TitleBaseColor, TitleLightingColor);
Brush glossBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Top + 13), Color.FromArgb(120, 255, 255, 255), Color.FromArgb(16, 255, 255, 255));// SolidBrush(Color.FromArgb(32, 255, 255, 255));
Brush frameBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Bottom), BaseColor, LightingColor);
e.Graphics.FillRectangle(frameBrush, frameRect);
e.Graphics.DrawRectangle(Pens.Gray, frameRect);
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
e.Graphics.DrawString(_actionDisplayName,new Font("Arial Black", 9), Brushes.Black, titleRect);
}
else
{
base.OnPaint(e);
}
}
Matt.
Scott Herbert
Sambakongen
hi .
in fact , i had not rehost the designer .
but the sample demo above is run well in VS2005 ,
i suggest the display representtation of designer has only relate the Activity Designer. but not to Toolbox Service.
is there any difference betweent rehosting Application Host and VS host
Bern McCarty
No, I think the workflow designer is the same. It does not matter if you host it in VS or in your app. But the text shown, when dragging items from the toolbox seems to be derived from the ToolboxItem instance. The designer displays the text but the ToolboxItem decides which text is shown.
However, I am not sure.
Can anyone please explain,
HOW TO CHANGE THE TEXT SHOWN WHEN A TOOLBOXITEM IS DRAGGED over the workflow designer
Thanks for your help so far.