Esempio n. 1
0
 private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
 {
     if (isStop)
     {
         isStop = false;
         return;
     }
     if (e.newState == 2)
     {
         ConfigClass config = SqlLiteHelper.query("isMainClose")[0];
         config.FormalValue = "0";
         config.TestValue   = "0";
         SqlLiteHelper.update(config);
         Application.Exit();
     }
     if (e.newState == 3)
     {
         //播放
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 查询配置
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static List <ConfigClass> query(string name)
        {
            try
            {
                List <ConfigClass> list = new List <ConfigClass>();
                SQLiteConnection   conn = new SQLiteConnection();
                System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder();
                connstr.DataSource    = SqlLiteHelper.getSQLiteConn();
                connstr.Password      = "******";           //设置密码,SQLite ADO.NET实现了数据库密码保护
                conn.ConnectionString = connstr.ToString();
                SQLiteCommand cmd = new SQLiteCommand(); //是不是很熟悉呢?

                DateTime StartComputerTime = DateTime.Now;

                cmd.Connection = conn;

                if (name == null)
                {
                    cmd.CommandText = "select * from t_config order by id asc";
                }
                else
                {
                    cmd.CommandText = "select * from t_config where name='" + name + "' order by id asc";
                }
                conn.Close();
                conn.Open();
                SQLiteDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    ConfigClass config = new ConfigClass();
                    config.Id          = reader["id"].ToString();
                    config.Name        = reader["name"].ToString();
                    config.FormalValue = reader["formalValue"].ToString();
                    config.TestValue   = reader["testValue"].ToString();
                    config.Remark      = reader["remark"].ToString();
                    list.Add(config);
                }
                conn.Close();
                return(list);
            }catch (Exception ex) { return(new List <ConfigClass>()); }
        }
Esempio n. 3
0
        /// <summary>
        /// 修改配置
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public static bool update(ConfigClass config)
        {
            try
            {
                SQLiteConnection conn = new SQLiteConnection();
                System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder();
                connstr.DataSource    = SqlLiteHelper.getSQLiteConn();
                connstr.Password      = "******";//设置密码,SQLite ADO.NET实现了数据库密码保护
                conn.ConnectionString = connstr.ToString();
                SQLiteCommand comm = new SQLiteCommand(conn);
                comm.CommandText = "update t_config set testValue='" + config.FormalValue + "',formalValue='" + config.FormalValue + "' where name='" + config.Name + "'";

                conn.Open();
                int result = comm.ExecuteNonQuery();
                if (result > 0)
                {
                    return(true);
                }
                conn.Close();
                return(false);
            }
            catch (Exception ex) { return(false); }
        }
Esempio n. 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            showOnMonitor(1);
            this.WindowState = FormWindowState.Maximized;
            InitVedio();

            InitVedioUrl();
            InitEvent();
            try
            {
                new Thread(delegate()
                {
                    Thread.Sleep(2000);
                    axWindowsMediaPlayer1.uiMode = "None";
                    //axWindowsMediaPlayer1.fullScreen = true;

                    axWindowsMediaPlayer1.settings.setMode("loop", true);
                    axWindowsMediaPlayer1.Ctlcontrols.play();
                }).Start();

                //axWindowsMediaPlayer1.MouseDownEvent+= new AxWMPLib._WMPOCXEvents_MouseDownEventHandler(Form1_MouseDown);
                axWindowsMediaPlayer1.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(axWindowsMediaPlayer1_PlayStateChange);
                axWindowsMediaPlayer1.MouseDownEvent  += new AxWMPLib._WMPOCXEvents_MouseDownEventHandler(_WMPOCXEvents_MouseDownEvent);
            }
            catch { }
            playstopThread = new Thread(delegate() {
                try
                {
                    while (true)
                    {
                        if (isClose)
                        {
                            return;
                        }
                        Thread.Sleep(1000 * 30);
                        if (isClose)
                        {
                            return;
                        }
                        isStop = false;
                        if (isClose)
                        {
                            return;
                        }
                        if ("1".Equals(SqlLiteHelper.query("isStopGCMp4")[0].FormalValue))
                        {
                            if (isClose)
                            {
                                return;
                            }
                            if (Convert.ToInt32(axWindowsMediaPlayer1.playState) == 3)
                            {
                                isStop = true;
                                if (isClose)
                                {
                                    return;
                                }
                                axWindowsMediaPlayer1.Invoke(new setMp4Delegate(setMp4), axWindowsMediaPlayer1, 1);
                                if (isClose)
                                {
                                    return;
                                }
                                int monitorCount = System.Windows.Forms.Screen.AllScreens.Count();
                                if (monitorCount == 1)
                                {
                                    Application.Exit();
                                    return;
                                }
                            }
                        }
                        else if ("2".Equals(SqlLiteHelper.query("isStopGCMp4")[0].FormalValue))
                        {
                            if (isClose)
                            {
                                return;
                            }
                            axWindowsMediaPlayer1.Invoke(new setMp4Delegate(setMp4), axWindowsMediaPlayer1, 2);
                        }
                    }
                }catch (Exception ex)
                {
                    //MessageBox.Show("error:"+ex.Message+","+ex.InnerException);
                }
            });
            playstopThread.Start();
        }