superstar_v2/DBObj/SongData.cs
jasonchenwork 8ca1dfcb2e 202508081823
Env 加入 sshost1
PlayState.Skipped 調整 為 刪除
手劃到選單上不顯示顏色
已點歌曲不會刪除 而移到完成
2025-08-11 10:42:06 +08:00

129 lines
4.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DualScreenDemo;
using System;
using System.IO;
using System.Windows.Markup;
namespace DBObj
{
public class SongData
{
private Song basic;
private Artist A ;
private Artist B ;
public bool isPublicSong { get; set; }
public PlayState state;
public SongData(string songNumber, string song, string filename, int humanVoice, bool isPublic)
{
basic=new(songNumber,song,"",filename,humanVoice);
isPublicSong = isPublic;
}
public SongData(string songNumber, string song, string artistA, string artistB, string filename, string artistASimplified, string artistBSimplified, string songSimplified, int humanVoice)
{
basic=new(songNumber,song,songSimplified,filename,humanVoice);
A= new Artist(artistA, artistASimplified);
if(!artistB.Equals("")){
B = new Artist(artistB, artistBSimplified);
} else
{
B = null;
}
isPublicSong = false;
}
public SongData(SongData value,PlayState s){
basic = value.getBasic();
A = value.getA();
B = value.getB();
state =s;
}
public Song getBasic() => basic;
public Artist getA() => A;
public Artist getB() => B;
public string getNumber() {return basic.getNumber();}
public string getName(bool IsSimplified=false) { return basic.getName(IsSimplified); }
public string getName() { return basic.getName();}
public string getArtist_A(bool IsSimplified) { return A.getName(IsSimplified); }
public string getArtist_A() { return A.getName();}
public string getArtist_B(bool IsSimplified) { return B.getName(IsSimplified); }
public string getArtist_B() { return B.getName();}
public int getNameLength() { return basic.getName().Length; }
public string getFileName() {return basic.getFileName();}
public string next_song_text()
{
var str = (state == PlayState.InsertPlayback) ? GetStateTxt(false) : "";
return String.Format("下一首:{0} {1}", basic.getName(false),str);
}
public string artist_text()
{
return B!=null
? $"{A.getName(false)} - {B.getName(false)}"
: A.getName(false);
}
public string name_text()
{
return B!=null
? String.Format("{0} - {1} - {2}", A.getName(false), B.getName(false), basic.getName(false))
: String.Format("{0} - {1}", A.getName(false), basic.getName(false));
}
public bool FileExistsInServers()
{
foreach (var server in Utils.Env.GetSongServers())
{
try
{
string fullPath = Path.Combine(server, basic.getFileName());
if (File.Exists(fullPath))
{
Console.WriteLine($"找到檔案: {fullPath}");
return true;
}
}
catch (Exception ex)
{
Console.WriteLine($"檢查檔案時發生錯誤: {ex.Message}");
}
}
Console.WriteLine($"全部 server 都找不到檔案: {basic.getFileName()}");
return false;
}
public string getFile()
{
return FindExistingPath(basic.getFileName());
}
private string FindExistingPath(string filename)
{
foreach (var server in Utils.Env.GetSongServers())
{
string fullPath = Path.Combine(server, filename);
if (File.Exists(fullPath)) return fullPath;
}
return null; // 找不到就回原本的 filename不加路徑
}
public Color GetStateColor(){
Color c = Color.White;
if (state == PlayState.Played) c = Color.Gray;//Color.FromArgb(200, 75, 125); // 播畢顏色:紫紅色
else if (state == PlayState.Skipped)c = Color.Gray;
else if (state == PlayState.NoFile)c = Color.Gray;
else if (state == PlayState.Playing)c = Color.LimeGreen;
else if (state == PlayState.InsertPlayback)c = Color.Gold;
return c;
}
public string GetStateTxt(bool IsSimplified){
return (state==PlayState.NotPlayed)?"":$"({state.GetDescription(IsSimplified)})";
}
public void SetState(PlayState s) => state = s;
public PlayState GetState()
{
return state;
}
public int getHumanVoice() { return basic.getHumanVoice(); }
public override string ToString()
{
return String.Format("{0} {1}", basic.getName(),state.GetDescription() );
}
}
}