-
Jun 4th, 2013, 06:58 PM
#1
Thread Starter
Fanatic Member
[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.
-
Jun 5th, 2013, 06:22 AM
#2
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
-
Jun 5th, 2013, 06:42 AM
#3
Thread Starter
Fanatic Member
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.
-
Jun 5th, 2013, 10:52 AM
#4
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.
-
Jun 5th, 2013, 02:38 PM
#5
Thread Starter
Fanatic Member
Re: Multiple object movement control array
Originally Posted by Evil_Giraffe
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.
-
Jun 6th, 2013, 02:40 AM
#6
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
-
Jun 6th, 2013, 09:06 AM
#7
Thread Starter
Fanatic Member
Re: Multiple object movement control array
No, Gary. You are right. You may move. It is mostly WPF related.
-
Jun 6th, 2013, 09:52 AM
#8
Re: Multiple object movement control array
Originally Posted by Flashbond
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.
-
Jun 7th, 2013, 07:22 AM
#9
Thread Starter
Fanatic Member
Re: Multiple object movement control array
?! Really? I have to try...
-
Jun 7th, 2013, 07:37 AM
#10
Thread Starter
Fanatic Member
Re: Multiple object movement control array
Originally Posted by Evil_Giraffe
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.
-
Jun 7th, 2013, 09:54 AM
#11
Thread Starter
Fanatic Member
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.
-
Jun 7th, 2013, 11:50 AM
#12
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
-
Jun 8th, 2013, 07:28 AM
#13
Thread Starter
Fanatic Member
Re: Multiple object movement control array
Originally Posted by gep13
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.
-
Jun 8th, 2013, 01:24 PM
#14
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
-
Jun 9th, 2013, 04:11 PM
#15
Thread Starter
Fanatic Member
Re: [RESOLVED] Multiple object movement control array
Noprob Gary. You are still my favourite Moderator
-
Jun 10th, 2013, 01:56 PM
#16
Re: [RESOLVED] Multiple object movement control array
Originally Posted by Flashbond
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|