I want to load some images in a ScrollView in basic4android. This happened only once.
My Code:
Activity.LoadLayout("main")
Dim b As Bitmap
Dim iv As ImageView
For i=1 To 10
b.Initialize(File.DirAssets,"1.png")
iv.Initialize("")
iv.Bitmap = b
ScrollView1.Panel.AddView(iv,30dip,30dip,212,64)
Next
instead of 10 image, only one image appears in my ScrollView.
I need your help. Thanks.
For i = 10
Dim iv As ImageView 'create an ImageView for each bitmap
iv.Initialize("") 'not interested in any events so we pass empty string.
Dim bd As BitmapDrawable
bd.Initialize(Bitmaps.Get(i))
iv.Background = bd 'set the background of the image view.
'add the image view to the scroll bar internal panel.
ScrollView1.Panel.AddView(iv, 5dip, 5dip + i * 200dip, ScrollView1.Width - 10dip, 190dip)
Next
Try the above code that "should" work, I am not near B4A to test it but all the code looks right on my example.
always addview on top 30dip
ScrollView1.Panel.AddView(iv,30dip,30dip,212,64)
Change value
ScrollView1.Panel.AddView(<Image>,<Left>,<Top>,<H>,<W>)
Related
I have small problem, does anyone know how to change position of existing dimensions and Notes in Part/Product using short macro.
I will shortly describe what I want to do and what kind of problem I have.
I have simple model (let say rectangle)
Inside this model I have dimensions and annotations created in FTA.
Next step is to drastically change position of this model (base model in point 0,0,0 and I want tochange it position to 150,10000,80 + rotation)
during this change some dimensions and annotations (Theirs position in 3D) are not fully following after geometry.
Because of that I would like to have simple macro to create new position of my dimensions and annotations after part update.
I have performed some simple tests code bellow
What I have noticed, when I set new position of the text:
Theoretically text change position but in 3D it stays in old position.
When edit my text by double click on it and then click OK my text translates to new position which was set in macro earlier. The same situation is when I would like to change frame of the text or content (I had AAA and I would like to have BBB), it's changes only when I open Text editor.
Set part1 = CATIA.ActiveDocument
Set Selection = part1.Selection
Set VisPropertySet = Selection.VisProperties
Selection.Search ("name='Text.1',all")
' get selected annotation here
Dim anAnnotation As Annotation
Set anAnnotation = CATIA.ActiveDocument.Selection.Item(1).Value
' get annotation on the DrawingText interface
Dim txtAnnotation As DrawingText
Set txtAnnotation = anAnnotation.Text.Get2dAnnot()
' get TPS view that contains annotation on the DrawingView interface
Dim vwTPSView As DrawingView
Set vwTPSView = txtAnnotation.Parent.Parent
' get coordinates on a view
Dim dX ' as Double
txtAnnotation.X = 0
txtAnnotation.Y = 30
txtAnnotation.FrameType = catEllipse
part1.Update
End Sub
Generally using Part.Update refreshes the annotation's position and text but you can also use:
Dim anAnnotation As Annotation
'Code here
anAnnotation.ModifyVisu 'This should work for both Texts and Dimensions
But if the above method does not work, you can try reseting the text on the annotation (It will work only for texts, and not for dimensions)
Dim vwTPSView As DrawingView
'Code here
vwTPSView.Text = vwTPSView.Text
Be carefull with this last methos though. If your text has any parameters or variables inside it, replacing the text will clear it.
I am trying to display a line of pictures in my program. But I am having a problem, where it is only showing the first image in the imagelist and only showing one image-box.
Private Cards As New List(Of PictureBox)
Private Sub SetupCards()
For i As Integer = 0 To imglist1.Images.Count - 1
Dim PicCard As PictureBox = New PictureBox()
PicCard.Width = 100
PicCard.Height = 200
PicCard.Top = 50
PicCard.Left = 50
Me.Controls.Add(PicCard)
PicCard.Image = imglist1.Images(i)
Cards.Add(PicCard)
Next i
End Sub
You're placing the picture boxes on top of each other, which is why you only see the last card. You've got to set a different Left property for every picture box you add.
The solution is rather simple. Just add the picture box's width to Left, multiplied by the current index i.
PicCard.Left = 50 + PicCard.Width * i
Don't need to keep the imaging controls in your own list if you add them to a parent container control.
Use ListView or third-party controls, or use custom drawing code if you need to use ListBox (which wraps respective Windows control). See
C# Can I display images in a list box?
I would like to know how to scroll down my Panel that contains a TabControl
in VB.NET using a button without showing a scrollbar. I tried the following
Dim Location As Integer = Panel_Images.Location.Y
If Location + 20 < Panel_Images.VerticalScroll.Maximum Then
Location += 20
Panel_Images.VerticalScroll.Value = Location
Else
'If scroll position is above 280 set the position to 280 (MAX)
Location = Panel_Images.VerticalScroll.Maximum
Panel_Images.AutoScrollPosition = New Point(0, Location)
End If
It only scrolls for once and doesnt work anymore.
So you want to set the location of the Panel inside another control? If you want to scroll the control up, set it's location.Y (or its 'Top') property to minus whatever value you want, it will be clipped by its parent.
To scroll down, set the property positive.
So, in order to print my Silverlight grids I had to Children.Remove them from LayoutRoot and Children.Add them to my Canvas I am using for printing. (Since they can only be attached to one parent element at a time).
Which is fine, but then this leaves my screen blank, as the Grids have been removed from LayoutRoot.
So I tried Children.Remove from the Canvas and Children.Add back to LayoutRoot, but it doesn't add anything back onto the screen.
How should I deal with this? Thanks.
(Using Silverlght 5 and VB.net).
My code:
If PageCounter = 1 Then
Dim PrintSurface As New Canvas
Dim topPosition1 As Double = e.PageMargins.Top + 10
Dim topPosition2 As Double = e.PageMargins.Top + 600
CompChartGrid.SetValue(Canvas.TopProperty, topPosition1)
AttChartGrid.SetValue(Canvas.TopProperty, topPosition2)
LayoutRoot.Children.Remove(CompChartGrid)
PrintSurface.Children.Add(CompChartGrid)
LayoutRoot.Children.Remove(AttChartGrid)
PrintSurface.Children.Add(AttChartGrid)
e.PageVisual = PrintSurface
PrintSurface.Children.Remove(CompChartGrid)
PrintSurface.Children.Remove(AttChartGrid)
LayoutRoot.Children.Add(CompChartGrid)
LayoutRoot.Children.Add(AttChartGrid)
PageCounter += 1
e.HasMorePages = True
Exit Sub
End If
This is most likely due to clipping.
When you set the Canvas.Top property on your elements, this value will persist until replaced. So when you add CompChartGrid and AttChartGrid back to the LayoutRoot grid, they are offset by topPosition1 and topPosition2 respectively.
Try calling
CompChartGrid.ClearValue(Canvas.TopProperty)
and
AttChartGrid.ClearValue(Canvas.TopProperty)
The elements should then end up back where they started.
As you'll can see the first image is the size of (1024*768) and it is correctly displayed in the picturebox and in the second case the image size is (1600*900) and it is displayed to half of the picturebox and the remaining is missing .So No I would like to fir that image in the picturebox no matter what the size is and even though it is greater than the size of the picturebox.I need to scale that Image.So how do I do that?And one more thing is that I need to resize the picturebox automatically when the image loads to it just as we see in the lightbox effect..
http://www.lokeshdhakar.com/projects/lightbox2/ -------->example.
Any help will be appreciated!
Here is what I am getting.
If it's a winforms app, you can set the SizeMode property of the PictureBox to PictureBoxSizeMode.Zoom. Note that this will increase the size of smaller images to fill the frame, so you might want to measure the image first, in order to check if either edge is too long, and then setting SizeMode to either PictureBoxSizeMode.Zoom or PictureBoxSizeMode.Normal.
I know this is marked answered, but I wrote this for one of my own apps. Hope it helps somebody..
Private Sub ScaleImage(ByVal p As PictureBox, ByRef i As Bitmap)
If i.Height > p.Height Then
Dim diff As Integer = i.Height - p.Height
Dim Resized As Bitmap = New Bitmap(i, New Size(i.Width - diff, i.Height - diff))
i = Resized
End If
If i.Width > p.Width Then
Dim diff As Integer = i.Width - p.Width
Dim Resized As Bitmap = New Bitmap(i, New Size(i.Width - diff, i.Height - diff))
i = Resized
End If
End Sub
The two Easiest Ways to Fit an Image to Any Size of PictureBox is:
-to set the Image as Background Image
OR
-to set it as picturebox image then set sizemode to StretchImage
1.Background Image
-use the BackgroundImage property of the PictureBox
picturebox.BackgroundImage = Image.FromStream(New IO.MemoryStream(CType(data, Byte())))
-Then Set its BackgroundImageLayout to stretch Like This:
picturebox.BackgroundImageLayout = ImageLayout.Stretch
Image
-use the Image property of the PictureBox
picturebox.Image = Image.FromStream(New IO.MemoryStream(CType(data, Byte())))
-Then Set its' sizeMode to StretchImage Like This:
picturebox.SizeMode = PictureBoxSizeMode.StretchImage
This will make any Picture / Image / Canvas Stroke (converted to Byte Array) fit according to the height and width of the picturebox
Hope This Helps :)