当前位置: 首页>>代码示例>>C#>>正文


C# Run.Last方法代码示例

本文整理汇总了C#中Run.Last方法的典型用法代码示例。如果您正苦于以下问题:C# Run.Last方法的具体用法?C# Run.Last怎么用?C# Run.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Run的用法示例。


在下文中一共展示了Run.Last方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        public IRun Create(IComparisonGeneratorsFactory factory)
        {
            var run = new Run(factory);

            var reader = new StreamReader(Stream);
            
            var line = reader.ReadLine();
            var titleInfo = line.Split('|');
            run.CategoryName = titleInfo[0].Substring(1);
            run.AttemptCount = int.Parse(titleInfo[1]);
            TimeSpan totalTime = TimeSpan.Zero;
            while ((line = reader.ReadLine()) != null)
            {
                if (line.Length > 0)
                {
                    var majorSplitInfo = line.Split('|');
                    totalTime += TimeSpanParser.Parse(majorSplitInfo[1]);
                    while (!reader.EndOfStream && reader.Read() == '*')
                    {
                        line = reader.ReadLine();
                        run.AddSegment(line);
                    }
                    var newTime = new Time(run.Last().PersonalBestSplitTime);
                    newTime.GameTime = totalTime;
                    run.Last().PersonalBestSplitTime = newTime;
                }
                else
                {
                    break;
                }
            }

            return run;
        }
开发者ID:Rezura,项目名称:LiveSplit,代码行数:34,代码来源:ShitSplitRunFactory.cs

示例2: Create

        public IRun Create(IComparisonGeneratorsFactory factory)
        {
            var run = new Run(factory);

            var iconsList = new List<Image>();

            var reader = new StreamReader(Stream);

            var oldRunExists = false;

            string line;
            while ((line = reader.ReadLine()) != null)
            {
                if (line.Length > 0)
                {
                    if (line.StartsWith("Title="))
                    {
                        run.CategoryName = line.Substring("Title=".Length);
                    }
                    else if (line.StartsWith("Attempts="))
                    {
                        run.AttemptCount = int.Parse(line.Substring("Attempts=".Length));
                    }
                    else if (line.StartsWith("Offset="))
                    {
                        run.Offset = new TimeSpan(0, 0, 0, 0, -int.Parse(line.Substring("Offset=".Length)));
                    }
                    else if (line.StartsWith("Size="))
                    {
                        //Ignore
                    }
                    else if (line.StartsWith("Icons="))
                    {
                        var iconsString = line.Substring("Icons=".Length);
                        iconsList.Clear();
                        foreach (var iconPath in iconsString.Split(','))
                        {
                            var realIconPath = iconPath.Substring(1, iconPath.Length - 2);
                            Image icon = null;
                            if (realIconPath.Length > 0) 
                            {
                                try
                                {
                                    icon = Image.FromFile(realIconPath);
                                }
                                catch (Exception e)
                                {
                                    Log.Error(e);
                                }
                            }
                            iconsList.Add(icon);
                        }
                    }
                    else //must be a split Kappa
                    {
                        var splitInfo = line.Split(',');
                        Time pbSplitTime = new Time();
                        Time goldTime = new Time();
                        Time oldRunTime = new Time();
                        pbSplitTime.RealTime = TimeSpan.FromSeconds(Convert.ToDouble(splitInfo[2], CultureInfo.InvariantCulture.NumberFormat));
                        goldTime.RealTime = TimeSpan.FromSeconds(Convert.ToDouble(splitInfo[3], CultureInfo.InvariantCulture.NumberFormat));
                        oldRunTime.RealTime = TimeSpan.FromSeconds(Convert.ToDouble(splitInfo[1], CultureInfo.InvariantCulture.NumberFormat));

                        if (pbSplitTime.RealTime == TimeSpan.Zero)
                            pbSplitTime.RealTime = null;

                        if (goldTime.RealTime == TimeSpan.Zero)
                            goldTime.RealTime = null;

                        if (oldRunTime.RealTime == TimeSpan.Zero)
                            oldRunTime.RealTime = null;
                        else
                            oldRunExists = true;
                            
                        run.AddSegment(splitInfo[0], pbSplitTime, goldTime);
                        run.Last().Comparisons["Old Run"] = oldRunTime;
                    }
                }
            }

            if (oldRunExists)
                run.CustomComparisons.Add("Old Run");


            for (var i = 0; i < iconsList.Count; ++i)
            {
                run[i].Icon = iconsList[i];
            }

            return run;
        }
开发者ID:xarrez,项目名称:LiveSplit,代码行数:91,代码来源:WSplitRunFactory.cs


注:本文中的Run.Last方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。