Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

It is a way for reducing this code ..maybe like 5 lines on something ??? because this is just for one image...but i have 30 of them.....and I really don't whant to multiply this code 30 times for each image..

 

I'm trying with a for..and can't make it work.

 


       If (vals1(1) > 1) Then
           If vals1(2) > 510 Then
               ianca.Location = New Point(vals1(1) + 16, vals1(2) - 80)
           End If
       End If


       If (vals1(1) > 640) Then
           If vals1(2) > 35 Then
               ianca.Location = New Point(vals1(1) - 140, vals1(2) + 16)
           End If
       End If


       If (vals1(1) > 640) Then
           If vals1(2) > 500 Then
               ianca.Location = New Point(vals1(1) - 139, vals1(2) - 79)
           End If
       End If

Posted

This will do it...

 

       For v As Integer = 1 To 30

           If (vals1(v) > 1) Then
               If vals1(v + 1) > 510 Then
                   ianca.Location = New Point(vals1(v) + 16, vals1(v + 1) - 80)
               End If
           End If

           'Fill the rest the same way...

       Next

 

 

Tell me if it worked...

Software bugs are impossible to detect by anybody except the end user.
Posted

let me tell you why I whant that.

 

I have some small pics (dots) over the large pic (map) , and for each pic I have a mouse_move for making visible a label next to the pic of course.

Those pics are put dinamicaly and with the same values I put the labels.(+20 x and +20 y) to be a little under the dot )

 

The problem apears when a dot is almost out of the main pic.If this happens th label is 90% out of the main pic, and I need something to make the label stay on the map but (the entire label)...next to the dot I hovered on.

 

I write that code to do that ..but it has 30 lines of code :) ...and this just for one dot.Imagine my source code for all labels...they are at least 25-30 of them.

 

I will try your way ....

 

thanks

Posted

I think my way will do...

 

When you have some repeated code you'll have to find the things that don't change and the things that change... and here, the ones that change are only the values on the array position...

 

I think this will work ... Tell me ok?

 

 

:D

Software bugs are impossible to detect by anybody except the end user.
Posted

hi.....don't be mad :)

 

I start using vb for 3 weeks.. :)

 

I was thinking with a beer in my hand......curios......and I realized that I can use a singe label for all my dots.

 

All I need is a function, and I call that function with parameters for location and text from text file.

 

it seams so easy......I will try it tomorow

 

 

 

soon...

  • 2 weeks later...
Posted (edited)

Hi.

 

I will try that code later... but it is possible to set something like margins for a label?

 

For ex I want to set the maximum area for displaying the label with 850x650 . If the label want to overlap the maximum area, that label to resize himself or repositioning in a way to not overlap the margins of the main area.

 

later edit:

done with a function.

Edited by Ace Master
Posted

Hi ! Long time no see...

 

You want something like the MaximumSize property of the Form control? If so, you just have to build your own inherited label and use the resize event.

 

Use this property...

   Dim _MaximumSize As System.Drawing.Size
   Public Property MaximumSize() As System.Drawing.Size
       Get
           Return _MaximumSize
       End Get
       Set(ByVal Value As System.Drawing.Size)
           _MaximumSize = Value
       End Set
   End Property

 

And in the Resize Event do the following...

 

   Private Sub myLabel1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize

       If (Me.Size.Height > Me.MaximumSize.Height) Then
           Me.Height = MaximumSize.Height
       ElseIf (Me.Size.Width > Me.MaximumSize.Width) Then
           Me.Width = MaximumSize.Width
       End If

   End Sub

 

 

This shoul do the max size trick...

 

The overlap thing I dodn't quite understood what u want!

You want to move the label if it stands out of its parent?

 

 

Tell me ! :D

Software bugs are impossible to detect by anybody except the end user.
Posted

This is what I want

 

The label appears with mouse enter for each red picture.

 

1. The normal label when the red picture in in center

 

2. The label overlap the max sizes because is to close to the max size

 

3. The label like I what to appear.

 

I made this with some functions calling parameters, bla bla..but is quite harder and lot's of code lines. I want to know if it is a simple way like a property of the label to make resize himself when is to close to max size.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...