RecipeTableSelect.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Caliburn.Micro;
  2. using Caliburn.Micro.Core;
  3. using FurnaceUI.Views.Recipes;
  4. using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
  5. namespace FurnaceUI.Common
  6. {
  7. public static class RecipeTableSelect
  8. {
  9. public static bool ShowDialog(RecipeDataBase recipeData,string recipeType)
  10. {
  11. var windowManager = IoC.Get<IWindowManager>();
  12. RecipeTableSelectDialogViewModel recipeTableSelectDialogView = new RecipeTableSelectDialogViewModel();
  13. recipeTableSelectDialogView.Recipe = recipeData;
  14. recipeTableSelectDialogView.IsAlarmRecipe = recipeType.ToLower()=="alarm";
  15. return (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeTableSelectDialogView, null, "Select Table");
  16. }
  17. public static int ShowDialogGetTableIndex(RecipeDataBase recipeData, string recipeType)
  18. {
  19. var windowManager = IoC.Get<IWindowManager>();
  20. RecipeTableSelectDialogViewModel recipeTableSelectDialogView = new RecipeTableSelectDialogViewModel();
  21. recipeTableSelectDialogView.Recipe = recipeData;
  22. recipeTableSelectDialogView.IsAlarmRecipe = recipeType.ToLower() == "alarm";
  23. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeTableSelectDialogView, null, "Select Table"))
  24. {
  25. return recipeTableSelectDialogView.SelectedIndex;
  26. }
  27. return -1;
  28. }
  29. public static string ShowDialog(string PrefixPath ,string Name, bool isEditEnable)
  30. {
  31. RecipeProvider provider = new RecipeProvider();
  32. var recipeContent = provider.LoadRecipe(PrefixPath, Name);
  33. RecipeDataBase recipeData = new RecipeDataBase();
  34. if (string.IsNullOrEmpty(recipeContent))
  35. return null;
  36. //recipeData.RecipeChamberType = "OriginChamber";
  37. recipeData.InitData(PrefixPath, Name, recipeContent, "PM1");
  38. var windowManager = IoC.Get<IWindowManager>();
  39. RecipeTableSelectDialogViewModel recipeTableSelectDialogView = new RecipeTableSelectDialogViewModel();
  40. recipeTableSelectDialogView.Recipe = recipeData;
  41. recipeTableSelectDialogView.IsEditEnable = isEditEnable;
  42. if((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeTableSelectDialogView, null, "Select Table"))
  43. {
  44. return $"{recipeData.TableIndex}:{recipeData.TableName}";
  45. }
  46. return null;
  47. }
  48. }
  49. }