Created a properties form, testing dynamic UI building for the relevant MKV attributes.

This commit is contained in:
2017-09-07 14:25:33 -05:00
parent ae5a8284b6
commit 51ab989cb8
8 changed files with 531 additions and 43 deletions
+11 -12
View File
@@ -34,13 +34,13 @@
this.fileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.openFolderFileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.debugToolStripMenuItem = 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.tableLayoutPanel1.SuspendLayout();
this.mainMenuStrip.SuspendLayout();
this.detailsGroupBox.SuspendLayout();
@@ -52,7 +52,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(2, 9);
this.selectFolderButton.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.selectFolderButton.Margin = new System.Windows.Forms.Padding(2);
this.selectFolderButton.Name = "selectFolderButton";
this.selectFolderButton.Size = new System.Drawing.Size(80, 29);
this.selectFolderButton.TabIndex = 1;
@@ -119,6 +119,13 @@
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
// debugToolStripMenuItem
//
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);
//
// inputFilesListView
//
this.tableLayoutPanel1.SetColumnSpan(this.inputFilesListView, 2);
@@ -138,7 +145,7 @@
this.detailsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.detailsGroupBox.Location = new System.Drawing.Point(339, 33);
this.detailsGroupBox.Name = "detailsGroupBox";
this.tableLayoutPanel1.SetRowSpan(this.detailsGroupBox, 2);
this.tableLayoutPanel1.SetRowSpan(this.detailsGroupBox, 3);
this.detailsGroupBox.Size = new System.Drawing.Size(218, 320);
this.detailsGroupBox.TabIndex = 5;
this.detailsGroupBox.TabStop = false;
@@ -148,7 +155,6 @@
//
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(3, 16);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(212, 301);
@@ -186,13 +192,6 @@
this.applyChangesButton.UseVisualStyleBackColor = true;
this.applyChangesButton.Click += new System.EventHandler(this.applyChangesButton_Click);
//
// debugToolStripMenuItem
//
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;
@@ -201,7 +200,7 @@
this.ClientSize = new System.Drawing.Size(560, 401);
this.Controls.Add(this.tableLayoutPanel1);
this.MainMenuStrip = this.mainMenuStrip;
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "Form1";
this.Text = "Form1";
this.tableLayoutPanel1.ResumeLayout(false);
+41 -23
View File
@@ -135,7 +135,7 @@ namespace MKVTest
Text = @"Track:s" + subtitleTrackNumber + @" Language: " + fileTrack.Language,
Parent = flowLayoutPanel1
};
audioTrackNumber++;
subtitleTrackNumber++;
if (flowLayoutPanel1.Container != null)
{
flowLayoutPanel1.Container.Add(nameLabel);
@@ -232,10 +232,6 @@ namespace MKVTest
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)
@@ -266,47 +262,69 @@ namespace MKVTest
ListFiles(d.SelectedPath);
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e) => Application.Exit();
public static bool CheckFiles()
{
return File.Exists("mkvpropedit.exe") && File.Exists("mkvinfo.exe");
}
private void ReadXml()
private void ReadXml(string s)
{
var xReader = new XmlTextReader(File.OpenRead("Test.info"));
var xReader = new XmlTextReader(new StringReader(s));
var r = new StringBuilder();
ClearForm();
//var readingTrack = false;
var tags = new List<XmlTag>();
while (xReader.Read())
{
switch (xReader.NodeType)
{
case XmlNodeType.Element:
//if (xReader.Name == "ATrack")
//{
inputFilesListView.Items.Add(xReader.Name + ": " + xReader.Value);
//}
//inputFilesListView.Items.Add(xReader.Name + ": " + xReader.Value);
var t = new XmlTag
{
Name = xReader.Name
};
tags.Add(t);
break;
case XmlNodeType.Text:
inputFilesListView.Items.Add(xReader.Value);
//inputFilesListView.Items.Add(xReader.Value);
tags[tags.Count - 1].Value = xReader.Value;
break;
}
}
//MessageBox.Show(r.ToString());
foreach (var tag in tags)
{
var label = new Label
{
Text = tag.Name
};
var textBox = new TextBox
{
Text = tag.Value
};
if (flowLayoutPanel1.Container != null)
{
flowLayoutPanel1.Container.Add(label);
flowLayoutPanel1.Container.Add(textBox);
}
//inputFilesListView.Items.Add(tag.Name + ": " + tag.Value);
}
}
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();
//var xml = new SerializeMkvInfo();
//var x = xml.SerializeFile("info.txt");
//var text = new StringBuilder();
//foreach (var line in x)
//{
// text.Append(line.Trim());
//}
//ReadXml(text.ToString());
var p = new FrmProperties();
p.ShowDialog();
}
}
}
+185
View File
@@ -0,0 +1,185 @@
namespace MKVTest
{
partial class FrmProperties
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.mainMenu = new System.Windows.Forms.MenuStrip();
this.fileMainMenu = new System.Windows.Forms.ToolStripMenuItem();
this.videoTrackGroupBox = new System.Windows.Forms.GroupBox();
this.audioTrackGoupBox = new System.Windows.Forms.GroupBox();
this.subtitleTrackGroupBox = new System.Windows.Forms.GroupBox();
this.chapterTrackGroupBox = new System.Windows.Forms.GroupBox();
this.videoFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.audioFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.subtitleFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.mainLayoutPanel.SuspendLayout();
this.mainMenu.SuspendLayout();
this.videoTrackGroupBox.SuspendLayout();
this.audioTrackGoupBox.SuspendLayout();
this.subtitleTrackGroupBox.SuspendLayout();
this.SuspendLayout();
//
// mainLayoutPanel
//
this.mainLayoutPanel.ColumnCount = 3;
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.mainLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F));
this.mainLayoutPanel.Controls.Add(this.mainMenu, 0, 0);
this.mainLayoutPanel.Controls.Add(this.videoTrackGroupBox, 0, 1);
this.mainLayoutPanel.Controls.Add(this.audioTrackGoupBox, 1, 1);
this.mainLayoutPanel.Controls.Add(this.subtitleTrackGroupBox, 2, 1);
this.mainLayoutPanel.Controls.Add(this.chapterTrackGroupBox, 0, 2);
this.mainLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.mainLayoutPanel.Name = "mainLayoutPanel";
this.mainLayoutPanel.RowCount = 3;
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 75F));
this.mainLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25F));
this.mainLayoutPanel.Size = new System.Drawing.Size(515, 406);
this.mainLayoutPanel.TabIndex = 0;
//
// mainMenu
//
this.mainLayoutPanel.SetColumnSpan(this.mainMenu, 3);
this.mainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileMainMenu});
this.mainMenu.Location = new System.Drawing.Point(0, 0);
this.mainMenu.Name = "mainMenu";
this.mainMenu.Size = new System.Drawing.Size(515, 24);
this.mainMenu.TabIndex = 0;
this.mainMenu.Text = "menuStrip1";
//
// fileMainMenu
//
this.fileMainMenu.Name = "fileMainMenu";
this.fileMainMenu.Size = new System.Drawing.Size(37, 20);
this.fileMainMenu.Text = "&File";
//
// videoTrackGroupBox
//
this.videoTrackGroupBox.Controls.Add(this.videoFlowLayoutPanel);
this.videoTrackGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.videoTrackGroupBox.Location = new System.Drawing.Point(3, 28);
this.videoTrackGroupBox.Name = "videoTrackGroupBox";
this.videoTrackGroupBox.Size = new System.Drawing.Size(165, 279);
this.videoTrackGroupBox.TabIndex = 1;
this.videoTrackGroupBox.TabStop = false;
this.videoTrackGroupBox.Text = "Video Track";
//
// audioTrackGoupBox
//
this.audioTrackGoupBox.Controls.Add(this.audioFlowLayoutPanel);
this.audioTrackGoupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.audioTrackGoupBox.Location = new System.Drawing.Point(174, 28);
this.audioTrackGoupBox.Name = "audioTrackGoupBox";
this.audioTrackGoupBox.Size = new System.Drawing.Size(165, 279);
this.audioTrackGoupBox.TabIndex = 2;
this.audioTrackGoupBox.TabStop = false;
this.audioTrackGoupBox.Text = "Audio Tracks";
//
// subtitleTrackGroupBox
//
this.subtitleTrackGroupBox.Controls.Add(this.subtitleFlowLayoutPanel);
this.subtitleTrackGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.subtitleTrackGroupBox.Location = new System.Drawing.Point(345, 28);
this.subtitleTrackGroupBox.Name = "subtitleTrackGroupBox";
this.subtitleTrackGroupBox.Size = new System.Drawing.Size(167, 279);
this.subtitleTrackGroupBox.TabIndex = 3;
this.subtitleTrackGroupBox.TabStop = false;
this.subtitleTrackGroupBox.Text = "Subtitles";
//
// chapterTrackGroupBox
//
this.chapterTrackGroupBox.Location = new System.Drawing.Point(3, 313);
this.chapterTrackGroupBox.Name = "chapterTrackGroupBox";
this.chapterTrackGroupBox.Size = new System.Drawing.Size(165, 90);
this.chapterTrackGroupBox.TabIndex = 4;
this.chapterTrackGroupBox.TabStop = false;
this.chapterTrackGroupBox.Text = "Chapter Markers";
//
// videoFlowLayoutPanel
//
this.videoFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.videoFlowLayoutPanel.Location = new System.Drawing.Point(3, 16);
this.videoFlowLayoutPanel.Name = "videoFlowLayoutPanel";
this.videoFlowLayoutPanel.Size = new System.Drawing.Size(159, 260);
this.videoFlowLayoutPanel.TabIndex = 0;
//
// audioFlowLayoutPanel
//
this.audioFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.audioFlowLayoutPanel.Location = new System.Drawing.Point(3, 16);
this.audioFlowLayoutPanel.Name = "audioFlowLayoutPanel";
this.audioFlowLayoutPanel.Size = new System.Drawing.Size(159, 260);
this.audioFlowLayoutPanel.TabIndex = 0;
//
// subtitleFlowLayoutPanel
//
this.subtitleFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.subtitleFlowLayoutPanel.Location = new System.Drawing.Point(3, 16);
this.subtitleFlowLayoutPanel.Name = "subtitleFlowLayoutPanel";
this.subtitleFlowLayoutPanel.Size = new System.Drawing.Size(161, 260);
this.subtitleFlowLayoutPanel.TabIndex = 0;
//
// FrmProperties
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(515, 406);
this.Controls.Add(this.mainLayoutPanel);
this.MainMenuStrip = this.mainMenu;
this.Name = "FrmProperties";
this.Text = "Properties";
this.mainLayoutPanel.ResumeLayout(false);
this.mainLayoutPanel.PerformLayout();
this.mainMenu.ResumeLayout(false);
this.mainMenu.PerformLayout();
this.videoTrackGroupBox.ResumeLayout(false);
this.audioTrackGoupBox.ResumeLayout(false);
this.subtitleTrackGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel mainLayoutPanel;
private System.Windows.Forms.MenuStrip mainMenu;
private System.Windows.Forms.ToolStripMenuItem fileMainMenu;
private System.Windows.Forms.GroupBox videoTrackGroupBox;
private System.Windows.Forms.GroupBox audioTrackGoupBox;
private System.Windows.Forms.GroupBox subtitleTrackGroupBox;
private System.Windows.Forms.GroupBox chapterTrackGroupBox;
private System.Windows.Forms.FlowLayoutPanel videoFlowLayoutPanel;
private System.Windows.Forms.FlowLayoutPanel audioFlowLayoutPanel;
private System.Windows.Forms.FlowLayoutPanel subtitleFlowLayoutPanel;
}
}
+114
View File
@@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
namespace MKVTest
{
public partial class FrmProperties : Form
{
public FrmProperties()
{
InitializeComponent();
GeneratePropertiesFile(@"C:\Users\glmcc\Desktop\Death Note\Black Lagoon - 1x02 - Mangrove Heaven.mkv");
ReadPropertiesFile();
}
private void GeneratePropertiesFile(string filePath)
{
var command = "/C mkvinfo.exe \"" + filePath + "\" > properties.txt";
var process = new System.Diagnostics.Process();
var startInfo = new System.Diagnostics.ProcessStartInfo
{
WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal,
FileName = "cmd.exe",
Arguments = command
};
process.StartInfo = startInfo;
process.Start();
while (!process.HasExited)
{
}
}
private void ReadPropertiesFile()
{
var serializer = new SerializeMkvInfo();
var xml = serializer.SerializeFile("properties.txt");
var text = new StringBuilder();
foreach (var line in xml)
{
text.Append(line.Trim());
}
ReadXml(text.ToString());
}
private void ReadXml(string s)
{
var xReader = new XmlTextReader(new StringReader(s));
var r = new StringBuilder();
ClearForm();
var tags = new List<XmlTag>();
var subGroup = new GroupBox();
while (xReader.Read())
{
switch (xReader.NodeType)
{
case XmlNodeType.Element:
var t = new XmlTag
{
Name = xReader.Name
};
tags.Add(t);
break;
case XmlNodeType.Text:
tags[tags.Count - 1].Value = xReader.Value;
break;
case XmlNodeType.EndElement:
tags.Clear();
break;
}
}
//foreach (var tag in tags)
//{
// //Foreach tag create a new row in the table layout panel.
// mainLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 30));
// var label = new Label
// {
// Text = tag.Name //Static property name.
// };
// var textBox = new TextBox
// {
// Text = tag.Value //Allows the user to
// };
// mainLayoutPanel.Controls.Add(label, 0, mainLayoutPanel.RowCount - 1);
// mainLayoutPanel.Controls.Add(textBox, 0, mainLayoutPanel.RowCount - 1);
//}
}
private void BuildForm(List<XmlTag> tags)
{
foreach (var tag in tags)
{
}
}
private void ClearForm()
{
}
}
}
+123
View File
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="mainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
+10
View File
@@ -51,11 +51,18 @@
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="FrmProperties.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmProperties.Designer.cs">
<DependentUpon>FrmProperties.cs</DependentUpon>
</Compile>
<Compile Include="MkvAttribute.cs" />
<Compile Include="MkvFile.cs" />
<Compile Include="MkvFileInfo.cs" />
<Compile Include="MkvSegmentInformation.cs" />
<Compile Include="MkvTrack.cs" />
<Compile Include="MkvWriter.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SerializeMkvInfo.cs" />
@@ -63,6 +70,9 @@
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmProperties.resx">
<DependentUpon>FrmProperties.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
+44
View File
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MKVTest
{
class MkvWriter
{
public bool WriteMkvMetaData(string commandString)
{
var process = new Process();
var startInfo = new ProcessStartInfo
{
WindowStyle = ProcessWindowStyle.Normal,
FileName = "cmd.exe",
Arguments = commandString
};
if (!CheckFiles())
{
throw new FileNotFoundException("Required files, mkvpropedit.exe and mkvinfo.exe not found.");
}
process.StartInfo = startInfo;
process.Start();
while (!process.HasExited)
{
}
if (process.ExitCode == 0) return true;
var error = File.ReadAllLines("temp.txt");
throw new ApplicationException(error.ToString());
}
public static bool CheckFiles()
{
return File.Exists("mkvpropedit.exe") && File.Exists("mkvinfo.exe");
}
}
}
+3 -8
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
@@ -81,7 +80,7 @@ namespace MKVTest
stack.Push(tag);
lastDepthLevel = depth;
}
//File.WriteAllLines(@"C:\Users\glmcc\Desktop\Test.info", xml);
return xml;
}
@@ -93,7 +92,7 @@ namespace MKVTest
var insideBraces = false;
var name = new StringBuilder();
var value = new StringBuilder();
var attributes = new List<MkvAttribute>();
//var attributes = new List<MkvAttribute>();
for (var i = 0; i < text.Length; i++)
{
@@ -139,10 +138,6 @@ namespace MKVTest
if(!insideBraces) name.Append(text[i]);
}
}
//if (text.Contains("Segment, "))
//{
// name.Clear();
//}
tag.Name = FormatTagName(name.ToString());
tag.Value = value.ToString().Trim();
tag.Depth = tagDepth;