RecipeTableSelect.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 RecipeTable CopyTable = null;
  10. public static bool ShowDialog(RecipeDataBase recipeData,string recipeType)
  11. {
  12. var windowManager = IoC.Get<IWindowManager>();
  13. RecipeTableSelectDialogViewModel recipeTableSelectDialogView = new RecipeTableSelectDialogViewModel();
  14. recipeTableSelectDialogView.Recipe = recipeData;
  15. recipeTableSelectDialogView.IsAlarmRecipe = recipeType.ToLower()=="alarm";
  16. return (bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeTableSelectDialogView, null, "Select Table");
  17. }
  18. public static int ShowDialogGetTableIndex(RecipeDataBase recipeData, string recipeType)
  19. {
  20. var windowManager = IoC.Get<IWindowManager>();
  21. RecipeTableSelectDialogViewModel recipeTableSelectDialogView = new RecipeTableSelectDialogViewModel();
  22. recipeTableSelectDialogView.Recipe = recipeData;
  23. recipeTableSelectDialogView.CopyTable = CopyTable;
  24. recipeTableSelectDialogView.IsAlarmRecipe = recipeType.ToLower() == "alarm";
  25. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeTableSelectDialogView, null, "Select Table"))
  26. {
  27. CopyTable = recipeTableSelectDialogView.CopyTable;
  28. return recipeTableSelectDialogView.SelectedIndex;
  29. }
  30. return -1;
  31. }
  32. public static string ShowDialog(string PrefixPath ,string Name, bool isEditEnable)
  33. {
  34. RecipeProvider provider = new RecipeProvider();
  35. var recipeContent = provider.LoadRecipe(PrefixPath, Name);
  36. RecipeDataBase recipeData = new RecipeDataBase();
  37. if (string.IsNullOrEmpty(recipeContent))
  38. return null;
  39. //recipeData.RecipeChamberType = "OriginChamber";
  40. recipeData.InitData(PrefixPath, Name, recipeContent, "PM1");
  41. var windowManager = IoC.Get<IWindowManager>();
  42. RecipeTableSelectDialogViewModel recipeTableSelectDialogView = new RecipeTableSelectDialogViewModel();
  43. recipeTableSelectDialogView.Recipe = recipeData;
  44. recipeTableSelectDialogView.IsEditEnable = isEditEnable;
  45. recipeTableSelectDialogView.CopyTable = CopyTable;
  46. if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeTableSelectDialogView, null, "Select Table"))
  47. {
  48. CopyTable = recipeTableSelectDialogView.CopyTable;
  49. return $"{recipeData.TableIndex}:{recipeData.TableName}";
  50. }
  51. return null;
  52. }
  53. }
  54. }