Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > VB.NET General Discussion

VB.NET General Discussion VB.NET general discussion area

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2009, 11:16 AM
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Jul 2009
Posts: 3
Reputation: 0
Super Dave is on a distinguished programming path ahead
Default Coverting C# System.Delegate.Combine

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) ;
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-03-2009, 1:09 PM
newguy's Avatar
VB.NET Forum Idol
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2008
Location: Denver Co, USA
Posts: 547
Reputation: 128
newguy a shining VB.NET starnewguy a shining VB.NET starnewguy a shining VB.NET starnewguy a shining VB.NET starnewguy a shining VB.NET star
Default

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-03-2009, 1:47 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Jul 2009
Posts: 3
Reputation: 0
Super Dave is on a distinguished programming path ahead
Default Addhandler

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-03-2009, 2:07 PM
newguy's Avatar
VB.NET Forum Idol
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2008
Location: Denver Co, USA
Posts: 547
Reputation: 128
newguy a shining VB.NET starnewguy a shining VB.NET starnewguy a shining VB.NET starnewguy a shining VB.NET starnewguy a shining VB.NET star
Default

I don't believe so, when you combine delegates you would have to pass 2 event handlers, hence combine. It appears there are giving each image an event - use the sender object in each event and that is the image you currently working with. They all share the same code format/behavior - if you will.
__________________
Close Counts for Horseshoes, Handgranades, and Nuclear Missiles!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-03-2009, 3:01 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.0 (VS 2005/2008)
 
Join Date: Jul 2009
Posts: 3
Reputation: 0
Super Dave is on a distinguished programming path ahead
Default Coversion

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 11:07 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.