private void Population_Variation_Button_Click(object sender, RoutedEventArgs e) { try { _mainPage.SetMainText(Variance(true).ToString()); } catch { _mainPage.initCalcError(); } // reset the equals key focus when we change view CalcHelpers.equalsKeyFocus(_mainPage.currentView.GetEqualsKey()); }
public void ChangeBitness(CalcViews.Programmer.ProgrammerCalcBits prevBits) { if (!_mainPage.isProgrammer()) { _mainPage.initCalcError(); return; } string dec = Get(); string bin = CalcViews.Programmer.dec2Long(dec, 2); // next if the user has chosen a specific bitness if ((currentView as ProgrammerView).currentBits == CalcViews.Programmer.ProgrammerCalcBits.Qword) { // ASSUME we're comming from a lower order bit dec = changeBitnessHelper(bin, dec, LONG, (currentView as ProgrammerView).currentBits, prevBits); } else if ((currentView as ProgrammerView).currentBits == CalcViews.Programmer.ProgrammerCalcBits.Dword) { // if we're going down in bitness if (bin.Length > INT) { bin = bin.Substring(bin.Length - INT); dec = CalcHelpers.bin2Dec(bin, (currentView as ProgrammerView).currentBits); } // if we're going up in bitness else { dec = changeBitnessHelper(bin, dec, INT, (currentView as ProgrammerView).currentBits, prevBits); } } else if ((currentView as ProgrammerView).currentBits == CalcViews.Programmer.ProgrammerCalcBits.Word) { // if we're going down in bitness if (bin.Length > SHORT) { bin = bin.Substring(bin.Length - SHORT); dec = CalcHelpers.bin2Dec(bin, (currentView as ProgrammerView).currentBits); } // if we're going up in bitness else { dec = changeBitnessHelper(bin, dec, SHORT, (currentView as ProgrammerView).currentBits, prevBits); } } else if ((currentView as ProgrammerView).currentBits == CalcViews.Programmer.ProgrammerCalcBits.Byte) { // if we're going down in bitness if (bin.Length > BYTE) { bin = bin.Substring(bin.Length - BYTE); //dec = mainPage.bin2Dec(bin); } // can't go smaller than byte dec = CalcHelpers.bin2Dec(bin, (currentView as ProgrammerView).currentBits); } Set(dec, GetLastInputType(), true); }