public static void RegisterCallbacks(OpenDialogDelegate openDialogCallback, OpenWindowDelegate openWindowCallback) { if (DialogService.openWindowCallback != null) { throw new InvalidOperationException("it is not allowed to call DialogService.RegisterCallbacks() again, after DialogService was already initialized."); } DialogService.openDialogCallback = openDialogCallback ?? throw new ArgumentNullException("openDialogCallback"); DialogService.openWindowCallback = openWindowCallback ?? throw new ArgumentNullException("openWindowCallback"); }
/// <summary> /// Open a window (for example Moving Pictures, MP-TV Series, etc.), /// invoke on GUI thread if called from a different /// thread than UI thread /// </summary> /// <param name="windowId"></param> public static void OpenWindow(int windowId) { if (GUIGraphicsContext.form.InvokeRequired) { OpenWindowDelegate d = OpenWindow; GUIGraphicsContext.form.Invoke(d, new object[] { windowId }); } else { GUIGraphicsContext.ResetLastActivity(); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, windowId, 0, null); GUIWindowManager.SendThreadMessage(msg); } }
/// <summary> /// Register a window for a specific data type. /// </summary> /// <typeparam name="T"></typeparam> public static void RegisterWindow <T>(OpenWindowDelegate openWindowCallback) { var callback = GetOpenWindowCallback(typeof(T)); RegisteredWindows[typeof(T)] = openWindowCallback; }