コード例 #1
0
        private void bundleAddButton_Click(object sender, EventArgs e)
        {
            if (bundleFromComboBox.SelectedIndex >= 0 && bundleToComboBox.SelectedIndex >= 0)
            {
                bool sameConnectionExist = false;
                foreach (string key in simulator.BundleList.Keys)
                {
                    if (simulator.BundleList[key].SendLayer.Name == (string)bundleFromComboBox.SelectedItem && simulator.BundleList[key].ReceiveLayer.Name == (string)bundleToComboBox.SelectedItem)
                    {
                        sameConnectionExist = true;
                    }
                }

                if (sameConnectionExist)
                {
                    MessageBox.Show("Already the same connection exist.");
                }
                else if (simulator.BundleList.ContainsKey(bundleNameTextBox.Text))
                {
                    MessageBox.Show("Already the same name exist.");
                }
                else if (bundleNameTextBox.Text.Trim() == "")
                {
                    MessageBox.Show("Bundle has to be assigned the name.");
                }
                else
                {
                    simulator.BundleMaking(bundleNameTextBox.Text, (string)bundleFromComboBox.SelectedItem, (string)bundleToComboBox.SelectedItem);
                    Refresh();
                }
            }

            bundleNameTextBox.Focus();
            bundleNameTextBox.SelectAll();
        }