コード例 #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Interval = new Random().Next(7000) + 3000;
            // notifyIcon1.ShowBalloonTip(5000,"title","message"+timer1.Interval,ToolTipIcon.Warning);
            for (int i = 0; i < mats.Count - 1; i++)
            {
                mats.Remove(mats.First());
            }

            mats.Add(OpenCvSharp.Extensions.BitmapConverter.ToMat(UtilsPic.GetScreenCapture()));
        }
コード例 #2
0
        public Form1(login _login)
        {
            SynchronizationContext synchronizationContext = SynchronizationContext.Current;

            this._login = _login;
            InitializeComponent();
            this.Text += " - " + login.s_id;
            title      = Text;
            maps       = new List <Dictionary <string, string> >();
            var stringses =
                UtilsDB.selectDB("SELECT `NAME`,S_ID,OL FROM members WHERE MGR>2 AND S_ID <>'" + login.s_id +
                                 "' ORDER BY OL DESC, MGR DESC,S_ID");

            for (int i = 0; i < stringses.Count; i++)
            {
                var map = new Dictionary <string, string>();
                map.Add("name", stringses[i][0]);
                map.Add("id", stringses[i][1]);
                map.Add("online", stringses[i][2]);
                maps.Add(map);
            }

            for (int i = 0; i < maps.Count; i++)
            {
                listBox1.Items.Add("oi");
            }

            new Thread(() =>
            {
                while (!login.over)
                {
                    //todo:查询需求、查询在线状况(自己和成员)、上传截图、
                    if (isworking && !ispause)
                    {
                        var strs = UtilsDB.selectDB(
                            "SELECT NUM_PIC,`NAME`,MSG FROM members JOIN (SELECT NUM_PIC,LOOKER,MSG FROM pictures WHERE MSG<>'' AND S_ID='" +
                            login.s_id + "') AS x ON x.LOOKER=members.S_ID");
                        if (strs.Count >= 1)
                        {
                            UtilsDB.changeDB("UPDATE pictures SET MSG='' WHERE NUM_PIC=" + strs[0][0]);
                            synchronizationContext.Post((obj) =>
                            {
                                notifyIcon1.BalloonTipTitle = strs[0][1];
                                notifyIcon1.BalloonTipText  = strs[0][2];
                                notifyIcon1.ShowBalloonTip(5000);
                            }, null);
                        }

                        var temp = UtilsDB.selectDB(
                            "SELECT MAX(NUM_PIC) FROM pictures WHERE S_ID='" + login.s_id + "' AND SERIER_PIC=0");
                        if (temp.Count == 1 && temp[0][0] != "")
                        {
                            UtilsDB.changeDB(
                                "UPDATE pictures SET SERIER_PIC=" + serier + " , BLOB_PIC=@blobData WHERE NUM_PIC=" +
                                temp[0][0],
                                new MySqlParameter("@blobData", UtilsPic.Bitmap2Byte(UtilsPic.GetScreenCapture())));
                        }

                        //TODO:修改时间间隔
                        if (worktime % 50 == 0)
                        {
                            UtilsDB.changeDB(
                                "INSERT INTO together.pictures(pictures.SERIER_PIC,pictures.S_ID,pictures.OPER_device,pictures.BLOB_PIC) VALUES('" +
                                serier + "','" + login.s_id + "',@macData,@blobData);",
                                new MySqlParameter("@blobData", UtilsPic.Bitmap2Byte(UtilsPic.GetScreenCapture())),
                                new MySqlParameter("@macData", UtilsDB.addr_Mac));
                        }
                    }

                    if (worktime % 2 == 0)
                    {
                        if (isworking)
                        {
                            UtilsDB.changeDB("UPDATE members SET OL=5 WHERE S_ID='" + login.s_id + "'");
                        }

                        synchronizationContext.Post((obj) =>
                        {
                            listBox1.BeginUpdate();
                            maps    = new List <Dictionary <string, string> >();
                            var sts =
                                UtilsDB.selectDB("SELECT `NAME`,S_ID,OL FROM members WHERE MGR>2 AND S_ID <>'" +
                                                 login.s_id +
                                                 "' ORDER BY OL DESC, MGR DESC,S_ID");
                            int total_ol = 0;
                            for (int i = 0; i < sts.Count; i++)
                            {
                                var map = new Dictionary <string, string>();
                                map.Add("name", sts[i][0]);
                                map.Add("id", sts[i][1]);
                                map.Add("online", sts[i][2]);
                                total_ol   += int.Parse(sts[i][2]) > 0 ? 1 : 0;
                                label1.Text = "在线人数:" + (total_ol + (!ispause && isworking ? 1 : 0));
                                maps.Add(map);
                            }

                            listBox1.EndUpdate();
                        }, null);
                    }


                    worktime++;
                    synchronizationContext.Post((state) => { label2.Text = "当前时长:" + state; },
                                                $"{stopwatch.Elapsed.Hours}:{stopwatch.Elapsed.Minutes}:{stopwatch.Elapsed.Seconds}");
                    Thread.Sleep(900);
                }
            }).Start();
        }