Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Conceição <Tiago_caza@hotmail.com>2021-09-21 04:09:02 +0300
committerTiago Conceição <Tiago_caza@hotmail.com>2021-09-21 04:09:02 +0300
commit6b1c70d362091bae4e2025ac73f4fe45aa9b6030 (patch)
tree936a840d6080b7d0a71882e92a68dae90b40507a
parent4407550e70e4e7fa62356d26602402dff78f1ac9 (diff)
Fix issue selection
-rw-r--r--UVtools.Core/UVtools.Core.csproj2
-rw-r--r--UVtools.WPF/MainWindow.Issues.cs53
-rw-r--r--UVtools.WPF/MainWindow.LayerPreview.cs50
-rw-r--r--UVtools.WPF/MainWindow.axaml2
-rw-r--r--UVtools.WPF/MainWindow.axaml.cs23
-rw-r--r--UVtools.WPF/UVtools.WPF.csproj2
6 files changed, 56 insertions, 76 deletions
diff --git a/UVtools.Core/UVtools.Core.csproj b/UVtools.Core/UVtools.Core.csproj
index c6553ac..6772040 100644
--- a/UVtools.Core/UVtools.Core.csproj
+++ b/UVtools.Core/UVtools.Core.csproj
@@ -10,7 +10,7 @@
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
<PackageProjectUrl>https://github.com/sn4k3/UVtools</PackageProjectUrl>
<Description>MSLA/DLP, file analysis, calibration, repair, conversion and manipulation</Description>
- <Version>2.22.1</Version>
+ <Version>2.23.0</Version>
<Copyright>Copyright © 2020 PTRTECH</Copyright>
<PackageIcon>UVtools.png</PackageIcon>
<Platforms>AnyCPU;x64</Platforms>
diff --git a/UVtools.WPF/MainWindow.Issues.cs b/UVtools.WPF/MainWindow.Issues.cs
index 9aacf11..dfdd747 100644
--- a/UVtools.WPF/MainWindow.Issues.cs
+++ b/UVtools.WPF/MainWindow.Issues.cs
@@ -6,8 +6,8 @@
* of this license document, but changing it is not allowed.
*/
using System;
+using System.Collections;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Collections;
@@ -38,6 +38,24 @@ namespace UVtools.WPF
public DataGrid IssuesGrid;
private int _issueSelectedIndex = -1;
+
+ public IEnumerable IssuesGridItems
+ {
+ get
+ {
+ if (!IsFileLoaded || DataContext is null) return null;
+ if (Settings.Issues.DataGridGroupByType || Settings.Issues.DataGridGroupByLayerIndex)
+ {
+ var groupView = new DataGridCollectionView(SlicerFile.IssueManager);
+ if (Settings.Issues.DataGridGroupByType) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("Type"));
+ if (Settings.Issues.DataGridGroupByLayerIndex) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("StartLayerIndex"));
+
+ return groupView;
+ }
+
+ return SlicerFile.IssueManager;
+ }
+ }
#endregion
#region Properties
@@ -53,6 +71,8 @@ namespace UVtools.WPF
set => RaiseAndSetIfChanged(ref _resinTrapDetectionStartLayer, value);
}
+ public bool SuppressIssueGridSelectionEvent { get; set; }
+
#endregion
#region Methods
@@ -381,7 +401,7 @@ namespace UVtools.WPF
private void IssuesGridOnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
- if (DataContext is null) return;
+ if (DataContext is null || SuppressIssueGridSelectionEvent) return;
if (IssuesGrid.SelectedItem is not MainIssue mainIssue)
{
@@ -390,34 +410,7 @@ namespace UVtools.WPF
}
var issue = mainIssue.FirstOrDefault();
-
-
- if (mainIssue.Type is MainIssue.IssueType.TouchingBound or MainIssue.IssueType.EmptyLayer || mainIssue.BoundingRectangle.IsEmpty)
- {
- ZoomToFit();
- }
- else if (!mainIssue.BoundingRectangle.IsEmpty && issue is not null)
- {
-
- if (Settings.LayerPreview.ZoomIssues ^ (_globalModifiers & KeyModifiers.Alt) != 0)
- {
- ZoomToIssue(issue);
- }
- else
- {
- //CenterLayerAt(GetTransposedIssueBounds(issue));
- // If issue is not already visible, center on it and bring it into view.
- // Issues already in view will not be centered, though their color may
- // change and the crosshair may move to reflect active selections.
-
- if (!LayerImageBox.GetSourceImageRegion().Contains(GetTransposedIssueBounds(issue).ToAvalonia()))
- {
- CenterAtIssue(issue);
- }
- }
- }
-
- ForceUpdateActualLayer(mainIssue.StartLayerIndex);
+ ZoomToIssue(issue, true);
}
diff --git a/UVtools.WPF/MainWindow.LayerPreview.cs b/UVtools.WPF/MainWindow.LayerPreview.cs
index 8b7bed1..750a6f5 100644
--- a/UVtools.WPF/MainWindow.LayerPreview.cs
+++ b/UVtools.WPF/MainWindow.LayerPreview.cs
@@ -960,27 +960,27 @@ namespace UVtools.WPF
switch (issue.Parent.Type)
{
case MainIssue.IssueType.Island:
- color = selectedIssues.Count > 0 && selectedIssues.Contains(issue)
+ color = selectedIssues.Count > 0 && selectedIssues.Contains(issue.Parent)
? Settings.LayerPreview.IslandHighlightColor
: Settings.LayerPreview.IslandColor;
drawCrosshair = true;
break;
case MainIssue.IssueType.Overhang:
- color = selectedIssues.Count > 0 && selectedIssues.Contains(issue)
+ color = selectedIssues.Count > 0 && selectedIssues.Contains(issue.Parent)
? Settings.LayerPreview.OverhangHighlightColor
: Settings.LayerPreview.OverhangColor;
drawCrosshair = true;
break;
case MainIssue.IssueType.ResinTrap:
- color = selectedIssues.Count > 0 && selectedIssues.Contains(issue)
+ color = selectedIssues.Count > 0 && selectedIssues.Contains(issue.Parent)
? Settings.LayerPreview.ResinTrapHighlightColor
: Settings.LayerPreview.ResinTrapColor;
drawCrosshair = true;
break;
case MainIssue.IssueType.SuctionCup:
- color = selectedIssues.Count > 0 && selectedIssues.Contains(issue)
+ color = selectedIssues.Count > 0 && selectedIssues.Contains(issue.Parent)
? Settings.LayerPreview.SuctionCupHighlightColor
: Settings.LayerPreview.SuctionCupColor;
drawCrosshair = true;
@@ -1583,32 +1583,35 @@ namespace UVtools.WPF
/// Zoom the layer preview to the passed issue, or if appropriate for issue type,
/// Zoom to fit the plate or print bounds.
/// </summary>
- private void ZoomToIssue(Issue issue)
+ private void ZoomToIssue(Issue issue, bool forceRefreshLayer = false)
{
- if (issue.Parent.Type is MainIssue.IssueType.TouchingBound or MainIssue.IssueType.EmptyLayer || issue.BoundingRectangle.IsEmpty)
+ if (issue.Type is MainIssue.IssueType.TouchingBound or MainIssue.IssueType.EmptyLayer || issue.BoundingRectangle.IsEmpty)
{
ZoomToFit();
+ if (forceRefreshLayer) ForceUpdateActualLayer(issue.LayerIndex);
return;
}
- if (!issue.BoundingRectangle.IsEmpty)
- {
- // Check to see if this zoom action will cross the crosshair fade threshold
- /*if (tsLayerImageShowCrosshairs.Checked && !ReferenceEquals(Issues, null) && flvIssues.SelectedIndices.Count > 0
- && pbLayer.Zoom <= CrosshairFadeLevel && LockedZoomLevel > CrosshairFadeLevel)
- {
- // Refresh the preview without the crosshairs before zooming-in.
- // Prevents zoomed-in crosshairs from breifly being displayed before
- // the Layer Preview is refreshed post-zoom.
- tsLayerImageShowCrosshairs.Checked = false;
- ShowLayer();
- tsLayerImageShowCrosshairs.Checked = true;
- }*/
-
+ if (issue.BoundingRectangle.IsEmpty) return;
+ if (Settings.LayerPreview.ZoomIssues ^ (_globalModifiers & KeyModifiers.Alt) != 0)
+ {
CenterLayerAt(GetTransposedIssueBounds(issue), AppSettings.LockedZoomLevel);
+ }
+ else
+ {
+ //CenterLayerAt(GetTransposedIssueBounds(issue));
+ // If issue is not already visible, center on it and bring it into view.
+ // Issues already in view will not be centered, though their color may
+ // change and the crosshair may move to reflect active selections.
+ if (!LayerImageBox.GetSourceImageRegion().Contains(GetTransposedIssueBounds(issue).ToAvalonia()))
+ {
+ CenterAtIssue(issue);
+ }
}
+
+ if(forceRefreshLayer) ForceUpdateActualLayer(issue.LayerIndex);
}
/// <summary>
@@ -1699,11 +1702,16 @@ namespace UVtools.WPF
{
//location = GetTransposedPoint(location);
// If location clicked is within an issue, activate it.
- foreach (var issue in SlicerFile.IssueManager.GetIssuesBy(_actualLayer))
+ foreach (var issue in SlicerFile.IssueManager.GetIssuesBy(_actualLayer).Reverse())
{
if (!GetTransposedIssueBounds(issue).Contains(location)) continue;
+ SuppressIssueGridSelectionEvent = true;
IssuesGrid.SelectedItem = issue.Parent;
+ SuppressIssueGridSelectionEvent = false;
+
+ ZoomToIssue(issue, true);
+
SelectedTabItem = TabIssues;
break;
}
diff --git a/UVtools.WPF/MainWindow.axaml b/UVtools.WPF/MainWindow.axaml
index 7b8a6b5..2e0fce5 100644
--- a/UVtools.WPF/MainWindow.axaml
+++ b/UVtools.WPF/MainWindow.axaml
@@ -857,7 +857,7 @@
SelectedIndex="{Binding IssueSelectedIndex, Mode=TwoWay}"
IsReadOnly="True"
ClipboardCopyMode="IncludeHeader"
- Items="{Binding SlicerFile.IssueManager}">
+ Items="{Binding IssuesGridItems}">
<DataGrid.Columns>
<DataGridTextColumn Header="Type"
diff --git a/UVtools.WPF/MainWindow.axaml.cs b/UVtools.WPF/MainWindow.axaml.cs
index b154173..7b2e5f1 100644
--- a/UVtools.WPF/MainWindow.axaml.cs
+++ b/UVtools.WPF/MainWindow.axaml.cs
@@ -19,7 +19,6 @@ using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
-using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading;
@@ -1174,18 +1173,7 @@ namespace UVtools.WPF
await settingsWindow.ShowDialog(this);
if (settingsWindow.DialogResult == DialogResults.OK)
{
- if (Settings.Issues.DataGridGroupByType || Settings.Issues.DataGridGroupByLayerIndex)
- {
- var groupView = new DataGridCollectionView(SlicerFile.IssueManager);
- if (Settings.Issues.DataGridGroupByType) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("Type"));
- if (Settings.Issues.DataGridGroupByLayerIndex) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("StartLayerIndex"));
-
- IssuesGrid.Items = groupView;
- }
- else
- {
- IssuesGrid.Items = SlicerFile.IssueManager;
- }
+ RaisePropertyChanged(nameof(IssuesGridItems));
}
}
@@ -1624,15 +1612,6 @@ namespace UVtools.WPF
}
}
- if (Settings.Issues.DataGridGroupByType || Settings.Issues.DataGridGroupByLayerIndex)
- {
- var groupView = new DataGridCollectionView(SlicerFile.IssueManager);
- if(Settings.Issues.DataGridGroupByType) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("Type"));
- if (Settings.Issues.DataGridGroupByLayerIndex) groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("StartLayerIndex"));
-
- IssuesGrid.Items = groupView;
- }
-
SlicerFile.IssueManager.CollectionChanged += (sender, e) =>
{
UpdateLayerTrackerHighlightIssues();
diff --git a/UVtools.WPF/UVtools.WPF.csproj b/UVtools.WPF/UVtools.WPF.csproj
index 093cb9d..86a7540 100644
--- a/UVtools.WPF/UVtools.WPF.csproj
+++ b/UVtools.WPF/UVtools.WPF.csproj
@@ -12,7 +12,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
- <Version>2.22.1</Version>
+ <Version>2.23.0</Version>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>