Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / September 2005

Tip: Looking for answers? Try searching our database.

Editor with DesignSurface

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SWu - 21 Jul 2005 01:21 GMT
Hi,

I would like to build a custom design that simulates WinForm designer in
MPF.  So here is what I have done so far:

1. Create a standard editor using the wizard.
2. Change the Editor class to inherit from UserControl instead of RichTextbox.
3. Add a private member m_designSurface : DesignSurface to the Editor class.
4. Add a public Initialize(IServiceProvider sp) to the Editor class.
   a. Get the ITrackSelection service.
   b. Create a selection container containing the Form.
   c. Set the selection container to the ITrackSelection.OnSelectChange.
5. In EditorPane:SetSite
   a. Call Editor.Initialize(psp)
   b. Query for IToolboxService, and add a Button to the toolbox.
6. Implement IVsToolboxUser on the EditorPane class.

In the end, what I want to achieve is to drag the Button from the toolbox
and drop it on the editor, and then change the properties of the button
through the property browser.

So far, I can't get much working.  If I double-click the Button toolbox
item, the button is added to the designsurface, but I can't interact with the
button.  And I cannot get the drag and drop working either.  

Can someone give me a rundown on what I need to implement, i.e., how to
annouce selection to the environment, interact with the designsurface and
enable drag & drop?

Thanks,
Shirley
"Gary Chang[MSFT]" - 21 Jul 2005 10:16 GMT
Hi Shirley,

Currently, we are looking into this problem. We will update you as soon as
we get anything out.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
SWu - 22 Jul 2005 01:55 GMT
Gary,

I have worked on the problem a bit more and got a couple of things working.

Things are working now:
1. Interact with the button object on the design surface.
2. Track selection.

Things still need answer:
1. I can only create one button object.  The first time I double-click the
Button toolbox item, one button is added.  If I click the Button toolbox item
again, nothing is added.  I think it is to do with INameCreationService, but
not sure.  Which object in VSShell provides INameCreationService?  I
understand the DesignSurface needs it (true?).

2. I still cannot do drag and drop.

3. I cannot draw a button on the DesignSurface.  When I click on the Button
toolbox item, the Button toolbox item is carried by the cursor.  Then I go to
the DesignSurface and try to draw it, nothing happens.  Is there something
special I need to do?

Thanks,
Shirley

> Hi Shirley,
>
[quoted text clipped - 14 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 23 Jul 2005 08:42 GMT
Hi Shirley,

>1. I can only create one button object.  The first time I double-click the
>Button toolbox item, one button is added.  If I click the Button toolbox item
>again, nothing is added.  I think it is to do with INameCreationService, but
>not sure.  Which object in VSShell provides INameCreationService?

I think you can use the GetService to access this interface, such as
following:

 INameCreationService nameService =
(INameCreationService)GetService(typeof(INameCreationService));
 name = nameService.CreateName(this, component.GetType());

>2. I still cannot do drag and drop.

I suggest you refer to the article "How to: Support Toolbox Drag and Drop"
in our VS2005 VSIP SDK, it provides the general directions on how to
implement basic drag-and-drop functionality with your custom edtior/

Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
SWu - 25 Jul 2005 19:13 GMT
Hi Gary,

I have created my own NameCreationService and pass it to the designService,
so that part is working now.

The thing I really have trouble with is drag & drop and draw controls on the
designSurface.  I have read "How to: Support Toolbox Drag and Drog".  Since
my Editor inherits from UserControl, it already implements IDropTarget.  I
have added IVsToolboxUser to my editor as well.  The problem is the event
handlers for UserControl.DragEnter and UserControl.DragDrop are not invoked
when I drag items from the toolbox.  Do you have any idea why this is the
case?

Thanks,
Shirley

> Hi Shirley,
>
[quoted text clipped - 31 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 27 Jul 2005 07:23 GMT
>...  Since my Editor inherits from UserControl, it already implements
>IDropTarget.  I have added IVsToolboxUser to my editor as well.  
>The problem is the event handlers for UserControl.DragEnter and
>UserControl.DragDrop are not invoked when I drag items from the
>toolbox.  Do you have any idea why this is the case?

Hi Shirley,

In the current scenario,  I could not figure out what's the problem if your
custom editor, I think it is better if you can upload a self-alone sample
project to us, then we may perform some test and research with it. I
suggest you can send your VSPackage's project(zipped) to me directly if it
is not inconvenient.(please remove the "online" of my email address)

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
SWu - 29 Jul 2005 02:39 GMT
Hi Gary,

We have the drag-and-drop part figured out.  Now the only thing remaining is
the drawing part.  For example, when I click on a toolbox item, I would like
to draw it on the designSurface.

Thanks,
Shirley

> >...  Since my Editor inherits from UserControl, it already implements
> >IDropTarget.  I have added IVsToolboxUser to my editor as well.  
[quoted text clipped - 23 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 30 Jul 2005 04:06 GMT
Hi Shirley,

>We have the drag-and-drop part figured out.  Now the only thing  
>remaining isthe drawing part.  For example, when I click on a
>toolbox item, I would like to draw it on the designSurface.

It's great, so would you please send me the updated sample package for
research the new problem, if it is not inconvenient to you?

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
"Gary Chang[MSFT]" - 02 Aug 2005 04:05 GMT
Hi Shirley,

How is your project going, have you worked out how to draw the toolbox
items in your editoer's designsurface?

Meanwhile, I have consulted this issue woth out VSIP specialists, their
opinions are if you simply attempts to add the control to your UserControl
object and have it displayed, this would be done similar to how we add
controls to a winform or usercontrol. Meaning, the appropriate code needs
to be added to the InitializeComponent() function similar to how we do it
with our own controls.

Have you tried this with a stock control (like a generic Winform button
control). Does it work? If not, you will need to add some additional logic
to your drop handler to ensure that the proper code is added to that
InitializeComponent function.

Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
Rossen Hristov - 08 Aug 2005 12:39 GMT
Hello,

I saw your discussion and I was very interested since I have similar
problems and I am stuck for almost a month now. basically what I would like
to do is the following:

1. Write a class that will inherit from component and would be able to show
up via the "Add New Item" template. My class will be named Report and when a
new Item is added it will be named Report1, Report2, etc. and will inherit
from the class Report. So far so good. I did this.
2. Next, based on the ShapeLibrary example, I implemented a IRootDesigner to
serve this class. As an inner class this designer holds a Control which
serves as the DesignSurface and is returned in the GetView implementation. I
managed to do drag and drop, and when something is dropped on the design
surface, a code fo its is added to the Report code view. However nothing
shows up and the actual code for adding the component to the current class is
not produces. I am trying to add a MyComponent, but I tried with standard
controls such a TextBox and Button and the result is the same. In my example
temporarily I inherit the ReportTemplate class so I can test my design time
code in the same project. Where can I send my sample so that someone could
help me. I am desperate since my deadline is almost here and the lack of
documentation on the subject prevents me from finishing the project. Please
help me. I will be infinitely generous.
Rossen Hristov - 30 Sep 2005 12:56 GMT
My question is how can I intergate VSIP package with a custom editor and
IRootDesigner having a DesignSurface, for example. Is this possible at all?

> Hi Shirley,
>
[quoted text clipped - 27 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.