PDA

View Full Version : سوال: :.:.:آیا این برنامه الگوریتم می باشد؟SRT )به c#(



ehsansoltanm
چهارشنبه 29 آذر 1391, 23:58 عصر
با سلام خدمت دوستان ... آیا قطعه برنامه زیر مربوط به الگوریتم SRT می شود؟ممنون یا حق

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Threading;

class Program
{
private static Queue<Subtitle> _subtitles;

private static Subtitle _activeSubtitle;

private static TimeSpan _currentTime = new TimeSpan();

static void Main(string[] args)
{
_subtitles = new Queue<Subtitle>();

Subtitle title1 = new Subtitle()
{
StartTime = TimeSpan.Parse("00:00:01.000"),
EndTime = TimeSpan.Parse("00:00:5.400"),
Text = "SALAM.p1.(TIMESPAN OF THIS PARAGRAF IS 05.000"
};

Subtitle title2 = new Subtitle()
{
StartTime = TimeSpan.Parse("00:00:5.900"),
EndTime = TimeSpan.Parse("00:00:10.500"),
Text = "PARAGRAF 2 : TIMESPAN 5.000"
};

Subtitle title3 = new Subtitle()
{
StartTime = TimeSpan.Parse("00:00:10.900"),
EndTime = TimeSpan.Parse("00:00:20.100"),
Text = "PARAGRAF 3 :.:.: IT :.:.: TIME SPAN "
};

_subtitles.Enqueue(title1);
_subtitles.Enqueue(title2);
_subtitles.Enqueue(title3);

Timer timer = new Timer(ShowSubtitles, null, 0, 100);

while (_currentTime <= new TimeSpan(0, 0, 1, 30))
{

}
Console.WriteLine("End");
}

private static void ShowSubtitles(object state)
{
Console.Clear();

if (_activeSubtitle == null && _subtitles.Count > 0)
_activeSubtitle = _subtitles.Dequeue();
// Console.WriteLine(_currentTime);

if (_activeSubtitle != null)
{


if (_currentTime >= _activeSubtitle.StartTime && _currentTime <= _activeSubtitle.EndTime)
Console.WriteLine(_activeSubtitle.Text);

if (_currentTime >= _activeSubtitle.EndTime)
_activeSubtitle = null;
}
_currentTime = _currentTime.Add(new TimeSpan(0, 0, 0, 0, 100));

}
}

internal class Subtitle
{
public TimeSpan StartTime { get; set; }
public TimeSpan EndTime { get; set; }
public string Text { get; set; }
}

ordebehesht
پنج شنبه 30 آذر 1391, 00:05 صبح
با سلام خدمت دوستان ... آیا قطعه برنامه زیر مربوط به الگوریتم SRT می شود؟ممنون یا حق using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; class Program { private static Queue _subtitles; private static Subtitle _activeSubtitle; private static TimeSpan _currentTime = new TimeSpan(); static void Main(string[] args) { _subtitles = new Queue(); Subtitle title1 = new Subtitle() { StartTime = TimeSpan.Parse("00:00:01.000"), EndTime = TimeSpan.Parse("00:00:5.400"), Text = "SALAM.(TIMESPAN OF THIS PARAGRAF IS 05.000" }; Subtitle title2 = new Subtitle() { StartTime = TimeSpan.Parse("00:00:5.900"), EndTime = TimeSpan.Parse("00:00:10.500"), Text = "PARAGRAF 2 : TIMESPAN 5.000" }; Subtitle title3 = new Subtitle() { StartTime = TimeSpan.Parse("00:00:10.900"), EndTime = TimeSpan.Parse("00:00:20.100"), Text = "PARAGRAF 3 :.:.: IT :.:.: TIME SPAN " }; _subtitles.Enqueue(title1); _subtitles.Enqueue(title2); _subtitles.Enqueue(title3); Timer timer = new Timer(ShowSubtitles, null, 0, 100); while (_currentTime 0) _activeSubtitle = _subtitles.Dequeue(); // Console.WriteLine(_currentTime); if (_activeSubtitle != null) { if (_currentTime >= _activeSubtitle.StartTime && _currentTime = _activeSubtitle.EndTime) _activeSubtitle = null; } _currentTime = _currentTime.Add(new TimeSpan(0, 0, 0, 0, 100)); } } internal class Subtitle { public TimeSpan StartTime { get; set; } public TimeSpan EndTime { get; set; } public string Text { get; set; } }


دوست من بالا این کادر نوشتاری یک تعدادآیتم هست با نامهای C#‎ و # , <> و js و cssو ....
اگه از ایم موارد استفاده میکردی کدت بهتر و خواناتر میشد من که هیچ کدر های حرفهای گم میشن لطف کن اصلاح کن

آنچه که معلومه این به زبون c# نوشته شده آیتم c# رو انتخواب کن