Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    2,882

    Updateing a winforms progressbar

    Hey guys
    A friend and me whipped up a simple little Project Packer utility to easily distribute source code from Visual Studio projects.
    Basically takes in the solution or project file, and makes a neat archive (.zip) for distribution.
    Of course for ease of use we want to use a GUI on it

    And it works.. but the leatest feature has us puzzled

    While the packer is creating the archive it would be nice to display the progress to the user in a messagebox and a progressbar. However this is the layout.

    Form1.cs of course holds the form stuff
    Pack.cs holds the methods for creating an archive and is called with arguments of the target directory, root directory (for including files above the solution root), and a String list of input files).

    When we click the "pack" button we have the whole getting the list of files, and calling the packer with the right arguments under the 'click' event for this.
    However my problem is to get the progress bar and/or messagebox to update status as the archive is created.


    I tried calling an update method i made in form1 from the pack method, but it wont allow me to do so Either i am missing something right in front of me or it cannot be done.. i belive its option number 1

    Hope i wasn understandable in the description ..i am commenting the source code for release so though its messy somebody could take a look later perhaps. But i dont get why it isnt possible to interact with the progressbar outside of Form1.cs. Because i cannot find any event that will update it step by step when i call the pack method on button click and its located elsewhere.
    Swoop - Buzzed Pirate!
    " If nobodys talking to me, im talking to me" - Swoop

    Reflection Design || Swoops Blog

    2D Tutorials Compilation

    The Speed Painting Thread || ((post your Concept Art thread))


  2. #2
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    When you do the packing, what are you using to do the zip?

    if you have a list of files and you add them 1 by 1 you could update the progress bar per file
    if you only send it "*.*" for example, then if it doesnt have events to hang off, that could be harder as theres no obvious way of telling how far it got.
    You could just show an animated "Doing something" till it finishes?
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  3. #3
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    2,882
    I have a list and i pack them 1 by 1 in the pack method.
    I basically creates an archive, and adds the files one at a time, and its this event that i want to update the progress bar.

    But so far i have read what i can and the packing method has no knowledge of a progress bar in existence, and then progress bar only sees the call to pack() not the inner workings of packing 1 file at a time.

    So at my current stance i can either update the progress from 0 to 100 in 1 step or not update at all

    But seems that apparently something with Delegates (which i know nothing about) is what i am looking for.

    That the pack() method can somehow fire an event after each file is packed in the loop.
    Swoop - Buzzed Pirate!
    " If nobodys talking to me, im talking to me" - Swoop

    Reflection Design || Swoops Blog

    2D Tutorials Compilation

    The Speed Painting Thread || ((post your Concept Art thread))


  4. #4
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    2,882
    Premature enlightenment!
    I now see the outlines of my solution. apparently i am looking at my first stab at creating my own events and delegates .. but i dont see the full solution yet
    Swoop - Buzzed Pirate!
    " If nobodys talking to me, im talking to me" - Swoop

    Reflection Design || Swoops Blog

    2D Tutorials Compilation

    The Speed Painting Thread || ((post your Concept Art thread))


  5. #5
    Join Date
    Nov 2006
    Location
    UK
    Posts
    3,774
    Well events and delegates are the better answer however, in your loop to send the files you could of course take either the quantity of files and work on progress as that, or, take the file sizes of all the files, and use that as your progress and just updated it at the end of each completion.
    Delphi !ROCKS!
    Got a question? Read this first!!!
    "You gotta help us, Doc. We've tried nothin' and we're all out of ideas"

  6. #6
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    2,882
    I cant get that working. If i try and call either the progressbar directly from my packing loop i get an error. Its not able to find it.

    Tried everything i can think of because simply updating after each file is written is what i really want to be able to do. I am trying to figure out about delegates but i cant get it working .. cant wrap my head around it right now

    What i have read i need to have the packing loop fire an event that i can use in the progress bare to update it. But i dont know the specifics of how to do that yet
    Swoop - Buzzed Pirate!
    " If nobodys talking to me, im talking to me" - Swoop

    Reflection Design || Swoops Blog

    2D Tutorials Compilation

    The Speed Painting Thread || ((post your Concept Art thread))


  7. #7
    Join Date
    Aug 2004
    Location
    little rock arkansas
    Posts
    3,482

    Talking

    Quote Originally Posted by Swoop View Post
    I cant get that working. If i try and call either the progressbar directly from my packing loop i get an error. Its not able to find it.

    Tried everything i can think of because simply updating after each file is written is what i really want to be able to do. I am trying to figure out about delegates but i cant get it working .. cant wrap my head around it right now

    What i have read i need to have the packing loop fire an event that i can use in the progress bare to update it. But i dont know the specifics of how to do that yet
    have you watched the Delegates Videos from the XNA class??
    ME WANT AGENTS ME WANT AGENTS ME WANT AGENTS

  8. #8
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    2,882
    No i wasnt in the class, and i havent gotten vol 3 yet
    Swoop - Buzzed Pirate!
    " If nobodys talking to me, im talking to me" - Swoop

    Reflection Design || Swoops Blog

    2D Tutorials Compilation

    The Speed Painting Thread || ((post your Concept Art thread))


  9. #9
    Join Date
    Aug 2004
    Location
    little rock arkansas
    Posts
    3,482

    Talking

    Quote Originally Posted by Swoop View Post
    No i wasnt in the class, and i havent gotten vol 3 yet
    well you should get them then
    they are great
    ME WANT AGENTS ME WANT AGENTS ME WANT AGENTS

  10. #10
    Join Date
    Mar 2003
    Location
    Denmark
    Posts
    2,882
    Quote Originally Posted by ostamo2 View Post
    well you should get them then
    they are great
    I already have... but still doesnt help me right now
    Swoop - Buzzed Pirate!
    " If nobodys talking to me, im talking to me" - Swoop

    Reflection Design || Swoops Blog

    2D Tutorials Compilation

    The Speed Painting Thread || ((post your Concept Art thread))


Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •