Platforms to show: All Mac Windows Linux Cross-Platform

/WinFrameworks/Windows Photo Acquire


Required plugins for this example: MBS WinFrameworks Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /WinFrameworks/Windows Photo Acquire

This example is the version from Sun, 18th Jul 2020.

Project "Windows Photo Acquire.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Function UnhandledException(error As RuntimeException) As Boolean dim t as Introspection.TypeInfo = Introspection.GetType(error) msgbox t.FullName+EndOfLine+error.Message return true // don't quit End EventHandler
End Class
Class MainWindow Inherits Window
Control PickButton Inherits PushButton
ControlInstance PickButton Inherits PushButton
EventHandler Sub Action() dim d as new WinPhotoAcquireDeviceSelectionDialogMBS d.SubmitButtonText = "Pick Device" d.Title = "Pick a device" dim DeviceID as string dim DeviceType as Integer = 0 if d.ShowModal(self, d.DeviceFlagAllDevices, deviceID, deviceType) then log "DeviceID: "+deviceID SetDevice DeviceID end if End EventHandler
End Control
Control OptionsButton Inherits PushButton
ControlInstance OptionsButton Inherits PushButton
EventHandler Sub Action() dim d as new WinPhotoAcquireOptionsDialogMBS d.Initialize "" // default registry path dim Result as integer = d.ShowModal(self) Select case result case 1 // okay d.SaveData case 2 // cancel else Break // impossible? end Select End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control AcquireButton Inherits PushButton
ControlInstance AcquireButton Inherits PushButton
EventHandler Sub Action() const ShowProgress = true acquire.Acquire(source, ShowProgress, self, "MyApp", cb) dim results() as string = acquire.Results for each result as string in results log result next End EventHandler
End Control
Control ItemButton Inherits PushButton
ControlInstance ItemButton Inherits PushButton
EventHandler Sub Action() if source <> nil then dim itemCount as integer = source.ItemCount if itemCount = 0 then msgbox "No items." else dim item as WinPhotoAcquireItemMBS = source.Item(0) log "Item: "+ item.ItemName // transfer dim data as string = item.data log "got "+str(data.lenb)+" bytes" dim pic as Picture = item.Thumbnail(1000, 1000) if pic <> nil then dim pw as new PictureWindow pw.Title = item.ItemName pw.Backdrop = pic end if end if end if End EventHandler
End Control
EventHandler Sub Open() acquire = new WinPhotoAcquireMBS cb = new WinPhotoAcquireProgressCallBack cb.list = list End EventHandler
Sub Log(s as string) List.AddRow s List.ScrollPosition = list.ListCount End Sub
Sub SetDevice(ID as String) source = acquire.CreatePhotoSource(ID) if source <> nil then log "Picked source: "+source.FriendlyName // look for images on device, e.g. camera dim ItemCount as integer source.InitializeItemList(false, cb, ItemCount) log "Item count: "+str(ItemCount) if ItemCount > 0 then for i as integer = 0 to ItemCount-1 dim it as WinPhotoAcquireItemMBS = source.Item(i) log "item "+str(i)+": "+it.ItemName next end if log "Items skipped in this example: "+str(cb.SkipCounter) ItemButton.Enabled = true AcquireButton.Enabled = true end if End Sub
Property acquire As WinPhotoAcquireMBS
Property cb As WinPhotoAcquireProgressCallBack
Property source As WinPhotoAcquireSourceMBS
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class WinPhotoAcquireProgressCallBack Inherits WinPhotoAcquireProgressCallBackMBS
EventHandler Sub Cancelled(byref Cancelled as Boolean) 'log CurrentMethodName End EventHandler
EventHandler Sub DirectoryCreated(Directory as String) log CurrentMethodName+": "+Directory End EventHandler
EventHandler Sub EndDelete(Result as Integer) log CurrentMethodName+": "+str(result) End EventHandler
EventHandler Sub EndEnumeration(Result as Integer) log CurrentMethodName+": "+str(result) End EventHandler
EventHandler Sub EndItemDelete(ItemIndex as Integer, Item as WinPhotoAcquireItemMBS, Result as Integer) log CurrentMethodName+": "+str(result) End EventHandler
EventHandler Sub EndItemTransfer(ItemIndex as Integer, Item as WinPhotoAcquireItemMBS, Result as Integer) log CurrentMethodName+": "+str(result) End EventHandler
EventHandler Sub EndSession(Result as Integer) log CurrentMethodName+": "+str(result) End EventHandler
EventHandler Sub EndTransfer(Result as Integer) log CurrentMethodName+": "+str(result) End EventHandler
EventHandler Sub ErrorAdvise(Result as Integer, ErrorMessage as String, MessageType as Integer, byref ErrorAdviseResult as Integer) log CurrentMethodName+": "+str(result) msgbox ErrorMessage // you can ask user and decide what to do ErrorAdviseResult = me.AdviseResultAbort End EventHandler
EventHandler Function FoundItem(Item as WinPhotoAcquireItemMBS) As Boolean log CurrentMethodName+": "+item.ItemName FoundCounter = FoundCounter + 1 if FoundCounter > 5 then // let's ignore more than 5 files, so our example doesn't take ages to run an import SkipCounter = SkipCounter + 1 return true end if End EventHandler
EventHandler Sub GetDeleteAfterAcquire(byref DeleteAfterAcquire as Boolean) log CurrentMethodName // we don't want to delete files in this example DeleteAfterAcquire = false End EventHandler
EventHandler Sub StartDelete(Source as WinPhotoAcquireSourceMBS) log CurrentMethodName+": "+Source.FriendlyName End EventHandler
EventHandler Sub StartEnumeration(Source as WinPhotoAcquireSourceMBS) log CurrentMethodName+": "+Source.FriendlyName End EventHandler
EventHandler Sub StartItemDelete(ItemIndex as Integer, Item as WinPhotoAcquireItemMBS) log CurrentMethodName+": "+item.ItemName End EventHandler
EventHandler Sub StartItemTransfer(ItemIndex as Integer, Item as WinPhotoAcquireItemMBS) log CurrentMethodName+": "+item.ItemName End EventHandler
EventHandler Sub StartTransfer(Source as WinPhotoAcquireSourceMBS) log CurrentMethodName + ": "+Source.FriendlyName End EventHandler
EventHandler Sub UpdateDeletePercent(Percent as Integer) log CurrentMethodName + ": "+str(Percent) End EventHandler
EventHandler Sub UpdateTransferPercent(Overall as Boolean, Percent as Integer) log CurrentMethodName + ": "+str(Percent) End EventHandler
Sub Log(s as string) List.AddRow s List.ScrollPosition = list.ListCount End Sub
Property FoundCounter As Integer
Property SkipCounter As Integer
Property list As listbox
End Class
Class PictureWindow Inherits Window
End Class
End Project

See also:

The items on this page are in the following plugins: MBS WinFrameworks Plugin.


The biggest plugin in space...