示例#1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(base.GetHashCode()
                + (Frequency.ToUpper().GetHashCode() * 3)
                + (FacilityType.GetHashCode() * 3)
                + (VisualRange.GetHashCode() * 3)
                + (ATIS.ToUpper().GetHashCode() * 3)
                + (GetItemHashCode(ATISTime) * 3) * 17);
     }
 }
        protected internal override void SetVisualRange(bool fresh)
        {
            if (Continual && LoadDone && fresh)
            {
                Lenght = (int)this.ActualWidth / 100;

                int LocalMin = VisualRange.IndexOf(VisualRange.FirstOrDefault(d => Compare(
                                                                                  Nearest((DateTime)AxisX.ActualVisualRange.ActualMinValue), item2: d)));

                int LocalMax = LocalMin + Lenght >= VisualRange.Count - 1 ? VisualRange.Count - 1 : LocalMin + Lenght;

                if (MinIndex != LocalMin)
                {
                    MinIndex = LocalMin;
                    if (MinIndex + Lenght <= VisualRange.Count - 1)
                    {
                        AxisX.ActualVisualRange.MinValue = VisualRange[MinIndex];
                    }
                    else if (LocalMax - Lenght >= 0)
                    {
                        AxisX.ActualVisualRange.MaxValue = VisualRange[VisualRange.Count - 1];
                    }
                    else
                    {
                        AxisX.ActualVisualRange.MinValue = VisualRange[0];
                    }
                }
                else if (MaxIndex != LocalMax)
                {
                    MaxIndex = LocalMax;
                    if (LocalMin + Lenght <= VisualRange.Count - 1)
                    {
                        AxisX.ActualVisualRange.MaxValue = VisualRange[LocalMin + Lenght];
                    }
                    else if (MaxIndex - Lenght >= 0)
                    {
                        AxisX.ActualVisualRange.MinValue = VisualRange[MaxIndex - Lenght];
                    }
                    else
                    {
                        AxisX.ActualVisualRange.MaxValue = VisualRange[VisualRange.Count - 1];
                    }
                }
            }
        }
示例#3
0
        // 日期变化,读取数据、绘分时图
        private void dtPicker_ValueChanged(object sender, EventArgs e)
        {
            dtTick.Rows.Clear();
            DataProcess dp = null;

            try
            {
                dp = new DataProcess((String)cbInstrument.SelectedItem);
                dp.SetDisplayTick(dtTick, dtPicker.Value.ToString("yyyyMMdd"));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (dtTick.Rows.Count > 0)
            {
                PubTools.FormTool.SetCustomLabel(chartControlTickVol, dp.drSegment);

                // 需考虑均价的最大最小值
                double      maxprice = (double)dtTick.Compute("max(LastPrice)", "");
                double      minprice = (double)dtTick.Compute("min(LastPrice)", "");
                WholeRange  wr       = (WholeRange)((XYDiagram)chartControlTick.Diagram).AxisY.WholeRange;
                VisualRange vr       = (VisualRange)((XYDiagram)chartControlTick.Diagram).AxisY.VisualRange;
                wr.SetMinMaxValues(minprice, maxprice);
                vr.SetMinMaxValues(minprice, maxprice);

                // 设置持仓量坐标轴
                long maxOpenInterest = (long)dtTick.Compute("max(OpenInterest)", "");
                long minOpenInterest = (long)dtTick.Compute("min(OpenInterest)", "");
                wr = (WholeRange)((XYDiagram)chartControlTickVol.Diagram).SecondaryAxesY[0].WholeRange;
                vr = (VisualRange)((XYDiagram)chartControlTickVol.Diagram).SecondaryAxesY[0].VisualRange;
                wr.SetMinMaxValues(minOpenInterest, maxOpenInterest);
                vr.SetMinMaxValues(minOpenInterest, maxOpenInterest);
            }
            chartControlTick.Invalidate();
            chartControlTickVol.Invalidate();
        }
 private DateTime Nearest(DateTime value) =>
 VisualRange.OrderBy(vr => Greater(vr, value)).FirstOrDefault();