Posted by paulpleasant on 4/15/2010 3:16 AM | Comments (4)

In Gagglefish Expeditions we let users add images from our library of images or upload their own images. They can move and resize images, crop images, and apply visual affects to images.

One of the business rules associated with tracking images was keeping track of an images height and width properties as well as the top and bottom properties. The process is very straightforward but it took a few minutes to get it right so I thought I would document it here for others to use.

The sample demo uses an adorner sample from http://nokola.com/blog/post/2009/12/13/Adorners-in-Silverlight-Move-Size-Rotate-Custom-Mouse-Cursor.aspx If you have not already checked out nokola.com, do so. There is a ton of very useful code on the site.

First we need to subscribe to an event so we can get the values we need. There are several events we could have used but the MouseLeftButtonUp event on the adorner works fine so I decided to use it.

_adorner.MouseLeftButtonUp += new MouseButtonEventHandler(_adorner_MouseLeftButtonUp);

 Then we get the values for the image.

void _adorner_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            textBlockWidth.Text = ImageTest.ActualWidth.ToString();
            textBlockHeight.Text = ImageTest.ActualHeight.ToString();
            textBlockTop.Text = Canvas.GetTop(ImageTest).ToString();
            textBlockLeft.Text = Canvas.GetLeft(ImageTest).ToString();
        }

Demo

That's all there is to it. You can then save the values for future sessions either remotely or using local storage. In our case, I wrote a simple compression algorythm so we could store the values in a string in our SQL Server 2008 R2 database.

Comments

New Balance Shoes
New Balance Shoes Sri Lanka on 7/28/2010 7:36 PM Wow that's interesting. Good news though, they make easy to use bikini hair removal creams. They work just as good as a wax for women who still want to be clean down there.
http://www.yaahshoes.com/
newsletter ideas
newsletter ideas United States on 8/18/2010 4:00 PM You seem to have a lot of experience with this seeing how knowledgeable you are. I find this information extremely interesting and valuable, thanks for posting.
Retro Jordans
Retro Jordans United States on 8/19/2010 7:02 PM Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for.
Apad
Apad People's Republic of China on 8/23/2010 3:26 PM Thanks for your useful information.http://www.efox-shop.com

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading