Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 16dcde18 authored by Raphael LUZ's avatar Raphael LUZ
Browse files

Merge

parents 6f341bb5 a8f1e112
No related branches found
No related tags found
No related merge requests found
Showing
with 18301 additions and 324 deletions
syntax: glob syntax: glob
bin/* # Ignore Visual Studio 2008 files
obj/* *.obj
VECTO.suo *.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.lib
*.sbr
*.scc
[Bb]in
[Dd]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
\ No newline at end of file
<#
.SYNOPSIS
Gets file encoding.
.DESCRIPTION
The Get-FileEncoding function determines encoding by looking at Byte Order Mark (BOM).
Based on port of C# code from http://www.west-wind.com/Weblog/posts/197245.aspx
.EXAMPLE
Get-ChildItem *.ps1 | select FullName, @{n='Encoding';e={Get-FileEncoding $_.FullName}} | where {$_.Encoding -ne 'ASCII'}
This command gets ps1 files in current directory where encoding is not ASCII
.EXAMPLE
Get-ChildItem *.ps1 | select FullName, @{n='Encoding';e={Get-FileEncoding $_.FullName}} | where {$_.Encoding -ne 'ASCII'} | foreach {(get-content $_.FullName) | set-content $_.FullName -Encoding ASCII}
Same as previous example but fixes encoding using set-content
.EXAMPLE
Do this next line before or add function in Profile.ps1
Import-Module .\Get-FileEncoding.ps1
.NOTES
File Name : Get-FileEncoding.ps1
Author : <Unknwon>, F.RICHARD, ankostis
Requires : PowerShell V2 CTP3
.LINK
http://franckrichard.blogspot.it/2010/08/powershell-get-encoding-file-type.html
http://unicode.org/faq/utf_bom.html
.LINK
http://en.wikipedia.org/wiki/Byte_order_mark
#>
function Get-FileEncoding {
[CmdletBinding()]
Param (
[Parameter(Position = 0, Mandatory = $True, ValueFromPipelineByPropertyName = $True)]
[alias(PSPath)]
[alias(FullName)]
[PSObject[]]$Path
)
PROCESS {
$files = @();
if($path) {
$files += $path
} else {
$files += @($input | Foreach-Object { $_.FullName })
}
#echo "___: $_"
#echo "PTH: $path"
#echo "INP: $input"
#echo "INO: $InputObject"
#echo "FIL: $files"
foreach($file ile in $files) {
[byte[]]$byte = get-content -Encoding byte -ReadCount 4 -TotalCount 4 -Path $File
#Write-Host Bytes: $byte[0] $byte[1] $byte[2] $byte[3]
# EF BB BF (UTF8)
if ( $byte[0] -eq 0xef -and $byte[1] -eq 0xbb -and $byte[2] -eq 0xbf )
{ printout 'UTF8' }
# FE FF (UTF-16 Big-Endian)
elseif ($byte[0] -eq 0xfe -and $byte[1] -eq 0xff)
{ printout 'Unicode UTF-16 Big-Endian' }
# FF FE (UTF-16 Little-Endian)
elseif ($byte[0] -eq 0xff -and $byte[1] -eq 0xfe)
{ printout 'Unicode UTF-16 Little-Endian' }
# 00 00 FE FF (UTF32 Big-Endian)
elseif ($byte[0] -eq 0 -and $byte[1] -eq 0 -and $byte[2] -eq 0xfe -and $byte[3] -eq 0xff)
{ printout 'UTF32 Big-Endian' }
# FE FF 00 00 (UTF32 Little-Endian)
elseif ($byte[0] -eq 0xfe -and $byte[1] -eq 0xff -and $byte[2] -eq 0 -and $byte[3] -eq 0)
{ printout 'UTF32 Little-Endian' }
# 2B 2F 76 (38 | 38 | 2B | 2F)
elseif ($byte[0] -eq 0x2b -and $byte[1] -eq 0x2f -and $byte[2] -eq 0x76 -and ($byte[3] -eq 0x38 -or $byte[3] -eq 0x39 -or $byte[3] -eq 0x2b -or $byte[3] -eq 0x2f) )
{ printout 'UTF7'}
# F7 64 4C (UTF-1)
elseif ( $byte[0] -eq 0xf7 -and $byte[1] -eq 0x64 -and $byte[2] -eq 0x4c )
{ printout 'UTF-1' }
# DD 73 66 73 (UTF-EBCDIC)
elseif ($byte[0] -eq 0xdd -and $byte[1] -eq 0x73 -and $byte[2] -eq 0x66 -and $byte[3] -eq 0x73)
{ printout 'UTF-EBCDIC' }
# 0E FE FF (SCSU)
elseif ( $byte[0] -eq 0x0e -and $byte[1] -eq 0xfe -and $byte[2] -eq 0xff )
{ printout 'SCSU' }
# FB EE 28 (BOCU-1)
elseif ( $byte[0] -eq 0xfb -and $byte[1] -eq 0xee -and $byte[2] -eq 0x28 )
{ printout 'BOCU-1' }
# 84 31 95 33 (GB-18030)
elseif ($byte[0] -eq 0x84 -and $byte[1] -eq 0x31 -and $byte[2] -eq 0x95 -and $byte[3] -eq 0x33)
{ printout 'GB-18030' }
else
{ printout 'ASCII' }
}
} # End file-loop
}
function printout($str) {
if ($files.length > 1) {
echo "${file}:$str"
} else {
#echo "${file}:$str"
echo "$str"
}
}
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
## 0. Transform all ACII files to UTF
$basepath = '../../VECTO';
ls "*/*/*/*.vb","*/*/*.vb","*/*.vb","*.vb" |
%{
$f=$_;
if ((Get-FileEncoding $f) -ne UTF8) {
echo "Re-encoding $f";
(cat $f) |
Out-File -FilePath $f -Encoding UTF8
} else {
echo "Skipping $f";
}
}
## 1. Gather all single-line comments.
##
filter extract-comments {
if ($_.Path -ne $last.Path) {
$file = $_.Filename;
echo ">>> $file";
}
$lno = $_.LineNumber;
$line = $_.Line;
echo "${lno}:$line";
$last = $_
}
Select-String -Path *.vb,*/*vb -Pattern "^\s*'.*[a-z]" -Encoding UTF8 |
extract-comments |
Out-File -Encoding UTF8 ../comments.txt
## 2. (MANUAL)Inspect and discard any comments .
## 3. Isolate text to translate.
##
filter isolate-text() {
if ($_ -match "\d+:\s*'(C )?\W*(\w.*)$") {
echo $Matches[2];
} else {
echo "";
}
}
cat comments2.txt |
isolate-text |
Out-File -Encoding UTF8 ../translate_from.txt
## 4a. (MANUAL)Inspect translation and go back to 1 or 4a in case of problems.
## 5b. (MANUAL) Store translated-comments into ../translate_to.txt
function isolate-untranslated($coms, $from, $to) {
for($i=0; $i -lt $coms.length; $i++) {
$cline = $coms[$i];
$fline = $from[$i];
$tline = $to[$i];
$tline = $tline.trim();
if ($cline.startsWith('>>> ')) {
echo "$cline" | Out-File -Encoding UTF8 comments_untrans.txt -Append;
} elseif ($tline -and !($tline.startsWith('@'))) {
echo "$fline" | Out-File -Encoding UTF8 comments_untrans.txt -Append;
}
}
}
## 5.a. Merge translated comment-lines with original ones.
##
$coms=cat comments2.txt
$from=cat translate_from.txt
$to=cat translate_to.txt
$coms.length, $from.length, $to.length
$r=for($i=0; $i -lt $coms.length; $i++) {
$cline = $coms[$i];
$fline = $from[$i];
$tline = $to[$i];
$tline = $tline.trim();
if ($cline.startsWith('>>> ')) {
echo "$cline"
} else {
$m = [regex]::Matches($cline, "(\d+):\s*'(C )?\W*(\w.*)$", "IgnoreCase");
if ($m[0]) {
$ccm = $m[0].Groups[3];
$ocom = $ccm.Value;
$ocomi = $ccm.Index;
$ln = $m[0].Groups[1].Value;
} else {
$ocom = "";
$ln = "<?>"
}
if ($ocom -ne $fline) {
echo "Unmtached with Original(parsed) line ${ln}:`n Parsed: ${ocom}`n TrFrom: $fline";
return;
}
if (!$tline) {
#echo "$nline"; ## UNCOMMENT HERE and delete the rest else-case for producing original.txt
continue;
} elseif ($tline.startsWith('@')) {
$tline = $tline.Substring(1);
$nline = $cline.Substring(0, $ocomi) + "$tline";
} else {
$nline = $cline.Substring(0, $ocomi) + "${fline} |@@| ${tline}";
}
echo "$nline"
}
}
Set-Content -Path comments2-trans.txt -Value $r -Encoding UTF8
## 5.b Manually remove empty filepaths (those without translated lines)
## 6.a comments2-orig.txt: Created by runing the above code slightly modified
## so as to remove those non-translated lines from the verbatim-comments, and then
## 6.b Manually remove empty filepaths (those without translated lines)
## 7. PATCH files
function matchTransLine($line) {
[hashtable]$res = @{};
$m = [regex]::Matches($line, "^(\d+):(.*)");
if ($m[0]) {
$mm = $m[0];
$res.lnum = $mm.Groups[1].Value;
$res.line = $mm.Groups[2].Value;
return $res;
} else {
echo "Bad comment line: `n$line"
return $Null;
}
}
filter Patch-Comments() {
BEGIN {
# Define it externally, depending on the PWD.
#$basepath = '../../VECTO';
$i = -1;
$file = $Null;
$isFileOK = $true;
}
PROCESS {
$i++;
if ($_.startsWith('>>> ')) {
if ($file) {
if ($isFileOK) {
echo $file | Out-File -FilePath $fname -Encoding UTF8
echo "Merged $fname";
} else {
echo "FAILED $fname";
}
}
$isFileOK = $true;
$fname = "$basepath/" + $_.Substring(4);
echo "Merging: ${fname}";
$file = cat "$fname";
} else {
$m = matchTransLine($coms[$i]);
if (!$m) {
$isFileOK = $false;
return;
}
$expline = $m.line;
$explnum = $m.lnum;
$m = matchTransLine($_);
if (!$m) {
$isFileOK = $false;
return;
}
$trnline = $m.line;
$trnlnum = $m.lnum;
if ($explnum -ne $trnlnum) {
$isFileOK = $false;
echo "Mismatch in line-nums:`n EXP($explnum):$expline`n TRN($trnlnum):$trnline"
} else {
$orgline = $file[($trnlnum - 1)];
if ($orgline -ne $expline) {
$isFileOK = $false;
echo "Unexpected line $lnum:`n ORG:$orgline`n EXP:$expline`n TRN:$trnline"
} else {
$file[($trnlnum - 1)] = $trnline;
}
}
}
}## End proc-loop
END {
if ($file) {
if ($isFileOK) {
echo $file | Out-File -FilePath $fname -Encoding UTF8
echo "Merged $fname";
} else {
echo "FAILED $fname";
}
}
}
}
$coms=cat ..\Tools\TranslateComments\comments2-orig-EmCalc.txt
$basepath = '.';
cat ..\Tools\TranslateComments\comments2-trans-EmCalc.txt| Patch-Comments
## The last cmd should run without any errors.
## DONE
## OTHER
filter clusterize-comments {
if ($_.Path -eq $last.Path) {
if ($_.LineNumber -ne ($Last.LineNumber + 1)) {
$lno = $_.LineNumber;
echo "@@$lno";
}
} else {
$file = $_.Filename;
echo "--- $file";
echo "+++ $file";
$lno = $_.LineNumber;
echo "@@$lno";
}
$line = $_.Line;
echo " $line";
$last = $_
}
filter ec {
if ($_.Path -ne $last.Path) {
$file = $_.Filename;
echo ">>> $file";
}
$lno = $_.LineNumber;
$line = $_.Line;
echo "${lno}:$line";
$last = $_
}
Select-String -Encoding Default -Path ../../*.vb,../../*/*vb -Pattern "^\s*'"|
select Path,LineNumber,Line|
Export-Clixml -Path ../comments.xml
## Invocted from with from within 'VectoSource/Vecto' folder.
Select-String -Encoding Default -Path ../../*.vb,../../*/*vb -Pattern "^\s*'.*[a-z]"|
select -Property LineNumber,Line |
Export-Csv -Encoding UTF8 -NoTypeInformation -Delimiter ';' -Path comments.csv
This diff is collapsed.
This diff is collapsed.
...@@ -81,28 +81,28 @@ lbClose: ...@@ -81,28 +81,28 @@ lbClose:
If Not fADV.OpenWrite(sFilePath) Then Return False If Not fADV.OpenWrite(sFilePath) Then Return False
'Zeile 1: FZP-Datei 'Line 1: FZP file
fADV.WriteLine(fFZPpath.PathOrDummy) fADV.WriteLine(fFZPpath.PathOrDummy)
'Zeile 2: FLT-Datei 'Line 2: FLT file
fADV.WriteLine(fFLTpath.PathOrDummy) fADV.WriteLine(fFLTpath.PathOrDummy)
'Zeile 3: TEM-Datei 'Line 3: TEM file
fADV.WriteLine(fTEMpath.PathOrDummy) fADV.WriteLine(fTEMpath.PathOrDummy)
'Zeile 4: RndSeed 'Line 4: RndSeed
fADV.WriteLine(RndSeed.ToString) fADV.WriteLine(RndSeed.ToString)
'Zeile 5: MISKAMout True/False 'Line 5: MISKAMout True/False|
fADV.WriteLine(Math.Abs(CInt(SD3out))) fADV.WriteLine(Math.Abs(CInt(SD3out)))
'Zeile 6: STRfilter True/False 'Line 6: STRfilter True/False
fADV.WriteLine(Math.Abs(CInt(STRfilter))) fADV.WriteLine(Math.Abs(CInt(STRfilter)))
'Zeile 7: Distance filter für SUM.STR 'Line 7: Distance filters for SUM.STR
fADV.WriteLine(STRSUMdistflt.ToString) fADV.WriteLine(STRSUMdistflt.ToString)
'Zeile 8+: STR Dateien 'Line 8 +: STR files
For Each SubPath In fSTRpaths For Each SubPath In fSTRpaths
fADV.WriteLine(SubPath.PathOrDummy) fADV.WriteLine(SubPath.PathOrDummy)
Next Next
......
This diff is collapsed.
Imports System.Collections.Generic Imports System.Collections.Generic
Namespace My Namespace My
' Fr MyApplication sind folgende Ereignisse verfgbar: ' The following events are available for MyApplication:
' '
' Startup: Wird beim Starten der Anwendung noch vor dem Erstellen des Startformulars ausgelst. ' Startup: Raised when the application starts even before the creation of the Startup-forms.
' Shutdown: Wird nach dem Schlieen aller Anwendungsformulare ausgelst. Dieses Ereignis wird nicht ausgelst, wenn die Anwendung nicht normal beendet wird. ' Shutdown: Raised after closing all the application forms. This event is not raised if the application terminates abnormally.
' UnhandledException: Wird ausgelst, wenn in der Anwendung eine unbehandelte Ausnahme auftritt. ' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Wird beim Starten einer Einzelinstanzanwendung ausgelst, wenn diese bereits aktiv ist. ' StartupNextInstance: Raised when launching a single-instance application, and one is already active.
' NetworkAvailabilityChanged: Wird beim Herstellen oder Trennen der Netzwerkverbindung ausgelst. ' NetworkAvailabilityChanged: Occurs when connecting or disconnecting to the network.
Partial Friend Class MyApplication Partial Friend Class MyApplication
'Initialisierung 'Initialization
Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
Dim logfDetail As IO.FileInfo Dim logfDetail As IO.FileInfo
...@@ -22,7 +22,7 @@ Namespace My ...@@ -22,7 +22,7 @@ Namespace My
FirstTime = False FirstTime = False
'Pfade 'Paths
MyAppPath = My.Application.Info.DirectoryPath & "\" MyAppPath = My.Application.Info.DirectoryPath & "\"
MyConfPath = MyAppPath & "config\" MyConfPath = MyAppPath & "config\"
MyDeclPath = MyAppPath & "Declaration\" MyDeclPath = MyAppPath & "Declaration\"
...@@ -30,7 +30,7 @@ Namespace My ...@@ -30,7 +30,7 @@ Namespace My
StartLogfile() StartLogfile()
'Falls Ordner nicht vorhanden: Erstellen! 'If folder does not exist: Create!
If Not IO.Directory.Exists(MyConfPath) Then If Not IO.Directory.Exists(MyConfPath) Then
FirstTime = True FirstTime = True
Try Try
...@@ -49,7 +49,7 @@ Namespace My ...@@ -49,7 +49,7 @@ Namespace My
Try Try
IO.Directory.CreateDirectory(FB_FilHisDir) IO.Directory.CreateDirectory(FB_FilHisDir)
'Directories.txt vorkonfigurieren 'Preconfigure Directories.txt
Try Try
s = IO.Directory.GetParent(My.Application.Info.DirectoryPath).ToString & "\" s = IO.Directory.GetParent(My.Application.Info.DirectoryPath).ToString & "\"
Catch ex As Exception Catch ex As Exception
...@@ -75,7 +75,7 @@ Namespace My ...@@ -75,7 +75,7 @@ Namespace My
End Try End Try
End If End If
'Trennzeichen! 'Separator!
SetCulture = False SetCulture = False
If System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator <> "." Then If System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator <> "." Then
SetCulture = True SetCulture = True
...@@ -88,14 +88,14 @@ Namespace My ...@@ -88,14 +88,14 @@ Namespace My
End Try End Try
End If End If
'Klassen initialisieren 'Initialize Classes
sKey = New csKey sKey = New csKey
JobFileList = New List(Of String) JobFileList = New List(Of String)
JobCycleList = New List(Of String) JobCycleList = New List(Of String)
DEV = New cDEV DEV = New cDEV
VEC = New cVECTO VEC = New cVECTO
Cfg = New cConfig 'ACHTUNG: cConfig.New lst cConfig.SetDefault aus welches sKey bentigt dehalb muss sKey schon vorher initialisiert werden!! Cfg = New cConfig 'ACHTUNG: cConfig.New löst cConfig.SetDefault aus welches sKey benötigt dehalb muss sKey schon vorher initialisiert werden!!
ProgBarCtrl = New cProgBarCtrl ProgBarCtrl = New cProgBarCtrl
...@@ -103,13 +103,13 @@ Namespace My ...@@ -103,13 +103,13 @@ Namespace My
Cfg.ConfigLOAD() Cfg.ConfigLOAD()
'Log starten 'Start Log
If IO.File.Exists(MyAppPath & "LOG.txt") Then If IO.File.Exists(MyAppPath & "LOG.txt") Then
'Dateigre checken 'File size check
logfDetail = My.Computer.FileSystem.GetFileInfo(MyAppPath & "LOG.txt") logfDetail = My.Computer.FileSystem.GetFileInfo(MyAppPath & "LOG.txt")
'Falls Log zu gro: lschen 'If Log too large: Delete
If logfDetail.Length / (2 ^ 20) > Cfg.LogSize Then If logfDetail.Length / (2 ^ 20) > Cfg.LogSize Then
LOGfile.WriteLine("Starting new logfile") LOGfile.WriteLine("Starting new logfile")
...@@ -136,7 +136,7 @@ Namespace My ...@@ -136,7 +136,7 @@ Namespace My
End If End If
'Lizenz initialisieren 'License initialization
Lic = New vectolic.cLicense Lic = New vectolic.cLicense
Lic.AppVersion = VECTOvers Lic.AppVersion = VECTOvers
Lic.FilePath = MyAppPath & "license.dat" Lic.FilePath = MyAppPath & "license.dat"
......
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class FB_Dialog Partial Class FB_Dialog
Inherits System.Windows.Forms.Form Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _ <System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean) Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try Try
...@@ -14,12 +14,12 @@ Partial Class FB_Dialog ...@@ -14,12 +14,12 @@ Partial Class FB_Dialog
End Try End Try
End Sub End Sub
'Wird vom Windows Form-Designer benötigt. 'Wird vom Windows Form-Designer benötigt.
Private components As System.ComponentModel.IContainer Private components As System.ComponentModel.IContainer
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich. 'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich. 'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich. 'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _ <System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent() Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container() Me.components = New System.ComponentModel.Container()
......
Public Class FB_Dialog Public Class FB_Dialog
Private MyFolder As String Private MyFolder As String
Private MyFiles() As String Private MyFiles() As String
...@@ -29,9 +29,9 @@ Public Class FB_Dialog ...@@ -29,9 +29,9 @@ Public Class FB_Dialog
'New 'New
Public Sub New(ByVal LightMode As Boolean) Public Sub New(ByVal LightMode As Boolean)
' Dieser Aufruf ist fr den Windows Form-Designer erforderlich. ' This call is required by the Windows Form Designer.
InitializeComponent() InitializeComponent()
' Fgen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. ' Append any initialization after the InitializeComponent() call.
MyID = "Default" MyID = "Default"
UpdateLock = False UpdateLock = False
Initialized = False Initialized = False
...@@ -80,7 +80,7 @@ Public Class FB_Dialog ...@@ -80,7 +80,7 @@ Public Class FB_Dialog
If Me.DialogResult = Windows.Forms.DialogResult.OK Then If Me.DialogResult = Windows.Forms.DialogResult.OK Then
If bBrowseFolder Then If bBrowseFolder Then
path = Trim(Me.TextBoxPath.Text) path = Trim(Me.TextBoxPath.Text)
'Wenn leerer Pfad: Aktuellen Ordner (MyFolder) nehmen 'If empty path: use the Current-folder(MyFolder)
If path = "" Then If path = "" Then
path = MyFolder path = MyFolder
Else Else
...@@ -95,15 +95,15 @@ Public Class FB_Dialog ...@@ -95,15 +95,15 @@ Public Class FB_Dialog
ReDim MyFiles(0) ReDim MyFiles(0)
MyFiles(0) = path MyFiles(0) = path
Else Else
'Abbruch wenn leerer Pfad 'Stop if empty path
If Trim(Me.TextBoxPath.Text) = "" Then If Trim(Me.TextBoxPath.Text) = "" Then
e.Cancel = True e.Cancel = True
Exit Sub Exit Sub
End If End If
LastExt = Trim(Me.ComboBoxExt.Text) LastExt = Trim(Me.ComboBoxExt.Text)
'Dateien in Array bernehmen 'Assume Files in array
If Microsoft.VisualBasic.Left(Me.TextBoxPath.Text, 1) = "<" And Me.ListViewFiles.SelectedItems.Count > 0 Then If Microsoft.VisualBasic.Left(Me.TextBoxPath.Text, 1) = "<" And Me.ListViewFiles.SelectedItems.Count > 0 Then
'Mehrere Dateien ausgewhlt 'Multiple files selected
ReDim MyFiles(Me.ListViewFiles.SelectedItems.Count - 1) ReDim MyFiles(Me.ListViewFiles.SelectedItems.Count - 1)
x = -1 x = -1
For Each lv0 As ListViewItem In Me.ListViewFiles.Items For Each lv0 As ListViewItem In Me.ListViewFiles.Items
...@@ -114,13 +114,13 @@ Public Class FB_Dialog ...@@ -114,13 +114,13 @@ Public Class FB_Dialog
Next Next
bMultiFiles = True bMultiFiles = True
Else Else
'Einzelne Datei 'Single File
path = Trim(Me.TextBoxPath.Text) path = Trim(Me.TextBoxPath.Text)
'Primre Extension (u.a. fr bForceExt) 'Primary extension (eg for bForceExt)
Ext = Trim(Me.ComboBoxExt.Text.Split(",")(0)) Ext = Trim(Me.ComboBoxExt.Text.Split(",")(0))
'Falls Datei ohne Pfad angegeben dann Pfad hinzufgen 'If file without path then append path
If Microsoft.VisualBasic.Mid(path, 2, 1) <> ":" Then path = MyFolder & path If Microsoft.VisualBasic.Mid(path, 2, 1) <> ":" Then path = MyFolder & path
'Falls statt Datei ein Ordner eingegeben wurde: Auf Ordner wechseln und Abbruch 'If instead of File a Folder is entered: Switch to Folder and Abort
If IO.Directory.Exists(path) Then If IO.Directory.Exists(path) Then
SetFolder(path) SetFolder(path)
e.Cancel = True e.Cancel = True
...@@ -131,18 +131,18 @@ Public Class FB_Dialog ...@@ -131,18 +131,18 @@ Public Class FB_Dialog
If UCase(IO.Path.GetExtension(path)) <> "." & UCase(Ext) Then path &= "." & Ext If UCase(IO.Path.GetExtension(path)) <> "." & UCase(Ext) Then path &= "." & Ext
HasExt = True HasExt = True
Else Else
'Check ob Datei mit Ext angegeben 'Check whether specified a File with Ext
HasExt = (Microsoft.VisualBasic.Len(IO.Path.GetExtension(path)) > 1) HasExt = (Microsoft.VisualBasic.Len(IO.Path.GetExtension(path)) > 1)
End If End If
'Falls Datei ohne Endung (nach bForceExt-Abfrage) und nicht existiert dann primre Endung hinzufgen 'If File without Extension (after bForceExt question) and it does not exist, then add primary Extension
If Not HasExt Then If Not HasExt Then
If Ext <> "*" And Ext <> "" Then If Ext <> "*" And Ext <> "" Then
If Not IO.File.Exists(path) Then path &= "." & Ext If Not IO.File.Exists(path) Then path &= "." & Ext
End If End If
End If End If
'Check ob Datei existiert 'Check that File exists
If IO.File.Exists(path) Then If IO.File.Exists(path) Then
'Ja: Check ob Overwrite wenn bOverwriteCheck 'Yes: when bOverwriteCheck, check for Overwrite
If bOverwriteCheck Then If bOverwriteCheck Then
If MsgBox("Overwrite " & path & " ?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then If MsgBox("Overwrite " & path & " ?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
e.Cancel = True e.Cancel = True
...@@ -150,14 +150,14 @@ Public Class FB_Dialog ...@@ -150,14 +150,14 @@ Public Class FB_Dialog
End If End If
End If End If
Else Else
'Nein: Abbruch wenn bFileMustExist 'No: abort if bFileMustExist
If bFileMustExist Then If bFileMustExist Then
MsgBox("The file " & path & " does not exist!", MsgBoxStyle.Critical) MsgBox("The file " & path & " does not exist!", MsgBoxStyle.Critical)
e.Cancel = True e.Cancel = True
Exit Sub Exit Sub
End If End If
End If End If
'MyFiles definieren 'Define MyFiles
ReDim MyFiles(0) ReDim MyFiles(0)
MyFiles(0) = path MyFiles(0) = path
bMultiFiles = False bMultiFiles = False
...@@ -172,7 +172,7 @@ Public Class FB_Dialog ...@@ -172,7 +172,7 @@ Public Class FB_Dialog
If Not Initialized Then Init() If Not Initialized Then Init()
'FolderHistory ContextMenu laden 'Load Folder History ContextMenu
For x = 0 To 9 For x = 0 To 9
Me.ContextMenuHisFolder.Items(x).Text = FB_FolderHistory(x) Me.ContextMenuHisFolder.Items(x).Text = FB_FolderHistory(x)
Next Next
...@@ -218,23 +218,23 @@ Public Class FB_Dialog ...@@ -218,23 +218,23 @@ Public Class FB_Dialog
End If End If
'Pfad definieren 'Define Path
' Falls kein Pfad angegeben wird: Letzter Ordner, kein Dateiname ' If no path is specified: Last folder, no file name
If path = "" Then path = FB_FolderHistory(0) If path = "" Then path = FB_FolderHistory(0)
' Falls Pfadlnge zu klein (Pfad ungltig): Letzte Datei ' If path-length too small (Path is invalid): Last File
If path.Length < 2 Then path = LastFile If path.Length < 2 Then path = LastFile
'Ordner ffnen - Falls kein Ordner im Pfad: Letzter Ordner 'Open Folder - If no folder in the path: Last folder
If fPATH(path) = "" Then If fPATH(path) = "" Then
'Falls Datei ohne Pfad angegeben 'If given a file without path
If Trim(FB_FolderHistory(0)) = "" Then If Trim(FB_FolderHistory(0)) = "" Then
SetFolder("C:\") SetFolder("C:\")
Else Else
SetFolder(FB_FolderHistory(0)) SetFolder(FB_FolderHistory(0))
End If End If
Else Else
'...sonst: '...Otherwise:
SetFolder(fPATH(path)) SetFolder(fPATH(path))
End If End If
If bBrowseFolder Then If bBrowseFolder Then
...@@ -244,7 +244,7 @@ Public Class FB_Dialog ...@@ -244,7 +244,7 @@ Public Class FB_Dialog
Me.TextBoxPath.Text = IO.Path.GetFileName(path) Me.TextBoxPath.Text = IO.Path.GetFileName(path)
End If End If
'Form anzeigen---------------------------------------------------- 'Show form ------------------------------------------------ ----
Me.ShowDialog() Me.ShowDialog()
If Me.DialogResult = Windows.Forms.DialogResult.OK Then If Me.DialogResult = Windows.Forms.DialogResult.OK Then
'File / Folder History 'File / Folder History
...@@ -256,7 +256,7 @@ Public Class FB_Dialog ...@@ -256,7 +256,7 @@ Public Class FB_Dialog
UpdateHisFolder(fPATH(LastFile)) UpdateHisFolder(fPATH(LastFile))
If Not bBrowseFolder Then UpdateHisFile(LastFile) If Not bBrowseFolder Then UpdateHisFile(LastFile)
End If End If
'Globale Folder History updaten 'Update Global History Folder
For x = 0 To 9 For x = 0 To 9
FB_FolderHistory(x) = Me.ContextMenuHisFolder.Items(x).Text FB_FolderHistory(x) = Me.ContextMenuHisFolder.Items(x).Text
Next Next
...@@ -269,7 +269,7 @@ Public Class FB_Dialog ...@@ -269,7 +269,7 @@ Public Class FB_Dialog
End If End If
End Function End Function
'Schlieen und File/Folder History speichern 'Close and save File / Folder History
Public Sub SaveAndClose() Public Sub SaveAndClose()
Dim f As System.IO.StreamWriter Dim f As System.IO.StreamWriter
Dim x As Int16 Dim x As Int16
...@@ -306,7 +306,7 @@ Public Class FB_Dialog ...@@ -306,7 +306,7 @@ Public Class FB_Dialog
Me.Close() Me.Close()
End Sub End Sub
'Umschalten auf FolderBrowser 'Switching to FolderBrowser
Public Sub SetFolderBrowser() Public Sub SetFolderBrowser()
If Initialized Then Exit Sub If Initialized Then Exit Sub
bBrowseFolder = True bBrowseFolder = True
...@@ -318,7 +318,7 @@ Public Class FB_Dialog ...@@ -318,7 +318,7 @@ Public Class FB_Dialog
Me.Text = "Directory Browser" Me.Text = "Directory Browser"
End Sub End Sub
'Initialisieren 'Initialize
Private Sub Init() Private Sub Init()
Dim x As Int16 Dim x As Int16
Dim line As String Dim line As String
...@@ -326,10 +326,10 @@ Public Class FB_Dialog ...@@ -326,10 +326,10 @@ Public Class FB_Dialog
UpdateLock = True UpdateLock = True
'Globale FileBrowser Initialisierung 'Initialization for Global File Browser
If Not FB_Init Then GlobalInit() If Not FB_Init Then GlobalInit()
'Laufwerk-ComboBox laden 'Load Drive ComboBox
For x = 0 To UBound(FB_Drives) For x = 0 To UBound(FB_Drives)
Me.ComboBoxDrive.Items.Add(FB_Drives(x)) Me.ComboBoxDrive.Items.Add(FB_Drives(x))
Next Next
...@@ -392,7 +392,7 @@ Public Class FB_Dialog ...@@ -392,7 +392,7 @@ Public Class FB_Dialog
Dim f As System.IO.StreamReader Dim f As System.IO.StreamReader
'Laufwerk-Liste erstellen 'Create Drive List
ReDim FB_Drives(UBound(IO.Directory.GetLogicalDrives())) ReDim FB_Drives(UBound(IO.Directory.GetLogicalDrives()))
x = -1 x = -1
For Each drive In IO.Directory.GetLogicalDrives() For Each drive In IO.Directory.GetLogicalDrives()
...@@ -400,7 +400,7 @@ Public Class FB_Dialog ...@@ -400,7 +400,7 @@ Public Class FB_Dialog
FB_Drives(x) = Microsoft.VisualBasic.Left(drive, 2) FB_Drives(x) = Microsoft.VisualBasic.Left(drive, 2)
Next Next
'FolderHistory einlesen 'Read Folder History
For x = 0 To 19 For x = 0 To 19
FB_FolderHistory(x) = EmptyText FB_FolderHistory(x) = EmptyText
Next Next
...@@ -725,7 +725,7 @@ Public Class FB_Dialog ...@@ -725,7 +725,7 @@ Public Class FB_Dialog
Dim x As Int16 Dim x As Int16
Dim y As Int16 Dim y As Int16
If bLightMode Then Exit Sub If bLightMode Then Exit Sub
'Context Menu sortieren 'Sort Context Menu
For x = 0 To 8 For x = 0 To 8
If UCase(Me.ContextMenuHisFile.Items(x).Text.ToString) = UCase(path) Then Exit For If UCase(Me.ContextMenuHisFile.Items(x).Text.ToString) = UCase(path) Then Exit For
Next Next
...@@ -738,7 +738,7 @@ Public Class FB_Dialog ...@@ -738,7 +738,7 @@ Public Class FB_Dialog
Dim x As Int16 Dim x As Int16
Dim y As Int16 Dim y As Int16
'Context Menu sortieren 'Sort Context Menu
For x = 0 To 8 For x = 0 To 8
If UCase(Me.ContextMenuHisFolder.Items(x).Text.ToString) = UCase(path) Then Exit For If UCase(Me.ContextMenuHisFolder.Items(x).Text.ToString) = UCase(path) Then Exit For
Next Next
...@@ -757,9 +757,9 @@ Public Class FB_Dialog ...@@ -757,9 +757,9 @@ Public Class FB_Dialog
Dim y As Int16 Dim y As Int16
'Init 'Init
If Not Initialized Then Init() If Not Initialized Then Init()
'Dateien 'Files
UpdateHisFile(path) UpdateHisFile(path)
'Ordner 'Folder
path = fPATH(path) path = fPATH(path)
For x = 0 To 8 For x = 0 To 8
If UCase(FB_FolderHistory(x)) = UCase(path) Then Exit For If UCase(FB_FolderHistory(x)) = UCase(path) Then Exit For
...@@ -770,25 +770,25 @@ Public Class FB_Dialog ...@@ -770,25 +770,25 @@ Public Class FB_Dialog
FB_FolderHistory(0) = path FB_FolderHistory(0) = path
End Sub End Sub
'Ordner wechseln 'Change folder
Private Sub SetFolder(ByVal Path As String) Private Sub SetFolder(ByVal Path As String)
'Abbruch wenn keine Laufwerk-Angabe 'Abort if no drive specified
If Microsoft.VisualBasic.Mid(Path, 2, 1) <> ":" Then Exit Sub If Microsoft.VisualBasic.Mid(Path, 2, 1) <> ":" Then Exit Sub
UpdateLock = True UpdateLock = True
'Suchfelder lschen 'Delete Search-fields
Me.TextBoxSearchFile.Text = "" Me.TextBoxSearchFile.Text = ""
Me.TextBoxSearchFolder.Text = "" Me.TextBoxSearchFolder.Text = ""
'Laufwerk setzen 'Set Drive
If MyDrive <> Microsoft.VisualBasic.Left(Path, 2) Then If MyDrive <> Microsoft.VisualBasic.Left(Path, 2) Then
MyDrive = UCase(Microsoft.VisualBasic.Left(Path, 2)) MyDrive = UCase(Microsoft.VisualBasic.Left(Path, 2))
Me.ComboBoxDrive.SelectedItem = MyDrive Me.ComboBoxDrive.SelectedItem = MyDrive
End If End If
'Ordner setzen 'Set Folder
MyFolder = Path MyFolder = Path
If Microsoft.VisualBasic.Right(MyFolder, 1) <> "\" Then MyFolder &= "\" If Microsoft.VisualBasic.Right(MyFolder, 1) <> "\" Then MyFolder &= "\"
LoadListFolder() LoadListFolder()
...@@ -803,7 +803,7 @@ Public Class FB_Dialog ...@@ -803,7 +803,7 @@ Public Class FB_Dialog
End Sub End Sub
'Ordner Eine Ebene hinauf 'Folder one level up
Private Sub FolderUp() Private Sub FolderUp()
Dim path As String Dim path As String
Dim x As Int32 Dim x As Int32
...@@ -814,14 +814,14 @@ Public Class FB_Dialog ...@@ -814,14 +814,14 @@ Public Class FB_Dialog
End If End If
End Sub End Sub
'FolderListe laden 'Load Folder-List
Private Sub LoadListFolder() Private Sub LoadListFolder()
Dim SearchPat As String Dim SearchPat As String
'FolderListe lschen 'Delete Folder-List
Me.ListViewFolder.Items.Clear() Me.ListViewFolder.Items.Clear()
SearchPat = "*" & Me.TextBoxSearchFolder.Text & "*" SearchPat = "*" & Me.TextBoxSearchFolder.Text & "*"
Try Try
'Ordner hinzufgen 'Add Folder
Dim di As New IO.DirectoryInfo(MyFolder) Dim di As New IO.DirectoryInfo(MyFolder)
Dim aryFi As IO.DirectoryInfo() Dim aryFi As IO.DirectoryInfo()
Dim fi As IO.DirectoryInfo Dim fi As IO.DirectoryInfo
...@@ -834,7 +834,7 @@ Public Class FB_Dialog ...@@ -834,7 +834,7 @@ Public Class FB_Dialog
End Try End Try
End Sub End Sub
'Dateiliste laden 'Load File-list
Private Sub LoadListFiles() Private Sub LoadListFiles()
Dim x As Int32 Dim x As Int32
Dim SearchPat As String Dim SearchPat As String
...@@ -842,25 +842,25 @@ Public Class FB_Dialog ...@@ -842,25 +842,25 @@ Public Class FB_Dialog
Dim SearchExt As String Dim SearchExt As String
Dim ExtStr As String() Dim ExtStr As String()
'Abbruch wenn bBrowseFolder 'Abort if bBrowseFolder
If bBrowseFolder Then Exit Sub If bBrowseFolder Then Exit Sub
Me.LabelFileAnz.Text = "0 Files" Me.LabelFileAnz.Text = "0 Files"
'Extension-Filter definieren 'Define Extension-filter
If Trim(Me.ComboBoxExt.Text.ToString) = "" Then If Trim(Me.ComboBoxExt.Text.ToString) = "" Then
ExtStr = New String() {"*"} ExtStr = New String() {"*"}
Else Else
ExtStr = Me.ComboBoxExt.Text.ToString.Split(",") ExtStr = Me.ComboBoxExt.Text.ToString.Split(",")
End If End If
'FileListe lschen 'Delete File-List
Me.ListViewFiles.Items.Clear() Me.ListViewFiles.Items.Clear()
SearchFile = Me.TextBoxSearchFile.Text SearchFile = Me.TextBoxSearchFile.Text
Me.ListViewFiles.BeginUpdate() Me.ListViewFiles.BeginUpdate()
Try Try
'Ordner hinzufgen 'Add Folder
Dim di As New IO.DirectoryInfo(MyFolder) Dim di As New IO.DirectoryInfo(MyFolder)
Dim aryFi As IO.FileInfo() Dim aryFi As IO.FileInfo()
Dim fi As IO.FileInfo Dim fi As IO.FileInfo
......
Module FB_Global Module FB_Global
Public FB_FolderHistory(19) As String Public FB_FolderHistory(19) As String
Public FB_Drives() As String Public FB_Drives() As String
......
Imports System.Collections Imports System.Collections
'Imports System.Windows.Forms 'Imports System.Windows.Forms
'V1.0 10.12.2010 'V1.0 10.12.2010
...@@ -11,18 +11,18 @@ Imports System.Collections ...@@ -11,18 +11,18 @@ Imports System.Collections
' - Dir-Favorites ' - Dir-Favorites
'V2.0.1 01.12.2011 'V2.0.1 01.12.2011
' - Fav-Dlog: "Abbrechen" => "Cancel" ' - Fav-Dlog: "Abbrechen" => "Cancel"
' - Fav-Dlog: Statt leeren Items in Fav-Liste "<undefined>" ' - Fav-Dlog: Statt leeren Items in Fav-Liste "<undefined>" |@@| Fav-Dlog: Empty Items in Fav list Instead "<undefined>"
'**Anwendung '**Application
'Dim fbTXT As cFileBrowser 'Dim fbTXT As cFileBrowser
'fbTXT = New cFileBrowser("TXT") 'fbTXT = New cFileBrowser("TXT")
'fbTXT.Extensions = New String() {"txt,log", "csv"} 'fbTXT.Extensions = New String() {"txt,log", "csv"}
'... '...
'fbTXT.Close() 'fbTXT.Close()
'**Bentigte Globale Variablen (Default): '**Required Global variables (default):
'Public FB_Drives() As String 'Public FB_Drives() As String
'Public FB_Init As Boolean = False 'Public FB_Init As Boolean = False
'Public FB_FilHisDir As String 'Public FB_FilHisDir As String
...@@ -46,7 +46,7 @@ Public Class cFileBrowser ...@@ -46,7 +46,7 @@ Public Class cFileBrowser
Private bFolderBrowser As Boolean Private bFolderBrowser As Boolean
Private bLightMode As Boolean Private bLightMode As Boolean
'Neue Instanz - ID definieren, umschalten auf FolderBrowser 'New Instance - define ID, switch to FolderBrowser
Public Sub New(ByVal ID As String, Optional ByVal FolderBrowser As Boolean = False, Optional ByVal LightMode As Boolean = False) Public Sub New(ByVal ID As String, Optional ByVal FolderBrowser As Boolean = False, Optional ByVal LightMode As Boolean = False)
Initialized = False Initialized = False
MyID = ID MyID = ID
...@@ -55,12 +55,12 @@ Public Class cFileBrowser ...@@ -55,12 +55,12 @@ Public Class cFileBrowser
bLightMode = LightMode bLightMode = LightMode
End Sub End Sub
'OpenDialog - ffnen Dialog - bergibt True wenn Dialog mit OK beendet wurde 'OpenDialog Return True when Dialog ended with OK
Public Function OpenDialog(ByVal path As String, Optional ByVal MultiFile As Boolean = False, Optional ByVal Ext As String = "") As Boolean Public Function OpenDialog(ByVal path As String, Optional ByVal MultiFile As Boolean = False, Optional ByVal Ext As String = "") As Boolean
Return CustomDialog(path, True, False, eExtMode.MultiExt, MultiFile, Ext, "Open") Return CustomDialog(path, True, False, eExtMode.MultiExt, MultiFile, Ext, "Open")
End Function End Function
'SaveDialog - Speichern Dialog - bergibt True wenn Dialog mit OK beendet wurde 'SaveDialog - Returns True when Dialog ended with OK
Public Function SaveDialog(ByVal path As String, Optional ByVal ForceExt As Boolean = True, Optional ByVal Ext As String = "") As Boolean Public Function SaveDialog(ByVal path As String, Optional ByVal ForceExt As Boolean = True, Optional ByVal Ext As String = "") As Boolean
Dim x As eExtMode Dim x As eExtMode
If ForceExt Then If ForceExt Then
...@@ -71,19 +71,19 @@ Public Class cFileBrowser ...@@ -71,19 +71,19 @@ Public Class cFileBrowser
Return CustomDialog(path, False, True, x, False, Ext, "Save As") Return CustomDialog(path, False, True, x, False, Ext, "Save As")
End Function End Function
'Dialog ffnen - bergibt True wenn Dialog mit OK beendet wurde 'Open dialogue - Return True if Dialogue ended with OK
Public Function CustomDialog(ByVal path As String, ByVal FileMustExist As Boolean, ByVal OverwriteCheck As Boolean, ByVal ExtMode As eExtMode, ByVal MultiFile As Boolean, ByVal Ext As String, Optional Title As String = "File Browser") As Boolean Public Function CustomDialog(ByVal path As String, ByVal FileMustExist As Boolean, ByVal OverwriteCheck As Boolean, ByVal ExtMode As eExtMode, ByVal MultiFile As Boolean, ByVal Ext As String, Optional Title As String = "File Browser") As Boolean
If Not Initialized Then Init() If Not Initialized Then Init()
Return Dlog.Browse(path, FileMustExist, OverwriteCheck, ExtMode, MultiFile, Ext, Title) Return Dlog.Browse(path, FileMustExist, OverwriteCheck, ExtMode, MultiFile, Ext, Title)
End Function End Function
'File-History manuell updaten 'Manually update File History
Public Sub UpdateHistory(ByVal Path As String) Public Sub UpdateHistory(ByVal Path As String)
If Not Initialized Then Init() If Not Initialized Then Init()
Dlog.UpdateHistory(Path) Dlog.UpdateHistory(Path)
End Sub End Sub
'File / Folder History speichen und Speicher freigeben 'File / Folder History speichen und Speicher freigeben |@@| File / Folder History spokes and Release memory
Public Sub Close() Public Sub Close()
If Initialized Then If Initialized Then
Dlog.SaveAndClose() Dlog.SaveAndClose()
...@@ -101,7 +101,7 @@ Public Class cFileBrowser ...@@ -101,7 +101,7 @@ Public Class cFileBrowser
Initialized = True Initialized = True
End Sub End Sub
'Dateiendungen definieren 'Define File-Extensions
Public Property Extensions() As String() Public Property Extensions() As String()
Get Get
Return MyExt Return MyExt
...@@ -112,7 +112,7 @@ Public Class cFileBrowser ...@@ -112,7 +112,7 @@ Public Class cFileBrowser
End Set End Set
End Property End Property
'Dateien abfragen 'Ask for Files
Public ReadOnly Property Files() As String() Public ReadOnly Property Files() As String()
Get Get
If Initialized Then If Initialized Then
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment