PopSettingDialogViewModel.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using OpenSEMI.ClientBase;
  2. using RecipeEditorLib.RecipeModel.Params;
  3. using System.Collections.ObjectModel;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. namespace MECF.Framework.UI.Client.CenterViews.Editors.Recipe
  7. {
  8. public class TemplateSelector : DataTemplateSelector
  9. {
  10. private DataTemplate _textBoxTemplate = null;
  11. public DataTemplate TextBoxTemplate
  12. {
  13. get { return _textBoxTemplate; }
  14. set { _textBoxTemplate = value; }
  15. }
  16. private DataTemplate _textBoxTemplateString = null;
  17. public DataTemplate TextBoxTemplateString
  18. {
  19. get { return _textBoxTemplateString; }
  20. set { _textBoxTemplateString = value; }
  21. }
  22. private DataTemplate _comboBoxTemplate = null;
  23. public DataTemplate ComboBoxTemplate
  24. {
  25. get { return _comboBoxTemplate; }
  26. set { _comboBoxTemplate = value; }
  27. }
  28. public override DataTemplate SelectTemplate(object item, DependencyObject container)
  29. {
  30. if (item is Param)
  31. {
  32. return (item as Param).GetType().Name == "ComboxParam" ? _comboBoxTemplate : ((item as Param).GetType().Name == "StringParam" ? _textBoxTemplateString : _textBoxTemplate);
  33. }
  34. return base.SelectTemplate(item, container);
  35. }
  36. }
  37. public class BandParam : Param
  38. {
  39. public Param WavelengthDoubleParam
  40. {
  41. get;
  42. set;
  43. }
  44. public Param BandwidthDoubleParam
  45. {
  46. get;
  47. set;
  48. }
  49. }
  50. /// <summary>
  51. ///
  52. /// </summary>
  53. public class PublicPopSettingDialogViewModel : DialogViewModel<ObservableCollection<Param>>
  54. {
  55. public ObservableCollection<Param> Parameters
  56. {
  57. get;
  58. set;
  59. }
  60. public ObservableCollection<Param> ControlParameters
  61. {
  62. get;
  63. set;
  64. }
  65. public ObservableCollection<BandParam> BandParameters
  66. {
  67. get;
  68. set;
  69. }
  70. public Visibility BandVisibility => BandParameters == null || BandParameters.Count == 0 ? Visibility.Collapsed : Visibility.Visible;
  71. public void OK()
  72. {
  73. this.DialogResult = Parameters;
  74. IsCancel = false;
  75. TryClose(true);
  76. }
  77. public void Cancel()
  78. {
  79. IsCancel = true;
  80. TryClose(false);
  81. }
  82. }
  83. }