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


C# Run.AddSegment方法代码示例

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


在下文中一共展示了Run.AddSegment方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
     {
         GameName = "",
         CategoryName = ""
     };
     run.AddSegment("");
     return run;
 }
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:10,代码来源:StandardRunFactory.cs

示例3: Create

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

            var reader = new StreamReader(Stream);

            var title = reader.ReadLine();
            run.CategoryName = title;

            var goal = reader.ReadLine();
            //TODO Store goal

            var attemptCount = reader.ReadLine();
            run.AttemptCount = Convert.ToInt32(attemptCount);

            var runsCompleted = reader.ReadLine();
            //TODO Store this somehow

            string segmentLine;
            while ((segmentLine = reader.ReadLine()) != null)
            {
                var splitted = segmentLine.Split(new[] { '-' }, 5);

                var segmentName = (splitted.Length >= 1) ? splitted[0].Replace("\"?\"", "-") : string.Empty;

                var splitTimeString = (splitted.Length >= 2) ? splitted[1] : string.Empty;
                var splitTime = parseTime(splitTimeString);

                var bestSegment = (splitted.Length >= 4) ? splitted[3] : string.Empty;
                var bestSegmentTime = parseTime(bestSegment);

                var iconPath = (splitted.Length >= 5) ? splitted[4] : string.Empty;
                Image icon = null;
                if (!string.IsNullOrWhiteSpace(iconPath))
                {
                    try
                    {
                        icon = Image.FromFile(iconPath);
                    }
                    catch (Exception e)
                    {
                        Log.Error(e);
                    }
                }

                run.AddSegment(segmentName, splitTime, bestSegmentTime, icon);
            }

            return run;
        }
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:50,代码来源:FaceSplitRunFactory.cs

示例4: Create

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

            var reader = new StreamReader(Stream);

            var title = reader.ReadLine();
            run.CategoryName = title;

            var goal = reader.ReadLine();
            //TODO Store goal

            var attemptCount = reader.ReadLine();
            run.AttemptCount = Convert.ToInt32(attemptCount);

            var runsCompleted = reader.ReadLine();
            //TODO Store this somehow

            string segmentLine;
            while ((segmentLine = reader.ReadLine()) != null)
            {
                //Parse the Segment Line from right to left, as dashes in the 
                //title are not escaped. Therefore we can't just split it by
                //the dashes. FaceSplit itself does that, but LiveSplit fixes 
                //that bug.
                var index = segmentLine.LastIndexOf('-');
                var bestSegment = segmentLine.Substring(index + 1);
                var bestSegmentTime = parseTime(bestSegment);

                segmentLine = segmentLine.Substring(0, index);
                index = segmentLine.LastIndexOf('-');
                //Ignore Segment Time

                segmentLine = segmentLine.Substring(0, index);
                index = segmentLine.LastIndexOf('-');
                var splitTimeString = segmentLine.Substring(index + 1);
                var splitTime = parseTime(splitTimeString);

                var segmentName = segmentLine.Substring(0, index);

                run.AddSegment(segmentName, splitTime, bestSegmentTime);
            }

            return run;
        }
开发者ID:gladian00b,项目名称:LiveSplit,代码行数:45,代码来源:FaceSplitRunFactory.cs

示例5: ReadFromLlanfairTextFile

        protected IRun ReadFromLlanfairTextFile(Stream stream, IComparisonGeneratorsFactory factory)
        {
            var run = new Run(factory);

            using (var reader = new StreamReader(stream))
            {
                var line = reader.ReadLine();
                var titleInfo = line.Split(',');
                run.GameName = Unescape(titleInfo[0]);
                run.CategoryName = Unescape(titleInfo[1]);
                run.AttemptCount = int.Parse(Unescape(titleInfo[2]));
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Length > 0)
                    {
                        var splitInfo = line.Split(',');
                        Time pbSplitTime = default(Time);
                        Time goldTime = default(Time);

                        try
                        {
                            pbSplitTime.RealTime = TimeSpan.Parse(Unescape(splitInfo[1]));
                        }
                        catch
                        {
                            try
                            {
                                pbSplitTime.RealTime = TimeSpan.Parse(Unescape("0:" + splitInfo[1]));
                            }
                            catch
                            {
                                pbSplitTime.RealTime = TimeSpan.Parse(Unescape("0:0:" + splitInfo[1]));
                            }
                        }

                        try
                        {
                            goldTime.RealTime = TimeSpan.Parse(Unescape(splitInfo[2]));
                        }
                        catch
                        {
                            try
                            {
                                goldTime.RealTime = TimeSpan.Parse(Unescape("0:" + splitInfo[2]));
                            }
                            catch
                            {
                                goldTime.RealTime = TimeSpan.Parse(Unescape("0:0:" + splitInfo[2]));
                            }
                        }

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

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

                        var realIconPath = "";
                        if (splitInfo.Length > 3)
                            realIconPath = Unescape(splitInfo[3]);
                        Image icon = null;
                        if (realIconPath.Length > 0)
                        {
                            try
                            {
                                using (var imageStream = File.OpenRead(realIconPath))
                                {
                                    icon = Image.FromStream(imageStream);
                                }
                            }
                            catch (Exception e)
                            {
                                Log.Error(e);
                            }
                        }
                        run.AddSegment(Unescape(splitInfo[0]), pbSplitTime, goldTime, icon);
                    }
                }
            }

            return run;
        }
开发者ID:0xwas,项目名称:LiveSplit,代码行数:82,代码来源:LlanfairRunFactory.cs

示例6: Create


//.........这里部分代码省略.........
                        "sp_a2_bts3",
                        "sp_a2_bts4",
                        "sp_a2_bts5",
                        "sp_a2_bts6",
                        "sp_a2_core",
                    }
                },
                {
                    "Chapter 6 - The Fall",
                    new []
                    {
                        "sp_a3_00",
                        "sp_a3_01",
                        "sp_a3_03",
                        "sp_a3_jump_intro",
                        "sp_a3_bomb_flings",
                        "sp_a3_crazy_box",
                        "sp_a3_transition01",
                    }
                },
                {
                    "Chapter 7 - The Reunion",
                    new []
                    {
                        "sp_a3_speed_ramp",
                        "sp_a3_speed_flings",
                        "sp_a3_portal_intro",
                        "sp_a3_end",
                    }
                },
                {
                    "Chapter 8 - The Itch",
                    new []
                    {
                        "sp_a4_intro",
                        "sp_a4_tb_intro",
                        "sp_a4_tb_trust_drop",
                        "sp_a4_tb_wall_button",
                        "sp_a4_tb_polarity",
                        "sp_a4_tb_catch",
                        "sp_a4_stop_the_box",
                        "sp_a4_laser_catapult",
                        "sp_a4_laser_platform",
                        "sp_a4_speed_tb_catch",
                        "sp_a4_jump_polarity",
                    }
                },
                {
                    "Chapter 9 - The Part Where...",
                    new []
                    {
                        "sp_a4_finale1",
                        "sp_a4_finale2",
                        "sp_a4_finale3",
                        "sp_a4_finale4",
                        //"sp_a5_credits",
                    }
                }
            };

            var run = new Run(factory);

            run.GameName = "Portal 2";
            run.CategoryName = "Any%";

            var reader = new StreamReader(Stream);

            var lines = reader
                .ReadToEnd()
                .Split('\n')
                .Select(x => x.Replace("\r", ""))
                .Skip(1)
                .Select(x => x.Split(','))
                .ToArray();

            var aggregateTicks = 0;

            foreach (var chapter in chapters)
            {
                foreach (var map in chapter.Value)
                {
                    //Force it to break, if the splits aren't there
                    lines.First(x => x[0] == map); 

                    foreach (var mapLine in lines.Where(x => x[0] == map))
                    {
                        var mapTicks = int.Parse(mapLine[2], CultureInfo.InvariantCulture)
                                      - int.Parse(mapLine[1], CultureInfo.InvariantCulture);
                        aggregateTicks += mapTicks;
                    }
                }

                var timeSpan = TimeSpan.FromSeconds(aggregateTicks / 60.0);
                var chapterTime = new Time(timeSpan, timeSpan);

                run.AddSegment(chapter.Key, chapterTime);
            }

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

示例7: Create

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

            var reader = new StreamReader(Stream);
            
            var line = reader.ReadLine();
            var titleInfo = line.Split(',');
            //Title Stuff here, do later
            run.CategoryName = Unescape(titleInfo[0]);
            run.AttemptCount = int.Parse(titleInfo[1]);
            while ((line = reader.ReadLine()) != null)
            {
                if (line.Length > 0)
                {
                    var splitInfo = line.Split(',');
                    Time pbSplitTime = new Time();
                    Time goldTime = new Time();

                    try
                    {
                        pbSplitTime.RealTime = TimeSpan.Parse(splitInfo[1]);
                    }
                    catch
                    {
                        try
                        {
                            pbSplitTime.RealTime = TimeSpan.Parse("0:" + splitInfo[1]);
                        }
                        catch
                        {
                            pbSplitTime.RealTime = TimeSpan.Parse("0:0:" + splitInfo[1]);
                        }
                    }

                    try
                    {
                        goldTime.RealTime = TimeSpan.Parse(splitInfo[2]);
                    }
                    catch 
                    {
                        try
                        {
                            goldTime.RealTime = TimeSpan.Parse("0:" + splitInfo[2]);
                        }
                        catch
                        {
                            goldTime.RealTime = TimeSpan.Parse("0:0:" + splitInfo[2]);
                        }
                    }

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

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

                    var realIconPath = "";
                    if (splitInfo.Length > 3)
                        realIconPath = Unescape(splitInfo[3]);
                    Image icon = null;
                    if (realIconPath.Length > 0)
                    {
                        try
                        {
                            using (var stream = File.OpenRead(realIconPath))
                            {
                                icon = Image.FromStream(stream);
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Error(e);
                        }
                    }
                    run.AddSegment(Unescape(splitInfo[0]), pbSplitTime, goldTime, icon);
                }
                else
                {
                    break;
                }
            }

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

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