예제 #1
0
        private void BulidThermalMap()
        {
            var today = DateTime.Now.Date;

            using (var context = new WareHouse_localEntities())
            {
                var L2EQuery = context.KeyMice.Where(
                    s => s.ExecuteDate >= today && s.DeviceName == "鼠标"
                    );
                var mouse_list = L2EQuery.ToList();
                foreach (var i in mouse_list)
                {
                    if (IsHandleCreated)
                    {
                        this.Invoke(new MethodInvoker(delegate
                        {
                            this.heatMapUC1.SetHeatPoint(Convert.ToInt32(i.LocationX), Convert.ToInt32(i.LocationY));
                        }));
                    }
                }
            }
            this.Invoke(new MethodInvoker(delegate
            {
                heatMapUC1.DrawMask();
            }));
        }
예제 #2
0
        private void metroTabControl_main_Selected(object sender, TabControlEventArgs e)
        {
            if (metroTabControl_main.SelectedTab == metroTabPage_chart)
            {
                PieChartExample();
                Timer.Start();
            }
            else
            {
                Timer.Stop();
            }
            if (metroTabControl_main.SelectedTab == metroTabPage_count)
            {
                //切换统计选项卡
                //var today = DateTime.Now.Date.AddDays(-1);
                var today = DateTime.Now.Date;
                using (var context = new WareHouse_localEntities())
                {
                    var L2EQuery = from km in context.KeyMice
                                   where km.ExecuteDate >= today
                                   group km by new { km.KeyData, km.DeviceName } into g
                    orderby g.Count() descending
                        select new { Peo = g.Key, Count = g.Count() };
                    var keyList   = L2EQuery.ToList();
                    var L2EQuery2 = context.KeyMice.Where(
                        s => s.ExecuteDate >= today
                        );
                    var L2EQuery3 = context.KeyMice;
                    var cont      = L2EQuery2.Count <KeyMouse>();
                    var cont2     = L2EQuery3.Count <KeyMouse>();
                    metroTile1.Text = string.Format("今天按了{0}次\n\r一共按了{1}次", cont.ToString(), cont2.ToString());

                    BindingList <KeyMouseModel> keyMs = new BindingList <KeyMouseModel>();
                    for (int i = 0; i < keyList.Count; i++)
                    {
                        KeyMouseModel keyM = new KeyMouseModel();
                        keyM.DeviceName    = keyList[i].Peo.DeviceName;
                        keyM.KeyData       = keyList[i].Peo.KeyData;
                        keyM.ExtendedValue = keyList[i].Count.ToString();
                        keyMs.Add(keyM);
                    }
                    this.metroGrid_count.DataSource = keyMs;
                };
            }
        }
예제 #3
0
        private async void M_hook_MouseDown(object sender, MouseEventArgs e)
        {
            //获取windos窗口信息
            Dictionary <string, object> winDet = GetWindowDetail();
            string        info      = winDet["info"].ToString();
            string        tit       = winDet["tit"].ToString();
            Icon          ico       = (Icon)winDet["ico"];
            StringBuilder className = (StringBuilder)winDet["className"];
            //添加数据
            KeyMouseModel km   = new KeyMouseModel();
            KeyMouse      KeyM = new KeyMouse();

            try
            {
                km.CategoryIcon = (Bitmap)imageList.Images["mousec.png"];
            }
            catch (Exception ex)
            {
                km.CategoryIcon = null;
            }
            KeyM.DeviceName  = km.DeviceName = "鼠标";
            KeyM.KeyData     = km.KeyData = e.Button.ToString();
            KeyM.LocationX   = km.LocationX = e.X;
            KeyM.LocationY   = km.LocationY = e.Y;
            KeyM.Title       = km.Title = tit;
            KeyM.ClassName   = km.ClassName = className.ToString();
            KeyM.ProcessPath = km.ProcessPath = info;
            km.ExecuteDate   = DateTime.Now.ToString();
            KeyM.ExecuteDate = DateTime.Now;
            try
            {
                km.ProgramIcon = ico == null ? (Bitmap)imageList.Images["win.ico"] : ico.ToBitmap();
            }
            catch (Exception ex)
            {
                km.ProgramIcon = null;
            }
            CSGlobal.GetInstance().KeyMs.Add(km);
            using (var context = new WareHouse_localEntities())
            {
                context.KeyMice.Add(KeyM);
                //context.SaveChanges();
                await context.SaveChangesAsync();
            }
        }
예제 #4
0
        public void PieChartExample()
        {
            Func <ChartPoint, string> labelPoint = chartPoint =>
                                                   string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);

            var today = DateTime.Now.Date;

            using (var context = new WareHouse_localEntities())
            {
                var L2EQuery = from km in context.KeyMice
                               where km.ExecuteDate >= today
                               group km by new { km.KeyData, km.DeviceName } into g
                orderby g.Count() descending
                    select new { Peo = g.Key, Count = g.Count() };
                var keyList = L2EQuery.ToList();

                SeriesCollection result = new SeriesCollection();

                for (int i = 0; i < keyList.Count; i++)
                {
                    ChartValues <double> chartvalue = new ChartValues <double>();
                    chartvalue.Add(keyList[i].Count);

                    PieSeries series = new PieSeries();
                    series.Values     = chartvalue;
                    series.Title      = keyList[i].Peo.KeyData;
                    series.DataLabels = true;
                    series.LabelPoint = labelPoint;
                    if (i == 0)
                    {
                        //突出第一名
                        series.PushOut = 15;
                    }
                    result.Add(series);
                    if (i > 8)
                    {
                        //最多展示
                        break;
                    }
                }
                pieChart1.Series = result;
            }

            pieChart1.LegendLocation = LegendLocation.Bottom;
        }
예제 #5
0
        private void TimerOnTick(object sender, EventArgs eventArgs)
        {
            var now   = DateTime.Now.AddSeconds(-3);
            int cont1 = 0;
            int cont2 = 0;

            using (var context = new WareHouse_localEntities())
            {
                var L2EQuery_Mouse = context.KeyMice.Where(
                    s => s.ExecuteDate >= now && s.DeviceName == "鼠标"
                    );
                var L2EQuery = context.KeyMice.Where(
                    s => s.ExecuteDate >= now && s.DeviceName == "键盘"
                    );
                //var keyList = L2EQuery.FirstOrDefault<KeyMouse>();
                cont1 = L2EQuery_Mouse.Count <KeyMouse>();
                cont2 = L2EQuery.Count <KeyMouse>();
            }
            ChartValues_Mouse.Add(new MeasureModel
            {
                DateTime = now,
                Value    = cont1
            });
            ChartValues.Add(new MeasureModel
            {
                DateTime = now,
                Value    = cont2
            });

            SetAxisLimits(now);

            //lets only use the last 30 values
            if (ChartValues.Count > 30)
            {
                ChartValues.RemoveAt(0);
            }
            if (ChartValues_Mouse.Count > 30)
            {
                ChartValues.RemoveAt(0);
            }
        }
예제 #6
0
        private async void K_hook_KeyDown(object sender, KeyEventArgs e)
        {
            //判断按下的键(Alt + A)
            //if (e.KeyData.ToString() == Settings.Default.lblKeyState)
            if (e.KeyValue == (int)Keys.A && (int)Control.ModifierKeys == (int)Keys.Alt)
            {
                //System.Windows.Forms.MessageBox.Show("按下了指定快捷键组合");
                if (this.Visible == true)
                {
                    this.Hide();
                    this.ShowInTaskbar = false;
                }
                else
                {
                    this.ShowInTaskbar = true;
                    //this.WindowState = FormWindowState.Normal;
                    this.Show();
                }
            }
            //避免一直触发事件,除了控制键
            if (!(e.KeyValue == (int)Keys.LMenu ||
                  e.KeyValue == (int)Keys.RMenu ||
                  e.KeyValue == (int)Keys.LControlKey ||
                  e.KeyValue == (int)Keys.RControlKey ||
                  e.KeyValue == (int)Keys.LShiftKey ||
                  e.KeyValue == (int)Keys.RShiftKey ||
                  e.KeyValue == (int)Keys.Menu ||
                  e.KeyValue == (int)Keys.Control ||
                  e.KeyValue == (int)Keys.Shift
                  ))
            {
                CSGlobal.GetInstance().k_hook.KeyDown -= K_hook_KeyDown;
            }
            //获取widos窗口信息
            Dictionary <string, object> winDet = GetWindowDetail();
            string        info      = winDet["info"].ToString();
            string        tit       = winDet["tit"].ToString();
            Icon          ico       = (Icon)winDet["ico"];
            StringBuilder className = (StringBuilder)winDet["className"];
            //添加数据
            KeyMouseModel km   = new KeyMouseModel();
            KeyMouse      KeyM = new KeyMouse();

            //Bitmap icon = new Bitmap(imageList.Images["keyboardc.png"]);
            //Bitmap win = new Bitmap(imageList.Images["win.ico"]);
            try
            {
                km.CategoryIcon = (Bitmap)imageList.Images["keyboardc.png"];
            }
            catch (Exception ex)
            {
                km.CategoryIcon = null;
            }
            KeyM.DeviceName  = km.DeviceName = "键盘";
            KeyM.KeyData     = km.KeyData = e.KeyData.ToString();
            km.LocationX     = 0;
            km.LocationY     = 0;
            KeyM.Title       = km.Title = tit;
            KeyM.ClassName   = km.ClassName = className.ToString();
            KeyM.ProcessPath = km.ProcessPath = info;
            km.ExecuteDate   = DateTime.Now.ToString();
            KeyM.ExecuteDate = DateTime.Now;
            try
            {
                km.ProgramIcon = ico == null ? (Bitmap)imageList.Images["win.ico"] : ico.ToBitmap();
            }
            catch (Exception ex)
            {
                km.ProgramIcon = null;
            }
            KeyM.KeyCode = km.KeyCode = e.KeyValue;
            CSGlobal.GetInstance().KeyMs.Add(km);
            using (var context = new WareHouse_localEntities())
            {
                context.KeyMice.Add(KeyM);
                await context.SaveChangesAsync();
            }
            //imageList.Images["keyboardc.png"].Dispose();
            //imageList.Images["win.ico"].Dispose();
        }