/// <summary>
        /// 创建热力图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uiButton_create_Click(object sender, EventArgs e)
        {
            if (todayOrTotal == 1 || todayOrTotal == 2)
            {
                //加载图片
                Bitmap bitmap = (Bitmap)Properties.Resources.KeyBord;
                //创建热力图
                HeatMapImage heatMapImage = new HeatMapImage(bitmap.Width, bitmap.Height, 150, 30);
                //加载数据
                if (todayOrTotal == 1)
                {
                    foreach (Key_Today key in KeyData_Today.todayData.KeyDatas)
                    {
                        //判断是否跳过数据
                        if (key.IsIgnore)
                        {
                            continue;
                        }
                        heatMapImage.SetAData(new DataType(key.Key_x, key.Key_y, key.Key_count));
                    }
                    //更新详细信息
                    uiLabel_total.Text = "总数:" + KeyData_Today.todayData.Total;
                    uiLabel_date.Text  = "日期:" + KeyData_Today.todayData.Date;
                }
                else if (todayOrTotal == 2)
                {
                    for (int i = 0; i < KeyData_Total.totalData.KeyDatas.Count && i < KeyData_Today.todayData.KeyDatas.Count; i++)
                    {
                        //判断是否跳过数据
                        if (KeyData_Today.todayData.KeyDatas[i].IsIgnore)
                        {
                            continue;
                        }
                        heatMapImage.SetAData(new DataType(KeyData_Today.todayData.KeyDatas[i].Key_x, KeyData_Today.todayData.KeyDatas[i].Key_y, KeyData_Total.totalData.KeyDatas[i].Key_count));
                    }
                    //更新数据面板
                    uiLabel_total.Text = "总数:" + KeyData_Total.totalData.Total;
                    uiLabel_date.Text  = "日期:" + KeyData_Total.totalData.StartDate + "至" + KeyData_Total.totalData.EndDate;
                }

                Bitmap img = heatMapImage.GetHeatMap(bitmap);

                pictureBox1.Image = img;

                pictureBox1.Refresh();

                uiButton_save.Enabled = true;
            }
        }
Esempio n. 2
0
        Bitmap Example2(int width, int height, int count)
        {
            datasGen = new MockDatasGen(width, height);
            HeatMapImage heatMapImage = new HeatMapImage(width, height, 200, 50);
            var          sw           = new Stopwatch();

            sw.Start();
            for (int i = 0; i < count; i++)
            {
                DataType data = datasGen.CreateAData();
                heatMapImage.SetAData(data);
            }
            sw.Stop();
            textBox1.Text += $@"Set Data, TotalSeconds{sw.Elapsed.TotalSeconds}";
            textBox1.Text += Environment.NewLine;
            return(heatMapImage.GetHeatMap());
        }
Esempio n. 3
0
        static void Example2()
        {
            Console.WriteLine("Create some mock datas");
            datasGen = new MockDatasGen(WIDTH, HEIGHT);
            HeatMapImage heatMapImage = new HeatMapImage(WIDTH, HEIGHT, 200, 50);

            Console.WriteLine("Start generating data and recording");
            for (int i = 0; i < 200; i++)
            {
                DataType data = datasGen.CreateAData();
                heatMapImage.SetAData(data);
            }

            Console.WriteLine("Calculate and generate heatmap");
            Bitmap img = heatMapImage.GetHeatMap();

            img.Save("..\\..\\..\\..\\Images\\heatmap2.png");
        }