Dan Fernandez - Demo of C# Express (pull images from Google)
- Posted: Jul 26, 2004 at 3:09 PM
- 137,496 Views
- 29 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?
samuel
Asynch Background Worker (reporting progress (do work, report change, run worker completed)) is super powerful and easy, easy to use! Next, the general RAD stuff is really impressive. This video is a great example of how easy it is to add, edit and debug complexish code. In debug, intellisense works in the watch window and you can view html from memory (variables) in a visualizer window. Daniel shows how to use a dictionary with a key and an image class (keeping images in memory and never writing them to disc).
RAD tools demonstrated include showing how to easily add the fully qualified name for a resource or add using to the top of the code with the appropriate namespace for missing data types. Refactor and extract method are demonstrated which allow you to take a piece of code an set it as a new function. You can see definitions of functions without jumping to the definition of the function. You can click definitions, 'surround with' to automatically add a try catch. Next, you can call a function without adding the stub for the new call. The IDE then will offer to create the method stub for the new function and it will create the stub with the correct return (or void) and add necessary data types to the definition. Code snippet expansions ('For Each' for example) will write out for you and you just pick a variable name, type and a collection to use for your for each and it's written. Now you can just add the code you want to execute for each whatever. Rename refactoring is shown to rename variables and objects in the program and it will change the reference in all comments, strings and code. You can use rename refactoring to rename a progress bar for example.
Thanks, Daniel, for another great demo!
I've added a walkthrough of the code and some of the UI for the application on my blog if people want to know more about how the application works.
Thanks,
-Dan
keep the good work
/Tyko
The search and replace is a good thing if it actually looks up object references and renames only those that actually match the object. I hope it doesn't simply perform a text-based search like what we already have. Consider this:
udtChild.Foo();
udtChildren.Goo();
I want to rename udtChild, which is an instance of a control, to udtBar. With a text-based search and replace, I end up with the unwanted scenario where all occurances of udtChild become udtBar, including the occurance of the substring udtChild in udtChildren. So, in effect, my code becomes:
udtBar.Foo();
udtBarren.Goo();
which is not so great. Thanks for the great post.
One thing to note about your post is that you can install C# Express on Windows 2000 as well as XP and 2003. I'm not sure if this helps you, but I wanted to make sure you knew. You can find the system requirements here.
Visual C# Express can be installed on any of the following systems:
- Microsoft Windows® 2003 Server™
- Windows XP
- Windows 2000
To your question about how refactoring works, you are correct, we use the power of the compiler to find the exact references that need to be changed when invoking a refactoring rather then a using a simple search and replace. The goal being that when you invoke a refactoring, you can trust that it's change the right code. For more information, you might want to see Jay Bazuzi's blog which can provide more detail into how we've implemented refactoring.Also, you can find the source code for the entire project, including the GetGoogleImages code here.
Thanks,
-Dan
Tyko,
We haven't announced when Beta 2 will be available yet, stay tuned....
Gimped,
I hear what you're saying with not explaining try/catch, but what I was trying to show was how the tool makes adding try/catch statements easier rather then best practices for try/catch. The ResetForm method doesn't have an "expected" exception so I set it as System.Exception to catch any exception. I was going to add the try/catch code for the WebRequest where I could catch the System.Net.WebException type and see if the error was a 404 error, but it involved lots more time, code and might have been confusing for someone who hasn't programmed with the System.Net namespace before.
Thanks,
-Dan
I was itching to say thanks, but the slow connection wouldn't let me. Finally, I've made my way through.
Like always, you guys are amazing. I gather you put up the link to the zipped source code only after my post? Amazing! Thanks a big bunch, Dan.
It comes as news to me, and in that a pleasant one that I can run VS Express on Windows 2000 as well. Thanks for that info. I really didn't know that. I recollect reading something about...but never mind. I am way too forgetful.
I actually tried installing both, VB Express as well as VC# Express Editions on my PC around the time the betas were released. Also scraped through the instructions that said it appears to hang after the first reboot, while installation. But when I tried, it looked as though it had hung even prior to the first boot. There was a blank progress bar, and after a seemingly endless wait, no progress. So, I dropped the idea.
I thought if there have been major changes to the .NET Base Class Libraries, then I might as well stick to .NET 1.1, because I'm supposed to be doing a project on VC# with VS2003 in this month or the next. We've already started. So I didn't chase the idea.
Thanks again, Dan. I am excited about the way you guys are treating us all on Channel 9. In general, I'm overwhelmed by the responses and the attitude Microsoft employees have towards others. I guess that is another trait that makes people like Microsoft.
One wish for refactoring stuff: I would like new code to not only appear at the end of the code file (per class) but the ability to route auto-gen'ed code to regions would be great as well.
Another wish: to be able to sort any block of lines of code alphanumerically.
More VS express stuff please
Maybe a video on how to save data in different ways like, databases, textfiles, inis, the registry, xml files and/or any other method(s).
Is the final version going to be a free download or will it cost money?
C# is pretty fun i must say, tough a bit hard to learn when the only prior "programming experience" you have is asp, php and mirc script.
But it will probably be much easier when the help is done.
That almost cracked me up until I read it again and noticed the word block, and I understood it must mean the ability to sort Region directives alphanumerically.
I thought somene was asking the IDE to be able to sort source code lines alphanumerically.
And just out of curiosity I stopped by the MS recruiting center and they had some convention thing at the park? what was that all about...
I added another couple of worker methods so that the program is more asynchronous. I got rid of the progress bar and made the images populate the image list as they are being retrieved. When it has fetched all the thumbnails the program then goes and fetches all the higher resolution images. You can click on an image in the imagelist at any time and it will either display the thumbnail or the high resolution image if it has been retrieve by then.
I also added the ability to save the high resolution mages to your harddrive.
It's only the second thing I've ever written in C# so forgive me if I've made some terrible mistake. Any comments would be appreciated.
My modified code is here
I use Arial Black (size 14). It's a very readable font from a far distance because of it's thickness and it's my preferred demo font.
Thanks,
-Dan
I am a very basic programmer.
Any help would be great
I think the best way to allow the copy ability is to add a context menu option called Copy Image and then set its click Event code to the following:

private void copy_click(object sender, EventArgs e)
{
ClipBoard.SetDataObject(detailedPicture.Image,true);
}
I might add this only copies the image thats in the detailedPictures box AKA the big picture
This will allow you to paste into what ever...
Visual C# Express Edition features are really cool... Code maintainability and development are still more easy. Its great.
localhost.GalleryComponentDataSet myset=(localhost.GalleryComponentDataSet)e.Argument;
// int progress = 0;
// BackgroundWorker worker = sender as BackgroundWorker;
// worker.ReportProgress(progress++);
//Load images
foreach (localhost.GalleryComponentDataSet.PicsRow row in myset.Pics)
{
try
{
error here-->>Stream ImageStream = new WebClient().OpenRead("http://localhost/newalpha/"+String.Format("ViewPhoto-{0}.aspx?Width=50",row.ID));
Image img = Image.FromStream(ImageStream);
//UrlAndImage.Add(System.Configuration.ConfigurationSettings.AppSettings["WebsitePath"] + String.Format("ViewPhoto-{0}.aspx", row.ID), img);
UrlAndImage.Add("http://localhost/newalpha/"+ String.Format("ViewPhoto-{0}.aspx", row.ID), img);
}
catch
{ }
finally
{
// worker.ReportProgress(progress++);
}
}
//Send result back to Form
e.Result = UrlAndImage;
Stream ImageStream = new WebClient().OpenRead("http://localhost/newalpha/"+String.Format("ViewPhoto-{0}.aspx?Width=50",row.ID));
I just want to be clear on that line of code...
great job, congratulations Dan!
i want to have it now!!!
Anthony
http://www.mentores.net
So the error is when i try to open the GoogleForm.cs in Designer wiew
"""Warning 1 The designer cannot process the code at line 117:
this.googleToolStrip.Raft = System.Windows.Forms.RaftingSides.Top;
The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. C:\Documents and Settings\sivnovagod\Desktop\googim3\GoogleImagesSample\GoogleForm.Designer.cs 118 0
"""
I also get a build error
"""Error 2 The type or namespace name 'RaftingContainer' does not exist in the namespace 'System.Windows.Forms' (are you missing an assembly reference?) C:\Documents and Settings\sivnovagod\Desktop\googim3\GoogleImagesSample\GoogleForm.Designer.cs 314 38 GoogleImagesSample"""
Do you know a way around this?
Id be very grateful for your help.
Cheers
Ivan Simurina
Hey Ivan,
Sorry for not responding sooner, but there is an updated version that works with the final release of Visual C# Express available here.
Thanks,
-Dan
Dear Sir
i have downloaded the code and tried to run it but it gives following error , pl help me
Ajay
Warning 1 The designer cannot process the code at line 117:
this.googleToolStrip.Raft = System.Windows.Forms.RaftingSides.Top;
The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. C:\Documents and Settings\Administrator.AJAY\Desktop\GoogleImagesSample_final\GoogleImagesSample\GoogleForm.Designer.cs 118 0
Cab anybody share source code? Lnks are broken :(
Remove this comment
Remove this thread
close