Results 1 to 16 of 16

Thread: [RESOLVED] Multiple object movement control array

  1. #1

    Thread Starter
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Resolved [RESOLVED] Multiple object movement control array

    Hi guys.

    I am trying to make a dock menu with WPF but my question is on VB.NET side. Anyway, basically I want some kind of a control array but I don't know how to write it.

    I have objects in dock are called _1, _2, _3, etc... from left to right. In WPF they are images. On solution explorer they appear as "_1 As Image".
    Mainly, what I need is:

    Code:
    Sub ImgCntrl(i As Integer)
        For Each Image in MainWindow
            With Me("_" & i)
                If object control name < i Then 'If the object is at left hadside of the initial object
                    Move those objects 100 pixel Left
                End If
                If object control name = i Then 'If the object is the initial object
                    Move that object 100 pixel Up
                End If
                If object control name > i Then 'If the object is at right hadside of the initial object
                    Move those objects 100 pixel Right
                End If
             End With
         Next
    End Sub
    
    Private Sub _1_MouseEnter(sender As Object, e As MouseEventArgs) Handles _1.MouseEnter
       ImgCntrl(1)
    End Sub
    
    Private Sub _2_MouseEnter(sender As Object, e As MouseEventArgs) Handles _1.MouseEnter
       ImgCntrl(2)
    End Sub
    
    Private Sub _3_MouseEnter(sender As Object, e As MouseEventArgs) Handles _1.MouseEnter
       ImgCntrl(3)
    End Sub
    Now this will rise the moseovered (there is no MouseHover in WPF thus is MouseEnter) object 100 pixel up while pushing the other objects to left and right. It will bring a dock like menu effect.

    Who may help me for the right expression?

    Thanks a lot!!!
    Last edited by Flashbond; Jun 7th, 2013 at 09:45 AM.

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Multiple object movement control array

    I don't understand enough about what you are trying to do to help you with the "right expression". But this may help you along a bit:

    1. Since you want to reposition your images, it's best to put them in a Canvas control instead of directly in the main window. You can add your Image controls to the Canvas in the WPF designer, or insert them at run time with Canvas.AddVisualChild.

    2. Then you can use Canvas.GetLeft, Canvas.GetTop, Canvas.SetLeft and Canvas.SetTop to get and change the image X and Y positions. For example, if the canvas is Canvas1, you could move the image _1 100 pixels to the left like this:
    Code:
    Dim X As Double = Canvas1.GetLeft(_1)
    Canvas1.SetLeft(_1,  X - 100)
    BB

  3. #3

    Thread Starter
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: Multiple object movement control array

    This can be ok too, but in your example since you can define a property control for only the initial object (it doesn't matter whether it is a canwas or an image).

    What I am looking for is to define all the needed property controls for an "i" integer and put the same sub to all events.
    Last edited by Flashbond; Jun 5th, 2013 at 07:39 AM.

  4. #4
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Multiple object movement control array

    Personally, I'd put the items in a horizontally oriented stack panel and accomplish the movement by having a property trigger on the images themselves to set a style with a bottom and left/right margins.

  5. #5

    Thread Starter
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: Multiple object movement control array

    Quote Originally Posted by Evil_Giraffe View Post
    Personally, I'd put the items in a horizontally oriented stack panel and accomplish the movement by having a property trigger on the images themselves to set a style with a bottom and left/right margins.
    For WPF, it is very slow with event triggers for 52 images. I want to try the same thing with VB.NET.

  6. #6
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Multiple object movement control array

    Hello,

    Since this is a WPF related question, I am going to move this thread to the WPF Forum. Please let me know if you have any questions.

    Gary

  7. #7

    Thread Starter
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: Multiple object movement control array

    No, Gary. You are right. You may move. It is mostly WPF related.

  8. #8
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: Multiple object movement control array

    Quote Originally Posted by Flashbond View Post
    For WPF, it is very slow with event triggers for 52 images. I want to try the same thing with VB.NET.
    Not sure if you understood my point. If you change the margins only on the image which is being moused over, then that's one event firing at a time, which shouldn't have WPF breaking a sweat. The WPF layout mechanism will move the surrounding images to the left or the right to make room for the additional margins, you don't need to trigger anything on those images.

  9. #9

    Thread Starter
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: Multiple object movement control array

    ?! Really? I have to try...

  10. #10

    Thread Starter
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: Multiple object movement control array

    Quote Originally Posted by Evil_Giraffe View Post
    Not sure if you understood my point. If you change the margins only on the image which is being moused over, then that's one event firing at a time, which shouldn't have WPF breaking a sweat. The WPF layout mechanism will move the surrounding images to the left or the right to make room for the additional margins, you don't need to trigger anything on those images.
    No, it didn't. Yeah, it expands margin without pushing or moving a thing.
    Last edited by Flashbond; Jun 7th, 2013 at 09:54 AM.

  11. #11

    Thread Starter
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: Multiple object movement control array

    Here is my project:

    http://speedy.sh/BN5bx/Game.rar
    rarpass: game

    I tried it with the first image as you can see but nothing happened. Please, make it with the same image as an example then I may continue it.

  12. #12
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Multiple object movement control array

    Hello Flashbond,

    This is a compiled exe that you are sharing, and this is not allowed as per our AUP.

    Please change this link for the source code of the application, or remove the link completely.

    Thanks

    Gary

  13. #13

    Thread Starter
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: Multiple object movement control array

    Quote Originally Posted by gep13 View Post
    Hello Flashbond,

    This is a compiled exe that you are sharing, and this is not allowed as per our AUP.

    Please change this link for the source code of the application, or remove the link completely.

    Thanks

    Gary
    No, I am quite sure that it contains neither compiled .exe nor another file with .exe extension. The rar contains only project files. You should review it more strictly. I refuse to change or remove the link because of "it contains a compiled .exe". But if you have another rule infringement determination then I will reconsider again.

    Regards.
    Last edited by Flashbond; Jun 8th, 2013 at 08:42 AM.

  14. #14
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Multiple object movement control array

    Hmmm, apologies. I was looking at the Gamer.rar.exe which is linked at the bottom of the page.

    Gary

  15. #15

    Thread Starter
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: [RESOLVED] Multiple object movement control array

    Noprob Gary. You are still my favourite Moderator

  16. #16
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Multiple object movement control array

    Quote Originally Posted by Flashbond View Post
    Noprob Gary. You are still my favourite Moderator
    Ha ha, thanks!

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