コード例 #1
0
        private void Disconnect(FeedbackEncoderConnection connection)
        {
            if (connection == null)
            {
                MessageBox.Show("This feedback output is not connected.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            try
            {
                // Delete the connection
                FeedbackEncoderConnection.Delete(connection);

                // Remove both links from the element and the output
                connection.EncoderInput.FeedbackConnection = null;
                connection.Element.FeedbackConnections.Remove(connection);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.RefreshConnectionList();
            }
        }
コード例 #2
0
        private void Connect(int inputPin, FeedbackEncoderConnection connection)
        {
            try
            {
                if (connection != null)
                {
                    if (MessageBox.Show("The selected output is currently connected. Are you sure you want to connect the output to another encoder input?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        return;
                    }
                }

                FeedbackConnectionFindView form = new FeedbackConnectionFindView(connection);
                if (form.ShowDialog(this) == DialogResult.Cancel)
                {
                    return;
                }

                // Delete the existing connection
                if (connection != null)
                {
                    FeedbackEncoderConnection.Delete(connection);

                    connection.EncoderInput.FeedbackConnection = null;
                    connection.Element.FeedbackConnections.Remove(connection);
                }

                FeedbackEncoderConnection newconnection = new FeedbackEncoderConnection();
                newconnection.EncoderInput    = form.SelectedInput;
                newconnection.Element         = this.Element;
                newconnection.ElementPinIndex = inputPin;
                FeedbackEncoderConnection.Save(newconnection);

                form.SelectedInput.FeedbackConnection = newconnection;
                this.Element.FeedbackConnections.Add(newconnection);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.RefreshConnectionList();
            }
        }