public void Start() { bool checkOperandA = Utils.CheckOperandRange(int.Parse(ALUViewModel.Instance.OperandA)); bool checkOperandB = Utils.CheckOperandRange(int.Parse(ALUViewModel.Instance.OperandB)); if (checkOperandA && checkOperandB) { TMR tmr = new TMR(); sbyte a = sbyte.Parse(ALUViewModel.Instance.OperandA), b = sbyte.Parse(ALUViewModel.Instance.OperandB); OPERATION_TYPE type = Utils.StringOperationToEnum(ALUViewModel.Instance.WybranaOperacja); bool[] isErr = new bool[3]; isErr[0] = BledyViewModel.Instance.IsCheckedBox1; isErr[1] = BledyViewModel.Instance.IsCheckedBox2; isErr[2] = BledyViewModel.Instance.IsCheckedBox3; tmr.SimulateOnce(a, b, type, isErr); WizualizacjaViewModel.Instance.WynikALU1 = Utils.SbyteToBinaryString(tmr.GetALU_Result(0), 8); WizualizacjaViewModel.Instance.WynikALU2 = Utils.SbyteToBinaryString(tmr.GetALU_Result(1), 8); WizualizacjaViewModel.Instance.WynikALU3 = Utils.SbyteToBinaryString(tmr.GetALU_Result(2), 8); WynikDecimal = tmr.GetVoter_Result(); string voter = Utils.SbyteToBinaryString(WynikDecimal, 8); WizualizacjaViewModel.Instance.Wynik = voter; WizualizacjaViewModel.Instance.OperandABinary = Utils.SbyteToBinaryString(sbyte.Parse(ALUViewModel.Instance.OperandA), 8); WizualizacjaViewModel.Instance.OperandBBinary = Utils.SbyteToBinaryString(sbyte.Parse(ALUViewModel.Instance.OperandB), 8); Utils.WriteLog("Kliknięto start"); Utils.WriteLog("Parametry uruchomienia: " + "\nOperand A: " + ALUViewModel.Instance.OperandA + "\nOperand B: " + ALUViewModel.Instance.OperandB + "\nOperacja: " + ALUViewModel.Instance.WybranaOperacja + "\nBłąd ALU1: " + BledyViewModel.Instance.IsCheckedBox1.ToString() + " - " + WizualizacjaViewModel.Instance.WynikALU1.ToString() + "\nBłąd ALU2: " + BledyViewModel.Instance.IsCheckedBox2.ToString() + " - " + WizualizacjaViewModel.Instance.WynikALU2.ToString() + "\nBłąd ALU3: " + BledyViewModel.Instance.IsCheckedBox3.ToString() + " - " + WizualizacjaViewModel.Instance.WynikALU3.ToString() + "\nWynik: " + WynikDecimal.ToString()); } else { MessageBox.Show("Wartości operandów powinny być z zakresu <-128, 127>"); } }
private void Apply_Click(object sender, RoutedEventArgs e) { try { Name = Name_textbox.Text; Surname = Surname_textbox.Text; Sex = SexCheck; Age = Convert.ToUInt32(Age_textbox.Text); Height = Convert.ToDouble(Height_textbox.Text.Replace('.', ',')); Weight = Convert.ToDouble(Weight_textbox.Text.Replace('.', ',')); ActivityLevel = Convert.ToUInt32(ActivityLevel_combobox.SelectedIndex); Goal = Convert.ToUInt32(Goal_combobox.SelectedIndex); DietType = Convert.ToUInt32(DietCheck()); MealCount = Convert.ToUInt32(MealsCount_combobox.SelectedItem); BMI = MathOperations.getBMI(Height, Weight); BMR = MathOperations.getBMR(Height, Weight, Convert.ToInt32(Age), Sex); TMR = MathOperations.getTMR(Convert.ToInt32(ActivityLevel), BMR); DailyCalories = MathOperations.getDailyCalories(Convert.ToInt32(Goal), TMR); BMI_textblock.Text = BMI.ToString("0.##"); BMR_textblock.Text = BMR.ToString(); TMR_textblock.Text = TMR.ToString(); DailyCalories_textblock.Text = DailyCalories.ToString(); Meals meals = new Meals(Convert.ToInt32(MealCount), DailyCalories, Convert.ToInt32(DietType), Convert.ToInt32(Goal), Weight); uint sex; if (Sex) { sex = 1; } else { sex = 0; } Users user = new Users(Login.UserLogin, Name, Surname, Age, Height, Weight, Goal, sex, ActivityLevel, DailyCalories, DietType, MealCount); UsersRepos.Update(user); } catch { MessageBox.Show(Properties.Resources.errorEmptyDatas, Properties.Resources.warning); } show(); }
private void SetData() { var UserList = UsersRepos.GetAll(); Users User = null; foreach (var user in UserList) { if (Login.UserLogin == user.Login) { User = new Users(user); break; } } if (User != null) { Name_textbox.Text = User.Name; Surname_textbox.Text = User.Surname; Age_textbox.Text = User.Age.ToString(); Height_textbox.Text = User.Height.ToString(); Weight_textbox.Text = User.Weight.ToString(); DailyCalories_textblock.Text = User.Kcal.ToString(); MealsCount_combobox.SelectedItem = Convert.ToInt32(User.MealsCount); ActivityLevel_combobox.SelectedIndex = Convert.ToInt32(User.ActivityLevel); Goal_combobox.SelectedIndex = Convert.ToInt32(User.Goal); if (User.Sex == 0) { woman_radiobutton.IsChecked = true; Sex = false; } if (User.Sex == 1) { man_radiobutton.IsChecked = true; Sex = true; } if (User.DietType == 0) { normal_radiobutton.IsChecked = true; } if (User.DietType == 1) { vegetarian_radiobutton.IsChecked = true; } if (User.DietType == 2) { vegan_radiobutton.IsChecked = true; } Height = Convert.ToDouble(User.Height); Weight = Convert.ToDouble(User.Weight); Age = Convert.ToUInt32(User.Age); ActivityLevel = Convert.ToUInt32(User.ActivityLevel); DietType = Convert.ToUInt32(DietCheck()); BMI = MathOperations.getBMI(Height, Weight); BMR = MathOperations.getBMR(Height, Weight, Convert.ToInt32(Age), Sex); TMR = MathOperations.getTMR(Convert.ToInt32(ActivityLevel), BMR); BMI_textblock.Text = BMI.ToString("0.##"); BMR_textblock.Text = BMR.ToString(); TMR_textblock.Text = TMR.ToString(); Login.CurrentUser = User; } }