Click here to Skip to main content
15,920,603 members
Home / Discussions / C#
   

C#

 
GeneralRe: Setting the "Address" of INternet Explorer through C# Pin
Abhi210428-Jun-07 20:57
Abhi210428-Jun-07 20:57 
AnswerRe: Setting the "Address" of INternet Explorer through C# Pin
Abhi210428-Jun-07 20:53
Abhi210428-Jun-07 20:53 
QuestionCrystal Report problem Pin
phantanagu28-Jun-07 17:27
phantanagu28-Jun-07 17:27 
QuestionHow many iamges can ImageList contain? Pin
jason_mf28-Jun-07 16:35
jason_mf28-Jun-07 16:35 
AnswerRe: How many iamges can ImageList contain? Pin
Martin#28-Jun-07 19:54
Martin#28-Jun-07 19:54 
AnswerRe: How many iamges can ImageList contain? Pin
Vikram A Punathambekar28-Jun-07 21:24
Vikram A Punathambekar28-Jun-07 21:24 
Questionpriority on background threads Pin
urbane.tiger28-Jun-07 16:23
urbane.tiger28-Jun-07 16:23 
AnswerRe: priority on background threads Pin
Jimmanuel29-Jun-07 0:58
Jimmanuel29-Jun-07 0:58 
GeneralRe: priority on background threads Pin
urbane.tiger4-Jul-07 21:31
urbane.tiger4-Jul-07 21:31 
QuestionC# How to display a PDF file from Windows app? Pin
mperazac28-Jun-07 16:04
mperazac28-Jun-07 16:04 
AnswerRe: C# How to display a PDF file from Windows app? Pin
Vikram A Punathambekar28-Jun-07 17:53
Vikram A Punathambekar28-Jun-07 17:53 
AnswerRe: C# How to display a PDF file from Windows app? Pin
Albu Marius28-Jun-07 21:53
Albu Marius28-Jun-07 21:53 
AnswerRe: C# How to display a PDF file from Windows app? Pin
Giorgi Dalakishvili28-Jun-07 23:40
mentorGiorgi Dalakishvili28-Jun-07 23:40 
GeneralRe: C# How to display a PDF file from Windows app? Pin
mperazac29-Jun-07 7:39
mperazac29-Jun-07 7:39 
GeneralRe: C# How to display a PDF file from Windows app? Pin
Giorgi Dalakishvili1-Jul-07 20:29
mentorGiorgi Dalakishvili1-Jul-07 20:29 
QuestionImage Processing Pin
james_dixon_200828-Jun-07 11:12
james_dixon_200828-Jun-07 11:12 
AnswerRe: Image Processing Pin
Luc Pattyn28-Jun-07 11:28
sitebuilderLuc Pattyn28-Jun-07 11:28 
GeneralRe: Image Processing Pin
james_dixon_200828-Jun-07 11:44
james_dixon_200828-Jun-07 11:44 
GeneralRe: Image Processing Pin
Christian Graus28-Jun-07 11:47
protectorChristian Graus28-Jun-07 11:47 
GeneralRe: Image Processing Pin
james_dixon_200828-Jun-07 12:08
james_dixon_200828-Jun-07 12:08 
GeneralRe: Image Processing Pin
Luc Pattyn28-Jun-07 12:33
sitebuilderLuc Pattyn28-Jun-07 12:33 
AnswerRe: Image Processing Pin
Amar Chaudhary28-Jun-07 12:30
Amar Chaudhary28-Jun-07 12:30 
AnswerRe: Image Processing Pin
gumi_r@msn.com29-Jun-07 4:37
gumi_r@msn.com29-Jun-07 4:37 
QuestionScrollProperties.Value needs to be set twice? Pin
PhilDanger28-Jun-07 11:12
PhilDanger28-Jun-07 11:12 
Hey all,

I've got some C# code that zooms in on an image contained in a Panel, and moves that panel's scroll bars to center on the place that was clicked on with the zoom tool. However, when I set the Value property of the ScrollProperties as shown below, the value stays the same unless I execute the same code twice in a row, as shown below. If I do it only once, it will center correctly, but the actual scroll bars will not move until the next set of the .Value property. Any ideas why?


/// <summary>
/// Positions the vertial and horizontal scroll bars by the given X and Y offsets
/// </summary>
private void CenterScrollBars(int X, int Y)
{
    //horizontal scroll bar first
    HScrollProperties hsp = MainPanel.HorizontalScroll;
    if (hsp.Visible) //if we don't have a scroll bar, don't try moving it!
    {
        //calculate the offset to move the scroll bar in order to center on the clicked point
        //since the point uses the DrawingBox's coordinate system, we need to move it into the
        //containing panel's coordinate system first by doing a shift
        int offs = (X + DrawBox.Location.X) - (MainPanel.Width / 2);
        MoveScrollPosition(hsp, offs);
    }
    //vertical next
    VScrollProperties vsp = MainPanel.VerticalScroll;
    if (vsp.Visible)  //if we don't have a scroll bar, don't try moving it!
    {
        //same idea as above
        int offs = (Y + DrawBox.Location.Y) - (MainPanel.Height / 2);
        MoveScrollPosition(vsp, offs);
    }



}

/// <summary>
/// Moves the scroll bar by the specified offset, clamping to min or maximum if needed
/// </summary>
/// <param name="sp">The scroll bar to move</param>
/// <param name="offset">The offset by which to move the scroll bar.</param>
private void MoveScrollPosition(ScrollProperties sp, int offset)
{
    int val = sp.Value + offset;
    //clamp the value to the min and max values of the scroll bar
    if (val < sp.Minimum)
    {
        val = sp.Minimum;
    }
    else if (val > sp.Maximum)
    {
        val = sp.Maximum;
    }
    sp.Value = val;
    sp.Value = val; //TODO -- investigate this problem, scroll bar position not updated properly unless this is done twice
}


Thanks!
AnswerRe: ScrollProperties.Value needs to be set twice? Pin
Luc Pattyn28-Jun-07 11:35
sitebuilderLuc Pattyn28-Jun-07 11:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.