/// <summary> /// Prompts a dialog box to select the new header. Once it is selected this method adds it to /// <see cref="Message.HeadersCollection"/>. Also this method creates a new <see cref="Message"/> /// for the header and puts it to the <see cref="Operation.MessagesCollection"/>. /// </summary> private void AddNewHeader() { SchemaElement newHeaderMessage = new SchemaElement(); SelectHeaderDialog dialog = new SelectHeaderDialog(this.headerElements, ref newHeaderMessage); dialog.ShowDialog(); if(newHeaderMessage.ElementName != null) { // First check whether the header already exists. And remove it if it does. foreach(Message msg in this.headerMessages) { if(newHeaderMessage.ElementName == msg.Element.ElementName && newHeaderMessage.ElementNamespace == msg.Element.ElementNamespace) { // Set the last item before returning. SelectTheLatestHeader(); return; // Exit without adding. } } string headerName = ""; int index = 1; while(headerName == "") { headerName = currentMessage.Name + "Header" + index.ToString(); foreach(MessageHeader hdr in currentMessage.HeadersCollection) { if(hdr.Name == headerName) { headerName = ""; index++; break; } } } // Create the header message. headerMessage = new Message(); headerMessage.Name = headerName; // currentMessage.Name + "Header" + headerNo; headerMessage.Documentation = ""; headerMessage.Element.ElementName = newHeaderMessage.ElementName; headerMessage.Element.ElementNamespace = newHeaderMessage.ElementNamespace; // Create the header. MessageHeader newHeader = new MessageHeader(); newHeader.Message = headerMessage.Name; newHeader.Name = headerMessage.Name; // Add header to the current message. currentMessage.HeadersCollection.Add(newHeader); // Add the new header message to the messages collection. currentOperation.MessagesCollection.Add(headerMessage); // Added the newly created header message to the header messages collection. // Reason: In case we need to remove the header messages we need to distinguish // them from the existing messages. this.headerMessages.Add(headerMessage); // Add the newly added header info to the headers combo box. currentComboBox.Items.Insert(currentComboBox.Items.Count - 1, headerMessage.Element.ElementName); // Set the last selected header message as the default header. currentComboBox.SelectedIndex = currentComboBox.Items.Count - 2; } }
/// <summary> /// Initializes a new instance of OutHeaderComboBoxController class with specified values. /// </summary> /// <param name="headerComboBox">Reference to the combo box which contains the headers.</param> /// <param name="headerCheckBox">Reference to the check box which indicates whether to use the message header(s) or not.</param> /// <param name="messageNameTextBox">Reference to the text box which contains the customized message name.</param> /// <param name="operation">Reference to the instance of <see cref="Operation"/> class, <see cref="MessageHeader"/> belongs to.</param> /// <param name="message">Reference to the instance of <see cref="Message"/> class, <see cref="MessageHeader"/> belongs to.</param> /// <param name="header">Reference to the current <see cref="MessageHeader"/> of the message.</param> /// <param name="headerElements">Reference to an instance of <see cref="SchemaElements"/> class with schema elements for headers.</param> /// <param name="removeButton">Reference to the link label control used to remove headers.</param> /// <param name="addedMessages">Reference to an instance of <see cref="MessagesCollection"/> class with <see cref="Message"/> objects added for the header.</param> public OutHeaderComboBoxController(ComboBox headerComboBox, CheckBox headerCheckBox, TextBox messageNameTextBox, Operation operation, Message message, MessageHeader header, List<SchemaElement> headerElements, LinkLabel removeButton, IEnumerable<Message> addedMessages) { currentComboBox = headerComboBox; currentCheckBox = headerCheckBox; currentMessageNameTextBox = messageNameTextBox; currentOperation = operation; currentMessage = message; currentHeader = header; this.headerElements = headerElements; this.headerMessages = new List<Message>(); if(addedMessages != null) { foreach(Message impHeader in addedMessages) { this.headerMessages.Add(impHeader); } } this.currentRemoveButton = removeButton; this.showDialog = true; // Attach the event handlers. currentCheckBox.CheckedChanged += new EventHandler(CheckBox_CheckedChanged); currentComboBox.SelectedIndexChanged += new EventHandler(ComboBox_SelectedIndexChanged); currentMessageNameTextBox.LostFocus += new EventHandler(TextBox_FocusOver); currentRemoveButton.Click += new EventHandler(this.RemoveLink_Click); }
private void CreateOutputPane(Operation operation, int opIndex, TextBox opDocTextBox, Message outMessage, PropertyPane propPaneOutMsg, string originalOperationName, MessageHeader outHeader) { Label outMessageParameterLabel; CheckBox outMessageNameCheckBox; TextBox outMessageNameTextBox; ComboBox outMessageParamsCombo; TextBox outDocTextBox = SetupOutputMessageDynamicControls(opIndex, outMessage, out outMessageParameterLabel, out outMessageNameCheckBox, out outMessageNameTextBox, out outMessageParamsCombo); operation.Output = outMessage; // Import the parameters from an existing WSDL file for round tripping. ImportMessageParameter(operation, true, outMessageParamsCombo, outMessageNameCheckBox, outMessageNameTextBox, propPaneOutMsg, opDocTextBox, outDocTextBox, originalOperationName); // Attach the dynamic combo box event handler. outMessageParamsCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); CheckBox outMessageHeaderCheckBox = CreateOutMessageHeaderCheckBox(opIndex); ComboBox outMessageHeaderCombo = CreateOutMessageHeaderCombo(opIndex); // Import headers from an existing WSDL file for round tripping. List<Message> addedOutHeaderMsgs = ImportMessageHeaders(operation, outMessage, outMessageHeaderCombo, outMessageHeaderCheckBox, true); // Attach the dynamic combo box event handler. outMessageHeaderCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); LinkLabel outRemoveHeaderLink = CreateOutRemoveHeaderLink(addedOutHeaderMsgs); // outRemoveHeaderLink.Anchor = AnchorStyles.Right; // Initialize the dynamic control controllers. MessagePaneLabelController mplcOut = new MessagePaneLabelController(outMessageNameTextBox, propPaneOutMsg); MessageNameTextBoxController mntbcOut = new MessageNameTextBoxController(outMessageNameTextBox, outMessageNameCheckBox, outMessage, propPaneOutMsg); OutHeaderComboBoxController hcbcOut = new OutHeaderComboBoxController(outMessageHeaderCombo, outMessageHeaderCheckBox, outMessageNameTextBox, operation, outMessage, outHeader, serviceInterfaceContract.HeaderSchemas, outRemoveHeaderLink, addedOutHeaderMsgs); MessageDocumentationTextBoxController outdtbc = new MessageDocumentationTextBoxController(outDocTextBox, outMessage); Label outDocLabel = CreateOutDocLabel(opIndex); // Finally add the generated controls to the container. propPaneOutMsg.Controls.Add(outDocTextBox); propPaneOutMsg.Controls.Add(outDocLabel); propPaneOutMsg.Controls.Add(outMessageParameterLabel); propPaneOutMsg.Controls.Add(outMessageNameTextBox); propPaneOutMsg.Controls.Add(outMessageParameterLabel); propPaneOutMsg.Controls.Add(outMessageParamsCombo); propPaneOutMsg.Controls.Add(outMessageNameCheckBox); propPaneOutMsg.Controls.Add(outMessageHeaderCombo); propPaneOutMsg.Controls.Add(outMessageHeaderCheckBox); propPaneOutMsg.Controls.Add(outRemoveHeaderLink); }
private MessageHeader AddOutputMessageHeader(string outputMessageName) { MessageHeader outHeader; outHeader = new MessageHeader(); outHeader.Name = outputMessageName + "Header"; outHeader.Message = outputMessageName + "Header"; return outHeader; }
private string CreateInputPane(string opName, Operation operation, string inputMessageName, Message inMessage, int opIndex, TextBox opDocTextBox, PropertyPane propPaneInMsg, MessageHeader inHeader) { Label inMessageParameterLabel; CheckBox inMessageNameCheckBox; TextBox inMessageNameTextBox; ComboBox inMessageParamsCombo; TextBox inDocTextBox = SetupInputMessageDynamicControls(inputMessageName, opIndex, out inMessageParameterLabel, out inMessageNameCheckBox, out inMessageNameTextBox, out inMessageParamsCombo); // Import the parameters from WSDL file for round tripping. string originalOperationName = ""; if (opName != null) { originalOperationName = opName; } ImportMessageParameter(operation, false, inMessageParamsCombo, inMessageNameCheckBox, inMessageNameTextBox, propPaneInMsg, opDocTextBox, inDocTextBox, originalOperationName); // Attach the dynamic combo box event handler. inMessageParamsCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); CheckBox inMessageHeaderCheckBox = CreateInMessageHeaderCheckBox(opIndex); ComboBox inMessageHeaderCombo = CreateInMessageHeaderCombo(opIndex); // Import headers from WSDL file for round tripping. List<Message> addedInHeaderMsgs = ImportMessageHeaders(operation, inMessage,inMessageHeaderCombo, inMessageHeaderCheckBox, false); // Attach the dynamic combo box event handler. inMessageHeaderCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); LinkLabel inRemoveHeaderLink = CreateInRemoveHeaderLink(addedInHeaderMsgs); // inRemoveHeaderLink.Anchor = AnchorStyles.Right; // Initialize the dynamic control controllers. MessagePaneLabelController mplcIn = new MessagePaneLabelController(inMessageNameTextBox, propPaneInMsg); MessageNameTextBoxController mntbcIn = new MessageNameTextBoxController(inMessageNameTextBox, inMessageNameCheckBox, inMessage, propPaneInMsg); InHeaderComboBoxController hcbcIn = new InHeaderComboBoxController(inMessageHeaderCombo, inMessageHeaderCheckBox, inMessageNameTextBox, operation, inMessage, inHeader, serviceInterfaceContract.HeaderSchemas, inRemoveHeaderLink, addedInHeaderMsgs); OperationDocumentationTextBoxController odtbc = new OperationDocumentationTextBoxController(opDocTextBox, operation); MessageDocumentationTextBoxController mdtbc = new MessageDocumentationTextBoxController(inDocTextBox, inMessage); Label inDocLabel = CreateInDocLabel(opIndex); // Finally add the controls to the container. propPaneInMsg.Controls.Add(inDocTextBox); propPaneInMsg.Controls.Add(inDocLabel); propPaneInMsg.Controls.Add(inMessageParameterLabel); propPaneInMsg.Controls.Add(inMessageNameTextBox); propPaneInMsg.Controls.Add(inMessageParameterLabel); propPaneInMsg.Controls.Add(inMessageParamsCombo); propPaneInMsg.Controls.Add(inMessageNameCheckBox); propPaneInMsg.Controls.Add(inMessageHeaderCombo); propPaneInMsg.Controls.Add(inMessageHeaderCheckBox); propPaneInMsg.Controls.Add(inRemoveHeaderLink); return originalOperationName; }
private MessageHeader AddInputMessageHeader(string inputMessageName) { MessageHeader inHeader = new MessageHeader(); inHeader.Name = inputMessageName + "Header"; inHeader.Message = inputMessageName + "Header"; return inHeader; }