public void PropagateForwardInclineFromNth0x5dBlock(int nth) { double incline = GetNth0x5dBlock(nth).CurrentIncline; for (int ii = nth + 1; ii < CountOf0x5dBlocks() - 1; ii++) { CommandBlock x5d = GetNth0x5dBlock(ii); x5d.CurrentIncline = incline; x5d.InclineSlider.Value = incline; x5d.Invalidate(); } }
public void AdjustByte8In0x5dBlocks() //byte #8 refers to the number of 0x60 blocks //immediately preceeding each 0x5d block { for (int ii = 0; ii < CountOf0x5dBlocks(); ii++) { CommandBlock x5d = GetNth0x5dBlock(ii); int idx = IndexOfNth0x5dBlock(ii); int num0x60s = CountOf0x60sBelowThisIndex(idx); int byte8 = 0xf7 - 9 * num0x60s; x5d.SetByte(7, (byte)byte8); x5d.Invalidate(); } }
public void PropagateForwardSpeedFromNth0x5dBlock(int nth) { double speed = GetNth0x5dBlock(nth).CurrentSpeed; for (int ii = nth + 1; ii < CountOf0x5dBlocks() - 1; ii++) { CommandBlock x5d = GetNth0x5dBlock(ii); x5d.CurrentSpeed = speed; x5d.CurrentSpeedMetric = speed * 1.609344; x5d.SpeedSlider.Value = speed; x5d.Invalidate(); } }
public void AdjustShowInitialInclineBlock() { CommandBlock b = this.GetNthBlockType(BlockType.ShowInitialIncline, 0); if (b != null) { double initialIncline = this.GetInclineInSteepestBlock(); b.CurrentIncline = initialIncline; b.Invalidate(); } else { MessageBox.Show("Logical program error: NthBlockType.AdjustShowInitalInclineBlock = null", Name); } }
public void AdjustShowInitialSpeedBlock() { CommandBlock b = this.GetNthBlockType(BlockType.ShowInitialSpeed, 0); if (b != null) { double initialSpeed = this.GetSpeedInFastestBlock(); b.CurrentSpeed = initialSpeed; b.CurrentSpeedMetric = initialSpeed * 1.609344; b.Invalidate(); } else { MessageBox.Show("Logical program error: NthBlockType.AdjustShowInitalSpeedBlock = null", Name); } }
public void AdjustInitialSpeedAndInclineHeaderBlock() { CommandBlock b = this.GetNthBlockType(BlockType.SetInitialSpeedAndIncline, 0); if (b != null) { double initialSpeed = this.GetNthBlockType(BlockType.AdjustSpeedAndIncline, 0).CurrentSpeed; double initialIncline = this.GetNthBlockType(BlockType.AdjustSpeedAndIncline, 0).CurrentIncline; b.CurrentSpeed = initialSpeed; b.CurrentSpeedMetric = initialSpeed * 1.609344; b.CurrentIncline = initialIncline; b.Invalidate(); } else { MessageBox.Show("Logical program error: NthBlockType.SetInitialSpeedAndIncline = null", this.Name); } }
public BinaryFit Clone(string bfNameParam, BinaryFit bfToBeReplaced, double speedGradient, double inclineGradient) { BinaryFit bf = new BinaryFit(bfNameParam, workoutLength); int nthX5d = 0; int idx = 0; for (int ii = 0; ii < this.Count; ii++) { if (this.blocks[ii].Type != BlockType.AdjustSpeedAndIncline) { bf.Insert(idx++, this.blocks[ii].Clone()); } else { idx++; CommandBlock newX5d = bfToBeReplaced.GetNth0x5dBlock(nthX5d++); // CommandBlock newX5d = this.blocks[ii].Clone(); // CommandBlock newX5d = bf.GetNth0x5dBlock(nthX5d-1); int indexOfNthX5d = bf.IndexOfNth0x5dBlock(nthX5d - 1); // newX5d = oldX5d; if (this.blocks[ii].IsGraduatable && nthX5d != CountOf0x5dBlocks())//don't increment the final x5d block //since it's used to end the program and set incline to 0 { newX5d.CurrentSpeed = this.blocks[ii].CurrentSpeed + speedGradient; newX5d.CurrentSpeedMetric = newX5d.CurrentSpeed * 1.609344; if (newX5d.CurrentSpeed > this.blocks[ii].SpeedSlider.Maximum) { newX5d.CurrentSpeed = this.blocks[ii].SpeedSlider.Maximum; } if (newX5d.CurrentSpeed < this.blocks[ii].SpeedSlider.Minimum) { newX5d.CurrentSpeed = this.blocks[ii].SpeedSlider.Minimum; } newX5d.CurrentIncline = this.blocks[ii].CurrentIncline + inclineGradient; if (newX5d.CurrentIncline > this.blocks[ii].InclineSlider.Maximum) { newX5d.CurrentIncline = this.blocks[ii].InclineSlider.Maximum; } if (newX5d.CurrentIncline < this.blocks[ii].InclineSlider.Minimum) { newX5d.CurrentIncline = this.blocks[ii].InclineSlider.Minimum; } } else if (!this.blocks[ii].IsGraduatable && nthX5d != CountOf0x5dBlocks()) //just copy the values { newX5d.CurrentSpeed = this.blocks[ii].CurrentSpeed; newX5d.CurrentSpeedMetric = this.blocks[ii].CurrentSpeed * 1.609344; if (newX5d.CurrentSpeed > this.blocks[ii].SpeedSlider.Maximum) { newX5d.CurrentSpeed = this.blocks[ii].SpeedSlider.Maximum; } if (newX5d.CurrentSpeed < this.blocks[ii].SpeedSlider.Minimum) { newX5d.CurrentSpeed = this.blocks[ii].SpeedSlider.Minimum; } newX5d.CurrentIncline = this.blocks[ii].CurrentIncline; if (newX5d.CurrentIncline > this.blocks[ii].InclineSlider.Maximum) { newX5d.CurrentIncline = this.blocks[ii].InclineSlider.Maximum; } if (newX5d.CurrentIncline < this.blocks[ii].InclineSlider.Minimum) { newX5d.CurrentIncline = this.blocks[ii].InclineSlider.Minimum; } } newX5d.Invalidate(); try { bf.blocks[indexOfNthX5d] = newX5d; } catch (Exception e) { MessageBox.Show(e.ToString()); return(bf); } } } return(bf); }