-
Notifications
You must be signed in to change notification settings - Fork 0
/
MapProcess.cs
86 lines (81 loc) · 3.24 KB
/
MapProcess.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Controls;
namespace eqmaps
{
internal static class MapProcess
{
public static double minYLine,
minXLine,
divnum;
public static void ProcessMapData(this Canvas myCanvas, string loadFile)
{
double[]? mapLimits;
List<double> lineYTotals = new(),
lineXTotals = new(),
minYLines = new(),
minXLines = new();
loadFile = loadFile.Replace("_1", "").Replace("_2", "").Replace("_3", "");
string loadFile1 = loadFile.Insert(loadFile.IndexOf(".txt"), "_1");
string loadFile2 = loadFile.Insert(loadFile.IndexOf(".txt"), "_2");
string loadFile3 = loadFile.Insert(loadFile.IndexOf(".txt"), "_3");
if (File.Exists(loadFile) && new FileInfo(loadFile).Length > 50)
{
mapLimits = MapLimits.FindMapLimits(loadFile);
lineYTotals.Add(mapLimits[0]);
lineXTotals.Add(mapLimits[1]);
minYLines.Add(mapLimits[2]);
minXLines.Add(mapLimits[3]);
}
if (File.Exists(loadFile1) && new FileInfo(loadFile1).Length > 50)
{
mapLimits = MapLimits.FindMapLimits(loadFile1);
lineYTotals.Add(mapLimits[0]);
lineXTotals.Add(mapLimits[1]);
minYLines.Add(mapLimits[2]);
minXLines.Add(mapLimits[3]);
}
if (File.Exists(loadFile2) && new FileInfo(loadFile2).Length > 50)
{
mapLimits = MapLimits.FindMapLimits(loadFile2);
lineYTotals.Add(mapLimits[0]);
lineXTotals.Add(mapLimits[1]);
minYLines.Add(mapLimits[2]);
minXLines.Add(mapLimits[3]);
}
if (File.Exists(loadFile3) && new FileInfo(loadFile3).Length > 50)
{
mapLimits = MapLimits.FindMapLimits(loadFile3);
lineYTotals.Add(mapLimits[0]);
lineXTotals.Add(mapLimits[1]);
minYLines.Add(mapLimits[2]);
minXLines.Add(mapLimits[3]);
}
minYLine = Math.Abs(minYLines.Min());
minXLine = Math.Abs(minXLines.Min());
divnum = lineXTotals.Max() / (myCanvas.ActualWidth - 20);
if ((lineYTotals.Max() / divnum) > (myCanvas.ActualHeight - 20))
{
divnum = lineYTotals.Max() / (myCanvas.ActualHeight - 20);
}
if (File.Exists(loadFile) && new FileInfo(loadFile).Length > 50)
{
MapRender.LoadMapData(myCanvas, loadFile);
}
if (File.Exists(loadFile1) && new FileInfo(loadFile1).Length > 50)
{
MapRender.LoadMapData(myCanvas, loadFile1);
}
if (File.Exists(loadFile2) && new FileInfo(loadFile2).Length > 50)
{
MapRender.LoadMapData(myCanvas, loadFile2);
}
if (File.Exists(loadFile3) && new FileInfo(loadFile3).Length > 50)
{
MapRender.LoadMapData(myCanvas, loadFile3);
}
}
}
}