in

WPF Design and Development

IdentityMine Team Blogs

David Kelley

A day in the life of a humble software architect... doing C#, WPF, Silverlight, Legos, Fuzzy Logic AI and/or whatever is the latest and greatest or more importantly the coolest techo mumbo jumbo...

Building UI Silverlight Popfly Blocks (part 2)

So once you build your block you also need to have a block definition file to go with it so that Popfly will know what to do with the block.  So in the case of the blank block you can see the basics used.  At the root you have a node ‘block’ with a class property that is the name of the class definition for the block.  Then you have the ‘providerName’, ‘providerUrl’, ‘providerLogoUrl’, ‘blockIconUrl’, ‘operations’ and then ‘objects’.  So ‘objects’ I have not used or are not used currently but the rest seem to have a purpose.  The first one ‘providerName’ is you or me in the case of the blank block.  Then we have the ‘providerUrl’ which is your URL if you want people to find out more about you.  Then there is the ‘providerLogoUrl’ which is your logo (not to important) and then there is the ‘blockIconUrl’ which is a link to an image that is used by the Popfly IDE to put on your blocks to help people recognize your block.  ‘operations’ is actually a collection of ‘operation’ nodes which is basically what your block does.  So of the methods that you want to expose to need to create an ‘operation’ node for each one. 

In the blank block I only have one method that is exposed and that is the ‘Method2’ method.  The ‘operation’ node has 2 properties that you should populate and that is the ‘name’ and callMode properties.  Name is just that the ‘name’ of the method.  The ‘callMode’ value should be ‘sync’.  The first child of the ‘operation’ node is the ‘description’ node and then the ‘inputs’ node which is a collection of ‘input’ nodes.  The ‘input’ nodes are the parameters of the function or method on your block that people have to pass into your block to make it work.  In this case I only have one parameter or ‘input’ called ‘Parameter1’. 

On the input node you have three properties to set.  First the name, then the ‘required’ and then the ‘type’ properties.  The ‘name’ properties is the name of the input.  The required properties determines if you have to input this value when calling this method.  The type although not actually used I know it will be so try to set it to something reasonable such as string or int or float or something like that.  Next you have the 3 child nodes : description, ‘defaultValue’ and ‘contraints’.  Don’t worry about ‘constraints’ but you can set a default value if you like and input a description that will help people know what to pass into that value.  

Now you can do all this work in Popfly but that process can be painful so I recommend a unit test harness.  In the blank block project you can see I created an HTML file that will run my block without all the Popfly bits so it makes it easier to work on.  In the HTML you notice a have a reference to the Silverlight.js file and to my ‘BlankBlock.xaml.js’ script.  I also have a script block with a function called ‘createSilverlightControl’ and then a div and initialization block in the div.  By looking at the ‘createSilverlightControl’ and then the matching member of the class you can see the difference is that this separate method references a local XAML which I have included where the one that is a member of the BlankBlock class is referencing the BarGraph XAML on Popfly.  Referencing the file locally means I can run the block when not online.  For the most part this function does the same thing as the member method except for the reference change.  This allows me to work offline on my block and use tools like Visual Studio for debugging etc. 

With this knowledge you should know enough to be dangerous to your self and others on Popfly.  J

 

Comments

No Comments

About david.kelley

David for the past 10 years has focused on distributed application design and emerging Microsoft technologies on the web. Having helped design and build some of the largest systems for companies like Microsoft, Onyx Software, Saltmine, Giordanous Group and more and of course our favorite company Identitymine, he has been on the leading edge of applying the latest tech to real world business problems. David’s technology breadth includes everything from SQL Server to Windows/WCF and Silverlight. David’s accomplishments also include developing new technologies such as self editing XML files and related XML technologies to fuzzy logic systems and advanced web user interface design.
© 2007 IdentityMine, Inc.
Powered by Community Server (Commercial Edition), by Telligent Systems