Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Dan Fernandez - Demo of C# Express (pull images from Google)

Download

Right click “Save as…”

Dan Fernandez, here, demonstrates how to build a cool little application in Visual C# Express Edition (you can download that from the Channel 9 Express site). 

Follow along as Dan takes you through the demo's source code and gives you a visual tour of C# Express.

Make sure while you are at it you submit an application to Channel 9's Summer of Express contest for a chance to win an XBox, Halo 2 and a year of Xbox live.

Follow the Discussion

  • moofishmoofish Living in Scotland, UK
    i used to program a little, nothing serious. However I can see that these features look really good - really productive - well done.

    samuel
  • How super cool!  The more I see the more I like C# Express!

    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!
  • Dan FernandezDan
    Thanks Samuel and Geoff, definitely appreciate it Smiley

    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
  • Thank you! great show! Smiley C# Express realy rocks, any news on next beta?
    keep the good work

    /Tyko
  • Nice post. Though I do not have either of the two required OS (XP or Windows 2003 Server) to run the Express Editions of VC# or VB, I'd like to see the code that gets the return string from the HTML query passed to Google. Can you guys please post the code for the GetGoogleImages() function?

    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.
  • GimpedGimped @caption goes here@
    Kind of unfortunate that when Dan was demonstrating the IntelliSense Try Catch feature that he set the exception as System.Exception. A missed opportunity to teach newbie programers a best practice of not catching System.Exception.
  • Dan FernandezDan
    Thanks Sathyaish,

    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   

  • Dan FernandezDan

    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 

  • Hello, 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.
  • rasxrasx Emperor of String.Empty
    This is the first great C# Express demo' shown on this site. Well done!

    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 Smiley

    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.





  • hi, here can you find a very nice video by Dan(the man) how to save data in database, textfiles and xml http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20040219csharpdf/manifest.xml have fun!
  • rasx said:

    Another wish: to be able to sort any block of lines of code alphanumerically.

    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. Wink
  • crispybitcrispybit Mr. Crispy himself
    Hehe looks great! keep up the great work all you guys on the C# and whidbey teams. Im up here in redmond as I write this, visiting the U of W and MS. I look forward to working with you guys some day. Big Smile

    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...

  • eddwoeddwo Wheres my head at?
    I just had a play around with this and made various changes.

    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
  • What font is it that they are using for these demos? They really stand out and could come in handy sometimes.
  • b0bb0b
    C# is very useful. I know C, so it made more sense to learn C# instead of VB. I still use C when I write console applications (its just faster to code), but for Windows apps, C# is my pick.
  • Dan FernandezDan
    Hi Wukkuan,

    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
  • Hi i've just built the Google image searcher for my students and I was wondering how to intergrate the copy and paste functions into the app, so when they do a search for images using this app they can copy from the app and then they can paste the image that they copied into another app like MS Word2003.

    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 Smiley

    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.

  • I'm trying to duplicate the demo's functionality, but i keep getting threading access errors on my dowork function. As far as i can tell, nothing is accessing the main thread, but it keeps claiming that i am.

    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;

  • my question is why are you passing in two vars??

    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...
  • very very nice demo!

    great job, congratulations Dan!

    i want to have it now!!!

    Anthony
    http://www.mentores.net
  • Thanks for the cool demo! I can't wait for Whidbey to be released!
  • Hello Dan, great application you made some time ago, its really interesting , i m having some difficult time trying to get it to work in newest Visual C# Express so i thought maybe you could help me solve this error.

    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
  • Dan FernandezDan
    sivko23 wrote:

    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 

  • kdvkdv

    Cab anybody share source code? Lnks are broken :(

Remove this comment

Remove this thread

close

Comments Closed

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.