Пример #1
0
        private void btnCopy_Click(object sender, System.EventArgs e)
        {
            RcVal  temp = vallist[idx];
            RcVal  temp2;
            string copyflag = "_copy";
            int    count    = 0;

copystate:
            try{
                temp2 = vallist.Add(temp.ValName + copyflag);
            }
            catch {
                count++;
                copyflag = "_copy" + count.ToString();
                goto copystate;
            }
            temp2.Default  = temp.Default;
            temp2.Disp     = temp.Disp;
            temp2.Max      = temp.Max;
            temp2.Min      = temp.Min;
            temp2.RefCount = 0;
            temp2.Step     = temp.Step;

            RefreshValList();
        }
Пример #2
0
        void AdoptValData()
        {
            result   = DialogResult.Yes;
            Modified = false;
            RcVal target = vallist[idx];

            if (txtName.Text == "")
            {
                if (target.RefCount > 0)
                {
                    if (MessageBox.Show("この変数は他の部分で使用されています。\nそのため削除するとモデル動作が意図しない物になる可能性があります。", "RefCount = " + target.RefCount, MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                    {
                        return;
                    }
                }
                vallist.Remove(target.ValName);
                lstVals.SelectedIndex = -1;
                RefreshValList();
                return;
            }
            try{
                target.ValName = txtName.Text;
                //target.Default = RcData.ParseNumber(txtDefault.Text);
                //target.Min = RcData.ParseNumber(txtMin.Text);
                //target.Max = RcData.ParseNumber(txtMax.Text);
                //target.Step = RcData.ParseNumber(txtStep.Text);
                target.Default = new RcConst(txtDefault.Text);
                target.Min     = new RcConst(txtMin.Text);
                target.Max     = new RcConst(txtMax.Text);
                target.Step    = new RcConst(txtStep.Text);

                if (target.Min > target.Max)
                {
                    MessageBox.Show("Max / Minの範囲が不正です。\nMaxをMinに合わせます。", "適用エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    target.Max = target.Min;
                }
                if (target.Min > target.Default)
                {
                    MessageBox.Show("Defaultが、Max / Minの範囲外です。\nMinに合わせます。", "適用エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    target.Default = target.Min;
                }
                else if (target.Default > target.Max)
                {
                    MessageBox.Show("Defaultが、Max / Minの範囲外です。\nMax0に合わせます。", "適用エラー", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    target.Default = target.Max;
                }
            }
            catch (FormatException fe) {
                MessageBox.Show("数字のみ有効です。", fe.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (OverflowException oe) {
                MessageBox.Show("値の絶対値が大きすぎます。", oe.Message, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            target.Disp        = chkDisp.Checked;
            lstVals.Items[idx] = target.ToString();
        }
Пример #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            RcVal target = vallist[idx];

            if (target.RefCount > 0)
            {
                if (MessageBox.Show("この変数は他の部分で使用されています。\nそのため削除するとモデル動作が意図しない物になる可能性があります。", "RefCount = " + target.RefCount, MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
            }
            vallist.Remove(target.ValName);
            idx = -1;
            lstVals.SelectedIndex = -1;
            RefreshValList();
            return;
        }
Пример #4
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;
                }
            }
        }