Пример #1
0
        public ButtonSetupForm(ButtonMapping m)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            buttonMapping   = m;
            this.Parameters = buttonMapping.Parameters;

            DialogResult = DialogResult.Cancel;

            MainForm.Instance.ChannelDataUpdate += onChannelDataUpdate;

            Disposed += (object sender, EventArgs e) => {
                MainForm.Instance.ChannelDataUpdate -= onChannelDataUpdate;
            };

            checkInvert.Checked           = Parameters.invert;
            checkTwoThresholds.Checked    = Parameters.notch;
            numericThresh1.Value          = Parameters.thresh1;
            numericThresh2.Value          = Parameters.thresh2;
            comboFailsafe.SelectedIndex   = Parameters.Failsafe;
            checkTriggerEnable.Checked    = Parameters.Trigger;
            comboTrigerEdge.SelectedIndex = (int)Parameters.TriggerEdge;
            numericTriggerDuration.Value  = Parameters.TriggerDuration == 0 ? TriggerState.DEFAULT_DURATION : Parameters.TriggerDuration;

            initialized = true;

            OnChange(null, null);
        }
Пример #2
0
        public ButtonSetupForm(ButtonMapping m)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            buttonMapping   = m;
            this.parameters = buttonMapping.Parameters;

            DialogResult = DialogResult.Cancel;

            MainForm.Instance.ChannelDataUpdate += onChannelDataUpdate;

            Disposed += delegate(object sender, EventArgs e) {
                MainForm.Instance.ChannelDataUpdate -= onChannelDataUpdate;
            };

            checkInvert.Checked        = parameters.invert;
            checkTwoThresholds.Checked = parameters.notch;
            numericThresh1.Value       = parameters.thresh1;
            numericThresh2.Value       = parameters.thresh2;

            initialized = true;

            OnChange(null, null);
        }
Пример #3
0
        void OnChange(object sender, EventArgs e)
        {
            if (!initialized)
            {
                return;
            }

            if (!checkTwoThresholds.Checked)
            {
                numericThresh2.Enabled  = false;
                labelThresh2.Enabled    = false;
                buttonCalibrate.Enabled = true;
            }
            else
            {
                numericThresh2.Enabled  = true;
                labelThresh2.Enabled    = true;
                buttonCalibrate.Enabled = false;

                if (numericThresh2.Value < numericThresh1.Value)
                {
                    numericThresh2.Value = numericThresh1.Value;
                }
            }

            numericTriggerDuration.Enabled = comboTrigerEdge.Enabled = checkTriggerEnable.Checked;

            Parameters = new ButtonMapping.ButtonParameters()
            {
                notch           = checkTwoThresholds.Checked,
                invert          = checkInvert.Checked,
                thresh1         = (int)numericThresh1.Value,
                thresh2         = (int)numericThresh2.Value,
                Failsafe        = comboFailsafe.SelectedIndex,
                Trigger         = checkTriggerEnable.Checked,
                TriggerEdge     = (TriggerState.Edge)comboTrigerEdge.SelectedIndex,
                TriggerDuration = (int)numericTriggerDuration.Value
            };

            pictureBox.Invalidate();
        }