コード例 #1
0
ファイル: Form1.cs プロジェクト: sopnic/ThirdParty
 public void drawKLines(WindData wd,int cycle,int colorNum)
 {
     double[,] data = (double[,])wd.getDataByFunc("wsi");
     gph = Graphics.FromImage(bmap);
     DateTime[] tlist = wd.timeList;
     PointF cpt = new PointF(50, 175);
     int oNum = (int)originNums[colorNum];
     //注释这段代码的功能是画K线
     //for (int i = 0; i < tlist.Length; i++) {
     //    int per = cycle * 2;
     //    PointF tmp = new PointF(48+per*(i+oNum),-(float)((10*data[i,0])/open-10)*175*beHigh+175);
     //    PointF tmp1 = new PointF(48 + per * (i + oNum) + per * 4 / 5, -(float)((10 * data[i, 1]) / open - 10) * 175 * beHigh + 175);
     //    PointF tmp2 = new PointF(48 + per * (i + oNum) + per * 2 / 5, -(float)((10 * data[i, 2]) / open - 10) * 175 * beHigh + 175);
     //    PointF tmp3 = new PointF(48 + per * (i + oNum) + per * 2 / 5, -(float)((10 * data[i, 3]) / open - 10) * 175 * beHigh + 175);
     //    if (tmp1.Y == tmp.Y)
     //        gph.DrawLine(myPens[colorNum%7], tmp, tmp1);
     //    else
     //        gph.DrawRectangle(myPens[colorNum%7], System.Math.Min(tmp.X, tmp1.X), System.Math.Min(tmp1.Y, tmp.Y), per * 4 / 5, System.Math.Abs(tmp1.Y - tmp.Y));
     //    gph.DrawLine(myPens[colorNum % 7],tmp2,tmp3);
     //}
     pictureBox1.Image = bmap;
     originNums[colorNum] = (int)originNums[colorNum] + tlist.Length;
 }
コード例 #2
0
ファイル: Form2.cs プロジェクト: zjusaga/IndexCal
 private void updateGrid(WindData wd,string func)
 {
     int clength = wd.codeList.Length, flength = wd.fieldList.Length, tlength = wd.timeList.Length;
     if (wd.errorCode != 0) {
         this.dataGridView1.ColumnCount = 2;
         this.dataGridView1.RowCount = 1;
         this.dataGridView1.Columns[0].HeaderText = "ErrCode";
         this.dataGridView1.Columns[1].HeaderText = "ErrMessage";
         this.dataGridView1.Rows[0].Cells[0].Value = wd.errorCode;
         this.dataGridView1.Rows[0].Cells[1].Value = w.getErrorMsg(wd.errorCode);
         return;
     }
     switch (func) {
         case "wsd":
         case "wsi":
         case "wst":{
             this.dataGridView1.ColumnCount = clength * flength;
             this.dataGridView1.RowCount = tlength+1;
             this.dataGridView1.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
             for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
             {
                 this.dataGridView1.Columns[i].HeaderText = "";
                 if (i % flength == flength / 2)
                     this.dataGridView1.Columns[i].HeaderText = wd.codeList[i / flength];
             }
             for (int m = 0; m < clength; m++)
                 for (int j = 0; j < flength; j++)
                 {
                     this.dataGridView1.Rows[0].Cells[m * flength + j].Value = wd.fieldList[j];
                 }
             this.dataGridView1.Rows[0].HeaderCell.Value = "";
             for (int k = 1; k < this.dataGridView1.RowCount; k++) {
                 if (func == "wsd")
                 {
                     this.dataGridView1.RowHeadersWidth = 120;
                     this.dataGridView1.Rows[k].HeaderCell.Value = wd.timeList[k - 1].ToString("yyyy-MM-dd");
                 }
                 else
                 {
                     this.dataGridView1.RowHeadersWidth = 160;
                     this.dataGridView1.Rows[k].HeaderCell.Value = wd.timeList[k - 1].ToString("yyyy-MM-dd HH:mm:ss");
                 }
             }
             object[,] odata = (object[,])wd.getDataByFunc(func, false);
             for (int l = 0; l < tlength; l++)
                 for (int n = 0; n < clength * flength;n++ )
                     this.dataGridView1.Rows[l+1].Cells[n].Value = string.Format("{0}",odata[l,n]);
             break;
         }
         case "wss":
         case "wset":
         case "wsq": {
             this.dataGridView1.ColumnCount = flength;
             this.dataGridView1.RowCount = clength;
             this.dataGridView1.RowHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
             this.dataGridView1.RowHeadersWidth = 120;
             for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
             {
                 this.dataGridView1.Columns[i].HeaderText = wd.fieldList[i];
             }
             for (int j = 0; j < this.dataGridView1.RowCount; j++) {
                 this.dataGridView1.Rows[j].HeaderCell.Value = wd.codeList[j];
             }
             object[,] odata = (object[,])wd.getDataByFunc(func, false);
             //System.Console.WriteLine(odata[0,0]);
             for (int l = 0; l < clength; l++)
                 for (int n = 0; n < flength; n++)
                     this.dataGridView1.Rows[l].Cells[n].Value = string.Format("{0}", odata[l, n]);
             break;
         }
         default: {
             this.dataGridView1.ColumnCount = 1;
             this.dataGridView1.RowCount = ((Array)wd.data).Length;
             this.dataGridView1.Columns[0].HeaderText = wd.fieldList[0];
             for (int j = 0; j < this.dataGridView1.RowCount;j++ )
                 this.dataGridView1.Rows[j].Cells[0].Value = ((Array)wd.data).GetValue(j);
             break;
         }
     }
     return;
 }
コード例 #3
0
ファイル: WindDataMethod.cs プロジェクト: sopnic/ThirdParty
        public static string WindDataToString(WindData wd, string strFuncName)
        {
            if (null == wd)
                return string.Empty;

            string s = string.Empty;
            string str = string.Empty;

            //请求出错,获取错误信息
            if (wd.errorCode != 0)
            {
                s += wd.GetErrorMsg() + Environment.NewLine;

                return s;
            }

            if (null != wd.codeList)
            {
                s += "Windcode = " + Environment.NewLine;
                foreach (String code in wd.codeList)
                    s += "  " + code + "\t";
                s += Environment.NewLine;
            }
            if (null != wd.fieldList)
            {
                s += "Indicators = " + Environment.NewLine;
                foreach (String field in wd.fieldList)
                    s += "  " + field + "\t";
                s += Environment.NewLine;
            }
            if (null != wd.timeList)
            {
                s += "Times = " + Environment.NewLine;
                foreach (DateTime time in wd.timeList)
                    s += "  " + time.ToString() + "\t";
                s += Environment.NewLine;
            }

            s += "Data = " + Environment.NewLine;
            object getData = wd.getDataByFunc(strFuncName, false);
            if (getData is object[,])//转化为2维数组
            {
                object[,] odata = (object[,])getData;

                switch (strFuncName)
                {
                    case "wsd":
                        {
                            string strColHead = string.Empty;
                            strColHead += "Time" + "\t\t";
                            foreach (String field in wd.fieldList)
                                strColHead += field + "\t";
                            strColHead += Environment.NewLine;

                            s = strColHead;

                            int nTimeLength = wd.timeList.Length;
                            int nCodeLength = wd.codeList.Length;
                            int nFieldLength = wd.fieldList.Length;
                            for (int i = 0; i < nTimeLength; i++)
                            {
                                s += wd.timeList[i].ToString("yyyy-MM-dd") + "\t";
                                for (int j = 0; j < nCodeLength * nFieldLength; j++)
                                {
                                    str = odata[i, j].ToString();
                                    s += str + "\t";
                                }
                                s += Environment.NewLine;
                            }
                        }
                        break;
                    case "wsi":
                    case "wst":
                        {
                            string strColHead = string.Empty;
                            bool bNeedOutputTime = true;
                            foreach (String field in wd.fieldList)
                            {
                                if (field == "time")
                                {
                                    strColHead += field + "\t\t\t";
                                    bNeedOutputTime = false;
                                }
                                else
                                    strColHead += field + "\t";
                            }
                            if (bNeedOutputTime)
                                strColHead = "time" + "\t\t\t" + strColHead;
                            strColHead += Environment.NewLine;

                            s = strColHead;

                            int nTimeLength = wd.timeList.Length;
                            int nCodeLength = wd.codeList.Length;
                            int nFieldLength = wd.fieldList.Length;
                            for (int i = 0; i < nTimeLength; i++)
                            {
                                if (bNeedOutputTime)
                                {
                                    s += wd.timeList[i].ToString() + "\t";
                                }

                                for (int j = 0; j < nCodeLength * nFieldLength; j++)
                                {
                                    str = odata[i, j].ToString();
                                    s += str + "\t";
                                }
                                s += Environment.NewLine;
                            }
                        }
                        break;
                    case "wsq":
                    case "wss":
                    case "wset":
                    case "wpf":
                        {
                            string strColHead = string.Empty;
                            foreach (String field in wd.fieldList)
                            {
                                strColHead += field + "\t";
                            }

                            s = strColHead + Environment.NewLine;

                            int nTimeLength = wd.timeList.Length;
                            int nCodeLength = wd.codeList.Length;
                            int nFieldLength = wd.fieldList.Length;
                            for (int i = 0; i < nCodeLength; i++)
                            {
                                if (i > 100)
                                    break;
                                s += wd.codeList[i] + "\t";
                                for (int j = 0; j < nTimeLength * nFieldLength; j++)
                                {
                                    if (null != odata[i, j])
                                    {
                                        str = odata[i, j].ToString();
                                        s += str + "\t";
                                    }
                                }
                                s += Environment.NewLine;
                            }
                        }
                        break;
                    default:
                        {
                            foreach (object o in odata)
                            {
                                str = o.ToString();
                                s += str + "\t";
                            }
                            s += Environment.NewLine;
                        }
                        break;
                }
            }
            else if (getData is object[])//一维数组
            {
                object[] odata = (object[])getData;
                foreach (object o in odata)
                {
                    str = o.ToString();
                    s += str + Environment.NewLine;
                }
            }
            else//简单对象
            {
                s += getData.ToString() + Environment.NewLine;
            }

            return s;
        }