void outBorder_SizeChanged(object sender, SizeChangedEventArgs e) { var outBorder = sender as Border; if (outBorder == null) { return; } var value = 0; if (!int.TryParse(outBorder.Tag.ToString(), out value)) { return; } var converter = new PIDConverter(); var maxVal = converter.GetMaxVol(outBorder.Uid); var minVal = converter.GetMinVol(outBorder.Uid); double curWidth = value * outBorder.ActualWidth / (maxVal - minVal); if (curWidth < 0) { curWidth = 0; } var inBorder = new Border { MinWidth = 20, Height = 6, HorizontalAlignment = HorizontalAlignment.Left, Width = curWidth, BorderThickness = new Thickness(1), Background = new SolidColorBrush(Colors.White) }; outBorder.Child = inBorder; }
private void DisplayOBD(DISP_Car car) { if (car.OBD == null) { return; } stkOBDParams.Children.Clear(); PIDConverter converter = new PIDConverter(); bool errorfinded = false; if (car.OBD.Count() > 0) { foreach (var item in car.OBD) { StringBuilder sb = new StringBuilder(); sb.Append(item.Value); sb.Append(" - "); sb.Append(converter.GetPidInfo(item.Key)); int min = converter.GetMinVol(item.Key); int max = converter.GetMaxVol(item.Key); int vol = 0; Int32.TryParse(item.Value, out vol); TextBlock text = new TextBlock(); text.Text = sb.ToString(); if (vol < min || vol > max) { errorfinded = true; text.Foreground = new SolidColorBrush(Colors.DarkRed); text.FontWeight = FontWeights.Bold; } stkOBDParams.Children.Add(text); } if (errorfinded) { brdrOBDStatus.Background = new SolidColorBrush(Colors.Orange); } else { brdrOBDStatus.Background = new SolidColorBrush(Colors.White); } } }
private void DisplayOBD(DISP_Car car) { if (car.OBD == null) { return; } stkOBDParams.Children.Clear(); var converter = new PIDConverter(); var errorfinded = false; if (!car.OBD.Any()) { return; } foreach (var item in car.OBD) { var sb = new StringBuilder(); sb.Append(item.Value); sb.Append(" - "); sb.Append(converter.GetPidInfo(item.Key)); var min = converter.GetMinVol(item.Key); var max = converter.GetMaxVol(item.Key); var vol = 0; int.TryParse(item.Value, out vol); var text = new TextBlock { Text = sb.ToString() }; if (vol < min || vol > max) { errorfinded = true; text.Foreground = new SolidColorBrush(Colors.DarkRed); text.FontWeight = FontWeights.Bold; } stkOBDParams.Children.Add(text); } //brdrOBDStatus.Background = errorfinded ? new SolidColorBrush(Colors.Orange) : new SolidColorBrush(Colors.White); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { PIDConverter converter = new PIDConverter(); txtName.Text = converter.GetPidInfo(_pid); int v = 0; Int32.TryParse(_vol, out v); txtVol.Text = _vol; int max = converter.GetMaxVol(_pid); if (max == -1) { pgrs.Visibility = Visibility.Collapsed; return; } pgrs.Maximum = max; int min = converter.GetMinVol(_pid); pgrs.Minimum = min; pgrs.Value = v; if (_previos.Count() < 20 && max != min) { double step = 50.0f / (double)(max - min); foreach (var item in _previos) { int h = 0; Int32.TryParse(item, out h); if (h >= min && h <= max) { double b = (double)(h - min) * step; b = Math.Round(b, 2); b = Math.Abs(b); if (b < 2) { b = 2; } Border b1 = new Border() { Width = 10, Height = b, VerticalAlignment = System.Windows.VerticalAlignment.Bottom }; Border b2 = new Border() { Background = new SolidColorBrush(Colors.Blue), VerticalAlignment = System.Windows.VerticalAlignment.Top, Height = 2 }; b1.Child = b2; cnvChart.Children.Add(b1); } else { cnvChart.Children.Add(new Border { Width = 10 }); } } } }