internal bool IsEquiv(clsTSig x) { if (x == null) { return(false); } return(NN == x.NN && DD == x.DD); }
//internal void RemoveTSig(clsBBT bbtlo, clsBBT bbthi) { // //* Validate // if (bbtlo.Bar == bbthi.Bar) return; // if (bbtlo.TicksRemBar != 0) throw new TSigException(); // if (bbthi != null && bbthi.TicksRemBar != 0) throw new TSigException(); // //* create tsig list up to selected area // List<clsTSigBB> list = new List<clsTSigBB>(); // clsTSigBB tsigprev = null; // int index = 0; // for (; index < TSigs.Length; index++) { // clsTSigBB tsig = TSigs[index]; // if (tsig.Tick >= bbtlo.Ticks) break; // list.Add(tsig); // tsigprev = tsig; // } // //* add tsigs after selected area // int ticksdiff = bbthi.Ticks - bbtlo.Ticks; // for (; index < TSigs.Length; index++) { // clsTSigBB tsig = TSigs[index]; // int ticksnext = (index < TSigs.Length - 1) ? TSigs[index + 1].Tick : P.F.MaxBBT.Ticks; // if (ticksnext <= bbthi.Ticks) continue; // int ticksnew = Math.Max(bbtlo.Ticks, tsig.Tick - ticksdiff); // tsig = new clsTSigBB(this, tsig, tsigprev, ticksnew); // list.Add(tsig); // tsigprev = tsig; // } // //* make live // TSigs = list.ToArray(); // CheckTSigs(); //} internal void ChangeTSig(int nn, int dd, clsBBT bbtlo, clsBBT bbthi) { //* Validate if (bbthi == null) { bbthi = P.F.MaxBBT.BBTCopy; } if (bbtlo.Bar == bbthi.Bar) { return; } if (bbtlo.TicksRemBar != 0) { throw new TSigException(); } if (bbthi != null && bbthi.TicksRemBar != 0) { throw new TSigException(); } //* create tsig list up to bbtlo List <clsTSigBB> list = new List <clsTSigBB>(); clsTSigBB tsigprev = null; foreach (clsTSigBB tsig in TSigs) { if (tsig.Tick >= bbtlo.Ticks) { break; } list.Add(tsig); tsigprev = tsig; } //* add new tsig clsTSigBB tsignew; try { tsignew = new clsTSigBB(this, nn, dd, bbtlo.Ticks, tsigprev, adj: false); } catch (TSigException) { return; } list.Add(tsignew); //* terminate or continue bool truncate = bbthi != null && bbthi.Bar == P.F.MaxBBT.Bar; if (bbthi == null || truncate) //truncate { TSigs = list.ToArray(); } else //insert //* set up newmtime { clsMTime newmtime = new clsMTime(TicksPerQNote, TSigs[00].NN, TSigs[0].DD); newmtime.TSigs = list.ToArray(); //up to and incl. new tsig newmtime.CheckTSigs(); //=>TSigException (should not happen) //* filler bar required? clsTSig tsigfiller = null; clsMTime.clsBBT bbttest = new clsBBT(newmtime, bbthi.Ticks); if (bbttest.TicksRemBar > 0) //need a filler bar { tsigfiller = GetFillerTSig(newmtime, bbttest.TicksRemBar); if (tsigfiller == null) { throw new TSigException(); } if (tsigfiller != null) { tsigprev = (list.Count > 0) ? list[list.Count - 1] : null; list.Add(new clsTSigBB(tsigfiller, tsigprev, bbthi.Ticks - tsigfiller.TicksPerBar)); newmtime.TSigs = list.ToArray(); } } //* add tsigs after selected area int index; clsTSigBB tsighi = FindTSigTick(bbthi.Ticks, out index); clsTSigBB newtsighi = new clsTSigBB(newmtime, tsighi, newmtime.TSigs[newmtime.TSigs.Length - 1], bbthi.Ticks); list.Add(newtsighi); for (int i = index + 1; i < TSigs.Length; i++) { clsTSigBB tsignewmtime = new clsTSigBB(newmtime, TSigs[i], list[list.Count - 1], TSigs[i].Tick); list.Add(tsignewmtime); } //* make live newmtime.TSigs = list.ToArray(); TSigs = newmtime.TSigs; } CheckTSigs(); //=>TSigException (should not happen) }
internal bool IsEquivNNDD(clsTSig x) { return(base.IsEquiv(x)); }
internal clsTSigBB(clsMTime mtime, clsTSig tsigbase, clsTSigBB tsigprev, int tick) : this(mtime, tsigbase.NN, tsigbase.DD, tick, tsigprev, adj : false) { }