static void Main(string[] args) { Time t1 = new Time(); t1.Parse("00:01:45,000"); Console.WriteLine("t1 = " + t1.ToString() + "\n\t+1000ms"); t1.AddMil(1000); Console.WriteLine("t1 = " + t1.ToString() + "\n\t+1s"); t1.AddSec(1); Console.WriteLine("t1 = " + t1.ToString() + "\n\t+40s"); t1.AddSec(40); Console.WriteLine("t1 = " + t1.ToString() + "\n\t+59mn"); t1.AddMin(59); Console.WriteLine("t1 = " + t1.ToString() + "\n\t+3600000ms"); t1.AddMil(3600000); Console.WriteLine("t1 = " + t1.ToString() + "\n\t-29s"); t1.AddSec(-29); Console.WriteLine("t1 = " + t1.ToString() + "\n\t+29s"); t1.AddSec(29); Console.WriteLine("t1 = " + t1.ToString() + "\n\t+63m"); t1.AddMin(63); Console.WriteLine("t1 = " + t1.ToString() + "\n\t-63m"); t1.AddMin(-63); Console.WriteLine("t1 = " + t1.ToString() + "\n\t-1000ms"); t1.AddMil(-1000); Console.WriteLine("t1 = " + t1.ToString()); Console.WriteLine("Press key "); Console.ReadKey(); }
public void Resynk(string path, string ifile, int milToAdd, Time tapartirde, Encoding enc) { this._path = path; this._ifile = ifile; this._milToAdd = milToAdd; this._tapartirde = tapartirde; this._enc = enc; //string ofile = "synk_" + ifile; this._ofile = this._ifile.Substring(0, ifile.Length - 5) + "_synk.srt"; //Encoding enc = ObtientENcoding(path + "\\" + ifile); string[] lines = File.ReadAllLines(@path + "\\" + ifile, enc); this.ResynkLines(lines); // MoveFocus path + "\\" + ifile to old //String newifile = ifile.Substring(0, ifile.Length - 5) + "_old.srt"; //String newofile = ifile; //System.Threading.Thread.Sleep(2000); //System.IO.File.Move(path + "\\" + ifile, path + "\\" + newifile); //System.IO.File.Move(path + "\\" + ofile, path + "\\" + newofile); }
public SrtResynk(int milToAdd) { _isTestMode = true; _milToAdd = milToAdd; _tapartirde = new Time(0, 0, 0, 0); _enc = new UTF8Encoding(); this.TestContent = new List<string>(); }
private void Resynk(string path, string ifile, int milToAdd, Time tapartirde) { SrtResynk resynk = new SrtResynk(this); resynk.Resynk(path, ifile, milToAdd, tapartirde, ObtientENcoding(path + "\\" + ifile)); this.Pb.Visibility = Visibility.Visible; }
private void bResynk_Click(object sender, RoutedEventArgs e) { string path = ""; int totalMil = 0; StackPanel sp = this.SpTemps; int mili = 0; int sec; int min = 0; int heu = 0; if (this.Filename == "") return; path = this.TbFic.Text.Substring(0, this.TbFic.Text.Count() - 1 - this.Filename.Count()); try { mili = int.Parse(this.Z.Text); sec = int.Parse(this.S.Text); min = int.Parse(this.M.Text); heu = int.Parse(this.H.Text); } catch (FormatException fe) { Debug.WriteLine(fe.Message); Alert("Seulement des nombres"); return; } totalMil += mili + (sec + 60*min + 3600*heu)*1000; // Gere le signe if (this.RbMoins.IsChecked == true) { if (totalMil > 0) totalMil *= -1; } else if (this.RbPlus.IsChecked == true) { if (totalMil < 0) totalMil *= -1; } //--------------- //string apartir = "" + exh.ToString() try { mili = int.Parse(this.Exz.Text); sec = int.Parse(this.Exs.Text); min = int.Parse(this.Exm.Text); heu = int.Parse(this.Exh.Text); } catch (FormatException fe) { Debug.WriteLine(fe.Message); Alert("Seulement des nombres"); return; } Time t = new Time(heu, min, sec, mili); //------------------------ this.Resynk(path, this.Filename, totalMil, t); Alert("Syncro terminée."); this.Button_Click_1(new object(), new RoutedEventArgs()); }
private void FillTime() { _time = Time.MaxValue; //_time = new cTime(23, 59, 59, 999); }
private void ResetTime() { _time = Time.MinValue; //_time = new cTime(0, 0, 0, 0); }
public bool ResynkLines(string[] lines) { if ((_isTestMode && _window != null) || (!_isTestMode && _window == null)) { Debug.WriteLine("\tError with window or testMode..."); return false; } int cpt = 1; /* cTime tapartirde = new cTime(); if(!tapartirde.Parse(apartirde)) return; */ // Chiffre seul string patternC = @"^[0-9]+$"; // Temps => 00:00:00,000 --> 00:00:00,000 string patternT = @"^([0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3}) --> ([0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3})\s?$"; // Instantiate the regular expression object. Regex chi = new Regex(patternC, RegexOptions.IgnoreCase); Regex tps = new Regex(patternT, RegexOptions.IgnoreCase); // output file //System.IO.StreamWriter file = new System.IO.StreamWriter(path + "\\" + ofile); FileStream fs = null; StreamWriter file = StreamWriter.Null; if (!_isTestMode) { fs = File.Create(this._path + "\\" + this._ofile); file = new StreamWriter(fs, this._enc); } int total = this.GetNb(lines, chi); if (!_isTestMode && _window != null) _window.Pb.Visibility = System.Windows.Visibility.Visible; foreach (string line in lines) { string ligne = line; //si ligne de chiffre if (chi.Match(line).Success) { if (int.Parse(line) != cpt) ligne = cpt.ToString(); ++cpt; // StatusBar // binding??? if (_window != null) { _window.Percent = cpt*100.0/total; _window.Pb.Value = _window.Percent; } } Match m = tps.Match(line); if (m.Success) //si ligne de temps { string tps1 = m.Groups[1].ToString(); string tps2 = m.Groups[2].ToString(); Time ti1 = new Time(); ti1.Parse(tps1); Time ti2 = new Time(); ti2.Parse(tps2); if (ti1 >= this._tapartirde) { ti1.AddMil(this._milToAdd); ti2.AddMil(this._milToAdd); ligne = ti1.ToString() + " --> " + ti2.ToString(); } } if (!_isTestMode) file.WriteLine(ligne); else TestContent.Add(ligne); } // ReSharper disable once InvertIf if (!_isTestMode && fs != null) { file.Close(); fs.Close(); } return true; }
protected bool Equals(Time other) { return this._h == other._h && this._m == other._m && this._s == other._s && this._z == other._z; }