Add Graphic User Interface to custom Activities
If so, where can I read some documentation about it. I think that, maybe, I need to override some method but I can't figure it out what method.
Thanks in advance.
Hi,
It is possible to create a custom activity with your own GUI. For this you need to create your own designer and override the OnPaint method. There are whole bunch of other methods that you can override to associate custom behavior with your designer.
[DesignerAttribute(typeof(MyDesigner))]
[ToolboxItemAttribute(typeof(ActivityToolboxItem))]
public partial class Activity1 : Sequence
{
public Activity1()
{
InitializeComponent();
}
}
public class MyDesigner : SequenceDesigner
{
public override void OnPaint(......){}
}
Hope this helps.
- Vihang
textBox1.Text = ActivitiesLibrary.Activity1.p1Property;But when I try to compile I get this message:
Error 1 Cannot implicitly convert type 'System.Workflow.ComponentModel.DependencyProperty' to 'string'
I know that is a cast problem, but how should i access the value of property p1 in my form? namespace
{
[DesignerAttribute(typeof(MyDesigner))]
[ToolboxItemAttribute(typeof(ActivityToolboxItem))]
public partial class Activity1 : System.Workflow.ComponentModel.Activity
{
public Activity1()
{
InitializeComponent();
}
public static DependencyProperty p1Property = DependencyProperty.Register("p1", typeof(System.String), typeof(ActivitiesLibrary.Activity1));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[ValidationVisibilityAttribute(ValidationVisibility.Optional)]
[BrowsableAttribute(true)]
public string p1
{
get
{
return ((string)(base.GetValue(ActivitiesLibrary.Activity1.p1Property)));
}
set
{
base.SetValue(ActivitiesLibrary.Activity1.p1Property, value);
}
}
}
public class MyDesigner : System.Workflow.ComponentModel.Design.ActivityDesigner
{
protected override void OnMouseDoubleClick(System.Windows.Forms.MouseEventArgs e)
{
UI.Form1 f1 = new UI.Form1();
f1.ShowDialog();
}
}
} namespace
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
textBox1.Text = ActivitiesLibrary.Activity1.p1Property;
}
}
}
Sorry, I've realized that I need to receive an instance of my activity in my designer. Something like this:
namespace UI{ public class MyDesigner : System.Workflow.ComponentModel.Design.ActivityDesigner
public partial class Form1 : Form
{
public Form1(ActivitiesLibrary.Activity1 act)
{
InitializeComponent();
textBox1.Text = act.p1;
}
}
}
What I cant still figure out how is to pass to my designer the instance of the activity doubleclicked:
{
protected override void OnMouseDoubleClick(System.Windows.Forms.MouseEventArgs e)
{
UI.Form1 f1 = new UI.Form1();
f1.ShowDialog();
}
Thanks in advance
Sorry..
public
{
private Activity1 m_Act1; protected override void Initialize(System.Workflow.ComponentModel.Activity activity){
m_Act1 = (
Activity1) activity;}
protected override void OnMouseDoubleClick(System.Windows.Forms.MouseEventArgs e){
UI.
Form1 f1 = new UI.Form1(m_Act1); // UI.Form1 f1 = new UI.Form1();f1.ShowDialog();
}
The deisgner has an Activity Property which gives you the instance of the activity.
protected override void OnMouseDoubleClick(System.Windows.Forms.MouseEventArgs e)
{
UI.Form1 f1 = new UI.Form1(this.Activity);
f1.ShowDialog();
}
Hope this helps.
- Vihang
What I did was to write code in my custom activity to display a form when that custom activity is doubleclicked in the workflow designer, and show in that form values of the custom activity properties.
Now I need to show in that same form, the values of the workflow's parameters.
I hope it will clarify the scenario.
Thanks in advance