コード例 #1
0
        public void thread_sc()
        {
            int    step_frame = 0;
            bool   is_first   = true;
            Bitmap bitmap;
            string last_ocr_text = "";
            string cmd           = "";

            while (true)
            {
                if (isRecording == false)
                {
                    //write_finish = true;
                    sc.Abort();
                    return;
                }
                bitmap = CaptureScreen(true, videoOption.V_l, videoOption.V_t, videoOption.V_w, videoOption.V_h);
                if (bitmap == null)
                {
                    Thread.Sleep(15);
                    continue;
                }


                //run image filter

                //List<int> keep_colors = new List<int>();
                //keep_colors.Add(my.RGBtoInt(50, 106, 157));
                //keep_colors.Add(my.RGBtoInt(255, 255, 255));
                //my.keep_rgb(ref bitmap, keep_colors, 30);

                //image resize
                string output_bitmap_path = my.pwd() + "\\tesseract-ocr\\temp.png";
                bitmap.Save(output_bitmap_path);
                bitmap.Dispose();
                //cmd = "cd /d " + my.pwd() + "\\tesseract-ocr && convert.exe temp.png -colorspace HSB -channel 2 -separate +channel -white-threshold 35% -negate -lat 50x50+5% -negate -morphology erode octagon:1 temp.png";
                //my.system(cmd);
                cmd = "cd /d " + my.pwd() + "\\tesseract-ocr && convert temp.png -clone 0 -channel rgba -fuzz 20% -fill none +opaque \"#ffffff\"  -clone 0 -channel rgba -fuzz 20% -fill none +opaque \"#4084c2\"  -delete 0 -compose plus -composite -compose over -background white -flatten temp.png";
                my.system(cmd);

                cmd = "cd /d " + my.pwd() + "\\tesseract-ocr && python clear.py";
                my.system(cmd);
                UpdateUI_Picture(output_bitmap_path, pbox1);
                //run ocr
                string TESSDATA_PREFIX = my.pwd() + "\\Tesseract-OCR";
                TESSDATA_PREFIX = TESSDATA_PREFIX.Replace("\\", "/");
                //cmd = "cd /d " + my.pwd() + "\\tesseract-ocr && set TESSDATA_PREFIX=" + TESSDATA_PREFIX + "&& tesseract.exe temp.png temp -l eng";
                //Console.Write(cmd);
                //my.system(cmd);
                //string data = my.b2s(my.file_get_contents(my.pwd() + "\\tesseract-ocr\\temp.txt"));
                //data = my.UTF8toBig5(data);

                //UpdateUI_LabelText(data, output_label);

                step_frame++;
                Thread.Sleep(Convert.ToInt32(skip_time * 1000)); //skip half second
            }
        }
コード例 #2
0
        public void getSettingINI()
        {
            /*
             # setting.ini
             # [
             # {
             #   "name":"",
             #   "ip":"",
             #   "port":"",
             #   "kind":"",
             #   "login_id":"",
             #   "pwd":"",
             #   "isConnect":"F",
             #   "pdo": obj ,
             #   "connString": string
             # }
             # ]
             */
            List <Dictionary <string, string> > data = new List <Dictionary <string, string> >();
            string setting_path = my.pwd() + "\\setting.ini";

            if (!my.is_file(setting_path))
            {
                my.file_put_contents(setting_path, "");
            }
            string endata = my.b2s(my.file_get_contents(setting_path));
            //string dedata = my.dePWD_string(endata, the_code);
            JArray ja = new JArray();

            if (endata != "")
            {
                ja = my.json_decode(endata);
            }

            for (int i = 0, max_i = ja.Count; i < max_i; i++)
            {
                Dictionary <string, object> doo = new Dictionary <string, object>();
                foreach (JObject obj in ja[i])
                {
                    Dictionary <string, object> dictObj = obj.ToObject <Dictionary <string, object> >();
                    dictObj["isConnect"] = "F";
                    connections.Add(dictObj);
                }
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: shadowjohn/my_cam
        /* private void run_f2()
         * {
         *   f2 = new Form2();
         *   f2.InitializeComponent();
         *   f2.Show();
         *   f2.TopMost=true;
         *   f2.Load += new System.EventHandler();
         *
         *
         * }
         */

        private void Form1_Load(object sender, EventArgs e)
        {
            //AviManager aviManager = new AviManager(@"E:\5.program\C#\my_cam_old\my_cam\bin\Debug\video\2019-06-23_20_08_40.avi", true);

            //添加音频
            //String fileName = @"E:\5.program\C#\my_cam_old\my_cam\bin\Debug\video\aaa.wav";
            //aviManager.AddAudioStream(fileName, 0);
            //aviManager.Close();

            //AviManager aviManager = new AviManager(@"E:\5.program\C#\my_cam_old\my_cam\bin\Debug\video\2019-06-23_20_41_08.avi", true);
            //aviManager.AddAudioStream(@"E:\5.program\C#\my_cam_old\my_cam\bin\Debug\video\2019-06-23_20_41_08.wav", 0);
            //aviManager.Close();


            _proc = HookCallback;
            r_btn = this.run_btn;
            // From : https://dotblogs.com.tw/huanlin/2008/04/23/3320
            // From : https://dotblogs.com.tw/huanlin/2008/04/23/3319
            _hookID = SetHook(_proc);


            this.Left = Screen.PrimaryScreen.Bounds.Width - this.Width - 120;
            this.Top  = Screen.PrimaryScreen.Bounds.Height - this.Height - 120;

            //f2_t = new Thread(run_f2);
            //f2_t.Start();
            f2 = new Form2();
            f2.Show();
            f2.UI_Init();

            video_path = my.pwd() + "\\video";
            log(video_path);
            if (!my.is_dir(video_path))
            {
                my.mkdir(video_path);
            }
            mn         = my.date("Y-m-d_H_i_s");
            video_path = my.pwd() + "\\video\\" + mn + ".avi";
            audio_path = my.pwd() + "\\video\\" + mn + ".wav";
            log(video_path);
            log(audio_path);
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: shadowjohn/UCL_LIU_CSharp
        private void Form1_Load(object sender, EventArgs e)
        {
            //檢查不能重複啟動
            if (!ucl.checkLockSuccess())
            {
                MessageBox.Show("肥米已執行了...");
                Application.Exit();
            }
            //載入 UCLLIU.ini
            ucl.loadConfig();
            //載入字根檔
            ucl.loadJsonData();
            //如果有拚音,載入拚音功能
            if (my.is_file(my.pwd() + "\\pinyi.txt"))
            {
                ucl.same_sound_data = new List <string>(my.explode("\n", my.trim(my.b2s(my.file_get_contents(my.pwd() + "\\pinyi.txt")))));
            }

            //產生最簡根表
            ucl.generator_sp_table();

            word_label.Text = "";
            type_label.Text = "";
            KeyboardHook(this, e);
            //小圖加入版本
            notifyIcon1.Text = "肥米輸入法:" + ucl.VERSION;
            //修正一下畫面
            //


            /*this.TopLevel = true;
             * this.TopLevel = false;
             * this.TopLevel = true;
             * this.TopMost = true;
             * this.TopMost = false;
             * this.TopMost = true;
             */
            //Thread.Sleep(3000);
            btn_UCL.PerformClick();
            btn_UCL.PerformClick();
            //起始不可以是 topmost ,在程式執行後,才置高,不然
            //首次切換輸入法時,會失去原始的焦點(如記事本)
            this.TopMost = true;



            /*Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * Thread.Sleep(1000);
             * SendKeys.SendWait("+");
             * ucl.toAlphaOrNonAlpha();
             */
            //AllocConsole();
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: shadowjohn/my_navicat
        public void drawLists()
        {
            ImageList myImageList = new ImageList();
            string    pwd         = my.pwd();

            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\mysql_close.png"));      //0
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\mysql_open.png"));       //1
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\postgresql_close.png")); //2
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\postgresql_open.png"));  //3
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\oracle_close.png"));     //4
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\oracle_open.png"));      //5
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\sqlite_close.png"));     //6
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\sqlite_open.png"));      //7
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\sqlserver_close.png"));  //8
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\sqlserver_open.png"));   //9
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\db_close.png"));         //10
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\db_open.png"));          //11

            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\tables.png"));           //12
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\views.png"));            //13
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\functions.png"));        //14
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\events.png"));           //15
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\queries.png"));          //16
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\reports.png"));          //17
            myImageList.Images.Add(Image.FromFile(pwd + "\\image\\backups.png"));          //18

            // Assign the ImageList to the TreeView.

            db_tree.ShowRootLines = false;
            db_tree.ShowLines     = true;

            db_tree.ShowPlusMinus = true;
            db_tree.Nodes.Clear();
            for (int i = 0, max_i = myN.connections.Count; i < max_i; i++)
            {
                //From : https://stackoverflow.com/questions/3415354/how-to-avoid-winforms-treeview-icon-changes-when-item-selected
                TreeNode newNode = new TreeNode(myN.connections[i]["name"].ToString(), i, i);
                switch (myN.connections[i]["kind"].ToString())
                {
                case "mysql":
                    newNode.ImageIndex         = (myN.connections[i]["isConnect"].ToString() == "F") ? 0 : 1;
                    newNode.SelectedImageIndex = (myN.connections[i]["isConnect"].ToString() == "F") ? 0 : 1;
                    break;

                case "postgresql":
                    newNode.ImageIndex         = (myN.connections[i]["isConnect"].ToString() == "F") ? 2 : 3;
                    newNode.SelectedImageIndex = (myN.connections[i]["isConnect"].ToString() == "F") ? 2 : 3;
                    break;

                case "oracle":
                    newNode.ImageIndex         = (myN.connections[i]["isConnect"].ToString() == "F") ? 4 : 5;
                    newNode.SelectedImageIndex = (myN.connections[i]["isConnect"].ToString() == "F") ? 4 : 5;
                    break;

                case "sqlite":
                    newNode.ImageIndex         = (myN.connections[i]["isConnect"].ToString() == "F") ? 6 : 7;
                    newNode.SelectedImageIndex = (myN.connections[i]["isConnect"].ToString() == "F") ? 6 : 7;
                    break;

                case "sqlserver":
                    newNode.ImageIndex         = (myN.connections[i]["isConnect"].ToString() == "F") ? 8 : 9;
                    newNode.SelectedImageIndex = (myN.connections[i]["isConnect"].ToString() == "F") ? 8 : 9;
                    break;
                }

                db_tree.Nodes.Add(newNode);
            }
            db_tree.ImageList = myImageList;
            SetWindowTheme(db_tree.Handle, "explorer", null);
        }
コード例 #6
0
 private void Form1_Load(object sender, EventArgs e)
 {
     PWD = my.pwd();
     downloadURL.Text = "https://www.comico.com.tw/2871/";
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: shadowjohn/system_status
        private void Form1_Load(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;

            //System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            //System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;

            //嘗試當掉就中斷離開
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(myCrash);
            this.LOCK_FILE = my.pwd() + "\\lock.txt";
            string COMPUTER_NAME = my.getSystemKey("COMPUTER_NAME");

            if (COMPUTER_NAME == "請填寫主機名稱")
            {
                MessageBox.Show("請填寫主機名稱...請先修改 system_status.exe.config");
                exit();
            }
            textSystemName.Text = COMPUTER_NAME;

            if (!my.is_file(this.LOCK_FILE))
            {
                my.file_put_contents(this.LOCK_FILE, "");
            }
            if (my.is_file_lock(this.LOCK_FILE))
            {
                //如果目前已是 lock 就結束
                CLog("Error ... Another zip process is running... ");
                Form1_FormClosing(sender, null);
                return;
            }
            //同時最多只能跑一支
            killSameProcessName();

            if (!my.isProcessRunning("system_status_watchdog"))
            {
                my.system(my.pwd() + "\\system_status_watchdog.exe", -1);
            }

            //寫入目前版本
            my.file_put_contents(my.pwd() + "\\version.txt", VERSION.ToString());

            notifyIcon1.Visible = true;
            //lock file
            s2 = new FileStream(this.LOCK_FILE, FileMode.Open, FileAccess.Read, FileShare.None);

            this.LOG_PATH = my.pwd() + "\\log";
            create_log_dir();
            this.Text += string.Format(" - 版本:{0}", VERSION);

            notifyIcon1.BalloonTipText  = "已縮小";
            notifyIcon1.BalloonTipTitle = this.Text;
            notifyIcon1.Text            = this.Text;

            this.StartPosition = FormStartPosition.CenterScreen;
            this.TopMost       = true;
            this.TopMost       = false;
            this.CenterToScreen();
            //載入設定檔
            //cIni.ini_init(this);
            //預設看要帶哪一個
            //cHdd.init(this);
            //cRunningProgram.init(this);
            //tabControl1.SelectTab("tabs_running_program");
            tabControl1.SelectTab("tabs_setting");
            tabControl1_Click(new object(), new EventArgs());

            /*if (iniData["setting"]["NAME"] == "")
             * {
             *  //首次使用,需先設定
             *  tabControl1.SelectTab("tabs_setting");
             *  tabControl1_Click(new object(), new EventArgs());
             * }
             */

            switch (my.getSystemKey("RUN_AT_START").ToUpper())
            {
            case "YES":
            {
                GLOBAL_RUN_AT_START = true;
            }
            break;
            }

            if (GLOBAL_RUN_AT_START)
            {
                //自動按
                btnManual_Click(sender, e);
                //自動縮小
                WindowState         = FormWindowState.Minimized;
                ShowInTaskbar       = false;
                notifyIcon1.Visible = true;
                notifyIcon1.ShowBalloonTip(1000);
            }
        }