Results 1 to 14 of 14

Thread: [2008] [WPF] Stick an image on top of another

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    [2008] [WPF] Stick an image on top of another

    In my WPF application I want to display items on a map, but since the map is rather large, it is scrollable.
    My questions are:
    * How do I display an image on top of my map?
    * How do I make sure that when the map is scrolled, the items scrolls too?

    Thanks in advance....

  2. #2
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: [2008] [WPF] Stick an image on top of another

    You could use the <InlineUIComponent> tag which places 1 child in another control but then you can uses multiple InlineUIComponents. Il fire up VS now and have a play around and see what we come up with, PS ive asked a mod to move this to the new WPF board k!

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [2008] [WPF] Stick an image on top of another

    Moved

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] [WPF] Stick an image on top of another

    I think I mentioned this in your previous thread but one of the samples that comes with Microsoft Expression Blend 2 has a very similar feature to this so I'm sure you could 'borrow' some ideas from that
    Let me know if you dont have blend and I'll try post the relevant bits of the sample
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: [2008] [WPF] Stick an image on top of another

    Ok so I have been playing around with the Inline UI container and it seems that you can only use it with flow documents. I was thinking though a grip clips all items at its borders right? so what you could do is place a grid over the picture and create some logic to scroll the items, once they reach the borders of the grid they will clip.

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] [WPF] Stick an image on top of another

    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  7. #7
    Frenzied Member
    Join Date
    Jul 2008
    Location
    Rep of Ireland
    Posts
    1,380

    Re: [2008] [WPF] Stick an image on top of another

    That's an amazing example man! good job

  8. #8
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] [WPF] Stick an image on top of another

    I know I was amazed when I saw how little code was required!
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: [2008] [WPF] Stick an image on top of another

    Thanks Chris, but a thumbnail was the subject of the previous question I posted. I'll defintely steal this XAML though, it's too good to ignore....
    Any thoughts on the sticking images on a map and have them scroll with the map?

    [edit]
    I could use some explanation on the second link you posted... What's this ControlTemplate stuff he's talking about?
    [/edit]
    Last edited by Hamish; Jan 27th, 2009 at 04:29 AM.

  10. #10
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] [WPF] Stick an image on top of another

    Oh right sorry I thought you meant you were just struggling to get the images to move with the mini-map / thumbnail.

    Well, how do you want to place these images on the map, dynamically or will they just always stay in the same place? Also, will they need to be there when the app is launched or are they going to be created and added to the map at runtime
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: [2008] [WPF] Stick an image on top of another

    Let me explain what I'm building here, it will probably clear up a lot of things. I'm afraid I'll be asking a lot of questions for this project, so the more people who know what I'm trying to do, the better.

    I'm trying to make a front-end application for a text-based Play-By-Email game. It's a WW2 setting, and involves a rather large map (approx. 2000 irregularly shaped areas), a pretty complex economy system and many military options. (I love this game! ) In a previous project I have built a new order entry program for the same game where you could select all applicable options from ComboBoxes etc. I would like to take this a step further and try to build a true GUI for it.
    The program would have to read turn result files, build a database from them and then display everything nicely on the map. Next step would (for example) enable you to just drag army-indicator-icons over the map and have the program build an order file for you.
    Since the graphics part is new to me (and therefore the most interesting) I wanted to start by just displaying the map and display game information on it. As a first step I just want to see if I can make icons appear on the map before I start thinking about anything else.

    So to get back to your questions:
    I want to display different kinds of icons in different situations, depending on what the user wants to see (armies, air forces, navy forces, industries, stockpiles), so they would definitely need to be added at run-time. When the user switches 'modes' all icons would need to be removed or hidden and new ones created or unhidden. So icons would not move on the map by themselves, but in the end some may be draggable.

  12. #12
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] [WPF] Stick an image on top of another

    hmmm ok, gives me a lot to think about! I'll try put something together that just displays images on a map as a starting point and get back to you
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  13. #13
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] [WPF] Stick an image on top of another

    OK, I've got something going at that might help a little as a starting point.

    First things first, lets create a canvas that we can place our images on.
    Code:
    <Canvas Name="MapCanvas" Margin="0,0,0,90" >
    </Canvas>
    Now we need to set the background of this canvas to the image of the map, we can do that by using the ImageBrush like so:
    Code:
    <Canvas Name="MapCanvas" Margin="0,0,0,90" >
                <Canvas.Background>
                    <ImageBrush ImageSource="c:\map.bmp" />
                </Canvas.Background>
            </Canvas>
    Note that we could do the same thing in code by doing this:
    vb Code:
    1. MapCanvas.Background = New Windows.Media.ImageBrush(New Imaging.BitmapImage(New Uri("c:\map.bmp")))
    But I much prefer to do it through the XAML code

    So we have our map now, lets add an image to it dynamically through our vb code. In this example I've made a stick man image and will use that
    vb Code:
    1. Dim personimage As New Image
    2. personimage.Source = New Imaging.BitmapImage(New Uri("C:\person.bmp"))
    3. personimage.Margin = New Thickness(10, 50, 10, 10)
    4. MapCanvas.Children.Add(personimage)

    So there we go, we end up with a little map (in my example I just made the map a red square) and a little person on the map!

    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Location
    Zeist, The Netherlands
    Posts
    266

    Re: [2008] [WPF] Stick an image on top of another

    Looks good Chris. Good idea to use a Canvas instead of an image.
    Little time to play with it now, hope to have some more later on.

Posting Permissions

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



Click Here to Expand Forum to Full Width