/// <summary> /// アクションを実行する。 /// </summary> /// <param name="message"></param> protected override void InvokeAction(InteractionMessage message) { if (message is OpenSettingDialogMessage actionMessage) { DialogUtils.ShowSettingWindow(actionMessage.TabPageIndex, this.AssociatedObject, false); } }
/// <summary> /// Invokes the action related to this class. /// </summary> /// <param name="m"><see cref="FolderSelectionMessage"/> specified to <see cref="InteractionMessenger"/> in the client.</param> protected override void InvokeAction(InteractionMessage m) { var folderSelectionMessage = m as FolderSelectionMessage; if (folderSelectionMessage != null) { Window hostWindow = Window.GetWindow(AssociatedObject); if (hostWindow == null) { return; } using (var dialog = FolderSelectionDialogFactory.CreateDialog(folderSelectionMessage.DialogPreference) ) { dialog.Title = folderSelectionMessage.Title; dialog.Description = folderSelectionMessage.Description; dialog.SelectedPath = folderSelectionMessage.SelectedPath; if (dialog.ShowDialog(hostWindow).GetValueOrDefault()) { folderSelectionMessage.Response = dialog.SelectedPath; } else { folderSelectionMessage.Response = null; } } } }
protected override void InvokeAction(InteractionMessage message) { // ReSharper disable once InvertIf if (message is ConfirmationMessage confirmMessage) { var result = MessageBox.Show( confirmMessage.Text, confirmMessage.Caption, confirmMessage.Button, confirmMessage.Image, confirmMessage.DefaultResult ); // ReSharper disable once SwitchStatementMissingSomeCases switch (result) { case MessageBoxResult.Yes: case MessageBoxResult.OK: confirmMessage.Response = true; break; case MessageBoxResult.Cancel: confirmMessage.Response = null; break; default: confirmMessage.Response = false; break; } } }
/// <summary> /// Initializes a new instance of the <see cref="Entry"/> class from <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="InteractionMessage"/> to initialize from.</param> public Entry(InteractionMessage message) { StartedDateTime = message.Timings.StartedDateTime; Time = Convert.ToInt64(Math.Round(message.Timings.Time.TotalMilliseconds, 0)); Request = new Request(message.Response.RequestMessage); Response = new Response(message.Response); }
/// <summary> /// アクション実行 /// </summary> /// <param name="message">メッセージ</param> protected override void InvokeAction(InteractionMessage message) { var setWindowBoundsMessage = message as SetWindowBoundsMessage; if (setWindowBoundsMessage == null) { return; } if (setWindowBoundsMessage.Left.HasValue) { this.AssociatedObject.Left = setWindowBoundsMessage.Left.Value; } if (setWindowBoundsMessage.Top.HasValue) { this.AssociatedObject.Top = setWindowBoundsMessage.Top.Value; } if (setWindowBoundsMessage.Width.HasValue) { this.AssociatedObject.Width = setWindowBoundsMessage.Width.Value; } if (setWindowBoundsMessage.Height.HasValue) { this.AssociatedObject.Height = setWindowBoundsMessage.Height.Value; } }
/// <summary> /// Invokes the action related to this class. /// </summary> /// <param name="m"><see cref="FolderSelectionMessage" /> specified to <see cref="InteractionMessenger" /> in the client.</param> protected override void InvokeAction(InteractionMessage m) { // ReSharper disable once InvertIf if (m is FolderSelectionMessage folderSelectionMessage) { var hostWindow = Window.GetWindow(AssociatedObject ?? throw new InvalidOperationException()); if (hostWindow == null) { return; } using (var dialog = FolderSelectionDialogFactory.CreateDialog(folderSelectionMessage.DialogPreference)) { if (dialog == null) { throw new InvalidOperationException(); } dialog.Title = folderSelectionMessage.Title; dialog.Description = folderSelectionMessage.Description; dialog.SelectedPath = folderSelectionMessage.SelectedPath; dialog.Multiselect = folderSelectionMessage.Multiselect; if (dialog.ShowDialog(hostWindow).GetValueOrDefault()) { folderSelectionMessage.SelectedPaths = dialog.SelectedPaths; folderSelectionMessage.Response = folderSelectionMessage.SelectedPaths.FirstOrDefault(); } else { folderSelectionMessage.Response = null; } } } }
protected override void InvokeAction(InteractionMessage message) { var windowMessage = message as WindowActionMessage; if (windowMessage != null) { var window = Window.GetWindow(AssociatedObject); if (window != null) { switch (windowMessage.Action) { case WindowAction.Close: window.Close(); break; case WindowAction.Maximize: window.WindowState = WindowState.Maximized; break; case WindowAction.Minimize: window.WindowState = WindowState.Minimized; break; case WindowAction.Normal: window.WindowState = WindowState.Normal; break; case WindowAction.Active: window.Activate(); break; } } } }
/// <summary> /// 実行 /// </summary> /// <param name="message">メッセージ</param> protected override void InvokeAction(InteractionMessage message) { if (message is not PromptMessage prompt) { return; } var viewModel = new PromptViewModel { Title = prompt.Title, Description = prompt.Description, Text = prompt.Text, IsAllowEmpty = prompt.IsAllowEmpty, Validation = prompt.Validation, }; prompt.Response = null; var window = new PromptWindow { DataContext = viewModel, Owner = Window.GetWindow(this.AssociatedObject), }; if (window.ShowDialog() ?? false) { prompt.Response = viewModel.Text; } }
protected override void InvokeAction(InteractionMessage message) { var screenshotMessage = message as ScreenshotMessage; if (screenshotMessage == null) { return; } try { this.SaveCore(screenshotMessage.Path); screenshotMessage.Response = new Processing(); } catch (Exception ex) { Debug.WriteLine(ex); try { screenshotMessage.Response = new Processing(ex); TakeScreenshot(800, 480, null, screenshotMessage.Path); } catch (Exception e) { screenshotMessage.Response = new Processing(e); } } }
protected override void InvokeAction(InteractionMessage message) { var confirmMessage = message as ConfirmationMessage; if (confirmMessage != null) { var result = MessageBox.Show( confirmMessage.Text, confirmMessage.Caption, confirmMessage.Button, confirmMessage.Image, confirmMessage.DefaultResult ); if (result == MessageBoxResult.Yes || result == MessageBoxResult.OK) { confirmMessage.Response = true; } else if (result == MessageBoxResult.Cancel) { confirmMessage.Response = null; } else { confirmMessage.Response = false; } } }
/// <summary> /// Actionを実行する /// </summary> /// <param name="message"></param> protected override void InvokeAction(InteractionMessage message) { if (message is not OpenSettingDialogMessage msg) { return; } DialogUtils.OpenSettingWindow(Window.GetWindow(this.AssociatedObject)); }
protected override void InvokeAction(InteractionMessage message) { var msg = message as TopmostMessage; if (msg != null) { this.AssociatedObject.Topmost = msg.Topmost; } }
private void handleInteractionMessage(InteractionMessage message) { switch (message.Action) { case InteractionMessageAction.Created: { CreateNewInteraction(message); } break; case InteractionMessageAction.Assigned: { IInteraction interaction = Interactions.FirstOrDefault(i => string.Compare(i.Id, message.Interaction.Id.ToString()) == 0); if (interaction != null) { ((CtiServiceInteraction)interaction).State = InteractionState.Active; OnInteractionConnected(new InteractionEventArgs(interaction)); } } break; case InteractionMessageAction.StateChanged: { IInteraction interaction = Interactions.FirstOrDefault(i => string.Compare(i.Id, message.Interaction.Id.ToString()) == 0); switch (message.Interaction.State) { case SwitchInteractionState.Active: break; case SwitchInteractionState.Held: break; case SwitchInteractionState.Disconnected: case SwitchInteractionState.Completed: if (interaction != null) { OnInteractionDisconnected(new InteractionEventArgs(interaction)); } Interactions.Remove(interaction); OnInteractionCompleted(new InteractionEventArgs(interaction)); CurrentInteraction = Interactions.FirstOrDefault(); break; default: break; } } break; default: break; } }
protected override void InvokeAction(InteractionMessage message) { var flyout = Flyout as Flyout; if (flyout != null) { flyout.IsOpen = true; } }
protected override void InvokeAction(InteractionMessage message) { var information = message as AsyncInputMessage; var window = Window.GetWindow(AssociatedObject) as MetroWindow; if (information != null && window != null) { information.Response = window.ShowInputAsync(information.Caption, information.Text); } }
protected override void InvokeAction(InteractionMessage message) { var m = message as ScrollIntoViewMessage; if (m != null) { var vsp = AssociatedObject.FindVisualChild <VirtualizingStackPanel>(); vsp?.BringIndexIntoViewPublic(m.Index); } }
//Callback (Executed locally on the server) public void OnGameObjectInteraction(NetworkMessage netMsg) { InteractionMessage msg = netMsg.ReadMessage <InteractionMessage> (); Debug.Log("Message received " + msg.ToString()); NetworkInstanceId netId = new NetworkInstanceId(msg.netId); GameObject go = NetworkServer.FindLocalObject(netId); PlayerCommands.OnGameObjectInteraction(go, msg.method, msg.args); }
/// <summary> /// アクション実行 /// </summary> /// <param name="message">メッセージ</param> protected override void InvokeAction(InteractionMessage message) { var setDialogResultMessage = message as SetDialogResultMessage; if (setDialogResultMessage == null) { return; } this.AssociatedObject.DialogResult = setDialogResultMessage.DialogResult; }
private bool?customInteractionHandler(InteractionMessage <EInteractionCustomCallback> im) { switch (im.Custom) { default: return(null); case EInteractionCustomCallback.noActivationCode: return(new ActivationCodeForm(true).ShowDialog() == DialogResult.OK); } }
/// <summary> /// アクション実行 /// </summary> /// <param name="message">メッセージ</param> protected override void InvokeAction(InteractionMessage message) { var setVisibilityMessage = message as SetVisibilityMessage; if (setVisibilityMessage == null) { return; } this.AssociatedObject.Visibility = setVisibilityMessage.Visibility; }
protected override void InvokeAction(InteractionMessage message) { var msg = message as CloseMessage; if (msg.Conditonal) { MessageBox.Show(msg.Text, msg.Caption, MessageBoxButton.OK, msg.Image); this.AssociatedObject.Close(); } }
protected override void InvokeAction(InteractionMessage message) { var confirmation = message as AsyncConfirmationMessage; var window = Window.GetWindow(AssociatedObject) as MetroWindow; if (confirmation != null && window != null) { var task = window.ShowMessageAsync(confirmation.Caption, confirmation.Text, MessageDialogStyle.AffirmativeAndNegative); confirmation.Response = task.ContinueWith(t => ToBoolean(t.Result)); } }
public void SlashCommandMessageRendersCorrectly() { var message = new InteractionMessage(ResponseType.InChannel) { Text = "It's 80 degrees right now." }; var expected = new JObject(new JProperty("response_type", "in_channel"), new JProperty("text", "It's 80 degrees right now.")); Assert.True(JToken.DeepEquals(expected, JObject.FromObject(message))); }
protected override void InvokeAction(InteractionMessage message) { if (message is InformationMessage informationMessage) { MessageBox.Show( informationMessage.Text, informationMessage.Caption, MessageBoxButton.OK, informationMessage.Image ); } }
/// <summary> /// Initializes a new instance of the <see cref="Entry"/> class from <paramref name="message"/>. /// </summary> /// <param name="message">The <see cref="InteractionMessage"/> to initialize from.</param> public Entry(InteractionMessage message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } StartedDateTime = message.Timings.StartedDateTime; Time = Convert.ToInt64(Math.Round(message.Timings.Time.TotalMilliseconds, 0)); Request = new Request(message.Response.RequestMessage); Response = new Response(message.Response); }
/// <summary> /// アクション実行 /// </summary> /// <param name="message"></param> protected override void InvokeAction(InteractionMessage message) { switch (message) { case InformationMessage infoMessage: this.InformationMessage(infoMessage); return; case InformationDialogMessage infoDialogMessage: this.InformationDialogMessage(infoDialogMessage); break; } }
protected override void InvokeAction(InteractionMessage m) { if (!(Window.GetWindow(this.AssociatedObject) is MetroWindow window)) { return; } if (!(m is FlyoutMessage message)) { return; } window.Flyout.Show(ModalFlyout.FromMessage(message.Content)); }
public static InteractionMessage GetMessageWithNewVoteAdded(IList <IMessageBlock> blocks, IList <string> usersVoted) { var responseMessage = new InteractionMessage(true); responseMessage.Blocks = blocks; var block = new Section() { Text = new MarkdownText(usersVoted.Count + " Voted: " + string.Join(", ", usersVoted.Select(u => "@" + u))) }; responseMessage.Blocks[^ 1] = block;
public void QueueInteraction(SwitchInteraction interaction) { interaction.State = SwitchInteractionState.Queued; Interactions.Add(interaction); var message = new InteractionMessage { Interaction = interaction, Action = InteractionMessageAction.Queued }; Parallel.ForEach(GlobalSubscribers, d => _messagingHandler.SendMessage(d, message)); AssignQueuedInteraction(interaction); }
protected override void InvokeAction(InteractionMessage message) { var informationMessage = message as InformationMessage; if (informationMessage != null) { MessageBox.Show( informationMessage.Text, informationMessage.Caption, MessageBoxButton.OK, informationMessage.Image ); } }