Added a root "File" node to the XML engine. Fixed a bug that deleted the "SegmentTracks" node.

This commit is contained in:
2017-09-05 13:26:40 -05:00
parent 646ea08f3e
commit fcbdbf15a4
4 changed files with 110 additions and 63 deletions
+44 -42
View File
@@ -33,13 +33,14 @@
this.mainMenuStrip = new System.Windows.Forms.MenuStrip();
this.fileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.openFolderFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.inputFilesListView = new System.Windows.Forms.ListView();
this.detailsGroupBox = new System.Windows.Forms.GroupBox();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.currentTitleLabel = new System.Windows.Forms.Label();
this.buttonPanel = new System.Windows.Forms.Panel();
this.applyChangesButton = new System.Windows.Forms.Button();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tableLayoutPanel1.SuspendLayout();
this.mainMenuStrip.SuspendLayout();
this.detailsGroupBox.SuspendLayout();
@@ -50,10 +51,10 @@
// selectFolderButton
//
this.selectFolderButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.selectFolderButton.Location = new System.Drawing.Point(4, 12);
this.selectFolderButton.Margin = new System.Windows.Forms.Padding(4);
this.selectFolderButton.Location = new System.Drawing.Point(2, 9);
this.selectFolderButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.selectFolderButton.Name = "selectFolderButton";
this.selectFolderButton.Size = new System.Drawing.Size(147, 54);
this.selectFolderButton.Size = new System.Drawing.Size(80, 29);
this.selectFolderButton.TabIndex = 1;
this.selectFolderButton.Text = "Select Folder";
this.selectFolderButton.UseVisualStyleBackColor = true;
@@ -71,16 +72,15 @@
this.tableLayoutPanel1.Controls.Add(this.buttonPanel, 2, 4);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(6);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 5;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 55F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25.08529F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 37.45736F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 37.45736F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 79F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 37F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(1027, 740);
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 43F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(560, 401);
this.tableLayoutPanel1.TabIndex = 2;
//
// mainMenuStrip
@@ -88,11 +88,11 @@
this.tableLayoutPanel1.SetColumnSpan(this.mainMenuStrip, 3);
this.mainMenuStrip.ImageScalingSize = new System.Drawing.Size(28, 28);
this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileMainMenu});
this.fileMainMenu,
this.debugToolStripMenuItem});
this.mainMenuStrip.Location = new System.Drawing.Point(0, 0);
this.mainMenuStrip.Name = "mainMenuStrip";
this.mainMenuStrip.Padding = new System.Windows.Forms.Padding(11, 4, 0, 4);
this.mainMenuStrip.Size = new System.Drawing.Size(1027, 42);
this.mainMenuStrip.Size = new System.Drawing.Size(560, 24);
this.mainMenuStrip.TabIndex = 2;
this.mainMenuStrip.Text = "menuStrip1";
//
@@ -102,26 +102,32 @@
this.openFolderFileMainMenu,
this.exitToolStripMenuItem});
this.fileMainMenu.Name = "fileMainMenu";
this.fileMainMenu.Size = new System.Drawing.Size(56, 34);
this.fileMainMenu.Size = new System.Drawing.Size(37, 20);
this.fileMainMenu.Text = "&File";
//
// openFolderFileMainMenu
//
this.openFolderFileMainMenu.Name = "openFolderFileMainMenu";
this.openFolderFileMainMenu.Size = new System.Drawing.Size(239, 34);
this.openFolderFileMainMenu.Size = new System.Drawing.Size(139, 22);
this.openFolderFileMainMenu.Text = "&Open Folder";
this.openFolderFileMainMenu.Click += new System.EventHandler(this.openFolderFileMainMenu_Click);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(139, 22);
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// inputFilesListView
//
this.tableLayoutPanel1.SetColumnSpan(this.inputFilesListView, 2);
this.inputFilesListView.Dock = System.Windows.Forms.DockStyle.Fill;
this.inputFilesListView.LabelWrap = false;
this.inputFilesListView.Location = new System.Drawing.Point(6, 61);
this.inputFilesListView.Margin = new System.Windows.Forms.Padding(6);
this.inputFilesListView.Location = new System.Drawing.Point(3, 33);
this.inputFilesListView.Name = "inputFilesListView";
this.tableLayoutPanel1.SetRowSpan(this.inputFilesListView, 4);
this.inputFilesListView.Size = new System.Drawing.Size(603, 673);
this.inputFilesListView.Size = new System.Drawing.Size(330, 365);
this.inputFilesListView.TabIndex = 3;
this.inputFilesListView.UseCompatibleStateImageBehavior = false;
this.inputFilesListView.View = System.Windows.Forms.View.Details;
@@ -130,12 +136,10 @@
//
this.detailsGroupBox.Controls.Add(this.flowLayoutPanel1);
this.detailsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.detailsGroupBox.Location = new System.Drawing.Point(621, 61);
this.detailsGroupBox.Margin = new System.Windows.Forms.Padding(6);
this.detailsGroupBox.Location = new System.Drawing.Point(339, 33);
this.detailsGroupBox.Name = "detailsGroupBox";
this.detailsGroupBox.Padding = new System.Windows.Forms.Padding(6);
this.tableLayoutPanel1.SetRowSpan(this.detailsGroupBox, 3);
this.detailsGroupBox.Size = new System.Drawing.Size(400, 592);
this.tableLayoutPanel1.SetRowSpan(this.detailsGroupBox, 2);
this.detailsGroupBox.Size = new System.Drawing.Size(218, 320);
this.detailsGroupBox.TabIndex = 5;
this.detailsGroupBox.TabStop = false;
this.detailsGroupBox.Text = "Details";
@@ -145,19 +149,18 @@
this.flowLayoutPanel1.Controls.Add(this.currentTitleLabel);
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(6, 28);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(6);
this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 16);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(388, 558);
this.flowLayoutPanel1.Size = new System.Drawing.Size(212, 301);
this.flowLayoutPanel1.TabIndex = 0;
//
// currentTitleLabel
//
this.currentTitleLabel.AutoSize = true;
this.currentTitleLabel.Location = new System.Drawing.Point(4, 0);
this.currentTitleLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.currentTitleLabel.Location = new System.Drawing.Point(2, 0);
this.currentTitleLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.currentTitleLabel.Name = "currentTitleLabel";
this.currentTitleLabel.Size = new System.Drawing.Size(125, 25);
this.currentTitleLabel.Size = new System.Drawing.Size(67, 13);
this.currentTitleLabel.TabIndex = 11;
this.currentTitleLabel.Text = "Current Title:";
//
@@ -166,41 +169,39 @@
this.buttonPanel.Controls.Add(this.applyChangesButton);
this.buttonPanel.Controls.Add(this.selectFolderButton);
this.buttonPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonPanel.Location = new System.Drawing.Point(621, 665);
this.buttonPanel.Margin = new System.Windows.Forms.Padding(6);
this.buttonPanel.Location = new System.Drawing.Point(339, 359);
this.buttonPanel.Name = "buttonPanel";
this.buttonPanel.Size = new System.Drawing.Size(400, 69);
this.buttonPanel.Size = new System.Drawing.Size(218, 39);
this.buttonPanel.TabIndex = 8;
//
// applyChangesButton
//
this.applyChangesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.applyChangesButton.Enabled = false;
this.applyChangesButton.Location = new System.Drawing.Point(205, 10);
this.applyChangesButton.Margin = new System.Windows.Forms.Padding(6);
this.applyChangesButton.Location = new System.Drawing.Point(112, 7);
this.applyChangesButton.Name = "applyChangesButton";
this.applyChangesButton.Size = new System.Drawing.Size(187, 54);
this.applyChangesButton.Size = new System.Drawing.Size(102, 29);
this.applyChangesButton.TabIndex = 2;
this.applyChangesButton.Text = "Apply Changes";
this.applyChangesButton.UseVisualStyleBackColor = true;
this.applyChangesButton.Click += new System.EventHandler(this.applyChangesButton_Click);
//
// exitToolStripMenuItem
// debugToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(239, 34);
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
this.debugToolStripMenuItem.Name = "debugToolStripMenuItem";
this.debugToolStripMenuItem.Size = new System.Drawing.Size(54, 20);
this.debugToolStripMenuItem.Text = "Debug";
this.debugToolStripMenuItem.Click += new System.EventHandler(this.debugToolStripMenuItem_Click);
//
// Form1
//
this.AcceptButton = this.selectFolderButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1027, 740);
this.ClientSize = new System.Drawing.Size(560, 401);
this.Controls.Add(this.tableLayoutPanel1);
this.MainMenuStrip = this.mainMenuStrip;
this.Margin = new System.Windows.Forms.Padding(4);
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Name = "Form1";
this.Text = "Form1";
this.tableLayoutPanel1.ResumeLayout(false);
@@ -228,6 +229,7 @@
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Label currentTitleLabel;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem;
}
}
+36
View File
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
namespace MKVTest
{
@@ -272,5 +275,38 @@ namespace MKVTest
{
return File.Exists("mkvpropedit.exe") && File.Exists("mkvinfo.exe");
}
private void ReadXml()
{
var xReader = new XmlTextReader(File.OpenRead("Test.info"));
var r = new StringBuilder();
while (xReader.Read())
{
switch (xReader.NodeType)
{
case XmlNodeType.Element:
r.Append("<" + xReader.Name + ">");
//listBox1.Items.Add("<" + xReader.Name + ">");
break;
case XmlNodeType.Text:
r.Append(xReader.Value);
//listBox1.Items.Add(xReader.Value);
break;
case XmlNodeType.EndElement:
//listBox1.Items.Add("");
break;
}
}
//MessageBox.Show(r.ToString());
}
private void debugToolStripMenuItem_Click(object sender, EventArgs e)
{
var xml = new SerializeMkvInfo();
var x = xml.SerializeFile("info.txt");
File.WriteAllLines("Test.info", x.ToArray());
ReadXml();
}
}
}
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
+28 -19
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace MKVTest
@@ -12,29 +13,32 @@ namespace MKVTest
var file = File.ReadAllLines(filePath);
if (file.Length == 0) return new List<string>();
var lastDepthLevel = 0;
var paddingOffSet = GetDepth(file[0]);
var xml = new StringBuilder();
//var paddingOffSet = GetDepth(file[0]);
//var xml = new StringBuilder();
var stack = new Stack<XmlTag>();
var test = new List<string>();
var xml = new List<string> {"<File>"};
//Create a root node for the file.
var rootNode = new XmlTag()
{
Name = "File"
};
stack.Push(rootNode);
for (var i = 0; i < file.Length; i++)
{
var depth = GetDepth(file[i]);
var tag = CreateTagFromString(file[i]);
var padding = new StringBuilder();
for (var j = depth - paddingOffSet; j > 0; j--)
{
padding.Append(" ");
}
//for (var j = depth - paddingOffSet; j > 0; j--)
//{
// padding.Append(" ");
//}
if (i == file.Length - 1)
{
var t = stack.Pop();
test[test.Count - 2] = padding + "<" + t.Name + " Value=\"" + t.Value + "\" />";
test[test.Count - 1] = padding + "<" + tag.Name + " Value=\"" + tag.Value + "\" />";
xml.Insert(xml.Count - 1, padding + "<" + t.Name + " Value=\"" + t.Value + "\" />");
xml[xml.Count - 1] = padding + "<" + tag.Name + " Value=\"" + tag.Value + "\" />";
//Unwind the stack.
foreach (var s in stack)
{
test.Add("</" + s.Name + ">");
}
xml.AddRange(stack.Select(s => "</" + s.Name + ">"));
continue;
}
@@ -43,7 +47,7 @@ namespace MKVTest
if (stack.Count != 0)
{
var t = stack.Pop();
test[test.Count - 1] = padding + "<" + t.Name + " Value=\"" + t.Value + "\" />";
xml[xml.Count - 1] = padding + "<" + t.Name + " Value=\"" + t.Value + "\" />";
}
}
else if (depth < lastDepthLevel)
@@ -52,7 +56,7 @@ namespace MKVTest
if (stack.Count != 0)
{
var t = stack.Pop();
test[test.Count - 1] = padding + "<" + t.Name + " Value=\"" + t.Value + "\" />";
xml[xml.Count - 1] = padding + "<" + t.Name + " Value=\"" + t.Value + "\" />";
var diff = lastDepthLevel - depth;
var subPadding = new StringBuilder();
for (var j = 0; j < diff; j++)
@@ -64,7 +68,7 @@ namespace MKVTest
//}
if (stack.Count != 0)
{
test.Add(subPadding + "</" + stack.Pop().Name + ">");
xml.Add(subPadding + "</" + stack.Pop().Name + ">");
}
else
{
@@ -73,12 +77,12 @@ namespace MKVTest
}
}
}
if(tag.Name != string.Empty) test.Add(padding + "<" + tag.Name + ">");
if(tag.Name != string.Empty) xml.Add(padding + "<" + tag.Name + ">");
stack.Push(tag);
lastDepthLevel = depth;
}
return test;
return xml;
}
public List<XmlTag> CreateTagListFromFile(string filePath)
@@ -121,13 +125,18 @@ namespace MKVTest
clearingPadding = false;
if (foundDelimiter)
{
if (text[i] == '(')
{
insideBraces = true;
continue;
}
if (insideBraces && text[i] == ')')
{
insideBraces = false;
continue;
}
value.Append(text[i]);
if(!insideBraces) value.Append(text[i]);
}
else
{