private static bool Init() { try { Global global = new Global(); //Object referene not set to an instanceof an object //加载班级数据 Thread thread_loadClassInfo = new Thread(delegate() { Global.loadSchoolInfo(); Global.loadClassInfo(); }); thread_loadClassInfo.Start(); } catch (Exception e) { MessageBox.Show("配置文件错误,请确认无误后再重新启动程序!\r\n(" + e.Message + ")", "警告"); return(false); } int nSchoolID = Global.getSchoolID(); int nClassID = Global.getClassID(); string assistanturl = Global.url_assistant; if (nSchoolID == 0 || nClassID == 0) { MessageBox.Show("请先进行学校参数的配置,谢谢!"); return(false); } Log.Info("nSchoolID=" + nSchoolID + ", nClassID=" + nClassID); return(true); }
public void SaveImages() { string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } bBtn = true; for (int i = 0; i < szBMP.Length; i++) { if (szBMP[i] != null) { // string imgName = i + "_" + DateTime.Now.ToString("HHmmss") + ".jpg"; string imgName = Global.getSchoolID() + "_" + Global.getClassID() + "_" + i + "_" + DateTime.Now.ToString("HHmmss") + ".jpg"; string imgPath = imgDir + "\\" + imgName; szBMP[i].Save(imgPath); RobotPenImageItem item = new RobotPenImageItem(DateTime.Now.ToString("HH:mm"), imgName); RobotPenImageGroup group = new RobotPenImageGroup(); group.imglist.Add(item); RECORD[i].grouplist.Add(group); } } bBtn = false; }
public static void uploadHDBind() { int classid = Global.getClassID(); string data = "hdid=" + Global.getHDID(); string resp = doPost("updateHDBind", data); }
public FormInter(string numberstr, string classid, string lessonid, string stuName) { Log.Info("FormPPTPractise.create, classid=" + classid + ", lessonid=" + lessonid); tm_create = DateTime.Now; al = new ArrayList(); alText = new ArrayList(); clickstate = new ArrayList(); _classid = classid; _lessonid = lessonid; //No xiti.id _xitiId = Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); //TODO: 截屏上传 if (EService.myppt != null || EService.bShowPicture) { _xitiId = "T_" + _xitiId; Image img = ScreenCapture.captureScreen(0, 0); string imgName = _xitiId + ".jpg"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; img.Save(imgPath); Common.uploadPicture(imgPath); } InitializeComponent(); int panelH = SetPanel(numberstr); this.Text = "出题[" + _xitiId + "]"; pictureBox2.Visible = false; pictureBox3.Visible = false; pictureBox4.Visible = false; this.Height = panelH; this.Width = screenWidth; StartPosition = FormStartPosition.Manual; SetDesktopLocation(0, screenHeight - this.Height); this.TopMost = true; #if DEBUG this.TopMost = false;//PPTPractise #endif //this.WindowState = FormWindowState.Maximized; this.Hide(); this.Show(); this.BringToFront(); t = new System.Timers.Timer(200); t.Elapsed += new System.Timers.ElapsedEventHandler(Theout); t.Enabled = true; t.AutoReset = true; }
public int generalRecieveData(int type) { int temp = 0; if (server == null) { server = new EService(); } ; string courseid = Global.getCourseID().ToString(); string classid = Global.getClassID().ToString(); string lessonid = Global.getLessonID().ToString(); server.HandonOver("-1", ""); if (type == 0) { temp = server.SingleProjectiveInPPT(courseid, classid, lessonid); } else if (type == 1) { temp = server.ProjectiveInPPT(courseid, classid, lessonid); } else if (type == 2) { temp = server.JudgeProjectiveInPPT(courseid, classid, lessonid); } return(temp); }
private void SaveInfo() { string ip = GetLocalIPAddress(); string sid = Global.getSchoolID() + ""; string cid = Global.getClassID() + ""; string apiurl = Global.url_hd; string str = HTTPReq.HttpGet(apiurl + "action=appsync&ip=" + ip + "&classid=" + cid + "&schoolid=" + sid + ""); }
public FormTimer(string numberstr) { Log.Info("FormHandon.create, numberstr=" + numberstr); al = new ArrayList(); alText = new ArrayList(); clickstate = new ArrayList(); _classid = Global.getClassID() + ""; _lessonid = Global.getLessonID() + ""; Log.Info("debug. FormHandon._classid=" + _classid + ", _lessonid=" + _lessonid); _xitiId = Global.getSchoolID() + "-" + _classid + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); //TODO: 截屏上传 if ((EService.myppt != null && EService.myppt.isOpen()) || EService.bShowPicture) { _xitiId = "H_" + _xitiId; Image img = ScreenCapture.captureScreen(0, 0); string imgName = _xitiId + ".jpg"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; img.Save(imgPath); Common.uploadPicture(imgPath); } InitializeComponent(); this.Text = "提问[" + _xitiId + "]"; this.Height = screenHeight; this.Width = screenWidth; StartPosition = FormStartPosition.Manual; SetDesktopLocation(0, screenHeight - this.Height); this.TopMost = true; #if DEBUG this.TopMost = false;//PPTPractise #endif //this.WindowState = FormWindowState.Maximized; this.Hide(); this.Show(); this.BringToFront(); Log.Info("FormHandon Timer_start(Theout) now..."); //t = new System.Timers.Timer(200); //t.Elapsed += new System.Timers.ElapsedEventHandler(Theout); //t.Enabled = true; //t.AutoReset = true; IntelligentRecommend.InitQuestion(); }
/// <summary> /// 异步同步文件列表到云端 /// </summary> public void AsnycSubmit() { int classid = Global.getClassID(); int schoolid = Global.getSchoolID(); string apiurl = Global.url_assistant; string url_param = "action=assfilenamebyclassroomid.set&filenames=" + submitStr + "&classid=" + classid + "&schoolid=" + schoolid + ""; HTTPReq.HttpGet(apiurl + url_param); Log.Info(apiurl + url_param); }
public void StartExercise() { //进入ms模式 //robotpenController.GetInstance()._Send(cmdId.WriteStart);//v1.0 robotpenController.GetInstance()._Send(cmdId.WriteBegin);//v1.1 //TODO: 重置发起时间 createtime = DateTime.Now.ToString("yyyyMMddHHmmss"); tm_create = DateTime.Now; rid = Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); }
public void loadCfg() { Log.Info(Global.toString()); textBox_wifi.Text = Global.getWiFi(); textBox_wifi.Enabled = false; textBox_schoolname.Text = Global.getSchoolname(); classid = Global.getClassID(); classname = Global.getClassname(); //get Class list { m_classlist.Clear(); comboBox_classlist.Text = ""; comboBox_classlist.Items.Clear(); m_classlist = m_db.getClassBySchoolid(Global.getSchoolID()); if (Global.IsPublicClassroom()) { comboBox_classlist.Items.Add("公共教室"); comboBox_classlist.SelectedIndex = comboBox_classlist.Items.Count - 1; button_reloadClasses.Visible = false; } else { foreach (Classes c in m_classlist) { if (c.name == "" || c.orderid == 0) { continue; } comboBox_classlist.Items.Add(c.name); if (classid == c.id) { comboBox_classlist.SelectedIndex = comboBox_classlist.Items.Count - 1; } } } } if (Global.getClassname() == "") { Classes c = m_db.getClassById(Global.getClassID()); if (c != null) { Global.setClassname(c.name); Global.setClassID(c.id); } } }
public static string doPost(string action, string data) { string data0 = "action=" + action + "&classid=" + Global.getClassID() + "&courseid=" + Global.getCourseID() + "&teacherid=" + Global.getTeacherID(); if (data.IndexOf("lesson.get") < 0) { data0 += "&lessonid=" + Global.getLessonID(); } if (data.IndexOf("schoolid=") < 0) { data0 += "&schoolid=" + Global.getSchoolID(); } data = data0 + "&" + data; string tm = DateTime.Now.ToString("yyyyMMddHHmmss"); string src = tm + "_" + Global.getSchoolID() + "_" + Global.getClassID() + "_" + KEY; string sign = GetMD5(src); string url = Global.url_assistant + "s=" + Global.getSchoolID() + "&r=0&classid=" + Global.getClassID() + "&t=" + tm + "&c=" + sign; string ret = ""; string keyTemp = sign.Substring(4, 16); string dataEncrypt = AesEncrypt(data, keyTemp);//跟java的substring不一样 string retCrypt = HTTPReq.HttpPost(url, dataEncrypt); ret = AesDecrypt(retCrypt, keyTemp); if (ret.Length == 0) { OfflineProcessor.AddEvent(action, url, data, tm); } Log.Info("doPost: data=" + data); Log.Debug("ret=" + ret); if (data.IndexOf("lesson.get") > 0) { handleGetLessonResponse(ret); } else if (data.IndexOf("handon") > 0 && Global.getLessonID() == 0) { handleGetLessonResponse(ret); } if (ret == null) { ret = ""; } return(ret); }
public FormVote(string options) { RESULT = "0,0,0,0"; InitializeComponent(); VoteOption = options; Log.Info("FormVote.create, options=" + options); tm_create = DateTime.Now; al = new ArrayList(); alText = new ArrayList(); clickstate = new ArrayList(); //No xiti.id _xitiId = Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); SetPanel(options); //设置面板 this.Text = "投票[" + _xitiId + "]"; this.Height = screenHeight; this.Width = screenWidth; //StartPosition = FormStartPosition.Manual; //SetDesktopLocation(0, screenHeight - this.Height); this.TopMost = true; #if DEBUG this.TopMost = false;//PPTPractise #endif this.Hide(); this.Show(); this.BringToFront(); t = new System.Timers.Timer(200); t.Elapsed += new System.Timers.ElapsedEventHandler(Theout); t.Enabled = true; t.AutoReset = true; //for (int i = 1; i <= 40; i++) //{ // statisticABCD(i, "A"); //} //VoteColumnEvent("A", pictureBox_A); }
//截屏移动重新封装 public static void screenshot() { string xitiID = Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); xitiID = "T_" + xitiID; Image img = ScreenCapture.captureScreen(0, 0); string imgName = xitiID + ".jpg"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; img.Save(imgPath); Common.uploadPicture(imgPath); }
public FormDraw() { InitializeComponent(); this.DoubleBuffered = true; Log.Info("FormDraw.create"); for (int i = 0; i < MAX; i++) { szTrail[i] = new Trail(); if (RECORD[i] == null) { RECORD[i] = new RobotPenImages(); } } //No xiti.id rid = Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); SetPanel(); this.Height = screenHeight; this.Width = screenWidth; StartPosition = FormStartPosition.Manual; SetDesktopLocation(0, screenHeight - this.Height); if (panelImg == null) { panelImg = new Bitmap(panel1.Width, panel1.Height); } this.TopMost = true; #if DEBUG this.TopMost = false;//PPTPractise #endif this.Hide(); labelName.Text = ""; labelIndex.Text = ""; init(); openDevice(); //清空界面 Graphics grap = this.panel1.CreateGraphics(); grap.Clear(this.BackColor); grap.Dispose(); }
public int recieveData(string answer, string type) { int temp = 0; if (server == null) { server = new EService(); } ; string courseid = Global.getCourseID().ToString(); string classid = Global.getClassID().ToString(); string lessonid = Global.getLessonID().ToString(); server.HandonOver("-1", ""); server.SingleProjectiveInPPT(courseid, classid, lessonid); server.SetAnswer(answer); return(temp); }
/// <summary> /// 文件上传----老师PPT做题或抢答 /// </summary> /// <param name="filename"></param> public static void uploadPicture(string path) { //if (true) // return; FileInfo fileInfo = new FileInfo(path); long filesize = fileInfo.Length; if (filesize > 1024 * 1024 * 5) { Log.Error("file too big. " + path); return; } int pos = path.LastIndexOf("\\"); string fileName = path.Substring(pos + 1); string md5 = Util.GetFileMD5(path); //异步同步到云服务 string url_param = "action=fileupload"; url_param += "&schoolid=" + schoolid; url_param += "&classid=" + Global.getClassID(); url_param += "&courseid=" + Global.getCourseID(); url_param += "&lessonid=" + Global.getLessonID(); url_param += "&teacherid=" + Global.getTeacherID(); url_param += "&filesize=" + filesize; url_param += "&md5=" + md5; url_param += "&filename=" + fileName; Thread thread = new Thread(delegate() { string url = "http://" + Global.HOST + "/upload.do" + "?" + url_param; string ret = HTTPReq.UploadFile(url, path); Log.Info(url + "," + path); }); thread.Start(); return; }
public FormQiangDa() { RESULT = ""; InitializeComponent(); tm_create = DateTime.Now; al = new ArrayList(); alText = new ArrayList(); clickstate = new ArrayList(); //No xiti.id _xitiId = Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); SetPanel(); this.Text = "抢答[" + _xitiId + "]"; this.Height = screenHeight; this.Width = screenWidth; this.TopMost = true; //#if DEBUG // this.TopMost = false;//PPTPractise //#endif this.BringToFront(); this.Show(); this.Hide(); t = new System.Timers.Timer(200); t.Elapsed += new System.Timers.ElapsedEventHandler(Theout); t.Enabled = true; t.AutoReset = true; //System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer(); //t1.Interval = 2000; //t1.Tick += new EventHandler(t_Tick_Close); //t1.Start(); }
private void pictureBox_home_Click(object sender, EventArgs e) { //批注截屏上传 Bitmap bmp = ScreenCapture.captureScreen(0, 0); string base64 = Util.ImgToBase64String(bmp); int imgHeight = bmp.Height; int imgWidth = bmp.Width; string imgName = Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss") + ".jpg"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; bmp.Save(imgPath); Common.uploadPicture(imgPath); Common.doPost("addDrawViewEvent", "filename=" + imgName); this.ShowMainPage(); }
private void pictureBox_main_exam_Click(object sender, EventArgs e) { //截屏 Size size = new System.Drawing.Size(screenWidth, SystemInformation.WorkingArea.Height - 80); try { Bitmap bmp = ScreenCapture.captureScreen(0, 0); string base64 = Util.ImgToBase64String(bmp); int imgHeight = bmp.Height; int imgWidth = bmp.Width; Log.Info("imgHeight=" + imgHeight + " imgWidth=" + imgWidth); Log.Info("screenHeight=" + screenHeight + " screenWidth=" + screenWidth); //doUpload if (true) { string imgName = DateTime.Now.ToString("yyyyMMdd") + "-" + Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("HHmmss") + ".png"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; bmp.Save(imgPath); // Common.uploadPicture(imgPath); string imgPathEncoded = System.Web.HttpUtility.UrlEncode(imgPath, Encoding.UTF8); //调用web string url = Application.StartupPath + @"\html\xiti.html?#" + imgName; Form1.formWeb = new FormWebBrowser(); Form1.formWeb.navigate(url); } } catch (Exception ex) { Log.Error(ex.Message); } }
private static void Update() { string versionC = Global.getVersion(); string versionS = ""; string url = "http://" + Global.HOST + "/user.do?action=update&schoolid=" + Global.getSchoolID() + "&classid=" + Global.getClassID() + "&version=" + Global.getVersion(); //string json = HTTPReq.doGet(url,1000); string json = HTTPReq.HttpGet(url); if (json.Length == 0) { return; } Log.Info("Update, ret=" + json); try { UpdateInfo resp = JsonOper.DeserializeJsonToObject <UpdateInfo>(json.Replace("(", "").Replace(")", "")); if (resp == null) { return; } foreach (UpdateItem item in resp.updateinfolist) { Log.Info(item.toJson()); if (item.type == 1)// { versionS = item.version; Log.Info("versionC=" + versionC + ", versionS=" + versionS); string[] szVerS = versionS.Split('.'); string[] szVerC = versionC.Split('.'); string zipurl = item.path; bool bUpdate = false; for (int i = 0; i < szVerS.Length; i++) { int nS = Util.toInt(szVerS[i]); int nC = Util.toInt(szVerC[i]); if (nS > nC) { bUpdate = true; break; } else if (nS < nC) { return; } else { continue; } } if (bUpdate) { string update = Application.StartupPath + "\\RueUpdate.exe"; string update2 = Application.StartupPath + "\\RueUpdate2.exe"; Log.Info(update); Log.Info(update2); if (File.Exists(update2)) { Log.Info("copy..."); KillProcess("RueUpdate.exe"); try { File.Delete(update); File.Copy(update2, update, true); Log.Info("delete update2..."); File.Delete(update2); } catch (Exception e) { Log.Info("File.copy(update2,update) and File.Delete exception. " + e.Message); } } else if (File.Exists(update)) { string param = versionS + " " + zipurl; Log.Info("run update.exe now..." + param); Process.Start(update, param); } } } else if (item.type == 2) { Global.setRyktUpdateInfo(item); } } } catch (Exception e) { Log.Error(e.Message); } }
public FormPPTXiTi(string numberstr, int m) { mode = m; al = new ArrayList(); alText = new ArrayList(); clickstate = new ArrayList(); //创建习题ID _xitiId = Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("yyyyMMddHHmmss"); //TODO: 截屏上传 if (m == 1) { _xitiId = "T_" + _xitiId; Image img = ScreenCapture.captureScreen(0, 0); string imgName = _xitiId + ".jpg"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; img.Save(imgPath); Common.uploadPicture(imgPath); } InitializeComponent(); int panelH = SetPanel(numberstr); this.Text = "抢答"; if (mode == 1)//PPT 抢答 { this.Height = panelH; this.Width = screenWidth; StartPosition = FormStartPosition.Manual; SetDesktopLocation(0, screenHeight - this.Height); label1.Visible = false; label3.Visible = false; lbltime.Visible = false; } else if (mode == 0) { this.WindowState = FormWindowState.Maximized; pictureBox1.Visible = true; //-------- int posY_timer = (screenHeight - lbltime.Height) / 2;//居中 label1.Location = new Point((screenWidth - label1.Width) / 2, posY_timer - lbltime.Height); lbltime.Location = new Point((screenWidth - lbltime.Width) / 2, posY_timer); label3.Location = new Point((screenWidth + lbltime.Width + label3.Width) / 2, posY_timer + lbltime.Height - label3.Height); //todo tlbl = new System.Timers.Timer(1000); tlbl.Elapsed += new System.Timers.ElapsedEventHandler(lblstart); tlbl.Enabled = true; tlbl.AutoReset = true; } this.TopMost = true; #if DEBUG this.TopMost = false;//PPTXiti,zzz #endif //this.WindowState = FormWindowState.Maximized; this.Hide(); this.Show(); this.BringToFront(); t = new System.Timers.Timer(200); t.Elapsed += new System.Timers.ElapsedEventHandler(Theout); t.Enabled = true; t.AutoReset = true; pictureBox2.Visible = false; pictureBox3.Visible = false; pictureBox4.Visible = false; //pictureBox3.Location = new System.Drawing.Point(screenWidth - 60, 0); //pictureBox4.Location = new System.Drawing.Point(screenWidth - 30, 0); }
/// <summary> /// 打开图片 /// </summary> /// <param name="datas"></param> /// <param name="mode">1: 数据流 2:本地文件 3:拍照文件 4: 截屏文件</param> public Form3(string datas, int mode, int firsttime) { InitializeComponent(); this.mode = mode; //this.pictureBox1.Size = new System.Drawing.Size(screenWidth, screenHeight); this.WindowState = FormWindowState.Maximized; this.TopMost = true; #if DEBUG this.TopMost = false;//Form3 ShowView #endif this.pictureBox1.Visible = false; this.pictureBox1.Visible = true; try { Bitmap bmp = null; if (mode == 1) { m_base64 = datas; m_bmp = Base64StringToImage(datas); } else if (mode == 2) { filepath = datas; string filetype = Path.GetExtension(filepath).ToLower(); if (filetype == ".png") { string filepath2 = Path.GetDirectoryName(filepath) + "\\" + Path.GetFileNameWithoutExtension(filepath) + ".jpg"; try { File.Delete(filepath2); System.Drawing.Bitmap b = (Bitmap)Image.FromFile(filepath); b.Save(filepath2, System.Drawing.Imaging.ImageFormat.Jpeg); } catch (Exception e) { Log.Error(e.Message); } filepath = filepath2; } Log.Info("showPicture2 :" + filepath); m_base64 = Util.ImgToBase64String(filepath); m_bmp = (Bitmap)Image.FromFile(filepath); imgHeight = m_bmp.Height; imgWidth = m_bmp.Width; Log.Info("imgHeight=" + imgHeight + " imgWidth=" + imgWidth); Log.Info("screenHeight=" + screenHeight + " screenWidth=" + screenWidth); //m_bmp = new Bitmap(m_bmp, screenWidth, screenHeight);//不能图片缩放,因为破坏了图片的质量 } else if (mode == 3) { filepath = Application.StartupPath + "\\" + datas; string filetype = Path.GetExtension(filepath).ToLower(); if (filetype == ".png") { string filepath2 = Path.GetDirectoryName(filepath) + "\\" + Path.GetFileNameWithoutExtension(filepath) + ".jpg"; System.Drawing.Bitmap b = (Bitmap)Image.FromFile(filepath); b.Save(filepath2, System.Drawing.Imaging.ImageFormat.Jpeg); filepath = filepath2; } Log.Info("showPicture3 :" + filepath); m_base64 = Util.ImgToBase64String(filepath); m_bmp = (Bitmap)Image.FromFile(filepath); } else if (mode == 4) { m_bmp = ScreenCapture.captureScreen(0, 0); m_base64 = Util.ImgToBase64String(m_bmp); } imgHeight = m_bmp.Height; imgWidth = m_bmp.Width; Log.Info("imgHeight=" + imgHeight + " imgWidth=" + imgWidth); Log.Info("screenHeight=" + screenHeight + " screenWidth=" + screenWidth); //m_bmp = new Bitmap(m_bmp, screenWidth, screenHeight);//不能图片缩放,因为破坏了图片的质量 this.pictureBox1.Image = m_bmp; this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; this.pictureBox1.Width = screenWidth; this.pictureBox1.Height = screenHeight; //doUpload if (mode == 1 && firsttime == 1) { string imgName = DateTime.Now.ToString("yyyyMMdd") + "-" + Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("HHmmss") + ".jpg"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; m_bmp.Save(imgPath); Common.uploadPicture(imgPath); Common.uploadCameraEvent(imgName);//相机拍照 } } catch (Exception ex) { Log.Error(ex.Message); } ////(图片宽>屏幕宽 && 图片高>屏幕高) //if ((pictureBox1.Width > Screen.PrimaryScreen.WorkingArea.Width && pictureBox1.Height > Screen.PrimaryScreen.WorkingArea.Height) || // (pictureBox1.Width > Screen.PrimaryScreen.WorkingArea.Width && pictureBox1.Height < Screen.PrimaryScreen.WorkingArea.Height)) //{ // MakeThumbnail(pictureBox1.Width, pictureBox1.Height, "W"); //} ////(图片宽<屏幕宽 && 图片高>屏幕高) 高度压缩 //else if (pictureBox1.Width < Screen.PrimaryScreen.WorkingArea.Width && pictureBox1.Height > Screen.PrimaryScreen.WorkingArea.Height) //{ // MakeThumbnail(pictureBox1.Width, pictureBox1.Height, "H"); //} //else //{ // pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; // this.pictureBox1.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - pictureBox1.Width / 2; // this.pictureBox1.Top = Screen.PrimaryScreen.WorkingArea.Height / 2 - pictureBox1.Height / 2; //} }
private void button1_Click(object sender, EventArgs e0) { bool bReloadClass = false; string _classname = ""; if (comboBox_classlist != null && comboBox_classlist.SelectedItem != null) { _classname = comboBox_classlist.SelectedItem.ToString(); try { foreach (Classes c in m_classlist) { if (_classname == "公共教室") { classid = -1; break; } if (_classname == c.name) { classid = c.id; } } if (classid != Global.getClassID()) { bReloadClass = true; } } catch (Exception e) { MessageBox.Show("教室ID参数设置错误,请重试!", "警告"); return; } Log.Info("Config.2 classid=" + classid); } try { hdip = textBox_hdip.Text; IPAddress ip; if (!IPAddress.TryParse(hdip, out ip)) { MessageBox.Show("采集器IP地址设置错误,请重试!", "警告"); return; } } catch (Exception e) { Log.Info("Config.3 " + e.Message); } Log.Info("Config.3 hdip=" + hdip); SetAutoRun(true); Global.setAutoUpdate(1); button_apply.Enabled = false; { string strHDIP = textBox_hdip.Text; Boolean bAutorun = autorun == 1?true:false; Global.saveSchoolConfig(strHDIP, bAutorun); } //TODO:如果教室ID变化,重新获取相关信息 if (bReloadClass) { Global.saveClassConfig(classid, _classname); if (Global.loadClassInfo()) { MessageBox.Show("更新成功!", "提示"); //更新班级的接收机ID Thread th = new Thread(delegate() { string hdid = Common.getHDID(); if (hdid.Length > 0) { Common.uploadHDBind(); } }); th.Start(); } else { MessageBox.Show("设置失败,请检查网络!", "提示"); } } button_apply.Enabled = true; }
public Form1() { InitializeComponent(); Log.Info("F1_1 set notifyIcon"); //show in taskbar { this.ShowInTaskbar = false; this.notifyIcon1.Visible = true;//在通知区显示Form的Icon this.WindowState = FormWindowState.Minimized; } //if (Global.isWithCamera()) //{ // this.toolStripMenuItem5.Visible = true; //} //else //{ // this.toolStripMenuItem5.Visible = false; //} FileInfo fi = new FileInfo(Application.StartupPath + "\\如e小助手.exe"); string lasttime = fi.LastWriteTime.ToString("yyyyMMdd HHmmss"); string MMdd = fi.LastWriteTime.ToString("MMdd"); string version = GetAssembly(typeof(System.Reflection.AssemblyVersionAttribute)); string[] szV = version.Split('.'); string version_1 = szV[0] + "." + szV[1] + "." + szV[2] + "." + MMdd; this.Text = "如e小助手 v" + version; this.labelAbout.Text = "关于 如e小助手(v" + version_1 + ")"; //设置自启动 Log.Info("F1_2 set autorun"); SetAutoRun(Global.getAutorun()); //清除历史文件夹 Log.Info("F1_3 remove historyDir"); RemoveHistoryDir(); //获取学校和班级的参数 int schoolid = Global.getSchoolID(); int classid = Global.getClassID(); Log.Info("F1_4 get parameters: schoolid=" + schoolid + ", classid=" + classid); string assistanturl = Global.url_assistant; Log.Info("F1_5 get class"); Classes c = m_db.getClassById(classid); if (c != null) { Global.setClassID(c.id); Global.setClassname(c.name); Global.setGrade(c.grade); } //更新班级的接收机ID Thread th = new Thread(delegate() { Log.Info("F1_6 setPCIP/syncHDId"); Thread.Sleep(3000); setHD_PcIp(); string hdid = Common.getHDID(); if (hdid.Length > 0) { Common.uploadHDBind(); } }); th.Start(); //上传历史数据 Thread thOfflineProcess = new Thread(delegate() { Log.Info("F1_7 syncOfflineData"); OfflineProcessor.UploadHistoryData(); }); thOfflineProcess.Start(); }
public Form1() { //Form_xiti1 ff = new Form_xiti1(); //ff.Show(); fController = new FormController(); fController.Display(false); //查看html文件夹是否存在,不存在就解压 string dir = Application.StartupPath + "\\html"; //if (!Directory.Exists(dir)) //{ // Common.UnZip(Application.StartupPath + @"\html.zip", Application.StartupPath + @"\html", ""); //} InitializeComponent(); //启动初始化接收机 answer_card = new AnswerCard(); //answer_card.Message(); string date = DateTime.Now.ToString("yyyyMMdd"); int schoolID = Global.getSchoolID(); Global.g_roommsg = Common.getClassroomCourseTable(schoolID, 101, "20170905"); //show in taskbar { this.ShowInTaskbar = false; this.notifyIcon1.Visible = true;//在通知区显示Form的Icon this.WindowState = FormWindowState.Minimized; } //if (Global.isWithCamera()) //{ // this.toolStripMenuItem5.Visible = true; //} //else //{ // this.toolStripMenuItem5.Visible = false; //} FileInfo fi = new FileInfo(Application.StartupPath + "\\互动课堂.exe"); string lasttime = fi.LastWriteTime.ToString("yyyyMMdd HHmmss"); string MMdd = fi.LastWriteTime.ToString("MMdd"); string version = GetAssembly(typeof(System.Reflection.AssemblyVersionAttribute)); string[] szV = version.Split('.'); string version_1 = szV[0] + "." + szV[1] + "." + szV[2] + "." + MMdd; this.Text = "互动课堂 v" + version; this.labelAbout.Text = "关于 互动课堂(v" + version_1 + ")"; //设置自启动 Log.Info("F1_2 set autorun"); SetAutoRun(Global.getAutorun()); //清除历史文件夹 Log.Info("F1_3 remove historyDir"); RemoveHistoryDir(); //获取学校和班级的参数 int schoolid = Global.getSchoolID(); int classid = Global.getClassID(); Log.Info("F1_4 get parameters: schoolid=" + schoolid + ", classid=" + classid); string assistanturl = Global.url_assistant; Log.Info("F1_5 get class"); Classes c = m_db.getClassById(classid); if (c != null) { Global.setClassID(c.id); Global.setClassname(c.name); Global.setGrade(c.grade); } //更新班级的接收机ID Thread th = new Thread(delegate() { Log.Info("F1_6 setPCIP/syncHDId"); Thread.Sleep(3000); setHD_PcIp(); string hdid = Common.getHDID(); if (hdid.Length > 0) { Common.uploadHDBind(); } }); th.Start(); //上传历史数据 Thread thOfflineProcess = new Thread(delegate() { Log.Info("F1_7 syncOfflineData"); OfflineProcessor.UploadHistoryData(); }); thOfflineProcess.Start(); while (Global.g_TeacherArray == null) { Thread.Sleep(50); } fNotifyToStart = new FormNotifyToStart(); fNotifyToStart.Show(); if (!Directory.Exists(dir)) { Common.UnZip(Application.StartupPath + @"\html.zip", Application.StartupPath + @"\html", ""); } else { System.IO.Directory.Delete(Application.StartupPath + @"\html", true); Common.UnZip(Application.StartupPath + @"\html.zip", Application.StartupPath + @"\html", ""); } }
/// <summary> /// 打开图片 /// </summary> /// <param name="datas"></param> /// <param name="mode">1: 数据流 2:本地文件 3:拍照文件</param> public FormCaptureScreen2() { InitializeComponent(); //截取掉下面的控制栏区域和任务栏 this.pictureBox1.Size = new System.Drawing.Size(screenWidth, SystemInformation.WorkingArea.Height - 80); this.Size = new System.Drawing.Size(screenWidth, SystemInformation.WorkingArea.Height - 80); this.Top = 0; this.Location = new Point(0, 0); this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; //this.WindowState = FormWindowState.Maximized; this.TopMost = true; #if DEBUG this.TopMost = false;//Form3 ShowView #endif this.pictureBox1.Visible = false; this.pictureBox1.Visible = true; try { //m_bmp = ScreenCapture.captureScreen(0, 0); Bitmap fullScreen = ScreenCapture.captureScreen(0, 0); m_bmp = this.CaptureImage(fullScreen, 0, 0, screenWidth, SystemInformation.WorkingArea.Height - 80); m_base64 = Util.ImgToBase64String(m_bmp); imgHeight = m_bmp.Height; imgWidth = m_bmp.Width; Log.Info("imgHeight=" + imgHeight + " imgWidth=" + imgWidth); Log.Info("screenHeight=" + screenHeight + " screenWidth=" + screenWidth); //m_bmp = new Bitmap(m_bmp, screenWidth, screenHeight);//不能图片缩放,因为破坏了图片的质量 this.pictureBox1.Image = m_bmp; this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; this.pictureBox1.Width = screenWidth; //this.pictureBox1.Height = screenHeight; this.pictureBox1.Height = SystemInformation.WorkingArea.Height - 80; //doUpload if (true) { string imgName = DateTime.Now.ToString("yyyyMMdd") + "-" + Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("HHmmss") + ".jpg"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; m_bmp.Save(imgPath); Common.uploadPicture(imgPath); //Common.uploadCameraEvent(imgName);//相机拍照 } } catch (Exception ex) { Log.Error(ex.Message); } ////(图片宽>屏幕宽 && 图片高>屏幕高) //if ((pictureBox1.Width > Screen.PrimaryScreen.WorkingArea.Width && pictureBox1.Height > Screen.PrimaryScreen.WorkingArea.Height) || // (pictureBox1.Width > Screen.PrimaryScreen.WorkingArea.Width && pictureBox1.Height < Screen.PrimaryScreen.WorkingArea.Height)) //{ // MakeThumbnail(pictureBox1.Width, pictureBox1.Height, "W"); //} ////(图片宽<屏幕宽 && 图片高>屏幕高) 高度压缩 //else if (pictureBox1.Width < Screen.PrimaryScreen.WorkingArea.Width && pictureBox1.Height > Screen.PrimaryScreen.WorkingArea.Height) //{ // MakeThumbnail(pictureBox1.Width, pictureBox1.Height, "H"); //} //else //{ // pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize; // this.pictureBox1.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - pictureBox1.Width / 2; // this.pictureBox1.Top = Screen.PrimaryScreen.WorkingArea.Height / 2 - pictureBox1.Height / 2; //} }
public string getInfor() { string data = Global.getSchoolID() + "," + Global.getTeacherID() + "," + Global.getClassID() + "," + Global.getCourseID() + "," + Global.getLessonID(); return(data); }
public void ShowFolders() { this.AllHide(); //this.Height = 0; path = 20;//文件夹 Bitmap bmp = ScreenCapture.captureScreen(0, 0); string base64 = Util.ImgToBase64String(bmp); int imgHeight = bmp.Height; int imgWidth = bmp.Width; string imgName = DateTime.Now.ToString("yyyyMMdd") + "-" + Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("HHmmss") + ".png"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; bmp.Save(imgPath); Common.uploadPicture(imgPath); this.AllShow(); this.TopMost = false; string imgPathEncoded = System.Web.HttpUtility.UrlEncode(imgPath, Encoding.UTF8); string url = Application.StartupPath + @"\html\xiti.html?#" + imgName; Form1.formWeb = new FormWebBrowser(); Form1.formWeb.navigate(url); }
public void CloseView() { Log.Info("CloseView over."); if (m_bDraw) { //上传画过的图片 Image img = ScreenCapture.captureScreen(0, 0); string imgName = DateTime.Now.ToString("yyyyMMdd") + "-" + Global.getSchoolID() + "-" + Global.getClassID() + "-" + DateTime.Now.ToString("HHmmss") + ".jpg"; string imgDir = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMdd"); if (!Directory.Exists(imgDir)) { Directory.CreateDirectory(imgDir); } string imgPath = imgDir + "\\" + imgName; img.Save(imgPath); Common.uploadPicture(imgPath);//drawView Common.uploadDrawView(imgName); } m_bDraw = false; this.Close(); }
public void loadCfg() { Log.Info(Global.toString()); textBox_wifi.Text = Global.getWiFi(); textBox_wifi.Enabled = false; textBox_schoolname.Text = Global.getSchoolname(); classid = Global.getClassID(); classname = Global.getClassname(); //get Class list { m_classlist.Clear(); comboBox_classlist.Text = ""; comboBox_classlist.Items.Clear(); m_classlist = m_db.getClassBySchoolid(Global.getSchoolID()); if (Global.IsPublicClassroom()) { comboBox_classlist.Items.Add("公共教室"); comboBox_classlist.SelectedIndex = comboBox_classlist.Items.Count - 1; button_reloadClasses.Visible = false; } else { foreach (Classes c in m_classlist) { if (c.name == "" || c.orderid == 0) { continue; } comboBox_classlist.Items.Add(c.name); if (classid == c.id) { comboBox_classlist.SelectedIndex = comboBox_classlist.Items.Count - 1; } } } } if (Global.getClassname() == "") { Classes c = m_db.getClassById(Global.getClassID()); if (c != null) { Global.setClassname(c.name); Global.setClassID(c.id); } } textBox_hdip.Text = Global.getHDIP(); //////////////////////////////// ArrayList iplist = Util.GetInternalIPList(); if (iplist.Count == 1) { textBox_360ip.Text = (string)iplist[0]; } else { foreach (string ip in iplist) { string ip_4 = ip.Substring(ip.LastIndexOf(".") + 1); if (ip == "172.18.201.3") { textBox_360ip.Text = ip; break; } } } }