Rank: Member
Groups: Member
Joined: 4/15/2007(UTC) Posts: 25
|
Dear sirs,
we have a question regarding TIFF Viewer Demo sample project in vb .net. When you load a multi page tiff file, on the left appears the thumbnails, and on the right appears the full image for the selected thumbnail. When you click on a the left, current thumbnail get selected with a gray image upon it. But when you click on the right (full image, not thumbnail), the gray image that indicates which thumbnail is selected, unfortunately disappears.
Any idea how to keep the gray image on the thumbnail so we know which thumbnails is selected?
Thanks,
firamax
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello firamax,
This is a standart behaviour of the control and, unfortunately, I have no idea how to change it. |
|
|
|
|
Rank: Member
Groups: Member
Joined: 4/15/2007(UTC) Posts: 25
|
Well, there is maybe a solution? Is there any way to make this gray image to appear on the bitmapViewer1_Click Event? I maybe by writing some kind of code in _Click event,we can make this gray appear, or draw it ??????
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello,
Yes, this is possible. You can add 2 images for each thumbnail into the image list. The first will be usual thumbnail, and another - thumbnail with selection drawn over thumbnail. So you will be able to indicate currently selected item by changing item's image list index. |
|
|
|
|
Rank: Member
Groups: Member
Joined: 4/15/2007(UTC) Posts: 25
|
Ok ,Alex, but can i have PLEASE some help on how to do this? We have to make 2 changes to initial code. First change, we need to add 2 images for each thumbnail, instead of one, and second change we need to change the code on _SelectedIndexChanged event, so it shows the one with selection drawn over thumbnail. We use the code provided from the samples. This is how a thumbnail is created and loads a jpeg file: Code:'LOAD THUMBNAIL
Private Sub loadThumbnailJpeg(ByVal fileName As String)
filename="C:\test.jpg"
jpegReader = New JpegReader(fileName)
imageList.ImageSize = New Size(200, 200)
imageList.ColorDepth = ColorDepth.Depth24Bit
thumbnailsView.LargeImageList = imageList
For Each frame As JpegFrame In jpegReader
Dim thumbnailBitmap As New Aurigma.GraphicsMill.Bitmap
frame.GetThumbnail(thumbnailBitmap, 200, 200)
Dim thumbnail As Aurigma.GraphicsMill.Bitmap = CreateThumbnail(thumbnailBitmap)'<---CREATE THUMBNAIL
thumbnailsView.Items.Add("Page " & (number + 1).ToString(), number)
imageList.Images.Add(thumbnail.ToGdiplusBitmap())
number += 1
jpegReader.Close()
frame.Dispose()
thumbnail.Dispose()
Next
End Sub
'THUMBNAIL CREATION
Private Function CreateThumbnail(ByVal source As Aurigma.GraphicsMill.Bitmap) As Aurigma.GraphicsMill.Bitmap
'1.CREATION OF THE WHITE(EMPTY) BITMAP(THUMBNAIL)
Dim thumbnailBitmap As New Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.White, 200, 200, PixelFormat.Format24bppRgb)
'2.PUT THE IMAGE ONTO THE BITMAP(THUMBNAIL)
source.Draw(thumbnailBitmap, New Rectangle(CInt(CSng(thumbnailBitmap.Width - source.Width) / 2), _
CInt(CSng(thumbnailBitmap.Height - source.Height) / 2), source.Width, source.Height), _
CombineMode.Alpha, 1, InterpolationMode.LowQuality)
'3.CREATION OF THE BLACK PERIMETER ON THE THUMBNAIL
Dim graphics As GdiGraphics = thumbnailBitmap.GetGdiGraphics()
Dim pen As New Aurigma.GraphicsMill.Drawing.Pen(RgbColor.Black, 1)
graphics.DrawRectangle(pen, CInt((thumbnailBitmap.Width - source.Width) / 2), _
CInt((thumbnailBitmap.Height - source.Height) / 2), source.Width - 2, source.Height - 2)
graphics.Dispose()
Return thumbnailBitmap
End Function
'THIS IS HOW WE SHOW EACH THUMBNAIL, WHEN WE CLICK WITH MOUSE ON IT
Private Sub thumbnailsView_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles thumbnailsView.SelectedIndexChanged
Dim filename, extension As String
Dim selectedThumbnailIndex As Integer
Dim frame
If thumbnailsView.SelectedIndices.Count > 0 Then
selectedThumbnailIndex = thumbnailsView.SelectedIndices(0)
filename = "c:\TEST.JPG"
extension = IO.Path.GetExtension(filename)
If extension = ".jpg" Then
jpegReader = New JpegReader(filename)
frame = New JpegFrame
frame = CType(jpegReader.LoadFrame(0), JpegFrame)
End If
frame.GetBitmap(bitmapViewerMainView.Bitmap)
frame.Dispose()
End If
End Sub
Help on this would be VERY much appreciated, firamax Edited by user Monday, December 17, 2007 12:17:51 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello firamax, Sorry for delay, I was a busy a little bit here. Here is small sample of the TIFF viewer in the attachments. It implements the trick with two ImageList items per thumbnail. I hope it will help you to solve this annoying issue in your application ;) |
|
|
|
|
Rank: Member
Groups: Member
Joined: 4/15/2007(UTC) Posts: 25
|
Hi Alex, thanks you very much for the sample you did. Our code is little bit different and unfortunately, although we spend many-many hours to do the same, we could not reproduce it to our project. I am sure its our fault, we are missing something, because your sample is very small and easy to understand. We send you attached a very small project, 100 lines only, that implements our code. If you please open it and make it work, then for sure 100% it will work for our application also. Please help us on that also.... firamax
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello firamax, Oh, I did not know that you are using .NET Framework 2.0! It uses hash instead of plain array in the ImageList. I modified your sample and marked all key points by comments. This is just a sample so I simply extended your tag array to store two additional keys and I used file names as base to create image list keys. I am sure that this code may be improved, but I think that it is sufficient to demonstrate the main idea. By the way, why do not you use the latest version of the Graphics Mill for .NET? It is already available for download, I highly recommend to upgrade your version. Its free. PS: Oh, I also deleted binaries from your project to reduce archive size, so you will have to renew reference to the Graphics Mill for .NET. |
|
|
|
|
Rank: Member
Groups: Member
Joined: 4/15/2007(UTC) Posts: 25
|
Hi Alex,
if you have any idea how this code may be improved, you may tell me. No matter what, thank you very much again, because it was very important to be able to indicate which thumbnail is selected among maybe 30 or 40 thumbnails!
firamax :)
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 12/17/2007(UTC) Posts: 49
|
Hi Alex, please see again the ModifiedThisSample.zip , since its long time ago you fixed it for us. It works fine!!! What we want to do on this, is to have a context menu(popup menu) when we make right click on a thumbnail. Now, when we make left click or right click it selects the current thumbnail, and we must to keep this functionality as it is. We only need in case of a right click to appear a context menu-popup menu preferable on the position that thumbnail right clicked. This context menu can display the number of page, for example 1 or 2 or 3. Any idea how to make it work? We tried to solve this by adding NEW code as below: Code:Public newThumbnailSelectedForRightClickOnly As Boolean
Code: Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
newThumbnailSelectedForRightClickOnly = False
End Sub
Code:Private Sub thumbnailsView_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles thumbnailsView.MouseUp
If e.Button = Windows.Forms.MouseButtons.Right Then
If newThumbnailSelectedForRightClickOnly = True Then
newThumbnailSelectedForRightClickOnly = False
Dim ff As New ContextMenu
Dim pos As Point
pos.X = e.X
pos.Y = e.Y
ff.MenuItems.Add("something 1")
ff.MenuItems.Add("something 2")
ff.Show(thumbnailsView, pos)
End If
Else
newThumbnailSelectedForRightClickOnly = False
End If
End Sub
And we add the following line into thumbnailsView_SelectedIndexChanged event: Code:If thumbnailsView.SelectedIndices.Count > 0 Then
newThumbnailSelectedForRightClickOnly = True'THIS IS THE NEW LINE WE INSERTED
selectedThumbnailIndex = thumbnailsView.SelectedIndices(0)
It works but not ok because when you left click a thumbnail and after you right click the same, context menu does not appear. Any idea how to implement this? Or we better do something else?
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 12/17/2007(UTC) Posts: 49
|
Any idea yet Alex?
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, I removed newThumbnailSelectedForRightClickOnly variable and all related code and modified MouseUp event handler in the following way: Code:
Private Sub tlv_MouseUp(ByVal sender As Object, ByVal e As _ System.Windows.Forms.MouseEventArgs) Handles thumbnailsView.MouseUp
If e.Button = Windows.Forms.MouseButtons.Right And _
thumbnailsView.SelectedItems.Count > 0 Then
Dim contextMenu As New ContextMenu
contextMenu.MenuItems.Add("something 1")
contextMenu.MenuItems.Add("something 2")
contextMenu.Show(thumbnailsView, e.Location)
End If
End Sub
It seems that everything works as you wish. However if it is not - post message here and we will discuss the issue. |
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 12/17/2007(UTC) Posts: 49
|
Thanks again Alex, looks to be as we wanted it to be. We tried this without
And thumbnailsView.SelectedItems.Count > 0
so it was showing popup everywhere....
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello,
Good, I'm glad to hear that everything works as it should!
|
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 12/17/2007(UTC) Posts: 49
|
Hi Alex, again Well, in last sample regarding the right-click operation, we need to do some more things, but we were stuck here. As you can see in the sample attached, we added 3 buttons. In buttons we suppose that we have a thumbnail selected, does not matter which one, and of course we want to maintain all current working operations, like right click. In button 1) we want to change the tiff file that the current selected thumbnail already shows, with another tiff file in same path and filename. Actually is the same file modified by a tiff editor and we simply want to reload it and show the new differences made by edited tiff file, in current thumbnail and bitmapViewer. In button 2) we want to do the same exactly with button 1) but not for the currently selected thumbnail but for a non selected one. Suppose we have selected the first one and we want to show the modification in the last one thumbnail. In button 3) we want to completely remove the selected thumbnail. That means to remove the ListView item + somethings from the image list??? What code we need to implement this? Any ideas how to do those 3 important things for us? PS:Your help is very much appreciated!!
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello,
Actually there is no big difference between first and second actions - in both cases you should just change images for the specified item in the ImageList and update item. And as for third case - it is even simpler one - here you should remove item from ThumbnailList and remove corresponding images from the ImageList.
In your implementation each ThumbnailListItem has tag array (attached via .Tag property) which contains both necessary keys for ImageList dictionary handling. So changing ImageList will be rather straightforward action - just use ImageList.Item property to modify/remove necessary entries.
|
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 12/17/2007(UTC) Posts: 49
|
Hello Alex, well what you said, we did it in the third action(remove thumbnail) and if you want you can have a look on the attached modified sample(just in case we forget to remove or change something), but it look to be working fine!!! Our problem remains for the first 2 actions(replace thumbnail image with another one). We try to work on it, and we managed to replace the image but sure we did something wrong in here. When you select 3rd thumbnail, and press button 1), the 3rd thumbnail, really changes and takes the new image but after doing this, when you simply click/select the 1st thumbnail, it also changes this one too  !!! Please have a look on the code and try to help with code. See code when you press button 1), since here is the new code we did while trying to make it work! Thanks again...
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, I reviewed your code and want to say that I meant another way of implementation. You are trying to work with item's indices and it is much more complicated way - too many oportunities to make a mess with indices ;). I suggest you another way - each item in your application has tag array. Inside it at 12 and 13 indices 2 image list keys are stored. And each time when you need to change thumbnails, you should work via this keys. For example to change selected item's thumbnail you should use something like this: Code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If thumbnailsView.SelectedItems.Count = 0 Then
Return
End If
Dim item As ListViewItem = thumbnailsView.SelectedItems(0)
Dim tag As Object() = item.Tag
imageList.Images.RemoveByKey(tag(12))
imageList.Images.RemoveByKey(tag(13))
imageList.Images.Add(tag(12), <... some new bitmap 1...>)
imageList.Images.Add(tag(13), <... some new bitmap 2...>)
End Sub
It is simplifyed version of code - you should also update values of the tag array - because other parts of the application reads info from here (e.g. tag(11) is used to obtain a filename of the image to load into BitmapViewer control). But I hope you undestand that we have no resources to debug/rewrite all samples provided by our customers. |
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 12/17/2007(UTC) Posts: 49
|
Yes you are right, your way is better! Thanks one more time Alex:d/
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.