Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello all

 

I read through and have been playing with Tim's "Hosting Windows Forms Designers" code and tut..

 

I would be the first to say that I really understood about 2% of the important hows and whys, but I am having a little trouble with it

 

Firstly i only understand vb and not c#(one day will learn)

 

what i have done is played around and extended the demo code and added my own usercontrol that displays a propertygrid linked to my own class which holds a few properties like dock and anchor and a few others.

 

now then you change the dock property within my control it changes the current selected item on the host form to the docking style i select..this is all good..

 

the problem is that once the control moves the box around it that display the grips stays where the control was, it doesnt move with it.

 

the other problem i am having is adding controls via code when the program starts.. ie i want to add say a tab control and dock it to the bottom of the host window.

Now in a way i think i have it working..

 

pnlViewHost.Controls.Add(view)

host.CreateComponent(GetType(Janus.Windows.UI.Tab.UITab))

 

.. i think this because once i run the program if i drag from the toolbox another tab control it labels it tab 2 so the one i added was tab 1.

But the tab i created does not display on the form..

 

i wanted to work this out so that once i have a form setup that i could somhow work out a way to save it so that i could open it and have it display what i saved later on.

 

thanks for any help.

Oz

PS - with many controls once you drop them on the form they have a right mouse menu for things like the tab control to add a new tab.. can this also be done??

Posted

I also used the Tim's hosting article to develop my own IDE.

My stuff is somethig a little diferent from the usual, as it persists the controls to XML along with the user code, so no exe's neither dll's... only XML.

 

This XML files are addins scripts to my ERP app, most like templates.

 

So this is how I persist the results of my IDE... how do you do it?

You're having problems showing the forms... but how do you persist tjem?

 

It's a start so I can help you...

 

Alex :P

Software bugs are impossible to detect by anybody except the end user.
Posted

Yeah I was going to use XML to store the control location etc.. then when the app is run load them to the form and bind the data table items to the correct control on the form (textboxes)

 

i just cant work out how to have the IDE designer of Tim's open and load items.. ie if i have created one and saved it, i now want to open it and change things around..

 

I just can not seem to work out how to add controls etc via code

 

Thanks

Oz

Posted

I can't give you the exact code because it's already registered to my company... ;)

 

But I can give you some hints:

1- You have to serialize the objects, this isn't easy, and it's not documented around the internet. You must create your own inherited controls, lets say fom a Button control, and implement the IXMLSerializable interface. Then write your own WriteXML, ReadXML and XMLSchema code so it knows what properties you want to persist to XML.

 

2- Using the technique descrybed above, you can persist the Controls property of the form, and it will create a chain of controls as Parent->Child. This way, when you deserialize the controls they will be on their correct places.

 

3- As to code, use the Scripting technique Tim describes... This way you'll be able to have code related to the persisted objects. Compiling the deserialized objects with the scripted code will integrate both.

 

4- Using this, if you create your objects on the script code, they will appear on the form...

 

 

Note...

This took me about 1 month to accomplish... so don't expect this to be easy.

The used time was mostly spent on the object serialization/deserialization process and on the code text editor...

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.
Posted

Thanks..

 

I already have all the XML and schemas ready to go.. the whole purpose of the post was to get some code help. i already knew that "isn't easy" and "it's not documented around the internet" hence the reason for the question since there isnt any help out there.

 

Guess i'll just keep lookings

 

Thanks

Oz

Posted

As is, is my 3rd point on my previous post...

Use the scripting technique, it's the best way I've found.

 

It's not just copy/past from Tim's code, but using Delegates or, one level up, simple events to connect the two modules (code and objects) you'll find the way out...

 

As a start code structure taka a detailed look at the auto generated code by the vs.net... the onlu part you don't need it's the object properties, the rest it's all suitable.

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.
Posted

My present serialized form document looks like the attached file.

 

This represents a Form (myMDIChild), with a Panel (myPanel1) with two button in it (myButton2 & myBut).

The <UnderlyingCode> tag represents the user code for that form...

 

If you noticed, everything is between a <SerClass> tag.

This SerClass is a class that holds several typed arrays, each one representig a possible serialized type.

 

The "my[controls]" represent my custom inherited controls that implement IXMLSerialize.

 

This is my way of doing it! :p

 

Alex :p

Working.zip

Software bugs are impossible to detect by anybody except the end user.
Posted

Tim..

 

I came across this old posting of yours

http://www.dotnet247.com/247reference/msgs/33/165825.aspx

 

could you explain a bit for me how you go about

"you then have to add it to the design container anyway, and still have to add it to the form to make it show up"

 

Just like the other person that asked the same sort of question as to what i am trying to do, i cant work out how once i create an instance of a control in code to add it to the designer??

 

i really have no idea how to use or code into the sample the IDesignerSerializationManager

 

Oz

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...