PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/source2/VSIP/Cosmos.VS.Windows/DataBytesUC.xaml.cs

https://bitbucket.org/mvptracker/cosmos
C# | 61 lines | 54 code | 7 blank | 0 comment | 3 complexity | 6f64823abdb384eda21a0ebfae02a3bb MD5 | raw file
Possible License(s): BSD-2-Clause
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. namespace Cosmos.VS.Windows {
  15. public partial class DataBytesUC : UserControl {
  16. public DataBytesUC() {
  17. InitializeComponent();
  18. }
  19. protected void UpdateDisplay() {
  20. if (mValue.HasValue) {
  21. tblkData.Text = mPrefix + mValue.Value.ToString("X" + mDigits);
  22. } else {
  23. tblkData.Text = mPrefix + (new string('-', mDigits));
  24. }
  25. tblkData.Foreground = mPrevValue == mValue ? Brushes.Black : Brushes.Red;
  26. }
  27. protected UInt32? mPrevValue;
  28. protected UInt32? mValue;
  29. public UInt32? Value {
  30. get { return mValue; }
  31. set {
  32. mValue = value;
  33. UpdateDisplay();
  34. mPrevValue = mValue;
  35. }
  36. }
  37. protected string mPrefix = "0x";
  38. public string Prefix {
  39. get { return mPrefix; }
  40. set {
  41. mPrefix = value;
  42. UpdateDisplay();
  43. }
  44. }
  45. protected int mDigits = 8;
  46. public int Digits {
  47. get { return mDigits; }
  48. set {
  49. mDigits = value;
  50. UpdateDisplay();
  51. }
  52. }
  53. }
  54. }