Skip to content

Commit

Permalink
First commit with working converter. Bug 1: Text with enters in start…
Browse files Browse the repository at this point in the history
… wil be shown wrong. Bug 2: weird grey areas on Drawings
  • Loading branch information
Hans Doof committed Apr 3, 2019
1 parent b1d73b5 commit 41b7c00
Show file tree
Hide file tree
Showing 16 changed files with 616 additions and 53 deletions.
4 changes: 2 additions & 2 deletions App.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Application x:Class="Ragemaker.App"
<Application x:Class="RagemakerToPDF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Ragemaker"
xmlns:local="clr-namespace:RagemakerToPDF"
StartupUri="MainWindow.xaml">
<Application.Resources>

Expand Down
2 changes: 1 addition & 1 deletion App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Linq;
using System.Windows;

namespace Ragemaker
namespace RagemakerToPDF
{
/// <summary>
/// Interaction logic for App.xaml
Expand Down
15 changes: 15 additions & 0 deletions DrawImage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RagemakerToPDF
{
// For both types "Draw" and "Image", they are essentially the same, they only differ in function inside ragemaker
class DrawImage : RageItem
{
// PNG afaik
public byte[] imagedata = new byte[1];
}
}
29 changes: 29 additions & 0 deletions Face.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RagemakerToPDF
{
class Face : RageItem
{
/*
* <Face>
<itemx>13.5</itemx>
<itemy>67</itemy>
<facename>Neutral/37.png</facename>
<scalex>0.6868686868686867</scalex>
<scaley>0.6868686868686867</scaley>
<mirrored>true</mirrored>
<rotation>0</rotation>
<opacity>1</opacity>
</Face>
*
*/
public string file = "";
public float scalex = 0.0f;
public float scaley = 0.0f;
public bool mirrored = false;
}
}
14 changes: 10 additions & 4 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<Window x:Class="Ragemaker.MainWindow"
<Window x:Class="RagemakerToPDF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Ragemaker"
xmlns:local="clr-namespace:RagemakerToPDF"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
Title="RageToPDF" Height="700" Width="400">
<Grid>

<StackPanel>
<Button FontSize="25" Click="LoadRageXML_Click" Height="50">Select ragemaker .xml file</Button>
<ScrollViewer Height="600" >
<TextBlock x:Name="status" ScrollViewer.CanContentScroll="True">You shouldn't see this.</TextBlock>
</ScrollViewer>

</StackPanel>
</Grid>
</Window>
114 changes: 112 additions & 2 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
Expand All @@ -12,16 +17,121 @@
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Ragemaker
namespace RagemakerToPDF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{

public MainWindow()
{
InitializeComponent();
status.Text = "Status:";
}

private async void LoadRageXML_Click(object sender, RoutedEventArgs e)
{

Ragecomic comic = new Ragecomic();

System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
//ofd.InitialDirectory = ".";
ofd.RestoreDirectory = true;
ofd.Filter = "Ragemaker .xml file (*.xml)|*.xml";
ofd.Title = "Select ragemaker .xml file to convert to PDF";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string filename = ofd.FileNames[0];

// Open File
using (FileStream fs = new FileStream(filename, FileMode.Open))
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.Async = true;

// Read XML
using (XmlReader reader = XmlReader.Create(fs, settings))
{

while (await reader.ReadAsync())
{
string elementName = reader.Name;
switch (elementName)
{
/*
* <panels>8</panels>
* <gridLinesArray>111001110011100</gridLinesArray>
* <gridAboveAll>true</gridAboveAll>
* <showGrid>true</showGrid>
* <redditWatermark>false</redditWatermark>
*/
case "panels":
int panels = int.Parse(reader.ReadInnerXml());
status.Text += "panels: " + panels.ToString() + "\n";
comic.panels = panels;
break;
case "gridLinesArray":
string gridLinesArray = reader.ReadInnerXml();
status.Text += "gridLinesArray: " + gridLinesArray+ "\n";
comic.gridLines = new bool[gridLinesArray.Length];
for(var i = 0; i < gridLinesArray.Length; i++)
{
comic.gridLines[i] = gridLinesArray[i].ToString() == "1" ? true: false;
//status.Text += comic.gridLines[i] + "\n";
}
//comic.panels = panels;
break;
case "gridAboveAll":
comic.gridAboveAll = bool.Parse(reader.ReadInnerXml());
status.Text += "gridAboveAll: " + comic.gridAboveAll + "\n";
break;
case "showGrid":
comic.showGrid = bool.Parse(reader.ReadInnerXml());
status.Text += "showGrid: " + comic.showGrid + "\n";
break;
case "redditWatermark":
comic.redditWatermark = bool.Parse(reader.ReadInnerXml());
status.Text += "redditWatermark: " + comic.redditWatermark + "\n";
break;
case "Face":
case "Text":
case "Draw":
case "Image":
if (reader.NodeType == XmlNodeType.EndElement) break;
using(XmlReader subtreeReader = reader.ReadSubtree())
{
RageItem newItem = await RageItem.createRageItem(elementName, subtreeReader);
comic.items.Add(newItem);
status.Text += "new item: " + newItem.ToString() + "\n";
}
break;
default:
break;
}
}
}
}
status.Text += filename + " was parsed successfully.\n\n\nProceeding to PDF generation\n\n\n";

RagecomicToPDF.MakePDF(comic, filename + ".pdf");

}
else
{
MessageBox.Show("error");
}

Thread thread = new Thread(LoadAndProcessRageXML);
thread.Start();


}

private void LoadAndProcessRageXML()
{

}
}
}
46 changes: 19 additions & 27 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 9 additions & 13 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 41b7c00

Please sign in to comment.