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,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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user