mirror of
https://github.com/bvanroll/cs-map-project.git
synced 2025-08-29 20:02:43 +00:00
mogelijkheid meerdere items te selecteren (nu mss betere kaart eu?)
This commit is contained in:
Binary file not shown.
@@ -49,6 +49,11 @@ namespace Globals
|
|||||||
if (string.Equals(Naam, "", StringComparison.Ordinal)) return "UNKNOWN";
|
if (string.Equals(Naam, "", StringComparison.Ordinal)) return "UNKNOWN";
|
||||||
else return Naam;
|
else return Naam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MultiPolygonPunten ToMultiPolygonPunten()
|
||||||
|
{
|
||||||
|
return new MultiPolygonPunten(new List<PolygonPunten>() { this }, this.Naam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Datalaag;
|
using Datalaag;
|
||||||
using Globals;
|
using Globals;
|
||||||
@@ -94,6 +95,37 @@ namespace Logica
|
|||||||
return new MultiPolygonPunten(pp, multiPolygon.Naam);
|
return new MultiPolygonPunten(pp, multiPolygon.Naam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<MultiPolygonPunten> ScaleMultiPolygons(List<MultiPolygonPunten> multiPolygons, double scaleX, double scaleY)
|
||||||
|
{
|
||||||
|
double maxX = multiPolygons.Max(m => m.MaximumX);
|
||||||
|
double maxY = multiPolygons.Max(m => m.MaximumY);
|
||||||
|
double minX = multiPolygons.Min(m => m.MinimumX);
|
||||||
|
double minY = multiPolygons.Min(m => m.MinimumY);
|
||||||
|
List<MultiPolygonPunten> mpps = new List<MultiPolygonPunten>();
|
||||||
|
foreach (MultiPolygonPunten mp in multiPolygons)
|
||||||
|
{
|
||||||
|
List<PolygonPunten> pp = new List<PolygonPunten>();
|
||||||
|
foreach (PolygonPunten poly in mp.PolygonPunten)
|
||||||
|
{
|
||||||
|
List<Punt> punten = new List<Punt>();
|
||||||
|
foreach (Punt punt in poly.Punten)
|
||||||
|
{
|
||||||
|
|
||||||
|
double x = punt.X - minX;
|
||||||
|
x /= maxX;
|
||||||
|
x *= scaleX;
|
||||||
|
double y = punt.Y - minY;
|
||||||
|
y /= maxY;
|
||||||
|
y *= scaleY;
|
||||||
|
punten.Add(new Punt(x, y, punt.Naam));
|
||||||
|
}
|
||||||
|
pp.Add(new PolygonPunten(punten, poly.Naam));
|
||||||
|
}
|
||||||
|
mpps.Add(new MultiPolygonPunten(pp, mp.Naam));
|
||||||
|
}
|
||||||
|
return mpps;
|
||||||
|
|
||||||
|
}
|
||||||
public List<PolygonPunten> GetAllPolygons()
|
public List<PolygonPunten> GetAllPolygons()
|
||||||
{
|
{
|
||||||
List<PolygonPunten> lijst = new List<PolygonPunten>();
|
List<PolygonPunten> lijst = new List<PolygonPunten>();
|
||||||
|
@@ -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"/>
|
<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"/>
|
<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"/>
|
<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>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@@ -38,7 +38,7 @@ namespace opdracht2
|
|||||||
List<Ellipse> el;
|
List<Ellipse> el;
|
||||||
List<Polygon> buffer;
|
List<Polygon> buffer;
|
||||||
ListBox l;
|
ListBox l;
|
||||||
|
CheckBox triangulate;
|
||||||
PolygonManipulatie pm;
|
PolygonManipulatie pm;
|
||||||
JsonReader j;
|
JsonReader j;
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
@@ -53,7 +53,7 @@ namespace opdracht2
|
|||||||
c = (Canvas)this.FindName("someCanvas");
|
c = (Canvas)this.FindName("someCanvas");
|
||||||
CompositionTarget.Rendering += DoUpdates;
|
CompositionTarget.Rendering += DoUpdates;
|
||||||
l = (ListBox)this.FindName("lb");
|
l = (ListBox)this.FindName("lb");
|
||||||
|
triangulate = (CheckBox)this.FindName("triangulate");
|
||||||
Debug.Write("done");
|
Debug.Write("done");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,8 +152,46 @@ namespace opdracht2
|
|||||||
private void lb_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
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 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
|
//zodat we een 1 lijst kunnen gebruiken voor alle polygons
|
||||||
|
if (lb.SelectedItems.Count >1)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
foreach(PolygonPunten ppd in pm.TriangulatePolygon(pp))
|
||||||
|
{
|
||||||
|
c.Children.Add(getPolygon(ppd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (Polygon p in getPolygon(mp))
|
||||||
|
{
|
||||||
|
c.Children.Add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
switch (lb.SelectedItem.GetType().Name)
|
switch (lb.SelectedItem.GetType().Name)
|
||||||
{
|
{
|
||||||
case "MultiPolygonPunten":
|
case "MultiPolygonPunten":
|
||||||
@@ -161,7 +199,7 @@ namespace opdracht2
|
|||||||
c.Children.Clear();
|
c.Children.Clear();
|
||||||
MultiPolygonPunten mp = pm.ScaleMultiPolygon((MultiPolygonPunten)lb.SelectedItem, 100, 100);
|
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
|
//hier ervoor zorgen dat scaling, triangulation etc gebeurt door gebruik van logica layer functies te callen
|
||||||
foreach(PolygonPunten pp in mp.PolygonPunten)
|
foreach (PolygonPunten pp in mp.PolygonPunten)
|
||||||
{
|
{
|
||||||
foreach (PolygonPunten ppd in pm.TriangulatePolygon(pp))
|
foreach (PolygonPunten ppd in pm.TriangulatePolygon(pp))
|
||||||
{
|
{
|
||||||
@@ -169,7 +207,7 @@ namespace opdracht2
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach(Polygon po in getPolygon(mp))
|
foreach (Polygon po in getPolygon(mp))
|
||||||
{
|
{
|
||||||
//c.Children.Add(po);
|
//c.Children.Add(po);
|
||||||
}
|
}
|
||||||
@@ -182,6 +220,8 @@ namespace opdracht2
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
@@ -33,37 +34,39 @@ using System.Windows.Shell;
|
|||||||
using opdracht2;
|
using opdracht2;
|
||||||
|
|
||||||
|
|
||||||
namespace opdracht2 {
|
namespace opdracht2
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// MainWindow
|
/// MainWindow
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
|
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
#line 10 "..\..\..\MainWindow.xaml"
|
#line 10 "..\..\..\MainWindow.xaml"
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
internal System.Windows.Controls.Canvas someCanvas;
|
internal System.Windows.Controls.Canvas someCanvas;
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
#line 20 "..\..\..\MainWindow.xaml"
|
#line 20 "..\..\..\MainWindow.xaml"
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
internal System.Windows.Controls.ListBox lb;
|
internal System.Windows.Controls.ListBox lb;
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
|
|
||||||
#line 21 "..\..\..\MainWindow.xaml"
|
#line 21 "..\..\..\MainWindow.xaml"
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||||
internal System.Windows.Controls.Button LoadFile;
|
internal System.Windows.Controls.Button LoadFile;
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
|
|
||||||
private bool _contentLoaded;
|
private bool _contentLoaded;
|
||||||
|
|
||||||
@@ -72,18 +75,20 @@ namespace opdracht2 {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.8.1.0")]
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.8.1.0")]
|
||||||
public void InitializeComponent() {
|
public void InitializeComponent()
|
||||||
if (_contentLoaded) {
|
{
|
||||||
|
if (_contentLoaded)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_contentLoaded = true;
|
_contentLoaded = true;
|
||||||
System.Uri resourceLocater = new System.Uri("/opdracht2;component/mainwindow.xaml", System.UriKind.Relative);
|
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);
|
System.Windows.Application.LoadComponent(this, resourceLocater);
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
@@ -92,7 +97,8 @@ namespace opdracht2 {
|
|||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
|
[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)
|
switch (connectionId)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@@ -101,24 +107,26 @@ namespace opdracht2 {
|
|||||||
case 2:
|
case 2:
|
||||||
this.lb = ((System.Windows.Controls.ListBox)(target));
|
this.lb = ((System.Windows.Controls.ListBox)(target));
|
||||||
|
|
||||||
#line 20 "..\..\..\MainWindow.xaml"
|
#line 20 "..\..\..\MainWindow.xaml"
|
||||||
this.lb.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.lb_SelectionChanged);
|
this.lb.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.lb_SelectionChanged);
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
return;
|
return;
|
||||||
case 3:
|
case 3:
|
||||||
this.LoadFile = ((System.Windows.Controls.Button)(target));
|
this.LoadFile = ((System.Windows.Controls.Button)(target));
|
||||||
|
|
||||||
#line 21 "..\..\..\MainWindow.xaml"
|
#line 21 "..\..\..\MainWindow.xaml"
|
||||||
this.LoadFile.Click += new System.Windows.RoutedEventHandler(this.LoadFile_Click);
|
this.LoadFile.Click += new System.Windows.RoutedEventHandler(this.LoadFile_Click);
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
#line hidden
|
#line hidden
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._contentLoaded = true;
|
this._contentLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal System.Windows.Controls.CheckBox Triangulate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user