nog rare dinge, ma tga beter of normaal

This commit is contained in:
BuildTools
2020-07-29 17:31:07 +02:00
parent 824860dc58
commit 9f1da145a0
56 changed files with 289 additions and 47 deletions

View File

@@ -10,15 +10,15 @@
<Canvas x:Name="someCanvas" RenderTransformOrigin="0.5,0.5" Margin="436,114,128,113">
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="2" ScaleX="2"/>
<ScaleTransform ScaleY="-1" ScaleX="-1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Canvas.RenderTransform>
</Canvas>
<ListBox Margin="10,94,568,93"/>
<Button x:Name="LoadFile" Content="LoadFile" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="27" Width="65"/>
<ListBox x:Name="lb" Margin="10,94,568,93" SelectionChanged="lb_SelectionChanged"/>
<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"/>

View File

@@ -23,6 +23,8 @@ using Globals;
using Brush = System.Windows.Media.Brush;
using Brushes = System.Windows.Media.Brushes;
using Point = System.Windows.Point;
using Datalaag;
using Logica;
namespace opdracht2
{
@@ -35,6 +37,10 @@ namespace opdracht2
List<Polygon> f;
List<Ellipse> el;
List<Polygon> buffer;
ListBox l;
PolygonManipulatie pm;
JsonReader j;
public MainWindow()
{
//todo logica toevoegen als object
@@ -46,34 +52,7 @@ namespace opdracht2
InitializeComponent();
c = (Canvas)this.FindName("someCanvas");
CompositionTarget.Rendering += DoUpdates;
OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == true)
{
//TODO remove
//Tuple<List<Polygon>, List<Ellipse>> t = GeoJsonParser.TriangulateJsonData(File.ReadAllText(openFileDialog.FileName), c.Width, c.Height);
f = GeoJsonParser.TriangulateJsonData(File.ReadAllText(openFileDialog.FileName), 800, 800);
el = new List<Ellipse>();
}
var st = new ScaleTransform();
c.RenderTransform = st;
foreach (Ellipse eli in el)
{
c.Children.Add(eli);
}
c.MouseWheel += (sender, e) =>
{
if (e.Delta > 0)
{
st.ScaleX *= 2;
st.ScaleY *= 2;
}
else
{
st.ScaleX /= 2;
st.ScaleY /= 2;
}
};
l = (ListBox)this.FindName("lb");
Debug.Write("done");
}
@@ -125,6 +104,119 @@ namespace opdracht2
}
}
private void LoadFile_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == true)
{
//TODO remove
//Tuple<List<Polygon>, List<Ellipse>> t = GeoJsonParser.TriangulateJsonData(File.ReadAllText(openFileDialog.FileName), c.Width, c.Height);
//f = GeoJsonParser.TriangulateJsonData(File.ReadAllText(openFileDialog.FileName), 200, 200);
j = new JsonReader(openFileDialog.FileName);
el = new List<Ellipse>();
pm = new PolygonManipulatie(j);
}
foreach (object o in pm.GetPolygons())
{
try { l.Items.Add(o); } catch (Exception) { };
}
foreach (object o in pm.GetMultiPolygons())
{
try { l.Items.Add(o); } catch (Exception) { };
}
var st = new ScaleTransform();
c.RenderTransform = st;
foreach (Ellipse eli in el)
{
c.Children.Add(eli);
}
c.MouseWheel += (sender, e) =>
{
if (e.Delta > 0)
{
st.ScaleX *= 2;
st.ScaleY *= 2;
}
else
{
st.ScaleX /= 2;
st.ScaleY /= 2;
}
};
}
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)
{
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;
}
}
private List<Polygon> getPolygon(MultiPolygonPunten mp)
{
List<Polygon> lijst = new List<Polygon>();
foreach(PolygonPunten p in mp.PolygonPunten)
{
lijst.Add(getPolygon(p));
}
return lijst;
}
private Polygon getPolygon(PolygonPunten p)
{
Polygon returnWaarde = new Polygon();
PointCollection puntCollectie = new PointCollection();
foreach(Punt punt in p.Punten)
{
puntCollectie.Add(new Point(punt.X, punt.Y));
}
returnWaarde.Points = puntCollectie;
returnWaarde.StrokeThickness = 1;
// deze code zorgt ervoor dat de driehoeken duidelijker zijn op de afbeelding door de kleur willekeurig te selecteren
Random random = new Random();
Type brushType = typeof(Brushes);
PropertyInfo[] properties = brushType.GetProperties();
int randomIndex = random.Next(properties.Length);
Brush willekeurigeBrush = (Brush)properties[randomIndex].GetValue(null, null);
if (willekeurigeBrush == Brushes.White) willekeurigeBrush = Brushes.Black;
returnWaarde.Fill = willekeurigeBrush;
returnWaarde.Stroke = willekeurigeBrush;
return returnWaarde;
}
}
}

View File

@@ -8,7 +8,10 @@
".NETCoreApp,Version=v3.1": {
"opdracht2/1.0.0": {
"dependencies": {
"Datalaag": "1.0.0",
"GeoJSON.Net": "1.2.19",
"Globals": "1.0.0",
"Logica": "1.0.0",
"System.Drawing.Common": "4.7.0"
},
"runtime": {
@@ -837,6 +840,28 @@
"System.Threading": "4.3.0",
"System.Xml.ReaderWriter": "4.3.0"
}
},
"Datalaag/1.0.0": {
"dependencies": {
"Globals": "1.0.0"
},
"runtime": {
"Datalaag.dll": {}
}
},
"Globals/1.0.0": {
"runtime": {
"Globals.dll": {}
}
},
"Logica/1.0.0": {
"dependencies": {
"Datalaag": "1.0.0",
"Globals": "1.0.0"
},
"runtime": {
"Logica.dll": {}
}
}
}
},
@@ -1454,6 +1479,21 @@
"sha512": "sha512-lJ8AxvkX7GQxpC6GFCeBj8ThYVyQczx2+f/cWHJU8tjS7YfI6Cv6bon70jVEgs2CiFbmmM8b9j1oZVx0dSI2Ww==",
"path": "system.xml.xmldocument/4.3.0",
"hashPath": "system.xml.xmldocument.4.3.0.nupkg.sha512"
},
"Datalaag/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Globals/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Logica/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}

View File

@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "68E7240A4F498547AC7EFB2C2D5F594143259E09"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "05D515F609A8E8D2AFAF26E4ADD6AF1BBA9D6ED8"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@@ -50,6 +50,14 @@ namespace opdracht2 {
#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"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button LoadFile;
@@ -91,7 +99,22 @@ namespace opdracht2 {
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;

View File

@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "68E7240A4F498547AC7EFB2C2D5F594143259E09"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "05D515F609A8E8D2AFAF26E4ADD6AF1BBA9D6ED8"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
@@ -50,6 +50,14 @@ namespace opdracht2 {
#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"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button LoadFile;
@@ -91,7 +99,22 @@ namespace opdracht2 {
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;

View File

@@ -1 +1 @@
ab61051a8f40b80922d3e5ed73f33937fcfba690
333d42d081eb5648599bfa58a7cbd5c56cf6bf43

View File

@@ -20,3 +20,9 @@ C:\Users\Beppe\source\repos\opdracht2\opdracht2\obj\Debug\netcoreapp3.1\opdracht
C:\Users\Beppe\source\repos\opdracht2\opdracht2\obj\Debug\netcoreapp3.1\opdracht2.pdb
C:\Users\Beppe\source\repos\opdracht2\opdracht2\obj\Debug\netcoreapp3.1\opdracht2.genruntimeconfig.cache
C:\Users\Beppe\source\repos\opdracht2\opdracht2\obj\Debug\netcoreapp3.1\opdracht2.csproj.CoreCompileInputs.cache
C:\Users\Beppe\source\repos\opdracht2\opdracht2\bin\Debug\netcoreapp3.1\Datalaag.dll
C:\Users\Beppe\source\repos\opdracht2\opdracht2\bin\Debug\netcoreapp3.1\Globals.dll
C:\Users\Beppe\source\repos\opdracht2\opdracht2\bin\Debug\netcoreapp3.1\Logica.dll
C:\Users\Beppe\source\repos\opdracht2\opdracht2\bin\Debug\netcoreapp3.1\Datalaag.pdb
C:\Users\Beppe\source\repos\opdracht2\opdracht2\bin\Debug\netcoreapp3.1\Globals.pdb
C:\Users\Beppe\source\repos\opdracht2\opdracht2\bin\Debug\netcoreapp3.1\Logica.pdb

View File

@@ -16,5 +16,5 @@ C:\Users\Beppe\source\repos\opdracht2\opdracht2\App.xaml
1981362301543
MainWindow.xaml;
True
False

View File

@@ -13,8 +13,8 @@ C:\Users\Beppe\source\repos\opdracht2\opdracht2\App.xaml
11151548125
6-680205189
195549397899
1981362301543
MainWindow.xaml;
False
True

View File

@@ -0,0 +1,4 @@

FC:\Users\Beppe\source\repos\opdracht2\opdracht2\MainWindow.xaml;;

View File

@@ -5,7 +5,6 @@
},
"projects": {
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Datalaag\\Datalaag.csproj",
"projectName": "Datalaag",
@@ -25,7 +24,6 @@
}
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Globals\\Globals.csproj",
"projectName": "Globals",
@@ -36,7 +34,6 @@
}
},
"C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\Logica\\Logica.csproj",
"projectName": "Logica",

View File

@@ -7,7 +7,7 @@
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Beppe\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.5.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>

View File

@@ -1,6 +1,6 @@
{
"version": 2,
"dgSpecHash": "p426YNxR+un7rXUpsV3S3g0htKyuFPUxB5pYHNl1fsHxje10LlIJDBLjupJb2IZCMEZ+Cv3TXWBEUMbbMYO5hA==",
"dgSpecHash": "Zy6jypDVLiSwLfNswZHvoD7ul/+NOG2AgIE/eLzWMMgAaQ+TzAjn3Or2nqa6RpIYT9zQrkp/4+yCHo1D0FoSMQ==",
"success": true,
"projectFilePath": "C:\\Users\\Beppe\\source\\repos\\opdracht2\\opdracht2\\opdracht2.csproj",
"expectedPackageFiles": [