WinForms Designer?

Feb 11, 2011 at 3:37 AM

Hey, was curious if the WinForms Designer also works w/ Cobra, or is that dependent on the DOM?

Mar 8, 2011 at 7:45 AM


Winforms designer needs Dom but before proceding forward accept my apology for replying so late

it is because i didnot know you had commented here. today i went to your page to see what is going on

with your project and saw your entry for this post i clicked and hence i am replying.

now continuing...

if dom is not available i once thought to do it through XAML because XAMl can read

CLR objects so if you create a designer in which one creates a Form and places controls then

that can be recorded in xaml at the backend and then the programm can run that xaml file to see the output

exactly has he built the form on your designer.only downside is that there will be no one to one correspondence

with what you are making in your designer and the code file in which you want to implement logic for events etc etc.

for that dom is needed again.





Mar 8, 2011 at 7:06 PM

XAML is an interesting thought.  Events are the nasty beast, for any of the DesignSurface examples I've seen (that aren't CSharp/VB.Net dependent).  I was wondering if maybe it would be possible to cheat though :-)  Use the C# codeDom to generate *.designer.cs, and then just make sure that particular file is included w/ the Cobra compilation command.  Not sure if it'd work, but am thinking it is worth a try (at least since it is the minimal effort approach)...

Nice thing about XAML though is the support for WPF / Silverlight, as opposed to WinForms, which is old. 

Mar 9, 2011 at 9:55 AM
Edited Mar 13, 2011 at 6:25 PM

xaml does support Winforms

you will get the idea

and yes you can do that by passing C# file directly to the cobraCompiler but that will have to be a standalone file

or file using other c# code i.e if you pass multiple c# files. you cannot access c# files code from cobra code file because

c# file will be passed on to the c# compiler without checking whereas .cobra file will go through the process of parsing and analysing

when it finds something that is not created either in the present file or other cobra files and also not in the assemblies referenced

then it would raise error because c# parser is not present in cobra. neither the passed c# file can access any cobra file code. or may be it could because by the time it would access cobra file code it would allready be c# code. but at all if there is a way to do this tell me too. accessing c# code file from cobra code file.

it seems it is possible with extern keyword and making a sort of duplicate of c# file in cobra thou.



Mar 9, 2011 at 3:36 PM

That does look interesting...

Thanks for the insight on the C#/Cobra mechanism.  I had gotten distracted, by contemplating intercepting events from the Design Surface.  For instance:

IComponentChangeService serv= designSurface.GetService(typeof (IComponentChangeService)) as IComponentChangeService;

serv.ComponentAdded +=new ComponentEventHandler(serv_ComponentAdded);

serv.ComponentChanged +=new ComponentChangedEventHandler(serv_ComponentChanged);

serv.ComponentRemoved +=new ComponentEventHandler(serv_ComponentRemoved);

serv.ComponentRename +=new ComponentRenameEventHandler(serv_ComponentRename);

And using the accumulated changes to generate the Cobra content.  But I've got nothing more than an accumulator for these events, and don't have any exporting happening yet.