Updated the Main form to include subtitles in the details pane. Minor tweaks to the serializer engine. Focus my shift from this to FNRenamer from here.
This commit is contained in:
Generated
+20
-28
@@ -33,14 +33,13 @@
|
||||
this.mainMenuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.fileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openFolderFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.selectFileMainMenu = 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.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.mainMenuStrip.SuspendLayout();
|
||||
this.detailsGroupBox.SuspendLayout();
|
||||
@@ -52,7 +51,7 @@
|
||||
//
|
||||
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, 4, 4, 4);
|
||||
this.selectFolderButton.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.selectFolderButton.Name = "selectFolderButton";
|
||||
this.selectFolderButton.Size = new System.Drawing.Size(147, 54);
|
||||
this.selectFolderButton.TabIndex = 1;
|
||||
@@ -72,7 +71,7 @@
|
||||
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, 6, 6, 6);
|
||||
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));
|
||||
@@ -89,8 +88,7 @@
|
||||
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.debugToolStripMenuItem});
|
||||
this.fileMainMenu});
|
||||
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);
|
||||
@@ -102,7 +100,7 @@
|
||||
//
|
||||
this.fileMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.openFolderFileMainMenu,
|
||||
this.selectFileMainMenu});
|
||||
this.exitToolStripMenuItem});
|
||||
this.fileMainMenu.Name = "fileMainMenu";
|
||||
this.fileMainMenu.Size = new System.Drawing.Size(56, 34);
|
||||
this.fileMainMenu.Text = "&File";
|
||||
@@ -110,14 +108,9 @@
|
||||
// openFolderFileMainMenu
|
||||
//
|
||||
this.openFolderFileMainMenu.Name = "openFolderFileMainMenu";
|
||||
this.openFolderFileMainMenu.Size = new System.Drawing.Size(218, 34);
|
||||
this.openFolderFileMainMenu.Size = new System.Drawing.Size(239, 34);
|
||||
this.openFolderFileMainMenu.Text = "&Open Folder";
|
||||
//
|
||||
// selectFileMainMenu
|
||||
//
|
||||
this.selectFileMainMenu.Name = "selectFileMainMenu";
|
||||
this.selectFileMainMenu.Size = new System.Drawing.Size(218, 34);
|
||||
this.selectFileMainMenu.Text = "&Select File";
|
||||
this.openFolderFileMainMenu.Click += new System.EventHandler(this.openFolderFileMainMenu_Click);
|
||||
//
|
||||
// inputFilesListView
|
||||
//
|
||||
@@ -125,7 +118,7 @@
|
||||
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, 6, 6, 6);
|
||||
this.inputFilesListView.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.inputFilesListView.Name = "inputFilesListView";
|
||||
this.tableLayoutPanel1.SetRowSpan(this.inputFilesListView, 4);
|
||||
this.inputFilesListView.Size = new System.Drawing.Size(603, 673);
|
||||
@@ -138,9 +131,9 @@
|
||||
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, 6, 6, 6);
|
||||
this.detailsGroupBox.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.detailsGroupBox.Name = "detailsGroupBox";
|
||||
this.detailsGroupBox.Padding = new System.Windows.Forms.Padding(6, 6, 6, 6);
|
||||
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.detailsGroupBox.TabIndex = 5;
|
||||
@@ -153,7 +146,7 @@
|
||||
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, 6, 6, 6);
|
||||
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(388, 558);
|
||||
this.flowLayoutPanel1.TabIndex = 0;
|
||||
@@ -174,7 +167,7 @@
|
||||
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, 6, 6, 6);
|
||||
this.buttonPanel.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.buttonPanel.Name = "buttonPanel";
|
||||
this.buttonPanel.Size = new System.Drawing.Size(400, 69);
|
||||
this.buttonPanel.TabIndex = 8;
|
||||
@@ -184,7 +177,7 @@
|
||||
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, 6, 6, 6);
|
||||
this.applyChangesButton.Margin = new System.Windows.Forms.Padding(6);
|
||||
this.applyChangesButton.Name = "applyChangesButton";
|
||||
this.applyChangesButton.Size = new System.Drawing.Size(187, 54);
|
||||
this.applyChangesButton.TabIndex = 2;
|
||||
@@ -192,12 +185,12 @@
|
||||
this.applyChangesButton.UseVisualStyleBackColor = true;
|
||||
this.applyChangesButton.Click += new System.EventHandler(this.applyChangesButton_Click);
|
||||
//
|
||||
// debugToolStripMenuItem
|
||||
// exitToolStripMenuItem
|
||||
//
|
||||
this.debugToolStripMenuItem.Name = "debugToolStripMenuItem";
|
||||
this.debugToolStripMenuItem.Size = new System.Drawing.Size(87, 34);
|
||||
this.debugToolStripMenuItem.Text = "Debug";
|
||||
this.debugToolStripMenuItem.Click += new System.EventHandler(this.debugToolStripMenuItem_Click);
|
||||
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);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
@@ -207,7 +200,7 @@
|
||||
this.ClientSize = new System.Drawing.Size(1027, 740);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.MainMenuStrip = this.mainMenuStrip;
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
||||
this.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
@@ -228,14 +221,13 @@
|
||||
private System.Windows.Forms.MenuStrip mainMenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem openFolderFileMainMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem selectFileMainMenu;
|
||||
private System.Windows.Forms.ListView inputFilesListView;
|
||||
private System.Windows.Forms.GroupBox detailsGroupBox;
|
||||
private System.Windows.Forms.Panel buttonPanel;
|
||||
private System.Windows.Forms.Button applyChangesButton;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
private System.Windows.Forms.Label currentTitleLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem debugToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+54
-17
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
@@ -21,7 +22,7 @@ namespace MKVTest
|
||||
InitializeComponent();
|
||||
inputFilesListView.ItemSelectionChanged += UpdateFilePropPrediction;
|
||||
inputFilesListView.MouseClick += ShowMenu;
|
||||
this.Resize += Form1_Resize;
|
||||
Resize += Form1_Resize;
|
||||
|
||||
var item = new ToolStripMenuItem
|
||||
{
|
||||
@@ -30,7 +31,7 @@ namespace MKVTest
|
||||
};
|
||||
menu.Items.Add(item);
|
||||
|
||||
var inputColumn = new ColumnHeader()
|
||||
var inputColumn = new ColumnHeader
|
||||
{
|
||||
Text = @"Files",
|
||||
Name = @"HeaderColumn",
|
||||
@@ -43,7 +44,7 @@ namespace MKVTest
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
if (inputFilesListView.FocusedItem.Bounds.Contains(e.Location) == true)
|
||||
if (inputFilesListView.FocusedItem.Bounds.Contains(e.Location))
|
||||
{
|
||||
menu.Show(Cursor.Position);
|
||||
}
|
||||
@@ -57,7 +58,7 @@ namespace MKVTest
|
||||
flowLayoutPanel1.Controls.Clear();
|
||||
flowLayoutPanel1.Invalidate();
|
||||
|
||||
var titleLabel = new Label()
|
||||
var titleLabel = new Label
|
||||
{
|
||||
Parent = flowLayoutPanel1,
|
||||
Text = @"Current Title: " + file.SegementInformation?.Title,
|
||||
@@ -68,6 +69,7 @@ namespace MKVTest
|
||||
|
||||
var videoTrackNumber = 1;
|
||||
var audioTrackNumber = 1;
|
||||
var subtitleTrackNumber = 1;
|
||||
|
||||
foreach (var fileTrack in file.Tracks)
|
||||
{
|
||||
@@ -115,6 +117,28 @@ namespace MKVTest
|
||||
flowLayoutPanel1.Container.Add(languageLabel);
|
||||
}
|
||||
}
|
||||
|
||||
if (fileTrack.Type == MkvTrack.TrackType.Subtitle)
|
||||
{
|
||||
var nameLabel = new Label
|
||||
{
|
||||
AutoSize = true,
|
||||
Text = @"Track:s" + subtitleTrackNumber + @" Name: " + fileTrack.Name,
|
||||
Parent = flowLayoutPanel1
|
||||
};
|
||||
var languageLabel = new Label
|
||||
{
|
||||
AutoSize = true,
|
||||
Text = @"Track:s" + subtitleTrackNumber + @" Language: " + fileTrack.Language,
|
||||
Parent = flowLayoutPanel1
|
||||
};
|
||||
audioTrackNumber++;
|
||||
if (flowLayoutPanel1.Container != null)
|
||||
{
|
||||
flowLayoutPanel1.Container.Add(nameLabel);
|
||||
flowLayoutPanel1.Container.Add(languageLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +183,7 @@ namespace MKVTest
|
||||
var files = dir.GetFiles("*.mkv", SearchOption.TopDirectoryOnly);
|
||||
foreach (var file in files)
|
||||
{
|
||||
var node = new ListViewItem()
|
||||
var node = new ListViewItem
|
||||
{
|
||||
Tag = true, //Assume the file needs to be updated.
|
||||
Name = file.FullName,
|
||||
@@ -177,11 +201,9 @@ namespace MKVTest
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var d = new FolderBrowserDialog();
|
||||
if (d.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ClearForm();
|
||||
ListFiles(d.SelectedPath);
|
||||
}
|
||||
if (d.ShowDialog() != DialogResult.OK) return;
|
||||
ClearForm();
|
||||
ListFiles(d.SelectedPath);
|
||||
}
|
||||
|
||||
private void Form1_Resize(object sender, EventArgs e)
|
||||
@@ -200,13 +222,17 @@ namespace MKVTest
|
||||
var command = "/C mkvpropedit.exe --edit info --set \"title=" + GetEpisodeName(node.Text) +
|
||||
"\" --edit track:v1 --set \"name=" + GetEpisodeName(node.Text) +
|
||||
"\" --edit track:v1 --set \"language=eng\" --edit track:a1 --set \"name=English\" --edit track:a1 --set \"language=eng\" \"" + node.Name + "\" > temp.txt";
|
||||
var process = new System.Diagnostics.Process();
|
||||
var startInfo = new System.Diagnostics.ProcessStartInfo
|
||||
var process = new Process();
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal,
|
||||
WindowStyle = ProcessWindowStyle.Normal,
|
||||
FileName = "cmd.exe",
|
||||
Arguments = command
|
||||
};
|
||||
if (!CheckFiles())
|
||||
{
|
||||
MessageBox.Show(@"The two required files, mkvpropedit.exe and mkvinfo.exe are missing from this program's startup folder. These files are required to edit MKV files.", @"Missing Required Files");
|
||||
}
|
||||
process.StartInfo = startInfo;
|
||||
process.Start();
|
||||
while (!process.HasExited)
|
||||
@@ -229,11 +255,22 @@ namespace MKVTest
|
||||
flowLayoutPanel1.Invalidate();
|
||||
}
|
||||
|
||||
private void debugToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void openFolderFileMainMenu_Click(object sender, EventArgs e)
|
||||
{
|
||||
var s = new SerializeMkvInfo();
|
||||
var xml = s.SerializeFile("C:\\Users\\Crypto\\Documents\\Source Control\\mkvbatcheditor\\MKVTest\\info.txt");
|
||||
File.WriteAllLines("C:\\Users\\Crypto\\Desktop\\1234Testing.txt", xml.ToArray());
|
||||
var d = new FolderBrowserDialog();
|
||||
if (d.ShowDialog() != DialogResult.OK) return;
|
||||
ClearForm();
|
||||
ListFiles(d.SelectedPath);
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
public static bool CheckFiles()
|
||||
{
|
||||
return File.Exists("mkvpropedit.exe") && File.Exists("mkvinfo.exe");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MkvAttribute.cs" />
|
||||
<Compile Include="MkvFile.cs" />
|
||||
<Compile Include="MkvFileInfo.cs" />
|
||||
<Compile Include="MkvSegmentInformation.cs" />
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MKVTest
|
||||
{
|
||||
class MkvAttribute
|
||||
{
|
||||
public string Name;
|
||||
public string Value;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ namespace MKVTest
|
||||
class MkvFile
|
||||
{
|
||||
public List<MkvTrack> Tracks;
|
||||
public List<MkvAttribute> Attributes;
|
||||
public MkvSegmentInformation SegementInformation;
|
||||
public string FullName;
|
||||
public string FileName;
|
||||
|
||||
@@ -30,6 +30,10 @@ namespace MKVTest
|
||||
Arguments = command
|
||||
};
|
||||
process.StartInfo = startInfo;
|
||||
if (!Form1.CheckFiles())
|
||||
{
|
||||
MessageBox.Show(@"The two required files, mkvpropedit.exe and mkvinfo.exe are missing from this program's startup folder. These files are required to edit MKV files.", @"Missing Required Files");
|
||||
}
|
||||
process.Start();
|
||||
while (!process.HasExited)
|
||||
{
|
||||
@@ -76,6 +80,7 @@ namespace MKVTest
|
||||
{
|
||||
var index = info[i].IndexOf(":", StringComparison.Ordinal) + 1;
|
||||
track.Name = info[i].Substring(index, (info[i].Length - index)).Trim();
|
||||
if(track.Type == MkvTrack.TrackType.Subtitle) tracks.Add(track);
|
||||
}
|
||||
|
||||
if (info[i].Contains("Language:"))
|
||||
|
||||
+38
-21
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
@@ -26,23 +27,23 @@ namespace MKVTest
|
||||
}
|
||||
if (i == file.Length - 1)
|
||||
{
|
||||
test[test.Count - 1] = padding + "<" + tag.Name + ">" + tag.Value + "</" + tag.Name + ">";
|
||||
var t = stack.Pop();
|
||||
test[test.Count - 2] = padding + "<" + t.Name + " Value=\"" + t.Value + "\" />";
|
||||
test[test.Count - 1] = padding + "<" + tag.Name + " Value=\"" + tag.Value + "\" />";
|
||||
//Unwind the stack.
|
||||
foreach (var s in stack)
|
||||
{
|
||||
test.Add("</" + s.Name + ">");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
//xml.Append(padding + "<" + tag.Name + ">" + tag.Value == string.Empty ? Environment.NewLine : string.Empty);
|
||||
//test.Add(padding + "<" + tag.Name + ">");
|
||||
//if (stack.Count != 0)
|
||||
//{
|
||||
// var t = stack.Pop();
|
||||
// //xml.Append(t.Value + "</" + t.Name + ">");
|
||||
// test.Add(t.Value + "</" + t.Name + ">");
|
||||
//}
|
||||
if (depth == lastDepthLevel)
|
||||
{
|
||||
if (stack.Count != 0)
|
||||
{
|
||||
var t = stack.Pop();
|
||||
test[test.Count - 1] = padding + test[test.Count - 1] + t.Value + "</" + t.Name + ">";
|
||||
test[test.Count - 1] = padding + "<" + t.Name + " Value=\"" + t.Value + "\" />";
|
||||
}
|
||||
}
|
||||
else if (depth < lastDepthLevel)
|
||||
@@ -51,16 +52,16 @@ namespace MKVTest
|
||||
if (stack.Count != 0)
|
||||
{
|
||||
var t = stack.Pop();
|
||||
test[test.Count - 1] = padding + "<" + t.Name + ">" + t.Value + "</" + t.Name + ">";
|
||||
test[test.Count - 1] = padding + "<" + t.Name + " Value=\"" + t.Value + "\" />";
|
||||
var diff = lastDepthLevel - depth;
|
||||
var subPadding = new StringBuilder();
|
||||
for (var j = 0; j < diff; j++)
|
||||
{
|
||||
subPadding.Clear();
|
||||
for (var k = padding.Length - j; k != 0; k--)
|
||||
{
|
||||
subPadding.Append(" ");
|
||||
}
|
||||
//for (var k = padding.Length - j; k != 0; k--)
|
||||
//{
|
||||
// subPadding.Append(" ");
|
||||
//}
|
||||
if (stack.Count != 0)
|
||||
{
|
||||
test.Add(subPadding + "</" + stack.Pop().Name + ">");
|
||||
@@ -80,6 +81,20 @@ namespace MKVTest
|
||||
return test;
|
||||
}
|
||||
|
||||
public List<XmlTag> CreateTagListFromFile(string filePath)
|
||||
{
|
||||
var file = File.ReadAllLines(filePath);
|
||||
if (file.Length == 0) return new List<XmlTag>();
|
||||
var tags = new List<XmlTag>();
|
||||
foreach (var line in file)
|
||||
{
|
||||
var tag = CreateTagFromString(line);
|
||||
if(tag.Name != string.Empty) tags.Add(tag);
|
||||
}
|
||||
|
||||
return tags;
|
||||
}
|
||||
|
||||
private static XmlTag CreateTagFromString(string text, XmlTag parent = null)
|
||||
{
|
||||
var tag = new XmlTag();
|
||||
@@ -88,6 +103,7 @@ namespace MKVTest
|
||||
var insideBraces = false;
|
||||
var name = new StringBuilder();
|
||||
var value = new StringBuilder();
|
||||
var attributes = new List<MkvAttribute>();
|
||||
|
||||
for (var i = 0; i < text.Length; i++)
|
||||
{
|
||||
@@ -96,7 +112,7 @@ namespace MKVTest
|
||||
continue;
|
||||
}
|
||||
|
||||
if (text[i].ToString() == ":" && !foundDelimiter)
|
||||
if ((text[i].ToString() == ":" || text[i] == ',') && !foundDelimiter)
|
||||
{
|
||||
foundDelimiter = true;
|
||||
continue;
|
||||
@@ -110,6 +126,7 @@ namespace MKVTest
|
||||
insideBraces = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
value.Append(text[i]);
|
||||
}
|
||||
else
|
||||
@@ -127,10 +144,10 @@ namespace MKVTest
|
||||
if(!insideBraces) name.Append(text[i]);
|
||||
}
|
||||
}
|
||||
if (text.Contains("Segment, "))
|
||||
{
|
||||
name.Clear();
|
||||
}
|
||||
//if (text.Contains("Segment, "))
|
||||
//{
|
||||
// name.Clear();
|
||||
//}
|
||||
tag.Name = FormatTagName(name.ToString());
|
||||
tag.Value = value.ToString().Trim();
|
||||
tag.Parent = parent;
|
||||
|
||||
Reference in New Issue
Block a user