Skip to content

Commit

Permalink
fixes folder compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
iblacksand committed Nov 27, 2019
1 parent 3561846 commit 2100c84
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 36 deletions.
2 changes: 1 addition & 1 deletion DiveRunner/ChangeScoreWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DiveRunner"
mc:Ignorable="d"
Title="ChangeScoreWindow" Height="450" Width="800" Closing="Window_Closing">
Title="ChangeScoreWindow" Height="450" Width="800" Closing="Window_Closing" WindowStyle="None">
<Grid>
<TextBox x:Name="JudgeOneScoreBox" HorizontalAlignment="Left" Height="23" Margin="116,288,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="69"/>
<TextBlock HorizontalAlignment="Left" Margin="116,244,0,0" TextWrapping="Wrap" Text="Judge 1 Score" VerticalAlignment="Top" Height="39" Width="69"/>
Expand Down
8 changes: 7 additions & 1 deletion DiveRunner/ChangeScoreWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ public ChangeScoreWindow(string name, Dive dive, double[] scores)

private void SaveButton_Click(object sender, RoutedEventArgs e)
{
this.Close();
Double x;
if (Double.TryParse(JudgeOneScoreBox.Text.Trim(), out x) && Double.TryParse(JudgeTwoScoreBox.Text.Trim(), out x) && Double.TryParse(JudgeThreeScoreBox.Text.Trim(), out x)){
this.Close();
}
else{
MessageBox.Show("The scores are not all numbers", "Error", MessageBoxButton.OK,MessageBoxImage.Error);
}
}

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
Expand Down
60 changes: 38 additions & 22 deletions DiveRunner/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@ public class Core
public int completedDives;
public string FileName;
public string PDFFolderName;
public bool createdDirectory;
public Core(String filename)
{
this.createdDirectory = false;
this.FileName = filename;
this.PDFFolderName = "pdfs/" + FileName.Split(new[] {".json"}, StringSplitOptions.RemoveEmptyEntries)[0] + "/";
if (!Directory.Exists("pdfs/")) Directory.CreateDirectory("pdfs");
else
{
Directory.Delete("pdfs", true);
Directory.CreateDirectory("pdfs");
}
this.PDFFolderName = "/pdfs/" + FileName.Replace(".json", "") + "/";
totalDives = 0;
completedDives = 0;
canStart = false;
Expand Down Expand Up @@ -126,34 +122,52 @@ public Dive GetDive(string diveCode, string boardHeight)

public void GenerateReports()
{
if (!Directory.Exists("pdfs")) Directory.CreateDirectory("pdfs");
if (!this.createdDirectory && !Directory.Exists(this.PDFFolderName)){
Directory.CreateDirectory(this.PDFFolderName);
createdDirectory = true;
}
else if(!this.createdDirectory)
{
createdDirectory = true;
Directory.Delete(this.PDFFolderName, true);
Directory.CreateDirectory(this.PDFFolderName);
}
List<string> pdfs = new List<string>();
for(int i = 0; i < events.Count; i++){
pdfs.AddRange(events[i].GenerateReports());
}
MessageBox.Show("Press ok when all command windows close");
string filename = "pdfs/" + "/CombinedReport";
MessageBox.Show("Press ok when all command windows close","Instructions", MessageBoxButton.OK, MessageBoxImage.Information);
string filename = PDFFolderName + "CombinedReport";
string template = File.ReadAllText("CombinedTemplateLandscape.tex");
string includes = "";
foreach (string d in pdfs)
{
includes += @"\includepdf[pages=-]{" + d + "}\n";
includes += @"\includepdf[pages=-]{" + PDFFolderName + d + "}\n";
}
template = template.Replace("//Pdf includes//", includes);
File.WriteAllText(filename + ".tex", template);
System.Diagnostics.Process.Start("CMD.exe", "/C pdflatex -output-directory=" + "pdfs" + " " + filename + ".tex");
MessageBox.Show("Press ok when all command windows close");
System.Diagnostics.Process.Start("CMD.exe", "/C pdflatex -output-directory=" + PDFFolderName + " " + filename + ".tex");
MessageBox.Show("Press ok when all command windows close","Instructions", MessageBoxButton.OK, MessageBoxImage.Information);
Process.Start(Environment.CurrentDirectory + "/" + filename + ".pdf");
}

public void GenerateDiveList(){
if (!Directory.Exists("pdfs")) Directory.CreateDirectory("pdfs");
if (!this.createdDirectory && !Directory.Exists(this.PDFFolderName)){
Directory.CreateDirectory(this.PDFFolderName);
createdDirectory = true;
}
else if(!this.createdDirectory)
{
createdDirectory = true;
Directory.Delete(this.PDFFolderName, true);
Directory.CreateDirectory(this.PDFFolderName);
}
List<string> pdfs = new List<string>();
for(int i = 0; i < events.Count; i++){
pdfs.Add(events[i].GenerateDiveList());
}
Thread.Sleep(5000);
string filename = "pdfs/" + "CombinedDiveList";
MessageBox.Show("Press ok when all command windows close","Instructions", MessageBoxButton.OK, MessageBoxImage.Information);
string filename = PDFFolderName + "CombinedDiveList";
string template = File.ReadAllText("CombinedTemplatePortrait.tex");
string includes = "";
foreach (string d in pdfs)
Expand All @@ -162,8 +176,8 @@ public void GenerateDiveList(){
}
template = template.Replace("//Pdf includes//", includes);
File.WriteAllText(filename + ".tex", template);
System.Diagnostics.Process.Start("CMD.exe", "/C pdflatex -output-directory=" + "pdfs" + " " + filename + ".tex");
Thread.Sleep(5000);
System.Diagnostics.Process.Start("CMD.exe", "/C pdflatex -output-directory=" + PDFFolderName + " " + filename + ".tex");
MessageBox.Show("Press ok when all command windows close","Instructions", MessageBoxButton.OK, MessageBoxImage.Information);
Process.Start(Environment.CurrentDirectory + "/" + filename + ".pdf");
}

Expand Down Expand Up @@ -201,9 +215,10 @@ public class Event
public string Board;
public int completedDives;
public int at;
public string dirname = "pdfs";
public Event(String Name, String Board)
public String dirname;
public Event(String Name, String Board, String dirname)
{
this.dirname = dirname;
this.completedDives = 0;
this.Board = Board;
divers = new List<Diver>();
Expand Down Expand Up @@ -259,6 +274,7 @@ public List<string> GenerateReports()
{
for(int i = 0; i < divers.Count; i++)
{
divers[i].dirname = this.dirname;
divers[i].CalculateScore();
}
string filename = dirname + "/" + name.Replace(" ", "");
Expand Down Expand Up @@ -287,7 +303,7 @@ public List<string> GenerateReports()
pdfs.Add(name.Replace(" ", "") + ".pdf");
foreach (Diver d in divers)
{
pdfs.Add(d.Pdf.Split('/')[1]);
pdfs.Add(d.Pdf.Split('/')[d.Pdf.Split('/').Length - 1]);
}
return pdfs;
}
Expand Down Expand Up @@ -459,7 +475,7 @@ public string GenerateReport()
for (int i = 0; i < Dives.Length; i++)
{
table += Dives[i].Code + "&" + Dives[i].Description + "&" + Scores[i][0] + "&" + Scores[i][1] + "&" + Scores[i][2] + "&" + SubScores[i][0] + "&" + SubScores[i][1] + @"\\\midrule" + "\n";
}
}
template = template.Replace("//tabledata//", table);
File.WriteAllText(filename + ".tex", template);
Pdf = filename + ".pdf";
Expand Down
4 changes: 4 additions & 0 deletions DiveRunner/DiveRunner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<PropertyGroup>
<StartupObject>DiveRunner.App</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Fastenshtein, Version=1.0.0.5, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Fastenshtein.1.0.0.5\lib\net40-client\Fastenshtein.dll</HintPath>
Expand Down Expand Up @@ -164,6 +167,7 @@
<None Include="AnnouncementTemplate.tex">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="app.manifest" />
<None Include="CombinedTemplateLandscape.tex">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
10 changes: 6 additions & 4 deletions DiveRunner/EventWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public partial class EventWindow : Window
{
public Event createdEvent;
public List<Diver> divers;
public EventWindow()
private string dirname;
public EventWindow(string dirname)
{
this.dirname = dirname;
divers = new List<Diver>();
InitializeComponent();
BoardSelection.Items.Add("1M");
Expand Down Expand Up @@ -55,7 +57,7 @@ private void NewDiverButton_Click(object sender, RoutedEventArgs e)

private void SaveButton_Click(object sender, RoutedEventArgs e)
{
createdEvent = new Event(EventNameBox.Text, BoardSelection.Text);
createdEvent = new Event(EventNameBox.Text, BoardSelection.Text, dirname);
foreach (Diver d in divers)
{
createdEvent.AddDiver(d);
Expand All @@ -65,7 +67,7 @@ private void SaveButton_Click(object sender, RoutedEventArgs e)

private void SetButton_Click(object sender, RoutedEventArgs e)
{
createdEvent = new Event(EventNameBox.Text, BoardSelection.SelectionBoxItem.ToString());
createdEvent = new Event(EventNameBox.Text, BoardSelection.SelectionBoxItem.ToString(), dirname);
EventNameBox.IsEnabled = false;
BoardSelection.IsEnabled = false;
SetButton.IsEnabled = false;
Expand Down Expand Up @@ -97,7 +99,7 @@ private void EditDiverButton_Click(object sender, RoutedEventArgs e)

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
createdEvent = new Event(EventNameBox.Text, BoardSelection.Text);
createdEvent = new Event(EventNameBox.Text, BoardSelection.Text, dirname);
foreach (Diver d in divers)
{
createdEvent.AddDiver(d);
Expand Down
2 changes: 1 addition & 1 deletion DiveRunner/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public MainWindow(Core c, string f, List<string> AllFiles)

private void NewEvent(object sender, RoutedEventArgs e)
{
EventWindow eventWindow = new EventWindow();
EventWindow eventWindow = new EventWindow(c.PDFFolderName);
eventWindow.ShowDialog();
Event ev = eventWindow.createdEvent;
c.AddEvent(ev);
Expand Down
2 changes: 1 addition & 1 deletion DiveRunner/SampleCore.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"events":[{"name":"Boys 11 to 12","divers":[{"currentDive":0,"Name":"Gerald Ford","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs"},{"currentDive":0,"Name":"Boy Staunton","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs"},{"currentDive":0,"Name":"Gerald Ford Numero Dos","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs"},{"currentDive":0,"Name":"Who knows","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs"}],"nextDiver":0,"curDiver":{"currentDive":0,"Name":"Gerald Ford","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs"},"Board":"1M","completedDives":0,"at":0,"dirname":"pdfs"},{"name":"Girls Five to eleven","divers":[{"currentDive":0,"Name":"Girl Boy","EventName":"Girls Five to eleven","Board":"3M","Dives":[{"Code":"102C","Board":"3M","Description":"Forward 1 Somersault Tuck","DD":1.5,"DiveData":"102C,3M,Forward 1 Somersault Tuck,1.50"},{"Code":"201C","Board":"3M","Description":"Back Dive Tuck","DD":1.7,"DiveData":"201C,3M,Back Dive Tuck,1.70"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs"},{"currentDive":0,"Name":"Hello World","EventName":"Girls Five to eleven","Board":"3M","Dives":[{"Code":"201B","Board":"3M","Description":"Back Dive Pike","DD":1.8,"DiveData":"201B,3M,Back Dive Pike,1.80"},{"Code":"301C","Board":"3M","Description":"Reverse Dive Tuck","DD":1.8,"DiveData":"301C,3M,Reverse Dive Tuck,1.80"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs"}],"nextDiver":0,"curDiver":{"currentDive":0,"Name":"Girl Boy","EventName":"Girls Five to eleven","Board":"3M","Dives":[{"Code":"102C","Board":"3M","Description":"Forward 1 Somersault Tuck","DD":1.5,"DiveData":"102C,3M,Forward 1 Somersault Tuck,1.50"},{"Code":"201C","Board":"3M","Description":"Back Dive Tuck","DD":1.7,"DiveData":"201C,3M,Back Dive Tuck,1.70"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs"},"Board":"3M","completedDives":0,"at":0,"dirname":"pdfs"}],"curEvent":0,"curDiver":0,"totalDives":0,"completedDives":0}
{"FileName":"SampleCore.json","PDFFolderName":"pdfs/SampleCore/","createdDirectory":false,"events":[{"name":"Boys 11 to 12","divers":[{"currentDive":0,"Name":"Gerald Ford","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs/SampleCore/"},{"currentDive":0,"Name":"Boy Staunton","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs/SampleCore/"},{"currentDive":0,"Name":"Gerald Ford Numero Dos","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs/SampleCore/"},{"currentDive":0,"Name":"Who knows","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs/SampleCore/"}],"nextDiver":0,"curDiver":{"currentDive":0,"Name":"Gerald Ford","EventName":"Boys 11 to 12","Board":"1M","Dives":[{"Code":"101C","Board":"1M","Description":"Forward Dive Tuck","DD":1.2,"DiveData":"101C,1M,Forward Dive Tuck,1.20"},{"Code":"202C","Board":"1M","Description":"Back 1 Somersault Tuck","DD":1.5,"DiveData":"202C,1M,Back 1 Somersault Tuck,1.50"},{"Code":"302C","Board":"1M","Description":"Reverse 1 Somersault Tuck","DD":1.6,"DiveData":"302C,1M,Reverse 1 Somersault Tuck,1.60"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs/SampleCore/"},"Board":"1M","completedDives":0,"at":0,"dirname":"pdfs/SampleCore/"},{"name":"Girls Five to eleven","divers":[{"currentDive":0,"Name":"Girl Boy","EventName":"Girls Five to eleven","Board":"3M","Dives":[{"Code":"102C","Board":"3M","Description":"Forward 1 Somersault Tuck","DD":1.5,"DiveData":"102C,3M,Forward 1 Somersault Tuck,1.50"},{"Code":"201C","Board":"3M","Description":"Back Dive Tuck","DD":1.7,"DiveData":"201C,3M,Back Dive Tuck,1.70"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs/SampleCore/"},{"currentDive":0,"Name":"Hello World","EventName":"Girls Five to eleven","Board":"3M","Dives":[{"Code":"201B","Board":"3M","Description":"Back Dive Pike","DD":1.8,"DiveData":"201B,3M,Back Dive Pike,1.80"},{"Code":"301C","Board":"3M","Description":"Reverse Dive Tuck","DD":1.8,"DiveData":"301C,3M,Reverse Dive Tuck,1.80"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs/SampleCore/"}],"nextDiver":0,"curDiver":{"currentDive":0,"Name":"Girl Boy","EventName":"Girls Five to eleven","Board":"3M","Dives":[{"Code":"102C","Board":"3M","Description":"Forward 1 Somersault Tuck","DD":1.5,"DiveData":"102C,3M,Forward 1 Somersault Tuck,1.50"},{"Code":"201C","Board":"3M","Description":"Back Dive Tuck","DD":1.7,"DiveData":"201C,3M,Back Dive Tuck,1.70"}],"Scores":[],"SubScores":null,"TotalScore":0.0,"Pdf":"null","Place":0,"dirname":"pdfs/SampleCore/"},"Board":"3M","completedDives":0,"at":0,"dirname":"pdfs/SampleCore/"}],"curEvent":0,"curDiver":0,"totalDives":0,"completedDives":0}
Loading

0 comments on commit 2100c84

Please sign in to comment.