private void EnableMessageAppending(UserControl_Bordered_MessageTreeMessage control)
        {
            MenuItem menuItem_messageAppending = new MenuItem() { Header = "Append Message" };
            menuItem_messageAppending.Click += (x, y) =>
                {
                    var window_messageChoice =
                        new Window_MessageChoice
                        (
                            null,
                            string.Format("{0} - XYZ Choice", control.MessageName),
                            "\"...\"",
                            MessageId,
                            (win) =>
                            {
                                Window_MessageChoice wWin = win as Window_MessageChoice;
                                if (wWin != null)
                                {
                                    int selectedMessageId = -1;
                                    ComboBox_Message comboBox_message = new ComboBox_Message();
                                    comboBox_message.SelectionChanged += (w, v) =>
                                    {
                                        var cb = w as ComboBox_Message;
                                        ComboBox_Message.ComboBoxItem_Message cbi;
                                        if (cb != null && cb == comboBox_message && (cbi = cb.SelectedItem as ComboBox_Message.ComboBoxItem_Message) != null)
                                            selectedMessageId = cbi.MessageId;
                                    };
                                    comboBox_message.SetActiveAndRegisterForGinTubEvents();
                                    GinTubBuilderManager.ReadAllMessages();

                                    var window_message =
                                        new Window_TaskOnAccept
                                        (
                                            "Select Message",
                                            (wwWin) =>
                                            {
                                                Window_TaskOnAccept wwwWin = wwWin as Window_TaskOnAccept;
                                                if (wwwWin != null)
                                                {
                                                    // This is a preeeetty hack-y way to handle this, but you reap what you sow
                                                    int
                                                        newMessageChoiceId = -1,
                                                        newResultId = -1;
                                                    GinTubBuilderManager.MessageChoiceReadEventHandler messageChoiceReadHandler = new GinTubBuilderManager.MessageChoiceReadEventHandler((sender, args) =>
                                                        {
                                                            newMessageChoiceId = args.Id;
                                                        });
                                                    GinTubBuilderManager.ResultReadEventHandler resultReadHandler = new GinTubBuilderManager.ResultReadEventHandler((sender, args) =>
                                                        {
                                                            newResultId = args.Id;
                                                        });

                                                    GinTubBuilderManager.MessageChoiceRead += messageChoiceReadHandler;
                                                    GinTubBuilderManager.CreateMessageChoice(wWin.MessageChoiceName, wWin.MessageChoiceText, control.MessageId.Value);
                                                    GinTubBuilderManager.MessageChoiceRead -= messageChoiceReadHandler;

                                                    GinTubBuilderManager.ResultRead += resultReadHandler;
                                                    // TODO: less hardcoding here
                                                    GinTubBuilderManager.CreateResult
                                                    (
                                                        string.Format("Message - {0} NEXT", control.MessageName),
                                                        "{\"messageId\":" + selectedMessageId.ToString() + "}",
                                                        10 // MAGIC NUMBER
                                                    );
                                                    GinTubBuilderManager.ResultRead -= resultReadHandler;

                                                    GinTubBuilderManager.CreateMessageChoiceResult(newResultId, newMessageChoiceId);

                                                    GinTubBuilderManager.ReadMessageTreeForMessage(control.MessageId.Value, control.MessageParentMessageChoiceId);
                                                }
                                            }
                                        );
                                    window_message.Content = comboBox_message;
                                    window_message.ShowDialog();
                                }
                            }
                        );
                    window_messageChoice.ShowDialog();

                };

            ContextMenu contextMenu_messageAppending = new ContextMenu();
            contextMenu_messageAppending.Items.Add(menuItem_messageAppending);

            control.ContextMenu = contextMenu_messageAppending;
        }
 private void Button_UpdateMessageChoice_Click(object sender, RoutedEventArgs e)
 {
     Window_MessageChoice window =
         new Window_MessageChoice
         (
             m_userControl_messageChoice.MessageChoiceId,
             m_userControl_messageChoice.MessageChoiceName,
             m_userControl_messageChoice.MessageChoiceText,
             m_userControl_messageChoice.MessageId,
             (win) =>
             {
                 Window_MessageChoice wWin = win as Window_MessageChoice;
                 if (wWin != null)
                     GinTubBuilderManager.UpdateMessageChoice
                     (
                         wWin.MessageChoiceId.Value,
                         wWin.MessageChoiceName,
                         wWin.MessageChoiceText,
                         wWin.MessageId
                     );
             }
         );
     window.Show();
 }
 private void NewMessageChoiceDialog()
 {
     Window_MessageChoice window =
         new Window_MessageChoice
         (
             null,
             null,
             null,
             MessageId,
             (win) =>
             {
                 Window_MessageChoice wWin = win as Window_MessageChoice;
                 if (wWin != null)
                     GinTubBuilderManager.CreateMessageChoice
                     (
                         wWin.MessageChoiceName,
                         wWin.MessageChoiceText,
                         wWin.MessageId
                     );
             }
         );
     window.Show();
 }