2509031637

Env config路徑改自本地
升降調label顯示邏輯修改
This commit is contained in:
jasonchenwork 2025-09-03 16:38:39 +08:00
parent 4ca6594561
commit 403e3c9606
7 changed files with 56 additions and 35 deletions

View File

@ -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("服務鈴"));

View File

@ -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;
}
}
}

14
Env.cs
View File

@ -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<string> 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");
}

View File

@ -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();

View File

@ -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");};

View File

@ -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<Control> _StartupcontrolsTop= new List<Control>();
public List<Control> _StartupcontrolsBottom= new List<Control>();
//async Task<Bitmap> GetBitmapFromUriAsync(Uri uri)

View File

@ -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)