|
Why not allow, the users use a control to use the desingher features |
| MigrationUser 1 Saturday, May 08, 2004 12:16 PM |
Can you explain what you are looking for in a bit more detail?
thanks - mike |
| MigrationUser 1 Tuesday, May 11, 2004 9:46 AM |
I mean like having a controls for:
@ Form desingher @ Control desingher @ Reprot desingher
with code view and is able to build just like VS .net |
| MigrationUser 1 Wednesday, May 12, 2004 12:13 PM |
Ahhh, I get it now. We've actually done alot of work in Whidbey to make it easier to create your own designers. For example, create a new WinForms app, add a reference to System.Design.dll and add a using statement for System.ComponentModel.Design, then add the following code in the Load event:
DesignSurface surface = new DesignSurface(typeof(Form)); Control c = surface.View as Control; if (c != null) { c.Dock = DockStyle.Fill; this.Controls.Add(c); }
Hit F5 and then you've got a new Form designer ready to go. Other tasks like adding a toolbox, and serializing to code require more code, but still less than in v1.1.
For other samples, I've got a component which can be dropped on a form and then switch the Form into design mode with a single line of code. This will be on the site when Beta 1 is public and we start shipping code samples to the Whidbey section.
- mike |
| MigrationUser 1 Tuesday, May 18, 2004 9:21 PM |
I know this is unrelated but its bothering the heck out of me in the current VB.NET... In whidbey are you able to set the forms designer grid size to 1,1 so that we can move the controls one pixel at a time instead of 2?? Currently in order to line controls up properly you have to set the location/size properties manually since the minimum grid size is 2,2 |
| MigrationUser 1 Thursday, May 20, 2004 5:34 PM |
Hi Mike, very cool. I just tried this and it works beautifully. I used a UserControl as a base type instead of a form.
Now I thought, let's try to add some controls to this. So I did the following:
UserControl uc = surface.Container.Components[0] as UserControl; uc.Controls.Add(new Button("Hello World");
So far, so good - the button appears on the surface. Great. Now, how do I get it selected?
I tried, following an example found elsewhere:
selectionService = (ISelectionService)surface.GetService(typeof(ISelectionService)); if (selectionService != null) { Console.WriteLine("Found selection service"); // Add some event handlers... }
That seems to work, and I get a selection service, and it even is valid, as it has the base UserControl set as its primary selection. However, if I click on the button on the UC, no selection event is fired.
What am I missing?
Any help very much appreciated. Also, how would I implement drag and drop of components onto the surface? And how do I switch back and forth between design mode and normal mode? Thanks a lot! |
| MigrationUser 1 Saturday, June 26, 2004 6:29 PM |
This looks great.
All I'm missing now is the ability to generate a CodeCompileUnit so that I can generate the C# code and the executable to run that form in a seperate process.
Do you have any sample code that does this ?
David Snipp |
| MigrationUser 1 Thursday, July 08, 2004 9:24 PM |
Hi David, I'm very curious if we are trying the same thing - are you trying to allow the generation of an executable using entirely designers?
I'm new to winform designers - (moderately good with web form designers) - however my main interest right now isn't in off the shelf controls but in winform designers being used directly in executables to generate actual programming code
So I have a rule engine that has a drag and drop interface but its different because I'm actually generating (very crudely) .net code to couple rule elements
I know I'm probably way off and you're talking about a visual studio solution, but saw what you posted...
I'm 99% convinced that designers can be hosted in a winform application, not sure how (but visual studio is mostly C# now I think). If I can figure this out, rather than draging around graphic objects and using my crude sizing handles that hardly work, I could potentially create wrappers around 2.0 designers, which would be an extremely huge step for the Nata1 MAIE (rule engine (brain) for our products)
Hope I'm not way off, I haven't done my 2.0 homework yet
Thanks, Paul |
| MigrationUser 1 Thursday, July 08, 2004 10:24 PM |
I think we are trying to do the same thing.
We don't want a VSIP solution as our customers are not programmers but they do want to design a user interface and perform a predefined set of actions and have that run as a standalone executable.
I've managed to generate my own CodeDom and compile that, but I need to serialize the Form and it's controls and their properties so that the form is instantiated correctly in the standalone executable.
I've looked at CodeDomComponentSerializationService but I am missing how to get from a Serialization store to a CodeCompileUnit.
Any ideas ?
Dave |
| MigrationUser 1 Friday, July 09, 2004 6:52 AM |
Hi Peter
You've probably run into the problem of scope. I encountered a similar problem a little while ago whilst working on something similar. If the object you are hooking your event into goes out of scope, the event will no longer fire. This problem gets increasingly difficult to track down when an event fires and then stops firing (when the GC clears it up).
The simplest work around is to have a local variable to assign the reference of your object into, that way you get to keep it alive.
HTH? |
| MigrationUser 1 Wednesday, September 22, 2004 3:59 AM |
Hi,
I've managed to get the DesignSurface working, including the ISelectionService. But I can't figure out how to disable the DesignSurface on-the-fly...
Is it possible to do this, and if so, can someone point me in the right direction?
Thanks in advance,
Marcel
ISelectionService example: -------------------------------- // Add Designer to 'this' DesignSurface surface = new DesignSurface(typeof(Form)); ServiceContainer sc = new ServiceContainer(surface);
Control c = surface.View as Control; if (c != null) { c.Dock = DockStyle.Fill; this.Controls.Add(c); }
Control designer = surface.Container.Components[0] as Control; // -->
// Add Button to designer IDesignerHost host = (IDesignerHost) sc.GetService(typeof(IDesignerHost));
Button button = (Button) host.CreateComponent(typeof(Button), "testButton"); button.Text = "Button"; designer.Controls.Add(button); // --> |
| MigrationUser 1 Thursday, September 30, 2004 2:55 AM |