PictureTagger/SB-PictureTagger/M_SB_PictureTagger.vb

221 lines
12 KiB
VB.net

Option Explicit On
Imports SB_PictureTagger.Stammbaum
Namespace Stammbaum.Module.PictureTagger
Module PictureTagger
'###################################################################################################################
'############### Lade ##############################################################################################
'###################################################################################################################
Public Sub PT_LoadVerzeichnis()
If System.IO.Directory.Exists(Settings.PictureTagger.Pub_sPath) Then
Settings.PictureTagger.pub_aPfade = Tools.Filesystem.GetFilesFromDir(Settings.PictureTagger.Pub_sPath, Settings.PictureTagger.pub_aSupportedFiles, Settings.PictureTagger.nOrdnerTiefe)
End If
End Sub 'Lade Bilder in pub_aPfade Array
Public Sub PT_LoadTaggedIMG()
'Absicherung für Undimensioniertes Array
If Settings.PictureTagger.pub_aPfade.Length = 0 Then ReDim Settings.PictureTagger.pub_aPfade(0)
'Bildpfad auf existenz Prüfen
If System.IO.File.Exists(Settings.PictureTagger.pub_aPfade(Settings.PictureTagger.pub_nPfadeIndex)) Then
'Taggs With INI:
Settings.PictureTagger.Pub_oLoaded_TaggedIMG = INI_Load_Taggs(Settings.PictureTagger.pub_aPfade(Settings.PictureTagger.pub_nPfadeIndex), False)
'Later With DB ---
End If
End Sub 'Lade TaggedIMG in Pub_oLoaded_TaggedIMG
'###################################################################################################################
'############### Speichere #########################################################################################
'###################################################################################################################
Public Sub PT_SaveTaggedIMG()
'Taggs With INI:
INI_Save_Taggs(Settings.PictureTagger.Pub_oLoaded_TaggedIMG, False)
'Later With DB ---
End Sub
'###################################################################################################################
'############### Taggs With INI ####################################################################################
'###################################################################################################################
'Taggs auslesen (jezt noch aus INI - später aus DB)
Private Function INI_Load_Taggs(ByVal PicturePath As String, Optional ByVal ForEachDat As Boolean = False) As Classen.PictureTagger.TaggedIMG
'### INI Einstellungen ###
Dim INI_Locate As String
Dim INI_Name As String
If ForEachDat Then
INI_Name = System.IO.Path.Combine(System.IO.Path.GetFileName(PicturePath), ".ini")
INI_Locate = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(PicturePath), INI_Name)
Else
INI_Name = "Tagg.ini"
INI_Locate = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(PicturePath), INI_Name)
End If
'### Main ##
Dim TMP_TaggIMG As New Classen.PictureTagger.TaggedIMG
If System.IO.File.Exists(PicturePath) Then
'Lade Wichtigste Eigenschaften = Immer Forhanden bei Geladenem TaggedIMG
TMP_TaggIMG.Image = Image.FromFile(PicturePath)
TMP_TaggIMG.Path = PicturePath
TMP_TaggIMG.ID = System.IO.Path.GetFileName(PicturePath)
If System.IO.File.Exists(INI_Locate) Then
'Deklarationen
Dim i As Long
Dim sKey As String = TMP_TaggIMG.ID
'Führ Makr einlese Schleife
Dim Mark_ID As String
Dim Mark_PositionX As Long
Dim Mark_PositionY As Long
Dim Mark_Radius As Long
Dim Mark_Description As String
Dim Mark_Index As String
'Lade Optionalen Rest:
'Titel
TMP_TaggIMG.Title = Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Title", Nothing)
'Kurzbeschreibung
'##############################################################
'ReFormate Description Text from "Description"
TMP_TaggIMG.Description = Tools.Convert.Coding.Base64_To_Ascii(Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Description", Nothing))
'##############################################################
'Zeitangabe
TMP_TaggIMG.Time = Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Time", Nothing)
'Ortsangabe-Title
TMP_TaggIMG.Ort.Title = Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Place_Title", Nothing)
'Ortsangabe-Adresse
TMP_TaggIMG.Ort.Adresse = Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Place_Adresse", Nothing)
'Ortsangabe-Kurzbeschreibung
'##############################################################
'ReFormate Description Text from "Place.Description"
TMP_TaggIMG.Ort.Description = Tools.Convert.Coding.Base64_To_Ascii(Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Place_Description", Nothing))
'##############################################################
'Ortsangabe-GPS Koordinaten
TMP_TaggIMG.Ort.GPS = Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Place_GPS", Nothing)
'Load Marks
'sMark_Index = Modul_Tools.Config_INI_ReadValue(INI_Locate, ID, "Title")
i = 0
Do While i <= 200
Mark_Index = ("Mark" & Convert.ToString(i) & "_ID")
Mark_ID = Tools.Data.File.INI_ReadValue(INI_Locate, sKey, Mark_Index)
If Mark_ID <> "" Then
i += 1
Mark_PositionX = Convert.ToDouble(Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Mark" & Convert.ToString(i) & "_PositionX", "0"))
Mark_PositionY = Convert.ToInt32(Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Mark" & Convert.ToString(i) & "_PositionY", "0"))
Mark_Radius = Convert.ToInt32(Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Mark" & Convert.ToString(i) & "_Radius", "0"))
'##############################################################
'ReFormate Description Text from "Mark_Description"
Mark_Description = Tools.Convert.Coding.Base64_To_Ascii(Tools.Data.File.INI_ReadValue(INI_Locate, sKey, "Mark" & Convert.ToString(i) & "_Description", Nothing))
'##############################################################
'Erstellen eines Neuen Marks
TMP_TaggIMG.Create_NewMark(Mark_ID, Mark_PositionX, Mark_PositionY, Mark_Radius, Mark_Description)
Else
'Verlasse Schleife
Exit Do
End If
Loop
End If 'File.Exists(INI_Locate)
End If 'File.Exists(PicturePath)
INI_Load_Taggs = TMP_TaggIMG
End Function
Private Sub INI_Save_Taggs(ByVal oTaggedIMG As Classen.PictureTagger.TaggedIMG, Optional ByVal ForEachDat As Boolean = False)
'### INI Einstellungen ###
Dim INI_Locate As String
Dim INI_Name As String
Dim PicturePath As String = oTaggedIMG.Path
If ForEachDat Then
INI_Name = System.IO.Path.Combine(System.IO.Path.GetFileName(PicturePath), ".ini")
INI_Locate = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(PicturePath), INI_Name)
Else
INI_Name = "Tagg.ini"
INI_Locate = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(PicturePath), INI_Name)
End If
Dim i As Long
'### Main ##
If System.IO.File.Exists(PicturePath) Then
If Not System.IO.File.Exists(INI_Locate) Then System.IO.File.Create(INI_Locate)
'Deklarationen
Dim sKey = oTaggedIMG.ID
'Titel
Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Title", oTaggedIMG.Title)
'Kurzbeschreibung
'##############################################################
'Formate Description Text from "Description"
Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Description", Tools.Convert.Coding.Ascii_To_Base64(oTaggedIMG.Description))
'##############################################################
'Zeitangabe
Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Time", oTaggedIMG.Time)
'Ortsangabe-Title
Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Place_Title", oTaggedIMG.Ort.Title)
'Ortsangabe-Adresse
Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Place_Adresse", oTaggedIMG.Ort.Adresse)
'Ortsangabe-Kurzbeschreibung
'##############################################################
'Formate Description Text from "TMP_TaggIMG.Place.Description"
Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Place_Description", Tools.Convert.Coding.Ascii_To_Base64(oTaggedIMG.Ort.Description))
'##############################################################
'Ortsangabe-GPS Koordinaten
Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Place_GPS", oTaggedIMG.Ort.GPS)
'Save Marks ############### wird noch geändert ############### <--
'i = 0
'If oTaggedIMG.Markierung(0).ID <> "" Then
' For i = 0 To UBound(oTaggedIMG.Markierung)
' Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Mark" & i & "_ID", Convert.ToString(i))
' Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Mark" & i & "_PositionX", Convert.ToString(oTaggedIMG.Markierung(i).PositionX))
' Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Mark" & i & "_PositionY", Convert.ToString(oTaggedIMG.Markierung(i).PositionY))
' Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Mark" & i & "_Radius", Convert.ToString(oTaggedIMG.Markierung(i).Radius))
' Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Mark" & i & "_Description", Tools.Convert.Coding.Ascii_To_Base64(oTaggedIMG.Markierung(i).Description))
' 'Schreibe Begrenzung
' Tools.Data.File.INI_WriteValue(INI_Locate, sKey, "Mark_MaxIndex", i)
' Next i
'End If
End If 'File.Exists(PicturePath)
End Sub
'###################################################################################################################
'############### Taggs With DB #####################################################################################
'###################################################################################################################
End Module 'PictureTagger
End Namespace 'Stammbaum.Module.PictureTagger