74 lines
3.1 KiB
VB.net
74 lines
3.1 KiB
VB.net
|
|
Imports netDxf
|
|
Module ModuloGestionFile
|
|
Public PATH As String = My.Computer.FileSystem.CurrentDirectory.ToString
|
|
Public Structure filtri_file
|
|
Const immgagini_jpg = "file images (*.jpg)|*.jpg"
|
|
Const immgagini_bmp = "file images (*.bmp)|*.bmp"
|
|
Const immgagini_png = "file images (*.png)|*.png"
|
|
Const immgagini_dxf = "file mask (*.dxf)|*.dxf"
|
|
Const immgagini_all = "All files (*.*)|*.*"
|
|
|
|
End Structure
|
|
Public Function apriImmagine(formati As Array) As Bitmap
|
|
Dim testo_filtri = formati(0)
|
|
For i = 1 To formati.Length - 1
|
|
testo_filtri &= "| " & formati(i)
|
|
Next
|
|
Dim immagine As Bitmap
|
|
Using f As New OpenFileDialog
|
|
f.InitialDirectory = PATH + "\maschere"
|
|
f.Filter = testo_filtri
|
|
If f.ShowDialog = DialogResult.OK Then
|
|
immagine = New Bitmap(f.FileName)
|
|
Return immagine
|
|
Else
|
|
|
|
Return Nothing
|
|
End If
|
|
End Using
|
|
End Function
|
|
Public Function apriDXF() As DxfDocument
|
|
Using f As New OpenFileDialog
|
|
Dim dxf As New DxfDocument
|
|
f.InitialDirectory = PATH + "\maschere\"
|
|
f.Filter = filtri_file.immgagini_dxf
|
|
If f.ShowDialog = DialogResult.OK Then
|
|
Try
|
|
Return DxfDocument.Load(f.FileName)
|
|
Catch err As netDxf.IO.DxfVersionNotSupportedException
|
|
Dim mess = MsgBox("ATTENZIONE il file che si sta tentando di aprire non è un file dxf valido. Usare programmi compatibili tipo AutoCad", MsgBoxStyle.OkOnly, "Errore Compatibilità")
|
|
Return Nothing
|
|
End Try
|
|
|
|
Else
|
|
|
|
Return Nothing
|
|
End If
|
|
End Using
|
|
End Function
|
|
Public Function ImportaDXF() As Boolean
|
|
|
|
Using f As New OpenFileDialog
|
|
|
|
f.InitialDirectory = PATH + "\maschere\"
|
|
f.Filter = "mask file (*.dxf)|*.dxf"
|
|
If f.ShowDialog = DialogResult.OK Then
|
|
'' .WriteLine("nome file apridxf=" + f.FileName)
|
|
'COMMENTATO PER EVITARE ERRORE miaMAschera = New maschera(PictureBox1, f.FileName, immagineBase)
|
|
'COMMENTATO PER EVITARE ERRORE immaginemaschera = New maschera_base(immagineBase, miaMAschera)
|
|
'testo += Chr(13) + Chr(10) + "Raggio MAschera=" + miaMAschera.info.Raggio.ToString
|
|
Dim ris = MsgBox("importare " + f.FileName + " nella directory " + f.InitialDirectory + "?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Importa Maschera")
|
|
'' .WriteLine("ris=" + ris.ToString)
|
|
If ris = MsgBoxResult.Yes Then
|
|
'IngAC_FILE_COPIA(f.FileName, f.InitialDirectory + "ccc.ddd", True)
|
|
Dim NomeFile As String = System.IO.Path.GetFileName(f.FileName)
|
|
My.Computer.FileSystem.CopyFile(f.FileName, f.InitialDirectory + NomeFile)
|
|
End If
|
|
Return True
|
|
End If
|
|
End Using
|
|
Return False
|
|
End Function
|
|
End Module
|