|
23 | 23 | using PointCloudConverter.Writers;
|
24 | 24 | using System.Reflection;
|
25 | 25 | using System.Globalization;
|
| 26 | +using System.Windows.Media; |
26 | 27 |
|
27 | 28 | namespace PointCloudConverter
|
28 | 29 | {
|
29 | 30 | public partial class MainWindow : Window
|
30 | 31 | {
|
31 |
| - static readonly string version = "23.09.2024"; |
| 32 | + static readonly string version = "24.09.2024"; |
32 | 33 | static readonly string appname = "PointCloud Converter - " + version;
|
33 | 34 | static readonly string rootFolder = AppDomain.CurrentDomain.BaseDirectory;
|
34 | 35 |
|
@@ -310,7 +311,7 @@ private static async Task ProcessAllFiles(object workerParamsObject)
|
310 | 311 | if (boundsListTemp[iii].z < lowestZ) lowestZ = (float)boundsListTemp[iii].z;
|
311 | 312 | }
|
312 | 313 |
|
313 |
| - //Console.WriteLine("Lowest bounds: " + lowestX + " " + lowestY + " " + lowestZ); |
| 314 | + //Log.Write("Lowest bounds: " + lowestX + " " + lowestY + " " + lowestZ); |
314 | 315 | // TODO could take center for XZ, and lowest for Y?
|
315 | 316 | importSettings.offsetX = lowestX;
|
316 | 317 | importSettings.offsetY = lowestY;
|
@@ -382,11 +383,18 @@ private static async Task ProcessAllFiles(object workerParamsObject)
|
382 | 383 | }
|
383 | 384 | finally
|
384 | 385 | {
|
385 |
| - //// Ensure the semaphore is released, if needed |
386 |
| - //if (semaphore.CurrentCount == 0) // Make sure we don't release more times than we acquire |
387 |
| - //{ |
388 |
| - // semaphore.Release(); |
389 |
| - //} |
| 386 | + // Ensure the semaphore is released safely |
| 387 | + if (semaphore.CurrentCount == 0) // Make sure we don't release more times than we acquire |
| 388 | + { |
| 389 | + try |
| 390 | + { |
| 391 | + semaphore.Release(); |
| 392 | + } |
| 393 | + catch (SemaphoreFullException ex) |
| 394 | + { |
| 395 | + //Log.Write($"Semaphore was already fully released. Exception: {ex.Message}"); |
| 396 | + } |
| 397 | + } |
390 | 398 | }
|
391 | 399 | //int? taskId = Task.CurrentId; // Get the current task ID
|
392 | 400 |
|
@@ -768,13 +776,18 @@ static bool ParseFile(ImportSettings importSettings, int fileIndex, int? taskId,
|
768 | 776 | importSettings.offsetY = importSettings.manualOffsetY;
|
769 | 777 | importSettings.offsetZ = importSettings.manualOffsetZ;
|
770 | 778 | }
|
771 |
| - else // neither |
| 779 | + else // no autooffset either |
772 | 780 | {
|
773 |
| - importSettings.offsetX = 0; |
774 |
| - importSettings.offsetY = 0; |
775 |
| - importSettings.offsetZ = 0; |
| 781 | + if (importSettings.useAutoOffset == false) |
| 782 | + { |
| 783 | + importSettings.offsetX = 0; |
| 784 | + importSettings.offsetY = 0; |
| 785 | + importSettings.offsetZ = 0; |
| 786 | + } |
776 | 787 | }
|
777 | 788 |
|
| 789 | + //Log.Write("************** Offsets: " + importSettings.offsetX + " " + importSettings.offsetY + " " + importSettings.offsetZ); |
| 790 | + |
778 | 791 | var taskWriter = importSettings.GetOrCreateWriter(taskId);
|
779 | 792 |
|
780 | 793 | // for saving pcroot header, we need this writer
|
@@ -1020,7 +1033,8 @@ void StartProcess(bool doProcess = true)
|
1020 | 1033 | args.Add("-output=" + txtOutput.Text);
|
1021 | 1034 |
|
1022 | 1035 | // check if using autooffset
|
1023 |
| - if ((bool)chkAutoOffset.IsChecked && !(bool)chkManualOffset.IsChecked) |
| 1036 | + //if ((bool)chkAutoOffset.IsChecked && !(bool)chkManualOffset.IsChecked) |
| 1037 | + if (!(bool)chkManualOffset.IsChecked) |
1024 | 1038 | {
|
1025 | 1039 | args.Add("-offset=" + (bool)chkAutoOffset.IsChecked);
|
1026 | 1040 | }
|
@@ -1123,6 +1137,9 @@ void ImportArgs(string rawArgs)
|
1123 | 1137 | bool isFirstArgExe = args[0].EndsWith(".exe", StringComparison.OrdinalIgnoreCase);
|
1124 | 1138 | int startIndex = isFirstArgExe ? 1 : 0;
|
1125 | 1139 |
|
| 1140 | + // reset all checkboxes to false |
| 1141 | + UncheckAllCheckboxes(this); |
| 1142 | + |
1126 | 1143 | for (int i = startIndex; i < args.Length; i++)
|
1127 | 1144 | {
|
1128 | 1145 | string arg = args[i];
|
@@ -1246,6 +1263,27 @@ void ImportArgs(string rawArgs)
|
1246 | 1263 | } // for all args
|
1247 | 1264 | } // ImportArgs()
|
1248 | 1265 |
|
| 1266 | + private void UncheckAllCheckboxes(DependencyObject parent) |
| 1267 | + { |
| 1268 | + // Loop through all the child elements |
| 1269 | + for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) |
| 1270 | + { |
| 1271 | + var child = VisualTreeHelper.GetChild(parent, i); |
| 1272 | + |
| 1273 | + // If the child is a CheckBox, set it to unchecked |
| 1274 | + if (child is CheckBox checkBox) |
| 1275 | + { |
| 1276 | + checkBox.IsChecked = false; |
| 1277 | + } |
| 1278 | + |
| 1279 | + // If the child is a container, recursively call the function to check its children |
| 1280 | + if (VisualTreeHelper.GetChildrenCount(child) > 0) |
| 1281 | + { |
| 1282 | + UncheckAllCheckboxes(child); |
| 1283 | + } |
| 1284 | + } |
| 1285 | + } |
| 1286 | + |
1249 | 1287 | private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
1250 | 1288 | {
|
1251 | 1289 | SaveSettings();
|
|
0 commit comments