本文整理汇总了C#中TimingMethod类的典型用法代码示例。如果您正苦于以下问题:C# TimingMethod类的具体用法?C# TimingMethod怎么用?C# TimingMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimingMethod类属于命名空间,在下文中一共展示了TimingMethod类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RecentSplitsFile
public RecentSplitsFile(string path, TimingMethod method, string gameName = null, string categoryName = null)
{
GameName = gameName;
CategoryName = categoryName;
Path = path;
LastTimingMethod = method;
}
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:7,代码来源:ISettings.cs
示例2: PopulatePredictions
private static void PopulatePredictions(IRun run, TimeSpan? currentTime, int segmentIndex, IList<TimeSpan?> predictions, bool simpleCalculation, bool useCurrentRun, TimingMethod method)
{
if (currentTime != null)
{
PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1);
if (!simpleCalculation)
{
foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Time[method].HasValue))
{
var segmentTime = segmentIndex > 0 ? run[segmentIndex - 1].SegmentHistory.FirstOrDefault(x => x.Index == nullSegment.Index) : null;
if (segmentTime == null || segmentTime.Time[method] != null)
{
var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Index, method);
PopulatePrediction(predictions, prediction.Time[method], prediction.Index);
}
}
}
if (useCurrentRun)
{
var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method);
PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index);
}
var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method);
PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index);
}
}
开发者ID:kugelrund,项目名称:LiveSplit,代码行数:26,代码来源:SumOfBest.cs
示例3: Generate
public void Generate(TimingMethod method)
{
var maxIndex = Run.AttemptHistory.Select(x => x.Index).DefaultIfEmpty(0).Max();
for (var y = Run.GetMinSegmentHistoryIndex(); y <= maxIndex; y++)
{
var time = TimeSpan.Zero;
foreach (var segment in Run)
{
Time segmentHistoryElement;
if (segment.SegmentHistory.TryGetValue(y, out segmentHistoryElement))
{
var segmentTime = segmentHistoryElement[method];
if (segmentTime != null)
{
time += segmentTime.Value;
if (segment.Comparisons[Name][method] == null || time < segment.Comparisons[Name][method])
{
var newTime = new Time(segment.Comparisons[Name]);
newTime[method] = time;
segment.Comparisons[Name] = newTime;
}
}
}
else break;
}
}
}
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:29,代码来源:BestSplitTimesComparisonGenerator.cs
示例4: PopulatePredictions
private static void PopulatePredictions(IRun run, TimeSpan? currentTime, int segmentIndex, IList<TimeSpan?> predictions, bool useCurrentRun, TimingMethod method)
{
if (currentTime != null)
{
PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1);
foreach (var segment in run[segmentIndex].SegmentHistory)
{
Time segmentTime;
if (segmentIndex == 0
|| !run[segmentIndex - 1].SegmentHistory.TryGetValue(segment.Key, out segmentTime)
|| segmentTime[method] != null)
{
var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex, segment.Key, method);
PopulatePrediction(predictions, prediction.Time[method], prediction.Index);
}
}
if (useCurrentRun)
{
var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method);
PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index);
}
var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method);
PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index);
}
}
开发者ID:Glurmo,项目名称:LiveSplit,代码行数:25,代码来源:SumOfWorst.cs
示例5: SubmitRun
public virtual bool SubmitRun(
IRun run,
string username, string password,
Func<Image> screenShotFunction = null,
bool attachSplits = false,
TimingMethod method = TimingMethod.RealTime,
string gameId = "", string categoryId = "",
string version = "", string comment = "",
string video = "",
params string[] additionalParams)
{
try
{
if (attachSplits)
comment += " " + SplitsIO.Instance.Share(run, screenShotFunction);
if (gameId == string.Empty)
gameId = GetGameIdByName(run.GameName);
if (categoryId == string.Empty)
categoryId = GetCategoryIdByName(gameId, run.CategoryName);
var json = ASUP.SubmitRun(run, username, password, gameId, categoryId, version, comment, video, additionalParams);
return json.result == "success";
}
catch (Exception e)
{
Log.Error(e);
return false;
}
}
开发者ID:xarrez,项目名称:LiveSplit,代码行数:29,代码来源:ASUPRunUploadPlatform.cs
示例6: GetSegmentTimeOrSegmentDelta
private static TimeSpan? GetSegmentTimeOrSegmentDelta(LiveSplitState state, int splitNumber, bool useCurrentTime, bool segmentTime, string comparison, TimingMethod method)
{
TimeSpan? currentTime;
if (useCurrentTime)
currentTime = state.CurrentTime[method];
else
currentTime = state.Run[splitNumber].SplitTime[method];
if (currentTime == null)
return null;
for (int x = splitNumber - 1; x >= 0; x--)
{
var splitTime = state.Run[x].SplitTime[method];
if (splitTime != null)
{
if (segmentTime)
return currentTime - splitTime;
else if (state.Run[x].Comparisons[comparison][method] != null)
return (currentTime - state.Run[splitNumber].Comparisons[comparison][method]) - (splitTime - state.Run[x].Comparisons[comparison][method]);
}
}
if (segmentTime)
return currentTime;
else
return currentTime - state.Run[splitNumber].Comparisons[comparison][method];
}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:27,代码来源:LiveSplitStateHelper.cs
示例7: Generate
public void Generate(TimingMethod method)
{
for (var y = Run.GetMinSegmentHistoryIndex() + 1; y <= Run.AttemptHistory.Count; y++)
{
var time = TimeSpan.Zero;
foreach (var segment in Run)
{
var segmentHistoryElement = segment.SegmentHistory.FirstOrDefault(x => x.Index == y);
if (segmentHistoryElement != null)
{
var segmentTime = segmentHistoryElement.Time[method];
if (segmentTime != null)
{
time += segmentTime.Value;
if (segment.Comparisons[Name][method] == null || time < segment.Comparisons[Name][method])
{
var newTime = new Time(segment.Comparisons[Name]);
newTime[method] = time;
segment.Comparisons[Name] = newTime;
}
}
}
else break;
}
}
}
开发者ID:xarrez,项目名称:LiveSplit,代码行数:28,代码来源:BestSplitTimesComparisonGenerator.cs
示例8: PopulatePredictions
private static void PopulatePredictions(IRun run, TimeSpan? currentTime, int segmentIndex, IList<TimeSpan?> predictions, bool simpleCalculation, bool useCurrentRun, TimingMethod method)
{
if (currentTime != null)
{
PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1);
if (!simpleCalculation)
{
foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Value[method].HasValue))
{
Time segmentTime;
if (segmentIndex == 0
|| !run[segmentIndex - 1].SegmentHistory.TryGetValue(nullSegment.Key, out segmentTime)
|| segmentTime[method] != null)
{
var prediction = TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Key, method);
PopulatePrediction(predictions, prediction.Time[method], prediction.Index);
}
}
}
if (useCurrentRun)
{
var currentRunPrediction = TrackCurrentRun(run, currentTime, segmentIndex, method);
PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index);
}
var personalBestRunPrediction = TrackPersonalBestRun(run, currentTime, segmentIndex, method);
PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index);
}
}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:28,代码来源:SumOfBest.cs
示例9: TimedRun
public TimedRun(String paramValue,
TimingMethod timingMethod = TimingMethod.Stopwatch)
{
ParamValue = paramValue;
Method = timingMethod;
Start();
}
开发者ID:jazzlife,项目名称:pdf-ebook-reader,代码行数:8,代码来源:TimedRun.cs
示例10: GetLastDelta
/// <summary>
/// Gets the last non-live delta in the run starting from splitNumber.
/// </summary>
/// <param name="state">The current state.</param>
/// <param name="splitNumber">The split number to start checking deltas from.</param>
/// <param name="comparison">The comparison that you are comparing with.</param>
/// <param name="method">The timing method that you are using.</param>
/// <returns>Returns the last non-live delta or null if there have been no deltas yet.</returns>
public static TimeSpan? GetLastDelta(LiveSplitState state, int splitNumber, string comparison, TimingMethod method)
{
for (var x = splitNumber; x >= 0; x--)
{
if (state.Run[x].Comparisons[comparison][method] != null && state.Run[x].SplitTime[method] != null)
return state.Run[x].SplitTime[method] - state.Run[x].Comparisons[comparison][method];
}
return null;
}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:17,代码来源:LiveSplitStateHelper.cs
示例11: parseTime
private static Time parseTime(int? time, TimingMethod timingMethod)
{
var parsedTime = new Time();
if (time.HasValue)
parsedTime[timingMethod] = TimeSpan.FromMilliseconds(time.Value);
return parsedTime;
}
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:9,代码来源:SplittyRunFactory.cs
示例12:
public TimeSpan? this[TimingMethod method]
{
get { return method == TimingMethod.RealTime ? RealTime : GameTime; }
set
{
if (method == TimingMethod.RealTime)
RealTime = value;
else
GameTime = value;
}
}
开发者ID:ExploudYourEar,项目名称:LiveSplit,代码行数:11,代码来源:Time.cs
示例13: CreateTimer
private static IDisposable CreateTimer(TimingMethod timingMethod)
{
switch (timingMethod)
{
case TimingMethod.WallClock:
return new MyWallTimer();
case TimingMethod.CPU:
return new MyCpuTimer();
default:
return new NullTimer();
}
}
开发者ID:adrianbanks,项目名称:Scratch,代码行数:12,代码来源:Iterations.cs
示例14: CalculateSumOfBest
public static TimeSpan? CalculateSumOfBest(IRun run, int startIndex, int endIndex, IList<TimeSpan?> predictions, bool simpleCalculation = false, bool useCurrentRun = true, TimingMethod method = TimingMethod.RealTime)
{
int segmentIndex = 0;
TimeSpan? currentTime = TimeSpan.Zero;
predictions[startIndex] = TimeSpan.Zero;
foreach (var segment in run.Skip(startIndex).Take(endIndex - startIndex + 1))
{
currentTime = predictions[segmentIndex];
PopulatePredictions(run, currentTime, segmentIndex, predictions, simpleCalculation, useCurrentRun, method);
segmentIndex++;
}
return predictions[endIndex + 1];
}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:13,代码来源:SumOfBest.cs
示例15: Run
/// <summary>
/// Runs an action a given number of times.
/// </summary>
public static void Run(int numberOfIterations, Action action, Action betweenEachAction = null, TimingMethod timingMethod = TimingMethod.None)
{
using (var timer = CreateTimer(timingMethod))
{
for (int i = 1; i <= numberOfIterations; i++)
{
action();
if (i < numberOfIterations)
{
betweenEachAction?.Invoke();
}
}
}
}
开发者ID:adrianbanks,项目名称:Scratch,代码行数:18,代码来源:Iterations.cs
示例16: GetTime
public override TimeSpan? GetTime(Model.LiveSplitState state, TimingMethod method)
{
TimeSpan? lastSplit = TimeSpan.Zero;
var runEndedDelay = state.CurrentPhase == TimerPhase.Ended ? 1 : 0;
if (state.CurrentSplitIndex > 0 + runEndedDelay)
{
if (state.Run[state.CurrentSplitIndex - 1 - runEndedDelay].SplitTime[method] != null)
lastSplit = state.Run[state.CurrentSplitIndex - 1 - runEndedDelay].SplitTime[method].Value;
else
lastSplit = null;
}
if (state.CurrentPhase == TimerPhase.NotRunning)
return state.Run.Offset;
else
return state.CurrentTime[method] - lastSplit;
}
开发者ID:0xwas,项目名称:LiveSplit.DetailedTimer,代码行数:16,代码来源:SegmentTimer.cs
示例17: TrackCurrentRun
public static IndexedTime TrackCurrentRun(IRun run, TimeSpan? currentTime, int segmentIndex, TimingMethod method = TimingMethod.RealTime)
{
if (segmentIndex > 0 && !run[segmentIndex - 1].SplitTime[method].HasValue)
return new IndexedTime(default(Time), 0);
var firstSplitTime = segmentIndex < 1 ? TimeSpan.Zero : run[segmentIndex - 1].SplitTime[method];
while (segmentIndex < run.Count)
{
var secondSplitTime = run[segmentIndex].SplitTime[method];
if (secondSplitTime.HasValue)
{
return new IndexedTime(new Time(method, secondSplitTime - firstSplitTime + currentTime), segmentIndex + 1);
}
segmentIndex++;
}
return new IndexedTime(default(Time), 0);
}
开发者ID:Glurmo,项目名称:LiveSplit,代码行数:16,代码来源:SumOfSegmentsHelper.cs
示例18: SubmitRun
public bool SubmitRun(IRun run, string username, string password, Func<System.Drawing.Image> screenShotFunction = null, bool attachSplits = false, TimingMethod method = TimingMethod.RealTime, string gameId = "", string categoryId = "", string version = "", string comment = "", string video = "", params string[] additionalParams)
{
string reason;
var isValid = SpeedrunCom.ValidateRun(run.Metadata.LiveSplitRun, out reason);
if (!isValid)
{
MessageBox.Show(reason, "Submitting Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
using (var submitDialog = new SpeedrunComSubmitDialog(run.Metadata))
{
var result = submitDialog.ShowDialog();
return result == DialogResult.OK;
}
}
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:17,代码来源:SpeedrunComRunUploadPlatform.cs
示例19: Clean
public static void Clean(IRun run, TimingMethod method, CleanUpCallback callback = null)
{
var predictions = new TimeSpan?[run.Count + 1];
CalculateSumOfBest(run, 0, run.Count - 1, predictions, true, false, method);
int segmentIndex = 0;
TimeSpan? currentTime = TimeSpan.Zero;
foreach (var segment in run)
{
currentTime = predictions[segmentIndex];
foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Value[method].HasValue))
{
var prediction = TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Key, method);
CheckPrediction(run, predictions, prediction.Time[method], segmentIndex - 1, prediction.Index - 1, nullSegment.Key, method, callback);
}
segmentIndex++;
}
}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:17,代码来源:SumOfBest.cs
示例20: TrackBranch
public static IndexedTime TrackBranch(IRun run, TimeSpan? currentTime, int segmentIndex, int runIndex, TimingMethod method = TimingMethod.RealTime)
{
while (segmentIndex < run.Count)
{
Time segmentTime;
if (run[segmentIndex].SegmentHistory.TryGetValue(runIndex, out segmentTime))
{
var curTime = segmentTime[method];
if (curTime.HasValue)
{
return new IndexedTime(new Time(method, curTime + currentTime), segmentIndex + 1);
}
}
else break;
segmentIndex++;
}
return new IndexedTime(default(Time), 0);
}
开发者ID:Glurmo,项目名称:LiveSplit,代码行数:18,代码来源:SumOfSegmentsHelper.cs
注:本文中的TimingMethod类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论