Beispiel #1
0
        /// <summary>
        /// 设置参数
        /// </summary>
        private void SetParameters()
        {
            List <ControlA> controls     = m_window.GetControls();
            List <LabelA>   labels       = new List <LabelA>();
            List <SpinA>    spins        = new List <SpinA>();
            int             controlsSize = controls.Count;

            for (int i = 0; i < controlsSize; i++)
            {
                ControlA control = controls[i];
                LabelA   label   = control as LabelA;
                SpinA    spin    = control as SpinA;
                if (label != null)
                {
                    labels.Add(label);
                }
                else if (spin != null)
                {
                    spins.Add(spin);
                }
            }
            int    labelsSize    = labels.Count;
            String newParameters = "";

            for (int i = 0; i < labelsSize; i++)
            {
                newParameters += labels[i].Text + ",0,0," + spins[i].Value.ToString();
                newParameters += ";";
            }
            labels.Clear();
            spins.Clear();
            m_indicator.Clear();
            m_indicator.SetSourceField(KeyFields.CLOSE, KeyFields.CLOSE_INDEX);
            m_indicator.SetSourceField(KeyFields.HIGH, KeyFields.HIGH_INDEX);
            m_indicator.SetSourceField(KeyFields.LOW, KeyFields.LOW_INDEX);
            m_indicator.SetSourceField(KeyFields.OPEN, KeyFields.OPEN_INDEX);
            m_indicator.SetSourceField(KeyFields.VOL, KeyFields.VOL_INDEX);
            m_indicator.SetSourceField(KeyFields.AMOUNT, KeyFields.AMOUNT_INDEX);
            m_indicator.SetSourceField(KeyFields.CLOSE.Substring(0, 1), KeyFields.CLOSE_INDEX);
            m_indicator.SetSourceField(KeyFields.HIGH.Substring(0, 1), KeyFields.HIGH_INDEX);
            m_indicator.SetSourceField(KeyFields.LOW.Substring(0, 1), KeyFields.LOW_INDEX);
            m_indicator.SetSourceField(KeyFields.OPEN.Substring(0, 1), KeyFields.OPEN_INDEX);
            m_indicator.SetSourceField(KeyFields.VOL.Substring(0, 1), KeyFields.VOL_INDEX);
            m_indicator.SetSourceField(KeyFields.AMOUNT.Substring(0, 1), KeyFields.AMOUNT_INDEX);
            IndicatorData indicatorData = m_indicator.Tag as IndicatorData;

            indicatorData.m_parameters = newParameters;
            String constValue = "";

            if (newParameters != null && newParameters.Length > 0)
            {
                String[] strs     = newParameters.Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                int      strsSize = strs.Length;
                for (int i = 0; i < strsSize; i++)
                {
                    String   str   = strs[i];
                    String[] strs2 = str.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    constValue += "const " + strs2[0] + ":" + strs2[3] + ";";
                }
            }
            m_indicator.Script = constValue + indicatorData.m_script;
            m_indicator.OnCalculate(0);
            if (m_indicator.AttachVScale == AttachVScale.Left)
            {
                //m_indicator.Div.TitleBar.Text = m_indicator.Title;
            }
            m_chart.Chart.Update();
            m_chart.Chart.Invalidate();
        }