/// <summary>
        /// toolStripMenuItemReceivePort DropDownItemClicked event to set the receive port.
        /// </summary>
        private void toolStripMenuItemReceivePort_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            ushort port;

            if (((ToolStripMenuItem)e.ClickedItem).Text == "...")
            {
                FormGetValue formGetValue = new FormGetValue();
                formGetValue.CheckString += (delegate(string currentValue)
                {
                    try
                    {
                        ushort.Parse(currentValue);
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                });
                formGetValue.ShowDialog();
                try
                {
                    if (formGetValue.value == "")
                    {
                        return;
                    }
                    port = ushort.Parse(formGetValue.value);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
            }
            else
            {
                port = ushort.Parse(((ToolStripMenuItem)e.ClickedItem).Text);
            }
            OpenReceiver(port);
        }
        /// <summary>
        /// toolStripMenuItemSendMessage DropDownItemClicked task called by event or programmatically.
        /// </summary>
        /// <param name="text">
        /// DropDownItem text to be processed.
        /// </param>
        private void toolStripMenuItemSendMessage_DropDownItemClicked_Task(string text)
        {
            // Create message from string
            string oscMessageString;

            if (text == "...")
            {
                FormGetValue formGetValue = new FormGetValue();
                formGetValue.CheckString += (delegate(string currentValue)
                {
                    try
                    {
                        OscMessage.Parse(currentValue);
                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                });
                formGetValue.ShowDialog();
                try
                {
                    if (formGetValue.value == "")
                    {
                        return;
                    }
                    OscMessage.Parse(formGetValue.value);
                    oscMessageString = formGetValue.value;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
            }
            else
            {
                oscMessageString = text;
            }

            // Update message list
            if (!sentMessageStrings.Contains(oscMessageString))
            {
                sentMessageStrings.Add(oscMessageString);
                sentMessageStrings.Sort();
            }
            toolStripMenuItemSendMessage.DropDownItems.Clear();
            foreach (string s in sentMessageStrings)
            {
                toolStripMenuItemSendMessage.DropDownItems.Add(s);
            }
            toolStripMenuItemSendMessage.DropDownItems.Add("...");

            // Check selected port
            foreach (ToolStripMenuItem toolStripMenuItem in toolStripMenuItemSendMessage.DropDownItems)
            {
                if (toolStripMenuItem.Text == oscMessageString)
                {
                    toolStripMenuItem.Checked = true;
                }
            }

            // Set selected send message
            selectedSendMessage = OscMessage.Parse(oscMessageString);
        }
        /// <summary>
        /// toolStripMenuItemSendPortIP DropDownItemClicked event to set the send port/IP.
        /// </summary>
        private void toolStripMenuItemSendPortIP_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            bool itemIsPort = true;

            // Determine if port or IP item clicked
            foreach (object o in toolStripMenuItemSendPortIP.DropDownItems)
            {
                if (o is ToolStripMenuItem)
                {
                    if (((ToolStripMenuItem)e.ClickedItem) == (ToolStripMenuItem)o)
                    {
                        break;
                    }
                }
                else if (o is ToolStripSeparator)
                {
                    itemIsPort = false;
                    break;
                }
            }

            // Process selected port item
            if (itemIsPort)
            {
                ushort port;
                if (((ToolStripMenuItem)e.ClickedItem).Text == "...")
                {
                    FormGetValue formGetValue = new FormGetValue();
                    formGetValue.CheckString += (delegate(string currentValue)
                    {
                        try
                        {
                            ushort.Parse(currentValue);
                            return(true);
                        }
                        catch
                        {
                            return(false);
                        }
                    });
                    formGetValue.ShowDialog();
                    try
                    {
                        if (formGetValue.value == "")
                        {
                            return;
                        }
                        port = ushort.Parse(formGetValue.value);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }
                }
                else
                {
                    port = ushort.Parse(((ToolStripMenuItem)e.ClickedItem).Text);
                }
                OpenSender(port, oscSender.RemoteAddress);
            }

            // Process selected IP item
            if (!itemIsPort)
            {
                IPAddress ipAddress;
                if (((ToolStripMenuItem)e.ClickedItem).Text == "...")
                {
                    FormGetValue formGetValue = new FormGetValue();
                    formGetValue.CheckString += (delegate(string currentValue)
                    {
                        try
                        {
                            IPAddress.Parse(currentValue);
                            return(true);
                        }
                        catch
                        {
                            return(false);
                        }
                    });
                    formGetValue.ShowDialog();
                    try
                    {
                        if (formGetValue.value == "")
                        {
                            return;
                        }
                        ipAddress = IPAddress.Parse(formGetValue.value);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        return;
                    }
                }
                else
                {
                    ipAddress = IPAddress.Parse(((ToolStripMenuItem)e.ClickedItem).Text);
                }
                OpenSender((ushort)oscSender.Port, ipAddress);
            }
        }
 /// <summary>
 /// toolStripMenuItemReceivePort DropDownItemClicked event to set the receive port
 /// </summary>
 private void toolStripMenuItemReceivePort_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     ushort port;
     if (((ToolStripMenuItem)e.ClickedItem).Text == "...")
     {
         FormGetValue formGetValue = new FormGetValue();
         formGetValue.ShowDialog();
         try
         {
             port = ushort.Parse(formGetValue.value);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             return;
         }
     }
     else
     {
         port = ushort.Parse(((ToolStripMenuItem)e.ClickedItem).Text);
     }
     OpenReceiver(port);
 }