diff --git a/CommandHandler.cs b/CommandHandler.cs index 7591259..53f68cd 100644 --- a/CommandHandler.cs +++ b/CommandHandler.cs @@ -128,31 +128,39 @@ namespace DualScreenDemo SafeInvokeAction("A275A4",() => OverlayForm.MainForm.ShowTopRightLabelTime(" 調色 ")); break; case "A283A4": - SafeInvokeAction("A283A4",() => OverlayForm.MainForm.ShowTopRightLabelTime("↑升4調 ")); + SafeInvokeAction("A283A4",() => OverlayForm.MainForm.ShowTopRightLabel("↑升4調 ")); + OverlayForm.Instance.topRightTimer.Stop(); break; case "A282A4": - SafeInvokeAction("A282A4",() => OverlayForm.MainForm.ShowTopRightLabelTime("↑升3調 ")); + SafeInvokeAction("A282A4",() => OverlayForm.MainForm.ShowTopRightLabel("↑升3調 ")); + OverlayForm.Instance.topRightTimer.Stop(); break; case "A281A4": - SafeInvokeAction("A281A4",() => OverlayForm.MainForm.ShowTopRightLabelTime("↑升2調 ")); + SafeInvokeAction("A281A4",() => OverlayForm.MainForm.ShowTopRightLabel("↑升2調 ")); + OverlayForm.Instance.topRightTimer.Stop(); break; case "A280A4": - SafeInvokeAction("A280A4",() => OverlayForm.MainForm.ShowTopRightLabelTime("↑升1調 ")); + SafeInvokeAction("A280A4",() => OverlayForm.MainForm.ShowTopRightLabel("↑升1調 ")); + OverlayForm.Instance.topRightTimer.Stop(); break; case "A27FA4": SafeInvokeAction("A27FA4",() => OverlayForm.MainForm.ShowTopRightLabelTime(" 標準調 ")); break; case "A27EA4": - SafeInvokeAction("A27EA4",() => OverlayForm.MainForm.ShowTopRightLabelTime("↓降1調 ")); + SafeInvokeAction("A27EA4",() => OverlayForm.MainForm.ShowTopRightLabel("↓降1調 ")); + OverlayForm.Instance.topRightTimer.Stop(); break; case "A27DA4": - SafeInvokeAction("A27EA4",() => OverlayForm.MainForm.ShowTopRightLabelTime("↓降2調 ")); + SafeInvokeAction("A27EA4",() => OverlayForm.MainForm.ShowTopRightLabel("↓降2調 ")); + OverlayForm.Instance.topRightTimer.Stop(); break; case "A27CA4": - SafeInvokeAction("A27CA4",() => OverlayForm.MainForm.ShowTopRightLabelTime("↓降3調 ")); + SafeInvokeAction("A27CA4",() => OverlayForm.MainForm.ShowTopRightLabel("↓降3調 ")); + OverlayForm.Instance.topRightTimer.Stop(); break; case "A27BA4": - SafeInvokeAction("A27BA4",() => OverlayForm.MainForm.ShowTopRightLabelTime("↓降4調 ")); + SafeInvokeAction("A27BA4",() => OverlayForm.MainForm.ShowTopRightLabel("↓降4調 ")); + OverlayForm.Instance.topRightTimer.Stop(); break; case "A266A4": SafeInvokeAction("A266A4",() => OverlayForm.MainForm.ShowTopRightLabel("服務鈴")); diff --git a/DBObj/SongData.cs b/DBObj/SongData.cs index 34ad183..4d67087 100644 --- a/DBObj/SongData.cs +++ b/DBObj/SongData.cs @@ -108,22 +108,27 @@ namespace DBObj } public Uri getFileUrl() { - return GetUri(basic.getFileName()); + if (!isPublicSong) + { + return GetUri(basic.getFileName()); + } + return null; } private Uri GetUri(string filename) { foreach (var server in Utils.Env.GetSongServers()) { - var check = IsFtpUriReachable(new Uri(server).ToString()); - if (!string.IsNullOrWhiteSpace(server) && check != false) - { - return new Uri(new Uri(server), filename); - } + var check = IsFtpUriReachable(new Uri(server).ToString()); + if (!string.IsNullOrWhiteSpace(server) && check != false) + { + Console.WriteLine(new Uri(new Uri(server), filename)); + if (IsFtpUriReachable(new Uri(new Uri(server), filename).ToString())) return new Uri(new Uri(server), filename); + } } // throw new InvalidOperationException("No valid server found."); - Console.WriteLine("No valid server found."); + if (!isPublicSong) Console.WriteLine("No valid server found."); return null; } @@ -146,13 +151,13 @@ namespace DBObj { return String.Format("{0} {1}", basic.getName(), state.GetDescription()); } - public static bool IsFtpUriReachable(string ftpUri) + public bool IsFtpUriReachable(string ftpUri) { try { - #pragma warning disable SYSLIB0014 // 類型或成員已經過時 +#pragma warning disable SYSLIB0014 // 類型或成員已經過時 var request = (FtpWebRequest)WebRequest.Create(ftpUri); - #pragma warning restore SYSLIB0014 // 類型或成員已經過時 +#pragma warning restore SYSLIB0014 // 類型或成員已經過時 request.Method = WebRequestMethods.Ftp.ListDirectory; // Lightweight check // request.Credentials = new NetworkCredential("svr", "svr"); // Replace with actual username/password request.Timeout = 5000; @@ -177,5 +182,11 @@ namespace DBObj return false; } } + + public static bool IsFtpUri(Uri uri) + { + return uri != null && uri.Scheme == Uri.UriSchemeFtp; + } + } } \ No newline at end of file diff --git a/Env.cs b/Env.cs index 8093219..7005b8a 100644 --- a/Env.cs +++ b/Env.cs @@ -9,7 +9,8 @@ namespace Utils { public static class Env { - private static string KtvPath = ""; + // private static string KtvPath = ""; + private static string KtvPath = @"\\sshost\KTVSuperstar"; private static readonly List KtvPaths = new() { @"\\sshost\KTVSuperstar", @@ -21,14 +22,15 @@ namespace Utils static Env() { - foreach (var path in KtvPaths) - { - // var path = Application.StartupPath; + // foreach (var path in KtvPaths) + // { + var path = Application.StartupPath; var configPath = Path.Combine(path, "config.ini"); if (File.Exists(configPath)) { - KtvPath = path; + // KtvPath = path; + Console.WriteLine("找到設定檔:" + configPath); foreach (var line in File.ReadAllLines(configPath)) { @@ -49,7 +51,7 @@ namespace Utils return; // 找到一份 config 就跳出 } - } + // } Console.WriteLine("所有指定目錄都找不到 config.ini"); } diff --git a/OverlayFormObj/OverlayForm.Labels.cs b/OverlayFormObj/OverlayForm.Labels.cs index 700a0ba..65391fb 100644 --- a/OverlayFormObj/OverlayForm.Labels.cs +++ b/OverlayFormObj/OverlayForm.Labels.cs @@ -13,7 +13,7 @@ namespace OverlayFormObj public Label muteLabel; // New mute label public Label topLeftLabel; public Label topRightLabel; - private System.Windows.Forms.Timer topRightTimer = new System.Windows.Forms.Timer(); + public System.Windows.Forms.Timer topRightTimer = new System.Windows.Forms.Timer(); private System.Windows.Forms.Timer secondLineDisplayTimer = new System.Windows.Forms.Timer(); private System.Windows.Forms.Timer qrCodeTimer = new System.Windows.Forms.Timer(); private System.Windows.Forms.Timer delayTimer = new System.Windows.Forms.Timer(); diff --git a/PrimaryFormParts/PrimaryForm.SyncScreen.cs b/PrimaryFormParts/PrimaryForm.SyncScreen.cs index 46777c9..9039d83 100644 --- a/PrimaryFormParts/PrimaryForm.SyncScreen.cs +++ b/PrimaryFormParts/PrimaryForm.SyncScreen.cs @@ -91,32 +91,31 @@ namespace DualScreenDemo new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MusicVolGain"])), new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MusicVolGain"])), null); - this.syncVolumeUpButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("音量 ↑ ","a2 b3 a4"); }; - this.syncVolumeUpButton.MouseUp += (sender, e) => { OverlayForm.MainForm.RedisplayTopRigthLabel(); }; + this.syncVolumeUpButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabelTime("音量 ↑ ","a2 b3 a4"); }; + ConfigureButton(this.syncVolumeDownButton, 1218, 616, 205, 55, new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MusicVolDown"])), new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MusicVolDown"])), new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MusicVolDown"])), null); - this.syncVolumeDownButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("音量 ↓ ","a2 b4 a4");}; - this.syncVolumeDownButton.MouseUp += (sender, e) => { OverlayForm.MainForm.RedisplayTopRigthLabel();}; + this.syncVolumeDownButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabelTime("音量 ↓ ","a2 b4 a4");}; + ConfigureButton(this.syncMicUpButton, 1218, 686, 205, 56, new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MicVolGain"])), new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MicVolGain"])), new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MicVolGain"])), null); - this.syncMicUpButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("麥克風 ↑ ","a2 b5 a4");}; - this.syncMicUpButton.MouseUp += (sender, e) => { OverlayForm.MainForm.RedisplayTopRigthLabel(); }; + this.syncMicUpButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabelTime("麥克風 ↑ ","a2 b5 a4");}; + ConfigureButton(this.syncMicDownButton, 1218, 756, 205, 56, new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MicVolDown"])), new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MicVolDown"])), new Bitmap(Path.Combine(serverPath, data["SyncScreen"]["MicVolDown"])), null); - this.syncMicDownButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("麥克風 ↓ ","a2 b6 a4");}; - this.syncMicDownButton.MouseUp += (sender, e) => { OverlayForm.MainForm.RedisplayTopRigthLabel(); }; + this.syncMicDownButton.MouseDown += (sender, e) => { OverlayForm.MainForm.ShowTopRightLabelTime("麥克風 ↓ ","a2 b6 a4");}; diff --git a/PrimaryFormParts/PrimaryForm.cs b/PrimaryFormParts/PrimaryForm.cs index a02bda5..a03f486 100644 --- a/PrimaryFormParts/PrimaryForm.cs +++ b/PrimaryFormParts/PrimaryForm.cs @@ -59,7 +59,7 @@ namespace DualScreenDemo public Button muteButton; private Button maleKeyButton; private Button femaleKeyButton; - private Button standardKeyButton; + public Button standardKeyButton; private Button soundEffectButton; private Button pitchUpButton; private Button pitchDownButton; @@ -87,7 +87,7 @@ namespace DualScreenDemo public VideoView videoView1 = new VideoView() { Dock = DockStyle.Fill }; // string serverPath = Utils.Env.GetPath("", ""); - string serverPath = Application.StartupPath; + public string serverPath = Application.StartupPath; public List _StartupcontrolsTop= new List(); public List _StartupcontrolsBottom= new List(); //async Task GetBitmapFromUriAsync(Uri uri) diff --git a/VideoPlayerForm.cs b/VideoPlayerForm.cs index 007666f..22b7478 100644 --- a/VideoPlayerForm.cs +++ b/VideoPlayerForm.cs @@ -365,6 +365,7 @@ namespace DualScreenDemo Task.Run(() => Thread.Sleep(100)); if (isSyncToPrimaryMonitor) SyncToPrimaryMonitor(); if (url == null&&!song.isPublicSong) PlayNextSong(); + PrimaryForm.Instance.standardKeyButton.PerformClick(); return Task.CompletedTask; } catch (Exception ex)