locked
Graphics and Scroll RRS feed

  • Question

  • Hi,

    I am pretty new to C# and GUI programming in general. I have a few graphics to draw. I figure that I should draw them on Panels (since they come with scrollbars). I want it so that when graphics are drawn on the panels beyond the visible regions, scrollbar would be shown. But it does not work automatically by simply drawing things beyond the region. What's the best way to implement it? Is it by setting AutoScrollMinSize?

    And a second question. Suppose I am implementing something similar to PowerPoint. Should I be using GDI to draw and implement my own custom controls since there is no such thing as the "slide" control? I just want to have an idea on how GUI is suppose to be programmed. I can imagine pulling together buttons, list, menus to make an application like Outlook Express. But for many other applications it doesn't seem to be as simple.

    Thanks,

    Timothy
    Monday, June 11, 2007 10:47 AM

Answers

  • As for your second question, I wouldn't recommend using GDI as I imagine that would get complicated.  Making a PowerPoint application is going to be difficult.  Since there is no "slide" control you'll basically have to make your own.  I could image starting with creating a custom control something like SlideControl and then some sort of SlideControlManager class that manages your control, it could keep track of a collection of TextBoxes and graphics that belong to your slide and it would let you add and remove these where needed.  If you really need to get fancy it could even use timers to control the position of the TextBoxes and graphics so that you could do some simple animations.  Creating GUI's are complicated, and power point is more complex than some might first imagine.
    Monday, June 11, 2007 2:23 PM

All replies

  • Hi,

    The answer the first question is set the AutoScroll property of the Panel to 'true'.

    Sample:

    this.panel1.AutoScroll = true;
               
    Monday, June 11, 2007 12:20 PM
  • As for your second question, I wouldn't recommend using GDI as I imagine that would get complicated.  Making a PowerPoint application is going to be difficult.  Since there is no "slide" control you'll basically have to make your own.  I could image starting with creating a custom control something like SlideControl and then some sort of SlideControlManager class that manages your control, it could keep track of a collection of TextBoxes and graphics that belong to your slide and it would let you add and remove these where needed.  If you really need to get fancy it could even use timers to control the position of the TextBoxes and graphics so that you could do some simple animations.  Creating GUI's are complicated, and power point is more complex than some might first imagine.
    Monday, June 11, 2007 2:23 PM
  • I did set AutoScroll to true, but it doesn't seem to work.
    Monday, June 11, 2007 3:24 PM
  •  

     Scroll your image its not that easy. To make an image scroll on a PictureBox for example, you have to add ScrollBars controls. Then calculate how much of your image was cut off and set it as the scrollBar value.

     

     And finally to scroll your image you should change the image position inside the PictureBox control, based on the ScrollBar movement. I'v e tried with panels before but i felt easier to work with the PictureBox.

     

    Bruno

    Monday, June 11, 2007 7:51 PM
  • How are you drawing graphics in your panel?  The autoscrolling will give you scrollbars if some control inside your panel is larger than the panel itself.  If you were overriding the paint method of the panel and drawing lines outside the visible region then you probably won't get scroll bars.  Maybe create some sort of CanvasControl object that inherits from control and then whenever you do the painting you can resize the object to be big enough to contain the entire drawing you plan to do.  Then you could put the CanvasControl in the panel you want to have scroll bars.  When the CanvasControl gets too big for the panel the panel will automatically create scroll bars.
    Monday, June 11, 2007 8:32 PM