示例#1
0
        private void ConnectButton_Click(object sender, RoutedEventArgs e)
        {
            if (sender == ConnectButton)
            {
                ServerWindow = new ServerWindow(AddressText.Text, int.Parse(PortText.Text));
                FullAddress  = AddressText.Text + ':' + PortText.Text;
                ServerWindow.Show();
            }

            Close();
        }
示例#2
0
        private void StartupButton_Click(object sender, RoutedEventArgs e)
        {
            if (StartupButton.Content.ToString() == "Start")
            {
                StartupButton.Content = "Stop";

                DataWindow dataWindow = new DataWindow(mediator);
                dataWindow.Show();

                WindowCheckBox checkBox = new WindowCheckBox(dataWindow, "Data transfer monitor");
                WindowCombo.Items.Add(checkBox);

                string listenString = ListenPortText.Text;
                string connection   = ConStringText.Text;
                int    port;
                if (connection.StartsWith("~") && int.TryParse(connection.Substring(1), out port))
                {
                    connection = "localhost:" + connection.Substring(1);
                    ServerWindow serverWindow = new ServerWindow(port);
                    serverWindow.Show();

                    checkBox = new WindowCheckBox(serverWindow, "Server emulator");
                    WindowCombo.Items.Add(checkBox);
                }

                Listen.ListenType listenType = Listen.ListenType.TCP;
                switch (ListenCombo.SelectedIndex)
                {
                case 0: listenType = Listen.ListenType.TCP; break;

                case 1: listenType = Listen.ListenType.HTTP; break;
                }

                Connector.ConnectionType connectionType = Connector.ConnectionType.TCP;
                switch (ConTypeCombo.SelectedIndex)
                {
                case 0: connectionType = Connector.ConnectionType.TCP; break;

                case 1: connectionType = Connector.ConnectionType.Serial; break;

                case 2: connectionType = Connector.ConnectionType.HTTP; break;
                }

                mediator.Start(listenType, listenString, connectionType, connection);
                Common.Log.Info("Started " + connectionType + connection);
            }
            else
            {
                StartupButton.Content = "Start";

                for (int i = WindowCombo.Items.Count - 1; i > 0; i--)
                {
                    WindowCheckBox checkBox = WindowCombo.Items[i] as WindowCheckBox;
                    checkBox.Dispose();
                    WindowCombo.Items.Remove(checkBox);
                }

                mediator.Stop();
                Common.Log.Info("Stopped");
            }
        }