Codeine .Net RSS 2.0
# Saturday, 26 January 2008

    Yesterday afternoon a new addition was added to my family that I had been expecting for some time. As with most new fathers I expect to be sleep deprived for a while. Thankfully this new family member doesn't require me to change any diapers and I can turn it off or trade it in at anytime. Just one of the few pluses of being a S.I.N.K.

 

    

 

Saturday, 26 January 2008 11:33:12 (Central Standard Time, UTC-06:00)  #    Comments [2] - Trackback - Save to del.icio.us - Digg This! - Follow me on Twitter

# Sunday, 20 January 2008

    So far I have went over how to create a basic workflow activity that evaluates a regular expression against a string and I have also covered creating the validation class for the activity. The next thing I want to cover are some basics to enhancing the designer experience of the workflow activity allowing you to override the default visual display in the designer for a custom activity. Based on the default designer class our RegEx activity appears as follows:

    

    The first thing that needs to be done is to add a new class to the project called RegExDesigner.cs.

    

 

    Next we need to make our new class inherit from the ActivityDesigner class. To do this we will also need to import the namespace System.Workflow.ComponentModel.Design, which means your code should now appear as follows:

    using System.Workflow.ComponentModel.Design;

 

namespace FloFactory.Activities.Util.Logic

{

    public class RegExDesigner : ActivityDesigner

    {

    }

}

 

 

    There are a lot of functions that you can override, but the main function that we are going to work with is the Initialize function which will allow us to override the appearance of our activity in the designer. This first thing that I am going to do is add a nice image to the activity. Assuming you already have an image that you want to use as a resource in your project you add the image to the activity's design view by doing the following:

 

protected override void Initialize(System.Workflow.ComponentModel.Activity activity)

{

base.Initialize(activity);

Bitmap WorkFlowImage = Properties.Resources.workflow;

 

Image = WorkFlowImage;

 

}

 

    The other thing I would like to do is change the text that appears in the activity. This will be the default text that shows up until the user of our activity sets the name property. This is easily done by setting the Text property in the Initialize function. After doing this the code should appear as follows:

 

    protected override void Initialize(System.Workflow.ComponentModel.Activity activity)

{

base.Initialize(activity);

Bitmap WorkFlowImage = Properties.Resources.workflow;

 

Image = WorkFlowImage;

 

//Set the Text That appears

Text = "FloFactory RegEx";

 

}

 

 

    Now we need to associate the designer class with our activity. We do this by going to the top of the RegEx.cs class and add the following attribute:

    [Designer(typeof(RegExDesigner), typeof(IDesigner))]

    public partial class RegEx: BaseActivity

    {

        …

}

 

 

 

    After adding this code to the Initialize function and adding the attribute if we now look at the RegEx activity we will see that our image has replaced the default image that appeared when the original designer class was applied to the RegEx activity. Also, the default text that was defined appears in the center of the activity.

 

 

    As you can see we have easily modified the image and the text that appears in the designer for our RegEx activity. In a future post I will cover modifying the appearance of the activity by changing its size and colors so as to create a more custom look and feel for the activity.

 

    

 

 

 

Sunday, 20 January 2008 20:38:13 (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback - Save to del.icio.us - Digg This! - Follow me on Twitter
.Net 3.0 | Development | Windows Workflow
# Tuesday, 01 January 2008

    Well lately I have been using Resharper from JetBrains which is an amazing Visual Studio Add in that adds an extensive amount of new features and shortcuts. It has greatly increased my productivity and if you're not using it then you should at least download the 30 day trial and test it out. (Greg this means you. Tell Matt I said he should buy it for you.) I especially like the file structure explorer that allows me to organize functions and properties in a class by dragging them around instead of needing to copy and paste them. This is very helpful when organizing your classes into regions. Also, if you've ever had a giant solution where it begins to be difficult to find files you'll appreciate the file search that allows you to start typing a filename and get a filtered list of files. It definitely can be a bit overwhelming with all the shortcuts it adds to Visual Studio so in order to make looking up the shortcuts easier I created this basic VS2005 add in that displays the Resharper cheat sheet on the screen. After installing the Recheater Add in you can display the cheat sheet by hitting CTRL-ALT-SHIFT-H and close it down by hitting the ESC key. To change the shortcut key simply modify the config file located under My Documents\Visual Studio 2005\Addins\RecheaterAddin. It's a pretty basic application, but feel free to download Recheater and post a comment if you find any bugs or want to suggest an enhancement.

Tuesday, 01 January 2008 11:09:57 (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback - Save to del.icio.us - Digg This! - Follow me on Twitter
Development | Resharper | Visual Studio

Navigation
Archive
<2008 February>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
2425262728291
2345678
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2024
David A. Osborn
Sign In
Statistics
Total Posts: 70
This Year: 0
This Month: 0
This Week: 0
Comments: 33
Themes
Pick a theme:
All Content © 2024, David A. Osborn
DasBlog theme 'Business' created by Christoph De Baene (delarou)