public PathBrowserCloseWatcher(object owner, Guid dialogHandleId, PathChoosenHandlerDlgt pathChoosenHandler, DialogCancelledHandlerDlgt cancelledHandler) { _watcher = new MessageWatcher(owner, PathBrowserMessaging.CHANNEL, message => { if (message.ChannelName == PathBrowserMessaging.CHANNEL) { PathBrowserMessaging.MessageType messageType = (PathBrowserMessaging.MessageType) message.MessageType; if (messageType == PathBrowserMessaging.MessageType.PathChoosen) { Guid closedDialogHandle = (Guid) message.MessageData[PathBrowserMessaging.DIALOG_HANDLE]; ResourcePath choosenPath = (ResourcePath) message.MessageData[PathBrowserMessaging.CHOOSEN_PATH]; if (closedDialogHandle == dialogHandleId) { if (pathChoosenHandler != null) pathChoosenHandler(choosenPath); return true; } } else if (messageType == PathBrowserMessaging.MessageType.DialogCancelled) { if (cancelledHandler != null) cancelledHandler(); return true; } } return false; }, true); _watcher.Start(); }
public DialogCloseWatcher(object owner, Guid dialogHandleId, CloseHandlerDlgt handler) { _watcher = new MessageWatcher(owner, DialogManagerMessaging.CHANNEL, message => { if (message.ChannelName == DialogManagerMessaging.CHANNEL) { DialogManagerMessaging.MessageType messageType = (DialogManagerMessaging.MessageType) message.MessageType; if (messageType == DialogManagerMessaging.MessageType.DialogClosed) { Guid closedDialogHandle = (Guid) message.MessageData[DialogManagerMessaging.DIALOG_HANDLE]; DialogResult dialogResult = (DialogResult) message.MessageData[DialogManagerMessaging.DIALOG_RESULT]; if (closedDialogHandle == dialogHandleId) { if (handler != null) handler(dialogResult); return true; } } } return false; }, true); _watcher.Start(); }