public StartForm() { InitializeComponent(); content.ContentDir = Path.Combine(GPFileHelper.getAppExecutableDirectory(), "Content"); content.LoadFlows(); content.WebBrowser = webBrowser1; content.TopButtons.Add(button1); content.TopButtons.Add(button2); content.TopButtons.Add(button3); content.TopButtons.Add(button4); content.TopButtons.Add(button5); content.TopButtons.Add(button6); content.BottomButtons.Add(buttonBottom1); content.BottomButtons.Add(buttonBottom2); content.BottomButtons.Add(buttonBottom3); content.BottomButtons.Add(buttonBottom4); content.MainForm = this; content.TopBar = flowLayoutPanel1; content.BottomBar = flowLayoutPanel2; webBrowser1.ObjectForScripting = content; content.LoadStartPage(); //content.specialCommand("#calcm;"); }
protected override void Execute() { WebResponse response = null; WebRequest request = WebRequest.Create("http://gcal.home.sk/languages/langlist.php"); ((HttpWebRequest)request).UserAgent = "GCAL Application"; List <GPLanguage> list = new List <GPLanguage>(); GPLanguageList shared = GPLanguageList.getShared(); try { setMessage("msg:" + GPStrings.getString(1285)); response = request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader sr = new StreamReader(stream); string fetchedList = sr.ReadToEnd(); sr.Close(); string[] lines = fetchedList.Split('\n'); foreach (string s in lines) { //Debugger.Log(0, "", "LANG: " + s + "\n"); string[] langRec = s.Split('\t'); if (langRec.Length >= 3) { GPLanguage lang = new GPLanguage(); if (!int.TryParse(langRec[0], out lang.LanguageId)) { lang.LanguageId = -1; } lang.LanguageName = langRec[1]; if (!int.TryParse(langRec[2], out lang.LanguageVersion)) { lang.LanguageVersion = -1; } if (shared.IsNewVersion(lang)) { list.Add(lang); } } } } catch (Exception e) { setMessage("msg:" + e.Message); System.Threading.Thread.Sleep(2000); } finally { if (response != null) { response.Close(); } } int i = 1; int m = list.Count; foreach (GPLanguage language in list) { try { setMessage(string.Format("msg:{0} {1}/{2}", GPStrings.getString(1286), i, m)); request = WebRequest.Create("http://gcal.home.sk/languages/exportraw.php?langid=" + language.LanguageId); response = request.GetResponse(); Stream s = response.GetResponseStream(); StreamReader sr = new StreamReader(s); string file = sr.ReadToEnd(); sr.Close(); string fileName = string.Format("lang{0}.txt", language.LanguageId); string filePath = Path.Combine(Path.Combine(GPFileHelper.getAppExecutableDirectory(), "languages"), fileName); if (File.Exists(filePath)) { File.Delete(filePath); } File.WriteAllText(filePath, file); } catch { } finally { if (response != null) { response.Close(); } } i++; } if (list.Count > 0) { shared.refreshLanguageList(); } else { setMessage("msg:" + GPStrings.getString(1287)); } System.Threading.Thread.Sleep(1000); setMessage("stop:"); }