예제 #1
0
        public MainFrm()
        {
            InitializeComponent();

            Directory.SetCurrentDirectory(Application.StartupPath);

            sqlMgr = new SQLiteMgr(Environment.CurrentDirectory, "twz", typeof(TWZDData));
            strokeMgr = new StrokeMgr("", pictureBox1);
            watch = new Stopwatch();
            rand = new Random();
            winTimer = new System.Timers.Timer((double)(Variable.AlertIntervalMin * 60 * 1000));
            taskTimer = new System.Timers.Timer(50.0);
            winTimer.Elapsed += new ElapsedEventHandler(OnAlert);
            taskTimer.Elapsed += new ElapsedEventHandler(DoAllTask);
            winTimer.Enabled = true;

            frmState = MainFrm.WinState.Halt;
            appIcon = (Environment.OSVersion.Version.Major <= 5)
                ? Resources.彩色
                : Resources.黑白;
            Opacity = 0.0;
            notifyIcon1.Icon = appIcon;

            GetConfig();
            CVDllImport.CVInit();

            //鼠标穿透
            //int WS_EX_APPWINDOW = 0x00040000;
            long STYLE = CVDllImport.GetWindowLong(Handle, -20);
            long WS_EX_TOOLWINDOW = 0x00000080;
            long WS_EX_TRANSPARENT = 0x00000020;
            CVDllImport.SetWindowLong(Handle, -20,
                STYLE | 0x80000 | (WS_EX_TRANSPARENT) | WS_EX_TOOLWINDOW);
        }
예제 #2
0
        private void PreAlert()
        {
            this.CheckCam();
            MainFrm.frameCallBack = new FrameCallBack(this.OnData);
            MainFrm.quitCallBack = new QuitCallBack(this.OnQuit);
            CVDllImport.CVSetFrameEvent(MainFrm.frameCallBack);
            CVDllImport.CVSetQuitEvent(MainFrm.quitCallBack);

            testID = rand.Next(phraseCount << 4, phraseCount << 5) % phraseCount;
            //testID = 10;

            DataTable dtPhrase = sqlMgr.SelectFromTable("Phrase", "rowid", testID.ToString());
            label词语.Text = (string)dtPhrase.Rows[0]["词语"];
            label注音.Text = (string)dtPhrase.Rows[0]["注音"];

            string temp = (string)dtPhrase.Rows[0]["释义"];
            if (temp.Length > 50)
            {
                label释义.Text = temp.Substring(0, 50) + "...";
            }
            else
            {
                label释义.Text = temp;
            }

            int pos = int.Parse((string)dtPhrase.Rows[0]["单字位置"]) - 1;
            currentChar = new string(label词语.Text[pos], 1);

            DataTable dtStroke = sqlMgr.SelectFromTable("StrokeOrder", "汉字", currentChar);
            strokeMgr = new StrokeMgr((string)dtStroke.Rows[0]["笔顺数据"], this.pictureBox1);
            pictureBox1.Image = null;
            pictureBox2.Image = null;

            this.Opacity = 0;
            if (!camUsable)
            {
                this.frmState = WinState.PhraseIn;
            }
            else
            {
                this.frmState = WinState.AlertIn;
            }

            退出ToolStripMenuItem.Enabled = false;
            设置ToolStripMenuItem.Enabled = false;
            预览ToolStripMenuItem.Text = "不寫了";
            taskTimer.Enabled = true;
            watch.Reset();
            watch.Start();
        }