代码拉取完成,页面将自动刷新
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing;
namespace avs2bdnxml_gui
{
#region Class Common
public class Common
{
#region Members
public static Resolution[] ResolutionList = new Resolution[] { new Resolution(1920, 1080), new Resolution(4096, 2160), new Resolution(1280, 720) };
public static double[] FpsList = new double[] { 23.976, 59.940, 50, 29.970, 25, 24 };
public enum FileType
{
Ass,
Ssa
}
#endregion
#region Class Resolution
public class Resolution
{
public int X { get; set; }
public int Y { get; set; }
public Resolution(int x, int y)
{
this.X = x;
this.Y = y;
}
}
#endregion
#region Class TaskData
public class TaskData
{
public string FileName { get; set; }
public string FileFullPath { get; set; }
public ConfigData CData { get; set; }
public TaskData()
{
CData = new ConfigData();
}
}
#endregion
#region Class ConfigData
[Serializable]
public class ConfigData
{
public string OutputPath { get; set; }
public int ResolutionIndex { get; set; }
public int FpsIndex { get; set; }
public string Lang { get; set; }
public int X { get; set; }
public int Y { get; set; }
public int S { get; set; }
public int M { get; set; }
public int MaxDegreeOfParallelism { get; set; }
public bool A { get; set; }
public bool P { get; set; }
public bool B { get; set; }
public int EBlacka { get; set; }
public bool BSup { get; set; }
public bool BFirstBlack { get; set; }
public bool BEndBlack { get; set; }
public bool BvsMod { get; set; }
}
#endregion
#region Methods
public static FileType GetFileType(string filename)
{
var ext = Path.GetExtension(filename)?.ToUpper();
switch (ext)
{
case ".SSA": return FileType.Ssa;
default: return FileType.Ass;
}
}
public static List<string> ReadFile(string filename)
{
if (!File.Exists(filename))
{
return null;
}
var ls = new List<string>();
using (var fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (var sr = new StreamReader(fs))
{
do
{
var s = sr.ReadLine();
if (s.Trim() == "")
{
continue;
}
ls.Add(s);
} while (!sr.EndOfStream);
}
}
return ls;
}
public static string PlusTc(string tc, double fps, int flong)
{
int hour, minute, second, frame;
string shour, sminute, ssecond, sframe;
var sa = tc.Split(':');
int.TryParse(sa[0], out hour);
int.TryParse(sa[1], out minute);
int.TryParse(sa[2], out second);
int.TryParse(sa[3], out frame);
frame += flong;
if (frame > fps)
{
second += (int)(frame / fps);
frame = (int)(frame % fps);
}
if (second > 59)
{
minute += (int)(second / 60);
second %= 60;
}
if (minute > 59)
{
hour += (int)(minute / 60);
minute %= 60;
}
shour = hour.ToString(); sminute = minute.ToString(); ssecond = second.ToString(); sframe = frame.ToString();
if (hour < 10)
{
shour = "0" + shour;
}
if (minute < 10)
{
sminute = "0" + sminute;
}
if (second < 10)
{
ssecond = "0" + ssecond;
}
if (frame < 10)
{
sframe = "0" + sframe;
}
return shour + ":" + sminute + ":" + ssecond + ":" + sframe;
}
#endregion
#region Class SUBTime
public class SubTime
{
public int Hour { get; set; }
public int Minute { get; set; }
public int Second { get; set; }
public int SSecond { get; set; }
public SubTime(int hour = 0, int minute = 0, int second = 0, int ssecond = 0)
{
this.Hour = hour; this.Minute = minute; this.Second = second; this.SSecond = ssecond;
}
public long GetMSecond()
{
return ((this.Hour * 3600 * 1000) + (this.Minute * 60 * 1000) + (this.Second * 1000) + ((this.SSecond)));
}
public long GetSecond()
{
return ((this.Hour * 3600) + (this.Minute * 60) + (this.Second) + ((this.SSecond) / 1000));
}
public static SubTime Parse(string stime)
{
var at = new SubTime();
int hour, minute, second, ssecond;
var sa = stime.Split(new char[] { '.' }, 2);
if (sa.Length != 2)
{
return null;
}
var sl = sa[0];
var sr = sa[1];
var saa = sl.Split(new char[] { ':' }, 3);
if (saa.Length != 3)
{
return null;
}
int.TryParse(saa[0], out hour);
int.TryParse(saa[1], out minute);
int.TryParse(saa[2], out second);
int.TryParse(sr, out ssecond);
at.Hour = hour;
at.Minute = minute;
at.Second = second;
if (sr.Length == 2)
{
ssecond *= 10;
}
at.SSecond = ssecond;
return at;
}
public override bool Equals(object obj)
{
switch (obj)
{
case null:
return false;
case SubTime time:
{
var at = time;
return at.GetMSecond() == this.GetMSecond();
}
default:
return false;
}
}
public override int GetHashCode()
{
return this.GetMSecond().GetHashCode();
}
public SubTime GetAssTime()
{
this.SSecond /= 10;
return this;
}
public static SubTime operator +(SubTime lt, SubTime rt)
{
var at = new SubTime
{
Hour = lt.Hour + rt.Hour,
Minute = lt.Minute + rt.Minute,
Second = lt.Second + rt.Second,
SSecond = lt.SSecond + rt.SSecond
};
if (at.SSecond >= 1000)
{
at.Second += at.SSecond / 1000;
at.SSecond %= 1000;
}
if (at.Second >= 60)
{
at.Minute += at.Second / 60;
at.Second %= 60;
}
if (at.Minute < 60) return at;
at.Hour += at.Minute / 60;
at.Minute %= 60;
return at;
}
public static SubTime operator -(SubTime lt, SubTime rt)
{
if (lt == rt || lt < rt)
{
return new SubTime();
}
var at = new SubTime
{
Hour = lt.Hour - rt.Hour,
Minute = lt.Minute - rt.Minute,
Second = lt.Second - rt.Second,
SSecond = lt.SSecond - rt.SSecond
};
if (at.SSecond < 0)
{
at.SSecond = 1000 - Math.Abs(at.SSecond);
at.Second -= 1;
}
if (at.Second < 0)
{
at.Second = 60 - Math.Abs(at.Second);
at.Minute -= 1;
}
if (at.Minute >= 0) return at;
at.Minute = 60 - Math.Abs(at.Minute);
at.Hour -= 1;
return at;
}
public static bool operator ==(SubTime lt, SubTime rt)
{
return lt.GetMSecond() == rt.GetMSecond();
}
public static bool operator !=(SubTime lt, SubTime rt)
{
return !(lt == rt);
}
public static bool operator <(SubTime lt, SubTime rt)
{
return lt.GetMSecond() < rt.GetMSecond();
}
public static bool operator >(SubTime lt, SubTime rt)
{
return !(lt < rt) && lt != rt;
}
}
public static void SavePng(string ofname)
{
using (var fs = new FileStream(ofname, FileMode.Create))
{
using (var sw = new StreamWriter(fs))
{
fs.Write(Properties.Resources.black, 0, Properties.Resources.black.Length);
}
}
}
#endregion
}
#endregion
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。