├── LICENSE ├── README.md ├── gMKVExtractGUI.sln ├── gMKVExtractGUI.v11.suo ├── gMKVExtractGUI ├── Controls │ ├── ControlExtensions.cs │ ├── ExceptionExtensions.cs │ ├── gCheckedListBox.cs │ ├── gComboBox.cs │ ├── gDataGridView.cs │ ├── gForm.cs │ ├── gForm.resx │ ├── gGroupBox.cs │ ├── gListBox.cs │ ├── gRichTextBox.cs │ ├── gTableLayoutPanel.cs │ ├── gTaskbarProgress.cs │ ├── gTextBox.cs │ └── gTreeView.cs ├── Forms │ ├── IFormMain.cs │ ├── frmJobManager.Designer.cs │ ├── frmJobManager.cs │ ├── frmJobManager.resx │ ├── frmLog.Designer.cs │ ├── frmLog.cs │ ├── frmLog.resx │ ├── frmMain.Designer.cs │ ├── frmMain.cs │ ├── frmMain.resx │ ├── frmMain2.Designer.cs │ ├── frmMain2.cs │ ├── frmMain2.resx │ ├── frmOptions.Designer.cs │ ├── frmOptions.cs │ └── frmOptions.resx ├── Images │ └── gMkvExtractGuiIcon.ico ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── app.config ├── app.manifest ├── gMKVExtractGUI.csproj ├── gMKVExtractGUI.csproj.user └── gSettings.cs └── gMKVToolNix ├── Chapters ├── matroskachapters.cs ├── matroskachapters.dtd └── matroskachapters.xsd ├── CueSheet ├── Cue.cs └── CueTrack.cs ├── Libs ├── LICENSE.md ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml ├── Properties └── AssemblyInfo.cs ├── gMKVAttachment.cs ├── gMKVChapter.cs ├── gMKVExtract.cs ├── gMKVHelper.cs ├── gMKVInfo.cs ├── gMKVJob.cs ├── gMKVJobInfo.cs ├── gMKVLogger.cs ├── gMKVMerge.cs ├── gMKVSegment.cs ├── gMKVSegmentInfo.cs ├── gMKVToolNix.csproj ├── gMKVToolNix.csproj.user ├── gMKVTrack.cs └── gMKVVersion.cs /LICENSE: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENCE 2 | Version 3.1, July 2019 3 | 4 | by Sam Hocevar 5 | theiostream 6 | dtf 7 | 8 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENCE 9 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 10 | 11 | 0. You just DO WHAT THE FUCK YOU WANT TO. 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gMKVExtractGUI_chs 2 | 3 | gMKVExtractGUI 为 [mkvextract](https://mkvtoolnix.download/doc/mkvextract.html) ( 从属于 [MKVToolNix](https://mkvtoolnix.download/) 套件 ) 的图形界面,它还整合了部分 [mkvinfo](https://mkvtoolnix.download/doc/mkvinfo.html) 的功能; 4 | 除文本汉化外,该项目与[上游](https://sourceforge.net/projects/gmkvextractgui/)无功能差异。 5 | 6 | ## 功能简述 7 | 8 | 导出 [Matroska](https://www.matroska.org/index.html) 媒体容器的轨道、时间码、标签、附件等。 9 | 10 | ## 简易指南 11 | 12 | _需要先下载 MKVToolNix 的便携版,或安装它的常规版。_ 13 | 14 | 解压本项目的预编译好的文件到任意目录,如果是常规版 MKVToolNix ,它会自动寻找到所需文件并成功打开,如果是便携版,需要在 ini 配置文件中指定具体路径; 15 | 或直接安置在 MKVToolNix 的所在路径下( `gMKVExtractGUI.exe` 与 `mkvtoolnix-gui.exe` 并列),此时会自动链接无需额外操作。 16 | 17 | ### 交流反馈 18 | 19 | 如汉化版存在专属问题,则前往 [此处](https://github.com/hooke007/MPV_lazy/discussions/categories/%E5%85%B6%E5%AE%83%E6%92%AD%E6%94%BE%E5%99%A8) 开帖;如原版也存在同样问题,则应回报给原作者。 20 | 21 | WTFPL 22 | WTFPL 23 | -------------------------------------------------------------------------------- /gMKVExtractGUI.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gMKVExtractGUI", "gMKVExtractGUI\gMKVExtractGUI.csproj", "{20EBEFF3-C838-4239-A236-EC055BF51398}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gMKVToolNix", "gMKVToolNix\gMKVToolNix.csproj", "{82FC8FA8-50C0-44FA-8801-80050C0ED89F}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x86 = Debug|x86 14 | Release|Any CPU = Release|Any CPU 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {20EBEFF3-C838-4239-A236-EC055BF51398}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {20EBEFF3-C838-4239-A236-EC055BF51398}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {20EBEFF3-C838-4239-A236-EC055BF51398}.Debug|x86.ActiveCfg = Debug|x86 21 | {20EBEFF3-C838-4239-A236-EC055BF51398}.Debug|x86.Build.0 = Debug|x86 22 | {20EBEFF3-C838-4239-A236-EC055BF51398}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {20EBEFF3-C838-4239-A236-EC055BF51398}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {20EBEFF3-C838-4239-A236-EC055BF51398}.Release|x86.ActiveCfg = Release|x86 25 | {20EBEFF3-C838-4239-A236-EC055BF51398}.Release|x86.Build.0 = Release|x86 26 | {82FC8FA8-50C0-44FA-8801-80050C0ED89F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {82FC8FA8-50C0-44FA-8801-80050C0ED89F}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {82FC8FA8-50C0-44FA-8801-80050C0ED89F}.Debug|x86.ActiveCfg = Debug|x86 29 | {82FC8FA8-50C0-44FA-8801-80050C0ED89F}.Debug|x86.Build.0 = Debug|x86 30 | {82FC8FA8-50C0-44FA-8801-80050C0ED89F}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {82FC8FA8-50C0-44FA-8801-80050C0ED89F}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {82FC8FA8-50C0-44FA-8801-80050C0ED89F}.Release|x86.ActiveCfg = Release|x86 33 | {82FC8FA8-50C0-44FA-8801-80050C0ED89F}.Release|x86.Build.0 = Release|x86 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /gMKVExtractGUI.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hooke007/gMKVExtractGUI_chs/138cb4cfda7783e805afbc2ce7b79e6c91c9d521/gMKVExtractGUI.v11.suo -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/ControlExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace gMKVToolNix.Controls 10 | { 11 | public static class ControlExtensions 12 | { 13 | [DllImport("user32.dll")] 14 | public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam); 15 | 16 | private const int WM_SETREDRAW = 11; 17 | 18 | /// 19 | /// Suspends ALL drawing for the specified control 20 | /// 21 | /// 22 | public static void SuspendDrawing(this Control parent) 23 | { 24 | SendMessage(parent.Handle, WM_SETREDRAW, false, 0); 25 | } 26 | 27 | /// 28 | /// Resumes ALL drawing for the specified control 29 | /// 30 | /// 31 | public static void ResumeDrawing(this Control parent) 32 | { 33 | SendMessage(parent.Handle, WM_SETREDRAW, true, 0); 34 | parent.Invalidate(true); 35 | } 36 | 37 | private static Boolean GetDesignMode(this Control control) 38 | { 39 | BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Static; 40 | PropertyInfo prop = control.GetType().GetProperty("DesignMode", bindFlags); 41 | return (Boolean)prop.GetValue(control, null); 42 | } 43 | 44 | /// 45 | /// Returns true if the control is currently in design mode, false otherwise 46 | /// 47 | /// 48 | /// 49 | public static Boolean IsInDesignMode(this Control control) 50 | { 51 | Control parent = control.Parent; 52 | while (parent != null) 53 | { 54 | if (parent.GetDesignMode()) 55 | { 56 | return true; 57 | } 58 | parent = parent.Parent; 59 | } 60 | return control.GetDesignMode(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/ExceptionExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Windows.Forms; 7 | 8 | namespace gMKVToolNix.Controls 9 | { 10 | public static class ExceptionExtensions 11 | { 12 | /// 13 | /// Displays a messagebox containing the message of the exception and aldo writes the exception stacktrace to the Debug console 14 | /// 15 | /// 16 | public static void ShowException(this Exception ex) 17 | { 18 | Debug.WriteLine(ex); 19 | MessageBox.Show(String.Format("An exception has occured!{0}{0}{1}", Environment.NewLine, ex.Message), "An exception has occured!", MessageBoxButtons.OK, MessageBoxIcon.Error); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gCheckedListBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Drawing; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace gMKVToolNix 10 | { 11 | 12 | public class gCheckedListBox: System.Windows.Forms.CheckedListBox 13 | { 14 | public gCheckedListBox() 15 | : base() 16 | { 17 | this.DoubleBuffered = true; 18 | //SetStyle(ControlStyles.AllPaintingInWmPaint, true); 19 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 20 | //SetStyle(ControlStyles.Opaque, true); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gComboBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace gMKVToolNix.Controls 10 | { 11 | public class gComboBox : ComboBox 12 | { 13 | protected ContextMenuStrip _ContextMenu = new ContextMenuStrip(); 14 | protected ToolStripMenuItem _ClearMenu = new ToolStripMenuItem("Clear"); 15 | protected ToolStripMenuItem _CopyMenu = new ToolStripMenuItem("Copy"); 16 | protected ToolTip _ToolTip = new ToolTip(); 17 | 18 | [Browsable(true)] 19 | public ToolTip ToolTip 20 | { 21 | get 22 | { 23 | return _ToolTip; 24 | } 25 | } 26 | 27 | public gComboBox() 28 | { 29 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 30 | this.DoubleBuffered = true; 31 | 32 | InitializeComponent(); 33 | 34 | SetUpContextMenu(); 35 | } 36 | 37 | protected void SetUpContextMenu() 38 | { 39 | // Set the ContextMenu Items 40 | _ContextMenu.Items.Clear(); 41 | _ContextMenu.Items.Add(_CopyMenu); 42 | _ContextMenu.Items.Add(_ClearMenu); 43 | 44 | // Add the EventHandlers 45 | _CopyMenu.Click += (object sender, EventArgs e) => 46 | { 47 | try 48 | { 49 | if (this.SelectedIndex > -1 && !String.IsNullOrWhiteSpace(this.Text)) 50 | { 51 | Clipboard.SetText(this.Text); 52 | } 53 | } 54 | catch (Exception ex) 55 | { 56 | ex.ShowException(); 57 | } 58 | }; 59 | 60 | _ClearMenu.Click += (object sender, EventArgs e) => 61 | { 62 | try 63 | { 64 | this.SelectedIndex = -1; 65 | } 66 | catch (Exception ex) 67 | { 68 | ex.ShowException(); 69 | } 70 | }; 71 | 72 | // Set the ContextMenu to this control 73 | this.ContextMenuStrip = _ContextMenu; 74 | } 75 | 76 | protected void InitializeComponent() 77 | { 78 | this.SuspendLayout(); 79 | // 80 | // gComboBox 81 | // 82 | this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(161))); 83 | this.Size = new System.Drawing.Size(121, 21); 84 | this.ResumeLayout(false); 85 | } 86 | 87 | protected void AutosizeDropDownWidth() 88 | { 89 | float longestItem = 0f; 90 | 91 | // Find the longest text from the items list, in order to define the width 92 | using (Graphics g = Graphics.FromHwnd(this.Handle)) 93 | { 94 | foreach (var item in Items) 95 | { 96 | float itemWidth = g.MeasureString(GetItemText(item), Font).Width; 97 | if (itemWidth > longestItem) 98 | { 99 | longestItem = itemWidth; 100 | } 101 | } 102 | } 103 | 104 | // If there is a ScrollBar, then increase the width by the VerticalScrollBarWidth 105 | if (Items.Count > MaxDropDownItems) 106 | { 107 | longestItem += SystemInformation.VerticalScrollBarWidth; 108 | } 109 | 110 | // Change the width of the items list, byt never make it smaller than the width of the control 111 | DropDownWidth = Convert.ToInt32(Math.Max(Math.Ceiling(longestItem), Width)); 112 | } 113 | 114 | protected override void OnDropDown(EventArgs e) 115 | { 116 | base.OnDropDown(e); 117 | 118 | try 119 | { 120 | AutosizeDropDownWidth(); 121 | } 122 | catch (Exception ex) 123 | { 124 | ex.ShowException(); 125 | } 126 | } 127 | 128 | protected override void OnTextChanged(EventArgs e) 129 | { 130 | base.OnTextChanged(e); 131 | 132 | _ToolTip.SetToolTip(this, this.Text ?? ""); 133 | } 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gDataGridView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Diagnostics; 6 | using System.Drawing; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace gMKVToolNix.Controls 11 | { 12 | public class gDataGridView:DataGridView 13 | { 14 | protected Int32 _LastClickedRowIndex = -1; 15 | 16 | [Browsable(false)] 17 | public Int32 LastClickedRowIndex 18 | { 19 | get { return _LastClickedRowIndex; } 20 | set { _LastClickedRowIndex = value; } 21 | } 22 | 23 | protected Int32 _LastClickedColumnIndex = -1; 24 | 25 | [Browsable(false)] 26 | public Int32 LastClickedColumnIndex 27 | { 28 | get { return _LastClickedColumnIndex; } 29 | set { _LastClickedColumnIndex = value; } 30 | } 31 | 32 | protected Int32 _ColumnResizedIndex = -1; 33 | protected Boolean _ColumnResizing = false; 34 | 35 | public gDataGridView() 36 | : base() 37 | { 38 | this.DoubleBuffered = true; 39 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 40 | 41 | this.RowHeadersVisible = false; 42 | this.AllowUserToAddRows = false; 43 | this.AllowUserToDeleteRows = false; 44 | this.AllowUserToResizeRows = false; 45 | this.EditMode = DataGridViewEditMode.EditProgrammatically; 46 | this.SelectionMode = DataGridViewSelectionMode.FullRowSelect; 47 | 48 | this.GridColor = Color.Gainsboro; 49 | this.BackgroundColor = System.Drawing.Color.GhostWhite; 50 | } 51 | 52 | protected override void OnCellMouseUp(DataGridViewCellMouseEventArgs e) 53 | { 54 | base.OnCellMouseUp(e); 55 | 56 | try 57 | { 58 | _LastClickedRowIndex = e.RowIndex; 59 | _LastClickedColumnIndex = e.ColumnIndex; 60 | 61 | if (Cursor.Current == Cursors.SizeWE) 62 | { 63 | _ColumnResizing = false; 64 | } 65 | } 66 | catch (Exception ex) 67 | { 68 | ex.ShowException(); 69 | } 70 | } 71 | 72 | protected override void OnCellMouseDown(DataGridViewCellMouseEventArgs e) 73 | { 74 | base.OnCellMouseDown(e); 75 | 76 | try 77 | { 78 | _LastClickedRowIndex = e.RowIndex; 79 | _LastClickedColumnIndex = e.ColumnIndex; 80 | 81 | _ColumnResizing = false; 82 | if (Cursor.Current == Cursors.SizeWE && e.RowIndex == -1 && e.ColumnIndex > -1) 83 | { 84 | _ColumnResizedIndex = e.ColumnIndex; 85 | 86 | // if we are in the first 8 pixel, we assume we resize the left column 87 | if (e.X < 8) 88 | { 89 | _ColumnResizedIndex = _ColumnResizedIndex - 1; 90 | } 91 | 92 | _ColumnResizing = true; 93 | } 94 | } 95 | catch (Exception ex) 96 | { 97 | ex.ShowException(); 98 | } 99 | } 100 | 101 | protected override void OnCellMouseMove(DataGridViewCellMouseEventArgs e) 102 | { 103 | base.OnCellMouseMove(e); 104 | 105 | try 106 | { 107 | if (e.Button == MouseButtons.Left && _ColumnResizing) 108 | { 109 | var c = new DataGridViewColumnEventArgs(this.Columns[_ColumnResizedIndex]); 110 | 111 | if (e.ColumnIndex > _ColumnResizedIndex) 112 | { 113 | // If we are in the next column, then e.X is zeroed 114 | // so we add the Column Width 115 | c.Column.Width += e.X; 116 | } 117 | else 118 | { 119 | // If we are in the same column, then e.X equals to Width 120 | c.Column.Width = e.X; 121 | } 122 | } 123 | } 124 | catch (Exception ex) 125 | { 126 | Debug.WriteLine(ex); 127 | } 128 | } 129 | 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Reflection; 7 | using System.Runtime.InteropServices; 8 | using System.Text; 9 | using System.Windows.Forms; 10 | 11 | namespace gMKVToolNix 12 | { 13 | public class gForm : Form 14 | { 15 | public static short LOWORD(int number) 16 | { 17 | return (short)number; 18 | } 19 | 20 | protected const int WM_DPICHANGED = 0x02E0; 21 | protected const float DESIGN_TIME_DPI = 96F; 22 | 23 | protected float oldDpi; 24 | protected float currentDpi; 25 | 26 | protected bool isMoving = false; 27 | protected bool shouldScale = false; 28 | 29 | /// 30 | /// Gets the form's border width in pixels 31 | /// 32 | public Int32 BorderWidth 33 | { 34 | get { return Convert.ToInt32(Convert.ToDouble((this.Width - this.ClientSize.Width)) / 2.0); } 35 | } 36 | 37 | /// 38 | /// Gets the form's Title Bar Height in pixels 39 | /// 40 | public Int32 TitlebarHeight 41 | { 42 | get { return this.Height - this.ClientSize.Height - 2 * BorderWidth; } 43 | } 44 | 45 | public gForm() :base() 46 | { 47 | this.DoubleBuffered = true; 48 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 49 | } 50 | 51 | protected void InitDPI() 52 | { 53 | oldDpi = currentDpi; 54 | float dx; 55 | using (Graphics g = this.CreateGraphics()) 56 | { 57 | dx = g.DpiX; 58 | } 59 | currentDpi = dx; 60 | 61 | HandleDpiChanged(); 62 | OnDPIChanged(); 63 | } 64 | 65 | protected override void OnResizeBegin(EventArgs e) 66 | { 67 | base.OnResizeBegin(e); 68 | 69 | this.isMoving = true; 70 | } 71 | 72 | protected override void OnResizeEnd(EventArgs e) 73 | { 74 | base.OnResizeEnd(e); 75 | 76 | this.isMoving = false; 77 | if (shouldScale) 78 | { 79 | shouldScale = false; 80 | HandleDpiChanged(); 81 | } 82 | } 83 | 84 | protected override void OnMove(EventArgs e) 85 | { 86 | base.OnMove(e); 87 | 88 | if (this.shouldScale && CanPerformScaling()) 89 | { 90 | this.shouldScale = false; 91 | HandleDpiChanged(); 92 | } 93 | } 94 | 95 | protected bool CanPerformScaling() 96 | { 97 | return (Screen.FromControl(this).Bounds.Contains(this.Bounds)); 98 | } 99 | 100 | protected override void WndProc(ref Message m) 101 | { 102 | switch (m.Msg) 103 | { 104 | // This message is sent when the form is dragged to a different monitor i.e. when 105 | // the bigger part of its are is on the new monitor. Note that handling the message immediately 106 | // might change the size of the form so that it no longer overlaps the new monitor in its bigger part 107 | // which in turn will send again the WM_DPICHANGED message and this might cause misbehavior. 108 | // Therefore we delay the scaling if the form is being moved and we use the CanPerformScaling method to 109 | // check if it is safe to perform the scaling. 110 | case WM_DPICHANGED: 111 | oldDpi = currentDpi; 112 | currentDpi = LOWORD((int)m.WParam); 113 | 114 | if (oldDpi != currentDpi) 115 | { 116 | if (this.isMoving) 117 | { 118 | shouldScale = true; 119 | } 120 | else 121 | { 122 | HandleDpiChanged(); 123 | } 124 | 125 | OnDPIChanged(); 126 | } 127 | 128 | break; 129 | } 130 | 131 | base.WndProc(ref m); 132 | } 133 | 134 | protected void HandleDpiChanged() 135 | { 136 | if (oldDpi != 0F) 137 | { 138 | float scaleFactor = currentDpi / oldDpi; 139 | 140 | // The default scaling method of the framework 141 | this.Scale(new SizeF(scaleFactor, scaleFactor)); 142 | 143 | // Fonts are not scaled automatically so we need to handle this manually 144 | this.ScaleFonts(scaleFactor); 145 | 146 | // Perform any other scaling different than font or size (e.g. ItemHeight) 147 | this.PerformSpecialScaling(scaleFactor); 148 | } 149 | else 150 | { 151 | // The special scaling also needs to be done initially 152 | this.PerformSpecialScaling(currentDpi / DESIGN_TIME_DPI); 153 | } 154 | } 155 | 156 | protected virtual void ScaleFonts(float scaleFactor) 157 | { 158 | // Go through all controls in the control tree and set their Font property 159 | ScaleFontForControl(this, scaleFactor); 160 | } 161 | 162 | protected static void ScaleFontForControl(Control control, float scaleFactor) 163 | { 164 | control.Font = new Font(control.Font.FontFamily, control.Font.Size * scaleFactor, control.Font.Style); 165 | 166 | foreach (Control child in control.Controls) 167 | { 168 | ScaleFontForControl(child, scaleFactor); 169 | } 170 | } 171 | 172 | protected virtual void PerformSpecialScaling(float scaleFactor) 173 | { 174 | } 175 | 176 | protected virtual void OnDPIChanged() 177 | { 178 | } 179 | 180 | /// 181 | /// Returns the full path and filename of the executing assembly 182 | /// 183 | /// 184 | protected String GetExecutingAssemblyLocation() 185 | { 186 | return Assembly.GetExecutingAssembly().Location; 187 | } 188 | 189 | /// 190 | /// Returns the current directory of the executing assembly 191 | /// 192 | /// 193 | protected String GetCurrentDirectory() 194 | { 195 | return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 196 | } 197 | 198 | /// 199 | /// Returns the version of the executing assembly 200 | /// 201 | /// 202 | protected Version GetCurrentVersion() 203 | { 204 | return Assembly.GetExecutingAssembly().GetName().Version; 205 | } 206 | 207 | protected void ShowErrorMessage(String argMessage) 208 | { 209 | MessageBox.Show("发生了错误!" + Environment.NewLine + Environment.NewLine + argMessage, "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error); 210 | } 211 | 212 | protected void ShowSuccessMessage(String argMessage) 213 | { 214 | MessageBox.Show(argMessage, "成功!", MessageBoxButtons.OK, MessageBoxIcon.Information); 215 | } 216 | 217 | protected DialogResult ShowQuestion(String argQuestion, String argTitle, bool argShowCancel = true) 218 | { 219 | MessageBoxButtons msgBoxBtns = MessageBoxButtons.YesNoCancel; 220 | if (!argShowCancel) 221 | { 222 | msgBoxBtns = MessageBoxButtons.YesNo; 223 | } 224 | return MessageBox.Show(argQuestion, argTitle, msgBoxBtns, MessageBoxIcon.Question); 225 | } 226 | 227 | private void InitializeComponent() 228 | { 229 | this.SuspendLayout(); 230 | // 231 | // gForm 232 | // 233 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 234 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 235 | this.ClientSize = new System.Drawing.Size(284, 261); 236 | this.Name = "gForm"; 237 | this.ResumeLayout(false); 238 | } 239 | 240 | protected void ToggleControls(Control argRootControl, Boolean argStatus) 241 | { 242 | foreach (Control ctrl in argRootControl.Controls) 243 | { 244 | if (ctrl is IContainer) 245 | { 246 | ToggleControls(ctrl, argStatus); 247 | } 248 | else 249 | { 250 | ctrl.Enabled = argStatus; 251 | } 252 | } 253 | } 254 | 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gGroupBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace gMKVToolNix 8 | { 9 | public class gGroupBox:GroupBox 10 | { 11 | public const Int32 WM_ERASEBKGND = 0x0014; 12 | 13 | public gGroupBox() 14 | : base() 15 | { 16 | this.DoubleBuffered = true; 17 | //SetStyle(ControlStyles.AllPaintingInWmPaint, true); 18 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gListBox.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace gMKVToolNix.Controls 8 | { 9 | public class gListBox:ListBox 10 | { 11 | public gListBox() 12 | : base() 13 | { 14 | this.DoubleBuffered = true; 15 | //SetStyle(ControlStyles.AllPaintingInWmPaint, true); 16 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 17 | //SetStyle(ControlStyles.Opaque, true); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gRichTextBox.cs: -------------------------------------------------------------------------------- 1 | using gMKVToolNix.Controls; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.Text; 6 | using System.Windows.Forms; 7 | 8 | namespace gMKVToolNix 9 | { 10 | public class gRichTextBox : RichTextBox 11 | { 12 | public gRichTextBox() 13 | : base() 14 | { 15 | this.DoubleBuffered = true; 16 | //SetStyle(ControlStyles.AllPaintingInWmPaint, true); 17 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 18 | 19 | this.ShortcutsEnabled = false; 20 | this.DetectUrls = false; 21 | } 22 | 23 | protected override void OnKeyDown(KeyEventArgs e) 24 | { 25 | base.OnKeyDown(e); 26 | try 27 | { 28 | if (e.Control && e.KeyCode == Keys.A) 29 | { 30 | this.SelectAll(); 31 | } 32 | else if (e.Control && e.KeyCode == Keys.C) 33 | { 34 | if (!String.IsNullOrWhiteSpace(this.SelectedText)) 35 | { 36 | Clipboard.SetText(this.SelectedText, TextDataFormat.UnicodeText); 37 | } 38 | } 39 | } 40 | catch (Exception ex) 41 | { 42 | Debug.WriteLine(ex); 43 | ex.ShowException(); 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gTableLayoutPanel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace gMKVToolNix 8 | { 9 | public class gTableLayoutPanel:TableLayoutPanel 10 | { 11 | public const Int32 WM_ERASEBKGND = 0x0014; 12 | 13 | public gTableLayoutPanel() 14 | : base() 15 | { 16 | this.DoubleBuffered = true; 17 | //SetStyle(ControlStyles.AllPaintingInWmPaint, true); 18 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gTaskbarProgress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Runtime.InteropServices; 4 | using System.Windows.Forms; 5 | 6 | namespace gMKVToolNix 7 | { 8 | public static class gTaskbarProgress 9 | { 10 | public enum TaskbarStates 11 | { 12 | NoProgress = 0, 13 | Indeterminate = 0x1, 14 | Normal = 0x2, 15 | Error = 0x4, 16 | Paused = 0x8 17 | } 18 | 19 | [ComImportAttribute()] 20 | [GuidAttribute("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")] 21 | [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] 22 | private interface ITaskbarList3 23 | { 24 | // ITaskbarList 25 | [PreserveSig] 26 | void HrInit(); 27 | [PreserveSig] 28 | void AddTab(IntPtr hwnd); 29 | [PreserveSig] 30 | void DeleteTab(IntPtr hwnd); 31 | [PreserveSig] 32 | void ActivateTab(IntPtr hwnd); 33 | [PreserveSig] 34 | void SetActiveAlt(IntPtr hwnd); 35 | 36 | // ITaskbarList2 37 | [PreserveSig] 38 | void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen); 39 | 40 | // ITaskbarList3 41 | [PreserveSig] 42 | Int32 SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal); 43 | [PreserveSig] 44 | Int32 SetProgressState(IntPtr hwnd, TaskbarStates state); 45 | [PreserveSig] 46 | Int32 SetOverlayIcon(IntPtr hwnd, IntPtr hIcon, [MarshalAs(UnmanagedType.LPWStr)] String pszDescription); 47 | } 48 | 49 | [GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")] 50 | [ClassInterfaceAttribute(ClassInterfaceType.None)] 51 | [ComImportAttribute()] 52 | private class TaskbarInstance { } 53 | 54 | private static ITaskbarList3 _TaskbarInstance = null; 55 | 56 | private static ITaskbarList3 Instance() 57 | { 58 | if (_TaskbarInstance == null) { _TaskbarInstance = (ITaskbarList3)new TaskbarInstance(); } 59 | return _TaskbarInstance; 60 | } 61 | 62 | private static bool IsTaskbarSupported 63 | { 64 | get 65 | { 66 | return !Program.IsOnLinux && Environment.OSVersion.Version >= new Version(6, 1); 67 | } 68 | } 69 | 70 | public static void SetState(Form frm, TaskbarStates taskbarState) 71 | { 72 | if (IsTaskbarSupported) { Instance().SetProgressState(frm.Handle, taskbarState); } 73 | } 74 | 75 | public static void SetValue(Form frm, UInt64 progressValue, UInt64 progressMax) 76 | { 77 | if (IsTaskbarSupported) { Instance().SetProgressValue(frm.Handle, (UInt64)progressValue, (UInt64)progressMax); } 78 | } 79 | 80 | public static void SetOverlayIcon(Form frm, System.Drawing.Icon icn, String description) 81 | { 82 | if (IsTaskbarSupported) 83 | { 84 | Debug.WriteLine(String.Format("{1}: HRESULT:0x{0:X8}", Instance().SetOverlayIcon(frm.Handle, icn == null ? IntPtr.Zero : icn.Handle, description ?? ""), description ?? "")); 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gTextBox.cs: -------------------------------------------------------------------------------- 1 | using gMKVToolNix.Controls; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.Text; 6 | using System.Windows.Forms; 7 | 8 | namespace gMKVToolNix 9 | { 10 | public class gTextBox:TextBox 11 | { 12 | public gTextBox() 13 | : base() 14 | { 15 | this.DoubleBuffered = true; 16 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 17 | } 18 | 19 | protected override void OnKeyDown(KeyEventArgs e) 20 | { 21 | base.OnKeyDown(e); 22 | 23 | try 24 | { 25 | if (e.Control && e.KeyCode == Keys.A) 26 | { 27 | this.SelectAll(); 28 | } 29 | else if (e.Control && e.KeyCode == Keys.C) 30 | { 31 | if (!String.IsNullOrWhiteSpace(this.SelectedText)) 32 | { 33 | Clipboard.SetText(this.SelectedText, TextDataFormat.UnicodeText); 34 | } 35 | } 36 | } 37 | catch (Exception ex) 38 | { 39 | Debug.WriteLine(ex); 40 | ex.ShowException(); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Controls/gTreeView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace gMKVToolNix 11 | { 12 | 13 | public class gTreeView : TreeView 14 | { 15 | private const int TVIF_STATE = 0x8; 16 | private const int TVIS_STATEIMAGEMASK = 0xF000; 17 | private const int TV_FIRST = 0x1100; 18 | private const int TVM_GETITEM = TV_FIRST + 62; 19 | private const int TVM_SETITEM = TV_FIRST + 63; 20 | 21 | [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Auto)] 22 | private struct TVITEM 23 | { 24 | public int mask; 25 | public IntPtr hItem; 26 | public int state; 27 | public int stateMask; 28 | [MarshalAs(UnmanagedType.LPTStr)] 29 | public string lpszText; 30 | public int cchTextMax; 31 | public int iImage; 32 | public int iSelectedImage; 33 | public int cChildren; 34 | public IntPtr lParam; 35 | } 36 | 37 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 38 | private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, ref TVITEM lParam); 39 | 40 | private bool _CheckOnClick = false; 41 | 42 | /// 43 | /// Gets or sets a value indicating whether the check box should be toggled when an item is selected. 44 | /// 45 | [Description("Indicates whether the check box should be toggled when an item is selected.")] 46 | public bool CheckOnClick 47 | { 48 | get { return _CheckOnClick; } 49 | set { _CheckOnClick = value; } 50 | } 51 | 52 | private bool _SelectOnRightClick = false; 53 | 54 | /// 55 | /// Gets or sets a value indicating whether right clicking a node changes the selection. 56 | /// 57 | [Description("Indicates whether right clicking a node changes the selection..")] 58 | public bool SelectOnRightClick 59 | { 60 | get { return _SelectOnRightClick; } 61 | set { _SelectOnRightClick = value; } 62 | } 63 | 64 | /// 65 | /// Returns a list with all the nodes of this TreeView 66 | /// 67 | [Description("Gets a list with all the nodes of this TreeView")] 68 | public List AllNodes 69 | { 70 | get 71 | { 72 | List nodes = new List(); 73 | GetAllNodes(this, nodes); 74 | return nodes; 75 | } 76 | } 77 | 78 | private void GetAllNodes(Object rootNode, List nodeList) 79 | { 80 | if(rootNode == null) 81 | { 82 | return; 83 | } 84 | if (nodeList == null) 85 | { 86 | nodeList = new List(); 87 | } 88 | if (rootNode is TreeView) 89 | { 90 | foreach (var node in (rootNode as TreeView).Nodes) 91 | { 92 | GetAllNodes(node, nodeList); 93 | } 94 | } 95 | else if (rootNode is TreeNode) 96 | { 97 | nodeList.Add(rootNode as TreeNode); 98 | if ((rootNode as TreeNode).Nodes != null && (rootNode as TreeNode).Nodes.Count > 0) 99 | { 100 | foreach (var node in (rootNode as TreeNode).Nodes) 101 | { 102 | GetAllNodes(node, nodeList); 103 | } 104 | } 105 | } 106 | } 107 | 108 | /// 109 | /// Returns a list with all the checked nodes of this TreeView 110 | /// 111 | [Description("Gets a list with all checked the nodes of this TreeView")] 112 | public List CheckedNodes 113 | { 114 | get 115 | { 116 | List nodes = new List(); 117 | GetCheckedNodes(this, nodes); 118 | return nodes; 119 | } 120 | } 121 | 122 | private void GetCheckedNodes(Object rootNode, List nodeList) 123 | { 124 | if (nodeList == null) 125 | { 126 | nodeList = new List(); 127 | } 128 | if (rootNode is TreeView) 129 | { 130 | foreach (var node in (rootNode as TreeView).Nodes) 131 | { 132 | GetCheckedNodes(node, nodeList); 133 | } 134 | } 135 | else if (rootNode is TreeNode) 136 | { 137 | if ((rootNode as TreeNode).Checked) 138 | { 139 | nodeList.Add(rootNode as TreeNode); 140 | } 141 | if ((rootNode as TreeNode).Nodes != null && (rootNode as TreeNode).Nodes.Count > 0) 142 | { 143 | foreach (var node in (rootNode as TreeNode).Nodes) 144 | { 145 | GetCheckedNodes(node, nodeList); 146 | } 147 | } 148 | } 149 | } 150 | 151 | public gTreeView() : base() 152 | { 153 | this.DoubleBuffered = true; 154 | //SetStyle(ControlStyles.AllPaintingInWmPaint, true); 155 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 156 | } 157 | 158 | /// 159 | /// Sets a value indicating if the checkbox is visible on the tree node. 160 | /// 161 | /// The tree node. 162 | /// true to make the checkbox visible on the tree node; otherwise false. 163 | public void SetIsCheckBoxVisible(TreeNode node, bool value) 164 | { 165 | if (node == null) 166 | throw new ArgumentNullException("node"); 167 | if (node.TreeView == null) 168 | throw new InvalidOperationException("The node does not belong to a tree."); 169 | 170 | // If we are on Linux, we can't use P/Invoke to user32.dll 171 | // So this function can't do anything 172 | if (gMKVHelper.IsOnLinux) { return; } 173 | 174 | var tvi = new TVITEM 175 | { 176 | hItem = node.Handle, 177 | mask = TVIF_STATE, 178 | stateMask = TVIS_STATEIMAGEMASK, 179 | state = (value ? node.Checked ? 2 : 1 : 0) << 12 180 | }; 181 | var result = SendMessage(node.TreeView.Handle, TVM_SETITEM, IntPtr.Zero, ref tvi); 182 | if (result == IntPtr.Zero) 183 | throw new ApplicationException("Error setting TreeNode state."); 184 | } 185 | 186 | /// 187 | /// Gets a value indicating if the checkbox is visible on the tree node. 188 | /// 189 | /// The tree node. 190 | /// true if the checkbox is visible on the tree node; otherwise false. 191 | public bool IsCheckBoxVisible(TreeNode node) 192 | { 193 | if (node == null) 194 | throw new ArgumentNullException("node"); 195 | if (node.TreeView == null) 196 | throw new InvalidOperationException("The node does not belong to a tree."); 197 | 198 | // If we are on Linux, we can't use P/Invoke to user32.dll 199 | // So if the node's check box visibility has the same value as the node's TreeView CheckBoxes property 200 | if (gMKVHelper.IsOnLinux) { return node.TreeView.CheckBoxes; } 201 | 202 | var tvi = new TVITEM 203 | { 204 | hItem = node.Handle, 205 | mask = TVIF_STATE 206 | }; 207 | var result = SendMessage(node.TreeView.Handle, TVM_GETITEM, node.Handle, ref tvi); 208 | if (result == IntPtr.Zero) 209 | throw new ApplicationException("Error getting TreeNode state."); 210 | var imageIndex = (tvi.state & TVIS_STATEIMAGEMASK) >> 12; 211 | return (imageIndex != 0); 212 | } 213 | 214 | protected override void OnNodeMouseClick(TreeNodeMouseClickEventArgs e) 215 | { 216 | base.OnNodeMouseClick(e); 217 | if (_CheckOnClick) 218 | { 219 | if (e.Button == MouseButtons.Left && 220 | e.Node.Bounds.Contains(new Point(e.X, e.Y)) 221 | && this.CheckBoxes 222 | && IsCheckBoxVisible(e.Node) 223 | ) 224 | { 225 | e.Node.Checked = !e.Node.Checked; 226 | } 227 | } 228 | if(_SelectOnRightClick && e.Button == MouseButtons.Right) 229 | { 230 | this.SelectedNode = e.Node; 231 | } 232 | } 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Forms/IFormMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace gMKVToolNix.Forms 7 | { 8 | public interface IFormMain 9 | { 10 | void SetTableLayoutMainStatus(Boolean argStatus); 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Forms/frmJobManager.cs: -------------------------------------------------------------------------------- 1 | using gMKVToolNix.Forms; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Diagnostics; 7 | using System.Drawing; 8 | using System.IO; 9 | using System.Media; 10 | using System.Reflection; 11 | using System.Text; 12 | using System.Threading; 13 | using System.Windows.Forms; 14 | using System.Linq; 15 | using System.Collections; 16 | 17 | namespace gMKVToolNix 18 | { 19 | public partial class frmJobManager : gForm 20 | { 21 | private readonly StringBuilder _ExceptionBuilder = new StringBuilder(); 22 | private readonly IFormMain _MainForm = null; 23 | private int _CurrentJob = 0; 24 | private int _TotalJobs = 0; 25 | private gMKVExtract _gMkvExtract = null; 26 | private bool _ExtractRunning = false; 27 | private gSettings _Settings = null; 28 | private bool _FromConstructor = false; 29 | 30 | private BindingList _JobList = new BindingList(); 31 | 32 | private Boolean _AbortAll = false; 33 | 34 | public frmJobManager(IFormMain argMainForm) 35 | { 36 | try 37 | { 38 | InitializeComponent(); 39 | 40 | _MainForm = argMainForm; 41 | 42 | Icon = Icon.ExtractAssociatedIcon(GetExecutingAssemblyLocation()); 43 | Text = String.Format("gMKVExtractGUI_chs v{0} -- 任务管理器", GetCurrentVersion()); 44 | 45 | _FromConstructor = true; 46 | 47 | // Load settings 48 | _Settings = new gSettings(this.GetCurrentDirectory()); 49 | _Settings.Reload(); 50 | 51 | chkShowPopup.Checked = _Settings.ShowPopupInJobManager; 52 | 53 | grdJobs.DataSource = _JobList; 54 | 55 | _FromConstructor = false; 56 | 57 | SetAbortStatus(false); 58 | 59 | // Initialize the DPI aware scaling 60 | InitDPI(); 61 | } 62 | catch (Exception ex) 63 | { 64 | Debug.WriteLine(ex); 65 | gMKVLogger.Log(ex.ToString()); 66 | _FromConstructor = false; 67 | ShowErrorMessage(ex.Message); 68 | } 69 | } 70 | 71 | private void SetJobsList(BindingList argJobList) 72 | { 73 | try 74 | { 75 | _JobList = argJobList; 76 | grdJobs.DataSource = _JobList; 77 | grdJobs.Refresh(); 78 | } 79 | catch (Exception ex) 80 | { 81 | Debug.WriteLine(ex); 82 | gMKVLogger.Log(ex.ToString()); 83 | ShowErrorMessage(ex.Message); 84 | } 85 | } 86 | 87 | public void AddJob(gMKVJobInfo argJobInfo) 88 | { 89 | // Check if the same job already exists 90 | foreach (var jobInfo in _JobList) 91 | { 92 | gMKVJob j = jobInfo.Job; 93 | gMKVJob argJ = argJobInfo.Job; 94 | if (j.ExtractionMode == argJ.ExtractionMode 95 | && j.MKVToolnixPath == argJ.MKVToolnixPath 96 | && j.ParametersList.Equals(argJ.ParametersList)) 97 | { 98 | return; 99 | } 100 | } 101 | 102 | _JobList.Add(argJobInfo); 103 | } 104 | 105 | private void SetAbortStatus(bool argStatus) 106 | { 107 | btnAbort.Enabled = argStatus; 108 | btnAbortAll.Enabled = argStatus; 109 | } 110 | 111 | private void SetActionStatus(bool argStatus) 112 | { 113 | btnRemove.Enabled = argStatus; 114 | btnRunAll.Enabled = argStatus; 115 | btnLoadJobs.Enabled = argStatus; 116 | btnSaveJobs.Enabled = argStatus; 117 | } 118 | 119 | void _gMkvExtract_MkvExtractTrackUpdated(string filename, string trackName) 120 | { 121 | this.Invoke(new UpdateTrackLabelDelegate(UpdateTrackLabel), new object[] { filename, trackName }); 122 | Debug.WriteLine(trackName); 123 | } 124 | 125 | void _gMkvExtract_MkvExtractProgressUpdated(int progress) 126 | { 127 | this.Invoke(new UpdateProgressDelegate(UpdateCurrentProgress), new object[] { progress }); 128 | } 129 | 130 | private void frmJobManager_FormClosing(object sender, FormClosingEventArgs e) 131 | { 132 | // To avoid getting disposed 133 | e.Cancel = true; 134 | if (_ExtractRunning) 135 | { 136 | ShowErrorMessage("There is an extraction process running! Please abort before closing!"); 137 | } 138 | else 139 | { 140 | this.Hide(); 141 | } 142 | } 143 | 144 | private void btnRemove_Click(object sender, EventArgs e) 145 | { 146 | try 147 | { 148 | if (grdJobs.Rows.Count > 0) 149 | { 150 | if (grdJobs.SelectedRows.Count > 0) 151 | { 152 | grdJobs.SelectedRows.Cast().ToList().ForEach(r => grdJobs.Rows.Remove(r)); 153 | } 154 | } 155 | } 156 | catch (Exception ex) 157 | { 158 | Debug.WriteLine(ex); 159 | gMKVLogger.Log(ex.ToString()); 160 | ShowErrorMessage(ex.Message); 161 | } 162 | } 163 | 164 | private void RunJobs(List argJobInfoList) 165 | { 166 | _ExceptionBuilder.Length = 0; 167 | foreach (gMKVJobInfo jobInfo in argJobInfoList) 168 | { 169 | try 170 | { 171 | // check for abort 172 | if (_AbortAll) 173 | { 174 | break; 175 | } 176 | // get job from jobInfo 177 | gMKVJob job = jobInfo.Job; 178 | // create the new gMKVExtract object 179 | _gMkvExtract = new gMKVExtract(job.MKVToolnixPath); 180 | _gMkvExtract.MkvExtractProgressUpdated += _gMkvExtract_MkvExtractProgressUpdated; 181 | _gMkvExtract.MkvExtractTrackUpdated += _gMkvExtract_MkvExtractTrackUpdated; 182 | // increate the current job index 183 | _CurrentJob++; 184 | // start the thread 185 | Thread myThread = new Thread(new ParameterizedThreadStart(job.ExtractMethod(_gMkvExtract))); 186 | jobInfo.StartTime = DateTime.Now; 187 | jobInfo.State = JobState.Running; 188 | grdJobs.Refresh(); 189 | myThread.Start(job.ParametersList); 190 | 191 | btnAbort.Enabled = true; 192 | btnAbortAll.Enabled = true; 193 | gTaskbarProgress.SetState(this, gTaskbarProgress.TaskbarStates.Normal); 194 | Application.DoEvents(); 195 | while (myThread.ThreadState != System.Threading.ThreadState.Stopped) 196 | { 197 | Application.DoEvents(); 198 | } 199 | jobInfo.EndTime = DateTime.Now; 200 | // check for exceptions 201 | if (_gMkvExtract.ThreadedException != null) 202 | { 203 | jobInfo.State = JobState.Failed; 204 | grdJobs.Refresh(); 205 | throw _gMkvExtract.ThreadedException; 206 | } 207 | else 208 | { 209 | jobInfo.State = JobState.Completed; 210 | grdJobs.Refresh(); 211 | Application.DoEvents(); 212 | } 213 | } 214 | catch (Exception ex) 215 | { 216 | _ExceptionBuilder.AppendFormat("Exception for job {0}: {1}{2}", jobInfo.ToString(), ex.Message, Environment.NewLine); 217 | } 218 | finally 219 | { 220 | if (_gMkvExtract != null) 221 | { 222 | _gMkvExtract.MkvExtractProgressUpdated -= _gMkvExtract_MkvExtractProgressUpdated; 223 | _gMkvExtract.MkvExtractTrackUpdated -= _gMkvExtract_MkvExtractTrackUpdated; 224 | } 225 | } 226 | } 227 | } 228 | 229 | public void UpdateCurrentProgress(Object val) 230 | { 231 | prgBrCurrent.Value = Convert.ToInt32(val); 232 | prgBrTotal.Value = (_CurrentJob - 1) * 100 + Convert.ToInt32(val); 233 | lblCurrentProgressValue.Text = String.Format("{0}%", Convert.ToInt32(val)); 234 | lblTotalProgressValue.Text = String.Format("{0}%", prgBrTotal.Value / _TotalJobs); 235 | gTaskbarProgress.SetValue(this, Convert.ToUInt64(val), (UInt64)100); 236 | grdJobs.Refresh(); 237 | Application.DoEvents(); 238 | } 239 | 240 | public void UpdateTrackLabel(Object filename, Object val) 241 | { 242 | txtCurrentTrack.Text = String.Format("{0} from {1}", val, Path.GetFileName((string)filename)); 243 | Application.DoEvents(); 244 | } 245 | 246 | private void btnRunAll_Click(object sender, EventArgs e) 247 | { 248 | try 249 | { 250 | if (GetNumberOfJobs(JobState.Ready) == 0) 251 | { 252 | throw new Exception("无可用的任务以运行!"); 253 | } 254 | List jobList = new List(); 255 | foreach (DataGridViewRow item in grdJobs.Rows) 256 | { 257 | gMKVJobInfo jobInfo = (gMKVJobInfo)item.DataBoundItem; 258 | if (jobInfo.State == JobState.Ready) 259 | { 260 | jobInfo.State = JobState.Pending; 261 | jobList.Add(jobInfo); 262 | } 263 | } 264 | grdJobs.Refresh(); 265 | PrepareForRunJobs(jobList); 266 | } 267 | catch (Exception ex) 268 | { 269 | Debug.WriteLine(ex); 270 | gMKVLogger.Log(ex.ToString()); 271 | ShowErrorMessage(ex.Message); 272 | } 273 | } 274 | 275 | private void PrepareForRunJobs(List argJobInfoList) 276 | { 277 | bool exceptionOccured = false; 278 | try 279 | { 280 | SetActionStatus(false); 281 | SetAbortStatus(true); 282 | _ExtractRunning = true; 283 | _MainForm.SetTableLayoutMainStatus(false); 284 | _TotalJobs = argJobInfoList.Count; 285 | _CurrentJob = 0; 286 | prgBrTotal.Maximum = _TotalJobs * 100; 287 | RunJobs(new List(argJobInfoList)); 288 | // Check exception builder for exceptions 289 | if (_ExceptionBuilder.Length > 0) 290 | { 291 | // reset the status from pending to ready 292 | foreach (DataGridViewRow item in grdJobs.Rows) 293 | { 294 | gMKVJobInfo jobInfo = (gMKVJobInfo)item.DataBoundItem; 295 | if (jobInfo.State == JobState.Pending) 296 | { 297 | jobInfo.State = JobState.Ready; 298 | } 299 | } 300 | throw new Exception(_ExceptionBuilder.ToString()); 301 | } 302 | UpdateCurrentProgress(100); 303 | if (chkShowPopup.Checked) 304 | { 305 | ShowSuccessMessage("The jobs completed successfully!"); 306 | } 307 | else 308 | { 309 | SystemSounds.Asterisk.Play(); 310 | } 311 | } 312 | catch (Exception ex) 313 | { 314 | Debug.WriteLine(ex); 315 | gMKVLogger.Log(ex.ToString()); 316 | ShowErrorMessage(ex.Message); 317 | } 318 | finally 319 | { 320 | if (chkShowPopup.Checked || exceptionOccured) 321 | { 322 | UpdateCurrentProgress(0); 323 | prgBrTotal.Value = 0; 324 | lblCurrentProgressValue.Text = ""; 325 | lblTotalProgressValue.Text = ""; 326 | } 327 | else 328 | { 329 | lblCurrentProgressValue.Text = ""; 330 | lblTotalProgressValue.Text = ""; 331 | txtCurrentTrack.Text = "导出完成!"; 332 | } 333 | gTaskbarProgress.SetState(this, gTaskbarProgress.TaskbarStates.NoProgress); 334 | gTaskbarProgress.SetOverlayIcon(this, null, null); 335 | _ExtractRunning = false; 336 | _AbortAll = false; 337 | grdJobs.Refresh(); 338 | SetActionStatus(true); 339 | SetAbortStatus(false); 340 | _MainForm.SetTableLayoutMainStatus(true); 341 | } 342 | } 343 | 344 | private void btnAbort_Click(object sender, EventArgs e) 345 | { 346 | try 347 | { 348 | if (_gMkvExtract != null) 349 | { 350 | _gMkvExtract.Abort = true; 351 | } 352 | } 353 | catch (Exception ex) 354 | { 355 | Debug.WriteLine(ex); 356 | gMKVLogger.Log(ex.ToString()); 357 | ShowErrorMessage(ex.Message); 358 | } 359 | } 360 | 361 | private void btnAbortAll_Click(object sender, EventArgs e) 362 | { 363 | try 364 | { 365 | _AbortAll = true; 366 | if (_gMkvExtract != null) 367 | { 368 | _gMkvExtract.Abort = true; 369 | _gMkvExtract.AbortAll = true; 370 | } 371 | } 372 | catch (Exception ex) 373 | { 374 | Debug.WriteLine(ex); 375 | gMKVLogger.Log(ex.ToString()); 376 | ShowErrorMessage(ex.Message); 377 | } 378 | } 379 | 380 | private Int32 GetNumberOfJobs(JobState argState) 381 | { 382 | Int32 counter = 0; 383 | foreach (DataGridViewRow drJobInfo in grdJobs.Rows) 384 | { 385 | gMKVJobInfo jobInfo = (gMKVJobInfo)drJobInfo.DataBoundItem; 386 | if (jobInfo.State == argState) 387 | { 388 | counter++; 389 | } 390 | } 391 | return counter; 392 | } 393 | 394 | private void grdJobs_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) 395 | { 396 | try 397 | { 398 | // Check if the row clicked is selected 399 | if (grdJobs.Rows[e.RowIndex].Selected) 400 | { 401 | gMKVJobInfo jobInfo = (gMKVJobInfo)grdJobs.Rows[e.RowIndex].DataBoundItem; 402 | if (jobInfo.State == JobState.Failed || jobInfo.State == JobState.Completed) 403 | { 404 | jobInfo.Reset(); 405 | grdJobs.Refresh(); 406 | } 407 | } 408 | } 409 | catch (Exception ex) 410 | { 411 | Debug.WriteLine(ex); 412 | } 413 | } 414 | 415 | private void btnSaveJobs_Click(object sender, EventArgs e) 416 | { 417 | try 418 | { 419 | // ask for path 420 | SaveFileDialog sfd = new SaveFileDialog(); 421 | sfd.Title = "选择任务文件 ..."; 422 | sfd.InitialDirectory = GetCurrentDirectory(); 423 | sfd.Filter = "*.xml|*.xml"; 424 | if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) 425 | { 426 | using (System.IO.StreamWriter sw = new System.IO.StreamWriter(sfd.FileName)) 427 | { 428 | System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(List)); 429 | 430 | List jobList = new List(); 431 | foreach (DataGridViewRow item in grdJobs.Rows) 432 | { 433 | jobList.Add((gMKVJobInfo)item.DataBoundItem); 434 | } 435 | 436 | x.Serialize(sw, jobList); 437 | } 438 | ShowSuccessMessage("The jobs were save successfully!"); 439 | } 440 | } 441 | catch (Exception ex) 442 | { 443 | Debug.WriteLine(ex); 444 | gMKVLogger.Log(ex.ToString()); 445 | ShowErrorMessage(ex.Message); 446 | } 447 | } 448 | 449 | private void btnLoadJobs_Click(object sender, EventArgs e) 450 | { 451 | try 452 | { 453 | // Ask for path 454 | OpenFileDialog ofd = new OpenFileDialog(); 455 | ofd.InitialDirectory = GetCurrentDirectory(); 456 | ofd.Title = "Select jobs file..."; 457 | ofd.Filter = "*.xml|*.xml"; 458 | if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) 459 | { 460 | List jobList = null; 461 | using (System.IO.StreamReader sr = new System.IO.StreamReader(ofd.FileName)) 462 | { 463 | System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(List)); 464 | 465 | jobList = (List)x.Deserialize(sr); 466 | } 467 | SetJobsList(new BindingList(jobList)); 468 | ShowSuccessMessage("The jobs were loaded successfully!"); 469 | } 470 | } 471 | catch (Exception ex) 472 | { 473 | Debug.WriteLine(ex); 474 | gMKVLogger.Log(ex.ToString()); 475 | ShowErrorMessage(ex.Message); 476 | } 477 | } 478 | 479 | private void contextMenuStrip_Opening(object sender, CancelEventArgs e) 480 | { 481 | SetContextMenuText(); 482 | } 483 | 484 | private void SetContextMenuText() 485 | { 486 | if (_ExtractRunning) 487 | { 488 | changeToReadyStatusToolStripMenuItem.Enabled = false; 489 | } 490 | else if (grdJobs.SelectedRows.Count == 0) 491 | { 492 | changeToReadyStatusToolStripMenuItem.Enabled = false; 493 | } 494 | else 495 | { 496 | foreach (DataGridViewRow row in grdJobs.SelectedRows) 497 | { 498 | if(((gMKVJobInfo)row.DataBoundItem).State != JobState.Ready) 499 | { 500 | changeToReadyStatusToolStripMenuItem.Enabled = true; 501 | break; 502 | } 503 | } 504 | } 505 | } 506 | 507 | private void changeToReadyStatusToolStripMenuItem_Click(object sender, EventArgs e) 508 | { 509 | foreach (DataGridViewRow row in grdJobs.SelectedRows) 510 | { 511 | if (((gMKVJobInfo)row.DataBoundItem).State != JobState.Ready) 512 | { 513 | ((gMKVJobInfo)row.DataBoundItem).Reset(); 514 | } 515 | } 516 | grdJobs.Refresh(); 517 | } 518 | 519 | private void deselectAllToolStripMenuItem_Click(object sender, EventArgs e) 520 | { 521 | grdJobs.ClearSelection(); 522 | } 523 | 524 | private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) 525 | { 526 | grdJobs.SelectAll(); 527 | } 528 | 529 | private void chkShowPopup_CheckedChanged(object sender, EventArgs e) 530 | { 531 | if (!_FromConstructor) 532 | { 533 | _Settings.ShowPopupInJobManager = chkShowPopup.Checked; 534 | _Settings.Save(); 535 | } 536 | } 537 | 538 | private void grdJobs_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) 539 | { 540 | try 541 | { 542 | grpJobs.Text = String.Format("任务 ({0})", grdJobs.Rows.Count); 543 | } 544 | catch (Exception ex) 545 | { 546 | Debug.WriteLine(ex); 547 | gMKVLogger.Log(ex.ToString()); 548 | ShowErrorMessage(ex.Message); 549 | } 550 | } 551 | } 552 | } 553 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Forms/frmJobManager.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Forms/frmLog.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace gMKVToolNix 2 | { 3 | partial class frmLog 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.tlpMain = new gMKVToolNix.gTableLayoutPanel(); 32 | this.grpLog = new gMKVToolNix.gGroupBox(); 33 | this.txtLog = new gMKVToolNix.gTextBox(); 34 | this.grpActions = new gMKVToolNix.gGroupBox(); 35 | this.btnSave = new System.Windows.Forms.Button(); 36 | this.btnClear = new System.Windows.Forms.Button(); 37 | this.btnRefresh = new System.Windows.Forms.Button(); 38 | this.btnCopy = new System.Windows.Forms.Button(); 39 | this.btnClose = new System.Windows.Forms.Button(); 40 | this.tlpMain.SuspendLayout(); 41 | this.grpLog.SuspendLayout(); 42 | this.grpActions.SuspendLayout(); 43 | this.SuspendLayout(); 44 | // 45 | // tlpMain 46 | // 47 | this.tlpMain.ColumnCount = 1; 48 | this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); 49 | this.tlpMain.Controls.Add(this.grpLog, 0, 0); 50 | this.tlpMain.Controls.Add(this.grpActions, 0, 1); 51 | this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill; 52 | this.tlpMain.Location = new System.Drawing.Point(0, 0); 53 | this.tlpMain.Name = "tlpMain"; 54 | this.tlpMain.RowCount = 2; 55 | this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); 56 | this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 60F)); 57 | this.tlpMain.Size = new System.Drawing.Size(604, 501); 58 | this.tlpMain.TabIndex = 0; 59 | // 60 | // grpLog 61 | // 62 | this.grpLog.Controls.Add(this.txtLog); 63 | this.grpLog.Dock = System.Windows.Forms.DockStyle.Fill; 64 | this.grpLog.Location = new System.Drawing.Point(3, 3); 65 | this.grpLog.Name = "grpLog"; 66 | this.grpLog.Size = new System.Drawing.Size(598, 435); 67 | this.grpLog.TabIndex = 0; 68 | this.grpLog.TabStop = false; 69 | this.grpLog.Text = "Log"; 70 | // 71 | // txtLog 72 | // 73 | this.txtLog.BackColor = System.Drawing.SystemColors.Window; 74 | this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill; 75 | this.txtLog.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(161))); 76 | this.txtLog.Location = new System.Drawing.Point(3, 19); 77 | this.txtLog.Multiline = true; 78 | this.txtLog.Name = "txtLog"; 79 | this.txtLog.ReadOnly = true; 80 | this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Both; 81 | this.txtLog.Size = new System.Drawing.Size(592, 413); 82 | this.txtLog.TabIndex = 0; 83 | this.txtLog.WordWrap = false; 84 | this.txtLog.TextChanged += new System.EventHandler(this.txtLog_TextChanged); 85 | // 86 | // grpActions 87 | // 88 | this.grpActions.Controls.Add(this.btnSave); 89 | this.grpActions.Controls.Add(this.btnClear); 90 | this.grpActions.Controls.Add(this.btnRefresh); 91 | this.grpActions.Controls.Add(this.btnCopy); 92 | this.grpActions.Controls.Add(this.btnClose); 93 | this.grpActions.Dock = System.Windows.Forms.DockStyle.Fill; 94 | this.grpActions.Location = new System.Drawing.Point(3, 444); 95 | this.grpActions.Name = "grpActions"; 96 | this.grpActions.Size = new System.Drawing.Size(598, 54); 97 | this.grpActions.TabIndex = 1; 98 | this.grpActions.TabStop = false; 99 | this.grpActions.Text = "操作"; 100 | // 101 | // btnSave 102 | // 103 | this.btnSave.Location = new System.Drawing.Point(105, 17); 104 | this.btnSave.Name = "btnSave"; 105 | this.btnSave.Size = new System.Drawing.Size(95, 30); 106 | this.btnSave.TabIndex = 4; 107 | this.btnSave.Text = "保存 ..."; 108 | this.btnSave.UseVisualStyleBackColor = true; 109 | this.btnSave.Click += new System.EventHandler(this.btnSave_Click); 110 | // 111 | // btnClear 112 | // 113 | this.btnClear.Location = new System.Drawing.Point(6, 17); 114 | this.btnClear.Name = "btnClear"; 115 | this.btnClear.Size = new System.Drawing.Size(95, 30); 116 | this.btnClear.TabIndex = 3; 117 | this.btnClear.Text = "清空日志"; 118 | this.btnClear.UseVisualStyleBackColor = true; 119 | this.btnClear.Click += new System.EventHandler(this.btnClear_Click); 120 | // 121 | // btnRefresh 122 | // 123 | this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 124 | this.btnRefresh.Location = new System.Drawing.Point(300, 17); 125 | this.btnRefresh.Name = "btnRefresh"; 126 | this.btnRefresh.Size = new System.Drawing.Size(95, 30); 127 | this.btnRefresh.TabIndex = 2; 128 | this.btnRefresh.Text = "刷新"; 129 | this.btnRefresh.UseVisualStyleBackColor = true; 130 | this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); 131 | // 132 | // btnCopy 133 | // 134 | this.btnCopy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 135 | this.btnCopy.Location = new System.Drawing.Point(399, 17); 136 | this.btnCopy.Name = "btnCopy"; 137 | this.btnCopy.Size = new System.Drawing.Size(95, 30); 138 | this.btnCopy.TabIndex = 1; 139 | this.btnCopy.Text = "复制已选"; 140 | this.btnCopy.UseVisualStyleBackColor = true; 141 | this.btnCopy.Click += new System.EventHandler(this.btnCopy_Click); 142 | // 143 | // btnClose 144 | // 145 | this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 146 | this.btnClose.Location = new System.Drawing.Point(498, 17); 147 | this.btnClose.Name = "btnClose"; 148 | this.btnClose.Size = new System.Drawing.Size(95, 30); 149 | this.btnClose.TabIndex = 0; 150 | this.btnClose.Text = "关闭"; 151 | this.btnClose.UseVisualStyleBackColor = true; 152 | this.btnClose.Click += new System.EventHandler(this.btnClose_Click); 153 | // 154 | // frmLog 155 | // 156 | this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); 157 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; 158 | this.ClientSize = new System.Drawing.Size(604, 501); 159 | this.Controls.Add(this.tlpMain); 160 | this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(161))); 161 | this.MinimumSize = new System.Drawing.Size(350, 350); 162 | this.Name = "frmLog"; 163 | this.Text = "frmLog"; 164 | this.Activated += new System.EventHandler(this.frmLog_Activated); 165 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmLog_FormClosing); 166 | this.tlpMain.ResumeLayout(false); 167 | this.grpLog.ResumeLayout(false); 168 | this.grpLog.PerformLayout(); 169 | this.grpActions.ResumeLayout(false); 170 | this.ResumeLayout(false); 171 | 172 | } 173 | 174 | #endregion 175 | 176 | private gTableLayoutPanel tlpMain; 177 | private gGroupBox grpLog; 178 | private gTextBox txtLog; 179 | private gGroupBox grpActions; 180 | private System.Windows.Forms.Button btnCopy; 181 | private System.Windows.Forms.Button btnClose; 182 | private System.Windows.Forms.Button btnRefresh; 183 | private System.Windows.Forms.Button btnClear; 184 | private System.Windows.Forms.Button btnSave; 185 | } 186 | } -------------------------------------------------------------------------------- /gMKVExtractGUI/Forms/frmLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Reflection; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using gMKVToolNix; 10 | using System.Diagnostics; 11 | using System.IO; 12 | 13 | namespace gMKVToolNix 14 | { 15 | public partial class frmLog : gForm 16 | { 17 | public frmLog() 18 | { 19 | InitializeComponent(); 20 | InitForm(); 21 | 22 | // Initialize the DPI aware scaling 23 | InitDPI(); 24 | } 25 | 26 | private void InitForm() 27 | { 28 | Icon = Icon.ExtractAssociatedIcon(GetExecutingAssemblyLocation()); 29 | Text = String.Format("gMKVExtractGUI_chs v{0} -- 日志", GetCurrentVersion()); 30 | } 31 | 32 | private void frmLog_Activated(object sender, EventArgs e) 33 | { 34 | txtLog.Text = gMKVLogger.LogText; 35 | } 36 | 37 | private void txtLog_TextChanged(object sender, EventArgs e) 38 | { 39 | txtLog.Select(txtLog.TextLength + 1, 0); 40 | txtLog.ScrollToCaret(); 41 | grpLog.Text = String.Format("日志 ({0})", txtLog.Lines.LongLength); 42 | } 43 | 44 | private void btnClose_Click(object sender, EventArgs e) 45 | { 46 | try 47 | { 48 | this.Close(); 49 | } 50 | catch (Exception ex) 51 | { 52 | Debug.WriteLine(ex); 53 | gMKVLogger.Log(ex.ToString()); 54 | ShowErrorMessage(ex.Message); 55 | } 56 | } 57 | 58 | private void btnCopy_Click(object sender, EventArgs e) 59 | { 60 | try 61 | { 62 | if (!string.IsNullOrWhiteSpace(txtLog.SelectedText)) 63 | { 64 | Clipboard.SetData(DataFormats.UnicodeText, txtLog.SelectedText); 65 | } 66 | } 67 | catch (Exception ex) 68 | { 69 | Debug.WriteLine(ex); 70 | gMKVLogger.Log(ex.ToString()); 71 | ShowErrorMessage(ex.Message); 72 | } 73 | } 74 | 75 | private void btnRefresh_Click(object sender, EventArgs e) 76 | { 77 | try 78 | { 79 | txtLog.Text = gMKVLogger.LogText; 80 | } 81 | catch (Exception ex) 82 | { 83 | Debug.WriteLine(ex); 84 | gMKVLogger.Log(ex.ToString()); 85 | ShowErrorMessage(ex.Message); 86 | } 87 | } 88 | 89 | private void frmLog_FormClosing(object sender, FormClosingEventArgs e) 90 | { 91 | // To avoid getting disposed 92 | e.Cancel = true; 93 | this.Hide(); 94 | } 95 | 96 | private void btnClear_Click(object sender, EventArgs e) 97 | { 98 | try 99 | { 100 | if (ShowQuestion("Are you sure you want to clear the log?", "Are you sure?") == DialogResult.Yes) 101 | { 102 | gMKVLogger.Clear(); 103 | } 104 | } 105 | catch (Exception ex) 106 | { 107 | Debug.WriteLine(ex); 108 | gMKVLogger.Log(ex.ToString()); 109 | ShowErrorMessage(ex.Message); 110 | } 111 | } 112 | 113 | private void btnSave_Click(object sender, EventArgs e) 114 | { 115 | try 116 | { 117 | SaveFileDialog sfd = new SaveFileDialog(); 118 | sfd.Title = "Select filename for log..."; 119 | sfd.CheckFileExists = true; 120 | sfd.DefaultExt = "txt"; 121 | sfd.Filter = "*.txt|*.txt"; 122 | sfd.FileName = String.Format("[{0}][{1}][gMKVExtractGUI_v{2}].txt", 123 | DateTime.Now.ToString("yyyy-MM-dd"), 124 | DateTime.Now.ToString("HH-mm-ss"), 125 | Assembly.GetExecutingAssembly().GetName().Version); 126 | if(sfd.ShowDialog() == DialogResult.Yes) 127 | { 128 | using(StreamWriter sw = new StreamWriter(sfd.FileName, false, Encoding.UTF8)) 129 | { 130 | sw.Write(gMKVLogger.LogText); 131 | } 132 | ShowSuccessMessage(String.Format("The log was saved to {0}!", sfd.FileName)); 133 | } 134 | } 135 | catch (Exception ex) 136 | { 137 | Debug.WriteLine(ex); 138 | gMKVLogger.Log(ex.ToString()); 139 | ShowErrorMessage(ex.Message); 140 | } 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Forms/frmLog.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Forms/frmMain.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 133, 17 122 | 123 | 124 | 17, 17 125 | 126 | 127 | 55 128 | 129 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Forms/frmMain2.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 282, 17 125 | 126 | 127 | 133, 17 128 | 129 | 130 | 45 131 | 132 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Forms/frmOptions.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Images/gMkvExtractGuiIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hooke007/gMKVExtractGUI_chs/138cb4cfda7783e805afbc2ce7b79e6c91c9d521/gMKVExtractGUI/Images/gMkvExtractGuiIcon.ico -------------------------------------------------------------------------------- /gMKVExtractGUI/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Reflection; 4 | using System.Windows.Forms; 5 | using gMKVToolNix.Forms; 6 | 7 | namespace gMKVToolNix 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// Returns if the running Platform is Linux Or MacOSX 13 | /// 14 | public static bool IsOnLinux 15 | { 16 | get 17 | { 18 | PlatformID myPlatform = Environment.OSVersion.Platform; 19 | // 128 is Mono 1.x specific value for Linux systems, so it's there to provide compatibility 20 | return (myPlatform == PlatformID.Unix) || (myPlatform == PlatformID.MacOSX) || ((int)myPlatform == 128); 21 | } 22 | } 23 | 24 | /// 25 | /// The main entry point for the application. 26 | /// 27 | [STAThread] 28 | static void Main(string[] args) 29 | { 30 | Application.EnableVisualStyles(); 31 | Application.SetCompatibleTextRenderingDefault(false); 32 | 33 | if (!File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "gMKVToolNix.dll"))) 34 | { 35 | MessageBox.Show("The gMKVToolNix.dll was not found! Please download and reinstall gMKVExtractGUI!", "An error has occured!", MessageBoxButtons.OK, MessageBoxIcon.Error); 36 | 37 | Environment.Exit(1); 38 | } 39 | 40 | // If on Linux, set the enironmnet variables for locale to C (default locale) 41 | // Actually set to en_US.UTF-8 locale in order to support UTF-8 filenames in Linux 42 | //// After clearing things with Mosu, this is not necessary anymore, since --ui-language is more than enough! 43 | //if (IsOnLinux) 44 | //{ 45 | // Environment.SetEnvironmentVariable("LC_ALL", "en_US.UTF-8", EnvironmentVariableTarget.Process); 46 | // Environment.SetEnvironmentVariable("LANG", "en_US.UTF-8", EnvironmentVariableTarget.Process); 47 | // Environment.SetEnvironmentVariable("LC_MESSAGES", "en_US.UTF-8", EnvironmentVariableTarget.Process); 48 | //} 49 | //Application.Run(new frmMain()); 50 | 51 | Application.Run(new frmMain2()); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("gMKVExtractGUI_chs")] 9 | [assembly: AssemblyDescription("gMKVExtractGUI sc edition")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("hooke007")] 12 | [assembly: AssemblyProduct("gMKVExtractGUI_chs")] 13 | [assembly: AssemblyCopyright("Copyright © 2021-2022")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3e794556-9870-4902-96c9-85b8a360a2ab")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.6.2.0")] 36 | [assembly: AssemblyFileVersion("2.6.2.0")] 37 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace gMKVToolNix.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("gMKVToolNix.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace gMKVToolNix.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /gMKVExtractGUI/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /gMKVExtractGUI/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /gMKVExtractGUI/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 52 | 53 | 54 | 55 | true/PM 56 | 57 | 58 | 59 | 67 | 68 | 69 | 70 | PerMonitorV2, PerMonitor 71 | 72 | 73 | 74 | 75 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /gMKVExtractGUI/gMKVExtractGUI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {20EBEFF3-C838-4239-A236-EC055BF51398} 8 | WinExe 9 | Properties 10 | gMKVToolNix 11 | gMKVExtractGUI 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | Images\gMkvExtractGuiIcon.ico 37 | 38 | 39 | gMKVToolNix.Program 40 | 41 | 42 | app.manifest 43 | 44 | 45 | true 46 | bin\x86\Debug\ 47 | DEBUG;TRACE 48 | full 49 | x86 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | 53 | 54 | bin\x86\Release\ 55 | TRACE 56 | true 57 | pdbonly 58 | x86 59 | prompt 60 | MinimumRecommendedRules.ruleset 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | Component 75 | 76 | 77 | Component 78 | 79 | 80 | Component 81 | 82 | 83 | Component 84 | 85 | 86 | Component 87 | 88 | 89 | Component 90 | 91 | 92 | Component 93 | 94 | 95 | Form 96 | 97 | 98 | frmJobManager.cs 99 | 100 | 101 | Form 102 | 103 | 104 | frmLog.cs 105 | 106 | 107 | Form 108 | 109 | 110 | frmMain.cs 111 | 112 | 113 | Component 114 | 115 | 116 | Form 117 | 118 | 119 | Form 120 | 121 | 122 | frmMain2.cs 123 | 124 | 125 | Form 126 | 127 | 128 | frmOptions.cs 129 | 130 | 131 | 132 | 133 | 134 | Component 135 | 136 | 137 | 138 | 139 | gForm.cs 140 | 141 | 142 | frmJobManager.cs 143 | 144 | 145 | frmLog.cs 146 | 147 | 148 | frmMain.cs 149 | 150 | 151 | frmMain2.cs 152 | 153 | 154 | frmOptions.cs 155 | 156 | 157 | ResXFileCodeGenerator 158 | Resources.Designer.cs 159 | Designer 160 | 161 | 162 | True 163 | Resources.resx 164 | True 165 | 166 | 167 | 168 | 169 | SettingsSingleFileGenerator 170 | Settings.Designer.cs 171 | 172 | 173 | True 174 | Settings.settings 175 | True 176 | 177 | 178 | 179 | 180 | {82fc8fa8-50c0-44fa-8801-80050c0ed89f} 181 | gMKVToolNix 182 | 183 | 184 | 185 | 186 | 187 | 188 | 195 | -------------------------------------------------------------------------------- /gMKVExtractGUI/gMKVExtractGUI.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ShowAllFiles 5 | 6 | -------------------------------------------------------------------------------- /gMKVToolNix/Chapters/matroskachapters.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System.Xml.Serialization; 12 | 13 | // 14 | // This source code was auto-generated by xsd, Version=4.6.81.0. 15 | // 16 | 17 | 18 | /// 19 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.81.0")] 20 | [System.SerializableAttribute()] 21 | [System.Diagnostics.DebuggerStepThroughAttribute()] 22 | [System.ComponentModel.DesignerCategoryAttribute("code")] 23 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] 24 | [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)] 25 | public partial class Chapters { 26 | 27 | private EditionEntry[] editionEntryField; 28 | 29 | /// 30 | [System.Xml.Serialization.XmlElementAttribute("EditionEntry")] 31 | public EditionEntry[] EditionEntry { 32 | get { 33 | return this.editionEntryField; 34 | } 35 | set { 36 | this.editionEntryField = value; 37 | } 38 | } 39 | } 40 | 41 | /// 42 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.81.0")] 43 | [System.SerializableAttribute()] 44 | [System.Diagnostics.DebuggerStepThroughAttribute()] 45 | [System.ComponentModel.DesignerCategoryAttribute("code")] 46 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] 47 | [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)] 48 | public partial class EditionEntry { 49 | 50 | private string editionUIDField; 51 | 52 | private string editionFlagHiddenField; 53 | 54 | private string editionManagedField; 55 | 56 | private string editionFlagDefaultField; 57 | 58 | private ChapterAtom[] chapterAtomField; 59 | 60 | /// 61 | public string EditionUID { 62 | get { 63 | return this.editionUIDField; 64 | } 65 | set { 66 | this.editionUIDField = value; 67 | } 68 | } 69 | 70 | /// 71 | public string EditionFlagHidden { 72 | get { 73 | return this.editionFlagHiddenField; 74 | } 75 | set { 76 | this.editionFlagHiddenField = value; 77 | } 78 | } 79 | 80 | /// 81 | public string EditionManaged { 82 | get { 83 | return this.editionManagedField; 84 | } 85 | set { 86 | this.editionManagedField = value; 87 | } 88 | } 89 | 90 | /// 91 | public string EditionFlagDefault { 92 | get { 93 | return this.editionFlagDefaultField; 94 | } 95 | set { 96 | this.editionFlagDefaultField = value; 97 | } 98 | } 99 | 100 | /// 101 | [System.Xml.Serialization.XmlElementAttribute("ChapterAtom")] 102 | public ChapterAtom[] ChapterAtom { 103 | get { 104 | return this.chapterAtomField; 105 | } 106 | set { 107 | this.chapterAtomField = value; 108 | } 109 | } 110 | } 111 | 112 | /// 113 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.81.0")] 114 | [System.SerializableAttribute()] 115 | [System.Diagnostics.DebuggerStepThroughAttribute()] 116 | [System.ComponentModel.DesignerCategoryAttribute("code")] 117 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] 118 | [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)] 119 | public partial class ChapterAtom { 120 | 121 | private string chapterTimeStartField; 122 | 123 | private string chapterTimeEndField; 124 | 125 | private string chapterUIDField; 126 | 127 | private string chapterSegmentUIDField; 128 | 129 | private string chapterSegmentEditionUIDField; 130 | 131 | private string chapterPhysicalEquivField; 132 | 133 | private ChapterTrack chapterTrackField; 134 | 135 | private string chapterFlagHiddenField; 136 | 137 | private string chapterFlagEnabledField; 138 | 139 | private ChapterDisplay[] chapterDisplayField; 140 | 141 | private ChapterProcess[] chapterProcessField; 142 | 143 | private ChapterAtom[] chapterAtom1Field; 144 | 145 | /// 146 | public string ChapterTimeStart { 147 | get { 148 | return this.chapterTimeStartField; 149 | } 150 | set { 151 | this.chapterTimeStartField = value; 152 | } 153 | } 154 | 155 | /// 156 | public string ChapterTimeEnd { 157 | get { 158 | return this.chapterTimeEndField; 159 | } 160 | set { 161 | this.chapterTimeEndField = value; 162 | } 163 | } 164 | 165 | /// 166 | public string ChapterUID { 167 | get { 168 | return this.chapterUIDField; 169 | } 170 | set { 171 | this.chapterUIDField = value; 172 | } 173 | } 174 | 175 | /// 176 | public string ChapterSegmentUID { 177 | get { 178 | return this.chapterSegmentUIDField; 179 | } 180 | set { 181 | this.chapterSegmentUIDField = value; 182 | } 183 | } 184 | 185 | /// 186 | public string ChapterSegmentEditionUID { 187 | get { 188 | return this.chapterSegmentEditionUIDField; 189 | } 190 | set { 191 | this.chapterSegmentEditionUIDField = value; 192 | } 193 | } 194 | 195 | /// 196 | public string ChapterPhysicalEquiv { 197 | get { 198 | return this.chapterPhysicalEquivField; 199 | } 200 | set { 201 | this.chapterPhysicalEquivField = value; 202 | } 203 | } 204 | 205 | /// 206 | public ChapterTrack ChapterTrack { 207 | get { 208 | return this.chapterTrackField; 209 | } 210 | set { 211 | this.chapterTrackField = value; 212 | } 213 | } 214 | 215 | /// 216 | public string ChapterFlagHidden { 217 | get { 218 | return this.chapterFlagHiddenField; 219 | } 220 | set { 221 | this.chapterFlagHiddenField = value; 222 | } 223 | } 224 | 225 | /// 226 | public string ChapterFlagEnabled { 227 | get { 228 | return this.chapterFlagEnabledField; 229 | } 230 | set { 231 | this.chapterFlagEnabledField = value; 232 | } 233 | } 234 | 235 | /// 236 | [System.Xml.Serialization.XmlElementAttribute("ChapterDisplay")] 237 | public ChapterDisplay[] ChapterDisplay { 238 | get { 239 | return this.chapterDisplayField; 240 | } 241 | set { 242 | this.chapterDisplayField = value; 243 | } 244 | } 245 | 246 | /// 247 | [System.Xml.Serialization.XmlElementAttribute("ChapterProcess")] 248 | public ChapterProcess[] ChapterProcess { 249 | get { 250 | return this.chapterProcessField; 251 | } 252 | set { 253 | this.chapterProcessField = value; 254 | } 255 | } 256 | 257 | /// 258 | [System.Xml.Serialization.XmlElementAttribute("ChapterAtom")] 259 | public ChapterAtom[] ChapterAtom1 { 260 | get { 261 | return this.chapterAtom1Field; 262 | } 263 | set { 264 | this.chapterAtom1Field = value; 265 | } 266 | } 267 | } 268 | 269 | /// 270 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.81.0")] 271 | [System.SerializableAttribute()] 272 | [System.Diagnostics.DebuggerStepThroughAttribute()] 273 | [System.ComponentModel.DesignerCategoryAttribute("code")] 274 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] 275 | [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)] 276 | public partial class ChapterTrack { 277 | 278 | private string chapterTrackNumberField; 279 | 280 | /// 281 | public string ChapterTrackNumber { 282 | get { 283 | return this.chapterTrackNumberField; 284 | } 285 | set { 286 | this.chapterTrackNumberField = value; 287 | } 288 | } 289 | } 290 | 291 | /// 292 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.81.0")] 293 | [System.SerializableAttribute()] 294 | [System.Diagnostics.DebuggerStepThroughAttribute()] 295 | [System.ComponentModel.DesignerCategoryAttribute("code")] 296 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] 297 | [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)] 298 | public partial class ChapterDisplay { 299 | 300 | private string chapterStringField; 301 | 302 | private string[] chapterLanguageField; 303 | 304 | private string[] chapterCountryField; 305 | 306 | /// 307 | public string ChapterString { 308 | get { 309 | return this.chapterStringField; 310 | } 311 | set { 312 | this.chapterStringField = value; 313 | } 314 | } 315 | 316 | /// 317 | [System.Xml.Serialization.XmlElementAttribute("ChapterLanguage")] 318 | public string[] ChapterLanguage { 319 | get { 320 | return this.chapterLanguageField; 321 | } 322 | set { 323 | this.chapterLanguageField = value; 324 | } 325 | } 326 | 327 | /// 328 | [System.Xml.Serialization.XmlElementAttribute("ChapterCountry")] 329 | public string[] ChapterCountry { 330 | get { 331 | return this.chapterCountryField; 332 | } 333 | set { 334 | this.chapterCountryField = value; 335 | } 336 | } 337 | } 338 | 339 | /// 340 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.81.0")] 341 | [System.SerializableAttribute()] 342 | [System.Diagnostics.DebuggerStepThroughAttribute()] 343 | [System.ComponentModel.DesignerCategoryAttribute("code")] 344 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] 345 | [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)] 346 | public partial class ChapterProcess { 347 | 348 | private string chapterProcessCodecIDField; 349 | 350 | private string chapterProcessPrivateField; 351 | 352 | private ChapterProcessCommand[] chapterProcessCommandField; 353 | 354 | /// 355 | public string ChapterProcessCodecID { 356 | get { 357 | return this.chapterProcessCodecIDField; 358 | } 359 | set { 360 | this.chapterProcessCodecIDField = value; 361 | } 362 | } 363 | 364 | /// 365 | public string ChapterProcessPrivate { 366 | get { 367 | return this.chapterProcessPrivateField; 368 | } 369 | set { 370 | this.chapterProcessPrivateField = value; 371 | } 372 | } 373 | 374 | /// 375 | [System.Xml.Serialization.XmlElementAttribute("ChapterProcessCommand")] 376 | public ChapterProcessCommand[] ChapterProcessCommand { 377 | get { 378 | return this.chapterProcessCommandField; 379 | } 380 | set { 381 | this.chapterProcessCommandField = value; 382 | } 383 | } 384 | } 385 | 386 | /// 387 | [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.81.0")] 388 | [System.SerializableAttribute()] 389 | [System.Diagnostics.DebuggerStepThroughAttribute()] 390 | [System.ComponentModel.DesignerCategoryAttribute("code")] 391 | [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] 392 | [System.Xml.Serialization.XmlRootAttribute(IsNullable=false)] 393 | public partial class ChapterProcessCommand { 394 | 395 | private string chapterProcessTimeField; 396 | 397 | private string chapterProcessDataField; 398 | 399 | /// 400 | public string ChapterProcessTime { 401 | get { 402 | return this.chapterProcessTimeField; 403 | } 404 | set { 405 | this.chapterProcessTimeField = value; 406 | } 407 | } 408 | 409 | /// 410 | public string ChapterProcessData { 411 | get { 412 | return this.chapterProcessDataField; 413 | } 414 | set { 415 | this.chapterProcessDataField = value; 416 | } 417 | } 418 | } 419 | -------------------------------------------------------------------------------- /gMKVToolNix/Chapters/matroskachapters.dtd: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 27 | 28 | 29 | 33 | 34 | 38 | 39 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /gMKVToolNix/Chapters/matroskachapters.xsd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /gMKVToolNix/CueSheet/Cue.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace gMKVToolNix.CueSheet 4 | { 5 | public class Cue 6 | { 7 | /* 8 | REM GENRE "Electronica" 9 | REM DATE "1998" 10 | PERFORMER "Faithless" 11 | TITLE "Live in Berlin" 12 | FILE "Faithless - Live in Berlin.mp3" MP3 13 | */ 14 | 15 | public string Genre { get; set; } 16 | public string Date { get; set; } 17 | public string Performer { get; set; } 18 | public string Title { get; set; } 19 | public string File { get; set; } 20 | public string FileType { get; set; } 21 | 22 | public List Tracks { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /gMKVToolNix/CueSheet/CueTrack.cs: -------------------------------------------------------------------------------- 1 | namespace gMKVToolNix.CueSheet 2 | { 3 | public class CueTrack 4 | { 5 | /* 6 | TRACK 01 AUDIO 7 | TITLE "Reverence" 8 | PERFORMER "Faithless" 9 | INDEX 01 00:00:00 10 | */ 11 | 12 | public int Number { get; set; } 13 | public string Title { get; set; } 14 | public string Performer { get; set; } 15 | public string Index { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gMKVToolNix/Libs/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2007 James Newton-King 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /gMKVToolNix/Libs/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hooke007/gMKVExtractGUI_chs/138cb4cfda7783e805afbc2ce7b79e6c91c9d521/gMKVToolNix/Libs/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /gMKVToolNix/Libs/Newtonsoft.Json.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hooke007/gMKVExtractGUI_chs/138cb4cfda7783e805afbc2ce7b79e6c91c9d521/gMKVToolNix/Libs/Newtonsoft.Json.pdb -------------------------------------------------------------------------------- /gMKVToolNix/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("gMKVToolNix")] 9 | [assembly: AssemblyDescription("A library to execute MKVToolNix cli utilities in .NET")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Gpower2")] 12 | [assembly: AssemblyProduct("gMKVToolNix")] 13 | [assembly: AssemblyCopyright("Copyright © 2014-2022")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(true)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1dcf6127-ee85-48d0-9e29-260dc29f5225")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.6.2.0")] 36 | [assembly: AssemblyFileVersion("2.6.2.0")] 37 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVAttachment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace gMKVToolNix 4 | { 5 | [Serializable] 6 | public class gMKVAttachment : gMKVSegment 7 | { 8 | public int ID { get; set; } 9 | 10 | public string Filename { get; set; } = ""; 11 | 12 | public string MimeType { get; set; } = ""; 13 | 14 | public string FileSize { get; set; } = ""; 15 | 16 | public override string ToString() 17 | { 18 | return $"Attachment {ID} [{Filename}][{MimeType}][{FileSize} bytes]"; 19 | } 20 | 21 | public override bool Equals(object oth) 22 | { 23 | gMKVAttachment other = oth as gMKVAttachment; 24 | if (other == null) 25 | { 26 | return false; 27 | } 28 | 29 | return 30 | Filename.Equals(other.Filename, StringComparison.OrdinalIgnoreCase) 31 | && FileSize.Equals(other.FileSize, StringComparison.OrdinalIgnoreCase) 32 | && ID == other.ID 33 | && MimeType.Equals(other.MimeType, StringComparison.OrdinalIgnoreCase) 34 | ; 35 | } 36 | 37 | public override int GetHashCode() 38 | { 39 | // https://stackoverflow.com/a/263416 40 | unchecked // Overflow is fine, just wrap 41 | { 42 | int hash = 17; 43 | // Suitable nullity checks etc, of course :) 44 | hash = hash * 23 + Filename.GetHashCode(); 45 | hash = hash * 23 + FileSize.GetHashCode(); 46 | hash = hash * 23 + ID.GetHashCode(); 47 | hash = hash * 23 + MimeType.GetHashCode(); 48 | return hash; 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVChapter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace gMKVToolNix 4 | { 5 | public enum MkvChapterTypes 6 | { 7 | XML, 8 | OGM, 9 | CUE 10 | } 11 | 12 | [Serializable] 13 | public class gMKVChapter : gMKVSegment 14 | { 15 | public int ChapterCount { get; set; } 16 | 17 | public override string ToString() 18 | { 19 | string entryString = ChapterCount > 1 ? "entries" : "entry"; 20 | return $"Chapters {ChapterCount} {entryString}"; 21 | } 22 | 23 | public override bool Equals(object oth) 24 | { 25 | gMKVChapter other = oth as gMKVChapter; 26 | if (other == null) 27 | { 28 | return false; 29 | } 30 | 31 | return ChapterCount == other.ChapterCount; 32 | } 33 | 34 | public override int GetHashCode() 35 | { 36 | return ChapterCount.GetHashCode(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Diagnostics; 5 | using Microsoft.Win32; 6 | using System.IO; 7 | using System.Reflection; 8 | 9 | namespace gMKVToolNix 10 | { 11 | public static class gMKVHelper 12 | { 13 | /// 14 | /// Returns if the running Platform is Linux Or MacOSX 15 | /// 16 | public static bool IsOnLinux 17 | { 18 | get 19 | { 20 | PlatformID myPlatform = Environment.OSVersion.Platform; 21 | 22 | // 128 is Mono 1.x specific value for Linux systems, so it's there to provide compatibility 23 | return (myPlatform == PlatformID.Unix) || (myPlatform == PlatformID.MacOSX) || ((int)myPlatform == 128); 24 | } 25 | } 26 | 27 | /// 28 | /// Gets the mkvmerge GUI executable filename 29 | /// 30 | public static string MKV_MERGE_GUI_FILENAME 31 | { 32 | get { return IsOnLinux ? "mmg" : "mmg.exe"; } 33 | } 34 | 35 | /// 36 | /// Gets the new mkvmerge GUI executable filename 37 | /// 38 | public static string MKV_MERGE_NEW_GUI_FILENAME 39 | { 40 | get { return IsOnLinux ? "mkvmerge" : "mkvmerge.exe"; } 41 | } 42 | 43 | /// 44 | /// Unescapes string from mkvtoolnix output 45 | /// 46 | /// 47 | /// 48 | public static string UnescapeString(string argString) 49 | { 50 | return argString. 51 | Replace(@"\s", " "). 52 | Replace(@"\2", "\""). 53 | Replace(@"\c", ":"). 54 | Replace(@"\h", "#"). 55 | Replace(@"\\", @"\"). 56 | Replace(@"\b", "["). 57 | Replace(@"\B", "]"); 58 | } 59 | 60 | /// 61 | /// Escapes string from mkvtoolnix output 62 | /// 63 | /// 64 | /// 65 | public static string EscapeString(string argString) 66 | { 67 | return argString. 68 | Replace(" ", @"\s"). 69 | Replace("\"", @"\2"). 70 | Replace(":", @"\c"). 71 | Replace("#", @"\h"). 72 | Replace(@"\", @"\\"). 73 | Replace("[", @"\b"). 74 | Replace("]", @"\B"); 75 | } 76 | 77 | /// 78 | /// Returns the path from MKVToolnix. 79 | /// It tries to find it via the registry keys. 80 | /// If it doesn't find it, it throws an exception. 81 | /// 82 | /// 83 | public static string GetMKVToolnixPathViaRegistry() 84 | { 85 | // Check if we are on Linux, so we don't have to check the registry 86 | if (gMKVHelper.IsOnLinux) 87 | { 88 | throw new Exception("Running on Linux..."); 89 | } 90 | 91 | RegistryKey regMkvToolnix = null; 92 | string valuePath = ""; 93 | bool subKeyFound = false; 94 | bool valueFound = false; 95 | 96 | // First check for Installed MkvToolnix 97 | // First check Win32 registry 98 | RegistryKey regUninstall = Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft"). 99 | OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Uninstall"); 100 | 101 | foreach (string subKeyName in regUninstall.GetSubKeyNames()) 102 | { 103 | if (subKeyName.Equals("MKVToolNix", StringComparison.OrdinalIgnoreCase)) 104 | { 105 | subKeyFound = true; 106 | regMkvToolnix = regUninstall.OpenSubKey("MKVToolNix"); 107 | break; 108 | } 109 | } 110 | 111 | // if sub key was found, try to get the executable path 112 | if (subKeyFound) 113 | { 114 | foreach (string valueName in regMkvToolnix.GetValueNames()) 115 | { 116 | if (valueName.Equals("DisplayIcon", StringComparison.OrdinalIgnoreCase)) 117 | { 118 | valueFound = true; 119 | valuePath = (string)regMkvToolnix.GetValue(valueName); 120 | break; 121 | } 122 | } 123 | } 124 | 125 | // if value was not found, search Win64 registry 126 | if (!valueFound) 127 | { 128 | subKeyFound = false; 129 | 130 | regUninstall = Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Wow6432Node").OpenSubKey("Microsoft"). 131 | OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Uninstall"); 132 | 133 | foreach (string subKeyName in regUninstall.GetSubKeyNames()) 134 | { 135 | if (subKeyName.Equals("MKVToolNix", StringComparison.OrdinalIgnoreCase)) 136 | { 137 | subKeyFound = true; 138 | regMkvToolnix = regUninstall.OpenSubKey("MKVToolNix"); 139 | break; 140 | } 141 | } 142 | 143 | // if sub key was found, try to get the executable path 144 | if (subKeyFound) 145 | { 146 | foreach (string valueName in regMkvToolnix.GetValueNames()) 147 | { 148 | if (valueName.Equals("DisplayIcon", StringComparison.OrdinalIgnoreCase)) 149 | { 150 | valueFound = true; 151 | valuePath = (string)regMkvToolnix.GetValue(valueName); 152 | break; 153 | } 154 | } 155 | } 156 | } 157 | 158 | // if value was still not found, we may have portable installation 159 | // let's try the CURRENT_USER registry 160 | if (!valueFound) 161 | { 162 | RegistryKey regSoftware = Registry.CurrentUser.OpenSubKey("Software"); 163 | subKeyFound = false; 164 | foreach (string subKey in regSoftware.GetSubKeyNames()) 165 | { 166 | if (subKey.Equals("mkvmergeGUI", StringComparison.OrdinalIgnoreCase)) 167 | { 168 | subKeyFound = true; 169 | regMkvToolnix = regSoftware.OpenSubKey("mkvmergeGUI"); 170 | break; 171 | } 172 | } 173 | 174 | // if we didn't find the MkvMergeGUI key, all hope is lost 175 | if (!subKeyFound) 176 | { 177 | throw new Exception($"Couldn't find MKVToolNix in your system!{Environment.NewLine}Please download and install it or provide a manual path!"); 178 | } 179 | 180 | RegistryKey regGui = null; 181 | Boolean foundGuiKey = false; 182 | foreach (string subKey in regMkvToolnix.GetSubKeyNames()) 183 | { 184 | if (subKey.Equals("GUI", StringComparison.OrdinalIgnoreCase)) 185 | { 186 | foundGuiKey = true; 187 | regGui = regMkvToolnix.OpenSubKey("GUI"); 188 | break; 189 | } 190 | } 191 | // if we didn't find the GUI key, all hope is lost 192 | if (!foundGuiKey) 193 | { 194 | throw new Exception("Found MKVToolNix in your system but not the registry Key GUI!"); 195 | } 196 | 197 | foreach (string valueName in regGui.GetValueNames()) 198 | { 199 | if (valueName.Equals("mkvmerge_executable", StringComparison.OrdinalIgnoreCase)) 200 | { 201 | valueFound = true; 202 | valuePath = (string)regGui.GetValue("mkvmerge_executable"); 203 | break; 204 | } 205 | } 206 | // if we didn't find the mkvmerge_executable value, all hope is lost 207 | if (!valueFound) 208 | { 209 | throw new Exception("Found MKVToolNix in your system but not the registry value mkvmerge_executable!"); 210 | } 211 | } 212 | 213 | // Now that we found a value (otherwise we would not be here, an exception would have been thrown) 214 | // let's check if it's valid 215 | if (!File.Exists(valuePath)) 216 | { 217 | throw new Exception($"Found a registry value ({valuePath}) for MKVToolNix in your system but it is not valid!"); 218 | } 219 | 220 | // Everything is A-OK! Return the valid Directory value! :) 221 | return Path.GetDirectoryName(valuePath); 222 | } 223 | 224 | /// 225 | /// 226 | /// 227 | /// 228 | /// 229 | /// 230 | public static List GetMergedMkvSegmentList(string argMkvToolnixPath, string argInputFile) 231 | { 232 | gMKVMerge g = new gMKVMerge(argMkvToolnixPath); 233 | gMKVInfo gInfo = new gMKVInfo(argMkvToolnixPath); 234 | 235 | List segmentList = g.GetMKVSegments(argInputFile); 236 | 237 | // Check if information was found in mkvmerge output 238 | bool segmentInfoWasFound = false; 239 | foreach (gMKVSegment seg in segmentList) 240 | { 241 | if (seg is gMKVSegmentInfo) 242 | { 243 | segmentInfoWasFound = true; 244 | break; 245 | } 246 | } 247 | 248 | // Check if codec_private_data was found in mkvmerge output 249 | bool codecPrivateDataWasFound = false; 250 | foreach (gMKVSegment seg in segmentList) 251 | { 252 | if (seg is gMKVTrack) 253 | { 254 | if (!string.IsNullOrWhiteSpace(((gMKVTrack)seg).CodecPrivateData)) 255 | { 256 | codecPrivateDataWasFound = true; 257 | break; 258 | } 259 | } 260 | } 261 | 262 | if (!segmentInfoWasFound || !codecPrivateDataWasFound) 263 | { 264 | List segmentListInfo = gInfo.GetMKVSegments(argInputFile); 265 | foreach (gMKVSegment seg in segmentListInfo) 266 | { 267 | if (seg is gMKVSegmentInfo && !segmentInfoWasFound) 268 | { 269 | segmentList.Insert(0, seg); 270 | } 271 | else if (seg is gMKVTrack && !codecPrivateDataWasFound) 272 | { 273 | // Update CodecPrivate info from mkvinfo to mkvextract segments 274 | foreach (gMKVSegment seg2 in segmentList) 275 | { 276 | if (seg2 is gMKVTrack) 277 | { 278 | if (((gMKVTrack)seg2).TrackID == ((gMKVTrack)seg).TrackID) 279 | { 280 | if (!string.IsNullOrWhiteSpace(((gMKVTrack)seg).CodecPrivate)) 281 | { 282 | ((gMKVTrack)seg2).CodecPrivate = ((gMKVTrack)seg).CodecPrivate; 283 | } 284 | if (((gMKVTrack)seg2).TrackType == MkvTrackType.video) 285 | { 286 | if (((gMKVTrack)seg2).VideoPixelWidth < ((gMKVTrack)seg).VideoPixelWidth) 287 | { 288 | ((gMKVTrack)seg2).VideoPixelWidth = ((gMKVTrack)seg).VideoPixelWidth; 289 | } 290 | if (((gMKVTrack)seg2).VideoPixelHeight < ((gMKVTrack)seg).VideoPixelHeight) 291 | { 292 | ((gMKVTrack)seg2).VideoPixelHeight = ((gMKVTrack)seg).VideoPixelHeight; 293 | } 294 | if (!string.IsNullOrWhiteSpace(((gMKVTrack)seg).ExtraInfo)) 295 | { 296 | ((gMKVTrack)seg2).ExtraInfo = ((gMKVTrack)seg).ExtraInfo; 297 | } 298 | } 299 | else if (((gMKVTrack)seg2).TrackType == MkvTrackType.audio) 300 | { 301 | if (((gMKVTrack)seg2).AudioChannels < ((gMKVTrack)seg).AudioChannels) 302 | { 303 | ((gMKVTrack)seg2).AudioChannels = ((gMKVTrack)seg).AudioChannels; 304 | } 305 | if (((gMKVTrack)seg2).AudioSamplingFrequency < ((gMKVTrack)seg).AudioSamplingFrequency) 306 | { 307 | ((gMKVTrack)seg2).AudioSamplingFrequency = ((gMKVTrack)seg).AudioSamplingFrequency; 308 | } 309 | if (!string.IsNullOrWhiteSpace(((gMKVTrack)seg).ExtraInfo)) 310 | { 311 | ((gMKVTrack)seg2).ExtraInfo = ((gMKVTrack)seg).ExtraInfo; 312 | } 313 | } 314 | break; 315 | } 316 | } 317 | } 318 | } 319 | } 320 | } 321 | 322 | // Try to determine the delays from mkvmerge info 323 | if (!g.FindDelays(segmentList)) 324 | { 325 | // If we couldn't determine the delays from mkvmerge info, then we use mkvinfo 326 | gInfo.FindAndSetDelays(segmentList, argInputFile); 327 | } 328 | 329 | // Translate codec_private_data in codec_private information 330 | g.FindCodecPrivate(segmentList); 331 | 332 | return segmentList; 333 | } 334 | 335 | /// 336 | /// Creates a DataReceivedEventArgs instance with the given Data. 337 | /// 338 | /// 339 | /// 340 | public static DataReceivedEventArgs GetDataReceivedEventArgs(object argData) 341 | { 342 | DataReceivedEventArgs eventArgs = (DataReceivedEventArgs)System.Runtime.Serialization.FormatterServices 343 | .GetUninitializedObject(typeof(DataReceivedEventArgs)); 344 | 345 | FieldInfo f = typeof(DataReceivedEventArgs).GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)[0]; 346 | f.SetValue(eventArgs, argData); 347 | 348 | return eventArgs; 349 | } 350 | 351 | /// 352 | /// Reads a Process's standard output stream character by character and calls the user defined method for each line 353 | /// 354 | /// 355 | /// 356 | public static void ReadStreamPerCharacter(Process argProcess, DataReceivedEventHandler argHandler) 357 | { 358 | StreamReader reader = argProcess.StandardOutput; 359 | StringBuilder line = new StringBuilder(); 360 | while (true) 361 | { 362 | if (!reader.EndOfStream) 363 | { 364 | char c = (char)reader.Read(); 365 | if (c == '\r') 366 | { 367 | if ((char)reader.Peek() == '\n') 368 | { 369 | // consume the next character 370 | reader.Read(); 371 | } 372 | 373 | argHandler(argProcess, GetDataReceivedEventArgs(line.ToString())); 374 | line.Length = 0; 375 | } 376 | else if (c == '\n') 377 | { 378 | argHandler(argProcess, GetDataReceivedEventArgs(line.ToString())); 379 | line.Length = 0; 380 | } 381 | else 382 | { 383 | line.Append(c); 384 | } 385 | } 386 | else 387 | { 388 | break; 389 | } 390 | } 391 | } 392 | } 393 | } 394 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVJob.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | 6 | namespace gMKVToolNix 7 | { 8 | public enum FormMkvExtractionMode 9 | { 10 | Tracks, 11 | Cue_Sheet, 12 | Tags, 13 | Timecodes, 14 | Tracks_And_Timecodes, 15 | Cues, 16 | Tracks_And_Cues, 17 | Tracks_And_Cues_And_Timecodes 18 | } 19 | 20 | public delegate void gMkvExtractMethod(object parameterList); 21 | 22 | [Serializable] 23 | [System.Xml.Serialization.XmlInclude(typeof(List))] 24 | [System.Xml.Serialization.XmlInclude(typeof(gMKVSegment))] 25 | [System.Xml.Serialization.XmlInclude(typeof(gMKVTrack))] 26 | [System.Xml.Serialization.XmlInclude(typeof(gMKVChapter))] 27 | [System.Xml.Serialization.XmlInclude(typeof(gMKVAttachment))] 28 | public class gMKVJob 29 | { 30 | public FormMkvExtractionMode ExtractionMode { get; set; } 31 | 32 | public string MKVToolnixPath { get; set; } 33 | 34 | public gMKVExtractSegmentsParameters ParametersList { get; set; } 35 | 36 | public gMKVJob(FormMkvExtractionMode argExtractionMode, string argMKVToolnixPath, gMKVExtractSegmentsParameters argParameters) 37 | { 38 | ExtractionMode = argExtractionMode; 39 | MKVToolnixPath = argMKVToolnixPath; 40 | ParametersList = argParameters; 41 | } 42 | 43 | public gMkvExtractMethod ExtractMethod(gMKVExtract argGmkvExtract) { 44 | switch (ExtractionMode) 45 | { 46 | case FormMkvExtractionMode.Tracks: 47 | return argGmkvExtract.ExtractMKVSegmentsThreaded; 48 | case FormMkvExtractionMode.Cue_Sheet: 49 | return argGmkvExtract.ExtractMkvCuesheetThreaded; 50 | case FormMkvExtractionMode.Tags: 51 | return argGmkvExtract.ExtractMkvTagsThreaded; 52 | case FormMkvExtractionMode.Timecodes: 53 | return argGmkvExtract.ExtractMKVTimecodesThreaded; 54 | case FormMkvExtractionMode.Tracks_And_Timecodes: 55 | return argGmkvExtract.ExtractMKVSegmentsThreaded; 56 | case FormMkvExtractionMode.Cues: 57 | return argGmkvExtract.ExtractMKVCuesThreaded; 58 | case FormMkvExtractionMode.Tracks_And_Cues: 59 | return argGmkvExtract.ExtractMKVSegmentsThreaded; 60 | case FormMkvExtractionMode.Tracks_And_Cues_And_Timecodes: 61 | return argGmkvExtract.ExtractMKVSegmentsThreaded; 62 | default: 63 | throw new Exception("Unsupported Extraction Mode!"); 64 | } 65 | } 66 | 67 | // For serialization only!!! 68 | internal gMKVJob() { } 69 | 70 | private string GetTracks(List argSegmentList) 71 | { 72 | StringBuilder trackBuilder = new StringBuilder(); 73 | foreach (gMKVSegment item in argSegmentList) 74 | { 75 | if (item is gMKVTrack track) 76 | { 77 | trackBuilder.AppendFormat("[{0}:{1}]", 78 | track.TrackType.ToString().Substring(0, 3), 79 | track.TrackID); 80 | } 81 | else if (item is gMKVAttachment attachment) 82 | { 83 | trackBuilder.AppendFormat("[Att:{0}]", 84 | attachment.ID); 85 | } 86 | else if (item is gMKVChapter) 87 | { 88 | trackBuilder.AppendFormat("[{0}]", "Chap"); 89 | } 90 | } 91 | return trackBuilder.ToString(); 92 | } 93 | 94 | public override string ToString() 95 | { 96 | StringBuilder retValue = new StringBuilder(); 97 | switch (ExtractionMode) 98 | { 99 | case FormMkvExtractionMode.Tracks: 100 | retValue.AppendFormat("Tracks {0} \r\n{1} \r\n{2}", 101 | GetTracks(ParametersList.MKVSegmentsToExtract), 102 | Path.GetFileName(ParametersList.MKVFile), ParametersList.OutputDirectory); 103 | break; 104 | case FormMkvExtractionMode.Cue_Sheet: 105 | retValue.AppendFormat("Cue Sheet \r\n{0} \r\n{1}'", 106 | Path.GetFileName(ParametersList.MKVFile), ParametersList.OutputDirectory); 107 | break; 108 | case FormMkvExtractionMode.Tags: 109 | retValue.AppendFormat("Tags \r\n{0} \r\n{1}", 110 | Path.GetFileName(ParametersList.MKVFile), ParametersList.OutputDirectory); 111 | break; 112 | case FormMkvExtractionMode.Timecodes: 113 | retValue.AppendFormat("Timecodes {0} \r\n{1} \r\n{2}", 114 | GetTracks(ParametersList.MKVSegmentsToExtract), 115 | Path.GetFileName(ParametersList.MKVFile), ParametersList.OutputDirectory); 116 | break; 117 | case FormMkvExtractionMode.Tracks_And_Timecodes: 118 | retValue.AppendFormat("Tracks/Timecodes {0} \r\n{1} \r\n{2}", 119 | GetTracks(ParametersList.MKVSegmentsToExtract), 120 | Path.GetFileName(ParametersList.MKVFile), ParametersList.OutputDirectory); 121 | break; 122 | case FormMkvExtractionMode.Cues: 123 | retValue.AppendFormat("Cues {0} \r\n{1} \r\n{2}", 124 | GetTracks(ParametersList.MKVSegmentsToExtract), 125 | Path.GetFileName(ParametersList.MKVFile), ParametersList.OutputDirectory); 126 | break; 127 | case FormMkvExtractionMode.Tracks_And_Cues: 128 | retValue.AppendFormat("Tracks/Cues {0} \r\n{1} \r\n{2}", 129 | GetTracks(ParametersList.MKVSegmentsToExtract), 130 | Path.GetFileName(ParametersList.MKVFile), ParametersList.OutputDirectory); 131 | break; 132 | case FormMkvExtractionMode.Tracks_And_Cues_And_Timecodes: 133 | retValue.AppendFormat("Tracks/Cues/Timecodes {0} \r\n{1} \r\n{2}", 134 | GetTracks(ParametersList.MKVSegmentsToExtract), 135 | Path.GetFileName(ParametersList.MKVFile), ParametersList.OutputDirectory); 136 | break; 137 | default: 138 | retValue.AppendFormat("Unknown job!!!"); 139 | break; 140 | } 141 | 142 | return retValue.ToString(); 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVJobInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace gMKVToolNix 4 | { 5 | public enum JobState 6 | { 7 | Ready, 8 | Pending, 9 | Running, 10 | Completed, 11 | Failed 12 | } 13 | 14 | [Serializable] 15 | public class gMKVJobInfo 16 | { 17 | public gMKVJob Job { get; set; } 18 | 19 | public DateTime? StartTime { get; set; } 20 | 21 | public DateTime? EndTime { get; set; } 22 | 23 | public JobState State { get; set; } = JobState.Ready; 24 | 25 | public TimeSpan? Duration 26 | { 27 | get 28 | { 29 | if (StartTime.HasValue) 30 | { 31 | if (EndTime.HasValue) 32 | { 33 | return ((TimeSpan?)(EndTime - StartTime)).Value; 34 | } 35 | else 36 | { 37 | return ((TimeSpan?)(DateTime.Now - StartTime)).Value; 38 | } 39 | } 40 | else 41 | { 42 | return null; 43 | } 44 | } 45 | } 46 | 47 | public gMKVJobInfo(gMKVJob argJob) 48 | { 49 | Job = argJob; 50 | } 51 | 52 | // For serialization only!!! 53 | internal gMKVJobInfo() { } 54 | 55 | public void Reset() 56 | { 57 | EndTime = null; 58 | StartTime = null; 59 | State = JobState.Ready; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVLogger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace gMKVToolNix 5 | { 6 | public delegate void LogLineAddedEventHandler(string lineAdded, DateTime actionDate); 7 | 8 | public static class gMKVLogger 9 | { 10 | private static readonly StringBuilder _Log = new StringBuilder(); 11 | 12 | public static string LogText { get { return _Log.ToString(); } } 13 | 14 | public static event LogLineAddedEventHandler LogLineAdded; 15 | 16 | public static void Clear() 17 | { 18 | _Log.Length = 0; 19 | } 20 | 21 | public static void Log(string message) 22 | { 23 | DateTime actionDate = DateTime.Now; 24 | string logMessage = $"{actionDate:[yyyy-MM-dd][HH:mm:ss]} {message}"; 25 | _Log.AppendLine(logMessage); 26 | OnLogLineAdded(logMessage, actionDate); 27 | } 28 | 29 | public static void OnLogLineAdded(string lineAdded, DateTime actionDate) 30 | { 31 | LogLineAdded?.Invoke(lineAdded, actionDate); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVSegment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace gMKVToolNix 4 | { 5 | [Serializable] 6 | public class gMKVSegment 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVSegmentInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace gMKVToolNix 4 | { 5 | [Serializable] 6 | public class gMKVSegmentInfo : gMKVSegment 7 | { 8 | public string TimecodeScale { get; set; } = ""; 9 | 10 | public string MuxingApplication { get; set; } = ""; 11 | 12 | public string WritingApplication { get; set; } = ""; 13 | 14 | public string Duration { get; set; } = ""; 15 | 16 | public string Date { get; set; } = ""; 17 | 18 | /// 19 | /// The segment's file filename 20 | /// 21 | public string Filename { get; set; } = ""; 22 | 23 | /// 24 | /// The segment's file directory 25 | /// 26 | public string Directory { get; set; } = ""; 27 | 28 | /// 29 | /// Returns the segment's full file path 30 | /// 31 | public string Path 32 | { 33 | get 34 | { 35 | return System.IO.Path.Combine(Directory ?? "", Filename ?? ""); 36 | } 37 | } 38 | 39 | public override bool Equals(object oth) 40 | { 41 | gMKVSegmentInfo other = oth as gMKVSegmentInfo; 42 | if (other == null) 43 | { 44 | return false; 45 | } 46 | 47 | return 48 | Date.Equals(other.Date, StringComparison.OrdinalIgnoreCase) 49 | && Directory.Equals(other.Directory, StringComparison.OrdinalIgnoreCase) 50 | && Duration.Equals(other.Duration, StringComparison.OrdinalIgnoreCase) 51 | && Filename.Equals(other.Filename, StringComparison.OrdinalIgnoreCase) 52 | && MuxingApplication.Equals(other.MuxingApplication, StringComparison.OrdinalIgnoreCase) 53 | && TimecodeScale.Equals(other.TimecodeScale, StringComparison.OrdinalIgnoreCase) 54 | && WritingApplication.Equals(other.WritingApplication, StringComparison.OrdinalIgnoreCase) 55 | ; 56 | } 57 | 58 | public override int GetHashCode() 59 | { 60 | // https://stackoverflow.com/a/263416 61 | unchecked // Overflow is fine, just wrap 62 | { 63 | int hash = 17; 64 | // Suitable nullity checks etc, of course :) 65 | hash = hash * 23 + Date.GetHashCode(); 66 | hash = hash * 23 + Directory.GetHashCode(); 67 | hash = hash * 23 + Duration.GetHashCode(); 68 | hash = hash * 23 + Filename.GetHashCode(); 69 | hash = hash * 23 + MuxingApplication.GetHashCode(); 70 | hash = hash * 23 + TimecodeScale.GetHashCode(); 71 | hash = hash * 23 + WritingApplication.GetHashCode(); 72 | return hash; 73 | } 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /gMKVToolNix/gMKVToolNix.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {82FC8FA8-50C0-44FA-8801-80050C0ED89F} 8 | Library 9 | Properties 10 | gMKVToolNix 11 | gMKVToolNix 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | true 35 | bin\x86\Debug\ 36 | DEBUG;TRACE 37 | full 38 | x86 39 | prompt 40 | MinimumRecommendedRules.ruleset 41 | 42 | 43 | bin\x86\Release\ 44 | TRACE 45 | true 46 | pdbonly 47 | x86 48 | prompt 49 | MinimumRecommendedRules.ruleset 50 | 51 | 52 | 53 | False 54 | Libs\Newtonsoft.Json.dll 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | matroskachapters.xsd 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | Designer 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 100 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVToolNix.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ShowAllFiles 5 | 6 | -------------------------------------------------------------------------------- /gMKVToolNix/gMKVTrack.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace gMKVToolNix 5 | { 6 | public enum MkvTrackType 7 | { 8 | video, 9 | audio, 10 | subtitles 11 | } 12 | 13 | [Serializable] 14 | public class gMKVTrack : gMKVSegment 15 | { 16 | public int TrackNumber { get; set; } 17 | 18 | public int TrackID { get; set; } 19 | 20 | public MkvTrackType TrackType { get; set; } 21 | 22 | public string CodecID { get; set; } = ""; 23 | 24 | public string CodecPrivate { get; set; } = ""; 25 | 26 | public string CodecPrivateData { get; set; } = ""; 27 | 28 | public string Language { get; set; } = ""; 29 | 30 | public string LanguageIetf { get; set; } = ""; 31 | 32 | public string TrackName { get; set; } = ""; 33 | 34 | public string ExtraInfo { get; set; } = ""; 35 | 36 | public int Delay { get; set; } = int.MinValue; 37 | 38 | public int EffectiveDelay { get; set; } = int.MinValue; 39 | 40 | /// 41 | /// In nanoseconds 42 | /// 43 | public long MinimumTimestamp { get; set; } = long.MinValue; 44 | 45 | 46 | public int VideoPixelWidth { get; set; } 47 | public int VideoPixelHeight { get; set; } 48 | 49 | public int AudioSamplingFrequency { get; set; } 50 | public int AudioChannels { get; set; } 51 | 52 | public override string ToString() 53 | { 54 | StringBuilder outputBuilder = new StringBuilder(); 55 | 56 | outputBuilder.Append($"Track {TrackNumber} [TID {TrackID}][{TrackType}][{CodecID}][{TrackName}][{Language}]"); 57 | 58 | if (!string.IsNullOrWhiteSpace(LanguageIetf)) 59 | { 60 | outputBuilder.Append($"[{LanguageIetf}]"); 61 | } 62 | 63 | outputBuilder.Append($"[{ExtraInfo}]"); 64 | 65 | if (!string.IsNullOrWhiteSpace(CodecPrivate)) 66 | { 67 | outputBuilder.Append($"[{CodecPrivate}]"); 68 | } 69 | 70 | if (TrackType != MkvTrackType.subtitles) 71 | { 72 | outputBuilder.Append($"[{Delay} ms][{EffectiveDelay} ms]"); 73 | } 74 | 75 | return outputBuilder.ToString(); 76 | } 77 | 78 | public override bool Equals(object oth) 79 | { 80 | gMKVTrack other = oth as gMKVTrack; 81 | if (other == null) 82 | { 83 | return false; 84 | } 85 | 86 | return 87 | AudioChannels == other.AudioChannels 88 | && AudioSamplingFrequency == other.AudioSamplingFrequency 89 | && CodecID.Equals( other.CodecID, StringComparison.OrdinalIgnoreCase) 90 | && CodecPrivate.Equals(other.CodecPrivate, StringComparison.OrdinalIgnoreCase) 91 | && CodecPrivateData.Equals(other.CodecPrivateData, StringComparison.OrdinalIgnoreCase) 92 | && Delay == other.Delay 93 | && EffectiveDelay == other.EffectiveDelay 94 | && ExtraInfo.Equals(other.ExtraInfo, StringComparison.OrdinalIgnoreCase) 95 | && Language.Equals(other.Language, StringComparison.OrdinalIgnoreCase) 96 | && LanguageIetf.Equals(other.LanguageIetf, StringComparison.OrdinalIgnoreCase) 97 | && MinimumTimestamp == other.MinimumTimestamp 98 | && TrackID == other.TrackID 99 | && TrackName.Equals(other.TrackName, StringComparison.OrdinalIgnoreCase) 100 | && TrackNumber == other.TrackNumber 101 | && TrackType == other.TrackType 102 | && VideoPixelHeight == other.VideoPixelHeight 103 | && VideoPixelWidth == other.VideoPixelWidth 104 | ; 105 | } 106 | 107 | public override int GetHashCode() 108 | { 109 | // https://stackoverflow.com/a/263416 110 | unchecked // Overflow is fine, just wrap 111 | { 112 | int hash = 17; 113 | // Suitable nullity checks etc, of course :) 114 | hash = hash * 23 + AudioChannels.GetHashCode(); 115 | hash = hash * 23 + AudioSamplingFrequency.GetHashCode(); 116 | hash = hash * 23 + CodecID.GetHashCode(); 117 | hash = hash * 23 + CodecPrivate.GetHashCode(); 118 | hash = hash * 23 + CodecPrivateData.GetHashCode(); 119 | hash = hash * 23 + Delay.GetHashCode(); 120 | hash = hash * 23 + EffectiveDelay.GetHashCode(); 121 | hash = hash * 23 + ExtraInfo.GetHashCode(); 122 | hash = hash * 23 + Language.GetHashCode(); 123 | hash = hash * 23 + LanguageIetf.GetHashCode(); 124 | hash = hash * 23 + MinimumTimestamp.GetHashCode(); 125 | hash = hash * 23 + TrackID.GetHashCode(); 126 | hash = hash * 23 + TrackName.GetHashCode(); 127 | hash = hash * 23 + TrackNumber.GetHashCode(); 128 | hash = hash * 23 + TrackType.GetHashCode(); 129 | hash = hash * 23 + VideoPixelHeight.GetHashCode(); 130 | hash = hash * 23 + VideoPixelWidth.GetHashCode(); 131 | return hash; 132 | } 133 | } 134 | } 135 | } -------------------------------------------------------------------------------- /gMKVToolNix/gMKVVersion.cs: -------------------------------------------------------------------------------- 1 | namespace gMKVToolNix 2 | { 3 | public class gMKVVersion 4 | { 5 | public int FileMajorPart { get; set; } 6 | public int FileMinorPart { get; set; } 7 | public int FilePrivatePart { get; set; } 8 | } 9 | } --------------------------------------------------------------------------------