using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace POSV { public sealed class WaitWindow { private WaitWindowGUI _GUI; internal delegate void MethodInvoker(T parameter1); internal EventHandler _WorkerMethod; internal List _Args; private WaitWindow() { } public static object Show(EventHandler workerMethod) { return WaitWindow.Show(workerMethod, null); } public static object Show(EventHandler workerMethod, string message) { WaitWindow instance = new WaitWindow(); return instance.Show(workerMethod, message, new List()); } public static object Show(EventHandler workerMethod, string message, params object[] args) { List arguments = new List(); arguments.AddRange(args); WaitWindow instance = new WaitWindow(); return instance.Show(workerMethod, message, arguments); } public string Message { set { this._GUI.Invoke(new MethodInvoker(this._GUI.SetMessage), value); } } public void Cancel() { this._GUI.Invoke(new MethodInvoker(this._GUI.Cancel), null); } private object Show(EventHandler workerMethod, string message, List args) { if (workerMethod == null) { throw new ArgumentException("No worker method has been specified.", "workerMethod"); } else { this._WorkerMethod = workerMethod; } this._Args = args; if (string.IsNullOrEmpty(message)) { message = "ΗλΙΤΊς..."; } this._GUI = new WaitWindowGUI(this); this._GUI.MessageLabel.Text = message; //this._GUI.circularProgress.Start(); this._GUI.ShowDialog(); object result = this._GUI._Result; Exception _Error = this._GUI._Error; this._GUI.Dispose(); if (_Error != null) { throw _Error; } else { return result; } } } public class WaitWindowEventArgs : EventArgs { public WaitWindowEventArgs(WaitWindow GUI, List args) : base() { this._Window = GUI; this._Arguments = args; } private WaitWindow _Window; private List _Arguments; private object _Result; public WaitWindow Window { get { return _Window; } } public List Arguments { get { return _Arguments; } } public object Result { get { return _Result; } set { _Result = value; } } } }