public static void StartLoading1(List <ComboBox> scv, ref int screen, DisplayUnitConfiguration temp, CheckBox useCustomHeaderCheck, TextBox headerTextBox, ref bool firstLoad) { foreach (ComboBox cbox in scv) { cbox.SelectedIndex = -1; cbox.IsEnabled = false; } scv[0].IsEnabled = true; screen = temp.ScreenToEdit; if (temp.Screens[screen].Variables.Count > 0) { for (int i = 0; i < temp.Screens[screen].Variables.Count; i++) { scv[i].IsEnabled = true; DisplayVarsEnum temp222; if (Enum.TryParse(temp.Screens[screen].Variables[i], out temp222)) { scv[i].SelectedItem = temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables[temp222].Name; } else { scv[i].SelectedIndex = -1; } } } else { scv[0].IsEnabled = true; scv[0].SelectedIndex = -1; } useCustomHeaderCheck.IsChecked = temp.Screens[screen].UseCustomHeader; headerTextBox.Text = temp.Screens[screen].CustomHeader; firstLoad = false; }
private void StartLoading() { this.firstLoad = true; this.Temp = (DisplayUnitConfiguration)this.DataContext; this.scv = new List <ComboBox> { this.ScreenVariable1CBox, this.ScreenVariable2CBox, this.ScreenVariable3CBox, this.ScreenVariable4CBox, this.ScreenVariable5CBox, this.ScreenVariable6CBox, this.ScreenVariable7CBox, this.ScreenVariable8CBox, this.ScreenVariable9CBox }; foreach (var variable in this.Temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables) { foreach (ComboBox comboBox in this.scv) { comboBox.Items.Add(variable.Value.Name); } } PageHelper.StartLoading1(this.scv, ref this.screen, this.Temp, this.UseCustomHeaderCheck, this.HeaderTextBox, ref this.firstLoad); this.firstLoad = false; }
public static void ScreenVariablesUpdatedExtracted(int maxDisplayLengthTM1638, string format, int param, List <ComboBox> scvIn, DisplayUnitConfiguration temp, Label spaceUsedLabel, bool firstLoadIn) { int count = 0; int i = 0; int stop = 0; while (count < maxDisplayLengthTM1638 && i < scvIn.Count) { stop = i + 1; if (scvIn[i].SelectedIndex >= 0) { count += temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables.Where(item => item.Value.Name == scvIn[i].SelectedItem.ToString()).Sum(item => item.Value.Length); spaceUsedLabel.Content = String.Format(format, count); if (count > maxDisplayLengthTM1638) { stop = i; i = scvIn.Count; } i++; } else { scvIn[i].IsEnabled = true; scvIn[i].Items.Clear(); foreach (var variable in temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables) { if (variable.Value.Length <= maxDisplayLengthTM1638 - count) { scvIn[i].Items.Add(variable.Value.Name); } } i = scvIn.Count; } } for (int j = stop; j < scvIn.Count; j++) { scvIn[j].Items.Clear(); scvIn[j].SelectedIndex = -1; scvIn[j].IsEnabled = false; } //save to config if (!firstLoadIn) { for (int p = 0; p < param; p++) { if (scvIn[p].SelectedValue != null) { string tempV = scvIn[p].SelectedValue.ToString(); var temp2 = new DisplayVarsEnum(); bool found = false; foreach (var disVar in temp.HostApp.DisplayMngr.Dictionarys.DisplayVariables) { if (disVar.Value.Name == tempV) { temp2 = disVar.Key; found = true; } } if (found) { if (temp.Screens[temp.ScreenToEdit].Variables.Count - 1 < p) { temp.Screens[temp.ScreenToEdit].Variables.Add(""); } temp.Screens[temp.ScreenToEdit].Variables[p] = temp2.ToString(); } } } } }
private void PageLoaded1(object sender, RoutedEventArgs e) { this.Temp = (DisplayUnitConfiguration)this.DataContext; this.ButtonFunctionsCBoxs = new List <ComboBox> { this.ButtonFunctionCBox1, this.ButtonFunctionCBox2, this.ButtonFunctionCBox3, this.ButtonFunctionCBox4, this.ButtonFunctionCBox5, this.ButtonFunctionCBox6, this.ButtonFunctionCBox7, this.ButtonFunctionCBox8 }; this.ButtonOptionsCBoxs = new List <ComboBox> { this.ButtonOptionCBox1, this.ButtonOptionCBox2, this.ButtonOptionCBox3, this.ButtonOptionCBox4, this.ButtonOptionCBox5, this.ButtonOptionCBox6, this.ButtonOptionCBox7, this.ButtonOptionCBox8 }; this.ButtonScreensCBoxs = new List <ComboBox> { this.ButtonScreenCBox1, this.ButtonScreenCBox2, this.ButtonScreenCBox3, this.ButtonScreenCBox4, this.ButtonScreenCBox5, this.ButtonScreenCBox6, this.ButtonScreenCBox7, this.ButtonScreenCBox8 }; //populate combo boxs foreach (var butFunc in this.Temp.HostApp.DisplayMngr.Dictionarys.ButtonFunctions) { foreach (ComboBox cbox in this.ButtonFunctionsCBoxs) { cbox.Items.Add(butFunc.Value.Name); } } foreach (ComboBox cBox in this.ButtonScreensCBoxs) { cBox.IsEnabled = true; cBox.Items.Add("All"); cBox.Items.Add("Current"); for (int i = 1; i <= this.Temp.TotalUnits + 1; i++) { cBox.Items.Add(i.ToString(CultureInfo.InvariantCulture)); } } //data bind for (int x = 0; x < Constants.NumberButtonsOnTm1638; x++) { var buttonFuncBinding = new Binding(String.Format("ButtonConfigurations.ButtonFunctions[{0}]", x)) { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.ButtonFunctionsCBoxs[x], Selector.SelectedValueProperty, buttonFuncBinding); var buttonOptBinding = new Binding(String.Format("ButtonConfigurations.ButtonOptions[{0}]", x)) { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.ButtonOptionsCBoxs[x], Selector.SelectedValueProperty, buttonOptBinding); var buttonScreenBinding = new Binding(String.Format("ButtonConfigurations.ButtonOptionsScreens[{0}]", x)) { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.ButtonScreensCBoxs[x], Selector.SelectedIndexProperty, buttonScreenBinding); } }
private void PageLoaded1(object sender, RoutedEventArgs e) { this.FFBWhichScreenLabel.IsEnabled = false; this.RevLimiterStyleLabel.IsEnabled = false; this.PitLimiterFlashSpeedLabel.IsEnabled = false; this.PitLimiterStyleLabel.IsEnabled = false; this.ShiftLightStyleLabel.IsEnabled = false; this.MatchStyleOptionLabel.IsEnabled = false; //Populate CBOXs this.Temp = (DisplayUnitConfiguration)this.DataContext; foreach (var item in this.Temp.HostApp.DisplayMngr.Dictionarys.ShiftStyles) { this.ShiftLightStyleCBox.Items.Add(item.Key); } foreach (var item in this.Temp.HostApp.DisplayMngr.Dictionarys.RevFlashStyles) { this.RevLightStyleCBox.Items.Add(item.Key); } foreach (var item in this.Temp.HostApp.DisplayMngr.Dictionarys.PitFlashStyles) { this.PitLightStyleCBox.Items.Add(item.Key); } foreach (var item in this.Temp.HostApp.DisplayMngr.Dictionarys.PitFlashSpeeds) { this.PitLightSpeedCBox.Items.Add(item.Key); } for (int i = 1; i <= this.Temp.NumScreens + 1; i++) { this.FFBClipScreenCBox.Items.Add(i.ToString(CultureInfo.InvariantCulture)); } foreach (var item in this.Temp.HostApp.DisplayMngr.Dictionarys.MatchCarShiftOptions) { this.MatchShiftLightsOptionCBox.Items.Add(item.Key); } //Data Bind var showShiftLightsBinding = new Binding("LEDsConfigurations.ShowShiftLights") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.ShowShiftLightsCheck, ToggleButton.IsCheckedProperty, showShiftLightsBinding); var matchShiftLightsBinding = new Binding("LEDsConfigurations.MatchCarShiftLights") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.MatchShiftLightsCheck, ToggleButton.IsCheckedProperty, matchShiftLightsBinding); var matchShiftOptionBinding = new Binding("LEDsConfigurations.MatchCarShiftOptions") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding( this.MatchShiftLightsOptionCBox, Selector.SelectedValueProperty, matchShiftOptionBinding); var useMatchRedShiftBinding = new Binding("LEDsConfigurations.MatchRedShift") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.UseRedShiftCheck, ToggleButton.IsCheckedProperty, useMatchRedShiftBinding); var showPitLightsBinding = new Binding("LEDsConfigurations.PitLights") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.ShowPitLightsCheck, ToggleButton.IsCheckedProperty, showPitLightsBinding); var showRevLightsBinding = new Binding("LEDsConfigurations.RevLimiterLights") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.ShowRevLightsCheck, ToggleButton.IsCheckedProperty, showRevLightsBinding); var ffbClippingBinding = new Binding("LEDsConfigurations.FFBClippingLights") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.ShowFFBCheck, ToggleButton.IsCheckedProperty, ffbClippingBinding); var ffbClipScreenBinding = new Binding("LEDsConfigurations.FFBClippingScreen") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.FFBClipScreenCBox, Selector.SelectedIndexProperty, ffbClipScreenBinding); var shiftLightStyleBinding = new Binding("LEDsConfigurations.ShiftLightStyle") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.ShiftLightStyleCBox, Selector.SelectedItemProperty, shiftLightStyleBinding); var pitLightStyleBinding = new Binding("LEDsConfigurations.PitLimiterStyle") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.PitLightStyleCBox, Selector.SelectedItemProperty, pitLightStyleBinding); var pitLightSpeedBinding = new Binding("LEDsConfigurations.PitLimiterSpeed") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.PitLightSpeedCBox, Selector.SelectedItemProperty, pitLightSpeedBinding); var revLightStyleBinding = new Binding("LEDsConfigurations.RevLimiterStyle") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.RevLightStyleCBox, Selector.SelectedItemProperty, revLightStyleBinding); var shiftClumpsBinding = new Binding("LEDsConfigurations.ShiftClumps") { Mode = BindingMode.TwoWay }; BindingOperations.SetBinding(this.ShiftClumpsCheck, ToggleButton.IsCheckedProperty, shiftClumpsBinding); }