From 8fcf9b034fc8e82cb2a83a089719c76e85d1b463 Mon Sep 17 00:00:00 2001 From: tautcony Date: Fri, 16 Sep 2016 13:12:22 +0800 Subject: [PATCH 01/30] Fix mpls index range. --- Time_Shift/Util/ChapterData/MplsData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Time_Shift/Util/ChapterData/MplsData.cs b/Time_Shift/Util/ChapterData/MplsData.cs index 0397655..ea24731 100644 --- a/Time_Shift/Util/ChapterData/MplsData.cs +++ b/Time_Shift/Util/ChapterData/MplsData.cs @@ -197,7 +197,7 @@ public static TimeSpan Pts2Time(int pts) public ChapterInfo ToChapterInfo(int index, bool combineChapter) { - if (index > ChapterClips.Count && !combineChapter) + if (index >= ChapterClips.Count && !combineChapter) { throw new IndexOutOfRangeException("Index of Video Clip out of range"); } From da632128162f5e85ed2248aeab73ab05e9aa4f7a Mon Sep 17 00:00:00 2001 From: tautcony Date: Fri, 16 Sep 2016 13:16:41 +0800 Subject: [PATCH 02/30] using FluentAssertions. --- Time_Shift_Test/Knuckleball/MP4FileTests.cs | 5 +- .../SharpDvdInfo/DvdInfoContainerTests.cs | 5 +- Time_Shift_Test/Time_Shift_Test.csproj | 13 ++++ Time_Shift_Test/Util/CueDataTests.cs | 5 +- Time_Shift_Test/Util/ExpressionTests.cs | 68 ++++++++---------- Time_Shift_Test/Util/IfoDataTests.cs | 5 +- Time_Shift_Test/Util/IfoParserTests.cs | 3 +- Time_Shift_Test/Util/MplsDataTests.cs | 69 +++++++++---------- Time_Shift_Test/Util/OgmDataTests.cs | 5 +- Time_Shift_Test/Util/ToolKitsTests.cs | 7 +- Time_Shift_Test/packages.config | 4 ++ 11 files changed, 99 insertions(+), 90 deletions(-) create mode 100644 Time_Shift_Test/packages.config diff --git a/Time_Shift_Test/Knuckleball/MP4FileTests.cs b/Time_Shift_Test/Knuckleball/MP4FileTests.cs index b1b4f6e..74a1a17 100644 --- a/Time_Shift_Test/Knuckleball/MP4FileTests.cs +++ b/Time_Shift_Test/Knuckleball/MP4FileTests.cs @@ -4,6 +4,7 @@ using System; using System.IO; using ChapterTool.Util.ChapterData; +using FluentAssertions; namespace Knuckleball.Tests { @@ -31,8 +32,8 @@ public void Mp4ChapterTest() foreach (var chapter in result.Chapter.Chapters) { Console.WriteLine(chapter); - Assert.IsTrue(expectResult[index].Name == chapter.Name); - Assert.IsTrue(expectResult[index].Time == chapter.Time.Time2String()); + expectResult[index].Name.Should().Be(chapter.Name); + expectResult[index].Time.Should().Be(chapter.Time.Time2String()); ++index; } } diff --git a/Time_Shift_Test/SharpDvdInfo/DvdInfoContainerTests.cs b/Time_Shift_Test/SharpDvdInfo/DvdInfoContainerTests.cs index fd561b7..d483303 100644 --- a/Time_Shift_Test/SharpDvdInfo/DvdInfoContainerTests.cs +++ b/Time_Shift_Test/SharpDvdInfo/DvdInfoContainerTests.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.IO; using ChapterTool.Util; +using FluentAssertions; namespace SharpDvdInfo.Tests { @@ -31,8 +32,8 @@ public void DvdInfoContainerTest() foreach (var chapter in result[0].Chapters) { Console.WriteLine(chapter); - Assert.IsTrue(expectResult[index].Name == chapter.Name); - Assert.IsTrue(expectResult[index].Time == chapter.Time.Time2String()); + expectResult[index].Name.Should().Be(chapter.Name); + expectResult[index].Time.Should().Be(chapter.Time.Time2String()); ++index; } } diff --git a/Time_Shift_Test/Time_Shift_Test.csproj b/Time_Shift_Test/Time_Shift_Test.csproj index 8684e20..74aa1a8 100644 --- a/Time_Shift_Test/Time_Shift_Test.csproj +++ b/Time_Shift_Test/Time_Shift_Test.csproj @@ -59,7 +59,17 @@ true + + ..\packages\FluentAssertions.4.14.0\lib\net45\FluentAssertions.dll + True + + + ..\packages\FluentAssertions.4.14.0\lib\net45\FluentAssertions.Core.dll + True + + + @@ -93,6 +103,9 @@ Time_Shift + + + diff --git a/Time_Shift_Test/Util/CueDataTests.cs b/Time_Shift_Test/Util/CueDataTests.cs index 47d8e15..ed730b6 100644 --- a/Time_Shift_Test/Util/CueDataTests.cs +++ b/Time_Shift_Test/Util/CueDataTests.cs @@ -3,6 +3,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System.IO; using ChapterTool.Util.ChapterData; +using FluentAssertions; namespace ChapterTool.Util.Tests { @@ -30,8 +31,8 @@ public void PraseCueTest() foreach (var chapter in result.Chapters) { Console.WriteLine(chapter.ToString()); - Assert.IsTrue(expectResult[index].Name == chapter.Name); - Assert.IsTrue(expectResult[index].Time == chapter.Time.Time2String()); + expectResult[index].Name.Should().Be(chapter.Name); + expectResult[index].Time.Should().Be(chapter.Time.Time2String()); ++index; } } diff --git a/Time_Shift_Test/Util/ExpressionTests.cs b/Time_Shift_Test/Util/ExpressionTests.cs index 4ea16f7..9425d12 100644 --- a/Time_Shift_Test/Util/ExpressionTests.cs +++ b/Time_Shift_Test/Util/ExpressionTests.cs @@ -1,24 +1,27 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using ChapterTool.Util; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using FluentAssertions; namespace ChapterTool.Util.Tests { [TestClass()] public class ExpressionTests { + private static void EvalAreEqual(decimal expected, string actual) + { + new Expression(actual).Eval().Should().Be(expected); + } + private static void EvalAreNearly(decimal expected, string actual) + { + Math.Abs(new Expression(actual).Eval() - expected).Should().BeLessThan(1e-10M); + } + [TestMethod()] public void ExpressionConverTest() { - var ret = new Expression("2^10%10 + 6 \t///comment sample"); - Assert.AreEqual("2 10 ^ 10 % 6 +", ret.ToString()); - ret = new Expression("((a+b)*(c+d))/(((e)))"); - Assert.AreEqual("a b + c d + * e /", ret.ToString()); + new Expression("2^10%10 + 6 \t///comment sample").ToString().Should().Be("2 10 ^ 10 % 6 +"); + new Expression("((a+b)*(c+d))/(((e)))").ToString().Should().Be("a b + c d + * e /"); } [TestMethod()] @@ -26,51 +29,34 @@ public void ExpressionPostFixTest() { var ret = new Expression("a b + c d + * e /".Split()); var exp = new Expression("((a+b)*(c+d))/(((e)))"); - Assert.AreEqual("((a + b) * (c + d)) / e", Expression.Postfix2Infix(ret.ToString())); - Assert.AreEqual(exp.ToString(), ret.ToString()); + "((a + b) * (c + d)) / e".Should().Be(Expression.Postfix2Infix(ret.ToString())); + exp.ToString().Should().Be(ret.ToString()); } [TestMethod()] public void ExpressionWEvalTest() { - var ret = new Expression("1+1/2+1/3+1/4+1/5+1/6+1/7+1/8+1/9+1/10"); - Assert.AreEqual(2.9289682539682539682539682539682539M, ret.Eval()); - ret = new Expression("1-1/2-1/4+1/8-1/16+1/32-1/64+1/128-1/256+1/512-1/1024"); - Assert.AreEqual(0.3330078125M, ret.Eval()); - ret = new Expression("1-(1/2)-(1/4)+(1/8)-(1/16)+(1/32)-(1/64)+(1/128)-(1/256)+(1/512)-(1/1024)"); - Assert.AreEqual(0.3330078125M, ret.Eval()); - ret = new Expression("2^2^2^2"); - Console.WriteLine($"without bracket: {ret}"); - Assert.AreEqual(256, ret.Eval()); - ret = new Expression("2^(2^(2^2))"); - Console.WriteLine($"with bracket: {ret}"); - Assert.AreEqual(65536, ret.Eval()); - } - - private static void EvalAreEqual(decimal expected, string actual) - { - Assert.AreEqual(expected, new Expression(actual).Eval()); - } - private static void EvalAreNearly(decimal expected, string actual) - { - var ret = new Expression(actual).Eval(); - Assert.IsTrue(Math.Abs(ret - expected) < 1e-10M); + EvalAreEqual(2.9289682539682539682539682539682539M, "1+1/2+1/3+1/4+1/5+1/6+1/7+1/8+1/9+1/10"); + EvalAreEqual(0.3330078125M, "1-1/2-1/4+1/8-1/16+1/32-1/64+1/128-1/256+1/512-1/1024"); + EvalAreEqual(0.3330078125M, "1-(1/2)-(1/4)+(1/8)-(1/16)+(1/32)-(1/64)+(1/128)-(1/256)+(1/512)-(1/1024)"); + EvalAreEqual(256, "2^2^2^2"); + EvalAreEqual(65536, "2^(2^(2^2))"); } [TestMethod()] public void EmptyExpressionTest() { - var ret = new Expression(""); - Assert.AreEqual("", ret.ToString()); - Assert.AreEqual(0M, ret.Eval()); + var ret = new Expression(string.Empty); + ret.ToString().Should().BeEmpty(); + ret.Eval().Should().Be(0M); } [TestMethod()] public void ExpressionWithFunctionTest() { var ret = new Expression("floor(1.133) + floor(log10(1023)) - ceil(0.9)"); - Assert.AreEqual("1.133 floor 1023 log10 floor + 0.9 ceil -", ret.ToString()); - Assert.AreEqual(3M, ret.Eval()); + ret.ToString().Should().Be("1.133 floor 1023 log10 floor + 0.9 ceil -"); + ret.Eval().Should().Be(3M); } [TestMethod()] @@ -116,7 +102,7 @@ public void Uva12803Test() { var exp = new Expression(input[i]); var tmp = exp.Eval().ToString("0.00"); - Assert.AreEqual(output[i], tmp); + tmp.Should().Be(output[i]); Console.Write($"{tmp} "); } timer.Stop(); @@ -126,8 +112,8 @@ public void Uva12803Test() [TestMethod()] public void Postfix2InfixTest() { - Assert.AreEqual("((x + (y * 64)) + (z * 256)) / 3", Expression.Postfix2Infix("x y 64 * + z 256 * + 3 /")); - Assert.AreEqual("((x + y) + z) / 3", Expression.Postfix2Infix("x y + z + 3 /")); + Expression.Postfix2Infix("x y 64 * + z 256 * + 3 /").Should().Be("((x + (y * 64)) + (z * 256)) / 3"); + Expression.Postfix2Infix("x y + z + 3 /").Should().Be("((x + y) + z) / 3"); } } } diff --git a/Time_Shift_Test/Util/IfoDataTests.cs b/Time_Shift_Test/Util/IfoDataTests.cs index d343fbf..4163828 100644 --- a/Time_Shift_Test/Util/IfoDataTests.cs +++ b/Time_Shift_Test/Util/IfoDataTests.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using ChapterTool.Util.ChapterData; +using FluentAssertions; namespace ChapterTool.Util.Tests { @@ -34,8 +35,8 @@ public void IfoDataTest() foreach (var chapter in result[0].Chapters) { Console.WriteLine(chapter); - Assert.IsTrue(expectResult[index].Name == chapter.Name); - Assert.IsTrue(expectResult[index].Time == chapter.Time.Time2String()); + expectResult[index].Name.Should().Be(chapter.Name); + expectResult[index].Time.Should().Be(chapter.Time.Time2String()); ++index; } } diff --git a/Time_Shift_Test/Util/IfoParserTests.cs b/Time_Shift_Test/Util/IfoParserTests.cs index 465cd4a..725b488 100644 --- a/Time_Shift_Test/Util/IfoParserTests.cs +++ b/Time_Shift_Test/Util/IfoParserTests.cs @@ -2,6 +2,7 @@ using System.Text.RegularExpressions; using ChapterTool.Util.ChapterData; using Microsoft.VisualStudio.TestTools.UnitTesting; +using FluentAssertions; namespace ChapterTool.Util.Tests { @@ -18,7 +19,7 @@ public void BcdToIntTest() var result = Regex.Match(hex, @"\d{2}"); if (result.Success) { - Assert.IsTrue(int.Parse(hex) == IfoParser.BcdToInt((byte)i)); + int.Parse(hex).Should().Be(IfoParser.BcdToInt((byte)i)); Console.Write($"[{hex}->{IfoParser.BcdToInt((byte)i):D3}] "); ++validValueCount; } diff --git a/Time_Shift_Test/Util/MplsDataTests.cs b/Time_Shift_Test/Util/MplsDataTests.cs index 82d4597..f3f0ec9 100644 --- a/Time_Shift_Test/Util/MplsDataTests.cs +++ b/Time_Shift_Test/Util/MplsDataTests.cs @@ -4,6 +4,7 @@ using System; using System.IO; using ChapterTool.Util.ChapterData; +using FluentAssertions; namespace ChapterTool.Util.Tests { @@ -20,15 +21,16 @@ public void MplsDataTest1() Console.WriteLine(mplsRaw.ToString()); var expectedTimeStamps = new List { 0, 648750, 984375, 23799375, 27487500, 28044375, 28276875, 28918125, 29195625, 36823125, 41679375, 52321875, 56593125, 62563125, 73524375, 83199375, 95167500, 100741875, 106155000, 116420625, 120845625, 126307500, 129403125, 139273125, 141071250, 142704375, 147866250, 151578750, 157603125, 163599375, 170810625, 178768125, 186941250, 191786250, 192165000, 202076250, 213168750, 222028125, 228003750, 236915625, 244306875, 253316250, 260053125, 271863750, 284366250, 285738750 }; - var offset = mplsRaw.ChapterClips.First().TimeStamp.First(); - Assert.IsTrue(mplsRaw.ChapterClips.Count == 1); - Assert.IsTrue(mplsRaw.ChapterClips.First().TimeStamp.Select(item => item - offset).SequenceEqual(expectedTimeStamps)); - Assert.IsTrue(mplsRaw.ChapterClips.First().Name == "00002"); - Assert.IsTrue(mplsRaw.ChapterClips.First().Fps == 2); - Assert.IsTrue(mplsRaw.ChapterClips.First().TimeIn == 188460000); - Assert.IsTrue(mplsRaw.ChapterClips.First().TimeOut == 474480000); - Assert.IsTrue(mplsRaw.ChapterClips.First().Length == 286020000); - Assert.IsTrue(mplsRaw.EntireClip.TimeStamp.SequenceEqual(expectedTimeStamps)); + mplsRaw.ChapterClips.Should().HaveCount(1); + var clip = mplsRaw.ChapterClips.First(); + var offset = clip.TimeStamp.First(); + clip.TimeStamp.Select(item => item - offset).Should().Equal(expectedTimeStamps); + clip.Name.Should().Be("00002"); + clip.Fps.Should().Be(2); + clip.TimeIn.Should().Be(188460000); + clip.TimeOut.Should().Be(474480000); + clip.Length.Should().Be(286020000); + mplsRaw.EntireClip.TimeStamp.Should().Equal(expectedTimeStamps); } [TestMethod()] @@ -38,16 +40,18 @@ public void MplsDataTest2() if (!File.Exists(mplsPath)) mplsPath = @"..\" + mplsPath; var mplsRaw = new MplsData(mplsPath); Console.WriteLine(mplsRaw.ToString()); + var expectedTimeStamps = new List { 0, 41963170, 96516418, 96831733, 98138038, 102186457, 131841081, 158573411, 162621830 }; - var offset = mplsRaw.ChapterClips.First().TimeStamp.First(); - Assert.IsTrue(mplsRaw.ChapterClips.Count == 1); - Assert.IsTrue(mplsRaw.ChapterClips.First().TimeStamp.Select(item => item - offset).SequenceEqual(expectedTimeStamps)); - Assert.IsTrue(mplsRaw.ChapterClips.First().Name == "00001"); - Assert.IsTrue(mplsRaw.ChapterClips.First().Fps == 1); - Assert.IsTrue(mplsRaw.ChapterClips.First().TimeIn == 90000); - Assert.IsTrue(mplsRaw.ChapterClips.First().TimeOut == 163027149); - Assert.IsTrue(mplsRaw.ChapterClips.First().Length == 162937149); - Assert.IsTrue(mplsRaw.EntireClip.TimeStamp.SequenceEqual(expectedTimeStamps)); + mplsRaw.ChapterClips.Should().HaveCount(1); + var clip = mplsRaw.ChapterClips.First(); + var offset = clip.TimeStamp.First(); + clip.TimeStamp.Select(item => item - offset).Should().Equal(expectedTimeStamps); + clip.Name.Should().Be("00001"); + clip.Fps.Should().Be(1); + clip.TimeIn.Should().Be(90000); + clip.TimeOut.Should().Be(163027149); + clip.Length.Should().Be(162937149); + mplsRaw.EntireClip.TimeStamp.Should().Equal(expectedTimeStamps); } [TestMethod()] @@ -58,7 +62,7 @@ public void MplsDataTest3() var mplsRaw = new MplsData(mplsPath); Console.WriteLine(mplsRaw.ToString()); - Assert.IsTrue(mplsRaw.ChapterClips.Count == 9); + mplsRaw.ChapterClips.Should().HaveCount(9); var expectedClip = new List> { new List {189000000}, @@ -73,21 +77,15 @@ public void MplsDataTest3() }; for (int i = 0; i < 9; i++) { - Assert.IsTrue(mplsRaw.ChapterClips[i].TimeStamp.SequenceEqual(expectedClip[i])); - } - var expectedClipName = new List { "00005", "00006&00007", "00008", "00009&00010", "00011", "00012", "00013&00014", "00015", "00016" }; - for (int i = 0; i < 9; i++) - { - Assert.IsTrue(mplsRaw.ChapterClips[i].Name == expectedClipName[i]); - } - var expectedClipLength = new List { 1664788, 4996241, 42184642, 5240235, 9862978, 58032975, 4881751, 1026650, 63947008 }; - for (int i = 0; i < 9; i++) - { - Assert.IsTrue(mplsRaw.ChapterClips[i].Length == expectedClipLength[i]); + mplsRaw.ChapterClips[i].TimeStamp.Should().Equal(expectedClip[i]); } - Assert.IsTrue(mplsRaw.ChapterClips.First().Fps == 1); - var expectedTimeStamps = new List { 0, 6661029, 27270993, 48845671, 54085906, 63676737, 63948884, 68134315, 72182734, 87212749, 121981859, 126863610, 127619990, 127890260, 136529515, 140581688, 155746838, 187516701, 191566998, 191792223 }; - Assert.IsTrue(mplsRaw.EntireClip.TimeStamp.SequenceEqual(expectedTimeStamps)); + mplsRaw.ChapterClips.Select(item => item.Name).Should().Equal("00005", "00006&00007", "00008", "00009&00010", "00011", "00012", "00013&00014", "00015", "00016"); + mplsRaw.ChapterClips.Select(item => item.Length).Should().Equal(1664788, 4996241, 42184642, 5240235, 9862978, 58032975, 4881751, 1026650, 63947008); + mplsRaw.ChapterClips.First().Fps.Should().Be(1); + mplsRaw.EntireClip.TimeStamp.Should() + .Equal(0, 6661029, 27270993, 48845671, 54085906, 63676737, 63948884, 68134315, 72182734, 87212749, + 121981859, 126863610, 127619990, 127890260, 136529515, 140581688, 155746838, 187516701, 191566998, + 191792223); } [TestMethod()] @@ -96,8 +94,9 @@ public void ToChapterInfoTest() string mplsPath = @"..\..\[mpls_Sample]\00011_eva.mpls"; if (!File.Exists(mplsPath)) mplsPath = @"..\" + mplsPath; var mplsRaw = new MplsData(mplsPath); - var combinedCi = mplsRaw.ToChapterInfo(100, true); - Console.WriteLine(combinedCi.ToString()); + new Action(() => mplsRaw.ToChapterInfo(1, false)).ShouldThrow() + .WithMessage("Index of Video Clip out of range"); + Console.WriteLine(mplsRaw.ToChapterInfo(100, true).ToString()); } } } \ No newline at end of file diff --git a/Time_Shift_Test/Util/OgmDataTests.cs b/Time_Shift_Test/Util/OgmDataTests.cs index c41b022..9fe923d 100644 --- a/Time_Shift_Test/Util/OgmDataTests.cs +++ b/Time_Shift_Test/Util/OgmDataTests.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using ChapterTool.Util.ChapterData; +using FluentAssertions; namespace ChapterTool.Util.Tests { @@ -35,8 +36,8 @@ public void OgmDataTest() foreach (var chapter in result.Chapters) { Console.WriteLine(chapter); - Assert.IsTrue(expectResult[index].Name == chapter.Name); - Assert.IsTrue(expectResult[index].Time == chapter.Time.Time2String()); + expectResult[index].Name.Should().Be(chapter.Name); + expectResult[index].Time.Should().Be(chapter.Time.Time2String()); ++index; } } diff --git a/Time_Shift_Test/Util/ToolKitsTests.cs b/Time_Shift_Test/Util/ToolKitsTests.cs index c5e2965..c06e615 100644 --- a/Time_Shift_Test/Util/ToolKitsTests.cs +++ b/Time_Shift_Test/Util/ToolKitsTests.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using FluentAssertions; namespace ChapterTool.Util.Tests { @@ -31,8 +32,8 @@ public void Time2StringTest() "04:15:01.456", "05:00:00.254" }; - Assert.IsTrue(tsList.Select(item => item.Time2String()).SequenceEqual(expectList)); - Assert.IsTrue(expectList.Select(item => item.ToTimeSpan()).SequenceEqual(tsList)); + tsList.Select(item => item.Time2String()).Should().Equal(expectList); + expectList.Select(item => item.ToTimeSpan()).Should().Equal(tsList); } [TestMethod()] @@ -41,7 +42,7 @@ public void ConvertFr2IndexTest() var frameRate = new List { 0, 24000D / 1001, 24D, 25D, 30000D / 1001, 50D, 60000D / 1001 }; var expected = new List {0, 1, 2, 3, 4, 6, 7}; frameRate.Select(ToolKits.ConvertFr2Index).ToList().ForEach(Console.Write); - Assert.IsTrue(frameRate.Select(ToolKits.ConvertFr2Index).SequenceEqual(expected)); + frameRate.Select(ToolKits.ConvertFr2Index).Should().Equal(expected); } } } \ No newline at end of file diff --git a/Time_Shift_Test/packages.config b/Time_Shift_Test/packages.config new file mode 100644 index 0000000..9220db0 --- /dev/null +++ b/Time_Shift_Test/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 754b5d14f1a42c591148ace1d6966a166372e4b1 Mon Sep 17 00:00:00 2001 From: tautcony Date: Fri, 16 Sep 2016 20:38:24 +0800 Subject: [PATCH 03/30] Bind Alt+num to type switching. --- Time_Shift/Forms/Form1.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index fefc2f4..52acf16 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -95,6 +95,18 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) case Keys.Control | Keys.D9: SwitchByHotKey(keyData); return true; + case Keys.Alt | Keys.D0: + case Keys.Alt | Keys.D1: + case Keys.Alt | Keys.D2: + case Keys.Alt | Keys.D3: + case Keys.Alt | Keys.D4: + case Keys.Alt | Keys.D5: + case Keys.Alt | Keys.D6: + case Keys.Alt | Keys.D7: + case Keys.Alt | Keys.D8: + case Keys.Alt | Keys.D9: + SwitchTypeByHotKey(keyData); + return true; case Keys.PageDown: if (comboBox2.SelectedIndex + 1 < comboBox2.Items.Count) { @@ -140,6 +152,15 @@ private void SwitchByHotKey(Keys keyData) tsTips.Text = Resources.Tips_Out_Of_Range; } } + + private void SwitchTypeByHotKey(Keys keyData) + { + Keys numKey = keyData ^ Keys.Alt; + Debug.WriteLine(numKey); + int index = numKey - Keys.D0; + if (index < 0 || index > savingType.Items.Count) return; + savingType.SelectedIndex = index - 1; + } #endregion #region Inital From d727a3982b48c03bd4eb90db53ca9b167d597a3d Mon Sep 17 00:00:00 2001 From: tautcony Date: Fri, 16 Sep 2016 20:38:38 +0800 Subject: [PATCH 04/30] Add class DualDict. --- Time_Shift/Util/DualDictionary.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Time_Shift/Util/DualDictionary.cs diff --git a/Time_Shift/Util/DualDictionary.cs b/Time_Shift/Util/DualDictionary.cs new file mode 100644 index 0000000..3dd4c3c --- /dev/null +++ b/Time_Shift/Util/DualDictionary.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; + +namespace ChapterTool.Util +{ + public class DualDictionary + { + private readonly Dictionary _dataS2I = new Dictionary(); + private readonly Dictionary _dataI2S = new Dictionary(); + + public T1 this[T2 index] => _dataI2S[index]; + public T2 this[T1 type] => _dataS2I[type]; + + public void Bind(T2 id, T1 type) + { + _dataI2S[id] = type; + _dataS2I[type] = id; + } + public void Bind(T1 type, T2 id) + { + _dataI2S[id] = type; + _dataS2I[type] = id; + } + } +} From 9c22dab7c28525b718691dba9d0e85e4f6b53da5 Mon Sep 17 00:00:00 2001 From: tautcony Date: Fri, 16 Sep 2016 20:39:34 +0800 Subject: [PATCH 05/30] Add expression type explicit conversion. --- Time_Shift/Util/Expression.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Time_Shift/Util/Expression.cs b/Time_Shift/Util/Expression.cs index 7fa6799..9b8ad11 100644 --- a/Time_Shift/Util/Expression.cs +++ b/Time_Shift/Util/Expression.cs @@ -400,6 +400,8 @@ public decimal Eval() } } + public static explicit operator decimal(Expression expr) => expr.Eval(); + private static string RemoveBrackets(string x) { if (x.First() == '(' && x.Last() == ')') From a2fd784accfde64d5f98de3154c8a4fc7946f6e1 Mon Sep 17 00:00:00 2001 From: tautcony Date: Fri, 16 Sep 2016 20:39:46 +0800 Subject: [PATCH 06/30] Improve unit test. --- Time_Shift_Test/Util/ExpressionTests.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Time_Shift_Test/Util/ExpressionTests.cs b/Time_Shift_Test/Util/ExpressionTests.cs index 9425d12..b4deb8a 100644 --- a/Time_Shift_Test/Util/ExpressionTests.cs +++ b/Time_Shift_Test/Util/ExpressionTests.cs @@ -14,7 +14,7 @@ private static void EvalAreEqual(decimal expected, string actual) } private static void EvalAreNearly(decimal expected, string actual) { - Math.Abs(new Expression(actual).Eval() - expected).Should().BeLessThan(1e-10M); + new Expression(actual).Eval().Should().BeInRange(expected - 1e-10M, expected + 1e-10M); } [TestMethod()] @@ -91,22 +91,22 @@ public void FunctionLog10Test() [TestMethod()] public void Uva12803Test() { - var timer = new System.Diagnostics.Stopwatch(); - timer.Start(); string path = Directory.GetCurrentDirectory() + "\\..\\..\\"; if (!File.Exists(path + "Util\\expression.in")) path += "..\\"; path += "Util\\"; + + var timer = new System.Diagnostics.Stopwatch(); + timer.Start(); var input = File.ReadAllLines(path + "expression.in"); var output = File.ReadAllLines(path + "expression.out"); for (int i = 0; i < input.Length; ++i) { - var exp = new Expression(input[i]); - var tmp = exp.Eval().ToString("0.00"); + var tmp = new Expression(input[i]).Eval().ToString("0.00"); tmp.Should().Be(output[i]); Console.Write($"{tmp} "); } timer.Stop(); - Console.WriteLine($"Duration: {timer.Elapsed.Milliseconds}ms"); + Console.WriteLine($"\nDuration: {timer.Elapsed.Milliseconds}ms"); } [TestMethod()] From e07acfe7ec931a34ff7dc137ad333aaf0307b63f Mon Sep 17 00:00:00 2001 From: tautcony Date: Sun, 18 Sep 2016 21:24:13 +0800 Subject: [PATCH 07/30] Unify the function and the operator. --- Time_Shift/Util/Expression.cs | 78 +++++++++++------------------------ 1 file changed, 23 insertions(+), 55 deletions(-) diff --git a/Time_Shift/Util/Expression.cs b/Time_Shift/Util/Expression.cs index 9b8ad11..21fac12 100644 --- a/Time_Shift/Util/Expression.cs +++ b/Time_Shift/Util/Expression.cs @@ -122,6 +122,7 @@ public override string ToString() private static Token EvalCMath(Token func, Token value, Token value2 = null) { + if (func.ParaCount == 2) return EvalCMathTwoToken(func, value, value2); if (!FunctionTokens.ContainsKey(func.Value)) throw new Exception($"There is no function named {func.Value}"); var ret = new Token {TokenType = Token.Symbol.Number}; @@ -147,16 +148,27 @@ private static Token EvalCMath(Token func, Token value, Token value2 = null) case "int" : ret.Number = Math.Truncate(value.Number); break; case "sign" : ret.Number = Math.Sign(value.Number); break; } - if (func.ParaCount == 2) + return ret; + } + + private static Token EvalCMathTwoToken(Token func, Token value, Token value2) + { + if (!FunctionTokens.ContainsKey(func.Value) && !OperatorTokens.Contains(func.Value)) + throw new Exception($"There is no function/operator named {func.Value}"); + var ret = new Token {TokenType = Token.Symbol.Number}; + if (value2 == null) throw new NullReferenceException(nameof(value2)); + switch (func.Value) { - if (value2 == null) throw new NullReferenceException(nameof(value2)); - switch (func.Value) - { - case "pow": ret.Number = (decimal)Math.Pow((double)value.Number, (double)value2.Number); break; - case "max": ret.Number = Math.Max(value.Number, value2.Number); break; - case "min": ret.Number = Math.Min(value.Number, value2.Number); break; - case "atan2": ret.Number = (decimal)Math.Atan2((double)value.Number, (double)value2.Number); break; - } + case "pow": ret.Number = (decimal)Math.Pow((double)value.Number, (double)value2.Number); break; + case "max": ret.Number = Math.Max(value.Number, value2.Number); break; + case "min": ret.Number = Math.Min(value.Number, value2.Number); break; + case "atan2": ret.Number = (decimal)Math.Atan2((double)value.Number, (double)value2.Number); break; + case "+": ret.Number = value.Number + value2.Number; break; + case "-": ret.Number = value.Number - value2.Number; break; + case "*": ret.Number = value.Number * value2.Number; break; + case "/": ret.Number = value.Number / value2.Number; break; + case "%": ret.Number = value.Number % value2.Number; break; + case "^": ret.Number = (decimal)Math.Pow((double)value.Number, (double)value2.Number); break; } return ret; } @@ -187,7 +199,7 @@ private static Token GetToken(string expr, ref int pos) case ',': return new Token($"{expr[i]}", Token.Symbol.Comma); default: - return new Token($"{expr[i]}", Token.Symbol.Operator); + return new Token($"{expr[i]}", Token.Symbol.Operator) {ParaCount = 2}; } } pos = i; @@ -332,15 +344,7 @@ public static decimal Eval(IEnumerable posfix, Dictionary Date: Sat, 24 Sep 2016 18:05:18 +0800 Subject: [PATCH 08/30] Make sure the saving data is latest. --- Time_Shift/Forms/Form1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index 52acf16..307fbd6 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -772,7 +772,7 @@ private string GeneRateSavePath(int saveType) private void SaveFile(int saveType) { if (!IsPathValid) return;//防止保存先于载入 - + UpdataGridView(); var savePath = GeneRateSavePath(saveType); SaveInfoLog(savePath); From a5999552f9979176fddc2164af899ba84a4aa3e6 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sat, 24 Sep 2016 21:16:31 +0800 Subject: [PATCH 09/30] Improve function ProcessCmdKey. --- Time_Shift/Forms/Form1.cs | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index 307fbd6..f4413d4 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -60,6 +60,16 @@ public Form1(string args) #region HotKey protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { + if ((keyData ^ Keys.Control) >= Keys.D0 && (keyData ^ Keys.Control) <= Keys.D9) + { + SwitchByHotKey(keyData); + return true; + } + if ((keyData ^ Keys.Alt) >= Keys.D0 && (keyData ^ Keys.Alt) <= Keys.D9) + { + SwitchTypeByHotKey(keyData); + return true; + } switch (keyData) { case Keys.Control | Keys.S: @@ -83,30 +93,6 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData) case Keys.Control | Keys.R: UpdataGridView(); return true; - case Keys.Control | Keys.D0: - case Keys.Control | Keys.D1: - case Keys.Control | Keys.D2: - case Keys.Control | Keys.D3: - case Keys.Control | Keys.D4: - case Keys.Control | Keys.D5: - case Keys.Control | Keys.D6: - case Keys.Control | Keys.D7: - case Keys.Control | Keys.D8: - case Keys.Control | Keys.D9: - SwitchByHotKey(keyData); - return true; - case Keys.Alt | Keys.D0: - case Keys.Alt | Keys.D1: - case Keys.Alt | Keys.D2: - case Keys.Alt | Keys.D3: - case Keys.Alt | Keys.D4: - case Keys.Alt | Keys.D5: - case Keys.Alt | Keys.D6: - case Keys.Alt | Keys.D7: - case Keys.Alt | Keys.D8: - case Keys.Alt | Keys.D9: - SwitchTypeByHotKey(keyData); - return true; case Keys.PageDown: if (comboBox2.SelectedIndex + 1 < comboBox2.Items.Count) { From 40f30ed0f3c5865b33e8b7772d37b7b8f2b7d02c Mon Sep 17 00:00:00 2001 From: tautcony Date: Tue, 4 Oct 2016 20:43:37 +0800 Subject: [PATCH 10/30] Add append chapter for mpls. --- Time_Shift/Forms/Form1.Designer.cs | 52 +++++++++++++++++++------ Time_Shift/Forms/Form1.cs | 62 +++++++++++++++++++++--------- Time_Shift/Forms/Form1.resx | 17 +++++++- 3 files changed, 100 insertions(+), 31 deletions(-) diff --git a/Time_Shift/Forms/Form1.Designer.cs b/Time_Shift/Forms/Form1.Designer.cs index f765207..bada5ba 100644 --- a/Time_Shift/Forms/Form1.Designer.cs +++ b/Time_Shift/Forms/Form1.Designer.cs @@ -49,6 +49,7 @@ private void InitializeComponent() this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.cbPostFix = new System.Windows.Forms.CheckBox(); this.btnLog = new System.Windows.Forms.Button(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.cOrder = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -69,7 +70,9 @@ private void InitializeComponent() this.tsTips = new System.Windows.Forms.ToolStripStatusLabel(); this.tsProgressBar1 = new System.Windows.Forms.ToolStripProgressBar(); this.tsBtnExpand = new System.Windows.Forms.ToolStripDropDownButton(); - this.cbPostFix = new System.Windows.Forms.CheckBox(); + this.loadMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.reloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.appendToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deviationMenuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); this.combineMenuStrip.SuspendLayout(); @@ -77,10 +80,12 @@ private void InitializeComponent() this.createZonestMenuStrip.SuspendLayout(); this.panel1.SuspendLayout(); this.statusStrip1.SuspendLayout(); + this.loadMenuStrip.SuspendLayout(); this.SuspendLayout(); // // btnLoad // + this.btnLoad.ContextMenuStrip = this.loadMenuStrip; this.btnLoad.FlatAppearance.BorderColor = System.Drawing.SystemColors.Highlight; this.btnLoad.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(184)))), ((int)(((byte)(184))))); this.btnLoad.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(207)))), ((int)(((byte)(207)))), ((int)(((byte)(207))))); @@ -94,7 +99,6 @@ private void InitializeComponent() this.btnLoad.Text = "载入"; this.btnLoad.UseVisualStyleBackColor = true; this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); - this.btnLoad.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnLoad_MouseUp); // // btnSave // @@ -304,6 +308,17 @@ private void InitializeComponent() // this.openFileDialog1.Title = "打开文件"; // + // cbPostFix + // + this.cbPostFix.AutoSize = true; + this.cbPostFix.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.cbPostFix.Location = new System.Drawing.Point(285, 45); + this.cbPostFix.Name = "cbPostFix"; + this.cbPostFix.Size = new System.Drawing.Size(12, 11); + this.cbPostFix.TabIndex = 32; + this.toolTip1.SetToolTip(this.cbPostFix, "逆波兰表达式"); + this.cbPostFix.UseVisualStyleBackColor = true; + // // btnLog // this.btnLog.FlatAppearance.BorderColor = System.Drawing.SystemColors.Highlight; @@ -538,16 +553,27 @@ private void InitializeComponent() this.tsBtnExpand.Text = "toolStripDropDownButton1"; this.tsBtnExpand.Click += new System.EventHandler(this.btnExpand_Click); // - // cbPostFix + // loadMenuStrip // - this.cbPostFix.AutoSize = true; - this.cbPostFix.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.cbPostFix.Location = new System.Drawing.Point(285, 45); - this.cbPostFix.Name = "cbPostFix"; - this.cbPostFix.Size = new System.Drawing.Size(12, 11); - this.cbPostFix.TabIndex = 32; - this.toolTip1.SetToolTip(this.cbPostFix, "逆波兰表达式"); - this.cbPostFix.UseVisualStyleBackColor = true; + this.loadMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.reloadToolStripMenuItem, + this.appendToolStripMenuItem}); + this.loadMenuStrip.Name = "loadMenuStrip"; + this.loadMenuStrip.Size = new System.Drawing.Size(153, 70); + // + // reloadToolStripMenuItem + // + this.reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; + this.reloadToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.reloadToolStripMenuItem.Text = "重新载入"; + this.reloadToolStripMenuItem.Click += new System.EventHandler(this.reloadToolStripMenuItem_Click); + // + // appendToolStripMenuItem + // + this.appendToolStripMenuItem.Name = "appendToolStripMenuItem"; + this.appendToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.appendToolStripMenuItem.Text = "追加合并"; + this.appendToolStripMenuItem.Click += new System.EventHandler(this.appendToolStripMenuItem_Click); // // Form1 // @@ -590,6 +616,7 @@ private void InitializeComponent() this.panel1.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); + this.loadMenuStrip.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -637,6 +664,9 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem ShiftForwardToolStripMenuItem; private System.Windows.Forms.TextBox textBoxExpression; private System.Windows.Forms.CheckBox cbPostFix; + private System.Windows.Forms.ContextMenuStrip loadMenuStrip; + private System.Windows.Forms.ToolStripMenuItem reloadToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem appendToolStripMenuItem; } } diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index f4413d4..e4e4691 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -423,7 +423,8 @@ private bool Loadfile() } switch (fileType) { - case FileType.Mpls: LoadMpls(); break; + case FileType.Mpls: + LoadMpls(out _rawMpls); break; case FileType.Xml : LoadXml(); break; case FileType.Txt : LoadOgm(); break; case FileType.Ifo : LoadIfo(); break; @@ -460,31 +461,28 @@ private bool Loadfile() return true; } - private void btnLoad_MouseUp(object sender, MouseEventArgs e) - { - //Reload File - if (e.Button != MouseButtons.Right || string.IsNullOrEmpty(FilePath)) return; - if (_isUrl) LoadBDMV(); - else if (Loadfile()) UpdataGridView(); - } - - private void LoadMpls() + private void LoadMpls(out MplsData rawMpls, bool display = true, string customPath = "") { MplsData.OnLog += Log; - _rawMpls = new MplsData(FilePath); + if (string.IsNullOrEmpty(customPath)) + customPath = FilePath; + rawMpls = new MplsData(customPath); MplsData.OnLog -= Log; Log(Resources.Log_MPLS_Load_Success); - Log(string.Format(Resources.Log_MPLS_Clip_Count, _rawMpls.ChapterClips.Count)); - - comboBox2.Enabled = comboBox2.Visible = _rawMpls.ChapterClips.Count >= 1; - if (!comboBox2.Enabled) return; - comboBox2.Items.Clear(); - foreach(var item in _rawMpls.ChapterClips) + Log(string.Format(Resources.Log_MPLS_Clip_Count, rawMpls.ChapterClips.Count)); + if (display) + { + comboBox2.Enabled = comboBox2.Visible = rawMpls.ChapterClips.Count >= 1; + if (!comboBox2.Enabled) return; + comboBox2.Items.Clear(); + } + foreach(var item in rawMpls.ChapterClips) { - comboBox2.Items.Add($"{item.Name}__{item.TimeStamp.Count}"); - Log($" |+{item.Name} Duration[{MplsData.Pts2Time(item.Length).Time2String()}]"); + if (display) comboBox2.Items.Add($"{item.Name}__{item.TimeStamp.Count}"); + Log($" |+{item.Name} Duration[{MplsData.Pts2Time(item.Length).Time2String()}]{{{MplsData.Pts2Time(item.Length).TotalSeconds}}}"); Log(string.Format(Resources.Log_TimeStamp_Count, item.TimeStamp.Count)); } + if (!display) return; comboBox2.SelectedIndex = ClipSeletIndex; GetChapterInfoFromMpls(ClipSeletIndex); } @@ -682,6 +680,32 @@ private async void LoadBDMV() #endregion + #region AppendFile + private void reloadToolStripMenuItem_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(FilePath)) return; + if (_isUrl) LoadBDMV(); + else if (Loadfile()) UpdataGridView(); + } + + private void appendToolStripMenuItem_Click(object sender, EventArgs e) + { + if (_rawMpls == null) return; + string dir = Path.GetDirectoryName(FilePath); + openFileDialog1.Filter = @"appendable file(mpls file)|*.mpls"; + openFileDialog1.InitialDirectory = dir; + if (openFileDialog1.ShowDialog() != DialogResult.OK) return; + string newFile = openFileDialog1.FileName; + MplsData appendMpls; + LoadMpls(out appendMpls, false, newFile); + _rawMpls.EntireClip.TimeStamp.AddRange(appendMpls.EntireClip.TimeStamp.Select(stamp=>stamp+ _rawMpls.EntireClip.Length)); + _rawMpls.EntireClip.Length += appendMpls.EntireClip.Length; + CombineChapter = true; + GetChapterInfoFromMpls(ClipSeletIndex); + UpdataGridView(); + } + #endregion + #region Save File private void btnSave_Click(object sender, EventArgs e) => SaveFile(savingType.SelectedIndex); diff --git a/Time_Shift/Forms/Form1.resx b/Time_Shift/Forms/Form1.resx index d04343e..a203745 100644 --- a/Time_Shift/Forms/Form1.resx +++ b/Time_Shift/Forms/Form1.resx @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 1058, 20 + 489, 18 @@ -147,11 +150,23 @@ True + + True + + + True + + + True + + + True + 755, 18 - 17, 56 + 937, 20 From f506f51df984dce9506d2eba376456df84109381 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sun, 9 Oct 2016 15:32:45 +0800 Subject: [PATCH 11/30] Add hints for below .Net4.6 --- Time_Shift/Program.cs | 25 +++++++++++++++++++-- Time_Shift/Properties/Resources.Designer.cs | 9 ++++++++ Time_Shift/Properties/Resources.resx | 3 +++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Time_Shift/Program.cs b/Time_Shift/Program.cs index 4db937f..1c7b4c1 100644 --- a/Time_Shift/Program.cs +++ b/Time_Shift/Program.cs @@ -1,5 +1,8 @@ using System; using System.Windows.Forms; +using System.Linq; +using ChapterTool.Properties; +using Microsoft.Win32; namespace ChapterTool { @@ -12,16 +15,34 @@ static void Main(string[] args) Application.SetCompatibleTextRenderingDefault(false); + CheckDotNetVersion(); if (args.Length == 0) { Application.Run(new Forms.Form1()); } else { - string argsFull = string.Join(" ", args); - //argsFull = "\"" + argsFull + "\""; + var option = args.TakeWhile(item => item.StartsWith("--")); + string argsFull = string.Join(" ", args.SkipWhile(item => item.StartsWith("--"))); Application.Run(new Forms.Form1(argsFull)); } } + + private static void CheckDotNetVersion() + { + var doCheck = Util.RegistryStorage.Load(name: "DoVersionCheck"); + if (doCheck == "False") return; + int dotNetVersion; + var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"); + if (key == null) dotNetVersion = 0; + else dotNetVersion = (int)(key.GetValue("Release")); + //https://msdn.microsoft.com/en-us/library/hh925568 + if (dotNetVersion >= 394802) return; + var ret = Util.Notification.ShowInfo(Resources.Message_Need_Newer_dotNet); + if (ret == DialogResult.Yes) + { + Util.RegistryStorage.Save("False", name: "DoVersionCheck"); + } + } } } diff --git a/Time_Shift/Properties/Resources.Designer.cs b/Time_Shift/Properties/Resources.Designer.cs index eb26ee1..3e7430f 100644 --- a/Time_Shift/Properties/Resources.Designer.cs +++ b/Time_Shift/Properties/Resources.Designer.cs @@ -575,6 +575,15 @@ internal static string Message_How_Can_You_Find_Here { } } + /// + /// 查找类似 需要 .Net4.6 或以上版本以保证所有功能正常运作,是否不再提示? 的本地化字符串。 + /// + internal static string Message_Need_Newer_dotNet { + get { + return ResourceManager.GetString("Message_Need_Newer_dotNet", resourceCulture); + } + } + /// /// 查找类似 使用 Chapter Tool 打开 .mpls 文件? 的本地化字符串。 /// diff --git a/Time_Shift/Properties/Resources.resx b/Time_Shift/Properties/Resources.resx index 2ece56e..ee5c4e9 100644 --- a/Time_Shift/Properties/Resources.resx +++ b/Time_Shift/Properties/Resources.resx @@ -355,4 +355,7 @@ 载入失败… + + 需要 .Net4.6 或以上版本以保证所有功能正常运作,是否不再提示? + \ No newline at end of file From 843eec424a1063b22ac9b83f6c09797d56e82df3 Mon Sep 17 00:00:00 2001 From: tautcony Date: Tue, 18 Oct 2016 22:14:32 +0800 Subject: [PATCH 12/30] Port Chapter2QPfile into C#. --- Time_Shift/Util/ChapterInfo.cs | 94 ++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 11 deletions(-) diff --git a/Time_Shift/Util/ChapterInfo.cs b/Time_Shift/Util/ChapterInfo.cs index 842e146..f958d23 100644 --- a/Time_Shift/Util/ChapterInfo.cs +++ b/Time_Shift/Util/ChapterInfo.cs @@ -17,6 +17,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // **************************************************************************** + using System; using System.IO; using System.Xml; @@ -70,11 +71,11 @@ public DataGridViewRow GetRow(int index, bool autoGenName) { var row = new DataGridViewRow { - Tag = Chapters[index], //绑定对象,以便删除行时可以得知对应的 Chapter - DefaultCellStyle = { BackColor = (Chapters[index].Number-1)%2 == 0 ? EVEN_COLOR : ODD_COLOR } + Tag = Chapters[index], //绑定对象,以便删除行时可以得知对应的 Chapter + DefaultCellStyle = {BackColor = (Chapters[index].Number - 1)%2 == 0 ? EVEN_COLOR : ODD_COLOR} }; row.Cells.Add(new DataGridViewTextBoxCell {Value = $"{Chapters[index].Number:D2}"}); - row.Cells.Add(new DataGridViewTextBoxCell {Value = Time2String(Chapters[index]) }); + row.Cells.Add(new DataGridViewTextBoxCell {Value = Time2String(Chapters[index])}); row.Cells.Add(new DataGridViewTextBoxCell {Value = autoGenName ? ChapterName.Get(index + 1) : Chapters[index].Name}); row.Cells.Add(new DataGridViewTextBoxCell {Value = Chapters[index].FramsInfo}); return row; @@ -124,7 +125,7 @@ public static ChapterInfo CombineChapter(List source, string type = Name = name.Get() }); } - duration += chapterClip.Duration;//每次加上当前段的总时长作为下一段位移的基准 + duration += chapterClip.Duration; //每次加上当前段的总时长作为下一段位移的基准 } fullChapter.Duration = duration; return fullChapter; @@ -140,12 +141,16 @@ public void ChangeFps(double fps) for (var i = 0; i < Chapters.Count; i++) { Chapter c = Chapters[i]; - double frames = c.Time.TotalSeconds * FramesPerSecond; - Chapters[i] = new Chapter { Name = c.Name, Time = new TimeSpan((long)Math.Round(frames / fps * TimeSpan.TicksPerSecond)) }; + double frames = c.Time.TotalSeconds*FramesPerSecond; + Chapters[i] = new Chapter + { + Name = c.Name, + Time = new TimeSpan((long) Math.Round(frames/fps*TimeSpan.TicksPerSecond)) + }; } - double totalFrames = Duration.TotalSeconds * FramesPerSecond; - Duration = new TimeSpan((long)Math.Round(totalFrames / fps * TimeSpan.TicksPerSecond)); - FramesPerSecond = fps; + double totalFrames = Duration.TotalSeconds*FramesPerSecond; + Duration = new TimeSpan((long) Math.Round(totalFrames/fps*TimeSpan.TicksPerSecond)); + FramesPerSecond = fps; } #region updataInfo @@ -176,9 +181,9 @@ public void UpdataInfo(int shift) public void UpdataInfo(string chapterNameTemplate) { if (string.IsNullOrWhiteSpace(chapterNameTemplate)) return; - using (var cn = chapterNameTemplate.Trim(' ', '\r', '\n').Split('\n').ToList().GetEnumerator())//移除首尾多余空行 + using (var cn = chapterNameTemplate.Trim(' ', '\r', '\n').Split('\n').ToList().GetEnumerator()) //移除首尾多余空行 { - Chapters.ForEach(item => item.Name = cn.MoveNext() ? cn.Current : item.Name.Trim('\r'));//确保无多余换行符 + Chapters.ForEach(item => item.Name = cn.MoveNext() ? cn.Current : item.Name.Trim('\r')); //确保无多余换行符 } } @@ -207,6 +212,73 @@ public string GetText(bool autoGenName) public void SaveQpfile(string filename) => File.WriteAllLines(filename, Chapters.Select(c => c.FramsInfo.ToString().Replace("*", "I").Replace("K", "I")).ToArray()); + public static void Chapter2Qpfile(string ipath, string opath, double fps, string tcfile = "") + { + var ilines = File.ReadAllLines(ipath); + string[] tclines = null; + var olines = new List(); + int tcindex = 0, tcframe = 0; + if (!string.IsNullOrEmpty(tcfile)) + { + tclines = File.ReadAllLines(tcfile); + tcindex = 0; + foreach (var tcline in tclines) + { + if (char.IsDigit(tcline.Trim().First())) + { + tcframe = 0; + break; + } + ++tcindex; + if (tcindex >= tclines.Length) + throw new IndexOutOfRangeException("TC index out of range! TC file and Chapter file mismatch?"); + } + } + + foreach (var line in ilines.Select(i => i.Trim().ToLower())) + { + if (!line.StartsWith("chapter")) continue; + var segments = line.Substring(7).Split('='); + if (segments.Length < 2) continue; + if (!segments[0].All(char.IsDigit)) continue; + int index; + if (int.TryParse(segments[0], out index)) continue; + var times = segments[1].Split(':'); + if (times.Length > 3) continue; + var time = 0.0; + try + { + time = times.Aggregate(time, (current, t) => current*60 + double.Parse(t)); + } + catch (Exception) + { + continue; + } + int frame; + if (string.IsNullOrEmpty(tcfile)) frame = (int) (time + 0.001*fps); + else + { + var timeLower = (time - 0.0005)*1000; + while (true) + { + if (tclines != null && double.Parse(tclines[tcindex]) >= timeLower) break; + while (true) + { + ++tcindex; + if (tclines != null && tcindex >= tclines.Length) + throw new IndexOutOfRangeException( + "TC index out of range! TC file and Chapter file mismatch?"); + if (tclines != null && char.IsDigit(tclines[tcindex].Trim().First())) break; + } + ++tcframe; + } + frame = tcframe; + } + olines.Add($"{frame} I"); + } + File.WriteAllLines(opath, olines); + } + public void SaveCelltimes(string filename) => File.WriteAllLines(filename, Chapters.Select(c => ((long) Math.Round(c.Time.TotalSeconds*FramesPerSecond)).ToString()).ToArray()); public void SaveTsmuxerMeta(string filename) From 140d2cd57e7006e055ed65ef1abc433965429f49 Mon Sep 17 00:00:00 2001 From: tautcony Date: Tue, 18 Oct 2016 22:17:05 +0800 Subject: [PATCH 13/30] Add more operators (but still buggy. --- Time_Shift/Util/Expression.cs | 53 ++++++++++++++++++++----- Time_Shift_Test/Util/ExpressionTests.cs | 15 +++++++ 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/Time_Shift/Util/Expression.cs b/Time_Shift/Util/Expression.cs index 21fac12..a1ef17c 100644 --- a/Time_Shift/Util/Expression.cs +++ b/Time_Shift/Util/Expression.cs @@ -46,6 +46,7 @@ private Expression() { } public Expression(string expr) { + System.Windows.Forms.MessageBox.Show("HERE"); PostExpression = BuildPostExpressionStack(expr); } @@ -87,7 +88,7 @@ public override string ToString() private const string SpaceCharacter = " \t\n\v\f\r"; - private const string OperatorTokens = "()+-*/%^,"; + private const string OperatorTokens = "\0(\0)\0+\0-\0*\0/\0%\0^\0,\0>\0<\0<=\0>=\0and\0or\0xor\0"; private static readonly Dictionary FunctionTokens = new Dictionary { @@ -169,18 +170,30 @@ private static Token EvalCMathTwoToken(Token func, Token value, Token value2) case "/": ret.Number = value.Number / value2.Number; break; case "%": ret.Number = value.Number % value2.Number; break; case "^": ret.Number = (decimal)Math.Pow((double)value.Number, (double)value2.Number); break; + case ">": ret.Number = value.Number > value2.Number ? 1 : 0; ret.TokenType = Token.Symbol.Boolean; break; + case "<": ret.Number = value.Number < value2.Number ? 1 : 0; ret.TokenType = Token.Symbol.Boolean; break; + case ">=": ret.Number = value.Number >= value2.Number ? 1 : 0; ret.TokenType = Token.Symbol.Boolean; break; + case "<=": ret.Number = value.Number <= value2.Number ? 1 : 0; ret.TokenType = Token.Symbol.Boolean; break; + case "and": ret.Number = (value.Number != 0M) && (value2.Number != 0M) ? 1 : 0; ret.TokenType = Token.Symbol.Boolean; break; + case "or": ret.Number = (value.Number != 0M) || (value2.Number != 0M) ? 1 : 0; ret.TokenType = Token.Symbol.Boolean; break; + case "xor": var t1 = value.Number != 0; var t2 = value.Number != 0; ret.Number = t1 ^ t2 ? 1 : 0; ret.TokenType = Token.Symbol.Boolean; break; } return ret; } + private static Token GetToken(string expr, ref int pos) { var varRet = new StringBuilder(); int i = pos; for (; i < expr.Length; i++) { - if (IsSpace(expr[i])) continue; - + if (IsSpace(expr[i])) + { + if (varRet.Length != 0) + break; + continue; + } if (IsDigit(expr[i]) || IsAlpha(expr[i])) { varRet.Append(expr[i]); @@ -192,6 +205,12 @@ private static Token GetToken(string expr, ref int pos) if (!OperatorTokens.Contains(expr[i])) continue; pos = i + 1; + if (pos < expr.Length && expr[pos] == '=' && + (expr[pos - 1] == '>' || expr[pos - 1] == '<')) + { + ++pos; + return new Token($"{expr[i]}=", Token.Symbol.Operator) { ParaCount = 2 }; + } switch (expr[i]) { case '(': case ')': @@ -213,6 +232,8 @@ private static Token GetToken(string expr, ref int pos) } if (FunctionTokens.ContainsKey(@var)) return new Token(@var, Token.Symbol.Function) {ParaCount = FunctionTokens[@var]}; + if (OperatorTokens.Contains($"\0{@var}\0")) + return new Token(@var, Token.Symbol.Operator) { ParaCount = 2 }; if (MathDefines.ContainsKey(@var)) return new Token(MathDefines[@var]) {Value = @var}; return new Token(@var, Token.Symbol.Variable); @@ -222,11 +243,10 @@ private static int GetPriority(Token token) { var precedence = new Dictionary { - ["+"] = 0, - ["-"] = 0, - ["*"] = 1, - ["/"] = 1, - ["%"] = 1, + [">"] = -1, ["<"] = -1, + [">="] = -1, ["<="] = -1, + ["+"] = 0, ["-"] = 0, + ["*"] = 1, ["/"] = 1, ["%"] = 1, ["^"] = 2 }; if (string.IsNullOrEmpty(token.Value) || token.TokenType == Token.Symbol.Blank) return -2; @@ -276,7 +296,7 @@ public static IEnumerable BuildPostExpressionStack(string expr) funcStack.Pop(); } break; - default: + default: throw new ArgumentOutOfRangeException($"Invalid bracket token {token.Value}"); } preToken = token; @@ -324,6 +344,7 @@ public static IEnumerable BuildPostExpressionStack(string expr) break; } } + while (stack.Peek().Value != string.Empty) { retStack.Push(stack.Peek()); @@ -365,6 +386,16 @@ public static decimal Eval(IEnumerable posfix, Dictionary22 ? x<96 ? 4*(x-16)^2+40000 : 65536:0 + //x 22 > x 96 < x 16 - dup * 4 * 40000 + 65536 ? 0 ? + + //a 20 < 65535 a 40 < x a 80 < y z ? ? ? + //a<20 ? 65535 : a < 40? x : a < 80 ? y : z + + //x 32768 - -512 > 32768 32768 32768 x - 256 / sqrt 4 min 256 * - ? + //32768-x < 512 ? 32768 : 32768 - 256*min{sqrt[|32768-x|/256],4} + } + */ } } From adce69d6001c8f5b23f9431440a8c57d1bc3f966 Mon Sep 17 00:00:00 2001 From: tautcony Date: Tue, 18 Oct 2016 22:17:24 +0800 Subject: [PATCH 14/30] Tiny improvement. --- Time_Shift/Forms/Form1.cs | 2 +- Time_Shift/Program.cs | 2 +- Time_Shift/Util/Expression.cs | 4 ++-- Time_Shift/Util/ToolKits.cs | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index e4e4691..3cf662a 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -154,7 +154,7 @@ private void Form1_Load(object sender, EventArgs e) { TargetHeight[0] = Height - 66; TargetHeight[1] = Height; - Text = $"[VCB-Studio] ChapterTool v{Assembly.GetExecutingAssembly().GetName().Version}"; + Text = $@"[VCB-Studio] ChapterTool v{Assembly.GetExecutingAssembly().GetName().Version}"; InitialLog(); if (!IsRunningOnMono()) { diff --git a/Time_Shift/Program.cs b/Time_Shift/Program.cs index 1c7b4c1..a6dfc01 100644 --- a/Time_Shift/Program.cs +++ b/Time_Shift/Program.cs @@ -11,6 +11,7 @@ static class Program [STAThread] static void Main(string[] args) { + var options = args.TakeWhile(item => item.StartsWith("--")).ToArray(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); @@ -22,7 +23,6 @@ static void Main(string[] args) } else { - var option = args.TakeWhile(item => item.StartsWith("--")); string argsFull = string.Join(" ", args.SkipWhile(item => item.StartsWith("--"))); Application.Run(new Forms.Form1(argsFull)); } diff --git a/Time_Shift/Util/Expression.cs b/Time_Shift/Util/Expression.cs index a1ef17c..4ce353b 100644 --- a/Time_Shift/Util/Expression.cs +++ b/Time_Shift/Util/Expression.cs @@ -415,7 +415,7 @@ public decimal Eval(double time) catch (Exception exception) { EvalAble = false; - Console.WriteLine($"Eval Failed: {exception.Message}"); + Console.WriteLine($@"Eval Failed: {exception.Message}"); return (decimal)time; } } @@ -430,7 +430,7 @@ public decimal Eval() catch (Exception exception) { EvalAble = false; - Console.WriteLine($"Eval Failed: {exception.Message}"); + Console.WriteLine($@"Eval Failed: {exception.Message}"); return 0; } } diff --git a/Time_Shift/Util/ToolKits.cs b/Time_Shift/Util/ToolKits.cs index 7f34d04..9535cf9 100644 --- a/Time_Shift/Util/ToolKits.cs +++ b/Time_Shift/Util/ToolKits.cs @@ -155,7 +155,6 @@ public static void LoadColor(this Form1 window) public static bool IsAdministrator() { WindowsIdentity identity = WindowsIdentity.GetCurrent(); - if (identity == null) return false; WindowsPrincipal principal = new WindowsPrincipal(identity); return principal.IsInRole(WindowsBuiltInRole.Administrator); } From ea0340aa88db3a4192c6fd620ee559434a81e387 Mon Sep 17 00:00:00 2001 From: tautcony Date: Tue, 18 Oct 2016 22:19:23 +0800 Subject: [PATCH 15/30] Remove debug line. --- Time_Shift/Util/Expression.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Time_Shift/Util/Expression.cs b/Time_Shift/Util/Expression.cs index 4ce353b..6e8a2ab 100644 --- a/Time_Shift/Util/Expression.cs +++ b/Time_Shift/Util/Expression.cs @@ -46,7 +46,6 @@ private Expression() { } public Expression(string expr) { - System.Windows.Forms.MessageBox.Show("HERE"); PostExpression = BuildPostExpressionStack(expr); } From 8dd17d5a40911684cd1f1072d0d4e1e8e800e4f6 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sat, 17 Dec 2016 12:37:10 +0800 Subject: [PATCH 16/30] Remove unused directives in codes. --- Time_Shift/ChapterData/IData.cs | 3 +-- Time_Shift_Test/Knuckleball/MP4FileTests.cs | 1 - Time_Shift_Test/Util/CueDataTests.cs | 1 - Time_Shift_Test/Util/CueSheetTests.cs | 4 ---- Time_Shift_Test/Util/OgmDataTests.cs | 5 ----- Time_Shift_Test/Util/ToolKitsTests.cs | 3 --- 6 files changed, 1 insertion(+), 16 deletions(-) diff --git a/Time_Shift/ChapterData/IData.cs b/Time_Shift/ChapterData/IData.cs index 871ca61..c9ed6f2 100644 --- a/Time_Shift/ChapterData/IData.cs +++ b/Time_Shift/ChapterData/IData.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using ChapterTool.Util; +using ChapterTool.Util; namespace ChapterTool.ChapterData { diff --git a/Time_Shift_Test/Knuckleball/MP4FileTests.cs b/Time_Shift_Test/Knuckleball/MP4FileTests.cs index 74a1a17..a8c1818 100644 --- a/Time_Shift_Test/Knuckleball/MP4FileTests.cs +++ b/Time_Shift_Test/Knuckleball/MP4FileTests.cs @@ -1,5 +1,4 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Diagnostics; using ChapterTool.Util; using System; using System.IO; diff --git a/Time_Shift_Test/Util/CueDataTests.cs b/Time_Shift_Test/Util/CueDataTests.cs index ed730b6..476f662 100644 --- a/Time_Shift_Test/Util/CueDataTests.cs +++ b/Time_Shift_Test/Util/CueDataTests.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.IO; using ChapterTool.Util.ChapterData; diff --git a/Time_Shift_Test/Util/CueSheetTests.cs b/Time_Shift_Test/Util/CueSheetTests.cs index 4a59ba1..c5e8a1b 100644 --- a/Time_Shift_Test/Util/CueSheetTests.cs +++ b/Time_Shift_Test/Util/CueSheetTests.cs @@ -1,11 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System; -using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ChapterTool.Util; namespace ChapterTool.Util.Tests { diff --git a/Time_Shift_Test/Util/OgmDataTests.cs b/Time_Shift_Test/Util/OgmDataTests.cs index 9fe923d..bc144bb 100644 --- a/Time_Shift_Test/Util/OgmDataTests.cs +++ b/Time_Shift_Test/Util/OgmDataTests.cs @@ -1,11 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using ChapterTool.Util; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using ChapterTool.Util.ChapterData; using FluentAssertions; diff --git a/Time_Shift_Test/Util/ToolKitsTests.cs b/Time_Shift_Test/Util/ToolKitsTests.cs index c06e615..3939477 100644 --- a/Time_Shift_Test/Util/ToolKitsTests.cs +++ b/Time_Shift_Test/Util/ToolKitsTests.cs @@ -1,10 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using ChapterTool.Util; using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using FluentAssertions; namespace ChapterTool.Util.Tests From cab03fddfc178f72274e2715db870f083f9cb511 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sat, 17 Dec 2016 12:40:15 +0800 Subject: [PATCH 17/30] Improve code style. --- Time_Shift/Controls/HiLightTextBox.cs | 2 +- Time_Shift/SharpDvdInfo/DvdInfoContainer.cs | 8 +- Time_Shift/Util/CTLogger.cs | 2 +- Time_Shift/Util/ChapterData/BDMVData.cs | 3 +- Time_Shift/Util/ChapterData/CueData.cs | 344 ++++---- Time_Shift/Util/ChapterData/IfoData.cs | 4 +- Time_Shift/Util/Expression.cs | 23 +- Time_Shift/Util/LanguageHelper.cs | 38 +- Time_Shift/Util/LanguageSelectionContainer.cs | 744 +++++++++--------- Time_Shift/Util/Notification.cs | 13 +- Time_Shift/Util/TaskAsync.cs | 3 +- .../SharpDvdInfo/DvdInfoContainerTests.cs | 2 - 12 files changed, 567 insertions(+), 619 deletions(-) diff --git a/Time_Shift/Controls/HiLightTextBox.cs b/Time_Shift/Controls/HiLightTextBox.cs index aee2d1d..78dc8fb 100644 --- a/Time_Shift/Controls/HiLightTextBox.cs +++ b/Time_Shift/Controls/HiLightTextBox.cs @@ -58,7 +58,7 @@ private void HighLight(object sender, DoWorkEventArgs e) }; text.SelectionLength = text.Text.Length; text.SelectionColor = OriginalColor; - text.SelectionFont = this.Font;// new Font("Consolas", 9, FontStyle.Regular); + text.SelectionFont = Font;// new Font("Consolas", 9, FontStyle.Regular); foreach (var pattern in _patterns) { diff --git a/Time_Shift/SharpDvdInfo/DvdInfoContainer.cs b/Time_Shift/SharpDvdInfo/DvdInfoContainer.cs index f2d9218..1ecc527 100644 --- a/Time_Shift/SharpDvdInfo/DvdInfoContainer.cs +++ b/Time_Shift/SharpDvdInfo/DvdInfoContainer.cs @@ -146,11 +146,11 @@ private void GetTitleInfo(int titleSetNumber, ref TitleInfo item) char langChar1 = (char) GetBits(buffer, 8, 16); char langChar2 = (char) GetBits(buffer, 8, 24); - audioStream.Language = ChapterTool.Util.LanguageSelectionContainer.LookupISOCode($"{langChar1}{langChar2}"); + audioStream.Language = LanguageSelectionContainer.LookupISOCode($"{langChar1}{langChar2}"); } else { - audioStream.Language = ChapterTool.Util.LanguageSelectionContainer.LookupISOCode(" "); + audioStream.Language = LanguageSelectionContainer.LookupISOCode(" "); } audioStream.Extension = (DvdAudioType)GetBits(buffer, 8, 40); item.AudioStreams.Add(audioStream); @@ -178,11 +178,11 @@ private void GetTitleInfo(int titleSetNumber, ref TitleInfo item) string langCode = langChar1.ToString(CultureInfo.InvariantCulture) + langChar2.ToString(CultureInfo.InvariantCulture); - sub.Language = ChapterTool.Util.LanguageSelectionContainer.LookupISOCode(langCode); + sub.Language = LanguageSelectionContainer.LookupISOCode(langCode); } else { - sub.Language = ChapterTool.Util.LanguageSelectionContainer.LookupISOCode(" "); + sub.Language = LanguageSelectionContainer.LookupISOCode(" "); } sub.Extension = (DvdSubpictureType)GetBits(buffer, 8, 40); item.SubtitleStreams.Add(sub); diff --git a/Time_Shift/Util/CTLogger.cs b/Time_Shift/Util/CTLogger.cs index 6491d01..5066e7c 100644 --- a/Time_Shift/Util/CTLogger.cs +++ b/Time_Shift/Util/CTLogger.cs @@ -20,7 +20,7 @@ public static class CTLogger public static void Log(string message) { DateTime actionDate = DateTime.Now; - string logMessage = $"{actionDate.ToString("[yyyy-MM-dd][HH:mm:ss]")} {message}"; + string logMessage = $"{actionDate:[yyyy-MM-dd][HH:mm:ss]} {message}"; LogContext.AppendLine(logMessage); OnLogLineAdded(logMessage, actionDate); } diff --git a/Time_Shift/Util/ChapterData/BDMVData.cs b/Time_Shift/Util/ChapterData/BDMVData.cs index 070b9ff..50397d5 100644 --- a/Time_Shift/Util/ChapterData/BDMVData.cs +++ b/Time_Shift/Util/ChapterData/BDMVData.cs @@ -1,7 +1,6 @@ using System; using System.IO; using System.Linq; -using System.Diagnostics; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -16,7 +15,7 @@ public static class BDMVData private static readonly Regex RDiskInfo = new Regex(@"(?\d)\) (?\d+\.mpls), (?:(?:(?\d+:\d+:\d+)[\n\s\b]*(?.+\.m2ts))|(?:(?.+\.m2ts), (?\d+:\d+:\d+)))", RegexOptions.Compiled); - public static async Task> GetChapter(string location) + public static async Task> GetChapterAsync(string location) { var list = new List(); string path = Path.Combine(Path.Combine(location, "BDMV"), "PLAYLIST"); diff --git a/Time_Shift/Util/ChapterData/CueData.cs b/Time_Shift/Util/ChapterData/CueData.cs index 683ddca..fba6e7c 100644 --- a/Time_Shift/Util/ChapterData/CueData.cs +++ b/Time_Shift/Util/ChapterData/CueData.cs @@ -18,17 +18,17 @@ // // **************************************************************************** +using ChapterTool.ChapterData; using System; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; -using ChapterTool.ChapterData; namespace ChapterTool.Util.ChapterData { - public class CueData : IData + public class CueData: IData { public ChapterInfo Chapter { get; private set; } @@ -42,28 +42,26 @@ public CueData(string path) var ext = Path.GetExtension(path)?.ToLower(); switch (ext) { - case ".cue": - cueData = File.ReadAllBytes(path).GetUTF8String(); - if (string.IsNullOrEmpty(cueData)) - { - throw new InvalidDataException("Empty cue file"); - } - break; - case ".flac": - cueData = GetCueFromFlac(path); - break; - case ".tak": - cueData = GetCueFromTak(path); - break; - default: - throw new Exception($"Invalid extension: {ext}"); + case ".cue": + cueData = File.ReadAllBytes(path).GetUTF8String(); + if (string.IsNullOrEmpty(cueData)) + throw new InvalidDataException("Empty cue file"); + break; + + case ".flac": + cueData = GetCueFromFlac(path); + break; + + case ".tak": + cueData = GetCueFromTak(path); + break; + + default: + throw new Exception($"Invalid extension: {ext}"); } if (string.IsNullOrEmpty(cueData)) - { throw new Exception($"No Cue detected in {ext} file"); - } Chapter = PraseCue(cueData); - //Chapter = new CueSheet(cueData, true).ToChapterInfo(); } private enum NextState @@ -97,80 +95,85 @@ public static ChapterInfo PraseCue(string context) { switch (nxState) { - case NextState.NsStart: - var chapterTitleMatch = RTitle.Match(line); - var fileMatch = RFile.Match(line); - if (chapterTitleMatch.Success) - { - cue.Title = chapterTitleMatch.Groups[1].Value; - //nxState = NextState.NsNewTrack; - break; - } - if (fileMatch.Success) //Title 为非必需项,故当读取到File行时跳出 - { - cue.SourceName = fileMatch.Groups[1].Value; - nxState = NextState.NsNewTrack; - } + case NextState.NsStart: + var chapterTitleMatch = RTitle.Match(line); + var fileMatch = RFile.Match(line); + if (chapterTitleMatch.Success) + { + cue.Title = chapterTitleMatch.Groups[1].Value; + //nxState = NextState.NsNewTrack; break; - case NextState.NsNewTrack: - if (string.IsNullOrWhiteSpace(line)) //读到空行,解析终止 - { - nxState = NextState.NsFin; - break; - } - var trackMatch = RTrack.Match(line); - if (trackMatch.Success) //读取到Track,获取其编号,跳至下一步 - { - chapter = new Chapter { Number = int.Parse(trackMatch.Groups[1].Value) }; - nxState = NextState.NsTrack; - } + } + if (fileMatch.Success) //Title 为非必需项,故当读取到File行时跳出 + { + cue.SourceName = fileMatch.Groups[1].Value; + nxState = NextState.NsNewTrack; + } + break; + + case NextState.NsNewTrack: + if (string.IsNullOrWhiteSpace(line)) //读到空行,解析终止 + { + nxState = NextState.NsFin; break; - case NextState.NsTrack: - var trackTitleMatch = RTitle.Match(line); - var performerMatch = RPerformer.Match(line); - var timeMatch = RTime.Match(line); + } + var trackMatch = RTrack.Match(line); + if (trackMatch.Success) //读取到Track,获取其编号,跳至下一步 + { + chapter = new Chapter { Number = int.Parse(trackMatch.Groups[1].Value) }; + nxState = NextState.NsTrack; + } + break; + + case NextState.NsTrack: + var trackTitleMatch = RTitle.Match(line); + var performerMatch = RPerformer.Match(line); + var timeMatch = RTime.Match(line); - if (trackTitleMatch.Success) //获取章节名 + if (trackTitleMatch.Success) //获取章节名 + { + Debug.Assert(chapter != null); + chapter.Name = trackTitleMatch.Groups[1].Value.Trim('\r'); + break; + } + if (performerMatch.Success) //获取艺术家名 + { + Debug.Assert(chapter != null); + chapter.Name += $" [{performerMatch.Groups[1].Value.Trim('\r')}]"; + break; + } + if (timeMatch.Success) //获取章节时间 + { + var trackIndex = int.Parse(timeMatch.Groups["index"].Value); + switch (trackIndex) { - Debug.Assert(chapter != null); - chapter.Name = trackTitleMatch.Groups[1].Value.Trim('\r'); + case 0: //pre-gap of a track, just ignore it. break; - } - if (performerMatch.Success) //获取艺术家名 - { + + case 1: //beginning of a new track. Debug.Assert(chapter != null); - chapter.Name += $" [{performerMatch.Groups[1].Value.Trim('\r')}]"; + var minute = int.Parse(timeMatch.Groups["M"].Value); + var second = int.Parse(timeMatch.Groups["S"].Value); + var millisecond = (int)Math.Round(int.Parse(timeMatch.Groups["F"].Value)*(1000F/75));//最后一项以帧(1s/75)而非以10毫秒为单位 + chapter.Time = new TimeSpan(0, 0, minute, second, millisecond); + cue.Chapters.Add(chapter); + nxState = NextState.NsNewTrack;//当前章节点的必要信息已获得,继续寻找下一章节 + break; + + default: + nxState = NextState.NsError; break; } - if (timeMatch.Success) //获取章节时间 - { - var trackIndex = int.Parse(timeMatch.Groups["index"].Value); - switch (trackIndex) - { - case 0: //pre-gap of a track, just ignore it. - break; - case 1: //beginning of a new track. - Debug.Assert(chapter != null); - var minute = int.Parse(timeMatch.Groups["M"].Value); - var second = int.Parse(timeMatch.Groups["S"].Value); - var millisecond = (int)Math.Round(int.Parse(timeMatch.Groups["F"].Value)*(1000F/75));//最后一项以帧(1s/75)而非以10毫秒为单位 - chapter.Time = new TimeSpan(0, 0, minute, second, millisecond); - cue.Chapters.Add(chapter); - nxState = NextState.NsNewTrack;//当前章节点的必要信息已获得,继续寻找下一章节 - break; - default: - nxState = NextState.NsError; - break; - } - } - break; - case NextState.NsError: - throw new Exception("Unable to Prase this cue file"); - case NextState.NsFin: - goto EXIT_1; - default: - nxState = NextState.NsError; - break; + } + break; + + case NextState.NsError: + throw new Exception("Unable to Prase this cue file"); + case NextState.NsFin: + goto EXIT_1; + default: + nxState = NextState.NsError; + break; } } EXIT_1: @@ -203,45 +206,25 @@ private static string GetCueSheet(byte[] buffer, string type) for (int i = 0; i < length; ++i) { if ((buffer[i] >= 0x41) && (buffer[i] <= 0x5A)) - buffer[i] += 0x20; - + buffer[i] -= 0x20; switch ((char)buffer[i]) { - case 'c': - state = 1; //C - break; - case 'u': - state = state == 1 ? 2 : 0;//Cu - break; - case 'e': - switch (state) - { - case 2: - state = 3; //Cue - break; - case 5: - state = 6; //Cueshe - break; - case 6: - state = 7; //Cueshee - break; - default: - state = 0; - break; - } - break; - case 's': - state = state == 3 ? 4 : 0;//Cues - break; - case 'h': - state = state == 4 ? 5 : 0;//Cuesh - break; - case 't': - state = state == 7 ? 8 : 0;//Cuesheet - break; - default: - state = 0; - break; + case 'c': state = 1; break;//C + case 'u': state = state == 1 ? 2 : 0; break;//Cu + case 'e': + switch (state) + { + case 2: state = 3; break;//Cue + case 5: state = 6; break;//Cueshe + case 6: state = 7; break;//Cueshee + default: state = 0; break; + } + break; + + case 's': state = state == 3 ? 4 : 0; break;//Cues + case 'h': state = state == 4 ? 5 : 0; break;//Cuesh + case 't': state = state == 7 ? 8 : 0; break;//Cuesheet + default: state = 0; break; } if (state != 8) continue; beginPos = i + 2; @@ -255,18 +238,12 @@ private static string GetCueSheet(byte[] buffer, string type) { switch (buffer[i]) { - case 0: - state++; - break; - default: - state = 0; - break; - } - if (state == controlCount) - { - endPos = i - controlCount; //指向0D 0A后的第一个字符 - break; + case 0: state++; break; + default: state = 0; break; } + if (state != controlCount) continue; + endPos = i - controlCount; //指向0D 0A后的第一个字符 + break; } if (beginPos == 0 || endPos <= 1) return string.Empty; @@ -283,76 +260,65 @@ private static string GetCueSheet(byte[] buffer, string type) private static string GetCueFromTak(string takPath) { - var fs = File.Open(takPath, FileMode.Open, FileAccess.Read); - if (fs.Length < 1<<20)// 小于1M,文档太小了 + using (var fs = File.Open(takPath, FileMode.Open, FileAccess.Read)) { - fs.Close(); - return string.Empty; - } - var header = new byte[4]; - fs.Read(header, 0, 4); - if (Encoding.ASCII.GetString(header, 0, 4) != "tBaK") - { - fs.Close(); - throw new InvalidDataException($"Except an tak but get an {Encoding.ASCII.GetString(header, 0, 4)}"); + if (fs.Length < 1 << 20)// 小于1M,文档太小了 + return string.Empty; + var header = new byte[4]; + fs.Read(header, 0, 4); + if (Encoding.ASCII.GetString(header, 0, 4) != "tBaK") + throw new InvalidDataException($"Except an tak but get an {Encoding.ASCII.GetString(header, 0, 4)}"); + fs.Seek(-20480, SeekOrigin.End); + var buffer = new byte[20480]; + fs.Read(buffer, 0, 20480); + return GetCueSheet(buffer, "tak"); } - fs.Seek(-20480, SeekOrigin.End); - var buffer = new byte[20480]; - fs.Read(buffer, 0, 20480); - fs.Close(); - return GetCueSheet(buffer, "tak"); } private static string GetCueFromFlac(string flacPath) { - var fs = File.Open(flacPath, FileMode.Open, FileAccess.Read); - if (fs.Length < 1<<20)// 小于1M,文档太小了 - { - fs.Close(); - return string.Empty; - } - var header = new byte[4]; - fs.Read(header, 0, 4); - if (Encoding.ASCII.GetString(header, 0, 4) != "fLaC") - { - fs.Close(); - throw new InvalidDataException($"Except an flac but get an {Encoding.ASCII.GetString(header, 0, 4)}"); - } - - var buffer = new byte[1]; - //4个字节的METADATA_BLOCK_HEADER - do + using (var fs = File.Open(flacPath, FileMode.Open, FileAccess.Read)) { + if (fs.Length < 1 << 20)// 小于1M,文档太小了 + return string.Empty; + var header = new byte[4]; fs.Read(header, 0, 4); - //读取BLOCK长度 - int length = (header[1] << 16) | (header[2] << 8) | header[3]; - //解析 - //检查最高位是否为1 - if ((header[0] & 0x80) == 0x80) + if (Encoding.ASCII.GetString(header, 0, 4) != "fLaC") + throw new InvalidDataException($"Except an flac but get an {Encoding.ASCII.GetString(header, 0, 4)}"); + + var buffer = new byte[1]; + //4个字节的METADATA_BLOCK_HEADER + do { - //最后一个METADATA_BLOCK + fs.Read(header, 0, 4); + //读取BLOCK长度 + int length = (header[1] << 16) | (header[2] << 8) | header[3]; + //解析 + //检查最高位是否为1 + if ((header[0] & 0x80) == 0x80) + { + //最后一个METADATA_BLOCK + if ((header[0] & 0x7F) == 0x04)//是VORBIS_COMMENT + { + buffer = new byte[length]; + //读取BLOCK DATA + fs.Read(buffer, 0, length); + } + break; + } + //不是最后一个METADATA_BLOCK if ((header[0] & 0x7F) == 0x04)//是VORBIS_COMMENT { buffer = new byte[length]; //读取BLOCK DATA fs.Read(buffer, 0, length); + break; } - break; - } - //不是最后一个METADATA_BLOCK - if ((header[0] & 0x7F) == 0x04)//是VORBIS_COMMENT - { - buffer = new byte[length]; - //读取BLOCK DATA - fs.Read(buffer, 0, length); - break; - } - //移动文件指针 - fs.Seek(length, SeekOrigin.Current); - } while (fs.Position <= 1048576L); - fs.Close(); - - return GetCueSheet(buffer, "flac"); + //移动文件指针 + fs.Seek(length, SeekOrigin.Current); + } while (fs.Position <= 1048576L); + return GetCueSheet(buffer, "flac"); + } } public int Count { get; } = 1; diff --git a/Time_Shift/Util/ChapterData/IfoData.cs b/Time_Shift/Util/ChapterData/IfoData.cs index a01cd2d..fd349f4 100644 --- a/Time_Shift/Util/ChapterData/IfoData.cs +++ b/Time_Shift/Util/ChapterData/IfoData.cs @@ -56,9 +56,7 @@ private static ChapterInfo GetChapterInfo(string location, int titleSetNum) pgc.Title = pgc.SourceName = $"{fileName.Substring(0, barIndex)}_{titleSetNum}"; } - TimeSpan duration; - double fps; - pgc.Chapters = GetChapters(location, titleSetNum, out duration, out fps); + pgc.Chapters = GetChapters(location, titleSetNum, out TimeSpan duration, out double fps); pgc.Duration = duration; pgc.FramesPerSecond = fps; diff --git a/Time_Shift/Util/Expression.cs b/Time_Shift/Util/Expression.cs index 6e8a2ab..4c33080 100644 --- a/Time_Shift/Util/Expression.cs +++ b/Time_Shift/Util/Expression.cs @@ -221,21 +221,20 @@ private static Token GetToken(string expr, ref int pos) } } pos = i; - var @var = varRet.ToString(); + var variable = varRet.ToString(); if (IsDigit(varRet[0])) { - decimal number; - if (!decimal.TryParse(@var, out number)) - throw new Exception($"Invalid number token [{@var}]"); - return new Token(number) {Value = @var}; + if (!decimal.TryParse(variable, out decimal number)) + throw new Exception($"Invalid number token [{variable}]"); + return new Token(number) {Value = variable}; } - if (FunctionTokens.ContainsKey(@var)) - return new Token(@var, Token.Symbol.Function) {ParaCount = FunctionTokens[@var]}; - if (OperatorTokens.Contains($"\0{@var}\0")) - return new Token(@var, Token.Symbol.Operator) { ParaCount = 2 }; - if (MathDefines.ContainsKey(@var)) - return new Token(MathDefines[@var]) {Value = @var}; - return new Token(@var, Token.Symbol.Variable); + if (FunctionTokens.ContainsKey(variable)) + return new Token(variable, Token.Symbol.Function) {ParaCount = FunctionTokens[variable]}; + if (OperatorTokens.Contains($"\0{variable}\0")) + return new Token(variable, Token.Symbol.Operator) { ParaCount = 2 }; + if (MathDefines.ContainsKey(variable)) + return new Token(MathDefines[variable]) {Value = variable}; + return new Token(variable, Token.Symbol.Variable); } private static int GetPriority(Token token) diff --git a/Time_Shift/Util/LanguageHelper.cs b/Time_Shift/Util/LanguageHelper.cs index 906394e..e689b14 100644 --- a/Time_Shift/Util/LanguageHelper.cs +++ b/Time_Shift/Util/LanguageHelper.cs @@ -15,18 +15,15 @@ public class LanguageHelper private static void SetAllLang(string lang) { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang); - Form frm = null; string name = "MainForm"; - frm = (Form)Assembly.Load("CameraTest").CreateInstance(name); + var frm = (Form)Assembly.Load("CameraTest").CreateInstance(name); + if (frm == null) return; - if (frm != null) - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(); - resources.ApplyResources(frm, "$this"); - AppLang(frm, resources); - } + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(); + resources.ApplyResources(frm, "$this"); + AppLang(frm, resources); } #endregion @@ -57,13 +54,13 @@ public static void SetLang(string lang, Form form, Type formType) /// private static void AppLang(Control control, System.ComponentModel.ComponentResourceManager resources) { - if (control is MenuStrip) + MenuStrip menuStrip = control as MenuStrip; + if (menuStrip != null) { - resources.ApplyResources(control, control.Name); - MenuStrip ms = (MenuStrip)control; - if (ms.Items.Count > 0) + resources.ApplyResources(menuStrip, menuStrip.Name); + if (menuStrip.Items.Count > 0) { - foreach (ToolStripMenuItem c in ms.Items) + foreach (ToolStripMenuItem c in menuStrip.Items) { AppLang(c, resources); } @@ -86,17 +83,12 @@ private static void AppLang(Control control, System.ComponentModel.ComponentReso /// private static void AppLang(ToolStripMenuItem item, System.ComponentModel.ComponentResourceManager resources) { - if (item is ToolStripMenuItem) + if (item == null) return; + resources.ApplyResources(item, item.Name); + if (item.DropDownItems.Count <= 0) return; + foreach (ToolStripMenuItem c in item.DropDownItems) { - resources.ApplyResources(item, item.Name); - ToolStripMenuItem tsmi = (ToolStripMenuItem)item; - if (tsmi.DropDownItems.Count > 0) - { - foreach (ToolStripMenuItem c in tsmi.DropDownItems) - { - AppLang(c, resources); - } - } + AppLang(c, resources); } } #endregion diff --git a/Time_Shift/Util/LanguageSelectionContainer.cs b/Time_Shift/Util/LanguageSelectionContainer.cs index 15bbb45..bee857a 100644 --- a/Time_Shift/Util/LanguageSelectionContainer.cs +++ b/Time_Shift/Util/LanguageSelectionContainer.cs @@ -43,7 +43,7 @@ public static class LanguageSelectionContainer /// public static Dictionary LanguagesTerminology { get; } - private static void addLanguage(string name, string iso3B, string iso3T, string iso2) + private static void AddLanguage(string name, string iso3B, string iso3T, string iso2) { Languages.Add(name, iso3B); LanguagesReverseBibliographic.Add(iso3B, name); @@ -81,377 +81,377 @@ static LanguageSelectionContainer() //languagesISO2 = new Dictionary(); LanguagesReverseISO2 = new Dictionary(); - addLanguage("Not Specified", " ", "", " "); - addLanguage("Abkhazian", "abk", "", "ab"); - addLanguage("Achinese", "ace", "", ""); - addLanguage("Acoli", "ach", "", ""); - addLanguage("Adangme", "ada", "", ""); - addLanguage("Adyghe", "ady", "", ""); - addLanguage("Afar", "aar", "", "aa"); - addLanguage("Afrikaans", "afr", "", "af"); - addLanguage("Ainu", "ain", "", ""); - addLanguage("Akan", "aka", "", "ak"); - addLanguage("Albanian", "alb", "sqi", "sq"); - addLanguage("Aleut", "ale", "", ""); - addLanguage("Amharic", "amh", "", "am"); - addLanguage("Angika", "anp", "", ""); - addLanguage("Arabic", "ara", "", "ar"); - addLanguage("Aragonese", "arg", "", "an"); - addLanguage("Arapaho", "arp", "", ""); - addLanguage("Arawak", "arw", "", ""); - addLanguage("Armenian", "arm", "hye", "hy"); - addLanguage("Aromanian", "rup", "", ""); - addLanguage("Assamese", "asm", "", "as"); - addLanguage("Asturian", "ast", "", ""); - addLanguage("Avaric", "ava", "", "av"); - addLanguage("Awadhi", "awa", "", ""); - addLanguage("Aymara", "aym", "", "ay"); - addLanguage("Azerbaijani", "aze", "", "az"); - addLanguage("Balinese", "ban", "", ""); - addLanguage("Baluchi", "bal", "", ""); - addLanguage("Bambara", "bam", "", "bm"); - addLanguage("Basa", "bas", "", ""); - addLanguage("Bashkir", "bak", "", "ba"); - addLanguage("Basque", "baq", "eus", "eu"); - addLanguage("Beja", "bej", "", ""); - addLanguage("Belarusian", "bel", "", "be"); - addLanguage("Bemba", "bem", "", ""); - addLanguage("Bengali", "ben", "", "bn"); - addLanguage("Bhojpuri", "bho", "", ""); - addLanguage("Bikol", "bik", "", ""); - addLanguage("Bini", "bin", "", ""); - addLanguage("Bislama", "bis", "", "bi"); - addLanguage("Blin", "byn", "", ""); - addLanguage("Bosnian", "bos", "", "bs"); - addLanguage("Braj", "bra", "", ""); - addLanguage("Breton", "bre", "", "br"); - addLanguage("Buginese", "bug", "", ""); - addLanguage("Bulgarian", "bul", "", "bg"); - addLanguage("Buriat", "bua", "", ""); - addLanguage("Burmese", "bur", "mya", "my"); - addLanguage("Caddo", "cad", "", ""); - addLanguage("Catalan", "cat", "", "ca"); - addLanguage("Cebuano", "ceb", "", ""); - addLanguage("Central Khmer", "khm", "", "km"); - addLanguage("Chamorro", "cha", "", "ch"); - addLanguage("Chechen", "che", "", "ce"); - addLanguage("Cherokee", "chr", "", ""); - addLanguage("Cheyenne", "chy", "", ""); - addLanguage("Chichewa", "nya", "", "ny"); - addLanguage("Chinese", "chi", "zho", "zh"); - addLanguage("Chinook jargon", "chn", "", ""); - addLanguage("Chipewyan", "chp", "", ""); - addLanguage("Choctaw", "cho", "", ""); - addLanguage("Chuukese", "chk", "", ""); - addLanguage("Chuvash", "chv", "", "cv"); - addLanguage("Cornish", "cor", "", "kw"); - addLanguage("Corsican", "cos", "", "co"); - addLanguage("Cree", "cre", "", "cr"); - addLanguage("Creek", "mus", "", ""); - addLanguage("Crimean Tatar", "crh", "", ""); - addLanguage("Croatian", "hrv", "", "hr"); - addLanguage("Czech", "cze", "ces", "cs"); - addLanguage("Dakota", "dak", "", ""); - addLanguage("Danish", "dan", "", "da"); - addLanguage("Dargwa", "dar", "", ""); - addLanguage("Delaware", "del", "", ""); - addLanguage("Dinka", "din", "", ""); - addLanguage("Divehi", "div", "", "dv"); - addLanguage("Dogri", "doi", "", ""); - addLanguage("Dogrib", "dgr", "", ""); - addLanguage("Duala", "dua", "", ""); - addLanguage("Dutch", "dut", "nld", "nl"); - addLanguage("Dyula", "dyu", "", ""); - addLanguage("Dzongkha", "dzo", "", "dz"); - addLanguage("Eastern Frisian", "frs", "", ""); - addLanguage("Efik", "efi", "", ""); - addLanguage("Ekajuk", "eka", "", ""); - addLanguage("English", "eng", "", "en"); - addLanguage("Erzya", "myv", "", ""); - addLanguage("Estonian", "est", "", "et"); - addLanguage("Ewe", "ewe", "", "ee"); - addLanguage("Ewondo", "ewo", "", ""); - addLanguage("Fang", "fan", "", ""); - addLanguage("Fanti", "fat", "", ""); - addLanguage("Faroese", "fao", "", "fo"); - addLanguage("Fijian", "fij", "", "fj"); - addLanguage("Filipino", "fil", "", ""); - addLanguage("Finnish", "fin", "", "fi"); - addLanguage("Fon", "fon", "", ""); - addLanguage("French", "fre", "fra", "fr"); - addLanguage("Friulian", "fur", "", ""); - addLanguage("Fulah", "ful", "", "ff"); - addLanguage("Ga", "gaa", "", ""); - addLanguage("Gaelic", "gla", "", "gd"); - addLanguage("Galibi Carib", "car", "", ""); - addLanguage("Galician", "glg", "", "gl"); - addLanguage("Ganda", "lug", "", "lg"); - addLanguage("Gayo", "gay", "", ""); - addLanguage("Gbaya", "gba", "", ""); - addLanguage("Georgian", "geo", "kat", "ka"); - addLanguage("German", "ger", "deu", "de"); - addLanguage("Gilbertese", "gil", "", ""); - addLanguage("Gondi", "gon", "", ""); - addLanguage("Gorontalo", "gor", "", ""); - addLanguage("Grebo", "grb", "", ""); - addLanguage("Greek", "gre", "ell", "el"); - addLanguage("Guarani", "grn", "", "gn"); - addLanguage("Gujarati", "guj", "", "gu"); - addLanguage("Gwich'in", "gwi", "", ""); - addLanguage("Haida", "hai", "", ""); - addLanguage("Haitian", "hat", "", "ht"); - addLanguage("Hausa", "hau", "", "ha"); - addLanguage("Hawaiian", "haw", "", ""); - addLanguage("Hebrew", "heb", "", "he"); - addLanguage("Herero", "her", "", "hz"); - addLanguage("Hiligaynon", "hil", "", ""); - addLanguage("Hindi", "hin", "", "hi"); - addLanguage("Hiri Motu", "hmo", "", "ho"); - addLanguage("Hmong", "hmn", "", ""); - addLanguage("Hungarian", "hun", "", "hu"); - addLanguage("Hupa", "hup", "", ""); - addLanguage("Iban", "iba", "", ""); - addLanguage("Icelandic", "ice", "isl", "is"); - addLanguage("Igbo", "ibo", "", "ig"); - addLanguage("Iloko", "ilo", "", ""); - addLanguage("Inari Sami", "smn", "", ""); - addLanguage("Indonesian", "ind", "", "id"); - addLanguage("Ingush", "inh", "", ""); - addLanguage("Inuktitut", "iku", "", "iu"); - addLanguage("Inupiaq", "ipk", "", "ik"); - addLanguage("Irish", "gle", "", "ga"); - addLanguage("Italian", "ita", "", "it"); - addLanguage("Japanese", "jpn", "", "ja"); - addLanguage("Javanese", "jav", "", "jv"); - addLanguage("Judeo-Arabic", "jrb", "", ""); - addLanguage("Judeo-Persian", "jpr", "", ""); - addLanguage("Kabardian", "kbd", "", ""); - addLanguage("Kabyle", "kab", "", ""); - addLanguage("Kachin", "kac", "", ""); - addLanguage("Kalaallisut", "kal", "", "kl"); - addLanguage("Kalmyk", "xal", "", ""); - addLanguage("Kamba", "kam", "", ""); - addLanguage("Kannada", "kan", "", "kn"); - addLanguage("Kanuri", "kau", "", "kr"); - addLanguage("Karachay-Balkar", "krc", "", ""); - addLanguage("Kara-Kalpak", "kaa", "", ""); - addLanguage("Karelian", "krl", "", ""); - addLanguage("Kashmiri", "kas", "", "ks"); - addLanguage("Kashubian", "csb", "", ""); - addLanguage("Kazakh", "kaz", "", "kk"); - addLanguage("Khasi", "kha", "", ""); - addLanguage("Kikuyu", "kik", "", "ki"); - addLanguage("Kimbundu", "kmb", "", ""); - addLanguage("Kinyarwanda", "kin", "", "rw"); - addLanguage("Kirghiz", "kir", "", "ky"); - addLanguage("Komi", "kom", "", "kv"); - addLanguage("Kongo", "kon", "", "kg"); - addLanguage("Konkani", "kok", "", ""); - addLanguage("Korean", "kor", "", "ko"); - addLanguage("Kosraean", "kos", "", ""); - addLanguage("Kpelle", "kpe", "", ""); - addLanguage("Kuanyama", "kua", "", "kj"); - addLanguage("Kumyk", "kum", "", ""); - addLanguage("Kurdish", "kur", "", "ku"); - addLanguage("Kurukh", "kru", "", ""); - addLanguage("Kutenai", "kut", "", ""); - addLanguage("Ladino", "lad", "", ""); - addLanguage("Lahnda", "lah", "", ""); - addLanguage("Lamba", "lam", "", ""); - addLanguage("Lao", "lao", "", "lo"); - addLanguage("Latvian", "lav", "", "lv"); - addLanguage("Lezghian", "lez", "", ""); - addLanguage("Limburgan", "lim", "", "li"); - addLanguage("Lingala", "lin", "", "ln"); - addLanguage("Lithuanian", "lit", "", "lt"); - addLanguage("Low German", "nds", "", ""); - addLanguage("Lower Sorbian", "dsb", "", ""); - addLanguage("Lozi", "loz", "", ""); - addLanguage("Luba-Katanga", "lub", "", "lu"); - addLanguage("Luba-Lulua", "lua", "", ""); - addLanguage("Luiseno", "lui", "", ""); - addLanguage("Lule Sami", "smj", "", ""); - addLanguage("Lunda", "lun", "", ""); - addLanguage("Luo", "luo", "", ""); - addLanguage("Lushai", "lus", "", ""); - addLanguage("Luxembourgish", "ltz", "", "lb"); - addLanguage("Macedonian", "mac", "mkd", "mk"); - addLanguage("Madurese", "mad", "", ""); - addLanguage("Magahi", "mag", "", ""); - addLanguage("Maithili", "mai", "", ""); - addLanguage("Makasar", "mak", "", ""); - addLanguage("Malagasy", "mlg", "", "mg"); - addLanguage("Malay", "may", "msa", "ms"); - addLanguage("Malayalam", "mal", "", "ml"); - addLanguage("Maltese", "mlt", "", "mt"); - addLanguage("Manchu", "mnc", "", ""); - addLanguage("Mandar", "mdr", "", ""); - addLanguage("Mandingo", "man", "", ""); - addLanguage("Manipuri", "mni", "", ""); - addLanguage("Manx", "glv", "", "gv"); - addLanguage("Maori", "mao", "mri", "mi"); - addLanguage("Mapudungun", "arn", "", ""); - addLanguage("Marathi", "mar", "", "mr"); - addLanguage("Mari", "chm", "", ""); - addLanguage("Marshallese", "mah", "", "mh"); - addLanguage("Marwari", "mwr", "", ""); - addLanguage("Masai", "mas", "", ""); - addLanguage("Mende", "men", "", ""); - addLanguage("Mi'kmaq", "mic", "", ""); - addLanguage("Minangkabau", "min", "", ""); - addLanguage("Mirandese", "mwl", "", ""); - addLanguage("Mohawk", "moh", "", ""); - addLanguage("Moksha", "mdf", "", ""); - addLanguage("Moldavian", "mol", "", "mo"); - addLanguage("Mongo", "lol", "", ""); - addLanguage("Mongolian", "mon", "", "mn"); - addLanguage("Mossi", "mos", "", ""); - addLanguage("Nauru", "nau", "", "na"); - addLanguage("Navajo", "nav", "", "nv"); - addLanguage("Ndebele, North", "nde", "", "nd"); - addLanguage("Ndebele, South", "nbl", "", "nr"); - addLanguage("Ndonga", "ndo", "", "ng"); - addLanguage("Neapolitan", "nap", "", ""); - addLanguage("Nepal Bhasa", "new", "", ""); - addLanguage("Nepali", "nep", "", "ne"); - addLanguage("Nias", "nia", "", ""); - addLanguage("Niuean", "niu", "", ""); - addLanguage("N'Ko", "nqo", "", ""); - addLanguage("Nogai", "nog", "", ""); - addLanguage("Northern Frisian", "frr", "", ""); - addLanguage("Northern Sami", "sme", "", "se"); - addLanguage("Norwegian", "nor", "", "no"); - addLanguage("norwegian bokmål", "nob", "", "nb"); - addLanguage("Norwegian Nynorsk", "nno", "", "nn"); - addLanguage("Nyamwezi", "nym", "", ""); - addLanguage("Nyankole", "nyn", "", ""); - addLanguage("Nyoro", "nyo", "", ""); - addLanguage("Nzima", "nzi", "", ""); - addLanguage("Occitan", "oci", "", "oc"); - addLanguage("Ojibwa", "oji", "", "oj"); - addLanguage("Oriya", "ori", "", "or"); - addLanguage("Oromo", "orm", "", "om"); - addLanguage("Osage", "osa", "", ""); - addLanguage("Ossetian", "oss", "", "os"); - addLanguage("Palauan", "pau", "", ""); - addLanguage("Pampanga", "pam", "", ""); - addLanguage("Pangasinan", "pag", "", ""); - addLanguage("Panjabi", "pan", "", "pa"); - addLanguage("Papiamento", "pap", "", ""); - addLanguage("Pedi", "nso", "", ""); - addLanguage("Persian", "per", "fas", "fa"); - addLanguage("Pohnpeian", "pon", "", ""); - addLanguage("Polish", "pol", "", "pl"); - addLanguage("Portuguese", "por", "", "pt"); - addLanguage("Pushto", "pus", "", "ps"); - addLanguage("Quechua", "que", "", "qu"); - addLanguage("Rajasthani", "raj", "", ""); - addLanguage("Rapanui", "rap", "", ""); - addLanguage("Rarotongan", "rar", "", ""); - addLanguage("Romanian", "rum", "ron", "ro"); - addLanguage("Romansh", "roh", "", "rm"); - addLanguage("Romany", "rom", "", ""); - addLanguage("Rundi", "run", "", "rn"); - addLanguage("Russian", "rus", "", "ru"); - addLanguage("Samoan", "smo", "", "sm"); - addLanguage("Sandawe", "sad", "", ""); - addLanguage("Sango", "sag", "", "sg"); - addLanguage("Santali", "sat", "", ""); - addLanguage("Sardinian", "srd", "", "sc"); - addLanguage("Sasak", "sas", "", ""); - addLanguage("Scots", "sco", "", ""); - addLanguage("Selkup", "sel", "", ""); - addLanguage("Serbian", "srp", "", "sr"); - addLanguage("Serer", "srr", "", ""); - addLanguage("Shan", "shn", "", ""); - addLanguage("Shona", "sna", "", "sn"); - addLanguage("Sichuan Yi", "iii", "", "ii"); - addLanguage("Sicilian", "scn", "", ""); - addLanguage("Sidamo", "sid", "", ""); - addLanguage("Siksika", "bla", "", ""); - addLanguage("Sindhi", "snd", "", "sd"); - addLanguage("Sinhala", "sin", "", "si"); - addLanguage("Skolt Sami", "sms", "", ""); - addLanguage("Slave (Athapascan)", "den", "", ""); - addLanguage("Slovak", "slo", "slk", "sk"); - addLanguage("Slovenian", "slv", "", "sl"); - addLanguage("Somali", "som", "", "so"); - addLanguage("Soninke", "snk", "", ""); - addLanguage("Sotho, Southern", "sot", "", "st"); - addLanguage("Southern Altai", "alt", "", ""); - addLanguage("Southern Sami", "sma", "", ""); - addLanguage("Spanish", "spa", "", "es"); - addLanguage("Sranan Tongo", "srn", "", ""); - addLanguage("Standard Moroccan Tamazight", "zgh", "", ""); - addLanguage("Sukuma", "suk", "", ""); - addLanguage("Sundanese", "sun", "", "su"); - addLanguage("Susu", "sus", "", ""); - addLanguage("Swahili", "swa", "", "sw"); - addLanguage("Swati", "ssw", "", "ss"); - addLanguage("Swedish", "swe", "", "sv"); - addLanguage("Swiss German", "gsw", "", ""); - addLanguage("Syriac", "syr", "", ""); - addLanguage("Tagalog", "tgl", "", "tl"); - addLanguage("Tahitian", "tah", "", "ty"); - addLanguage("Tajik", "tgk", "", "tg"); - addLanguage("Tamashek", "tmh", "", ""); - addLanguage("Tamil", "tam", "", "ta"); - addLanguage("Tatar", "tat", "", "tt"); - addLanguage("Telugu", "tel", "", "te"); - addLanguage("Tereno", "ter", "", ""); - addLanguage("Tetum", "tet", "", ""); - addLanguage("Thai", "tha", "", "th"); - addLanguage("Tibetan", "tib", "bod", "bo"); - addLanguage("Tigre", "tig", "", ""); - addLanguage("Tigrinya", "tir", "", "ti"); - addLanguage("Timne", "tem", "", ""); - addLanguage("Tiv", "tiv", "", ""); - addLanguage("Tlingit", "tli", "", ""); - addLanguage("Tok Pisin", "tpi", "", ""); - addLanguage("Tokelau", "tkl", "", ""); - addLanguage("Tonga (Nyasa)", "tog", "", ""); - addLanguage("Tonga (Tonga Islands)", "ton", "", "to"); - addLanguage("Tsimshian", "tsi", "", ""); - addLanguage("Tsonga", "tso", "", "ts"); - addLanguage("Tswana", "tsn", "", "tn"); - addLanguage("Tumbuka", "tum", "", ""); - addLanguage("Turkish", "tur", "", "tr"); - addLanguage("Turkmen", "tuk", "", "tk"); - addLanguage("Tuvalu", "tvl", "", ""); - addLanguage("Tuvinian", "tyv", "", ""); - addLanguage("Twi", "twi", "", "tw"); - addLanguage("Udmurt", "udm", "", ""); - addLanguage("Uighur", "uig", "", "ug"); - addLanguage("Ukrainian", "ukr", "", "uk"); - addLanguage("Umbundu", "umb", "", ""); - addLanguage("Uncoded languages", "mis", "", ""); - addLanguage("Undetermined", "und", "", ""); - addLanguage("Upper Sorbian", "hsb", "", ""); - addLanguage("Urdu", "urd", "", "ur"); - addLanguage("Uzbek", "uzb", "", "uz"); - addLanguage("Vai", "vai", "", ""); - addLanguage("Venda", "ven", "", "ve"); - addLanguage("Vietnamese", "vie", "", "vi"); - addLanguage("Votic", "vot", "", ""); - addLanguage("Walloon", "wln", "", "wa"); - addLanguage("Waray", "war", "", ""); - addLanguage("Washo", "was", "", ""); - addLanguage("Welsh", "wel", "cym", "cy"); - addLanguage("Western Frisian", "fry", "", "fy"); - addLanguage("Wolaitta", "wal", "", ""); - addLanguage("Wolof", "wol", "", "wo"); - addLanguage("Xhosa", "xho", "", "xh"); - addLanguage("Yakut", "sah", "", ""); - addLanguage("Yao", "yao", "", ""); - addLanguage("Yapese", "yap", "", ""); - addLanguage("Yiddish", "yid", "", "yi"); - addLanguage("Yoruba", "yor", "", "yo"); - addLanguage("Zapotec", "zap", "", ""); - addLanguage("Zaza", "zza", "", ""); - addLanguage("Zenaga", "zen", "", ""); - addLanguage("Zhuang", "zha", "", "za"); - addLanguage("Zulu", "zul", "", "zu"); - addLanguage("Zuni", "zun", "", ""); + AddLanguage("Not Specified", " ", "", " "); + AddLanguage("Abkhazian", "abk", "", "ab"); + AddLanguage("Achinese", "ace", "", ""); + AddLanguage("Acoli", "ach", "", ""); + AddLanguage("Adangme", "ada", "", ""); + AddLanguage("Adyghe", "ady", "", ""); + AddLanguage("Afar", "aar", "", "aa"); + AddLanguage("Afrikaans", "afr", "", "af"); + AddLanguage("Ainu", "ain", "", ""); + AddLanguage("Akan", "aka", "", "ak"); + AddLanguage("Albanian", "alb", "sqi", "sq"); + AddLanguage("Aleut", "ale", "", ""); + AddLanguage("Amharic", "amh", "", "am"); + AddLanguage("Angika", "anp", "", ""); + AddLanguage("Arabic", "ara", "", "ar"); + AddLanguage("Aragonese", "arg", "", "an"); + AddLanguage("Arapaho", "arp", "", ""); + AddLanguage("Arawak", "arw", "", ""); + AddLanguage("Armenian", "arm", "hye", "hy"); + AddLanguage("Aromanian", "rup", "", ""); + AddLanguage("Assamese", "asm", "", "as"); + AddLanguage("Asturian", "ast", "", ""); + AddLanguage("Avaric", "ava", "", "av"); + AddLanguage("Awadhi", "awa", "", ""); + AddLanguage("Aymara", "aym", "", "ay"); + AddLanguage("Azerbaijani", "aze", "", "az"); + AddLanguage("Balinese", "ban", "", ""); + AddLanguage("Baluchi", "bal", "", ""); + AddLanguage("Bambara", "bam", "", "bm"); + AddLanguage("Basa", "bas", "", ""); + AddLanguage("Bashkir", "bak", "", "ba"); + AddLanguage("Basque", "baq", "eus", "eu"); + AddLanguage("Beja", "bej", "", ""); + AddLanguage("Belarusian", "bel", "", "be"); + AddLanguage("Bemba", "bem", "", ""); + AddLanguage("Bengali", "ben", "", "bn"); + AddLanguage("Bhojpuri", "bho", "", ""); + AddLanguage("Bikol", "bik", "", ""); + AddLanguage("Bini", "bin", "", ""); + AddLanguage("Bislama", "bis", "", "bi"); + AddLanguage("Blin", "byn", "", ""); + AddLanguage("Bosnian", "bos", "", "bs"); + AddLanguage("Braj", "bra", "", ""); + AddLanguage("Breton", "bre", "", "br"); + AddLanguage("Buginese", "bug", "", ""); + AddLanguage("Bulgarian", "bul", "", "bg"); + AddLanguage("Buriat", "bua", "", ""); + AddLanguage("Burmese", "bur", "mya", "my"); + AddLanguage("Caddo", "cad", "", ""); + AddLanguage("Catalan", "cat", "", "ca"); + AddLanguage("Cebuano", "ceb", "", ""); + AddLanguage("Central Khmer", "khm", "", "km"); + AddLanguage("Chamorro", "cha", "", "ch"); + AddLanguage("Chechen", "che", "", "ce"); + AddLanguage("Cherokee", "chr", "", ""); + AddLanguage("Cheyenne", "chy", "", ""); + AddLanguage("Chichewa", "nya", "", "ny"); + AddLanguage("Chinese", "chi", "zho", "zh"); + AddLanguage("Chinook jargon", "chn", "", ""); + AddLanguage("Chipewyan", "chp", "", ""); + AddLanguage("Choctaw", "cho", "", ""); + AddLanguage("Chuukese", "chk", "", ""); + AddLanguage("Chuvash", "chv", "", "cv"); + AddLanguage("Cornish", "cor", "", "kw"); + AddLanguage("Corsican", "cos", "", "co"); + AddLanguage("Cree", "cre", "", "cr"); + AddLanguage("Creek", "mus", "", ""); + AddLanguage("Crimean Tatar", "crh", "", ""); + AddLanguage("Croatian", "hrv", "", "hr"); + AddLanguage("Czech", "cze", "ces", "cs"); + AddLanguage("Dakota", "dak", "", ""); + AddLanguage("Danish", "dan", "", "da"); + AddLanguage("Dargwa", "dar", "", ""); + AddLanguage("Delaware", "del", "", ""); + AddLanguage("Dinka", "din", "", ""); + AddLanguage("Divehi", "div", "", "dv"); + AddLanguage("Dogri", "doi", "", ""); + AddLanguage("Dogrib", "dgr", "", ""); + AddLanguage("Duala", "dua", "", ""); + AddLanguage("Dutch", "dut", "nld", "nl"); + AddLanguage("Dyula", "dyu", "", ""); + AddLanguage("Dzongkha", "dzo", "", "dz"); + AddLanguage("Eastern Frisian", "frs", "", ""); + AddLanguage("Efik", "efi", "", ""); + AddLanguage("Ekajuk", "eka", "", ""); + AddLanguage("English", "eng", "", "en"); + AddLanguage("Erzya", "myv", "", ""); + AddLanguage("Estonian", "est", "", "et"); + AddLanguage("Ewe", "ewe", "", "ee"); + AddLanguage("Ewondo", "ewo", "", ""); + AddLanguage("Fang", "fan", "", ""); + AddLanguage("Fanti", "fat", "", ""); + AddLanguage("Faroese", "fao", "", "fo"); + AddLanguage("Fijian", "fij", "", "fj"); + AddLanguage("Filipino", "fil", "", ""); + AddLanguage("Finnish", "fin", "", "fi"); + AddLanguage("Fon", "fon", "", ""); + AddLanguage("French", "fre", "fra", "fr"); + AddLanguage("Friulian", "fur", "", ""); + AddLanguage("Fulah", "ful", "", "ff"); + AddLanguage("Ga", "gaa", "", ""); + AddLanguage("Gaelic", "gla", "", "gd"); + AddLanguage("Galibi Carib", "car", "", ""); + AddLanguage("Galician", "glg", "", "gl"); + AddLanguage("Ganda", "lug", "", "lg"); + AddLanguage("Gayo", "gay", "", ""); + AddLanguage("Gbaya", "gba", "", ""); + AddLanguage("Georgian", "geo", "kat", "ka"); + AddLanguage("German", "ger", "deu", "de"); + AddLanguage("Gilbertese", "gil", "", ""); + AddLanguage("Gondi", "gon", "", ""); + AddLanguage("Gorontalo", "gor", "", ""); + AddLanguage("Grebo", "grb", "", ""); + AddLanguage("Greek", "gre", "ell", "el"); + AddLanguage("Guarani", "grn", "", "gn"); + AddLanguage("Gujarati", "guj", "", "gu"); + AddLanguage("Gwich'in", "gwi", "", ""); + AddLanguage("Haida", "hai", "", ""); + AddLanguage("Haitian", "hat", "", "ht"); + AddLanguage("Hausa", "hau", "", "ha"); + AddLanguage("Hawaiian", "haw", "", ""); + AddLanguage("Hebrew", "heb", "", "he"); + AddLanguage("Herero", "her", "", "hz"); + AddLanguage("Hiligaynon", "hil", "", ""); + AddLanguage("Hindi", "hin", "", "hi"); + AddLanguage("Hiri Motu", "hmo", "", "ho"); + AddLanguage("Hmong", "hmn", "", ""); + AddLanguage("Hungarian", "hun", "", "hu"); + AddLanguage("Hupa", "hup", "", ""); + AddLanguage("Iban", "iba", "", ""); + AddLanguage("Icelandic", "ice", "isl", "is"); + AddLanguage("Igbo", "ibo", "", "ig"); + AddLanguage("Iloko", "ilo", "", ""); + AddLanguage("Inari Sami", "smn", "", ""); + AddLanguage("Indonesian", "ind", "", "id"); + AddLanguage("Ingush", "inh", "", ""); + AddLanguage("Inuktitut", "iku", "", "iu"); + AddLanguage("Inupiaq", "ipk", "", "ik"); + AddLanguage("Irish", "gle", "", "ga"); + AddLanguage("Italian", "ita", "", "it"); + AddLanguage("Japanese", "jpn", "", "ja"); + AddLanguage("Javanese", "jav", "", "jv"); + AddLanguage("Judeo-Arabic", "jrb", "", ""); + AddLanguage("Judeo-Persian", "jpr", "", ""); + AddLanguage("Kabardian", "kbd", "", ""); + AddLanguage("Kabyle", "kab", "", ""); + AddLanguage("Kachin", "kac", "", ""); + AddLanguage("Kalaallisut", "kal", "", "kl"); + AddLanguage("Kalmyk", "xal", "", ""); + AddLanguage("Kamba", "kam", "", ""); + AddLanguage("Kannada", "kan", "", "kn"); + AddLanguage("Kanuri", "kau", "", "kr"); + AddLanguage("Karachay-Balkar", "krc", "", ""); + AddLanguage("Kara-Kalpak", "kaa", "", ""); + AddLanguage("Karelian", "krl", "", ""); + AddLanguage("Kashmiri", "kas", "", "ks"); + AddLanguage("Kashubian", "csb", "", ""); + AddLanguage("Kazakh", "kaz", "", "kk"); + AddLanguage("Khasi", "kha", "", ""); + AddLanguage("Kikuyu", "kik", "", "ki"); + AddLanguage("Kimbundu", "kmb", "", ""); + AddLanguage("Kinyarwanda", "kin", "", "rw"); + AddLanguage("Kirghiz", "kir", "", "ky"); + AddLanguage("Komi", "kom", "", "kv"); + AddLanguage("Kongo", "kon", "", "kg"); + AddLanguage("Konkani", "kok", "", ""); + AddLanguage("Korean", "kor", "", "ko"); + AddLanguage("Kosraean", "kos", "", ""); + AddLanguage("Kpelle", "kpe", "", ""); + AddLanguage("Kuanyama", "kua", "", "kj"); + AddLanguage("Kumyk", "kum", "", ""); + AddLanguage("Kurdish", "kur", "", "ku"); + AddLanguage("Kurukh", "kru", "", ""); + AddLanguage("Kutenai", "kut", "", ""); + AddLanguage("Ladino", "lad", "", ""); + AddLanguage("Lahnda", "lah", "", ""); + AddLanguage("Lamba", "lam", "", ""); + AddLanguage("Lao", "lao", "", "lo"); + AddLanguage("Latvian", "lav", "", "lv"); + AddLanguage("Lezghian", "lez", "", ""); + AddLanguage("Limburgan", "lim", "", "li"); + AddLanguage("Lingala", "lin", "", "ln"); + AddLanguage("Lithuanian", "lit", "", "lt"); + AddLanguage("Low German", "nds", "", ""); + AddLanguage("Lower Sorbian", "dsb", "", ""); + AddLanguage("Lozi", "loz", "", ""); + AddLanguage("Luba-Katanga", "lub", "", "lu"); + AddLanguage("Luba-Lulua", "lua", "", ""); + AddLanguage("Luiseno", "lui", "", ""); + AddLanguage("Lule Sami", "smj", "", ""); + AddLanguage("Lunda", "lun", "", ""); + AddLanguage("Luo", "luo", "", ""); + AddLanguage("Lushai", "lus", "", ""); + AddLanguage("Luxembourgish", "ltz", "", "lb"); + AddLanguage("Macedonian", "mac", "mkd", "mk"); + AddLanguage("Madurese", "mad", "", ""); + AddLanguage("Magahi", "mag", "", ""); + AddLanguage("Maithili", "mai", "", ""); + AddLanguage("Makasar", "mak", "", ""); + AddLanguage("Malagasy", "mlg", "", "mg"); + AddLanguage("Malay", "may", "msa", "ms"); + AddLanguage("Malayalam", "mal", "", "ml"); + AddLanguage("Maltese", "mlt", "", "mt"); + AddLanguage("Manchu", "mnc", "", ""); + AddLanguage("Mandar", "mdr", "", ""); + AddLanguage("Mandingo", "man", "", ""); + AddLanguage("Manipuri", "mni", "", ""); + AddLanguage("Manx", "glv", "", "gv"); + AddLanguage("Maori", "mao", "mri", "mi"); + AddLanguage("Mapudungun", "arn", "", ""); + AddLanguage("Marathi", "mar", "", "mr"); + AddLanguage("Mari", "chm", "", ""); + AddLanguage("Marshallese", "mah", "", "mh"); + AddLanguage("Marwari", "mwr", "", ""); + AddLanguage("Masai", "mas", "", ""); + AddLanguage("Mende", "men", "", ""); + AddLanguage("Mi'kmaq", "mic", "", ""); + AddLanguage("Minangkabau", "min", "", ""); + AddLanguage("Mirandese", "mwl", "", ""); + AddLanguage("Mohawk", "moh", "", ""); + AddLanguage("Moksha", "mdf", "", ""); + AddLanguage("Moldavian", "mol", "", "mo"); + AddLanguage("Mongo", "lol", "", ""); + AddLanguage("Mongolian", "mon", "", "mn"); + AddLanguage("Mossi", "mos", "", ""); + AddLanguage("Nauru", "nau", "", "na"); + AddLanguage("Navajo", "nav", "", "nv"); + AddLanguage("Ndebele, North", "nde", "", "nd"); + AddLanguage("Ndebele, South", "nbl", "", "nr"); + AddLanguage("Ndonga", "ndo", "", "ng"); + AddLanguage("Neapolitan", "nap", "", ""); + AddLanguage("Nepal Bhasa", "new", "", ""); + AddLanguage("Nepali", "nep", "", "ne"); + AddLanguage("Nias", "nia", "", ""); + AddLanguage("Niuean", "niu", "", ""); + AddLanguage("N'Ko", "nqo", "", ""); + AddLanguage("Nogai", "nog", "", ""); + AddLanguage("Northern Frisian", "frr", "", ""); + AddLanguage("Northern Sami", "sme", "", "se"); + AddLanguage("Norwegian", "nor", "", "no"); + AddLanguage("norwegian bokmål", "nob", "", "nb"); + AddLanguage("Norwegian Nynorsk", "nno", "", "nn"); + AddLanguage("Nyamwezi", "nym", "", ""); + AddLanguage("Nyankole", "nyn", "", ""); + AddLanguage("Nyoro", "nyo", "", ""); + AddLanguage("Nzima", "nzi", "", ""); + AddLanguage("Occitan", "oci", "", "oc"); + AddLanguage("Ojibwa", "oji", "", "oj"); + AddLanguage("Oriya", "ori", "", "or"); + AddLanguage("Oromo", "orm", "", "om"); + AddLanguage("Osage", "osa", "", ""); + AddLanguage("Ossetian", "oss", "", "os"); + AddLanguage("Palauan", "pau", "", ""); + AddLanguage("Pampanga", "pam", "", ""); + AddLanguage("Pangasinan", "pag", "", ""); + AddLanguage("Panjabi", "pan", "", "pa"); + AddLanguage("Papiamento", "pap", "", ""); + AddLanguage("Pedi", "nso", "", ""); + AddLanguage("Persian", "per", "fas", "fa"); + AddLanguage("Pohnpeian", "pon", "", ""); + AddLanguage("Polish", "pol", "", "pl"); + AddLanguage("Portuguese", "por", "", "pt"); + AddLanguage("Pushto", "pus", "", "ps"); + AddLanguage("Quechua", "que", "", "qu"); + AddLanguage("Rajasthani", "raj", "", ""); + AddLanguage("Rapanui", "rap", "", ""); + AddLanguage("Rarotongan", "rar", "", ""); + AddLanguage("Romanian", "rum", "ron", "ro"); + AddLanguage("Romansh", "roh", "", "rm"); + AddLanguage("Romany", "rom", "", ""); + AddLanguage("Rundi", "run", "", "rn"); + AddLanguage("Russian", "rus", "", "ru"); + AddLanguage("Samoan", "smo", "", "sm"); + AddLanguage("Sandawe", "sad", "", ""); + AddLanguage("Sango", "sag", "", "sg"); + AddLanguage("Santali", "sat", "", ""); + AddLanguage("Sardinian", "srd", "", "sc"); + AddLanguage("Sasak", "sas", "", ""); + AddLanguage("Scots", "sco", "", ""); + AddLanguage("Selkup", "sel", "", ""); + AddLanguage("Serbian", "srp", "", "sr"); + AddLanguage("Serer", "srr", "", ""); + AddLanguage("Shan", "shn", "", ""); + AddLanguage("Shona", "sna", "", "sn"); + AddLanguage("Sichuan Yi", "iii", "", "ii"); + AddLanguage("Sicilian", "scn", "", ""); + AddLanguage("Sidamo", "sid", "", ""); + AddLanguage("Siksika", "bla", "", ""); + AddLanguage("Sindhi", "snd", "", "sd"); + AddLanguage("Sinhala", "sin", "", "si"); + AddLanguage("Skolt Sami", "sms", "", ""); + AddLanguage("Slave (Athapascan)", "den", "", ""); + AddLanguage("Slovak", "slo", "slk", "sk"); + AddLanguage("Slovenian", "slv", "", "sl"); + AddLanguage("Somali", "som", "", "so"); + AddLanguage("Soninke", "snk", "", ""); + AddLanguage("Sotho, Southern", "sot", "", "st"); + AddLanguage("Southern Altai", "alt", "", ""); + AddLanguage("Southern Sami", "sma", "", ""); + AddLanguage("Spanish", "spa", "", "es"); + AddLanguage("Sranan Tongo", "srn", "", ""); + AddLanguage("Standard Moroccan Tamazight", "zgh", "", ""); + AddLanguage("Sukuma", "suk", "", ""); + AddLanguage("Sundanese", "sun", "", "su"); + AddLanguage("Susu", "sus", "", ""); + AddLanguage("Swahili", "swa", "", "sw"); + AddLanguage("Swati", "ssw", "", "ss"); + AddLanguage("Swedish", "swe", "", "sv"); + AddLanguage("Swiss German", "gsw", "", ""); + AddLanguage("Syriac", "syr", "", ""); + AddLanguage("Tagalog", "tgl", "", "tl"); + AddLanguage("Tahitian", "tah", "", "ty"); + AddLanguage("Tajik", "tgk", "", "tg"); + AddLanguage("Tamashek", "tmh", "", ""); + AddLanguage("Tamil", "tam", "", "ta"); + AddLanguage("Tatar", "tat", "", "tt"); + AddLanguage("Telugu", "tel", "", "te"); + AddLanguage("Tereno", "ter", "", ""); + AddLanguage("Tetum", "tet", "", ""); + AddLanguage("Thai", "tha", "", "th"); + AddLanguage("Tibetan", "tib", "bod", "bo"); + AddLanguage("Tigre", "tig", "", ""); + AddLanguage("Tigrinya", "tir", "", "ti"); + AddLanguage("Timne", "tem", "", ""); + AddLanguage("Tiv", "tiv", "", ""); + AddLanguage("Tlingit", "tli", "", ""); + AddLanguage("Tok Pisin", "tpi", "", ""); + AddLanguage("Tokelau", "tkl", "", ""); + AddLanguage("Tonga (Nyasa)", "tog", "", ""); + AddLanguage("Tonga (Tonga Islands)", "ton", "", "to"); + AddLanguage("Tsimshian", "tsi", "", ""); + AddLanguage("Tsonga", "tso", "", "ts"); + AddLanguage("Tswana", "tsn", "", "tn"); + AddLanguage("Tumbuka", "tum", "", ""); + AddLanguage("Turkish", "tur", "", "tr"); + AddLanguage("Turkmen", "tuk", "", "tk"); + AddLanguage("Tuvalu", "tvl", "", ""); + AddLanguage("Tuvinian", "tyv", "", ""); + AddLanguage("Twi", "twi", "", "tw"); + AddLanguage("Udmurt", "udm", "", ""); + AddLanguage("Uighur", "uig", "", "ug"); + AddLanguage("Ukrainian", "ukr", "", "uk"); + AddLanguage("Umbundu", "umb", "", ""); + AddLanguage("Uncoded languages", "mis", "", ""); + AddLanguage("Undetermined", "und", "", ""); + AddLanguage("Upper Sorbian", "hsb", "", ""); + AddLanguage("Urdu", "urd", "", "ur"); + AddLanguage("Uzbek", "uzb", "", "uz"); + AddLanguage("Vai", "vai", "", ""); + AddLanguage("Venda", "ven", "", "ve"); + AddLanguage("Vietnamese", "vie", "", "vi"); + AddLanguage("Votic", "vot", "", ""); + AddLanguage("Walloon", "wln", "", "wa"); + AddLanguage("Waray", "war", "", ""); + AddLanguage("Washo", "was", "", ""); + AddLanguage("Welsh", "wel", "cym", "cy"); + AddLanguage("Western Frisian", "fry", "", "fy"); + AddLanguage("Wolaitta", "wal", "", ""); + AddLanguage("Wolof", "wol", "", "wo"); + AddLanguage("Xhosa", "xho", "", "xh"); + AddLanguage("Yakut", "sah", "", ""); + AddLanguage("Yao", "yao", "", ""); + AddLanguage("Yapese", "yap", "", ""); + AddLanguage("Yiddish", "yid", "", "yi"); + AddLanguage("Yoruba", "yor", "", "yo"); + AddLanguage("Zapotec", "zap", "", ""); + AddLanguage("Zaza", "zza", "", ""); + AddLanguage("Zenaga", "zen", "", ""); + AddLanguage("Zhuang", "zha", "", "za"); + AddLanguage("Zulu", "zul", "", "zu"); + AddLanguage("Zuni", "zun", "", ""); } diff --git a/Time_Shift/Util/Notification.cs b/Time_Shift/Util/Notification.cs index 9f6a227..d77c0a9 100644 --- a/Time_Shift/Util/Notification.cs +++ b/Time_Shift/Util/Notification.cs @@ -92,7 +92,7 @@ private static bool InputQuery(string caption, string prompt, ref string value) form.StartPosition = FormStartPosition.CenterScreen; - var lblPrompt = new System.Windows.Forms.Label + var lblPrompt = new Label { Parent = form, AutoSize = true, @@ -101,7 +101,7 @@ private static bool InputQuery(string caption, string prompt, ref string value) Text = prompt }; - var edInput = new System.Windows.Forms.TextBox + var edInput = new TextBox { Parent = form, Left = lblPrompt.Left, @@ -116,7 +116,7 @@ private static bool InputQuery(string caption, string prompt, ref string value) //Command buttons should be 50x14 dlus Size buttonSize = ScaleSize(new Size(50, 14), dialogUnits.Width / 4, dialogUnits.Height / 8); - System.Windows.Forms.Button bbOk = new System.Windows.Forms.Button + Button bbOk = new Button { Parent = form, Text = "OK", @@ -126,7 +126,7 @@ private static bool InputQuery(string caption, string prompt, ref string value) bbOk.Location = new Point(MulDiv(38, dialogUnits.Width, 4), buttonTop); bbOk.Size = buttonSize; - System.Windows.Forms.Button bbCancel = new System.Windows.Forms.Button + Button bbCancel = new Button { Parent = form, Text = "Cancel", @@ -141,10 +141,7 @@ private static bool InputQuery(string caption, string prompt, ref string value) value = edInput.Text; return true; } - else - { - return false; - } + return false; } } } \ No newline at end of file diff --git a/Time_Shift/Util/TaskAsync.cs b/Time_Shift/Util/TaskAsync.cs index 66b9596..bf0c765 100644 --- a/Time_Shift/Util/TaskAsync.cs +++ b/Time_Shift/Util/TaskAsync.cs @@ -2,9 +2,8 @@ using System.Diagnostics; using System.Threading.Tasks; -namespace ChapterTool +namespace ChapterTool.Util { - public static class TaskAsync { public static async Task RunProcessAsync(string fileName, string args, string workingDirectory = "") diff --git a/Time_Shift_Test/SharpDvdInfo/DvdInfoContainerTests.cs b/Time_Shift_Test/SharpDvdInfo/DvdInfoContainerTests.cs index d483303..b01b480 100644 --- a/Time_Shift_Test/SharpDvdInfo/DvdInfoContainerTests.cs +++ b/Time_Shift_Test/SharpDvdInfo/DvdInfoContainerTests.cs @@ -1,7 +1,5 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; using ChapterTool.Util; using FluentAssertions; From 0d1de6966f18e5e973c7235a40d232ef2a81b8c6 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sat, 17 Dec 2016 12:40:48 +0800 Subject: [PATCH 18/30] Set Clip as an internal class. --- Time_Shift/Time_Shift.csproj | 7 +++-- Time_Shift/Util/ChapterData/MplsData.cs | 25 ++++++++++++----- Time_Shift/Util/Clip.cs | 37 ------------------------- 3 files changed, 23 insertions(+), 46 deletions(-) delete mode 100644 Time_Shift/Util/Clip.cs diff --git a/Time_Shift/Time_Shift.csproj b/Time_Shift/Time_Shift.csproj index 9ff23b2..51dd948 100644 --- a/Time_Shift/Time_Shift.csproj +++ b/Time_Shift/Time_Shift.csproj @@ -138,7 +138,6 @@ - Component @@ -197,9 +196,11 @@ Form1.cs + Designer Form1.cs + Designer Form2.cs @@ -216,7 +217,9 @@ FormUpdater.cs - + + Designer + Designer ResXFileCodeGenerator diff --git a/Time_Shift/Util/ChapterData/MplsData.cs b/Time_Shift/Util/ChapterData/MplsData.cs index ea24731..bb510aa 100644 --- a/Time_Shift/Util/ChapterData/MplsData.cs +++ b/Time_Shift/Util/ChapterData/MplsData.cs @@ -52,12 +52,11 @@ public MplsData(string path) private void ParseMpls() { - int playlistMarkSectionStartAddress, playItemNumber, playItemEntries; - ParseHeader(out playlistMarkSectionStartAddress, out playItemNumber, out playItemEntries); + ParseHeader(out int playlistMarkSectionStartAddress, out int playItemNumber, out int playItemEntries); for (var playItemOrder = 0; playItemOrder < playItemNumber; playItemOrder++) { - int lengthOfPlayItem, itemStartAdress, streamCount; - ParsePlayItem(playItemEntries, out lengthOfPlayItem, out itemStartAdress, out streamCount); + + ParsePlayItem(playItemEntries, out int lengthOfPlayItem, out int itemStartAdress, out int streamCount); for (int streamOrder = 0; streamOrder < streamCount; streamOrder++) { ParseStream(itemStartAdress, streamOrder, playItemOrder); @@ -84,7 +83,7 @@ private void ParseHeader(out int playlistMarkSectionStartAddress, out int playIt private bool ParsePlayItem(int playItemEntries, out int lengthOfPlayItem, out int itemStartAdress, out int streamCount) { - bool mulitAngle = false; + bool mulitAngle = false; lengthOfPlayItem = Byte2Int16(_data, playItemEntries); var bytes = new byte[lengthOfPlayItem + 2]; Array.Copy(_data, playItemEntries, bytes, 0, lengthOfPlayItem + 2); @@ -233,6 +232,19 @@ public ChapterInfo ToChapterInfo(int index, bool combineChapter) } } + public class Clip + { + public string Name { get; set; } + public List TimeStamp { get; } = new List(); + public int Fps { get; set; } + public int Length { get; set; } + public int RelativeTimeIn { get; set; } + public int RelativeTimeOut { get; set; } + public int TimeIn { get; set; } + public int TimeOut { get; set; } + public override string ToString() => $"{Name} - {MplsData.Pts2Time(Length)}"; + } + internal static class StreamAttribute { public delegate void LogEventHandler(string message); @@ -242,8 +254,7 @@ internal static class StreamAttribute public static void LogStreamAttributes(byte[] stream, string clipName) { var streamCodingType = stream[0x0b]; - string streamCoding; - var result = StreamCoding.TryGetValue(streamCodingType, out streamCoding); + var result = StreamCoding.TryGetValue(streamCodingType, out string streamCoding); if (!result) streamCoding = "und"; OnLog?.Invoke($"Stream[{clipName}] Type: {streamCoding}"); if (0x01 != streamCodingType && 0x02 != streamCodingType && diff --git a/Time_Shift/Util/Clip.cs b/Time_Shift/Util/Clip.cs deleted file mode 100644 index 9a75a48..0000000 --- a/Time_Shift/Util/Clip.cs +++ /dev/null @@ -1,37 +0,0 @@ -// **************************************************************************** -// -// Copyright (C) 2014-2016 TautCony (TautCony@vcb-s.com) -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// **************************************************************************** -using System.Collections.Generic; -using ChapterTool.Util.ChapterData; - -namespace ChapterTool.Util -{ - public class Clip - { - public string Name { get; set; } - public List TimeStamp { get; } = new List(); - public int Fps { get; set; } - public int Length { get; set; } - public int RelativeTimeIn { get; set; } - public int RelativeTimeOut { get; set; } - public int TimeIn { get; set; } - public int TimeOut { get; set; } - public override string ToString() => $"{Name} - {MplsData.Pts2Time(Length)}"; - } -} From e28b082750898fc0eaa31f22af7a61e1121667c0 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sat, 17 Dec 2016 12:41:37 +0800 Subject: [PATCH 19/30] Add some more improvement. --- Time_Shift/Forms/Form1.Designer.cs | 56 ++++++++++++------------ Time_Shift/Forms/Form1.cs | 2 +- Time_Shift/Time_Shift.csproj.DotSettings | 2 +- Time_Shift/Util/ToolKits.cs | 8 ++-- 4 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Time_Shift/Forms/Form1.Designer.cs b/Time_Shift/Forms/Form1.Designer.cs index bada5ba..b1ba651 100644 --- a/Time_Shift/Forms/Form1.Designer.cs +++ b/Time_Shift/Forms/Form1.Designer.cs @@ -31,6 +31,9 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.btnLoad = new System.Windows.Forms.Button(); + this.loadMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.reloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.appendToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.btnSave = new System.Windows.Forms.Button(); this.lbPath = new System.Windows.Forms.Label(); this.btnTrans = new System.Windows.Forms.Button(); @@ -70,9 +73,7 @@ private void InitializeComponent() this.tsTips = new System.Windows.Forms.ToolStripStatusLabel(); this.tsProgressBar1 = new System.Windows.Forms.ToolStripProgressBar(); this.tsBtnExpand = new System.Windows.Forms.ToolStripDropDownButton(); - this.loadMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); - this.reloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.appendToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.loadMenuStrip.SuspendLayout(); this.deviationMenuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); this.combineMenuStrip.SuspendLayout(); @@ -80,7 +81,6 @@ private void InitializeComponent() this.createZonestMenuStrip.SuspendLayout(); this.panel1.SuspendLayout(); this.statusStrip1.SuspendLayout(); - this.loadMenuStrip.SuspendLayout(); this.SuspendLayout(); // // btnLoad @@ -100,6 +100,28 @@ private void InitializeComponent() this.btnLoad.UseVisualStyleBackColor = true; this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); // + // loadMenuStrip + // + this.loadMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.reloadToolStripMenuItem, + this.appendToolStripMenuItem}); + this.loadMenuStrip.Name = "loadMenuStrip"; + this.loadMenuStrip.Size = new System.Drawing.Size(125, 48); + // + // reloadToolStripMenuItem + // + this.reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; + this.reloadToolStripMenuItem.Size = new System.Drawing.Size(124, 22); + this.reloadToolStripMenuItem.Text = "重新载入"; + this.reloadToolStripMenuItem.Click += new System.EventHandler(this.reloadToolStripMenuItem_Click); + // + // appendToolStripMenuItem + // + this.appendToolStripMenuItem.Name = "appendToolStripMenuItem"; + this.appendToolStripMenuItem.Size = new System.Drawing.Size(124, 22); + this.appendToolStripMenuItem.Text = "追加合并"; + this.appendToolStripMenuItem.Click += new System.EventHandler(this.appendToolStripMenuItem_Click); + // // btnSave // this.btnSave.FlatAppearance.BorderColor = System.Drawing.SystemColors.Highlight; @@ -531,7 +553,7 @@ private void InitializeComponent() // this.tsTips.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.tsTips.Name = "tsTips"; - this.tsTips.Size = new System.Drawing.Size(443, 17); + this.tsTips.Size = new System.Drawing.Size(412, 17); this.tsTips.Spring = true; this.tsTips.Text = " "; this.tsTips.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -553,28 +575,6 @@ private void InitializeComponent() this.tsBtnExpand.Text = "toolStripDropDownButton1"; this.tsBtnExpand.Click += new System.EventHandler(this.btnExpand_Click); // - // loadMenuStrip - // - this.loadMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.reloadToolStripMenuItem, - this.appendToolStripMenuItem}); - this.loadMenuStrip.Name = "loadMenuStrip"; - this.loadMenuStrip.Size = new System.Drawing.Size(153, 70); - // - // reloadToolStripMenuItem - // - this.reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; - this.reloadToolStripMenuItem.Size = new System.Drawing.Size(152, 22); - this.reloadToolStripMenuItem.Text = "重新载入"; - this.reloadToolStripMenuItem.Click += new System.EventHandler(this.reloadToolStripMenuItem_Click); - // - // appendToolStripMenuItem - // - this.appendToolStripMenuItem.Name = "appendToolStripMenuItem"; - this.appendToolStripMenuItem.Size = new System.Drawing.Size(152, 22); - this.appendToolStripMenuItem.Text = "追加合并"; - this.appendToolStripMenuItem.Click += new System.EventHandler(this.appendToolStripMenuItem_Click); - // // Form1 // this.AllowDrop = true; @@ -607,6 +607,7 @@ private void InitializeComponent() this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter); this.Move += new System.EventHandler(this.Form1_Move); + this.loadMenuStrip.ResumeLayout(false); this.deviationMenuStrip.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); this.combineMenuStrip.ResumeLayout(false); @@ -616,7 +617,6 @@ private void InitializeComponent() this.panel1.PerformLayout(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); - this.loadMenuStrip.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index 3cf662a..a34b4a0 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -650,7 +650,7 @@ private async void LoadBDMV() tsTips.Text = Resources.Tips_Loading; Application.DoEvents(); BDMVData.OnLog += Log; - _bdmvGroup = await BDMVData.GetChapter(FilePath); + _bdmvGroup = await BDMVData.GetChapterAsync(FilePath); BDMVData.OnLog -= Log; if (_bdmvGroup == null || _bdmvGroup.Count == 0) { diff --git a/Time_Shift/Time_Shift.csproj.DotSettings b/Time_Shift/Time_Shift.csproj.DotSettings index 73e9656..c54c126 100644 --- a/Time_Shift/Time_Shift.csproj.DotSettings +++ b/Time_Shift/Time_Shift.csproj.DotSettings @@ -1,2 +1,2 @@  - CSharp60 \ No newline at end of file + CSharp70 \ No newline at end of file diff --git a/Time_Shift/Util/ToolKits.cs b/Time_Shift/Util/ToolKits.cs index 9535cf9..617689d 100644 --- a/Time_Shift/Util/ToolKits.cs +++ b/Time_Shift/Util/ToolKits.cs @@ -111,10 +111,12 @@ public static string GetUTF8String(this byte[] buffer) { if (buffer == null) return null; if (buffer.Length <= 3) return Encoding.UTF8.GetString(buffer); - if (buffer[0] == 0xef && buffer[1] == 0xbb && buffer[2] == 0xbf) - { + if (buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) return new UTF8Encoding(false).GetString(buffer, 3, buffer.Length - 3); - } + if (buffer[0] == 0xFF && buffer[1] == 0xFE) + return Encoding.Unicode.GetString(buffer); + if (buffer[0] == 0xFE && buffer[1] == 0xFF) + return Encoding.BigEndianUnicode.GetString(buffer); return Encoding.UTF8.GetString(buffer); } From fec4e9b0f39e8bc1d9ff40b81dd5c3e5d8a86386 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sat, 17 Dec 2016 12:52:11 +0800 Subject: [PATCH 20/30] Rename some forms. --- Time_Shift/Forms/Form1.cs | 18 ++++++++---------- ...Form2.Designer.cs => FormAbout.Designer.cs} | 4 ++-- Time_Shift/Forms/{Form2.cs => FormAbout.cs} | 4 ++-- .../Forms/{Form2.resx => FormAbout.resx} | 0 ...Form3.Designer.cs => FormColor.Designer.cs} | 2 +- Time_Shift/Forms/{Form3.cs => FormColor.cs} | 4 ++-- .../Forms/{Form3.resx => FormColor.resx} | 0 7 files changed, 15 insertions(+), 17 deletions(-) rename Time_Shift/Forms/{Form2.Designer.cs => FormAbout.Designer.cs} (99%) rename Time_Shift/Forms/{Form2.cs => FormAbout.cs} (98%) rename Time_Shift/Forms/{Form2.resx => FormAbout.resx} (100%) rename Time_Shift/Forms/{Form3.Designer.cs => FormColor.Designer.cs} (99%) rename Time_Shift/Forms/{Form3.cs => FormColor.cs} (98%) rename Time_Shift/Forms/{Form3.resx => FormColor.resx} (100%) diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index a34b4a0..f12fb93 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -267,7 +267,7 @@ private void progressBar1_Click(object sender, EventArgs e) Log(string.Format(Resources.Log_About_Form_Click, _poi[0])); if (_poi[0] >= _poi[1]) { - Form2 version = new Form2(); + FormAbout version = new FormAbout(); Log(Resources.Log_About_Form_Opened); version.Show(); _poi[0] = 00; @@ -290,7 +290,7 @@ private void Form1_DragDrop(object sender, DragEventArgs e) if(Directory.Exists(FilePath)) { _isUrl = true; - LoadBDMV(); + LoadBDMVAsync(); return; } _isUrl = false; @@ -642,7 +642,7 @@ private void LoadWebVTT() tsTips.Text = Resources.Tips_Load_Success; } - private async void LoadBDMV() + private async void LoadBDMVAsync() { SetDefault(); try @@ -684,7 +684,7 @@ private async void LoadBDMV() private void reloadToolStripMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(FilePath)) return; - if (_isUrl) LoadBDMV(); + if (_isUrl) LoadBDMVAsync(); else if (Loadfile()) UpdataGridView(); } @@ -696,8 +696,7 @@ private void appendToolStripMenuItem_Click(object sender, EventArgs e) openFileDialog1.InitialDirectory = dir; if (openFileDialog1.ShowDialog() != DialogResult.OK) return; string newFile = openFileDialog1.FileName; - MplsData appendMpls; - LoadMpls(out appendMpls, false, newFile); + LoadMpls(out MplsData appendMpls, false, newFile); _rawMpls.EntireClip.TimeStamp.AddRange(appendMpls.EntireClip.TimeStamp.Select(stamp=>stamp+ _rawMpls.EntireClip.Length)); _rawMpls.EntireClip.Length += appendMpls.EntireClip.Length; CombineChapter = true; @@ -1072,8 +1071,7 @@ private void FrameShiftForward() var fpsIndex = comboBox1.SelectedIndex + 1; if (fpsIndex < 1) return; var shiftFramesString = Notification.InputBox("向前平移N帧,小于0的将被删除", "请输入所需平移的帧数", "0"); - int shiftFrames; - if (!int.TryParse(shiftFramesString, out shiftFrames)) return; + if (!int.TryParse(shiftFramesString, out int shiftFrames)) return; TimeSpan shiftTime = TimeSpan.FromTicks((long) Math.Round(shiftFrames/MplsData.FrameRate[fpsIndex]*TimeSpan.TicksPerSecond)); _info.UpdataInfo(shiftTime); _info.Chapters = _info.Chapters.SkipWhile(item => item.Time < TimeSpan.Zero).ToList(); @@ -1085,14 +1083,14 @@ private void FrameShiftForward() #endregion #region Form Color - private Form3 _fcolor; + private FormColor _fcolor; private void Color_MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; if (_fcolor == null) { - _fcolor = new Form3(this); + _fcolor = new FormColor(this); } Log(Resources.Log_Color_Setting_Form_Open); _fcolor.Show(); diff --git a/Time_Shift/Forms/Form2.Designer.cs b/Time_Shift/Forms/FormAbout.Designer.cs similarity index 99% rename from Time_Shift/Forms/Form2.Designer.cs rename to Time_Shift/Forms/FormAbout.Designer.cs index b90c77b..8c9c667 100644 --- a/Time_Shift/Forms/Form2.Designer.cs +++ b/Time_Shift/Forms/FormAbout.Designer.cs @@ -1,6 +1,6 @@ namespace ChapterTool.Forms { - partial class Form2 + partial class FormAbout { /// /// Required designer variable. @@ -29,7 +29,7 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form2)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAbout)); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); diff --git a/Time_Shift/Forms/Form2.cs b/Time_Shift/Forms/FormAbout.cs similarity index 98% rename from Time_Shift/Forms/Form2.cs rename to Time_Shift/Forms/FormAbout.cs index 62b87aa..4102c43 100644 --- a/Time_Shift/Forms/Form2.cs +++ b/Time_Shift/Forms/FormAbout.cs @@ -27,10 +27,10 @@ namespace ChapterTool.Forms { - public partial class Form2 : Form + public partial class FormAbout : Form { private readonly int _poi; - public Form2() + public FormAbout() { InitializeComponent(); //this.SizeChanged += new System.EventHandler(this.Form2_SizeChanged); diff --git a/Time_Shift/Forms/Form2.resx b/Time_Shift/Forms/FormAbout.resx similarity index 100% rename from Time_Shift/Forms/Form2.resx rename to Time_Shift/Forms/FormAbout.resx diff --git a/Time_Shift/Forms/Form3.Designer.cs b/Time_Shift/Forms/FormColor.Designer.cs similarity index 99% rename from Time_Shift/Forms/Form3.Designer.cs rename to Time_Shift/Forms/FormColor.Designer.cs index 3bfade6..f4a3bff 100644 --- a/Time_Shift/Forms/Form3.Designer.cs +++ b/Time_Shift/Forms/FormColor.Designer.cs @@ -1,6 +1,6 @@ namespace ChapterTool.Forms { - partial class Form3 + partial class FormColor { /// /// Required designer variable. diff --git a/Time_Shift/Forms/Form3.cs b/Time_Shift/Forms/FormColor.cs similarity index 98% rename from Time_Shift/Forms/Form3.cs rename to Time_Shift/Forms/FormColor.cs index 2caba7a..df03478 100644 --- a/Time_Shift/Forms/Form3.cs +++ b/Time_Shift/Forms/FormColor.cs @@ -25,11 +25,11 @@ namespace ChapterTool.Forms { - public partial class Form3 : Form + public partial class FormColor : Form { private readonly Form1 _mainWindow; private readonly List _currentSetting; - public Form3(Form1 mainWindow) + public FormColor(Form1 mainWindow) { InitializeComponent(); MaximizeBox = false; diff --git a/Time_Shift/Forms/Form3.resx b/Time_Shift/Forms/FormColor.resx similarity index 100% rename from Time_Shift/Forms/Form3.resx rename to Time_Shift/Forms/FormColor.resx From 0c00b2110223fd73f8b8142dbd1f86d8becdc500 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sat, 17 Dec 2016 13:40:59 +0800 Subject: [PATCH 21/30] Fix icon extract. --- Time_Shift/Forms/Form1.cs | 9 +++++---- Time_Shift/Forms/FormPreview.cs | 2 +- Time_Shift/Forms/FormUpdater.cs | 3 +-- Time_Shift/Time_Shift.csproj | 20 ++++++++++---------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index f12fb93..4c0f5b0 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -21,6 +21,7 @@ using System.IO; using System.Xml; using System.Linq; +using System.Text; using System.Drawing; using Microsoft.Win32; using ChapterTool.Util; @@ -358,15 +359,15 @@ private enum FileType private static readonly Lazy MainFilter = new Lazy(() => { Func, string> getType = enumerable => enumerable.Aggregate(string.Empty, (current, type) => current + $"*.{type};"); - string ret = Resources.File_Filter_All_Support; + StringBuilder ret = new StringBuilder(Resources.File_Filter_All_Support); string types = getType(SupportTypes.SelectMany(supportType => supportType.Value)); - ret += $"({types.TrimEnd(';')})|{types}"; + ret.Append($" ({types.TrimEnd(';')})|{types}"); foreach (var supportType in SupportTypes) { types = getType(supportType.Value); - ret += $"|{supportType.Key}({types.TrimEnd(';')})|{types}"; + ret.Append($"|{supportType.Key} ({types.TrimEnd(';')})|{types}"); } - return ret; + return ret.ToString(); }); private void btnLoad_Click(object sender, EventArgs e) diff --git a/Time_Shift/Forms/FormPreview.cs b/Time_Shift/Forms/FormPreview.cs index a969d97..90ee1c8 100644 --- a/Time_Shift/Forms/FormPreview.cs +++ b/Time_Shift/Forms/FormPreview.cs @@ -37,7 +37,7 @@ public FormPreview(string text, Form1 mainWindow) _mainWindow = mainWindow; _mainPos = mainWindow.Location; ScrollBarSet(); - Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); + Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); } private void ScrollBarSet() diff --git a/Time_Shift/Forms/FormUpdater.cs b/Time_Shift/Forms/FormUpdater.cs index 105eaad..b2f4bb5 100644 --- a/Time_Shift/Forms/FormUpdater.cs +++ b/Time_Shift/Forms/FormUpdater.cs @@ -2,7 +2,6 @@ using System.IO; using System.Net; using System.Drawing; -using System.Reflection; using System.Windows.Forms; using System.ComponentModel; @@ -25,7 +24,7 @@ public partial class FormUpdater : Form public FormUpdater(string currentProgram, Version version, string baseUrl) { InitializeComponent(); - Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); + Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); _newPath = currentProgram + ".new"; _exePath = currentProgram; _backupPath = currentProgram + ".bak"; diff --git a/Time_Shift/Time_Shift.csproj b/Time_Shift/Time_Shift.csproj index 51dd948..9e6b9a9 100644 --- a/Time_Shift/Time_Shift.csproj +++ b/Time_Shift/Time_Shift.csproj @@ -149,17 +149,17 @@ Form1.cs - + Form - - Form2.cs + + FormAbout.cs - + Form - - Form3.cs + + FormColor.cs Form @@ -202,11 +202,11 @@ Form1.cs Designer - - Form2.cs + + FormAbout.cs - - Form3.cs + + FormColor.cs FormLog.cs From f371dd2a9d224c003d6f79f00b71429be58b6649 Mon Sep 17 00:00:00 2001 From: tautcony Date: Fri, 23 Dec 2016 15:39:02 +0800 Subject: [PATCH 22/30] Improve code style. --- Time_Shift/Forms/Form1.Designer.cs | 3 +- Time_Shift/Forms/Form1.cs | 54 +++++++++++++----------------- Time_Shift/Forms/Form1.resx | 15 --------- Time_Shift/Forms/FormColor.cs | 14 ++++---- Time_Shift/Forms/FormPreview.cs | 11 ++++-- 5 files changed, 41 insertions(+), 56 deletions(-) diff --git a/Time_Shift/Forms/Form1.Designer.cs b/Time_Shift/Forms/Form1.Designer.cs index b1ba651..b81d744 100644 --- a/Time_Shift/Forms/Form1.Designer.cs +++ b/Time_Shift/Forms/Form1.Designer.cs @@ -553,7 +553,7 @@ private void InitializeComponent() // this.tsTips.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.tsTips.Name = "tsTips"; - this.tsTips.Size = new System.Drawing.Size(412, 17); + this.tsTips.Size = new System.Drawing.Size(443, 17); this.tsTips.Spring = true; this.tsTips.Text = " "; this.tsTips.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; @@ -606,7 +606,6 @@ private void InitializeComponent() this.Load += new System.EventHandler(this.Form1_Load); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.Form1_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.Form1_DragEnter); - this.Move += new System.EventHandler(this.Form1_Move); this.loadMenuStrip.ResumeLayout(false); this.deviationMenuStrip.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index 4c0f5b0..74fac15 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -706,11 +706,18 @@ private void appendToolStripMenuItem_Click(object sender, EventArgs e) } #endregion + #region Global status + private bool AutoGenName => cbAutoGenName.Checked; + private bool Shift => cbShift.Checked; + private bool Round => cbRound.Checked; + #endregion + #region Save File private void btnSave_Click(object sender, EventArgs e) => SaveFile(savingType.SelectedIndex); private string _customSavingPath = string.Empty; + private void btnSave_MouseUp(object sender, MouseEventArgs e) { try @@ -747,12 +754,12 @@ private void SaveInfoLog(string savePath) { Log(string.Format(Resources.Log_Save_Language, xmlLang.Items[xmlLang.SelectedIndex])); } - Log(string.Format(Resources.Log_Save_Is_Use_Chapter_Name, !cbAutoGenName.Checked)); + Log(string.Format(Resources.Log_Save_Is_Use_Chapter_Name, !AutoGenName)); Log(string.Format(Resources.Log_Save_Is_Use_Chapter_Name_Template, cbChapterName.Checked)); Log(string.Format(Resources.Log_Save_Chapter_Order_Shift, numericUpDown1.Value)); //Log(string.Format(Resources.Log_Save_Time_Factor, cbMul1k1.Checked)); - Log(string.Format(Resources.Log_Save_Time_Shift, cbShift.Checked)); - if (cbShift.Checked) + Log(string.Format(Resources.Log_Save_Time_Shift, Shift)); + if (Shift) { Log(string.Format(Resources.Log_Save_Time_Shift_Amount,_info.Expr)); } @@ -792,11 +799,11 @@ private void SaveFile(int saveType) switch (saveType) { case 0: //TXT - _info.SaveText(savePath, cbAutoGenName.Checked); + _info.SaveText(savePath, AutoGenName); break; case 1: //XML string key = RLang.Match(xmlLang.Items[xmlLang.SelectedIndex].ToString()).Groups["lang"].ToString(); - _info.SaveXml(savePath, string.IsNullOrWhiteSpace(key) ? "" : LanguageSelectionContainer.Languages[key], cbAutoGenName.Checked); + _info.SaveXml(savePath, string.IsNullOrWhiteSpace(key) ? "" : LanguageSelectionContainer.Languages[key], AutoGenName); break; case 2: //QPF _info.SaveQpfile(savePath); @@ -808,7 +815,7 @@ private void SaveFile(int saveType) _info.SaveTsmuxerMeta(savePath); break; case 5: //CUE - _info.SaveCue(Path.GetFileName(FilePath), savePath, cbAutoGenName.Checked); + _info.SaveCue(Path.GetFileName(FilePath), savePath, AutoGenName); break; } tsProgressBar1.Value = 100; @@ -861,7 +868,7 @@ private void comboBox2_SelectionChangeCommitted(object sender, EventArgs e) { _info = _bdmvGroup[ClipSeletIndex]; } - if (cbShift.Checked) + if (Shift) { cbShift_CheckedChanged(new object(), new EventArgs()); } @@ -881,7 +888,7 @@ private void combineToolStripMenuItem_Click(object sender, EventArgs e) { GetChapterInfoFromIFO(ClipSeletIndex); } - if (cbShift.Checked) + if (Shift) { cbShift_CheckedChanged(new object(), new EventArgs()); } @@ -961,11 +968,11 @@ private void UpdataGridView(int fpsIndex = 0, bool updateFrameInfo = true) { if (clearRows) { - dataGridView1.Rows.Add(_info.GetRow(i, cbAutoGenName.Checked)); + dataGridView1.Rows.Add(_info.GetRow(i, AutoGenName)); } else { - _info.EditRow(dataGridView1.Rows[i], cbAutoGenName.Checked); + _info.EditRow(dataGridView1.Rows[i], AutoGenName); } Application.DoEvents(); } @@ -1018,7 +1025,7 @@ private void GetFramInfo(int index = 0) { var settingAccuracy = CostumeAccuracy; - if (cbRound.Checked) + if (Round) { //当未手动提供帧率[del]并且不是mpls或ifo这种已知帧率的,[/del]才进行蒙帧率操作 index = index == 0/* && _rawMpls == null && _ifoGroup == null */? GetAutofps(settingAccuracy) : index; @@ -1033,9 +1040,9 @@ private void GetFramInfo(int index = 0) foreach (var chapter in _info.Chapters) { var frams = _info.Expr.Eval(chapter.Time.TotalSeconds) * MplsData.FrameRate[index]; - if (cbRound.Checked) + if (Round) { - var rounded = cbRound.Checked ? Math.Round(frams, MidpointRounding.AwayFromZero) : frams; + var rounded = Round ? Math.Round(frams, MidpointRounding.AwayFromZero) : frams; bool accuracy = Math.Abs(frams - rounded) < settingAccuracy; chapter.FramsInfo = $"{rounded}{(accuracy ? " K" : " *")}"; } @@ -1115,7 +1122,6 @@ public Color BackChange { BackColor = value; statusStrip1.BackColor = value; - //btnExpand.BackColor = value; } private get { return BackColor; } } @@ -1142,7 +1148,6 @@ public Color MouseOverColor btnTrans.FlatAppearance.MouseOverBackColor = value; btnLog.FlatAppearance.MouseOverBackColor = value; btnPreview.FlatAppearance.MouseOverBackColor = value; - //btnExpand.FlatAppearance.MouseOverBackColor = value; } private get { return btnLoad.FlatAppearance.MouseOverBackColor; } } @@ -1155,7 +1160,6 @@ public Color MouseDownColor btnTrans.FlatAppearance.MouseDownBackColor = value; btnLog.FlatAppearance.MouseDownBackColor = value; btnPreview.FlatAppearance.MouseDownBackColor = value; - //btnExpand.FlatAppearance.MouseDownBackColor = value; } private get { return btnLoad.FlatAppearance.MouseDownBackColor; } } @@ -1168,7 +1172,6 @@ public Color BordBackColor btnTrans.FlatAppearance.BorderColor = value; btnLog.FlatAppearance.BorderColor = value; btnPreview.FlatAppearance.BorderColor = value; - //btnExpand.FlatAppearance.BorderColor = value; dataGridView1.GridColor = value; } private get { return btnLoad.FlatAppearance.BorderColor; } @@ -1180,7 +1183,6 @@ public Color TextFrontColor ForeColor = value; numericUpDown1.ForeColor = value; textBoxExpression.ForeColor = value; - //btnExpand.ForeColor = value; comboBox1.ForeColor = value; comboBox2.ForeColor = value; xmlLang.ForeColor = value; @@ -1382,12 +1384,12 @@ private void cbShift_CheckedChanged(object sender, EventArgs e) { if (!IsPathValid) { - if(cbShift.Checked) + if(Shift) ParseExpression(textBoxExpression.Text); return; } if (_info == null) return; - _info.Expr = cbShift.Checked ? ParseExpression(textBoxExpression.Text) : Expression.Empty; + _info.Expr = Shift ? ParseExpression(textBoxExpression.Text) : Expression.Empty; UpdataGridView(); } @@ -1434,22 +1436,14 @@ private void btnPreview_Click(object sender, EventArgs e) if (!IsPathValid) return; if (_previewForm == null) { - _previewForm = new FormPreview(_info.GetText(cbAutoGenName.Checked), this); + _previewForm = new FormPreview(_info.GetText(AutoGenName), this); } - _previewForm.UpdateText(_info.GetText(cbAutoGenName.Checked)); + _previewForm.UpdateText(_info.GetText(AutoGenName)); _previewForm.Show(); _previewForm.Focus(); _previewForm.Select(); } - private void Form1_Move(object sender, EventArgs e) - { - if (_previewForm != null) - { - _previewForm.Location = new Point(Location.X - _previewForm.Width, Location.Y); - } - } - private void btnPreview_MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right || !RunAsAdministrator()) return; diff --git a/Time_Shift/Forms/Form1.resx b/Time_Shift/Forms/Form1.resx index a203745..6e64d2f 100644 --- a/Time_Shift/Forms/Form1.resx +++ b/Time_Shift/Forms/Form1.resx @@ -126,9 +126,6 @@ 10, 15 - - 489, 18 - 590, 18 @@ -150,18 +147,6 @@ True - - True - - - True - - - True - - - True - 755, 18 diff --git a/Time_Shift/Forms/FormColor.cs b/Time_Shift/Forms/FormColor.cs index df03478..0f4e62f 100644 --- a/Time_Shift/Forms/FormColor.cs +++ b/Time_Shift/Forms/FormColor.cs @@ -48,14 +48,16 @@ private void AddToolTip() textFront.MouseEnter += (sender, args) => toolTip1.Show(@"文字前景色", (IWin32Window)sender); bordBack.MouseEnter += (sender, args) => toolTip1.Show(@"按键边框色", (IWin32Window)sender); - back.MouseLeave += (sender, args) => toolTip1.RemoveAll(); - textBack.MouseLeave += (sender, args) => toolTip1.RemoveAll(); - overBack.MouseLeave += (sender, args) => toolTip1.RemoveAll(); - downBack.MouseLeave += (sender, args) => toolTip1.RemoveAll(); - textFront.MouseLeave += (sender, args) => toolTip1.RemoveAll(); - bordBack.MouseLeave += (sender, args) => toolTip1.RemoveAll(); + back.MouseLeave += OnMouseLeave; + textBack.MouseLeave += OnMouseLeave; + overBack.MouseLeave += OnMouseLeave; + downBack.MouseLeave += OnMouseLeave; + textFront.MouseLeave += OnMouseLeave; + bordBack.MouseLeave += OnMouseLeave; } + private void OnMouseLeave(object sender, EventArgs e) => toolTip1.RemoveAll(); + private void SetDefault() { back.BackColor = _currentSetting[0]; diff --git a/Time_Shift/Forms/FormPreview.cs b/Time_Shift/Forms/FormPreview.cs index 90ee1c8..8f387a4 100644 --- a/Time_Shift/Forms/FormPreview.cs +++ b/Time_Shift/Forms/FormPreview.cs @@ -28,7 +28,7 @@ namespace ChapterTool.Forms public partial class FormPreview : Form { private Point _mainPos; - private Form1 _mainWindow; + private readonly Form1 _mainWindow; public FormPreview(string text, Form1 mainWindow) { @@ -38,6 +38,8 @@ public FormPreview(string text, Form1 mainWindow) _mainPos = mainWindow.Location; ScrollBarSet(); Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); + + _mainWindow.Move += Form1_Move; } private void ScrollBarSet() @@ -60,7 +62,6 @@ public void UpdateText(string text) private void cTextBox1_DoubleClick(object sender, EventArgs e) => Close(); - private void FormPreview_Load(object sender, EventArgs e) { _mainPos.X = _mainPos.X - Size.Width; @@ -73,10 +74,14 @@ private void FormPreview_FormClosing(object sender, FormClosingEventArgs e) Hide(); } - private void FormPreview_Activated(object sender, EventArgs e) { //_mainWindow.Activate(); } + + private void Form1_Move(object sender, EventArgs e) + { + this.Location = new Point(_mainWindow.Location.X - Width, _mainWindow.Location.Y); + } } } From 646c4431ae196819f89f88a4eb8d42c58342ce45 Mon Sep 17 00:00:00 2001 From: tautcony Date: Fri, 23 Dec 2016 16:17:23 +0800 Subject: [PATCH 23/30] Translate more text and fix column text resources apply. --- Time_Shift/Forms/Form1.Designer.cs | 250 ++--- Time_Shift/Forms/Form1.en-US.resx | 112 ++- Time_Shift/Forms/Form1.resx | 1056 +++++++++++++++++++- Time_Shift/Properties/Resources.en-US.resx | 23 +- Time_Shift/Util/LanguageHelper.cs | 9 + 5 files changed, 1232 insertions(+), 218 deletions(-) diff --git a/Time_Shift/Forms/Form1.Designer.cs b/Time_Shift/Forms/Form1.Designer.cs index b81d744..b2a0835 100644 --- a/Time_Shift/Forms/Form1.Designer.cs +++ b/Time_Shift/Forms/Form1.Designer.cs @@ -85,56 +85,47 @@ private void InitializeComponent() // // btnLoad // + resources.ApplyResources(this.btnLoad, "btnLoad"); this.btnLoad.ContextMenuStrip = this.loadMenuStrip; this.btnLoad.FlatAppearance.BorderColor = System.Drawing.SystemColors.Highlight; this.btnLoad.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(184)))), ((int)(((byte)(184))))); this.btnLoad.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(207)))), ((int)(((byte)(207)))), ((int)(((byte)(207))))); - this.btnLoad.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnLoad.Location = new System.Drawing.Point(12, 36); - this.btnLoad.Margin = new System.Windows.Forms.Padding(12, 4, 3, 4); this.btnLoad.Name = "btnLoad"; - this.btnLoad.Size = new System.Drawing.Size(80, 40); - this.btnLoad.TabIndex = 0; this.btnLoad.TabStop = false; - this.btnLoad.Text = "载入"; + this.toolTip1.SetToolTip(this.btnLoad, resources.GetString("btnLoad.ToolTip")); this.btnLoad.UseVisualStyleBackColor = true; this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); // // loadMenuStrip // + resources.ApplyResources(this.loadMenuStrip, "loadMenuStrip"); this.loadMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.reloadToolStripMenuItem, this.appendToolStripMenuItem}); this.loadMenuStrip.Name = "loadMenuStrip"; - this.loadMenuStrip.Size = new System.Drawing.Size(125, 48); + this.toolTip1.SetToolTip(this.loadMenuStrip, resources.GetString("loadMenuStrip.ToolTip")); // // reloadToolStripMenuItem // + resources.ApplyResources(this.reloadToolStripMenuItem, "reloadToolStripMenuItem"); this.reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; - this.reloadToolStripMenuItem.Size = new System.Drawing.Size(124, 22); - this.reloadToolStripMenuItem.Text = "重新载入"; this.reloadToolStripMenuItem.Click += new System.EventHandler(this.reloadToolStripMenuItem_Click); // // appendToolStripMenuItem // + resources.ApplyResources(this.appendToolStripMenuItem, "appendToolStripMenuItem"); this.appendToolStripMenuItem.Name = "appendToolStripMenuItem"; - this.appendToolStripMenuItem.Size = new System.Drawing.Size(124, 22); - this.appendToolStripMenuItem.Text = "追加合并"; this.appendToolStripMenuItem.Click += new System.EventHandler(this.appendToolStripMenuItem_Click); // // btnSave // + resources.ApplyResources(this.btnSave, "btnSave"); this.btnSave.FlatAppearance.BorderColor = System.Drawing.SystemColors.Highlight; this.btnSave.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(184)))), ((int)(((byte)(184))))); this.btnSave.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(207)))), ((int)(((byte)(207)))), ((int)(((byte)(207))))); - this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnSave.Location = new System.Drawing.Point(109, 36); - this.btnSave.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(80, 40); - this.btnSave.TabIndex = 3; this.btnSave.TabStop = false; - this.btnSave.Text = "保存"; + this.toolTip1.SetToolTip(this.btnSave, resources.GetString("btnSave.ToolTip")); this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); this.btnSave.MouseEnter += new System.EventHandler(this.btnSave_MouseEnter); @@ -143,221 +134,182 @@ private void InitializeComponent() // // lbPath // - this.lbPath.Location = new System.Drawing.Point(12, 9); + resources.ApplyResources(this.lbPath, "lbPath"); this.lbPath.Name = "lbPath"; - this.lbPath.Size = new System.Drawing.Size(374, 23); - this.lbPath.TabIndex = 5; + this.toolTip1.SetToolTip(this.lbPath, resources.GetString("lbPath.ToolTip")); this.lbPath.MouseEnter += new System.EventHandler(this.lbPath_MouseEnter); this.lbPath.MouseLeave += new System.EventHandler(this.ToolTipRemoveAll); // // btnTrans // + resources.ApplyResources(this.btnTrans, "btnTrans"); this.btnTrans.FlatAppearance.BorderColor = System.Drawing.SystemColors.Highlight; this.btnTrans.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(184)))), ((int)(((byte)(184))))); this.btnTrans.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(207)))), ((int)(((byte)(207)))), ((int)(((byte)(207))))); - this.btnTrans.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnTrans.Location = new System.Drawing.Point(538, 9); - this.btnTrans.Margin = new System.Windows.Forms.Padding(4); this.btnTrans.Name = "btnTrans"; - this.btnTrans.Size = new System.Drawing.Size(30, 30); - this.btnTrans.TabIndex = 2; this.btnTrans.TabStop = false; - this.btnTrans.Text = "↻"; + this.toolTip1.SetToolTip(this.btnTrans, resources.GetString("btnTrans.ToolTip")); this.btnTrans.UseVisualStyleBackColor = true; this.btnTrans.Click += new System.EventHandler(this.refresh_Click); this.btnTrans.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Color_MouseUp); // // cbAutoGenName // - this.cbAutoGenName.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.cbAutoGenName.Location = new System.Drawing.Point(303, 8); - this.cbAutoGenName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + resources.ApplyResources(this.cbAutoGenName, "cbAutoGenName"); this.cbAutoGenName.Name = "cbAutoGenName"; - this.cbAutoGenName.Size = new System.Drawing.Size(97, 21); - this.cbAutoGenName.TabIndex = 3; this.cbAutoGenName.TabStop = false; - this.cbAutoGenName.Text = "不使用章节名"; - this.toolTip1.SetToolTip(this.cbAutoGenName, "将章节名重新从Chapter 01开始标记"); + this.toolTip1.SetToolTip(this.cbAutoGenName, resources.GetString("cbAutoGenName.ToolTip")); this.cbAutoGenName.UseVisualStyleBackColor = true; this.cbAutoGenName.CheckedChanged += new System.EventHandler(this.cbAutoGenName_CheckedChanged); // // comboBox1 // + resources.ApplyResources(this.comboBox1, "comboBox1"); this.comboBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.comboBox1.ForeColor = System.Drawing.SystemColors.WindowText; this.comboBox1.FormattingEnabled = true; this.comboBox1.Items.AddRange(new object[] { - "24000 / 1001", - "24000 / 1000", - "25000 / 1000", - "30000 / 1001", - "RESER / VED", - "50000 / 1000", - "60000 / 1001"}); - this.comboBox1.Location = new System.Drawing.Point(447, 52); + resources.GetString("comboBox1.Items"), + resources.GetString("comboBox1.Items1"), + resources.GetString("comboBox1.Items2"), + resources.GetString("comboBox1.Items3"), + resources.GetString("comboBox1.Items4"), + resources.GetString("comboBox1.Items5"), + resources.GetString("comboBox1.Items6")}); this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(121, 25); - this.comboBox1.TabIndex = 11; this.comboBox1.TabStop = false; + this.toolTip1.SetToolTip(this.comboBox1, resources.GetString("comboBox1.ToolTip")); this.comboBox1.SelectionChangeCommitted += new System.EventHandler(this.comboBox1_SelectionChangeCommitted); // // cbRound // - this.cbRound.AutoSize = true; + resources.ApplyResources(this.cbRound, "cbRound"); this.cbRound.Checked = true; this.cbRound.CheckState = System.Windows.Forms.CheckState.Checked; this.cbRound.ContextMenuStrip = this.deviationMenuStrip; - this.cbRound.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.cbRound.Location = new System.Drawing.Point(417, 14); this.cbRound.Name = "cbRound"; - this.cbRound.Size = new System.Drawing.Size(76, 21); - this.cbRound.TabIndex = 12; this.cbRound.TabStop = false; - this.cbRound.Text = "帧数取整 "; - this.toolTip1.SetToolTip(this.cbRound, "右键菜单可设置误差范围"); + this.toolTip1.SetToolTip(this.cbRound, resources.GetString("cbRound.ToolTip")); this.cbRound.UseVisualStyleBackColor = true; this.cbRound.CheckedChanged += new System.EventHandler(this.refresh_Click); // // deviationMenuStrip // + resources.ApplyResources(this.deviationMenuStrip, "deviationMenuStrip"); this.deviationMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tsmAccuracy}); this.deviationMenuStrip.Name = "contextMenuStrip1"; - this.deviationMenuStrip.Size = new System.Drawing.Size(125, 26); + this.toolTip1.SetToolTip(this.deviationMenuStrip, resources.GetString("deviationMenuStrip.ToolTip")); // // tsmAccuracy // + resources.ApplyResources(this.tsmAccuracy, "tsmAccuracy"); this.tsmAccuracy.Name = "tsmAccuracy"; - this.tsmAccuracy.Size = new System.Drawing.Size(124, 22); - this.tsmAccuracy.Text = "误差范围"; this.tsmAccuracy.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.Accuracy_DropDownItemClicked); // // numericUpDown1 // + resources.ApplyResources(this.numericUpDown1, "numericUpDown1"); this.numericUpDown1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.numericUpDown1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.numericUpDown1.ForeColor = System.Drawing.SystemColors.WindowText; - this.numericUpDown1.Location = new System.Drawing.Point(501, 7); this.numericUpDown1.Maximum = new decimal(new int[] { 50, 0, 0, 0}); this.numericUpDown1.Name = "numericUpDown1"; - this.numericUpDown1.Size = new System.Drawing.Size(52, 23); - this.numericUpDown1.TabIndex = 16; this.numericUpDown1.TabStop = false; + this.toolTip1.SetToolTip(this.numericUpDown1, resources.GetString("numericUpDown1.ToolTip")); this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); // // lbShift // - this.lbShift.AutoSize = true; - this.lbShift.Location = new System.Drawing.Point(413, 9); + resources.ApplyResources(this.lbShift, "lbShift"); this.lbShift.Name = "lbShift"; - this.lbShift.Size = new System.Drawing.Size(68, 17); - this.lbShift.TabIndex = 17; - this.lbShift.Text = "平移章节号"; + this.toolTip1.SetToolTip(this.lbShift, resources.GetString("lbShift.ToolTip")); // // cbShift // - this.cbShift.AutoSize = true; - this.cbShift.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.cbShift.Location = new System.Drawing.Point(182, 40); + resources.ApplyResources(this.cbShift, "cbShift"); this.cbShift.Name = "cbShift"; - this.cbShift.Size = new System.Drawing.Size(100, 21); - this.cbShift.TabIndex = 18; this.cbShift.TabStop = false; - this.cbShift.Text = "应用表达式 (t)"; + this.toolTip1.SetToolTip(this.cbShift, resources.GetString("cbShift.ToolTip")); this.cbShift.UseVisualStyleBackColor = true; this.cbShift.CheckedChanged += new System.EventHandler(this.cbShift_CheckedChanged); // // cbChapterName // - this.cbChapterName.AutoSize = true; - this.cbChapterName.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.cbChapterName.Location = new System.Drawing.Point(182, 8); - this.cbChapterName.Margin = new System.Windows.Forms.Padding(12, 3, 3, 3); + resources.ApplyResources(this.cbChapterName, "cbChapterName"); this.cbChapterName.Name = "cbChapterName"; - this.cbChapterName.Size = new System.Drawing.Size(108, 21); - this.cbChapterName.TabIndex = 21; this.cbChapterName.TabStop = false; - this.cbChapterName.Text = "使用章节名模板"; - this.toolTip1.SetToolTip(this.cbChapterName, "不取消勾选时将持续生效"); + this.toolTip1.SetToolTip(this.cbChapterName, resources.GetString("cbChapterName.ToolTip")); this.cbChapterName.UseVisualStyleBackColor = true; this.cbChapterName.CheckedChanged += new System.EventHandler(this.cbChapterName_CheckedChanged); // // comboBox2 // + resources.ApplyResources(this.comboBox2, "comboBox2"); this.comboBox2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.comboBox2.ContextMenuStrip = this.combineMenuStrip; this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.comboBox2.ForeColor = System.Drawing.SystemColors.WindowText; this.comboBox2.FormattingEnabled = true; - this.comboBox2.Location = new System.Drawing.Point(318, 51); this.comboBox2.Name = "comboBox2"; - this.comboBox2.Size = new System.Drawing.Size(121, 25); - this.comboBox2.TabIndex = 23; this.comboBox2.TabStop = false; + this.toolTip1.SetToolTip(this.comboBox2, resources.GetString("comboBox2.ToolTip")); this.comboBox2.SelectionChangeCommitted += new System.EventHandler(this.comboBox2_SelectionChangeCommitted); this.comboBox2.MouseEnter += new System.EventHandler(this.comboBox2_MouseEnter); this.comboBox2.MouseLeave += new System.EventHandler(this.ToolTipRemoveAll); // // combineMenuStrip // + resources.ApplyResources(this.combineMenuStrip, "combineMenuStrip"); this.combineMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.combineToolStripMenuItem}); this.combineMenuStrip.Name = "contextMenuStrip2"; - this.combineMenuStrip.Size = new System.Drawing.Size(125, 26); + this.toolTip1.SetToolTip(this.combineMenuStrip, resources.GetString("combineMenuStrip.ToolTip")); this.combineMenuStrip.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.contextMenuStrip2_Closed); this.combineMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip2_Opening); // // combineToolStripMenuItem // + resources.ApplyResources(this.combineToolStripMenuItem, "combineToolStripMenuItem"); this.combineToolStripMenuItem.Name = "combineToolStripMenuItem"; - this.combineToolStripMenuItem.Size = new System.Drawing.Size(124, 22); - this.combineToolStripMenuItem.Text = "合并章节"; this.combineToolStripMenuItem.Click += new System.EventHandler(this.combineToolStripMenuItem_Click); // // folderBrowserDialog1 // - this.folderBrowserDialog1.Description = "请设置所要保存的位置"; + resources.ApplyResources(this.folderBrowserDialog1, "folderBrowserDialog1"); this.folderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.MyComputer; // // openFileDialog1 // - this.openFileDialog1.Title = "打开文件"; + resources.ApplyResources(this.openFileDialog1, "openFileDialog1"); // // cbPostFix // - this.cbPostFix.AutoSize = true; - this.cbPostFix.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.cbPostFix.Location = new System.Drawing.Point(285, 45); + resources.ApplyResources(this.cbPostFix, "cbPostFix"); this.cbPostFix.Name = "cbPostFix"; - this.cbPostFix.Size = new System.Drawing.Size(12, 11); - this.cbPostFix.TabIndex = 32; - this.toolTip1.SetToolTip(this.cbPostFix, "逆波兰表达式"); + this.toolTip1.SetToolTip(this.cbPostFix, resources.GetString("cbPostFix.ToolTip")); this.cbPostFix.UseVisualStyleBackColor = true; // // btnLog // + resources.ApplyResources(this.btnLog, "btnLog"); this.btnLog.FlatAppearance.BorderColor = System.Drawing.SystemColors.Highlight; this.btnLog.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(184)))), ((int)(((byte)(184))))); this.btnLog.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(207)))), ((int)(((byte)(207)))), ((int)(((byte)(207))))); - this.btnLog.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnLog.Location = new System.Drawing.Point(501, 37); this.btnLog.Name = "btnLog"; - this.btnLog.Size = new System.Drawing.Size(52, 23); - this.btnLog.TabIndex = 24; this.btnLog.TabStop = false; - this.btnLog.Text = "LOG"; + this.toolTip1.SetToolTip(this.btnLog, resources.GetString("btnLog.ToolTip")); this.btnLog.UseVisualStyleBackColor = true; this.btnLog.Click += new System.EventHandler(this.btnLog_Click); // // dataGridView1 // + resources.ApplyResources(this.dataGridView1, "dataGridView1"); this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.BackgroundColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -370,13 +322,11 @@ private void InitializeComponent() this.cFrams}); this.dataGridView1.EnableHeadersVisualStyles = false; this.dataGridView1.GridColor = System.Drawing.SystemColors.Highlight; - this.dataGridView1.Location = new System.Drawing.Point(12, 83); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; this.dataGridView1.RowTemplate.Height = 23; - this.dataGridView1.Size = new System.Drawing.Size(556, 351); - this.dataGridView1.TabIndex = 25; this.dataGridView1.TabStop = false; + this.toolTip1.SetToolTip(this.dataGridView1, resources.GetString("dataGridView1.ToolTip")); this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick); this.dataGridView1.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit); this.dataGridView1.CellMouseUp += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView1_CellMouseUp); @@ -387,130 +337,112 @@ private void InitializeComponent() // this.cOrder.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; this.cOrder.Frozen = true; - this.cOrder.HeaderText = "#"; + resources.ApplyResources(this.cOrder, "cOrder"); this.cOrder.Name = "cOrder"; this.cOrder.ReadOnly = true; this.cOrder.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.cOrder.Width = 21; // // cTimeCode // this.cTimeCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; - this.cTimeCode.HeaderText = " 时间点 "; + resources.ApplyResources(this.cTimeCode, "cTimeCode"); this.cTimeCode.Name = "cTimeCode"; this.cTimeCode.ReadOnly = true; this.cTimeCode.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.cTimeCode.Width = 57; // // cChapterName // this.cChapterName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; - this.cChapterName.HeaderText = " 章节名 "; + resources.ApplyResources(this.cChapterName, "cChapterName"); this.cChapterName.Name = "cChapterName"; this.cChapterName.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.cChapterName.Width = 57; // // cFrams // this.cFrams.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; - this.cFrams.HeaderText = " 帧数 "; + resources.ApplyResources(this.cFrams, "cFrams"); this.cFrams.Name = "cFrams"; this.cFrams.ReadOnly = true; this.cFrams.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.cFrams.Width = 45; // // savingType // + resources.ApplyResources(this.savingType, "savingType"); this.savingType.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.savingType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.savingType.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.savingType.FormattingEnabled = true; this.savingType.Items.AddRange(new object[] { - "OGM", - "XML", - "QPF", - "Time Codes", - "TsMuxeR Meta", - "CUE"}); - this.savingType.Location = new System.Drawing.Point(62, 4); + resources.GetString("savingType.Items"), + resources.GetString("savingType.Items1"), + resources.GetString("savingType.Items2"), + resources.GetString("savingType.Items3"), + resources.GetString("savingType.Items4"), + resources.GetString("savingType.Items5")}); this.savingType.Name = "savingType"; - this.savingType.Size = new System.Drawing.Size(108, 25); - this.savingType.TabIndex = 26; this.savingType.TabStop = false; + this.toolTip1.SetToolTip(this.savingType, resources.GetString("savingType.ToolTip")); this.savingType.SelectedIndexChanged += new System.EventHandler(this.savingType_SelectedIndexChanged); // // lbFormat // - this.lbFormat.AutoSize = true; - this.lbFormat.Location = new System.Drawing.Point(3, 10); + resources.ApplyResources(this.lbFormat, "lbFormat"); this.lbFormat.Name = "lbFormat"; - this.lbFormat.Size = new System.Drawing.Size(56, 17); - this.lbFormat.TabIndex = 27; - this.lbFormat.Text = "保存格式"; + this.toolTip1.SetToolTip(this.lbFormat, resources.GetString("lbFormat.ToolTip")); // // btnPreview // + resources.ApplyResources(this.btnPreview, "btnPreview"); this.btnPreview.FlatAppearance.BorderColor = System.Drawing.SystemColors.Highlight; this.btnPreview.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(184)))), ((int)(((byte)(184)))), ((int)(((byte)(184))))); this.btnPreview.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(207)))), ((int)(((byte)(207)))), ((int)(((byte)(207))))); - this.btnPreview.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnPreview.Location = new System.Drawing.Point(500, 9); - this.btnPreview.Margin = new System.Windows.Forms.Padding(4); this.btnPreview.Name = "btnPreview"; - this.btnPreview.Size = new System.Drawing.Size(30, 30); - this.btnPreview.TabIndex = 28; this.btnPreview.TabStop = false; - this.btnPreview.Text = "P"; + this.toolTip1.SetToolTip(this.btnPreview, resources.GetString("btnPreview.ToolTip")); this.btnPreview.UseVisualStyleBackColor = true; this.btnPreview.Click += new System.EventHandler(this.btnPreview_Click); this.btnPreview.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnPreview_MouseUp); // // xmlLang // + resources.ApplyResources(this.xmlLang, "xmlLang"); this.xmlLang.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230))))); this.xmlLang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.xmlLang.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.xmlLang.FormattingEnabled = true; - this.xmlLang.Location = new System.Drawing.Point(62, 37); this.xmlLang.Name = "xmlLang"; - this.xmlLang.Size = new System.Drawing.Size(108, 25); - this.xmlLang.TabIndex = 29; this.xmlLang.TabStop = false; + this.toolTip1.SetToolTip(this.xmlLang, resources.GetString("xmlLang.ToolTip")); this.xmlLang.SelectionChangeCommitted += new System.EventHandler(this.xmlLang_SelectionChangeCommitted); // // lbXmlLang // - this.lbXmlLang.AutoSize = true; - this.lbXmlLang.Location = new System.Drawing.Point(3, 42); + resources.ApplyResources(this.lbXmlLang, "lbXmlLang"); this.lbXmlLang.Name = "lbXmlLang"; - this.lbXmlLang.Size = new System.Drawing.Size(58, 17); - this.lbXmlLang.TabIndex = 30; - this.lbXmlLang.Text = "XML语言"; + this.toolTip1.SetToolTip(this.lbXmlLang, resources.GetString("lbXmlLang.ToolTip")); // // createZonestMenuStrip // + resources.ApplyResources(this.createZonestMenuStrip, "createZonestMenuStrip"); this.createZonestMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.creatZonesToolStripMenuItem, this.ShiftForwardToolStripMenuItem}); this.createZonestMenuStrip.Name = "createZonestMenuStrip"; - this.createZonestMenuStrip.Size = new System.Drawing.Size(136, 48); + this.toolTip1.SetToolTip(this.createZonestMenuStrip, resources.GetString("createZonestMenuStrip.ToolTip")); // // creatZonesToolStripMenuItem // + resources.ApplyResources(this.creatZonesToolStripMenuItem, "creatZonesToolStripMenuItem"); this.creatZonesToolStripMenuItem.Name = "creatZonesToolStripMenuItem"; - this.creatZonesToolStripMenuItem.Size = new System.Drawing.Size(135, 22); - this.creatZonesToolStripMenuItem.Text = "生成Zones"; this.creatZonesToolStripMenuItem.Click += new System.EventHandler(this.creatZonesToolStripMenuItem_Click); // // ShiftForwardToolStripMenuItem // + resources.ApplyResources(this.ShiftForwardToolStripMenuItem, "ShiftForwardToolStripMenuItem"); this.ShiftForwardToolStripMenuItem.Name = "ShiftForwardToolStripMenuItem"; - this.ShiftForwardToolStripMenuItem.Size = new System.Drawing.Size(135, 22); - this.ShiftForwardToolStripMenuItem.Text = "向前平移"; this.ShiftForwardToolStripMenuItem.Click += new System.EventHandler(this.ShiftForwardToolStripMenuItem_Click); // // panel1 // + resources.ApplyResources(this.panel1, "panel1"); this.panel1.Controls.Add(this.cbPostFix); this.panel1.Controls.Add(this.textBoxExpression); this.panel1.Controls.Add(this.lbFormat); @@ -523,65 +455,54 @@ private void InitializeComponent() this.panel1.Controls.Add(this.btnLog); this.panel1.Controls.Add(this.lbShift); this.panel1.Controls.Add(this.numericUpDown1); - this.panel1.Location = new System.Drawing.Point(12, 440); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(556, 64); - this.panel1.TabIndex = 32; + this.toolTip1.SetToolTip(this.panel1, resources.GetString("panel1.ToolTip")); // // textBoxExpression // - this.textBoxExpression.Location = new System.Drawing.Point(303, 37); + resources.ApplyResources(this.textBoxExpression, "textBoxExpression"); this.textBoxExpression.Name = "textBoxExpression"; - this.textBoxExpression.Size = new System.Drawing.Size(178, 23); - this.textBoxExpression.TabIndex = 31; + this.toolTip1.SetToolTip(this.textBoxExpression, resources.GetString("textBoxExpression.ToolTip")); this.textBoxExpression.TextChanged += new System.EventHandler(this.textBoxExpression_TextChanged); // // statusStrip1 // + resources.ApplyResources(this.statusStrip1, "statusStrip1"); this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tsTips, this.tsProgressBar1, this.tsBtnExpand}); - this.statusStrip1.Location = new System.Drawing.Point(0, 511); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(580, 22); this.statusStrip1.SizingGrip = false; - this.statusStrip1.TabIndex = 33; - this.statusStrip1.Text = "statusStrip1"; + this.toolTip1.SetToolTip(this.statusStrip1, resources.GetString("statusStrip1.ToolTip")); // // tsTips // + resources.ApplyResources(this.tsTips, "tsTips"); this.tsTips.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; this.tsTips.Name = "tsTips"; - this.tsTips.Size = new System.Drawing.Size(443, 17); this.tsTips.Spring = true; - this.tsTips.Text = " "; - this.tsTips.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // tsProgressBar1 // + resources.ApplyResources(this.tsProgressBar1, "tsProgressBar1"); this.tsProgressBar1.Name = "tsProgressBar1"; - this.tsProgressBar1.Size = new System.Drawing.Size(100, 16); this.tsProgressBar1.Click += new System.EventHandler(this.progressBar1_Click); // // tsBtnExpand // + resources.ApplyResources(this.tsBtnExpand, "tsBtnExpand"); this.tsBtnExpand.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.tsBtnExpand.Image = ((System.Drawing.Image)(resources.GetObject("tsBtnExpand.Image"))); - this.tsBtnExpand.ImageTransparentColor = System.Drawing.Color.Magenta; this.tsBtnExpand.Name = "tsBtnExpand"; this.tsBtnExpand.ShowDropDownArrow = false; - this.tsBtnExpand.Size = new System.Drawing.Size(20, 20); - this.tsBtnExpand.Text = "toolStripDropDownButton1"; this.tsBtnExpand.Click += new System.EventHandler(this.btnExpand_Click); // // Form1 // + resources.ApplyResources(this, "$this"); this.AllowDrop = true; - this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.Color.WhiteSmoke; - this.ClientSize = new System.Drawing.Size(580, 533); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.panel1); this.Controls.Add(this.btnPreview); @@ -593,14 +514,11 @@ private void InitializeComponent() this.Controls.Add(this.lbPath); this.Controls.Add(this.btnSave); this.Controls.Add(this.btnLoad); - this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.ForeColor = System.Drawing.SystemColors.WindowText; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.MaximizeBox = false; this.Name = "Form1"; - this.Text = "Chapter Tool"; + this.toolTip1.SetToolTip(this, resources.GetString("$this.ToolTip")); this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)(18)))), ((int)(((byte)(10)))), ((int)(((byte)(143))))); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); diff --git a/Time_Shift/Forms/Form1.en-US.resx b/Time_Shift/Forms/Form1.en-US.resx index 0a1a480..1cd297e 100644 --- a/Time_Shift/Forms/Form1.en-US.resx +++ b/Time_Shift/Forms/Form1.en-US.resx @@ -126,34 +126,130 @@ Auto Gen - - Use Template + + Rename the chapter name from Chapter 01 - - Time x 1.001 + + + 62, 21 Round + + You can edit the error range in right-click menu + + + 72, 17 + + + Shift Order + + + 81, 21 + Shift Time + + 104, 21 + + + Use Template + + + It will remain in effect until unchecked + + + Inverse Polish expression + + + Time Stamp + + + + 82 + Chapter Name + + 98 + Frams - - Time Stamp + + 48 + + + 36, 17 Type - - Shift Order + + 36, 17 Lang + + + iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAYAAACN1PRVAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABQSURBVEhLYxgFo2AUjILhAZiAuA+IDxCBQepA6ikCQkB8 + Doj/48EgeZA6qgB8FlLVIhjAZiFNLIIBZAtpahEMgCxYAKVHwSgYBaOALoCBAQCARx+VJacCbgAAAABJ + RU5ErkJggg== + + + + + AAABAAMAEBAQAAAABAAoAQAANgAAACAgEAAAAAQA6AIAAF4BAAAwMBAAAAAEAGgGAABGBAAAKAAAABAA + AAAgAAAAAQAEAAAAAACAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAIAAAIAAAACAgACAAAAAgACAAICA + AACAgIAAwMDAAAAA/wAA/wAAAP//AP8AAAD/AP8A//8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//AACAAQAAtv0AALb9 + AACAbQAAtv0AALb9AACAbQAAtv0AALb9AACAAQAAtv8AALb/AACA/wAA//8AAP//AAAoAAAAIAAAAEAA + AAABAAQAAAAAAAACAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICA + gADAwMAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAA///////////////////////////wAAAP8AAAD/Oc/8/znP/P85z/z/AAOc/wADnP85z/z/Oc + /8/znP/P8AA5z/AAOc/znP/P85z/z/Oc/8/wAAAP8AAAD/Oc///znP//85z///AA///wAP////////// + //////////////////8oAAAAMAAAAGAAAAABAAQAAAAAAIAEAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAA + gAAAgAAAAICAAIAAAACAAIAAgIAAAMDAwACAgIAAAAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAP///////wAA////////AAD///////8AAP///////wAA////////AAD///////8AAPAA + AAAADwAA8AAAAAAPAADwAAAAAA8AAPAAAAAADwAA8PDw//8PAADw8PD//w8AAPDw8P//DwAA8PDw//8P + AADwAAAPDw8AAPAAAA8PDwAA8AAADw8PAADwAAAPDw8AAPDw8P//DwAA8PDw//8PAADw8PD//w8AAPDw + 8P//DwAA8AAADw8PAADwAAAPDw8AAPAAAA8PDwAA8AAADw8PAADw8PD//w8AAPDw8P//DwAA8PDw//8P + AADw8PD//w8AAPAAAAAADwAA8AAAAAAPAADwAAAAAA8AAPAAAAAADwAA8PDw////AADw8PD///8AAPDw + 8P///wAA8PDw////AADwAAD///8AAPAAAP///wAA8AAA////AADwAAD///8AAP///////wAA//////// + AAD///////8AAP///////wAA////////AAD///////8AAA== + + \ No newline at end of file diff --git a/Time_Shift/Forms/Form1.resx b/Time_Shift/Forms/Form1.resx index 6e64d2f..0210a97 100644 --- a/Time_Shift/Forms/Form1.resx +++ b/Time_Shift/Forms/Form1.resx @@ -117,54 +117,526 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 1058, 20 - - - 489, 18 - - - 10, 15 - - - 590, 18 - - - 175, 15 - - - 355, 15 - - - True - - - True - - - True - - - True - - - 755, 18 - - - 937, 20 - + + + 12 + + + 125, 26 + + + textBoxExpression + + + + 3, 4, 3, 4 + + + P + + + tsBtnExpand + + + 178, 23 + + + 97, 21 + + + 501, 37 + + + + + + + + + $this + + + 4 + + + 追加合并 + + + 182, 40 + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 182, 8 + + + 135, 22 + + + 重新载入 + + + Flat + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 帧数 + + + 12, 3, 3, 3 + + + tsTips + + + + + + 20, 20 + + + cbShift + + + 7 + + + 501, 7 + + + 0, 511 + + + 10 + + + 413, 9 + + + 18 + + + combineMenuStrip + + + 章节名 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + 3 + + + 3, 10 + + + 108, 25 + + + 303, 8 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ShiftForwardToolStripMenuItem + + + loadMenuStrip + + + 30, 30 + + + 21 + + + 135, 22 + + + numericUpDown1 + + + 7 + + + + + + 580, 22 + + + 68, 17 + + + lbFormat + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel1 + + + 4 + + + 30 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 11 + + + 57 + + + cbRound + + + cFrams + + + 417, 14 + + + 447, 52 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 12, 11 + + + btnLoad + + + Flat + - iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAYAAACN1PRVAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABQSURBVEhLYxgFo2AUjILhAZiAuA+IDxCBQepA6ikCQkB8 - Doj/48EgeZA6qgB8FlLVIhjAZiFNLIIBZAtpahEMgCxYAKVHwSgYBaOALoCBAQCARx+VJacCbgAAAABJ - RU5ErkJggg== + iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAYAAACN1PRVAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO + wwAADsMBx2+oZAAAAFBJREFUSEtjGAWjYBSMguEBmIC4D4gPEIFB6kDqKQJCQHwOiP/jwSB5kDqqAHwW + UtUiGMBmIU0sggFkC2lqEQyALFgApUfBKBgFo4AugIEBAIBHH5UlpwJuAAAAAElFTkSuQmCC - - 61 - + + btnLog + + + 124, 22 + + + createZonestMenuStrip + + + System.Windows.Forms.ToolStripProgressBar, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + $this + + + OGM + + + 载入 + + + + + + $this + + + 96, 96 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 0 + + + 使用章节名模板 + + + Flat + + + Flat + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 124, 22 + + + 124, 22 + + + Flat + + + 56, 17 + + + 21 + + + 556, 351 + + + 3, 4, 3, 4 + + + 23 + + + + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + CUE + + + 32 + + + Time Codes + + + QPF + + + XML + + + System.Windows.Forms.StatusStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + 12, 9 + + + Flat + + + 121, 25 + + + 误差范围 + + + $this + + + reloadToolStripMenuItem + + + $this + + + 13 + + + btnSave + + + System.Windows.Forms.FolderBrowserDialog, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 45 + + + 生成Zones + + + 时间点 + + + 8 + + + panel1 + + + 保存 + + + panel1 + + + 5 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 10 + + + 30, 30 + + + btnTrans + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 9 + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 保存格式 + + + 帧数取整 + + + panel1 + + + 109, 36 + + + 27 + + + System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + cChapterName + + + 12, 36 + + + 逆波兰表达式 + + + panel1 + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + statusStrip1 + + + Magenta + + + 2 + + + 5 + + + dataGridView1 + + + 1 + + + savingType + + + System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 12, 4, 3, 4 + + + Flat + + + 121, 25 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + 4, 4, 4, 4 + + + deviationMenuStrip + + + + + + Flat + + + 125, 48 + + + 4, 4, 4, 4 + + + 3 + + + System.Windows.Forms.ToolStripDropDownButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + AAABAAMAEBAQAAAABAAoAQAANgAAACAgEAAAAAQA6AIAAF4BAAAwMBAAAAAEAGgGAABGBAAAKAAAABAA @@ -215,4 +687,502 @@ AAD///////8AAP///////wAA////////AAD///////8AAA== + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel1 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 285, 45 + + + 303, 37 + + + # + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + 80, 40 + + + btnPreview + + + 443, 17 + + + 24000 / 1001 + + + 11 + + + + + + 32 + + + RESER / VED + + + + + + 14 + + + 556, 64 + + + Flat + + + panel1 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + 25 + + + 100, 16 + + + 向前平移 + + + lbPath + + + + + + 24 + + + 80, 40 + + + LOG + + + $this + + + Flat + + + + + + 374, 23 + + + Chapter Tool + + + 17 + + + $this + + + 500, 9 + + + cbPostFix + + + Form1 + + + 28 + + + 微软雅黑, 9pt + + + True + + + 应用表达式 (t) + + + 6 + + + 6 + + + System.Windows.Forms.OpenFileDialog, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 136, 48 + + + cOrder + + + $this + + + Flat + + + 24000 / 1000 + + + 不使用章节名 + + + cbChapterName + + + panel1 + + + 31 + + + 合并章节 + + + XML语言 + + + 62, 4 + + + 125, 26 + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + comboBox2 + + + + + + panel1 + + + 12, 83 + + + 2 + + + 29 + + + 76, 21 + + + System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 16 + + + cTimeCode + + + cbAutoGenName + + + 30000 / 1001 + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 0 + + + 52, 23 + + + 打开文件 + + + panel1 + + + $this + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + MiddleLeft + + + Flat + + + 25000 / 1000 + + + + + + 5 + + + 12 + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + panel1 + + + 58, 17 + + + + + + panel1 + + + openFileDialog1 + + + statusStrip1 + + + 3 + + + 将章节名重新从Chapter 01开始标记 + + + 26 + + + 8 + + + 50000 / 1000 + + + toolStripDropDownButton1 + + + Flat + + + panel1 + + + lbShift + + + 538, 9 + + + 9 + + + comboBox1 + + + 580, 533 + + + 11 + + + + + + + + + folderBrowserDialog1 + + + combineToolStripMenuItem + + + 请设置所要保存的位置 + + + TsMuxeR Meta + + + 100, 21 + + + True + + + 右键菜单可设置误差范围 + + + tsmAccuracy + + + 3, 4, 3, 4 + + + 108, 21 + + + tsProgressBar1 + + + $this + + + 不取消勾选时将持续生效 + + + 57 + + + lbXmlLang + + + toolTip1 + + + 平移章节号 + + + 33 + + + 12, 440 + + + 52, 23 + + + 3, 42 + + + 60000 / 1001 + + + 62, 37 + + + creatZonesToolStripMenuItem + + + appendToolStripMenuItem + + + True + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.DataGridView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + 318, 51 + + + 124, 22 + + + Flat + + + + + + xmlLang + + + + + + 108, 25 + + + $this + + + True + + + 175, 15 + + + 937, 20 + + + 61 + + + True + + + 755, 18 + + + 590, 18 + + + 355, 15 + + + 1058, 20 + + + 10, 15 + + + True + + + True + + + 489, 18 + + + True + \ No newline at end of file diff --git a/Time_Shift/Properties/Resources.en-US.resx b/Time_Shift/Properties/Resources.en-US.resx index 8d52e62..8af1c9e 100644 --- a/Time_Shift/Properties/Resources.en-US.resx +++ b/Time_Shift/Properties/Resources.en-US.resx @@ -289,7 +289,7 @@ Skip Update checking - Oh~, I'm not the administrator + Oh~, I haven't granted administrator privileges Wow ( •̀ ω •́ )y, I can do some thing naive! @@ -327,4 +327,25 @@ Save StackTrack to clipboard? + + Copy content to clipboard? + + + Please set to round frames mode first. + + + Index out of range + + + WebVTT File + + + Loading, please wait… + + + Load failed… + + + Require .Net4.6 or higher to support all feature,no longer remind? + \ No newline at end of file diff --git a/Time_Shift/Util/LanguageHelper.cs b/Time_Shift/Util/LanguageHelper.cs index e689b14..601134c 100644 --- a/Time_Shift/Util/LanguageHelper.cs +++ b/Time_Shift/Util/LanguageHelper.cs @@ -67,6 +67,15 @@ private static void AppLang(Control control, System.ComponentModel.ComponentReso } } + DataGridView gridView = control as DataGridView; + if (gridView != null) + { + foreach (DataGridViewColumn column in gridView.Columns) + { + resources.ApplyResources(column, column.Name); + } + } + foreach (Control c in control.Controls) { resources.ApplyResources(c, c.Name); From 322e2762e5abde1ca1bb9e72d1062ef9822b377d Mon Sep 17 00:00:00 2001 From: tautcony Date: Fri, 23 Dec 2016 20:14:04 +0800 Subject: [PATCH 24/30] fix more issues in i18n. --- Time_Shift/Forms/Form1.cs | 8 +- Time_Shift/Forms/Form1.en-US.resx | 52 +++++++++++- Time_Shift/Forms/Form1.resx | 126 +++++++++++++++--------------- Time_Shift/Util/LanguageHelper.cs | 47 +++++++---- 4 files changed, 150 insertions(+), 83 deletions(-) diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index 74fac15..77db81b 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -45,8 +45,14 @@ public partial class Form1 : Form public Form1() { InitializeComponent(); - //LanguageHelper.SetLang("en-US", this, typeof(Form1)); AddCommand(); + /* + LanguageHelper.SetLang("en-US", this, typeof(Form1)); + LanguageHelper.SetLang("en-US", deviationMenuStrip, typeof(Form1)); + LanguageHelper.SetLang("en-US", combineMenuStrip, typeof(Form1)); + LanguageHelper.SetLang("en-US", createZonestMenuStrip, typeof(Form1)); + LanguageHelper.SetLang("en-US", loadMenuStrip, typeof(Form1)); + */ } public Form1(string args) diff --git a/Time_Shift/Forms/Form1.en-US.resx b/Time_Shift/Forms/Form1.en-US.resx index 1cd297e..14885ae 100644 --- a/Time_Shift/Forms/Form1.en-US.resx +++ b/Time_Shift/Forms/Form1.en-US.resx @@ -117,9 +117,25 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 144, 48 + Load + + 152, 22 + + + Reload file + + + 152, 22 + + + Append file + Save @@ -129,7 +145,9 @@ Rename the chapter name from Chapter 01 - + + 170, 26 + 62, 21 @@ -137,7 +155,13 @@ Round - You can edit the error range in right-click menu + You can edit the tolerance scope in right-click menu + + + 169, 22 + + + tolerance scope 72, 17 @@ -160,6 +184,15 @@ It will remain in effect until unchecked + + 164, 26 + + + 163, 22 + + + Merge chapter + Inverse Polish expression @@ -194,6 +227,21 @@ Lang + + 190, 48 + + + 189, 22 + + + Create Zones + + + 189, 22 + + + Forward translation + iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAYAAACN1PRVAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 diff --git a/Time_Shift/Forms/Form1.resx b/Time_Shift/Forms/Form1.resx index 0210a97..1361658 100644 --- a/Time_Shift/Forms/Form1.resx +++ b/Time_Shift/Forms/Form1.resx @@ -186,8 +186,8 @@ 帧数 - - 12, 3, 3, 3 + + panel1 tsTips @@ -297,8 +297,8 @@ 4 - - 30 + + 12 System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -382,6 +382,9 @@ 使用章节名模板 + + panel1 + Flat @@ -394,6 +397,9 @@ System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 12, 3, 3, 3 + 124, 22 @@ -409,8 +415,8 @@ 21 - - 556, 351 + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 3, 4, 3, 4 @@ -427,8 +433,8 @@ CUE - - 32 + + TsMuxeR Meta Time Codes @@ -442,8 +448,8 @@ System.Windows.Forms.StatusStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + comboBox1 @@ -487,11 +493,11 @@ 时间点 - - 8 + + xmlLang - - panel1 + + 32 保存 @@ -523,6 +529,9 @@ True + + 4, 4, 4, 4 + 9 @@ -538,12 +547,12 @@ 帧数取整 + + + panel1 - - 109, 36 - 27 @@ -553,6 +562,9 @@ cChapterName + + appendToolStripMenuItem + 12, 36 @@ -562,8 +574,8 @@ panel1 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 平移章节号 System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -586,8 +598,8 @@ 1 - - savingType + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 System.Windows.Forms.DataGridViewTextBoxColumn, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -607,8 +619,8 @@ - - 4, 4, 4, 4 + + savingType deviationMenuStrip @@ -634,7 +646,7 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + @@ -705,9 +717,6 @@ 303, 37 - - # - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -738,6 +747,9 @@ RESER / VED + + 33 + @@ -801,9 +813,6 @@ 17 - - $this - 500, 9 @@ -891,8 +900,8 @@ 2 - - 29 + + tsProgressBar1 76, 21 @@ -915,8 +924,8 @@ 30000 / 1001 - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + # System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -936,9 +945,6 @@ $this - - System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - @@ -957,8 +963,8 @@ 5 - - 12 + + $this System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -1002,23 +1008,26 @@ toolStripDropDownButton1 + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Flat - - panel1 - lbShift 538, 9 + + 556, 351 + 9 - - comboBox1 + + 30 580, 533 @@ -1029,9 +1038,6 @@ - - - folderBrowserDialog1 @@ -1041,8 +1047,8 @@ 请设置所要保存的位置 - - TsMuxeR Meta + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 100, 21 @@ -1059,12 +1065,6 @@ 3, 4, 3, 4 - - 108, 21 - - - tsProgressBar1 - $this @@ -1080,11 +1080,11 @@ toolTip1 - - 平移章节号 + + 8 - - 33 + + 109, 36 12, 440 @@ -1104,8 +1104,8 @@ creatZonesToolStripMenuItem - - appendToolStripMenuItem + + 108, 21 True @@ -1131,8 +1131,8 @@ - - xmlLang + + 29 diff --git a/Time_Shift/Util/LanguageHelper.cs b/Time_Shift/Util/LanguageHelper.cs index 601134c..a09ec53 100644 --- a/Time_Shift/Util/LanguageHelper.cs +++ b/Time_Shift/Util/LanguageHelper.cs @@ -16,7 +16,7 @@ private static void SetAllLang(string lang) { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang); - string name = "MainForm"; + string name = "Form1"; var frm = (Form)Assembly.Load("CameraTest").CreateInstance(name); if (frm == null) return; @@ -37,13 +37,20 @@ private static void SetAllLang(string lang) public static void SetLang(string lang, Form form, Type formType) { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang); - if (form != null) - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(formType); - resources.ApplyResources(form, "$this"); - AppLang(form, resources); - } + if (form == null) return; + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(formType); + resources.ApplyResources(form, "$this"); + AppLang(form, resources); + } + + public static void SetLang(string lang, Control control, Type formType) + { + //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang); + if (control == null) return; + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(formType); + AppLang(control, resources); } + #endregion #region AppLang for control @@ -54,25 +61,32 @@ public static void SetLang(string lang, Form form, Type formType) /// private static void AppLang(Control control, System.ComponentModel.ComponentResourceManager resources) { - MenuStrip menuStrip = control as MenuStrip; + var menuStrip = control as MenuStrip; if (menuStrip != null) { resources.ApplyResources(menuStrip, menuStrip.Name); - if (menuStrip.Items.Count > 0) + foreach (ToolStripMenuItem c in menuStrip.Items) + { + AppLang(c, resources); + } + } + + var contextMenuStrip = control as ContextMenuStrip; + if (contextMenuStrip != null) + { + resources.ApplyResources(contextMenuStrip, contextMenuStrip.Name); + foreach (ToolStripMenuItem c in contextMenuStrip.Items) { - foreach (ToolStripMenuItem c in menuStrip.Items) - { - AppLang(c, resources); - } + AppLang(c, resources); } } - DataGridView gridView = control as DataGridView; + var gridView = control as DataGridView; if (gridView != null) { - foreach (DataGridViewColumn column in gridView.Columns) + foreach (DataGridViewColumn c in gridView.Columns) { - resources.ApplyResources(column, column.Name); + resources.ApplyResources(c, c.Name); } } @@ -94,7 +108,6 @@ private static void AppLang(ToolStripMenuItem item, System.ComponentModel.Compon { if (item == null) return; resources.ApplyResources(item, item.Name); - if (item.DropDownItems.Count <= 0) return; foreach (ToolStripMenuItem c in item.DropDownItems) { AppLang(c, resources); From d9fafd083e2d384452e1b705e2c71d74dc846933 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sun, 22 Jan 2017 00:25:16 +0800 Subject: [PATCH 25/30] Write a simple flac parser to get the cuesheet. --- Time_Shift/Time_Shift.csproj | 1 + Time_Shift/Util/ChapterData/CueData.cs | 56 ++---- Time_Shift/Util/ChapterData/FlacData.cs | 223 ++++++++++++++++++++++++ 3 files changed, 234 insertions(+), 46 deletions(-) create mode 100644 Time_Shift/Util/ChapterData/FlacData.cs diff --git a/Time_Shift/Time_Shift.csproj b/Time_Shift/Time_Shift.csproj index 9e6b9a9..b9aa5d2 100644 --- a/Time_Shift/Time_Shift.csproj +++ b/Time_Shift/Time_Shift.csproj @@ -132,6 +132,7 @@ + diff --git a/Time_Shift/Util/ChapterData/CueData.cs b/Time_Shift/Util/ChapterData/CueData.cs index fba6e7c..e2ad78a 100644 --- a/Time_Shift/Util/ChapterData/CueData.cs +++ b/Time_Shift/Util/ChapterData/CueData.cs @@ -205,8 +205,8 @@ private static string GetCueSheet(byte[] buffer, string type) int state = 0, beginPos = 0; for (int i = 0; i < length; ++i) { - if ((buffer[i] >= 0x41) && (buffer[i] <= 0x5A)) - buffer[i] -= 0x20; + if (buffer[i] >= 'A' && buffer[i] <= 'Z') + buffer[i] -= 'a' - 'A'; switch ((char)buffer[i]) { case 'c': state = 1; break;//C @@ -253,16 +253,18 @@ private static string GetCueSheet(byte[] buffer, string type) var cueLength = endPos - beginPos + 1; if (cueLength <= 10) return string.Empty; string cueSheet = Encoding.UTF8.GetString(buffer, beginPos, cueLength); - Debug.WriteLine(cueSheet); + //Debug.WriteLine(cueSheet); return cueSheet; } + private const long SizeThreshold = 1 << 20; + private static string GetCueFromTak(string takPath) { using (var fs = File.Open(takPath, FileMode.Open, FileAccess.Read)) { - if (fs.Length < 1 << 20)// 小于1M,文档太小了 + if (fs.Length < SizeThreshold) return string.Empty; var header = new byte[4]; fs.Read(header, 0, 4); @@ -277,48 +279,10 @@ private static string GetCueFromTak(string takPath) private static string GetCueFromFlac(string flacPath) { - using (var fs = File.Open(flacPath, FileMode.Open, FileAccess.Read)) - { - if (fs.Length < 1 << 20)// 小于1M,文档太小了 - return string.Empty; - var header = new byte[4]; - fs.Read(header, 0, 4); - if (Encoding.ASCII.GetString(header, 0, 4) != "fLaC") - throw new InvalidDataException($"Except an flac but get an {Encoding.ASCII.GetString(header, 0, 4)}"); - - var buffer = new byte[1]; - //4个字节的METADATA_BLOCK_HEADER - do - { - fs.Read(header, 0, 4); - //读取BLOCK长度 - int length = (header[1] << 16) | (header[2] << 8) | header[3]; - //解析 - //检查最高位是否为1 - if ((header[0] & 0x80) == 0x80) - { - //最后一个METADATA_BLOCK - if ((header[0] & 0x7F) == 0x04)//是VORBIS_COMMENT - { - buffer = new byte[length]; - //读取BLOCK DATA - fs.Read(buffer, 0, length); - } - break; - } - //不是最后一个METADATA_BLOCK - if ((header[0] & 0x7F) == 0x04)//是VORBIS_COMMENT - { - buffer = new byte[length]; - //读取BLOCK DATA - fs.Read(buffer, 0, length); - break; - } - //移动文件指针 - fs.Seek(length, SeekOrigin.Current); - } while (fs.Position <= 1048576L); - return GetCueSheet(buffer, "flac"); - } + var info = FlacData.GetMetadataFromFlac(flacPath); + if (info.VorbisComment.ContainsKey("cuesheet")) + return info.VorbisComment["cuesheet"]; + return string.Empty; } public int Count { get; } = 1; diff --git a/Time_Shift/Util/ChapterData/FlacData.cs b/Time_Shift/Util/ChapterData/FlacData.cs new file mode 100644 index 0000000..526a732 --- /dev/null +++ b/Time_Shift/Util/ChapterData/FlacData.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Linq; +using System.Text; + +namespace ChapterTool.Util.ChapterData +{ + public class FlacInfo + { + public long RawLength { get; set; } + public long TrueLength { get; } + public double CompressRate { get; } + public bool HasCover { get; set; } + public string Encoder { get; set; } + public Dictionary VorbisComment { get; set; } + + public FlacInfo() + { + VorbisComment = new Dictionary(); + } + } + + //https://xiph.org/flac/format.html + public static class FlacData + { + private const long SizeThreshold = 1 << 20; + + [SuppressMessage("ReSharper", "InconsistentNaming")] + private enum BlockType + { + STREAMINFO = 0x00, + PADDING, + APPLICATION, + SEEKTABLE, + VORBIS_COMMENT, + CUESHEET, + PICTURE + }; + + public static FlacInfo GetMetadataFromFlac(string flacPath) + { + using (var fs = File.Open(flacPath, FileMode.Open, FileAccess.Read)) + { + if (fs.Length < SizeThreshold) return new FlacInfo(); + FlacInfo info = new FlacInfo(); + var header = new byte[4]; + fs.Read(header, 0, 4); + if (Encoding.ASCII.GetString(header, 0, 4) != "fLaC") + throw new InvalidDataException($"Except an flac but get an {Encoding.ASCII.GetString(header, 0, 4)}"); + //METADATA_BLOCK_HEADER + //1-bit Last-metadata-block flag + //7-bit BLOCK_TYPE + //24-bit Length + while (fs.Position < fs.Length) + { + uint blockHeader = fs.ReadUInt(); + bool lastMetadataBlock = blockHeader >> 31 == 0x1; + BlockType blockType = (BlockType)((blockHeader >> 24) & 0x7f); + int length = (int) (blockHeader & 0xffffff); + + switch (blockType) + { + case BlockType.STREAMINFO: + Debug.Assert(length == 34); + ParseStreamInfo(fs, ref info); + break; + case BlockType.VORBIS_COMMENT: + ParseVorbisComment(fs, ref info); + break; + case BlockType.PICTURE: + ParsePicture(fs, ref info); + break; + case BlockType.PADDING: + case BlockType.APPLICATION: + case BlockType.SEEKTABLE: + case BlockType.CUESHEET: + fs.Seek(length, SeekOrigin.Current); + break; + default: + throw new System.ArgumentOutOfRangeException($"Invalid BLOCK_TYPE: 0x{blockType:X}"); + } + if (lastMetadataBlock) break; + } + return info; + } + } + + private static void ParseStreamInfo(Stream fs, ref FlacInfo info) + { + long minBlockSize = fs.ReadUShort(); + long maxBlockSize = fs.ReadUShort(); + long minFrameSize = fs.ReadInt24(); + long maxFrameSize = fs.ReadInt24(); + var buffer = fs.ReadBytes(8); + BitReader br = new BitReader(buffer); + int sampleRate = (int) br.GetBits(20); + int channelCount = (int) br.GetBits(3)+1; + int bitPerSample = (int) br.GetBits(5)+1; + int totalSample = (int) br.GetBits(36); + info.RawLength = channelCount * bitPerSample * totalSample; + var md5 = fs.ReadBytes(16); + } + + private static void ParseVorbisComment(Stream fs, ref FlacInfo info) + { + //only here in flac use little-endian + int vendorLength = (int) fs.ReadUInt(true); + var vendorRawStringData = fs.ReadBytes(vendorLength); + var vendor = Encoding.UTF8.GetString(vendorRawStringData, 0, vendorLength); + info.Encoder = vendor; + int userCommentListLength = (int) fs.ReadUInt(true); + for (int i = 0; i < userCommentListLength; ++i) + { + int commentLength = (int) fs.ReadUInt(true); + var commentRawStringData = fs.ReadBytes(commentLength); + var comment = Encoding.UTF8.GetString(commentRawStringData, 0, commentLength); + var spilterIndex = comment.IndexOf('='); + var key = comment.Substring(0, spilterIndex); + var value = comment.Substring(spilterIndex + 1, comment.Length - 1 - spilterIndex); + info.VorbisComment[key] = value; + } + } + + private static void ParsePicture(Stream fs, ref FlacInfo info) + { + int pictureType = (int) fs.ReadUInt(); + int mimeStringLength = (int) fs.ReadUInt(); + string mimeType = Encoding.ASCII.GetString(fs.ReadBytes(mimeStringLength), 0, mimeStringLength); + int descriptionLength = (int) fs.ReadUInt(); + string description = Encoding.UTF8.GetString(fs.ReadBytes(descriptionLength), 0, descriptionLength); + int pictureWidth = (int) fs.ReadUInt(); + int pictureHeight = (int) fs.ReadUInt(); + int colorDepth = (int) fs.ReadUInt(); + int indexedColorCount = (int) fs.ReadUInt(); + int pictureDataLength = (int) fs.ReadUInt(); + fs.Seek(pictureDataLength, SeekOrigin.Current); + info.HasCover = true; + } + + private static ushort ReadUShort(this Stream fs) + { + var buffer = fs.ReadBytes(2).Reverse().ToArray(); + return BitConverter.ToUInt16(buffer, 0); + } + + private static int ReadInt24(this Stream fs) + { + var buffer = fs.ReadBytes(3); + int ret = 0; + for (int i = 0; i < 3; ++i) + { + ret |= buffer[i] << ((2 - i) * 8); + } + return ret; + } + + private static uint ReadUInt(this Stream fs, bool littleEndian = false) + { + var buffer = fs.ReadBytes(4); + if (!littleEndian) buffer = buffer.Reverse().ToArray(); + return BitConverter.ToUInt32(buffer, 0); + } + + private static byte[] ReadBytes(this Stream fs, int length) + { + var ret = new byte[length]; + fs.Read(ret, 0, length); + return ret; + } + } + + public class BitReader + { + private readonly byte[] _buffer; + private int _bytePosition; + private int _bitPositionInByte; + + public int Position => _bytePosition * 8 + _bitPositionInByte; + + public BitReader(byte[] source) + { + _buffer = new byte[source.Length]; + Array.Copy(source, _buffer, source.Length); + } + + public void Reset() + { + _bytePosition = 0; + _bitPositionInByte = 0; + } + + public bool GetBit() + { + if (_bytePosition >= _buffer.Length) + throw new IndexOutOfRangeException(nameof(_bytePosition)); + bool ret = ((_buffer[_bytePosition] >> (7 - _bitPositionInByte)) & 1) == 1; + Next(); + return ret; + } + + private void Next() + { + ++_bitPositionInByte; + if (_bitPositionInByte != 8) return; + _bitPositionInByte = 0; + ++_bytePosition; + } + + public long GetBits(int length) + { + long ret = 0; + for (int i = 0; i < length; ++i) + { + ret |= ((long)(_buffer[_bytePosition] >> (7 - _bitPositionInByte) & 1) << (length - 1 - i)); + Next(); + } + return ret; + } + } +} From 60c87af772028df5f941577bab097b95f365625e Mon Sep 17 00:00:00 2001 From: tautcony Date: Sun, 22 Jan 2017 10:29:00 +0800 Subject: [PATCH 26/30] Add log for flac parse. --- Time_Shift/Forms/Form1.cs | 2 +- Time_Shift/Util/ChapterData/CueData.cs | 9 ++++++--- Time_Shift/Util/ChapterData/FlacData.cs | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index 77db81b..95409b9 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -627,7 +627,7 @@ private void LoadCue() { try { - _info = new CueData(FilePath).Chapter; + _info = new CueData(FilePath, Log).Chapter; tsProgressBar1.Value = 33; tsTips.Text = Resources.Tips_Load_Success; diff --git a/Time_Shift/Util/ChapterData/CueData.cs b/Time_Shift/Util/ChapterData/CueData.cs index e2ad78a..213e706 100644 --- a/Time_Shift/Util/ChapterData/CueData.cs +++ b/Time_Shift/Util/ChapterData/CueData.cs @@ -36,7 +36,8 @@ public class CueData: IData /// 从文件中获取cue播放列表并转换为ChapterInfo /// /// - public CueData(string path) + /// + public CueData(string path, Action log = null) { string cueData; var ext = Path.GetExtension(path)?.ToLower(); @@ -49,7 +50,7 @@ public CueData(string path) break; case ".flac": - cueData = GetCueFromFlac(path); + cueData = GetCueFromFlac(path, log); break; case ".tak": @@ -277,9 +278,11 @@ private static string GetCueFromTak(string takPath) } } - private static string GetCueFromFlac(string flacPath) + private static string GetCueFromFlac(string flacPath, Action log = null) { + FlacData.OnLog += log; var info = FlacData.GetMetadataFromFlac(flacPath); + FlacData.OnLog -= log; if (info.VorbisComment.ContainsKey("cuesheet")) return info.VorbisComment["cuesheet"]; return string.Empty; diff --git a/Time_Shift/Util/ChapterData/FlacData.cs b/Time_Shift/Util/ChapterData/FlacData.cs index 526a732..8fbb2f0 100644 --- a/Time_Shift/Util/ChapterData/FlacData.cs +++ b/Time_Shift/Util/ChapterData/FlacData.cs @@ -28,6 +28,8 @@ public static class FlacData { private const long SizeThreshold = 1 << 20; + public static event Action OnLog; + [SuppressMessage("ReSharper", "InconsistentNaming")] private enum BlockType { @@ -46,8 +48,7 @@ public static FlacInfo GetMetadataFromFlac(string flacPath) { if (fs.Length < SizeThreshold) return new FlacInfo(); FlacInfo info = new FlacInfo(); - var header = new byte[4]; - fs.Read(header, 0, 4); + var header = fs.ReadBytes(4); if (Encoding.ASCII.GetString(header, 0, 4) != "fLaC") throw new InvalidDataException($"Except an flac but get an {Encoding.ASCII.GetString(header, 0, 4)}"); //METADATA_BLOCK_HEADER @@ -60,7 +61,7 @@ public static FlacInfo GetMetadataFromFlac(string flacPath) bool lastMetadataBlock = blockHeader >> 31 == 0x1; BlockType blockType = (BlockType)((blockHeader >> 24) & 0x7f); int length = (int) (blockHeader & 0xffffff); - + info.RawLength += length; switch (blockType) { case BlockType.STREAMINFO: @@ -77,10 +78,11 @@ public static FlacInfo GetMetadataFromFlac(string flacPath) case BlockType.APPLICATION: case BlockType.SEEKTABLE: case BlockType.CUESHEET: + OnLog?.Invoke($"{blockType} with Length: {length}"); fs.Seek(length, SeekOrigin.Current); break; default: - throw new System.ArgumentOutOfRangeException($"Invalid BLOCK_TYPE: 0x{blockType:X}"); + throw new ArgumentOutOfRangeException($"Invalid BLOCK_TYPE: 0x{blockType:X}"); } if (lastMetadataBlock) break; } @@ -100,8 +102,12 @@ private static void ParseStreamInfo(Stream fs, ref FlacInfo info) int channelCount = (int) br.GetBits(3)+1; int bitPerSample = (int) br.GetBits(5)+1; int totalSample = (int) br.GetBits(36); - info.RawLength = channelCount * bitPerSample * totalSample; var md5 = fs.ReadBytes(16); + info.RawLength += channelCount * bitPerSample * totalSample; + OnLog?.Invoke($"minimum block size: {minBlockSize}, maximum block size: {maxBlockSize}"); + OnLog?.Invoke($"minimum frame size: {minFrameSize}, maximum frame size: {maxFrameSize}"); + OnLog?.Invoke($"Sample rate: {sampleRate}Hz, bits per sample: {bitPerSample}-bit"); + OnLog?.Invoke($"{channelCount}-channel"); } private static void ParseVorbisComment(Stream fs, ref FlacInfo info) @@ -137,6 +143,7 @@ private static void ParsePicture(Stream fs, ref FlacInfo info) int indexedColorCount = (int) fs.ReadUInt(); int pictureDataLength = (int) fs.ReadUInt(); fs.Seek(pictureDataLength, SeekOrigin.Current); + info.RawLength += pictureDataLength; info.HasCover = true; } From dfc3b2d9f0607ebe979f0be48d541507c64ff6a2 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sun, 22 Jan 2017 10:39:32 +0800 Subject: [PATCH 27/30] Improve info about flac log. --- Time_Shift/Util/ChapterData/FlacData.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Time_Shift/Util/ChapterData/FlacData.cs b/Time_Shift/Util/ChapterData/FlacData.cs index 8fbb2f0..fa27fa5 100644 --- a/Time_Shift/Util/ChapterData/FlacData.cs +++ b/Time_Shift/Util/ChapterData/FlacData.cs @@ -62,6 +62,7 @@ public static FlacInfo GetMetadataFromFlac(string flacPath) BlockType blockType = (BlockType)((blockHeader >> 24) & 0x7f); int length = (int) (blockHeader & 0xffffff); info.RawLength += length; + OnLog?.Invoke($"|+{blockType} with Length: {length}"); switch (blockType) { case BlockType.STREAMINFO: @@ -78,7 +79,6 @@ public static FlacInfo GetMetadataFromFlac(string flacPath) case BlockType.APPLICATION: case BlockType.SEEKTABLE: case BlockType.CUESHEET: - OnLog?.Invoke($"{blockType} with Length: {length}"); fs.Seek(length, SeekOrigin.Current); break; default: @@ -104,10 +104,12 @@ private static void ParseStreamInfo(Stream fs, ref FlacInfo info) int totalSample = (int) br.GetBits(36); var md5 = fs.ReadBytes(16); info.RawLength += channelCount * bitPerSample * totalSample; - OnLog?.Invoke($"minimum block size: {minBlockSize}, maximum block size: {maxBlockSize}"); - OnLog?.Invoke($"minimum frame size: {minFrameSize}, maximum frame size: {maxFrameSize}"); - OnLog?.Invoke($"Sample rate: {sampleRate}Hz, bits per sample: {bitPerSample}-bit"); - OnLog?.Invoke($"{channelCount}-channel"); + OnLog?.Invoke($" | minimum block size: {minBlockSize}, maximum block size: {maxBlockSize}"); + OnLog?.Invoke($" | minimum frame size: {minFrameSize}, maximum frame size: {maxFrameSize}"); + OnLog?.Invoke($" | Sample rate: {sampleRate}Hz, bits per sample: {bitPerSample}-bit"); + OnLog?.Invoke($" | Channel count: {channelCount}"); + string md5String = md5.Aggregate("", (current, item) => current + $"{item:X2}"); + OnLog?.Invoke($" | MD5: {md5String}"); } private static void ParseVorbisComment(Stream fs, ref FlacInfo info) @@ -117,6 +119,7 @@ private static void ParseVorbisComment(Stream fs, ref FlacInfo info) var vendorRawStringData = fs.ReadBytes(vendorLength); var vendor = Encoding.UTF8.GetString(vendorRawStringData, 0, vendorLength); info.Encoder = vendor; + OnLog?.Invoke($" | Vendor: {vendor}"); int userCommentListLength = (int) fs.ReadUInt(true); for (int i = 0; i < userCommentListLength; ++i) { @@ -127,6 +130,8 @@ private static void ParseVorbisComment(Stream fs, ref FlacInfo info) var key = comment.Substring(0, spilterIndex); var value = comment.Substring(spilterIndex + 1, comment.Length - 1 - spilterIndex); info.VorbisComment[key] = value; + var summary = value.Length > 15 ? value.Substring(0, 15) + "..." : value; + OnLog?.Invoke($" | [{key}] = '{summary}'"); } } From 1a923af1674ca8fb74b0a707ed8ef7162a592209 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sun, 22 Jan 2017 11:07:08 +0800 Subject: [PATCH 28/30] Format some code. --- Time_Shift/Forms/Form1.cs | 46 ++++++++------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/Time_Shift/Forms/Form1.cs b/Time_Shift/Forms/Form1.cs index 95409b9..fe9226e 100644 --- a/Time_Shift/Forms/Form1.cs +++ b/Time_Shift/Forms/Form1.cs @@ -855,30 +855,12 @@ private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) private void comboBox2_SelectionChangeCommitted(object sender, EventArgs e) { - if (_rawMpls != null) - { - GetChapterInfoFromMpls(ClipSeletIndex); - } - else if (_xmlGroup != null) - { - _info = _xmlGroup[ClipSeletIndex]; - } - else if (_ifoGroup != null) - { - GetChapterInfoFromIFO(ClipSeletIndex); - } - else if (_xplGroup != null) - { - _info = _xplGroup[ClipSeletIndex]; - } else if (_bdmvGroup != null) - { - _info = _bdmvGroup[ClipSeletIndex]; - } - if (Shift) - { - cbShift_CheckedChanged(new object(), new EventArgs()); - } - //_info.Mul1K1 = cbMul1k1.Checked; + if (_rawMpls != null) GetChapterInfoFromMpls(ClipSeletIndex); + else if (_ifoGroup != null) GetChapterInfoFromIFO (ClipSeletIndex); + else if (_xmlGroup != null) _info = _xmlGroup [ClipSeletIndex]; + else if (_xplGroup != null) _info = _xplGroup [ClipSeletIndex]; + else if (_bdmvGroup != null) _info = _bdmvGroup[ClipSeletIndex]; + if (Shift) cbShift_CheckedChanged(null, null); UpdataGridView(); } @@ -886,19 +868,9 @@ private void combineToolStripMenuItem_Click(object sender, EventArgs e) { if (_rawMpls == null && _ifoGroup == null) return; CombineChapter = !CombineChapter; - if (_rawMpls != null) - { - GetChapterInfoFromMpls(ClipSeletIndex); - } - else if (_ifoGroup != null) - { - GetChapterInfoFromIFO(ClipSeletIndex); - } - if (Shift) - { - cbShift_CheckedChanged(new object(), new EventArgs()); - } - //_info.Mul1K1 = cbMul1k1.Checked; + if (_rawMpls != null) GetChapterInfoFromMpls(ClipSeletIndex); + else if (_ifoGroup != null) GetChapterInfoFromIFO(ClipSeletIndex); + if (Shift) cbShift_CheckedChanged(null, null); UpdataGridView(); } From c80b89596b4984780e8d2565e3e38039ee88a3b3 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sun, 22 Jan 2017 12:00:11 +0800 Subject: [PATCH 29/30] Some more log about flac. --- Time_Shift/Util/ChapterData/FlacData.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Time_Shift/Util/ChapterData/FlacData.cs b/Time_Shift/Util/ChapterData/FlacData.cs index fa27fa5..27fa71b 100644 --- a/Time_Shift/Util/ChapterData/FlacData.cs +++ b/Time_Shift/Util/ChapterData/FlacData.cs @@ -130,8 +130,8 @@ private static void ParseVorbisComment(Stream fs, ref FlacInfo info) var key = comment.Substring(0, spilterIndex); var value = comment.Substring(spilterIndex + 1, comment.Length - 1 - spilterIndex); info.VorbisComment[key] = value; - var summary = value.Length > 15 ? value.Substring(0, 15) + "..." : value; - OnLog?.Invoke($" | [{key}] = '{summary}'"); + var summary = value.Length > 25 ? value.Substring(0, 25) + "..." : value; + OnLog?.Invoke($" | [{key}] = '{summary.Replace('\n', ' ')}'"); } } @@ -150,6 +150,8 @@ private static void ParsePicture(Stream fs, ref FlacInfo info) fs.Seek(pictureDataLength, SeekOrigin.Current); info.RawLength += pictureDataLength; info.HasCover = true; + OnLog?.Invoke($" | picture type: {mimeType}"); + OnLog?.Invoke($" | attribute: {pictureWidth}px*{pictureHeight}px@{colorDepth}-bit"); } private static ushort ReadUShort(this Stream fs) From 961b210e8d076aa8a81b31883d892d234cf3f711 Mon Sep 17 00:00:00 2001 From: tautcony Date: Sun, 22 Jan 2017 12:54:28 +0800 Subject: [PATCH 30/30] Update version infomation. --- ChangeLog.md | 6 ++++++ Time_Shift/Properties/AssemblyInfo.cs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 82c74d2..979a9f6 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -333,3 +333,9 @@ - 使用表达式来控制时间戳的变换(所有运算符均采用左结合) - 表达式形式可选中缀表达式或逆波兰表达式(仅限vapoursynth中支持的操作符) - 输入的表达式将会在log中输出转换后的逆波兰表达式(应QPet需求)或中缀表达式 + +## [2.33.33.1] +- 错误修正与效能提升 +- mpls增加追加功能 +- 低版本.Net运行时增加更新提示 +- 新增flac parser可获得更多flac相关信息(虽然是ATI用的 diff --git a/Time_Shift/Properties/AssemblyInfo.cs b/Time_Shift/Properties/AssemblyInfo.cs index fb9caad..dd60faf 100644 --- a/Time_Shift/Properties/AssemblyInfo.cs +++ b/Time_Shift/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.33.32.33")] -[assembly: AssemblyFileVersion("2.33.32.33")] +[assembly: AssemblyVersion("2.33.33.1")] +[assembly: AssemblyFileVersion("2.33.33.1")]