C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 307,158 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,519 people online right now. Registration is fast and FREE... Join Now!




Picture Scrolling

 

Picture Scrolling

nova2108

14 Aug, 2009 - 06:46 PM
Post #1

New D.I.C Head
*

Joined: 1 Aug, 2009
Posts: 16


My Contributions
I've created an Network IM program that can send text and also can set your "display image" for your session. Which will also send this image to the other user connected through a socket. This work perfectly. (I've been working on it for about 2 or 3 days). The problem I have is when the photo is bigger then the screen. (If it not then the program will resize it to the photo's size and display it.) If it is bigger then it will just display the image at the default size. (Which will only show a protion of the photo) I was wondering on how to add scrolling to a PictureBox so that the photo will able to be seen completly. (I don't want to resize the photo)...Can anyone help/Point me in the right direction?

Here is the code for display the photo.
CODE

public partial class ImageDialog : Form
    {
        public ImageDialog(Image image)
        {
            InitializeComponent();
            setImage(image);
        }

        /// <summary>
        /// Sets the pictureBox Image to the parameter's Image.
        /// </summary>
        /// <param name="image">Image to be set to.</param>
        private void setImage(Image image)
        {
            pictureBox.Image = image;
            TryResizeDialog();
        }

        private void TryResizeDialog()
        {
            Image displayedImage = pictureBox.Image;
            int imageHeight = displayedImage.Height + 30;
            int imageWidth = displayedImage.Width + 20;
            Rectangle imageRec = new Rectangle(0, 0, imageWidth, imageHeight);
            Rectangle screenRec = Screen.PrimaryScreen.WorkingArea;
            if (screenRec.Contains(imageRec))
            {
                this.Height = imageHeight + 40;
                this.Width = imageWidth;
            }
            else
            {
                //Adds scrolling function because picture is bigger than the screen.
            }
            
        }

        public void CloseDialog()
        {
            this.Close();
        }
    }


Thanks in advance... smile.gif

User is offlineProfile CardPM
+Quote Post



Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 05:50PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month