private void Form1_Load(object sender, EventArgs e) { #if false //LoadHtml() throw assert m_wb.LoadHtml(@"<!DOCTYPE html> <html><head> <meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8""> <script type=""text/javascript""> function fireEvent(name, data) { var event = new MessageEvent(name,{'view': window, 'bubbles': false, 'cancelable': false, 'data': data}); document.dispatchEvent(event); } </script> </head> <body>fdsfsda <input type=""button"" onclick=""fireEvent('myFunction', 'some data');"" value=""SHOW DATA"" /> </body></html>" ); m_wb.AddMessageEventListener("myFunction", ((string s) => MessageBox.Show(s))); #endif m_wb.AddMessageEventListener("func1", onFunc1); m_wb.Navigate(@"C:\temp\until\KinhNikaya\testGUI\click.html"); }
private void OnLoadForm(object sender, EventArgs e) { var cfg = ConfigMng.getInstance(); var cnnStr = cfg.m_cnnInfo.cnnStr; if (cnnStr == null && OpenDbDlg()) { cfg.m_cnnInfo.cnnStr = m_cnnStr; cfg.m_content.initCnn(m_cnnStr); renderTree(); //set form title UpdateFormName(); } else { m_cnnStr = cfg.m_cnnInfo.cnnStr; cfg.m_content.initCnn(m_cnnStr); renderTree(); //restore state //restoreSts(); //set form title UpdateFormName(); } //set font this.Font = new Font(cfg.m_fontFamily, cfg.m_fontSize); this.MainMenuStrip.Font = new Font(cfg.m_fontFamily, cfg.m_fontSize); if (cfg.m_wndSize.Width > 0) { this.Location = cfg.m_wndPos; this.Size = cfg.m_wndSize; } m_wb.AddMessageEventListener("addNewMsg", OnaddNewMsg); m_wb.AddMessageEventListener("addLikeMsg", OnaddLikeMsg); m_wb.AddMessageEventListener("addProgReg", OnaddProgReg); }
private void Form1_Load(object sender, EventArgs e) { geckoWebBrowser.AddMessageEventListener("externAlert", s => { Gecko.GeckoHtmlElement lat, lng; lat = geckoWebBrowser.Document.GetHtmlElementById("coord1"); lng = geckoWebBrowser.Document.GetHtmlElementById("coord2"); Dlat.Text = lat.TextContent; Dlng.Text = lng.TextContent; }); geckoWebBrowser.AddMessageEventListener("deleteAlert", s => { Gecko.GeckoHtmlElement photo; photo = geckoWebBrowser.Document.GetHtmlElementById("curphoto"); CurPhoto.Text = photo.TextContent; int i = Convert.ToInt16(CurPhoto.Text); string filename = "document.json"; JObject rss = JObject.Parse(File.ReadAllText(Path.Combine(folderpath, filename))); // Считываем json файл в объект rss JObject channel = (JObject)rss["photolist"]; JArray or = (JArray)channel["photoor"]; JArray sm = (JArray)channel["photosm"]; JArray tag1 = (JArray)channel["geotag1"]; JArray tag2 = (JArray)channel["geotag2"]; JArray h = (JArray)channel["height"]; JArray w = (JArray)channel["width"]; string photopath = sm[i].ToString(); photopath = photopath.Substring(6, photopath.Length - 6); or[i].Remove(); sm[i].Remove(); tag1[i].Remove(); tag2[i].Remove(); h[i].Remove(); w[i].Remove(); File.WriteAllText((Path.Combine(folderpath, filename)), rss.ToString()); File.Delete(photopath); }); geckoWebBrowser.AddMessageEventListener("updateAlert", s => { Gecko.GeckoHtmlElement photo; photo = geckoWebBrowser.Document.GetHtmlElementById("curphoto"); CurPhoto.Text = photo.TextContent; int i = Convert.ToInt16(CurPhoto.Text); string slat = Dlat.Text; string slng = Dlng.Text; slat = slat.Replace(".", ","); slng = slng.Replace(".", ","); double lat = Convert.ToDouble(slat); double lng = Convert.ToDouble(slng); string filename = "document.json"; JObject rss = JObject.Parse(File.ReadAllText(Path.Combine(folderpath, filename))); // Считываем json файл в объект rss JObject channel = (JObject)rss["photolist"]; JArray tag1 = (JArray)channel["geotag1"]; JArray tag2 = (JArray)channel["geotag2"]; tag1[i] = lat; tag2[i] = lng; File.WriteAllText((Path.Combine(folderpath, filename)), rss.ToString()); string message = "Обновить геоданные в исходной фотографии? (В случае отказа координаты фотографии на карте изменятся, но геоданные в исходной фотографии не будут изменены)"; string caption = "Изменение координат"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == System.Windows.Forms.DialogResult.Yes) { JArray photoor = (JArray)channel["photoor"]; string temp = photoor[i].ToString(); temp = temp.Substring(6, temp.Length - 6); geotag.LoadImage(temp, lat, lng, false); } else { } }); }