I’m currently working on a workflow implementation which, like many, is going to be used by users who are not necessarily programmers. So the thought of giving them conditions to write in code is the kind of thing that keeps me up at night.
I’m using Flowchart as the root node as it provides the sort of UI that we need, however there are a few issues.
First off is the display of the FlowDecision node. The standard look and feel is as follows…
That’s all well and good, but I’m trying to keep this usable from non-programmers and so setting the Condition property (a) from the property grid and (b) in code is a step too far.
Re-Designing FlowDecision
So, the first step is to re-design this designer. It’s a simple job as with WF4 it’s a load easier to register a new designer. Here’s what I ended up with, the XAML and code is shown later…
That’s looking more user friendly already. The first step was to create a new designer, the XAML of which is shown below (I’ve taken some formatting liberties with the XAML to fit on the page)…
<sap:ActivityDesigner x:Class="CustomActivities.CustomFlowDecisionDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;
assembly=System.Activities.Presentation"
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;
assembly=System.Activities.Presentation">
<sap:WorkflowItemPresenter Item="{Binding ModelItem.Condition}"
HintText="Drop a condition here"/>
</sap:ActivityDesigner>
All I’ve done here is derive from ActivityDesigner and then create a WorkflowItemPresenter (there’s a bit more work to do on this but I’ll save that for another blog post).
So, now I want to have a ‘condition’ activity (that’s a naming convention I’ve come up with myself). A condition activity returns a boolean, so will fit nicely into the slot provided by FlowDecision. My first one is the “IsAPastyMuncher” activity (I’m from Cornwall in the UK, pasties are part of my heritage – for some great ones you can do a lot worse than order over the phone from Malcolm Barnecutts).
Anyhow, this activity returns True or False, and the default designer looks like this…
Now that’s OK when it’s on its own, but as this activity is designed to be dropped within the FlowDecision it doesn’t look as good in that instance…
Removing the ‘Chrome’
There’s a bit too much ‘chrome’ going on there for my liking – the reason being that a standard designer derives from ActivityDesigner which adds the adornments such as the border, name and so on. What I’d really like is ‘chrome-less’ experience in the designer, and to do that all you need to do is change the base class of your designer from ActivityDesigner to WorkflowViewElement. This is as simple as editing the XAML directly and altering the root element to the following…
<sap:WorkflowViewElement x:Class="CustomActivities.IsAPastyMuncherDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;
assembly=System.Activities.Presentation"
xmlns:sapv="clr-namespace:System.Activities.Presentation.View;
assembly=System.Activities.Presentation">
<CheckBox Content="Munches Pasties" IsChecked="{Binding ModelItem.MunchesPasties}"/>
</sap:WorkflowViewElement>
Then you’ll have a much better experience within the designer…
That’s looking a load better – maybe still some room for improvement mind you (again another post I must get around to) but it’s getting there. But now to the main event…
Morphing Activities
There is however one major problem with the IsAPastyMuncher activity as now, when added to the toolbox & dropped outside of a decision I see just the following…
Now that’s a bit too minimal even for me! What I would ideally like to do is check if this activity has been dropped inside a FlowDecision, and if not automatically surround it with one. Your first thought might be to dive in with an activity that implements IActivityTemplateFactory, create a FlowDecision and within it create the IsAPastyMuncher activity. There’s one problem with that – FlowDecision doesn’t derive from Activity and cannot therefore be returned from the custom factory.
Never fear however, where there’s a will there’s a way, and instead I’ve overridden a method within the IsAPastyMuncher activity that is called when the activity is created (i.e. by the drag & drop operation) and in here I can do the switch. The code is shown below…
protected override void OnModelItemChanged(object newItem)
{
ConditionHelper.MorphIntoDecision(newItem);
}
I’ve created the ConditionHelper class which actually performs the swap…
internal class ConditionHelper
{
/// <summary>
/// Method that morphs a dropped activity inside a flow step into the same
/// activity but within a flow decision
/// </summary>
/// <param name="newItem"></param>
public static void MorphIntoDecision(object newItem)
{
if (newItem is ModelItem)
{
ModelItem item = newItem as ModelItem;
ModelItem parent = item.Parent;
if (parent.ItemType == typeof(FlowStep))
{
// Morph the parent to a flow decision
EditingContext context = item.GetEditingContext();
ModelItem newModelItem = ModelFactory.CreateItem(context, new FlowDecision());
using (ModelEditingScope scope = newModelItem.BeginEdit("Convert to Decision"))
{
MorphHelper.MorphObject(parent, newModelItem);
MorphHelper.MorphProperties(parent, newModelItem);
// Now I need to set newModelItem.Condition = parent.Action,
// so the MorphProperties helper is pretty useless in this instance!
ModelProperty conditionProp = newModelItem.Properties["Condition"];
ModelProperty actionProp = parent.Properties["Action"];
conditionProp.SetValue(actionProp.Value);
actionProp.SetValue(null);
scope.Complete();
}
}
}
}
}
When an activity other than FlowDecision is added to the flow chart activity it is surrounded with a FlowStep activity. I check if this is the case and if so construct a FlowDecision activity as the parent instead and morph the existing parent into the new activity (well, MorphHelper.MorphObject does this for me). Any properties on the original parent activity which match with property names on the new parent activity are copied across using the MorphHelper.MorphProperties call, but then I need to move the actual activity (i.e. the IsAPastyMuncher) from the FlowStep to the FlowDecision. On FlowStep the property holding the activity is Action, whereas on FlowDecision this is Condition, so I use the ModelProperty class to make this change.
Now I can drop on an IsAPastyMuncher activity and have it automatically surrounded with a FlowDecision, but also allow the user to drop one inside a FlowDecision that’s already on the design surface which is the best of both worlds.
The Code
If you would like to download a sample please click here. This is built on Visual Studio 2010.
In the example there are 2 custom activities on the toolbox – the IsAPastyMuncher which morphs inside a FlowDecision when dropped, and the LovesClottedCream activity which does not.
60 comments:
Hey this looks like something i could use.
Do your decision activity support a false and true branch?
Will it be possible to do that same for flowswitch?
The link to your sample seems to be broken :(
Could you mail me the sample?
- rck at mysupply dot dk
In advance thanks! :)
Travelling at the moment, will dig out the code when I get back home.
Very interesting post! I need to do the same in my workflow application. I want to modify the designer of FlowDecision activity in order to allow users to define conditions through a user friendly GUI.
Download link seems to be broken, could you email me the source code? r.vviani AT libero DOT it.
Thanks.
Emails sent!
Could you mail me the sample please?
Thanks in advance!
Hi Morgan,
It's very useful for me too. I'm trying to make a custom decision activity in my application. I'll be grateful if you send me the sample.
Thanks in advance.
HI,
Are you able to make the code available again or can you please email it to me?
Thanks
Very interesting post! I need to do the same in my workflow application. Could you mail me the sample please?
Thanks!
Cuong Bui
I want that you review my site on the errors. have a peek here and leave your thoughts in comment section.
What a amazing post shared here. I really love this website, I would like to say thanks for sharing such great post HPE2-E69 dumps . I would like to say bundle of thanks for sharing.
If you wish to become the best author of this age, you need to start a search for www.edubirdie.com reviews as soon as possible. Only this search will give you the information you need to become one of the greats.
Minecraft apk Hay Day mod apk
hi Morgan .
Thank you for the good content of the your blog.
Download link seems to be broken, could you email me the source code?
thanks
Thank you for the visit, thank you also have provided the information we really need, do not forget to share information and visit our page thank you. hotele , sprawdz rowniez hotele na mazurach
You can leave all the stressful work to us so that we handle it for you and assure you of delivering excellent online nursing essay writers to you all the time in our best custom research paper site company.
Our free college research papers is also keen on ensuring that the content of the completed paper is free from grammatical errors so as to provide those seeking for online research paper writing services receive a professional legitimate custom paper .
Our Professional Medicine Essay Writers work tirelessly to ensure that your Medicine Research Paper Writing is completed within the time frame given to avoid poor scores in your Medical Essay Assignments Writing.
We, at MyAssignmentHelp ensures the assignment submission before the due time, in case, amendments needed.We do not hold a customer for long, or procrastinate over the order. Every time a customer comes up with the order, the due time of delivery is decided. Once placed the assignment help online order, feel stress-free and wait for the most authentic assignment to be submitted.
كشف تسربات المياه بالمدينة المنورة
نقل عفش بالمدينة المنورة
شركة مكافحة الحشرات بالمدينة المنورة
ارخص شركة نقل عفش بالمدينة المنورة
DriverMax Pro is a free driver updater software that supports automatic installation, scheduled scans, and full device driver backups. Furthermore, it acts as a tool to discover and download the latest driver updates for your system.
Autodesk AutoCAD is a computer-aided design that is created for architects, constructional professionals, and engineers that helps them in creating 2D and 3D drawings.
Sandboxie provides a disconnected testing environment to the users. It enables them to run programs and files without affecting the system, application, or any platform on which they are installed.
MacBooster is a software program that is related to Mac. It is multi functional. Also, it is not only a simple but effective software which is a straightforward crack.
I’m impressed, I must say. Seldom do I come across a blog
that’s equally educative and interesting, and without a doubt, you’ve hit the
nail on the head. The problem is something which too few folks are speaking intelligently about.
I am very happy I found this in my search for something concerning this.
wondershare uniconverter crack
4k video downloader crack
cyberghost vpn crack
advanced systemcare pro crack serial key
This is my first visit here and I feel really good reading everything in one place.
sidify music converter crack
easeus data recovery wizard crack
fineprint
imazing full crack
photolemur crack
idm crack
xrecode iii
easeus data recovery wizard crack
eset smart security crack
snagit crack
avast premier crack
paragon ntfs crack
reaconverter pro crack
Hi! This is my first comment here so I just wanted to give a quick shout out and say I
really enjoy reading through your articles.
Can you suggest any other blogs/websites/forums that deal with the
same subjects? Thanks a lot!
tuxera ntfs crack
I just want to say that your article is just as great. The clarity of your message is simple
excellent and I can assume that you are an expert on this matter.
Well, with your permission, let me introduce you to the feed to keep you updated on future posts.
photofiltre studio x crack
smart defrag portable crack
Skip to Main Content. Skip to main content. Microsoft. Software Download. Software Download. Software Download. Home. Windows. Windows 10 · Windows ...
clone fish voice changer
avg-antivirus-crack
gets rid of the virus from the device. it's far an antivirus that the person can deploy on their plans to get safety. also protects and gives security to the scenarios in which it's miles set up and gets rid of malware from that gadget through scanning the device. One is the protection of computers, and the opposite is the safety of the net and email. laptop level protection way that it protects the machine from spyware, rootkits, viruses, malware, trojans, ransomware, or different malware.
PE-Design Crack is programming for making weaving amalgamation. This program features auto and Photo Stitch has 130 worked in literary styles, similarly as 5 new content styles for minimal substance, unique kinds of lines to make complex plans weaving, customized creation of utilization.
Pe Design Crack
Your source for fun, free mobile and PC download games. Thousands of free ... Download or play free online! ... Here is the Exact Arcade Version of Dig Dug!
2007 android games
Oh, this is a great post. Concept In addition to wasting time and effort
I write great articles, I want to write that way. I save a lot for later and don't seem to be doing anything.
quicktime pro
Hello! This post couldn't have been better! Reading this post reminded me of my good old roommate! He always talked about it. I will forward this page to him. I'm pretty sure he'll read it well. Thanks for sharing!
iobit uninstaller pro crack
activepresenter pro crack
bootstrap studio crack
wondershare mobiletrans crack
smartgit
This is very interesting, you are a skilled blogger. I have added your feed and hope to keep looking for more
great posts. Plus, I have shared your website on social media!
blackmagic fusion crack
cyberfox crack
xlstat crack
paperscan pro crack
smartftp enterprise crack
razer surround pro crack
You have Thank you for the information. This is very useful. If you know the wizard reset password, visit our Seagate Central Assistant Password Reset page.
manycam pro crack
wondershare video converter ultimate crack
manycam pro crack
magix music maker crack
iobit malware fighter free
idm crack
hma pro vpn crack
final cut pro x 10 crack
Your source for fun, free mobile and PC download games. Thousands of free . Download or play free online! . Here is the Exact Arcade Version of Dig Dug!
cricket 07 apk download
You Can Also Download Free Software & Mac
https://tijacrack.com/pe-design-crack/
Reach us for the professional writers like Online Assignment help canada
Online Essay help canada
Online Dissertation help
Homework help Canada
Online Coursework help
Thesis help canada
Oh, this is a great post—concept In addition to wasting time and effort.
activatedlink
Unhackme Crack
Speedify VPN Crack
Zwcad Sp2 Crack
Netflix Crack
Keepvid Pro Crack
similarly it is very hard to find Assassin's Creed 1 Torrent but you can have this game also here in just with single click only. And if you want to play the god of war 3 pc game free download full version highly compressed its is also available on this site too. So always visit here for Highly Compressed Pc Games here only one place on internet.
I loved as much as you will receive carried out right here.
The sketch is attractive, your authored material stylish.
nonetheless, you command get got a shakiness over that you wish
be delivering the following. unwell unquestionably come further formerly
again as the same nearly a lot often inside case you shield this hike.
vector magic crack
winx hd video converter crack
I loved it as you can find through this site.
The sketch is beautiful and your written material is stylish.
Yet, you'll be an anxiety-like feeling about the you'd like to do.
The following will be the content. Absolutely, definitely will come more formerly.
The same applies frequently in the event you are able to shield this particular hike.
microsoft office 2007 crack
I'm truly inspired by your writing skills and also by your blog structure. Is it a paid subject or have you changed it yourself?
No matter how good the high quality content stays, it's uncommon today to see a wonderful blog like this one.
VMware Workstation Pro Working License Key
Driver Downloader License Key Free List,
Global Mapper Crack + Keygen Free Download
Autodesk Fusion 360 Tutorial
Download Manycam Full Crack
Serial 4K Youtube to MP3
Codice Licenza Advanced System Repair Pro
Baixar Free YouTube Download Premium
This program appeals to me because it is quick and simple to use. I've been looking for software like this for my PC, and it's a pleasure to be able to download it for free. https://cracksir.com/mobiledit-phone-copier-express-4-6-0-2-crack-keygen-2020/
This is very rare and useful software. You may get many benefits free. Then why do you pay for other software for the same features? https://cracksir.com/dearmob-iphone-manager/
What a wonderful article and thank you so much for sharing it with us. I'm a big fan of your work, and I know it helps a lot of people
.
I am very happy to see this fantastic information,that is really a good for mine.https://thepcsoft.com/getdataback-crack-
Movavi Video Editor Crack is a cool and flexible editing software for all sorts of the person. It gives simple and easy-to-handle tools for making an exceptional video.
This is a good time to make long term plans and it's timely.
Have fun. I have read this post, and if you will excuse me, I would like to advise you on interesting topics or tips.
You can write the following articles on this topic.
I want to read more topics on this topic!
english short stories with moral value english stories What is the factorial of 100
I'm ecstatic to have come across this article. The author has a very creative mind; life is about creating yourself rather than finding yourself. Please pay a visit to my page because my post contains important information. Download Now
I appreciate your content. It is helpful for new people. this is nice and great!
Click Hear
It's a fantastic theme that's also quite simple to use.
https://cracksync.com/red-giant-universe-crack/
Wow, this was an exceptionally well-written article. This was just too much information for my taste.https://xactivator.net/indiafont-download-updated/
I'm blown away by your post because it's very helpful to me and provides me with new information.https://hdlicense.net/hotstar-mod-apk-crack/
crackeygenpatch.com is a software website from where we download all software with activation key
Crack Keygen Patch Softwares
I am a professional blogger. visit my website
pro crack software
Post a Comment