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 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); }
/// <summary> /// Prepares the dynamic controls for the operations-message parameters mapping UI. /// </summary> private void SetupOperationsMessagesPanes() { int i = 0; ((ISupportInitialize)ptvServiceOperations).BeginInit(); ptvServiceOperations.SuspendLayout(); // Clear the existing items. serviceInterfaceContract.OperationsCollection.Clear(); ptvServiceOperations.PaneNodes.Clear(); foreach (ListViewItem lvi in operationsListView.Items) { bool found = false; // Check whether the operation already has a property pane or not. foreach (PaneNode proPane in ptvServiceOperations.PaneNodes) { if (lvi.Text == (string)proPane.PropertyPane.Tag) { found = true; break; } } if (found) { continue; } Operation operation = new Operation(); operation.Name = lvi.Text; string mepValue = lvi.SubItems[1].Text; if (mepValue == "One-Way") operation.Mep = Mep.OneWay; else operation.Mep = Mep.RequestResponse; operation.Documentation = ""; string opName = operation.Name; string opNamePrefix = opName.Substring(0, 1); opNamePrefix = opNamePrefix.ToLower(CultureInfo.CurrentCulture); opName = opName.Substring(1, opName.Length - 1); opName = opNamePrefix + opName; Message inMessage = new Message(); inMessage.Name = opName + "In"; inMessage.Documentation = ""; inMessage.Element = messageSchemas[0]; operation.MessagesCollection.Add(inMessage); MessageHeader inHeader = new MessageHeader(); inHeader.Name = inMessage.Name + "Header"; inHeader.Message = inMessage.Name + "Header"; serviceInterfaceContract.OperationsCollection.Add(operation); PropertyPane propPaneOp = new PropertyPane(); propPaneOp.Name = "propPaneOp" + i; propPaneOp.Text = "Operation " + operation.Name; propPaneOp.Tag = operation.Name; // Setup dynamic GUI controls for the pane - Operation LinkLabel addFaultMessage = new LinkLabel(); addFaultMessage.Text = "Add Fault Message"; addFaultMessage.Location = new Point(6, 5); addFaultMessage.Click += addFaultMessage_Clicked; propPaneOp.Controls.Add(addFaultMessage); ptvServiceOperations.PaneNodes.Add(propPaneOp); PropertyPane propPaneInMsg = new PropertyPane(); propPaneInMsg.Name = "propPaneInMsg" + i; propPaneInMsg.Text = "Message " + inMessage.Name; propPaneOp.PaneNodes.Add(propPaneInMsg); propPaneOp.PaneNode.Expanded = true; PropertyPane propPaneOutMsg = null; Message outMessage = null; MessageHeader outHeader = null; if (operation.Mep == Mep.RequestResponse) { outMessage = new Message(); outMessage.Name = opName + "Out"; outMessage.Documentation = ""; outMessage.Element = messageSchemas[0]; operation.MessagesCollection.Add(outMessage); outHeader = new MessageHeader(); outHeader.Name = outMessage.Name + "Header"; outHeader.Message = outMessage.Name + "Header"; propPaneOutMsg = new PropertyPane(); propPaneOutMsg.Name = "propPaneOutMsg" + i; propPaneOutMsg.Text = "Message " + outMessage.Name; propPaneOp.PaneNodes.Add(propPaneOutMsg); propPaneOp.PaneNode.Expanded = true; } // Setup dynamic GUI controls for the pane - Operation TextBox opDocTextBox = new TextBox(); opDocTextBox.Location = new Point(8, 148); opDocTextBox.Multiline = true; opDocTextBox.Name = "outDocTextBox" + i; opDocTextBox.Size = new Size(135, 0); opDocTextBox.DataBindings.Add("Text", operation, "Documentation"); opDocTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; Label opDocLabel = new Label(); opDocLabel.Location = new Point(8, 128); opDocLabel.Name = "outDocLabel" + i; opDocLabel.Size = new Size(88, 23); opDocLabel.Text = "Documentation:"; propPaneOp.Controls.Add(opDocTextBox); propPaneOp.Controls.Add(opDocLabel); // Setup dynamic GUI controls for the pane - InMessage TextBox inDocTextBox = new TextBox(); inDocTextBox.Location = new Point(8, 168); inDocTextBox.Multiline = true; inDocTextBox.Name = "inDocTextBox" + i; inDocTextBox.Size = new Size(135, 0); inDocTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; Label inMessageParameterLabel = new Label(); inMessageParameterLabel.Location = new Point(6, 5); inMessageParameterLabel.Name = "inMessageParameterLabel" + i; inMessageParameterLabel.Size = new Size(55, 33); inMessageParameterLabel.Text = "Message body:"; CheckBox inMessageNameCheckBox = new CheckBox(); inMessageNameCheckBox.Location = new Point(9, 44); inMessageNameCheckBox.Name = "inMessageNameCheckBox" + i; inMessageNameCheckBox.Text = "Message name (optional)"; inMessageNameCheckBox.Size = new Size(220, 25); TextBox inMessageNameTextBox = new TextBox(); inMessageNameTextBox.Location = new Point(8, 69); inMessageNameTextBox.Name = "inMessageNameTextBox" + i; inMessageNameTextBox.Size = new Size(142, 20); inMessageNameTextBox.Enabled = false; inMessageNameTextBox.Text = inMessage.Name; inMessageNameTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; ComboBox inMessageParamsCombo = new ComboBox(); inMessageParamsCombo.DropDownStyle = ComboBoxStyle.DropDownList; inMessageParamsCombo.Location = new Point(65, 5); inMessageParamsCombo.Name = "inMessageParamsCombo" + i; inMessageParamsCombo.Size = new Size(80, 21); inMessageParamsCombo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; // Fill the combo box with the Message values. foreach (SchemaElement element in this.messageSchemas) { inMessageParamsCombo.Items.Add(element.ElementName); } inMessageParamsCombo.SelectedIndex = 0; operation.Input = inMessage; // Import the parameters from WSDL file for round tripping. string originalOperationName = ""; if (lvi.Tag != null) { originalOperationName = lvi.Tag.ToString(); } 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 = new CheckBox(); inMessageHeaderCheckBox.Location = new Point(9, 95); inMessageHeaderCheckBox.Name = "inMessageHeaderCheckBox" + i; inMessageHeaderCheckBox.Text = "Message headers (optional)"; inMessageHeaderCheckBox.Size = new Size(181, 25); ComboBox inMessageHeaderCombo = new ComboBox(); inMessageHeaderCombo.DropDownStyle = ComboBoxStyle.DropDownList; inMessageHeaderCombo.Location = new Point(8, 120); inMessageHeaderCombo.Enabled = false; inMessageHeaderCombo.Name = "inMessageHeaderCombo" + i; inMessageHeaderCombo.Size = new Size(100, 21); inMessageHeaderCombo.Items.Add("<New...>"); inMessageHeaderCombo.SelectedIndex = 0; inMessageHeaderCombo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; // Import headers from WSDL file for round tripping. MessagesCollection addedInHeaderMsgs = ImportMessageHeaders(operation, inMessage, inMessageHeaderCombo, inMessageHeaderCheckBox, false); // Attach the dynamic combo box event handler. inMessageHeaderCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); LinkLabel inRemoveHeaderLink = new LinkLabel(); inRemoveHeaderLink.Text = "Remove"; inRemoveHeaderLink.Location = new Point(193, 95); inRemoveHeaderLink.Size = new Size(64, 25); inRemoveHeaderLink.TextAlign = ContentAlignment.MiddleRight; inRemoveHeaderLink.Visible = (addedInHeaderMsgs != null); // 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, this.headerSchemas, inRemoveHeaderLink, addedInHeaderMsgs); OperationDocumentationTextBoxController odtbc = new OperationDocumentationTextBoxController(opDocTextBox, operation); MessageDocumentationTextBoxController mdtbc = new MessageDocumentationTextBoxController(inDocTextBox, inMessage); Label inDocLabel = new Label(); inDocLabel.Location = new Point(8, 149); inDocLabel.Name = "inDocLabel" + i; inDocLabel.Size = new Size(88, 23); inDocLabel.Text = "Documentation:"; // 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); // Setup dynamic GUI controls for the pane - OutMessage if (operation.Mep == Mep.RequestResponse) { TextBox outDocTextBox = new TextBox(); outDocTextBox.Location = new Point(8, 165); outDocTextBox.Multiline = true; outDocTextBox.Name = "outDocTextBox" + i; outDocTextBox.Size = new Size(135, 0); outDocTextBox.DataBindings.Add("Text", outMessage, "Documentation"); outDocTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; Label outMessageParameterLabel = new Label(); outMessageParameterLabel.Location = new Point(6, 5); outMessageParameterLabel.Name = "outMessageParameterLabel" + i; outMessageParameterLabel.Size = new Size(55, 33); outMessageParameterLabel.Text = "Message body:"; CheckBox outMessageNameCheckBox = new CheckBox(); outMessageNameCheckBox.Location = new Point(9, 44); outMessageNameCheckBox.Name = "outMessageNameCheckBox" + i; outMessageNameCheckBox.Text = "Message name (optional)"; outMessageNameCheckBox.Size = new Size(220, 25); TextBox outMessageNameTextBox = new TextBox(); outMessageNameTextBox.Location = new Point(8, 69); outMessageNameTextBox.Name = "outMessageNameTextBox" + i; outMessageNameTextBox.Size = new Size(142, 20); outMessageNameTextBox.Enabled = false; outMessageNameTextBox.Text = outMessage.Name; outMessageNameTextBox.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; ComboBox outMessageParamsCombo = new ComboBox(); outMessageParamsCombo.DropDownStyle = ComboBoxStyle.DropDownList; outMessageParamsCombo.Location = new Point(65, 5); outMessageParamsCombo.Name = "outMessageParamsCombo" + i; outMessageParamsCombo.Size = new Size(80, 21); outMessageParamsCombo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; // Fill the combo box with the Message values. foreach (SchemaElement element in this.messageSchemas) { outMessageParamsCombo.Items.Add(element.ElementName); } outMessageParamsCombo.SelectedIndex = 0; 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 = new CheckBox(); outMessageHeaderCheckBox.Location = new Point(9, 95); outMessageHeaderCheckBox.Name = "outMessageHeaderCheckBox" + i; outMessageHeaderCheckBox.Text = "Message headers (optional)"; outMessageHeaderCheckBox.Size = new Size(181, 25); ComboBox outMessageHeaderCombo = new ComboBox(); outMessageHeaderCombo.DropDownStyle = ComboBoxStyle.DropDownList; outMessageHeaderCombo.Location = new Point(8, 120); outMessageHeaderCombo.Enabled = false; outMessageHeaderCombo.Name = "outMessageHeaderCombo" + i; outMessageHeaderCombo.Size = new Size(100, 21); outMessageHeaderCombo.Items.Add("<New...>"); outMessageHeaderCombo.SelectedIndex = 0; outMessageHeaderCombo.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; // Import headers from an existing WSDL file for round tripping. MessagesCollection addedOutHeaderMsgs = ImportMessageHeaders(operation, outMessage, outMessageHeaderCombo, outMessageHeaderCheckBox, true); // Attach the dynamic combo box event handler. outMessageHeaderCombo.SelectedIndexChanged += new EventHandler(DynamicComboBox_SelectedIndexChanged); LinkLabel outRemoveHeaderLink = new LinkLabel(); outRemoveHeaderLink.Text = "Remove"; outRemoveHeaderLink.Location = new Point(193, 95); outRemoveHeaderLink.Size = new Size(64, 25); outRemoveHeaderLink.TextAlign = ContentAlignment.MiddleRight; outRemoveHeaderLink.Visible = (addedOutHeaderMsgs != null); // 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, headerSchemas, outRemoveHeaderLink, addedOutHeaderMsgs); MessageDocumentationTextBoxController outdtbc = new MessageDocumentationTextBoxController(outDocTextBox, outMessage); Label outDocLabel = new Label(); outDocLabel.Location = new Point(8, 149); outDocLabel.Name = "outDocLabel" + i; outDocLabel.Size = new Size(88, 23); outDocLabel.Text = "Documentation:"; // 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); } ImportFaultMessages(propPaneOp.PaneNode, operation, originalOperationName); i++; } oldOperations = (OperationsCollection)serviceInterfaceContract.OperationsCollection.Clone(); ((ISupportInitialize)ptvServiceOperations).EndInit(); ptvServiceOperations.ResumeLayout(false); }