Example #1
0
 public ResultStatus CreateParametricData(
     Holds holds,
     Holds_Request request,
     out Holds_Result result)
 {
     return(this.CreateParametricData(holds, (Holds_Parameters)null, request, out result));
 }
Example #2
0
        public bool CurrentlyAllowsFallSpring(UnitMove move)
        {
            // does not check pre-conditions like "is the proper unit in the edge.source"
            // we rely on the UnitMove generator to check these and only generate valid possible moves
            // this is only checking the given move is valid based on all other moves in this set

            if (move.IsHold)
            {
                return(!TargetTerritories.Contains(move.Edge.Source.Territory));
            }
            else if (move.IsDisband)
            {
                bool otherPowerMovingIn = this.Where(u => u.Unit.Power != move.Unit.Power)
                                          .Select(u => u.Edge.Target?.Territory)
                                          .Contains(move.Edge.Source.Territory);
                IEnumerable <MapNode> adjacentMapNodes = move.Unit.MyMap.AdjacentInEdges(move.Edge.Source).Select(e => e.Source);
                bool otherPowerHoldingAdjacent         = Holds.Where(u => u.Unit.Power != move.Unit.Power)
                                                         .Select(u => u.Edge.Source)
                                                         .Intersect(adjacentMapNodes)
                                                         .Any();
                return(otherPowerHoldingAdjacent && otherPowerMovingIn);
            }
            else if (move.IsConvoy)
            {
                bool necessaryFleetsHolding = move.ConvoyRoute.All(mn => Holds.Select(um => um.Edge.Target).Contains(mn));
                bool targetTerritoryEmpty   = !TargetTerritories.Contains(move.Edge.Target.Territory);
                return(necessaryFleetsHolding && targetTerritoryEmpty);
            }
            else
            {
                bool targetTerritoryEmpty = !TargetTerritories.Contains(move.Edge.Target.Territory);
                bool noSwap = !this.Any(um => um.Edge.Source.Territory == move.Edge.Target.Territory && um.Edge.Target.Territory == move.Edge.Source.Territory);
                return(targetTerritoryEmpty && noSwap);
            }
        }
Example #3
0
 public ResultStatus LoadESigDetails(
     Holds holds,
     Holds_Request request,
     out Holds_Result result)
 {
     return(this.LoadESigDetails(holds, (Holds_LoadESigDetails_Parameters)null, request, out result));
 }
Example #4
0
        public void PlaceHold(int assetId, int libraryCardId)
        {
            var now = DateTime.Now;

            var asset = _context.LibraryAsset
                        .Include(a => a.Status)
                        .FirstOrDefault(a => a.Id == assetId);

            var card = _context.LibraryCards
                       .First(a => a.Id == libraryCardId);

            _context.Update(asset);

            if (asset.Status.Name == "Available")
            {
                asset.Status = _context.Status.FirstOrDefault(a => a.Name == "On Hold");
            }

            var hold = new Holds
            {
                HoldPlaced   = now,
                LibraryAsset = asset,
                LibraryCard  = card
            };

            _context.Add(hold);
            _context.SaveChanges();
        }
Example #5
0
        private static decimal calculateResult(DateTime endTime, History quickDay, Holds holds)
        {
            decimal result    = holds.cash;
            int     nullCount = 0;

            foreach (var holdStock in holds.holds)
            {
                var day = quickDay.getDay(holdStock.stockName, endTime);
                if (day == null)
                {
                    nullCount++;
                    continue;;
                }
                result += day.adjClose * holdStock.amount;
            }
            ResultContainer.Instance.addOutput(result.ToString());
            if (nullCount * 2 > holds.holds.Count)
            {
                return(-1);
            }
            else
            {
                return(result);
            }
        }
Example #6
0
        public ImageBrush getMyImage(Holds holds)
        {
            string holder = "";

            if (holds == Holds.Ball)
            {
                holder = "Ball";
            }
            else if (holds == Holds.Blocker)
            {
                holder = "Blocker";
            }
            else if (holds == Holds.Food)
            {
                holder = "Food";
            }
            else
            {
                //return null;
                holder = "Empty";
            }

            ImageBrush bi = new ImageBrush();

            bi.ImageSource = new BitmapImage(new Uri(@"../Images/" + holder + ".png", UriKind.Relative));
            return(bi);
        }
Example #7
0
        public void test3()
        {
            var h = new Holds <int>();

            h.v = 500;
            Contract.Assert(h.v == 500);
        }
Example #8
0
 public ResultStatus ProcessComputation(
     Holds holds,
     Holds_Request request,
     out Holds_Result result)
 {
     return(this.ProcessComputation(holds, (Holds_Parameters)null, request, out result));
 }
Example #9
0
        private static void sell(DateTime time, Holds holds, Operation operation, decimal price)
        {
            Hold    hold = holds.holds.Single(c => c.stockName == operation.StockName);
            decimal soldAmount;

            if (hold.amount > operation.amount)
            {
                soldAmount  = operation.amount;
                hold.amount = hold.amount - operation.amount;
            }
            else
            {
                soldAmount  = hold.amount;
                hold.amount = 0;
                holds.holds.Remove(hold);
            }

            decimal sellCash = soldAmount * price;
            decimal fee      = calculateSellFee(soldAmount, sellCash);

            ResultContainer.Instance.addTrade(new Trade()
            {
                name           = hold.stockName,
                date           = time,
                type           = TradeType.Sell,
                amount         = soldAmount,
                price          = price,
                cash           = sellCash,
                fee            = fee,
                benefitPercent = (price - hold.buyPrice) / hold.buyPrice
            });
            holds.cash += sellCash - fee;
        }
Example #10
0
 /// <summary>
 /// Holds the specified amount.
 /// </summary>
 /// <param name="amount">The amount.</param>
 /// <param name="description">The description.</param>
 /// <param name="source_uri">The source_uri.</param>
 /// <param name="meta">The meta.</param>
 /// <returns>Hold.</returns>
 public Hold Hold(int amount,
                  string description,
                  string source_uri,
                  IDictionary <string, string> meta)
 {
     return(Holds.Create(amount, description, source_uri, meta));
 }
Example #11
0
        public void PlaceHold(int assetId, int libraryCardId)
        {
            var now = DateTime.Now;
            //locating asset from storage
            var asset = _context.LibraryAssets
                        .Include(a => a.Status)
                        .FirstOrDefault(a => a.Id == assetId);

            //locating the library card in storage
            var card = _context.LibraryCards.FirstOrDefault(c => c.Id == libraryCardId);

            if (asset.Status.Name == "Available")
            {
                UpdateAssetStatus(assetId, "On Hold");
            }
            var hold = new Holds
            {
                HoldPlaced   = now,
                LibraryAsset = asset,
                LibraryCard  = card
            };

            _context.Add(hold);
            _context.SaveChanges();
        }
Example #12
0
 public ResultStatus GetActions(
     Holds holds,
     Holds_Request request,
     out Holds_Result result)
 {
     return(this.GetActions(holds, (Holds_Parameters)null, request, out result));
 }
Example #13
0
        public Operations calcaulate(History history, DateTime date, Holds holds)
        {
            Operations operations = new Operations();

            foreach (Hold hold in holds.holds)
            {
                var day = history.getDay(hold.stockName, date);
                if (day == null)
                {
                    continue;
                }
                if (hold.buyTime.AddDays(20) > date)
                {
                    continue;
                }
                operations.operations.Add(sell(hold));
            }


            foreach (var stockName in history.stocks.Keys)
            {
                DayResult currentDay = history.getDay(stockName, date);
                if (currentDay == null || currentDay.volume == 0 || currentDay.volume * currentDay.adjClose < 100000000)
                {
                    continue;
                }
                DateTime currentDate = currentDay.date;
                operations.operations.Add(buy(stockName, currentDay.adjClose, holds.cash));
            }
            return(operations);
        }
        public void PlaceHold(int assetId, int LibraryCardId)
        {
            var now = DateTime.Now;

            var asset = _context.LibraryAssets
                        .Include(s => s.Status)
                        .FirstOrDefault(a => a.Id == assetId);

            var librarycard = _context.LibraryCards
                              .FirstOrDefault(l => l.Id == LibraryCardId);

            if (asset.Status.Name == "Available")
            {
                UpdateAssetStatus(assetId, "On Hold");
            }

            var hold = new Holds
            {
                HoldPlaced   = now,
                LibraryAsset = asset,
                LibraryCard  = librarycard
            };

            _context.Add(hold);
            _context.SaveChanges();
        }
Example #15
0
        public void test4()
        {
            var h = new Holds <int>();

            h.v = 2;
            Contract.Assert(h.v == 2);
            Contract.Assert(h.test() == 2);
        }
Example #16
0
 public Block(Holds hold, Side sid, Position pos, int x, int y)
 {
     this.x        = x;
     this.y        = y;
     this.holds    = hold;
     this.side     = sid;
     this.position = pos;
 }
Example #17
0
 public Block(Side sid, Position pos, int x, int y)
 {
     this.x        = x;
     this.y        = y;
     this.holds    = Gravity.Holds.None;
     this.side     = sid;
     this.position = pos;
 }
Example #18
0
        public void test6()
        {
            var h = new Holds <Holds <int> >();

            h.v   = new Holds <int>();
            h.v.v = 16;

            Contract.Assert(h.test().test() == 16);
        }
        // Used for v0.1
        void CommitHold(SlideCollection col)
        {
            Hold        tempHold  = new Hold(0, 0, 0, Side.NotSet);
            List <Note> tempNotes = new List <Note>();

            for (int i = 0; i < col.Notes.Count; i++)
            {
                var    parsed  = col.Notes[i].Item1;
                double noteSub = 1.0 / parsed.Notes.Count;
                var    j       = col.Notes[i].Item2;
                Side   side    = parsed.NoteClass == 2 ? Side.Left : Side.Right;

                if (i == 0)
                {
                    tempHold = new Hold(4 * (parsed.Measure + j * noteSub), parsed.LaneIndex, parsed.Notes[j].Item2, side);
                }
                else
                {
                    switch (parsed.Notes[j].Item1)
                    {
                    case 1:     // Shouldn't happen because it was already added above
                        throw new Exception("Unexpected start note.");

                    case 2:     // End a hold note with no shuffle
                    case 4:     // Add a midpoint with no shuffle
                        tempNotes.Add(new Note(4 * (parsed.Measure + j * noteSub), parsed.LaneIndex, parsed.Notes[j].Item2, side)
                        {
                            Type = NoteType.Hold
                        });
                        break;

                    case 3:     // End a hold note with a shuffle
                    case 5:     // Add a midpoint with a shuffle
                        tempNotes.Add(new Note(4 * (parsed.Measure + j * noteSub), parsed.LaneIndex, parsed.Notes[j].Item2, side)
                        {
                            Type = NoteType.Shuffle
                        });
                        break;
                    }
                }
            }
            tempNotes.Sort((x, y) => x.BeatLocation.CompareTo(y.BeatLocation));
            foreach (var note in tempNotes)
            {
                tempHold.AddNote(note);
            }

            Holds.Add(tempHold);
        }
Example #20
0
 public ResultStatus GetEnvironment(
     Holds cdo,
     Holds_Request request,
     out Holds_Result result)
 {
     result = (Holds_Result)null;
     try
     {
         return(((IHoldsService)this._Channel).GetEnvironment(this._UserProfile, cdo, request, out result));
     }
     catch (Exception ex)
     {
         return(this.OnThrowException(ex));
     }
 }
Example #21
0
        /// <summary>
        /// Update the mouse manager.
        /// </summary>
        public override void Update(bool isActive)
        {
            //clear out the taps & touches
            Clicks.Clear();
            Highlights.Clear();
            Drags.Clear();
            Drops.Clear();
            Flicks.Clear();
            Pinches.Clear();
            Holds.Clear();

            if (null != Pinch)
            {
                //reset the pinch delta
                Pinch.Delta = 0f;
            }

            if (isActive && IsEnabled)
            {
                TouchCollection = TouchPanel.GetState();

                //get the new taps & touches
                GetGestures();
                GetTouches();
            }

            //Add the pinch event if there is an ongoing gesture
            if (null != Pinch)
            {
                if (Pinch.Finished)
                {
                    Pinches.Add(new PinchEventArgs(Pinch.First, Pinch.Second, Pinch.Delta)
                    {
                        Release = true
                    });
                    Pinch = null;
                }
                else
                {
                    Pinches.Add(new PinchEventArgs(Pinch.First, Pinch.Second, Pinch.Delta));
                }
            }
        }
Example #22
0
        public ResultStatus AddDataTransaction(Holds cdo)
        {
            this.OnBeforeCall(nameof(AddDataTransaction), (DCObject)cdo, (Parameters)null, (Request)null);
            ResultStatus res;

            try
            {
                res = !this._IsTransactionOpened ? this.GetAddDataTransactionException() : this.AddMethod((Method) new HoldsMethod(cdo, HoldsMethods.AddDataTransaction, (Holds_Parameters)null));
            }
            catch (Exception ex)
            {
                res = this.OnThrowException(ex);
            }
            if (res.IsSuccess)
            {
                Result result;
                this.OnAfterCall(nameof(AddDataTransaction), res, (DCObject)cdo, (Parameters)null, (Request)null, result);
            }
            return(res);
        }
Example #23
0
        public void Plachold(int assetId, int LibraryCardId)
        {
            var now = DateTime.Now;

            var asset = _context.LibraryAssets
                        .FirstOrDefault(a => a.Id == assetId);

            var card = _context.LibraryCards
                       .FirstOrDefault(c => c.Id == LibraryCardId);

            var hold = new Holds
            {
                HoldPlaced   = now,
                LibraryAsset = asset,
                LibraryCard  = card
            };

            _context.Add(hold);

            _context.SaveChanges();
        }
Example #24
0
        public static async Task run()
        {
            ResultContainer.Instance.addOutput("开始");
            //DateTime startTime = new DateTime(1990, 12, 19);
            //DateTime endTime = new DateTime(2016, 8, 1);
            DateTime startTime = new DateTime(2006, 1, 1);
            DateTime endTime   = new DateTime(2016, 1, 1);
            History  quickDay  = new History();
            await quickDay.load();

            Holds holds = new Holds();

            holds.cash = 100000;
            DateTime lastDay = startTime.AddDays(-1);

            while (startTime < endTime)
            {
                quickDay.SetLimitDate(startTime);
                Operations operations = new ZhihuAlgorithm().calcaulate(quickDay, startTime, holds);

                Exchange.ExchangeExecutor.Match(quickDay, startTime, operations, holds);
                if (startTime.Year != lastDay.Year || startTime.Month != lastDay.Month)
                {
                    ResultContainer.Instance.addOutput(startTime.ToString());
                    decimal   currentMoney = calculateResult(startTime, quickDay, holds);
                    DayResult marketResult = quickDay.market.Value.SingleOrDefault(c => c.Key == startTime).Value;
                    if (currentMoney != -1 && marketResult != null)
                    {
                        lastDay = startTime;
                        ResultContainer.Instance.addMonthResult(new MonthResult {
                            year = lastDay.Year, month = lastDay.Month, money = currentMoney, market = marketResult.adjClose
                        });
                    }
                }
                startTime = startTime.AddDays(1);
            }
            //减3是因为截止到7月最后一天,+1就到了8月一日,而7月底的最后两天是假期
            calculateResult(endTime, quickDay, holds);
            ResultContainer.Instance.addOutput("全部结束");
        }
Example #25
0
        public ResultStatus ExecuteTransaction(
            Holds cdo,
            Holds_Request request,
            out Holds_Result result)
        {
            result = (Holds_Result)null;
            this.OnBeforeCall(nameof(ExecuteTransaction), (DCObject)cdo, (Parameters)null, (Request)request);
            ResultStatus res;

            try
            {
                res = !this._IsTransactionOpened ? ((IHoldsService)this._Channel).ExecuteTransaction(this._UserProfile, cdo, request, out result) : this.AddMethod((Method) new HoldsMethod(cdo, HoldsMethods.ExecuteTransaction, (Holds_Parameters)null));
            }
            catch (Exception ex)
            {
                res = this.OnThrowException(ex);
            }
            if (res.IsSuccess)
            {
                this.OnAfterCall(nameof(ExecuteTransaction), res, (DCObject)cdo, (Parameters)null, (Request)request, (Result)result);
            }
            return(res);
        }
Example #26
0
        private static void buy(DateTime time, Holds holds, Operation operation, decimal price)
        {
            if (operation.amount % 100 != 0)
            {
                return;
            }
            decimal stockCost = price * operation.amount;
            decimal fee       = calculateBuyFee(operation, stockCost);
            decimal totalCost = stockCost + fee;

            if (holds.cash < totalCost)
            {
                return;
            }
            holds.cash = holds.cash - totalCost;
            Hold currentHold = holds.holds.SingleOrDefault(c => c.stockName == operation.StockName);

            if (currentHold == null)
            {
                currentHold           = new Hold();
                currentHold.stockName = operation.StockName;
                holds.holds.Add(currentHold);
            }
            currentHold.amount  += operation.amount;
            currentHold.buyTime  = time;
            currentHold.buyPrice = price;
            ResultContainer.Instance.addTrade(new Trade()
            {
                name   = currentHold.stockName,
                date   = time,
                type   = TradeType.Buy,
                amount = operation.amount,
                price  = price,
                fee    = fee,
                cash   = stockCost
            });
        }
Example #27
0
        public ResultStatus GetActions(
            Holds holds,
            Holds_Parameters parameters,
            Holds_Request request,
            out Holds_Result result)
        {
            result = (Holds_Result)null;
            this.OnBeforeCall(nameof(GetActions), (DCObject)holds, (Parameters)parameters, (Request)request);
            ResultStatus res;

            try
            {
                res = !this._IsTransactionOpened ? ((IHoldsService)this._Channel).GetActions(this._UserProfile, holds, parameters, request, out result) : this.AddMethod((Method) new HoldsMethod(holds, HoldsMethods.GetActions, parameters));
            }
            catch (Exception ex)
            {
                res = this.OnThrowException(ex);
            }
            if (res.IsSuccess)
            {
                this.OnAfterCall(nameof(GetActions), res, (DCObject)holds, (Parameters)parameters, (Request)request, (Result)result);
            }
            return(res);
        }
Example #28
0
        public void placeHold(int assetId, int libraryCardId)
        {
            var timeNow = DateTime.Now;
            var asset   = _context.libraryAssets
                          .Include(a => a.Status)
                          .FirstOrDefault(a => a.id == assetId);
            var card = _context.libraryCards
                       .FirstOrDefault(c => c.id == libraryCardId);

            if (asset.Status.name == "Available")
            {
                updateAsset(assetId, "On Hold");
            }

            var hold = new Holds
            {
                HoldPlaced   = timeNow,
                LibraryAsset = asset,
                LibraryCard  = card,
            };

            _context.Add(hold);
            _context.SaveChanges();
        }
        public SongMetadata ParseFile()
        {
            string fileName = Metadata.ChartFullPath;

            // Used for v0.1
            Dictionary <int, SlideCollection> tempSlideDict = new Dictionary <int, SlideCollection>();
            // Used for v1.0
            Dictionary <int, Hold> tempHoldDict = new Dictionary <int, Hold>();

            // Temp parsing variables
            int    beatsPerMeasure = 4; // Ultimately this should be tied to time signature
            int    measure         = -1;
            double subDiv;
            int    noteClass, lane, width, id, endLane, endWidth;
            bool   inNoteData = false;

            try
            {
                using (StreamReader sr = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read)))
                {
                    while (!sr.EndOfStream)
                    {
                        string line = sr.ReadLine();

                        // Whatever metadata stuff isn't covered in SongMetadata

                        if (Metadata.Version.Major == 1 && Metadata.Version.Minor == 0)
                        {
                            // Look for BPM change tags
                            if (Regex.Match(line, "^(#BPMC)").Success)
                            {
                                var bpmSplit = Regex.Split(line, @"[(#BPMC)\s:.]+").Where(s => !String.IsNullOrEmpty(s));
                                if (bpmSplit.Count() == 3)
                                {
                                    id      = bpmSplit.ElementAt(0).ParseBase36();
                                    measure = int.Parse(bpmSplit.ElementAt(1));
                                    subDiv  = double.Parse(bpmSplit.ElementAt(2)) / 192.0;

                                    Metadata.BpmEvents.Add(new BpmChangeEvent(Metadata.BpmIndex[id], beatsPerMeasure * (measure + subDiv)));
                                }
                                else
                                {
                                    Console.WriteLine("Failed to parse BPM Change: {0}", line);
                                }
                            }
                            else
                            {
                                // Must have seen the "#NOTES" tag before parsing notes
                                if (Regex.Match(line, "^(#NOTES)").Success)
                                {
                                    inNoteData = true;
                                }
                                else if (Regex.Match(line, "^(#ENDNOTES)").Success)
                                {
                                    inNoteData = false;
                                }

                                if (inNoteData)
                                {
                                    if (Regex.Match(line, "^[0-9]{3}$").Success)
                                    {
                                        measure = int.Parse(line);
                                    }
                                    else if (Regex.Match(line, "^[0-9]{3}:").Success)
                                    {
                                        var timeSplit = Regex.Split(line, ":").Where(s => !String.IsNullOrEmpty(s));
                                        if (timeSplit.Count() == 2) // It should only be 2
                                        {
                                            subDiv = double.Parse(timeSplit.ElementAt(0)) / 192.0;
                                            var noteSplit = Regex.Split(timeSplit.ElementAt(1), ",").Where(s => !String.IsNullOrEmpty(s));
                                            foreach (var note in noteSplit)
                                            {
                                                if (Regex.Match(note, "^[2-3]{1}").Success) // Motions
                                                {
                                                    noteClass = note[0].ToString().ParseBase36();
                                                    Motions.Add(new Note(beatsPerMeasure * (measure + subDiv), 0, 16, noteClass == 2 ? Motion.Up : Motion.Down));
                                                }
                                                else if (Regex.Match(note, "^[0-1]{1}[0-9a-fA-F]{2}$").Success) // Any step
                                                {
                                                    noteClass = note[0].ToString().ParseBase36();
                                                    lane      = note[1].ToString().ParseBase36();
                                                    width     = note[2].ToString().ParseBase36() + 1;

                                                    Steps.Add(new Note(beatsPerMeasure * (measure + subDiv), lane, width, noteClass == 0 ? Side.Left : Side.Right));
                                                }
                                                else if (Regex.Match(note, "^[4-9a-bA-B]{1}[0-9a-fA-F]{2}[0-9a-zA-Z]{1}").Success) // Hold/Slides
                                                {
                                                    noteClass = note[0].ToString().ParseBase36();
                                                    id        = note[1].ToString().ParseBase36();
                                                    lane      = note[2].ToString().ParseBase36();
                                                    width     = note[3].ToString().ParseBase36() + 1;

                                                    switch (noteClass)
                                                    {
                                                    case 4:     // Left hold start
                                                    case 5:     // Right hold start
                                                                // Check to see if a hold is already active-- if so, commit it and start a new one
                                                        if (tempHoldDict.ContainsKey(id))
                                                        {
                                                            CommitHold(tempHoldDict[id]);
                                                            tempHoldDict.Remove(id);
                                                        }
                                                        // Create the new note
                                                        tempHoldDict.Add(id, new Hold(beatsPerMeasure * (measure + subDiv), lane, width, noteClass == 4 ? Side.Left : Side.Right));
                                                        break;

                                                    case 6:     // Slide waypoint
                                                        // Check to see this slide is still active
                                                        if (tempHoldDict.ContainsKey(id))
                                                        {
                                                            tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width)
                                                            {
                                                                Type = NoteType.Hold
                                                            });
                                                        }
                                                        else
                                                        {
                                                            Console.WriteLine("Corresponding hold/slide for this waypoint is not active. Check file. Line: {0}", line);
                                                        }
                                                        break;

                                                    case 7:     // Hold / Slide end
                                                        // Check to see this hold/slide is still active
                                                        if (tempHoldDict.ContainsKey(id))
                                                        {
                                                            tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width)
                                                            {
                                                                Type = NoteType.Hold
                                                            });
                                                            CommitHold(tempHoldDict[id]);
                                                            tempHoldDict.Remove(id);
                                                        }
                                                        else
                                                        {
                                                            Console.WriteLine("Corresponding hold/slide for this endpoint is not active. Check file. Line: {0}", line);
                                                        }
                                                        break;

                                                    case 8:     // Simple Shuffle Waypoint
                                                        // Check to see this hold/slide is still active
                                                        if (tempHoldDict.ContainsKey(id))
                                                        {
                                                            tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width)
                                                            {
                                                                Type = NoteType.Shuffle
                                                            });
                                                        }
                                                        else
                                                        {
                                                            Console.WriteLine("Corresponding hold/slide for this shuffle is not active. Check file. Line: {0}", line);
                                                        }
                                                        break;

                                                    case 9:     // Complex Shuffle waypoint
                                                        // Check to see this hold/slide is still active
                                                        if (tempHoldDict.ContainsKey(id))
                                                        {
                                                            // Check to see if there's enough parameters
                                                            if (note.Length == 6)
                                                            {
                                                                endLane  = note[4].ToString().ParseBase36();
                                                                endWidth = note[5].ToString().ParseBase36() + 1;
                                                                tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width, endLane, endWidth)
                                                                {
                                                                    Type = NoteType.Shuffle
                                                                });
                                                            }
                                                            else
                                                            {
                                                                Console.WriteLine("Not enough parameters for this complex shuffle. Line: {0}", line);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            Console.WriteLine("Corresponding hold/slide for this shuffle is not active. Check file. Line: {0}", line);
                                                        }
                                                        break;

                                                    case 10:        // Simple Shuffle End
                                                        // Check to see this hold/slide is still active
                                                        if (tempHoldDict.ContainsKey(id))
                                                        {
                                                            tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width)
                                                            {
                                                                Type = NoteType.Shuffle
                                                            });
                                                            CommitHold(tempHoldDict[id]);
                                                            tempHoldDict.Remove(id);
                                                        }
                                                        else
                                                        {
                                                            Console.WriteLine("Corresponding hold/slide for this shuffle end is not active. Check file. Line: {0}", line);
                                                        }
                                                        break;

                                                    case 11:        // Complex shuffle end
                                                        // Check to see this hold/slide is still active
                                                        if (tempHoldDict.ContainsKey(id))
                                                        {
                                                            // Check to see if there's enough parameters
                                                            if (note.Length == 6)
                                                            {
                                                                endLane  = note[4].ToString().ParseBase36();
                                                                endWidth = note[5].ToString().ParseBase36() + 1;
                                                                tempHoldDict[id].AddNote(new Note(beatsPerMeasure * (measure + subDiv), lane, width, endLane, endWidth)
                                                                {
                                                                    Type = NoteType.Shuffle
                                                                });
                                                                CommitHold(tempHoldDict[id]);
                                                                tempHoldDict.Remove(id);
                                                            }
                                                            else
                                                            {
                                                                Console.WriteLine("Not enough parameters for this complex shuffle end. Line: {0}", line);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            Console.WriteLine("Corresponding hold/slide for this shuffle end is not active. Check file. Line: {0}", line);
                                                        }
                                                        break;

                                                    default:
                                                        break;
                                                    }
                                                }
                                                else
                                                {
                                                    Console.WriteLine("Failed to parse note: {0}", line);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            Console.WriteLine("Empty notestring found: {0}", line);
                                        }
                                    }
                                }
                            }
                        }
                        else if (Metadata.Version.Major == 0)
                        {
                            // Regex match for standard steps
                            if (Regex.Match(line, "[#][0-9]{3}[1]").Success)
                            {
                                var    parsed  = ParseLine(line);
                                double noteSub = 1.0 / parsed.Notes.Count;
                                for (int i = 0; i < parsed.Notes.Count; i++)
                                {
                                    switch (parsed.Notes[i].Item1)
                                    {
                                    case 1:     // Left Step
                                        Steps.Add(new Note(4 * (parsed.Measure + i * noteSub), parsed.LaneIndex, parsed.Notes[i].Item2, Side.Left));
                                        break;

                                    case 2:     // Right Step
                                        Steps.Add(new Note(4 * (parsed.Measure + i * noteSub), parsed.LaneIndex, parsed.Notes[i].Item2, Side.Right));
                                        break;

                                    case 3:     // Motion Up
                                        Motions.Add(new Note(4 * (parsed.Measure + i * noteSub), 0, 16, Motion.Up));
                                        break;

                                    case 4:     // Motion Down
                                        Motions.Add(new Note(4 * (parsed.Measure + i * noteSub), 0, 16, Motion.Down));
                                        break;

                                    default:        // Rest notes / spacers (0) are ignored
                                        break;
                                    }
                                }
                            }
                            // Regex match for hold/slides
                            else if (Regex.IsMatch(line, "[#][0-9]{3}[2-3]"))
                            {
                                var    parsed  = ParseLine(line);
                                double noteSub = 1.0 / parsed.Notes.Count;
                                for (int i = 0; i < parsed.Notes.Count; i++)
                                {
                                    Side side = parsed.NoteClass == 2 ? Side.Left : Side.Right;

                                    switch (parsed.Notes[i].Item1)
                                    {
                                    case 1:     // Start a new note
                                                // Check to see if a hold is already active-- if so, commit it and start a new one
                                        if (tempSlideDict.ContainsKey(parsed.NoteIdentifier))
                                        {
                                            CommitHold(tempSlideDict[parsed.NoteIdentifier]);
                                            tempSlideDict.Remove(parsed.NoteIdentifier);
                                        }
                                        // Create a collection
                                        tempSlideDict.Add(parsed.NoteIdentifier, new SlideCollection());
                                        // Add this note to it
                                        tempSlideDict[parsed.NoteIdentifier].Notes.Add(new Tuple <NoteParse, int>(parsed, i));
                                        break;

                                    case 2:     // End a hold note with no shuffle
                                    case 3:     // End a hold note with a shuffle
                                    case 4:     // Add a midpoint with no shuffle
                                    case 5:     // Add a midpoint with a shuffle
                                        if (!tempSlideDict.ContainsKey(parsed.NoteIdentifier))
                                        {
                                            tempSlideDict.Add(parsed.NoteIdentifier, new SlideCollection());        // Add a new one (it will f**k up shit if this happens)
                                        }
                                        // Add this note to it
                                        tempSlideDict[parsed.NoteIdentifier].Notes.Add(new Tuple <NoteParse, int>(parsed, i));
                                        break;

                                    default:        // Rest notes / spacers (0) are ignored
                                        break;
                                    }
                                }
                            }
                            // Parse BPM changes
                            else if (Regex.IsMatch(line, "[#][0-9]{3}(08:)"))
                            {
                                //var parsed = ParseLine(line);
                                var split  = line.Replace(" ", string.Empty).Split(':');
                                var parsed = new NoteParse();
                                parsed.Measure = Convert.ToDouble(line.Substring(1, 3));
                                parsed.Notes   = new List <Tuple <int, int> >();
                                for (int i = 0; i < split[1].Length; i += 2)
                                {
                                    string idStr = split[1][i].ToString() + split[1][i + 1].ToString();
                                    parsed.Notes.Add(new Tuple <int, int>(idStr.ParseBase36(), 0));
                                }

                                double noteSub = 1.0 / parsed.Notes.Count;
                                for (int i = 0; i < parsed.Notes.Count; i++)
                                {
                                    if (parsed.Notes[i].Item1 == 0)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        Metadata.BpmEvents.Add(new BpmChangeEvent(Metadata.BpmIndex[parsed.Notes[i].Item1], 4 * (parsed.Measure + i * noteSub)));
                                    }
                                }
                            }
                        }
                    }
                }

                // Close out any remaining hold notes
                foreach (var tempHold in tempSlideDict)
                {
                    CommitHold(tempHold.Value);
                }
                // Sort holds for drawing later
                Holds = Holds.OrderBy(x => x.StartNote.BeatLocation).ToList();

                // Add Beat Markers
                var    noteLast   = Steps.Count > 0 ? Steps.Max(x => x.BeatLocation) : 0;
                var    holdLast   = Holds.Count > 0 ? Holds.Max(x => x.Notes.Max(y => y.BeatLocation)) : 0;
                var    motionLast = Motions.Count > 0 ? Motions.Max(x => x.BeatLocation) : 0;
                double lastBeat   = Math.Max(noteLast, holdLast);
                lastBeat = Math.Ceiling(Math.Max(lastBeat, motionLast));
                for (int i = 0; i <= (int)lastBeat; i += 4)
                {
                    Markers.Add(new BeatMarker(i));
                }

                TotalNotes += Steps.Count();
                TotalNotes += Holds.Count();
                foreach (var hold in Holds)
                {
                    TotalNotes += hold.GradePoints.Count;   // Additional beat counters for holds/slides
                    TotalNotes += hold.Notes.Count(x => x.Type == NoteType.Shuffle);
                }
                TotalNotes += Motions.Count();
            }
            catch (Exception e)
            {
                StyleStarLogger.WriteEntry("Exception in NoteCollection.ParseFile() => Input: " + fileName + ", Exception: " + e.Message + ", Stack Trace: " + e.StackTrace + (e.InnerException != null ? ", Inner Exception: " + e.InnerException.Message : ""));
            }

            return(Metadata);
        }
 // Used for v1.0
 private void CommitHold(Hold hold)
 {
     Holds.Add(hold);
 }