mogelijkheid meerdere items te selecteren (nu mss betere kaart eu?)

This commit is contained in:
BuildTools
2020-07-30 09:54:07 +02:00
parent 9f1da145a0
commit 8a0386a5c4
7 changed files with 163 additions and 77 deletions

View File

@@ -21,6 +21,7 @@
<Button x:Name="LoadFile" Content="LoadFile" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="27" Width="65" Click="LoadFile_Click"/>
<Slider HorizontalAlignment="Left" Margin="10,406,0,0" VerticalAlignment="Top" Width="120" Maximum="100" SmallChange="1"/>
<Label Content="Epsilon (0.001 - 0.1%)" HorizontalAlignment="Left" Margin="8,375,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="Triangulate" Content="Triangulate" HorizontalAlignment="Left" Margin="10,346,0,0" VerticalAlignment="Top"/>
</Grid>
</Window>

View File

@@ -38,7 +38,7 @@ namespace opdracht2
List<Ellipse> el;
List<Polygon> buffer;
ListBox l;
CheckBox triangulate;
PolygonManipulatie pm;
JsonReader j;
public MainWindow()
@@ -53,7 +53,7 @@ namespace opdracht2
c = (Canvas)this.FindName("someCanvas");
CompositionTarget.Rendering += DoUpdates;
l = (ListBox)this.FindName("lb");
triangulate = (CheckBox)this.FindName("triangulate");
Debug.Write("done");
}
@@ -152,36 +152,76 @@ namespace opdracht2
private void lb_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//TODO zorg ervoor dat als meerdere items geselecteerd worden, we een scaling methode hebben voor meerdere (wss gebruik van list)
//TODO als we zo een methode nodig hebben moeten we ook polygonpunten kunnen omzetten naar multipolygonpunten (met dan maar 1 polygon)
//zodat we een 1 lijst kunnen gebruiken voor alle polygons
switch (lb.SelectedItem.GetType().Name)
if (lb.SelectedItems.Count >1)
{
case "MultiPolygonPunten":
Debug.WriteLine(lb.SelectedItem.GetType().Name);
c.Children.Clear();
MultiPolygonPunten mp = pm.ScaleMultiPolygon((MultiPolygonPunten)lb.SelectedItem, 100, 100);
//hier ervoor zorgen dat scaling, triangulation etc gebeurt door gebruik van logica layer functies te callen
foreach(PolygonPunten pp in mp.PolygonPunten)
c.Children.Clear();
List<MultiPolygonPunten> mpps = new List<MultiPolygonPunten>();
foreach (Object o in lb.SelectedItems)
{
if (o.GetType().ToString() == "PolygonPunten") {
PolygonPunten p = (PolygonPunten)o;
mpps.Add(p.ToMultiPolygonPunten());
} else
{
foreach (PolygonPunten ppd in pm.TriangulatePolygon(pp))
mpps.Add((MultiPolygonPunten)o);
}
}
//peuker implementatie moet ook nog gebeuren, code is er al, maar wanneer moet deze aangeroepen worden
mpps = pm.ScaleMultiPolygons(mpps, 100, 100);
foreach(MultiPolygonPunten mp in mpps)
{
if (triangulate.IsChecked == true) //kan blkbr ook null zijn, raar
{
foreach(PolygonPunten pp in mp.PolygonPunten)
{
c.Children.Add(getPolygon(ppd));
foreach(PolygonPunten ppd in pm.TriangulatePolygon(pp))
{
c.Children.Add(getPolygon(ppd));
}
}
}
foreach(Polygon po in getPolygon(mp))
else
{
//c.Children.Add(po);
foreach (Polygon p in getPolygon(mp))
{
c.Children.Add(p);
}
}
break;
case "PolygonPunten":
Debug.WriteLine(lb.SelectedItem.GetType().Name);
c.Children.Clear();
PolygonPunten p = pm.ScalePolygon((PolygonPunten)lb.SelectedItem, 100, 100);
c.Children.Add(getPolygon(p));
break;
}
}
else
{
switch (lb.SelectedItem.GetType().Name)
{
case "MultiPolygonPunten":
Debug.WriteLine(lb.SelectedItem.GetType().Name);
c.Children.Clear();
MultiPolygonPunten mp = pm.ScaleMultiPolygon((MultiPolygonPunten)lb.SelectedItem, 100, 100);
//hier ervoor zorgen dat scaling, triangulation etc gebeurt door gebruik van logica layer functies te callen
foreach (PolygonPunten pp in mp.PolygonPunten)
{
foreach (PolygonPunten ppd in pm.TriangulatePolygon(pp))
{
c.Children.Add(getPolygon(ppd));
}
}
foreach (Polygon po in getPolygon(mp))
{
//c.Children.Add(po);
}
break;
case "PolygonPunten":
Debug.WriteLine(lb.SelectedItem.GetType().Name);
c.Children.Clear();
PolygonPunten p = pm.ScalePolygon((PolygonPunten)lb.SelectedItem, 100, 100);
c.Children.Add(getPolygon(p));
break;
}
}
}

View File

@@ -1,4 +1,5 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "05D515F609A8E8D2AFAF26E4ADD6AF1BBA9D6ED8"
// Updated by XamlIntelliSenseFileGenerator 7/30/2020 9:49:33 AM
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "05D515F609A8E8D2AFAF26E4ADD6AF1BBA9D6ED8"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@@ -33,92 +34,99 @@ using System.Windows.Shell;
using opdracht2;
namespace opdracht2 {
namespace opdracht2
{
/// <summary>
/// MainWindow
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 10 "..\..\..\MainWindow.xaml"
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector
{
#line 10 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Canvas someCanvas;
#line default
#line hidden
#line 20 "..\..\..\MainWindow.xaml"
#line default
#line hidden
#line 20 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.ListBox lb;
#line default
#line hidden
#line 21 "..\..\..\MainWindow.xaml"
#line default
#line hidden
#line 21 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button LoadFile;
#line default
#line hidden
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.8.1.0")]
public void InitializeComponent() {
if (_contentLoaded) {
public void InitializeComponent()
{
if (_contentLoaded)
{
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/opdracht2;component/mainwindow.xaml", System.UriKind.Relative);
#line 1 "..\..\..\MainWindow.xaml"
#line 1 "..\..\..\MainWindow.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.8.1.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
{
switch (connectionId)
{
case 1:
this.someCanvas = ((System.Windows.Controls.Canvas)(target));
return;
case 2:
this.lb = ((System.Windows.Controls.ListBox)(target));
#line 20 "..\..\..\MainWindow.xaml"
this.lb.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.lb_SelectionChanged);
#line default
#line hidden
return;
case 3:
this.LoadFile = ((System.Windows.Controls.Button)(target));
#line 21 "..\..\..\MainWindow.xaml"
this.LoadFile.Click += new System.Windows.RoutedEventHandler(this.LoadFile_Click);
#line default
#line hidden
return;
case 1:
this.someCanvas = ((System.Windows.Controls.Canvas)(target));
return;
case 2:
this.lb = ((System.Windows.Controls.ListBox)(target));
#line 20 "..\..\..\MainWindow.xaml"
this.lb.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.lb_SelectionChanged);
#line default
#line hidden
return;
case 3:
this.LoadFile = ((System.Windows.Controls.Button)(target));
#line 21 "..\..\..\MainWindow.xaml"
this.LoadFile.Click += new System.Windows.RoutedEventHandler(this.LoadFile_Click);
#line default
#line hidden
return;
}
this._contentLoaded = true;
}
internal System.Windows.Controls.CheckBox Triangulate;
}
}