@@ -26,7 +26,7 @@ namespace PointCloudConverter
26
26
{
27
27
public partial class MainWindow : Window
28
28
{
29
- static readonly string version = "09.03 .2024" ;
29
+ static readonly string version = "09.06 .2024" ;
30
30
static readonly string appname = "PointCloud Converter - " + version ;
31
31
static readonly string rootFolder = AppDomain . CurrentDomain . BaseDirectory ;
32
32
@@ -44,15 +44,24 @@ public partial class MainWindow : Window
44
44
public static MainWindow mainWindowStatic ;
45
45
bool isInitialiazing = true ;
46
46
47
+ static List < LasHeader > lasHeaders = new List < LasHeader > ( ) ;
48
+ private readonly ILogger logger ;
49
+
50
+ // progress bar data
51
+ static int progressPoint = 0 ;
52
+ static int progressTotalPoints = 0 ;
53
+ static int progressFile = 0 ;
54
+ static int progressTotalFiles = 0 ;
55
+ static DispatcherTimer progressTimerThread ;
56
+ public static string lastStatusMessage = "" ;
57
+
47
58
public MainWindow ( )
48
59
{
49
60
InitializeComponent ( ) ;
50
61
mainWindowStatic = this ;
51
62
Main ( ) ;
52
63
}
53
64
54
- private readonly ILogger logger ;
55
-
56
65
private void Main ( )
57
66
{
58
67
// check cmdline args
@@ -64,6 +73,9 @@ private void Main()
64
73
// default logger
65
74
Log . CreateLogger ( isJSON : false , version : version ) ;
66
75
76
+ // default code
77
+ Environment . ExitCode = ( int ) ExitCode . Success ;
78
+
67
79
if ( args . Length > 1 )
68
80
{
69
81
AttachConsole ( ATTACH_PARENT_PROCESS ) ;
@@ -77,7 +89,6 @@ private void Main()
77
89
}
78
90
}
79
91
80
-
81
92
Console . ForegroundColor = ConsoleColor . Cyan ;
82
93
Log . WriteLine ( "\n ::: " + appname + " :::\n " ) ;
83
94
//Console.WriteLine("\n::: " + appname + " :::\n");
@@ -119,7 +130,7 @@ private void Main()
119
130
// hack for console exit https://stackoverflow.com/a/67940480/5452781
120
131
SendKeys . SendWait ( "{ENTER}" ) ;
121
132
FreeConsole ( ) ;
122
- Environment . Exit ( 0 ) ;
133
+ Environment . Exit ( Environment . ExitCode ) ;
123
134
}
124
135
125
136
// regular WPF starts from here
@@ -131,7 +142,6 @@ private void Main()
131
142
LoadSettings ( ) ;
132
143
}
133
144
134
- static List < LasHeader > lasHeaders = new List < LasHeader > ( ) ;
135
145
136
146
// main processing loop
137
147
private static void ProcessAllFiles ( System . Object importSettingsObject )
@@ -168,6 +178,10 @@ private static void ProcessAllFiles(System.Object importSettingsObject)
168
178
{
169
179
boundsListTemp . Add ( new Float3 ( res . Item2 , res . Item3 , res . Item4 ) ) ;
170
180
}
181
+ else
182
+ {
183
+ Log . WriteLine ( "Error> Failed to get bounds from file: " + importSettings . inputFiles [ i ] , LogEvent . Error ) ;
184
+ }
171
185
}
172
186
173
187
// print lowest bounds from boundsListTemp
@@ -197,7 +211,11 @@ private static void ProcessAllFiles(System.Object importSettingsObject)
197
211
//Debug.WriteLine("\nReading file (" + (i + 1) + "/" + len + ") : " + importSettings.inputFiles[i] + " (" + Tools.HumanReadableFileSize(new FileInfo(importSettings.inputFiles[i]).Length) + ")");
198
212
//if (abort==true)
199
213
// do actual point cloud parsing for this file
200
- ParseFile ( importSettings , i ) ;
214
+ var res = ParseFile ( importSettings , i ) ;
215
+ if ( res == false )
216
+ {
217
+ Log . WriteLine ( "Error> Failed to parse file: " + importSettings . inputFiles [ i ] , LogEvent . Error ) ;
218
+ }
201
219
}
202
220
203
221
stopwatch . Stop ( ) ;
@@ -221,14 +239,6 @@ void HideProcessingPanel()
221
239
gridProcessingPanel . Visibility = Visibility . Hidden ;
222
240
}
223
241
224
- // progress bar data
225
- static int progressPoint = 0 ;
226
- static int progressTotalPoints = 0 ;
227
- static int progressFile = 0 ;
228
- static int progressTotalFiles = 0 ;
229
- static DispatcherTimer progressTimerThread ;
230
- public static string lastStatusMessage = "" ;
231
-
232
242
static void StartProgressTimer ( )
233
243
{
234
244
progressTimerThread = new DispatcherTimer ( DispatcherPriority . Background , Application . Current . Dispatcher ) ;
@@ -266,6 +276,7 @@ static void ProgressTick(object sender, EventArgs e)
266
276
if ( res == false )
267
277
{
268
278
Log . WriteLine ( "Unknown error while initializing reader: " + importSettings . inputFiles [ fileIndex ] ) ;
279
+ Environment . ExitCode = ( int ) ExitCode . Error ;
269
280
return ( false , 0 , 0 , 0 ) ;
270
281
}
271
282
var bounds = importSettings . reader . GetBounds ( ) ;
@@ -278,13 +289,14 @@ static void ProgressTick(object sender, EventArgs e)
278
289
279
290
280
291
// process single file
281
- static void ParseFile ( ImportSettings importSettings , int fileIndex )
292
+ static bool ParseFile ( ImportSettings importSettings , int fileIndex )
282
293
{
283
294
var res = importSettings . reader . InitReader ( importSettings , fileIndex ) ;
284
295
if ( res == false )
285
296
{
286
297
Log . WriteLine ( "Unknown error while initializing reader: " + importSettings . inputFiles [ fileIndex ] ) ;
287
- return ;
298
+ Environment . ExitCode = ( int ) ExitCode . Error ;
299
+ return false ;
288
300
}
289
301
290
302
if ( importSettings . importMetadata == true )
@@ -346,7 +358,7 @@ static void ParseFile(ImportSettings importSettings, int fileIndex)
346
358
if ( writerRes == false )
347
359
{
348
360
Log . WriteLine ( "Error> Failed to initialize Writer" ) ;
349
- return ;
361
+ return false ;
350
362
}
351
363
352
364
progressPoint = 0 ;
@@ -466,6 +478,8 @@ static void ParseFile(ImportSettings importSettings, int fileIndex)
466
478
}
467
479
} ) ;
468
480
}
481
+
482
+ return true ;
469
483
} // ParseFile
470
484
471
485
private void btnConvert_Click ( object sender , RoutedEventArgs e )
@@ -535,7 +549,6 @@ void StartProcess(bool doProcess = true)
535
549
txtConsole . Text = cl ;
536
550
Console . WriteLine ( cl ) ;
537
551
538
- // TODO lock UI, add cancel button, add progress bar
539
552
if ( doProcess == true )
540
553
{
541
554
ParameterizedThreadStart start = new ParameterizedThreadStart ( ProcessAllFiles ) ;
@@ -548,6 +561,7 @@ void StartProcess(bool doProcess = true)
548
561
{
549
562
HideProcessingPanel ( ) ;
550
563
txtConsole . Text = "Operation failed! " + string . Join ( Environment . NewLine , importSettings . errors ) ;
564
+ Environment . ExitCode = ( int ) ExitCode . Error ;
551
565
}
552
566
}
553
567
@@ -560,7 +574,7 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
560
574
if ( workerThread != null )
561
575
{
562
576
workerThread . Abort ( ) ;
563
- Environment . Exit ( Environment . ExitCode ) ;
577
+ Environment . Exit ( ( int ) ExitCode . Cancelled ) ;
564
578
}
565
579
}
566
580
@@ -779,7 +793,7 @@ private void BtnCancel_Click(object sender, RoutedEventArgs e)
779
793
if ( workerThread != null )
780
794
{
781
795
workerThread . Abort ( ) ;
782
- Environment . Exit ( Environment . ExitCode ) ;
796
+ Environment . Exit ( ( int ) ExitCode . Cancelled ) ;
783
797
}
784
798
}
785
799
0 commit comments