diff --git a/Rs.SkyLine/Commom/TestCenterMessageBox.cs b/Rs.SkyLine/Commom/TestCenterMessageBox.cs new file mode 100644 index 0000000..fca11bd --- /dev/null +++ b/Rs.SkyLine/Commom/TestCenterMessageBox.cs @@ -0,0 +1,73 @@ +using Rs.MotionPlat.Flow; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using static Rs.MotionPlat.Commom.SchedulingMessageBox; + +namespace Rs.MotionPlat.Commom +{ + public class TestCenterMessageBox + { + private int ID; + private SchedulingMessageBox msgBox; + private ManualResetEvent msgRecivedEvent; + public TestCenterMessageBox() + { + msgBox = new SchedulingMessageBox(); + msgRecivedEvent = new ManualResetEvent(false); + } + + public void Show(int id,string message,ETipButton button,Dictionary buttonTexts) + { + ID = id; + msgBox.ButtonContexts = buttonTexts; + msgBox.Message = message; + msgBox.Button = button; + msgBox.Instruction = EInstruction.ShowMessage; + msgBox.ID = id; + TestCenter.Instance.ShowMsgBox(msgBox); + TestCenterMessageBoxManager.Add(id, this); + } + + public SchedulingMessageBox Result; + + public void Recived(SchedulingMessageBox result) + { + Result = result; + msgRecivedEvent.Set(); + + } + + public SchedulingMessageBox WaitResult() + { + msgRecivedEvent.WaitOne(); + TestCenterMessageBoxManager.Remove(ID); + return Result; + } + } + + public class TestCenterMessageBoxManager + { + private static Dictionary msgBoxDic = new Dictionary(); + public static void Add(int id,TestCenterMessageBox msgBox) + { + msgBoxDic.Add(id,msgBox); + } + + public static TestCenterMessageBox GetMsgbox(int id) + { + if(msgBoxDic.ContainsKey(id)) + return msgBoxDic[id]; + return null; + } + + public static void Remove(int id) + { + if( msgBoxDic.ContainsKey(id)) + msgBoxDic.Remove(id); + } + } +} diff --git a/Rs.SkyLine/Rs.SkyLine.csproj b/Rs.SkyLine/Rs.SkyLine.csproj index 06b9e59..5f4cc1a 100644 --- a/Rs.SkyLine/Rs.SkyLine.csproj +++ b/Rs.SkyLine/Rs.SkyLine.csproj @@ -123,6 +123,7 @@ +