Keine Beschreibung

MeasurePoint.cs 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ComponentModel;
  6. using System.Reflection;
  7. namespace WpfApplication19
  8. {
  9. class MeasurePoint : INotifyPropertyChanged
  10. {
  11. #region INotifyPropertyChanged Members
  12. public event PropertyChangedEventHandler PropertyChanged;
  13. protected void Notify(string propName)
  14. {
  15. if (this.PropertyChanged != null)
  16. {
  17. PropertyChanged(this, new PropertyChangedEventArgs(propName));
  18. }
  19. }
  20. #endregion
  21. /*
  22. private int _P1;
  23. public int P1
  24. {
  25. get { return _P1; }
  26. set
  27. {
  28. this._P1 = value;
  29. Notify("P1");
  30. }
  31. }
  32. */
  33. public int Count { get; set; }
  34. public double P1 { get; set; }
  35. public double P2 { get; set; }
  36. public double P3 { get; set; }
  37. public double P4 { get; set; }
  38. public double P5 { get; set; }
  39. public double P6 { get; set; }
  40. public double P7 { get; set; }
  41. public double P8 { get; set; }
  42. public double P9 { get; set; }
  43. public double P10 { get; set; }
  44. public double Avg { get; set; }
  45. public string Grade { get; set; }
  46. public string ResultGrade { get; set; }
  47. public string Type { get; set; }
  48. public int SubOrder { get; set; }
  49. public void setValue(string alias, double value)
  50. {
  51. PropertyInfo methodInfo =
  52. typeof(MeasurePoint).GetProperty("P"+alias);
  53. // Use the instance to call the method without arguments
  54. try{
  55. int cn = Convert.ToInt16(alias);
  56. if (cn >= 1 && cn <= 10)
  57. methodInfo.SetValue(this, value, null);
  58. }catch{
  59. return;
  60. }
  61. }
  62. public float GetValue(string alias)
  63. {
  64. PropertyInfo methodInfo =
  65. typeof(MeasurePoint).GetProperty(alias);
  66. return (float)methodInfo.GetValue(this, null);
  67. }
  68. }
  69. }