mirror of
https://github.com/bvanroll/cs-map-project.git
synced 2025-08-29 11:52:44 +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";
|
||||
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.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Datalaag;
|
||||
using Globals;
|
||||
@@ -94,6 +95,37 @@ namespace Logica
|
||||
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()
|
||||
{
|
||||
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"/>
|
||||
<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>
|
||||
|
@@ -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,8 +152,46 @@ 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
|
||||
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)
|
||||
{
|
||||
case "MultiPolygonPunten":
|
||||
@@ -182,6 +220,8 @@ namespace opdracht2
|
||||
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>
|
||||
// This code was generated by a tool.
|
||||
@@ -33,13 +34,15 @@ using System.Windows.Shell;
|
||||
using opdracht2;
|
||||
|
||||
|
||||
namespace opdracht2 {
|
||||
namespace opdracht2
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// MainWindow
|
||||
/// </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"
|
||||
@@ -72,8 +75,10 @@ namespace opdracht2 {
|
||||
/// </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;
|
||||
@@ -92,7 +97,8 @@ namespace opdracht2 {
|
||||
[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:
|
||||
@@ -119,6 +125,8 @@ namespace opdracht2 {
|
||||
}
|
||||
this._contentLoaded = true;
|
||||
}
|
||||
|
||||
internal System.Windows.Controls.CheckBox Triangulate;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user