Al Summers
Member
@Tayfur
First of all thank you for your jPictureBox library - it has helped me no end.
The problem I'm having is getting the context menu to change. I think I have coded correctly but am still unable to change anything on the popup menu.
I have included part of my code just incase someone can spot my error.
The screen shot below shows the menu I get with the code above - no sign of Original 163% and 26%?
Many Thanks
Al
First of all thank you for your jPictureBox library - it has helped me no end.
The problem I'm having is getting the context menu to change. I think I have coded correctly but am still unable to change anything on the popup menu.
I have included part of my code just incase someone can spot my error.
B4X:
'**************************************************************************************************************************************************************
'START Picture Viewer
Sub btnPictures_Click
Private ViewForm As Form
ViewForm.Initialize("PicView",850,850)
ViewForm.RootPane.LoadLayout("pictureviewer") 'Load the layout file.
ViewForm.Show
ImageFileList
cbPictureHiveNo.Items.AddAll(HivenoPictureList)
cbPictureHiveNo.Items.Add("All")
cbPictureHiveNo.SelectedIndex=0
End Sub
Sub ImageFileList
Dim files As List
files = File.ListFiles("D:\Data\AMS\B4X\projects\HivesPC_B4J\HivesPC\data\pictures") 'get all files in this folder
Private HiveInsp1 As HiveInsp
HivenoPictureList.Initialize
For i = 0 To files.Size - 1
HiveInsp1.Initialize(files.Get(i))
'Log(HiveInsp1.GetHive)
'Log(HiveInsp1.GetDate)
'Log(HiveInsp1.GetTime)
'Log("Days = " & (HiveInsp1.GetCurrentAgeInTicks / DateTime.TicksPerDay))
HivenoPictureList.Add(HiveInsp1.GetHive)
Next
HivenoPictureList = RemoveDuplicates(HivenoPictureList)
End Sub
Sub cbPictureHiveNo_ValueChanged (Value As Object)
Dim files As List
HivenoPictureFileList.Clear
Private HiveInsp2 As HiveInsp
jPictureBox1.ClearAll
files = File.ListFiles("D:\Data\AMS\B4X\projects\HivesPC_B4J\HivesPC\data\pictures") 'get all files in this folder
For i = 0 To files.Size - 1
HiveInsp2.Initialize(files.Get(i))
Dim Age As Int = HiveInsp2.GetCurrentAgeInDays
If Age >= HivenoPictureFromDays And Age <= HivenoPictureToDays Then
If Value = "All" Then
HivenoPictureFileList.Add(files.Get(i))
Else
If HiveInsp2.GetHive = Value Then
HivenoPictureFileList.Add(files.Get(i))
End If
End If
End If
Next
For i = 0 To HivenoPictureFileList.Size - 1
jPictureBox1.addPicture("D:\Data\AMS\B4X\projects\HivesPC_B4J\HivesPC\data\pictures", HivenoPictureFileList.Get(i))
Next
'Show first picture
jPictureBox1.PictureIndex=0
jPictureBox1.Fit_in_Page
Context_Menu_load
'Context_Menu_load_FS
jPictureBox1.MaxRatio=3 ' 300% orginial size
jPictureBox1.MinRatio=0.1 ' 10% orginial size
End Sub
Sub RemoveDuplicates(pList As List) As List
If pList = Null Or Not(pList.IsInitialized) Then Return pList
Dim lstNew As List : lstNew.Initialize
Dim objItem As Object
For i = 0 To pList.Size - 1
objItem = pList.Get(i)
If lstNew.IndexOf(objItem) = - 1 Then
lstNew.Add(objItem)
End If
Next
Return lstNew
End Sub
Sub tfFromDays_TextChanged (Old As String, New As String)
If IsNumber(New) Then
If New >= HivenoPictureToDays Then tfFromDays.Text = HivenoPictureToDays + 1
HivenoPictureFromDays = New
'Trigger a refresh
cbPictureHiveNo_ValueChanged(cbPictureHiveNo.Value)
End If
cbPictureHiveNo.SelectedIndex = cbPictureHiveNo.SelectedIndex
End Sub
Sub tfToDays_TextChanged (Old As String, New As String)
If IsNumber(New) Then
If New <= HivenoPictureFromDays Then tfToDays.Text = HivenoPictureFromDays + 1
HivenoPictureToDays = New
'Trigger a refresh
cbPictureHiveNo_ValueChanged(cbPictureHiveNo.Value)
End If
End Sub
private Sub Context_Menu_load
Dim m As Map
m.Initialize
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_fullscreen
z.Text="Full Screen xx"
z.CM_Type=jPictureBox1.CM_Type_Function
z.CM_Rate=jPictureBox1.CM_Rate_FullScreen
m.Put(z.Text,z)
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_rotate_right
z.Text="Pic. Right"
z.CM_Type=jPictureBox1.CM_Type_Function
z.CM_Rate=jPictureBox1.CM_Rate_Rotate_CW
m.Put(z.Text,z)
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_rotate_left
z.Text="Pic Left"
z.CM_Type=jPictureBox1.CM_Type_Function
z.CM_Rate=jPictureBox1.CM_Rate_Rotate_CCW
m.Put(z.Text,z)
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_fit_size
z.Text="fit in page"
z.CM_Type=jPictureBox1.CM_Type_Function
z.CM_Rate=jPictureBox1.CM_Rate_Fit_Page
m.Put(z.Text,z)
' Dim z As C_Menu
' z.Initialize
' z.Enable=True
' z.imageFolder=jPictureBox1.Icon_Folder
' z.imageName=""
' z.Text="PRINTER"
' z.CM_Type=jPictureBox1.CM_Type_Function
' z.CM_Rate="PRINT"
'
' m.Put(z.Text,z)
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_resize_in
z.Text="Orginal 163%"
z.CM_Type=jPictureBox1.CM_Type_Absolite
z.CM_Rate=1.63
m.Put(z.Text,z)
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_resize_out
z.Text="Orginal 26%"
z.CM_Type=jPictureBox1.CM_Type_Absolite
z.CM_Rate=0.26
m.Put(z.Text,z)
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_zoom_in
z.Text="+25%"
z.CM_Type=jPictureBox1.CM_Type_Incremental
z.CM_Rate=0.25
m.Put(z.Text,z)
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_zoom_out
z.Text="-25%"
z.CM_Type=jPictureBox1.CM_Type_Incremental
z.CM_Rate=-0.25
m.Put(z.Text,z)
' Dim z As C_Menu
' z.Initialize
' z.Enable=False
' z.imageFolder=jPictureBox1.Icon_Folder
' z.imageName=jPictureBox1.Icon_exit
' z.Text="Close Form"
' z.CM_Type=jPictureBox1.CM_Type_Function
' z.CM_Rate=jPictureBox1.CM_Rate_Close
'
' m.Put(z.Text,z)
jPictureBox1.Context_Menu=m
End Sub
private Sub Context_Menu_load_FS
Dim m As Map
m.Initialize
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_zoom_in
z.Text="+25%"
z.CM_Type=jPictureBox1.CM_Type_Incremental
z.CM_Rate=0.25
m.Put(z.Text,z)
Dim z As C_Menu
z.Initialize
z.Enable=True
z.imageFolder=jPictureBox1.Icon_Folder
z.imageName=jPictureBox1.Icon_zoom_out
z.Text="-25%"
z.CM_Type=jPictureBox1.CM_Type_Incremental
z.CM_Rate=-0.25
m.Put(z.Text,z)
jPictureBox1.FSContext_Menu=m
End Sub
Sub jPictureBox1_GeneralError (Error As String)
Log(Error)
End Sub
The screen shot below shows the menu I get with the code above - no sign of Original 163% and 26%?
Many Thanks
Al