private void _updateAllControlsFromRule(KeyStrokeDB rule)
        {
            // Cancel selectindex events because we are refreshing
            NoSelectedIndexDueToOngoingRefresh = true;

            // Clean some things that could lead to hazardous editing error.
            // Limit number of elements.
            rule.KeySources.RemoveRange(3, rule.KeySources.Count - 3);
            rule.KeySourcesOperators.RemoveRange(2, rule.KeySourcesOperators.Count - 2);

            // Now update
            this.txtKeyRuleName.Text = rule.UniqueName;

            this.cmbSourceType1.SelectedItem = rule.KeySources[0].Type.ToString();
            this.txtSourceIndex1.Text        = rule.KeySources[0].Index.ToString();
            this.txtThreshold1.Text          = rule.KeySources[0].Threshold.ToString("N3");
            this.chkSign1.Checked            = rule.KeySources[0].InvSign;

            this.cmbCombine1.SelectedItem = rule.KeySourcesOperators[0].ToString();

            this.cmbSourceType2.SelectedItem = rule.KeySources[1].Type.ToString();
            this.txtSourceIndex2.Text        = rule.KeySources[1].Index.ToString();
            this.txtThreshold2.Text          = rule.KeySources[1].Threshold.ToString("N3");
            this.chkSign2.Checked            = rule.KeySources[1].InvSign;

            this.cmbCombine2.SelectedItem = rule.KeySourcesOperators[1].ToString();

            this.cmbSourceType3.SelectedItem = rule.KeySources[2].Type.ToString();
            this.txtSourceIndex3.Text        = rule.KeySources[2].Index.ToString();
            this.txtThreshold3.Text          = rule.KeySources[2].Threshold.ToString("N3");
            this.chkSign2.Checked            = rule.KeySources[2].InvSign;

            this.txtAxisTolerance_pct.Text = rule.AxisTolerance_pct.ToString("N3");
            this.txtHoldTimes_ms.Text      = rule.HoldTime_ms.ToString();
            this.chkIsInversed.Checked     = rule.IsInvertedLogic;
            this.chkTestValue.Checked      = false;

            this.cmbKeyAPI.SelectedItem = rule.KeyAPI.ToString();
            if (rule.CombinedKeyStrokes.Count < 2)
            {
                for (int i = rule.CombinedKeyStrokes.Count; i < 2; i++)
                {
                    rule.CombinedKeyStrokes.Add(new KeyCodes());
                }
            }
            this.cmbKeyStroke1.SelectedItem = rule.CombinedKeyStrokes[0].ToString();
            this.cmbKeyStroke2.SelectedItem = rule.CombinedKeyStrokes[1].ToString();

            this.txtExpr.Text = rule.GetExpression();

            NoSelectedIndexDueToOngoingRefresh = false;
        }