![]() |
Click here to advertise with us
|
|
|||||||
| VB.NET General Discussion VB.NET general discussion area |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I'm trying to convert a C# project to vb CodeProject: Image Thumbnail Viewer with .NET 2.0. Free source code and programming help
The one thing that has me stumped is the conversion of a routine to add thumbnails to a layout panel. A global event is declaired Public Event OnImageSizeChanged As ThumbnailImageEventHandler Then a section where each thumbnail image image is added with a size changed event for when a slider control is moved. It looks like just a big multicast delegate where each image control is chained to the slider. So any change in the size slider changes each thumbnail image controls size. C# original code: this.OnImageSizeChanged += new ThumbnailImageEventHandler(imageViewer.ImageSizeCh anged); I assume that the += is shorthand for the System.Delegate.Combine The problem is any attempt to have OnImageSizeChanged equal anything shows an error that says I must use a raiseevent. How should this be changed to work in vb? Regards, Super Dave Original C# private void AddImage(string imageFilename) { // thread safe if (this.InvokeRequired) { this.Invoke(m_AddImageDelegate, imageFilename); } else { int size = ImageSize; ImageViewer imageViewer = new ImageViewer(); imageViewer.Dock = DockStyle.Bottom; imageViewer.LoadImage(imageFilename, 256, 256); imageViewer.Width = size; imageViewer.Height = size; imageViewer.IsThumbnail = true; imageViewer.MouseClick += new MouseEventHandler(imageViewer_MouseClick); this.OnImageSizeChanged += new ThumbnailImageEventHandler(imageViewer.ImageSizeCh anged); this.flowLayoutPanelMain.Controls.Add(imageViewer) ; } } |
|
||||
|
I think it might be the same as 'Addhandler' but I am not very good at C#. here is a converter Convert C# to VB.NET - A free code conversion tool - developer Fusion - ASP.NET, C# Programming, VB.NET, .NET Framework, Java and Visual Basic Tutorials But you code is fragmented so you will have to put the whole thing in if you have it.
__________________
Close Counts for Horseshoes, Handgranades, and Nuclear Missiles! |
|
|||
|
If you just want to add one yes, but what it is doing I think is adding a handler to the list not replacing the last one. This is used for browsing images. As each image is added a a listing in the event is added. The method of System.Delegate.Combine is the way to chain this all together. I just can't figure out how to use it in this context.
|
|
|||
|
Thanks for the reply. I used Reflector to covert the project and for some reason it changed the signature of one of the events.
AddHandler imageViewer.MouseClick, AddressOf imageViewer_MouseClick AddHandler Me.OnImageSizeChanged, AddressOf imageViewer.ImageSizeChanged works correctly now and Addhandler will concatenate the event list. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|