Exemplo n.º 1
0
        public frmVals(RcValList list, string valname) : this(list) {
            var v = Array.Find(list.List, x => x.ValName == valname);
            if (v == null)
            {
                v = list.Add(valname);
            }

            idx = Array.IndexOf(list.List, v);
        }
Exemplo n.º 2
0
        private void lstVals_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (Modified && idx >= 0)
            {
                AdoptValData();
            }

            int buff;

            if (lstVals.SelectedIndex == -1)
            {
                idx = -1;
                btnApply.Enabled = txtName.Enabled = txtDefault.Enabled = txtMin.Enabled = txtMax.Enabled = txtStep.Enabled = chkDisp.Enabled = grpPreviewer.Enabled = false;
            }
            else if (lstVals.SelectedItem as string == "(新規)")
            {
                // 新規追加
                RcVal NewVal = vallist.Add("val" + (vallist.Count + 1).ToString());
                if (NewVal == null)
                {
                    lstVals.SelectedIndex = -1;
                    return;
                }
                //string name = dlgTextInput.ShowDialog("val" + vallist.Count, "新しい変数の名前を入力してください", 0, @" ""!#$%&'()-=^~|\[]{}`@:*;+,<.>/?", true);
                //if (name != null)
                int tmp = lstVals.SelectedIndex;
                RefreshValList();
                lstVals.SelectedIndex = tmp;

                txtName.Focus();
            }
            else
            {
                btnApply.Enabled = txtName.Enabled = txtDefault.Enabled = txtMin.Enabled = txtMax.Enabled = txtStep.Enabled = chkDisp.Enabled = grpPreviewer.Enabled = true;
                idx             = lstVals.SelectedIndex;
                txtName.Text    = vallist[idx].ValName;
                txtDefault.Text = vallist[idx].Default.ToString();
                txtMin.Text     = vallist[idx].Min.ToString();
                txtMax.Text     = vallist[idx].Max.ToString();
                txtStep.Text    = vallist[idx].Step.ToString();
                chkDisp.Checked = vallist[idx].Disp;

                prevValue = vallist[idx].Default;
                if (prevValue > vallist[idx].Max)
                {
                    prevValue = vallist[idx].Max;
                }
                else if (prevValue < vallist[idx].Min)
                {
                    prevValue = vallist[idx].Min;
                }
                if (float.IsInfinity(vallist[idx].Max) || float.IsInfinity(vallist[idx].Min) || float.IsInfinity(vallist[idx].Default) || float.IsInfinity(vallist[idx].Step))
                {
                    vsbPrevBar.Enabled = grpPreviewer.Enabled = false;
                }
                else
                {
                    vsbPrevBar.Enabled = grpPreviewer.Enabled = true;
                    buff = -(int)((prevValue - vallist[idx].Min) * 10000 / (vallist[idx].Max - vallist[idx].Min));
                    if (buff > vsbPrevBar.Maximum)
                    {
                        buff = vsbPrevBar.Maximum;
                    }
                    if (buff < vsbPrevBar.Minimum)
                    {
                        buff = vsbPrevBar.Minimum;
                    }
                    vsbPrevBar.Value = buff;
                }
            }
        }