From: <kro...@us...> - 2010-11-17 08:14:00
|
Revision: 3939 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3939&view=rev Author: kroko_koenig Date: 2010-11-17 08:13:53 +0000 (Wed, 17 Nov 2010) Log Message: ----------- add mouse support, some codes changes Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Release/Plugins/Windows/BrowseTheWeb.dll trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/todo.txt trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.suo trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.suo Modified: trunk/plugins/BrowseTheWeb/Release/Plugins/Windows/BrowseTheWeb.dll =================================================================== (Binary files differ) Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -136,10 +136,6 @@ textWriter.WriteValue(bkm.Url); textWriter.WriteEndElement(); - textWriter.WriteStartElement("ID"); - textWriter.WriteValue(bkm.Id); - textWriter.WriteEndElement(); - textWriter.WriteStartElement("Visited"); textWriter.WriteValue(bkm.Visited); textWriter.WriteEndElement(); @@ -198,39 +194,40 @@ return true; } - public static void SaveSnap(Bitmap Snap, long ID) + public static void SaveSnap(Bitmap Snap, string Url) { try { - string filename = ID.ToString() + ".png"; + string filename = GetThumbString(Url); + filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb\\" + filename; - filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb\\" + filename; Snap.Save(filename); } catch { } } - public static Bitmap GetSnap(long ID) + public static Bitmap GetSnap(string Url) { Bitmap snap = null; try { - string filename = ID.ToString() + ".png"; + string filename = GetThumbString(Url); + filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb\\" + filename; - filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb\\" + filename; if (File.Exists(filename)) + { snap = (Bitmap)Bitmap.FromFile(filename); - - return snap; + return snap; + } } catch { } return snap; } - public static string GetSnapPath(long ID) + public static string GetSnapPath(string Url) { - string filename = ID.ToString() + ".png"; + string filename = GetThumbString(Url); filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb\\" + filename; return filename; @@ -240,5 +237,25 @@ if (!Directory.Exists(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb")) Directory.CreateDirectory(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb"); } + + private static string GetThumbString(string Name) + { + string result = Name; + + if (result.EndsWith("/")) result = result.Substring(0, result.Length - 1); + + int x = result.IndexOf("//"); + if (x > 0) + { + result = result.Substring(x + 2); + } + + result = result.Replace("/", "_"); + result = result.Replace(".", "_"); + result = result.Replace("?", "_"); + result = result + ".png"; + + return result; + } } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -32,7 +32,6 @@ { public string Name = string.Empty; public string Url = string.Empty; - public Int64 Id = 0; public int Visited = 0; public DateTime LastVisited; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -74,11 +74,6 @@ result.Name = Node.SelectSingleNode("Name").InnerText; result.Url = Node.SelectSingleNode("URL").InnerText; - try - { - result.Id = Convert.ToInt64(Node.SelectSingleNode("ID").InnerText); - } - catch { } result.Visited = Convert.ToInt32(Node.SelectSingleNode("Visited").InnerText); result.LastVisited = Convert.ToDateTime(Node.SelectSingleNode("LastVisited").InnerText); @@ -117,16 +112,18 @@ childElement.AppendChild(sub1); XmlElement sub2 = xmlDocument.CreateElement("URL"); sub2.InnerText = string.Empty; childElement.AppendChild(sub2); - XmlElement sub3 = xmlDocument.CreateElement("Visited"); sub3.InnerText = "0"; + XmlElement sub3 = xmlDocument.CreateElement("ID"); sub3.InnerText = "0"; childElement.AppendChild(sub3); - XmlElement sub4 = xmlDocument.CreateElement("LastVisited"); sub4.InnerText = "0001-01-01T00:00:00"; + XmlElement sub4 = xmlDocument.CreateElement("Visited"); sub4.InnerText = "0"; childElement.AppendChild(sub4); - XmlElement sub5 = xmlDocument.CreateElement("Created"); sub5.InnerText = DateTime.UtcNow.ToString("u", null); + XmlElement sub5 = xmlDocument.CreateElement("LastVisited"); sub5.InnerText = "0001-01-01T00:00:00"; childElement.AppendChild(sub5); - XmlElement sub6 = xmlDocument.CreateElement("isFolder"); sub6.InnerText = "true"; + XmlElement sub6 = xmlDocument.CreateElement("Created"); sub6.InnerText = DateTime.UtcNow.ToString("u", null); childElement.AppendChild(sub6); - XmlElement sub7 = xmlDocument.CreateElement("isSubFolder"); sub7.InnerText = "false"; + XmlElement sub7 = xmlDocument.CreateElement("isFolder"); sub7.InnerText = "true"; childElement.AppendChild(sub7); + XmlElement sub8 = xmlDocument.CreateElement("isSubFolder"); sub8.InnerText = "false"; + childElement.AppendChild(sub8); XmlNode parentNode = xmlDocument.SelectSingleNode("Bookmarks"); parentNode.InsertBefore(childElement, parentNode.FirstChild); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user 2010-11-17 08:13:53 UTC (rev 3939) @@ -1,7 +1,7 @@ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <StartAction>Program</StartAction> - <StartProgram>C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe</StartProgram> + <StartProgram>C:\Program Files\Team MediaPortal\MediaPortal\Mediaportal.exe</StartProgram> </PropertyGroup> <PropertyGroup> <ProjectView>ProjectFiles</ProjectView> Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -126,7 +126,7 @@ } else { - string file = Bookmark.GetSnapPath(bkm.Id); + string file = Bookmark.GetSnapPath(bkm.Url); item.IconImage = file; item.IconImageBig = file; } @@ -168,7 +168,7 @@ item.Label = bkm.Name; item.Path = bkm.Url; - string file = Bookmark.GetSnapPath(bkm.Id); + string file = Bookmark.GetSnapPath(bkm.Url); item.IconImage = file; item.IconImageBig = file; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -78,6 +78,7 @@ private bool statusBar = true; private bool osd = false; private bool windowed = false; + private bool useMouse = false; private bool zoomPage = false; private bool zoomDomain = false; private string lastDomain = string.Empty; @@ -178,7 +179,11 @@ #region add forms webBrowser = new GeckoWebBrowser(); + webBrowser.Name = "BrowseTheWeb"; + webBrowser.NoDefaultContextMenu = true; GUIGraphicsContext.form.Controls.Add(webBrowser); + + webBrowser.Enabled = false; webBrowser.Visible = false; osd_linkID = new OSD_LinkId(); @@ -207,10 +212,18 @@ GUIPropertyManager.SetProperty("#btWeb.linkid", ""); linkId = string.Empty; + if (useMouse) + { + MyLog.debug("Mouse support is enabled"); + GUIGraphicsContext.MouseSupport = true; + } + #region init browser webBrowser.Visible = true; - webBrowser.Enabled = false; + if (!useMouse) webBrowser.Enabled = false; + else webBrowser.Enabled = true; + webBrowser.Dock = System.Windows.Forms.DockStyle.None; webBrowser.Location = new System.Drawing.Point(0, 0); @@ -218,6 +231,7 @@ webBrowser.DocumentCompleted += new EventHandler(webBrowser_DocumentCompleted); webBrowser.StatusTextChanged += new EventHandler(webBrowser_StatusTextChanged); + webBrowser.DomKeyDown += new GeckoDomKeyEventHandler(webBrowser_DomKeyDown); if (statusBar) webBrowser.Size = new System.Drawing.Size(GUIGraphicsContext.form.Width, GUIGraphicsContext.form.Height - 100); @@ -260,6 +274,9 @@ timer.Interval = 100; timer.Tick += new EventHandler(timer_Tick); timer.Start(); + + if (useMouse) + GUIGraphicsContext.form.Controls["BrowseTheWeb"].Select(); } catch (Exception ex) { @@ -269,7 +286,32 @@ base.OnPageLoad(); } + protected override void OnPageDestroy(int new_windowId) + { + if (new_windowId != 54537688) + { // not if you got favs + if (blankBrowser) + { + webBrowser.Navigate("about:blank"); + MyLog.debug("blank on destroy"); + } + } + GUIGraphicsContext.form.Focus(); + webBrowser.Hide(); + + osd_linkID.Visible = false; + + webBrowser.DocumentCompleted -= new EventHandler(webBrowser_DocumentCompleted); + webBrowser.StatusTextChanged -= new EventHandler(webBrowser_StatusTextChanged); + webBrowser.DomKeyDown -= new GeckoDomKeyEventHandler(webBrowser_DomKeyDown); + + timer.Tick -= new EventHandler(timer_Tick); + timer.Stop(); + + base.OnPageDestroy(new_windowId); + } + private void LoadSettings() { string dir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config); @@ -283,6 +325,7 @@ statusBar = xmlreader.GetValueAsBool("btWeb", "status", true); osd = xmlreader.GetValueAsBool("btWeb", "osd", true); windowed = xmlreader.GetValueAsBool("btWeb", "window", false); + useMouse = xmlreader.GetValueAsBool("btWeb", "mouse", false); defaultZoom = (float)xmlreader.GetValueAsInt("btWeb", "zoom", 100) / 100; zoom = defaultZoom; @@ -300,8 +343,6 @@ remote_zoom_out = xmlreader.GetValueAsString("btWeb", "key_4", "ACTION_PAGE_UP"); remote_status = xmlreader.GetValueAsString("btWeb", "key_5", "ACTION_SHOW_GUI"); - Setup.actualID = Convert.ToInt64(xmlreader.GetValueAsString("btWeb", "actualID", "123")); - useProxy = xmlreader.GetValueAsBool("btWeb", "proxy", false); Server = xmlreader.GetValueAsString("btWeb", "proxy_server", "127.0.0.1"); Port = xmlreader.GetValueAsInt("btWeb", "proxy_port", 8888); @@ -340,6 +381,9 @@ private void timer_Tick(object sender, EventArgs e) { + if (useMouse) + Cursor.Show(); + if (linkId != string.Empty) { if (osd) @@ -363,28 +407,7 @@ GUIPropertyManager.SetProperty("#btWeb.linkid", linkId); } } - protected override void OnPageDestroy(int new_windowId) - { - if (new_windowId != 54537688) - { // not if you got favs - if (blankBrowser) - { - webBrowser.Navigate("about:blank"); - MyLog.debug("blank on destroy"); - } - } - webBrowser.Visible = false; - osd_linkID.Visible = false; - webBrowser.DocumentCompleted -= new EventHandler(webBrowser_DocumentCompleted); - webBrowser.StatusTextChanged -= new EventHandler(webBrowser_StatusTextChanged); - - timer.Tick -= new EventHandler(timer_Tick); - timer.Stop(); - - base.OnPageDestroy(new_windowId); - } - public override void OnAction(Action action) { base.OnAction(action); @@ -405,16 +428,18 @@ #region selectable buttons if (strAction == remote_confirm) { - if (linkId != string.Empty) + if (!useMouse) { - MyLog.debug("confirm link pressed"); - OnLinkId(linkId); + if (linkId != string.Empty) + { + MyLog.debug("confirm link pressed"); + OnLinkId(linkId); + } + else + { + MyLog.debug("confirm2 link pressed, no link present"); + } } - else - { - MyLog.debug("confirm2 link pressed, no link present"); - } - return; } if (strAction == remote_bookmark) { @@ -424,16 +449,12 @@ if ((strAction == remote_zoom_in) || (action.wID == Action.ActionType.ACTION_MUSIC_FORWARD)) { - if (zoom < 2) zoom += 0.1f; - webBrowser.Zoom = zoom; - if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); + OnZoomIn(); } if ((strAction == remote_zoom_out) || (action.wID == Action.ActionType.ACTION_MUSIC_REWIND)) { - if (zoom > 0.1f) zoom -= 0.1f; - webBrowser.Zoom = zoom; - if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); + OnZoomOut(); } if (strAction == remote_status) { @@ -447,61 +468,75 @@ switch (action.wID) { - case Action.ActionType.ACTION_KEY_PRESSED: - linkTime = 0; - MyLog.debug("action key press=" + action.m_key.KeyChar); - switch (action.m_key.KeyChar) + case Action.ActionType.ACTION_MOUSE_CLICK: { - #region 0..9 - case '1': - linkId += "1"; - break; - case '2': - linkId += "2"; - break; - case '3': - linkId += "3"; - break; - case '4': - linkId += "4"; - break; - case '5': - linkId += "5"; - break; - case '6': - linkId += "6"; - break; - case '7': - linkId += "7"; - break; - case '8': - linkId += "8"; - break; - case '9': - linkId += "9"; - break; - case '0': - linkId += "0"; - break; - #endregion + break; } + case Action.ActionType.ACTION_MOUSE_MOVE: + if (useMouse) + { + + } break; - case Action.ActionType.ACTION_PLAY: - case Action.ActionType.ACTION_MUSIC_PLAY: - webBrowser.Visible = false; - string selectedUrl = "http://"; - if (ShowKeyboard(ref selectedUrl, false) == System.Windows.Forms.DialogResult.OK) + case Action.ActionType.ACTION_SHOW_SUBTITLES: + if (mouse.Visible) { - if (Bookmark.isValidUrl(selectedUrl)) + mouse.Visible = false; + + } + else + { + //mouse.Visible = true; + //mouse.BringToFront(); + } + break; + case Action.ActionType.ACTION_KEY_PRESSED: + if (!useMouse) + { + linkTime = 0; + MyLog.debug("action key press=" + action.m_key.KeyChar); + switch (action.m_key.KeyChar) { - webBrowser.Navigate(selectedUrl); - MyLog.debug("navigate to " + selectedUrl); + #region 0..9 + case '1': + linkId += "1"; + break; + case '2': + linkId += "2"; + break; + case '3': + linkId += "3"; + break; + case '4': + linkId += "4"; + break; + case '5': + linkId += "5"; + break; + case '6': + linkId += "6"; + break; + case '7': + linkId += "7"; + break; + case '8': + linkId += "8"; + break; + case '9': + linkId += "9"; + break; + case '0': + linkId += "0"; + break; + #endregion } - else - ShowAlert("Wrong link ?", " The link you entered seems to be not valid.", "Input:", selectedUrl); + if (linkId.Length > 4) linkId = linkId.Substring(0, 1); } - webBrowser.Visible = true; break; + case Action.ActionType.ACTION_PLAY: + case Action.ActionType.ACTION_MUSIC_PLAY: + OnEnterNewLink(); + break; case Action.ActionType.ACTION_PAUSE: webBrowser.Navigate(homepage); MyLog.debug("load home page " + homepage); @@ -529,17 +564,26 @@ #region move case Action.ActionType.ACTION_MOVE_RIGHT: - if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX + 100, webBrowser.Window.ScrollY); + OnMoveRight(); break; case Action.ActionType.ACTION_MOVE_LEFT: - if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX - 100, webBrowser.Window.ScrollY); + OnMoveLeft(); break; case Action.ActionType.ACTION_MOVE_UP: - if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY - 100); + OnMoveUp(); break; case Action.ActionType.ACTION_MOVE_DOWN: - if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY + 100); + OnMoveDown(); break; + case Action.ActionType.ACTION_SELECT_ITEM: + if (mouse.Visible) + { + //System.Windows.Forms.Cursor.Show(); + int x = GUIGraphicsContext.form.Location.X + mouse.Location.X + 20; + int y = GUIGraphicsContext.form.Location.Y + mouse.Location.Y + 50; + System.Windows.Forms.Cursor.Position = new Point(x, y); + } + break; #endregion } if (linkId != string.Empty) @@ -549,35 +593,68 @@ } - private void OnAddBookmark() + private void webBrowser_DomKeyDown(object sender, GeckoDomKeyEventArgs e) { - #region save snapshot + if (useMouse) + { + System.Diagnostics.Debug.WriteLine("DOM " + e.KeyCode.ToString()); - long id = Setup.actualID; + if (e.KeyCode == (uint)Keys.Escape) + GUIWindowManager.ShowPreviousWindow(); + System.Diagnostics.Debug.WriteLine(e.KeyCode.ToString()); - if (webBrowser.Url.ToString() != "about:blank") - { - int y = webBrowser.Height; - int x = y / 4 * 3; + if (e.KeyCode == (uint)Keys.PageUp) OnZoomIn(); + if (e.KeyCode == (uint)Keys.PageDown) OnZoomOut(); - int offset = (webBrowser.Width - x) / 2; + if (e.KeyCode == (uint)Keys.Down) OnMoveDown(); + if (e.KeyCode == (uint)Keys.Up) OnMoveUp(); + if (e.KeyCode == (uint)Keys.Left) OnMoveLeft(); + if (e.KeyCode == (uint)Keys.Right) OnMoveRight(); - Bitmap snap = new Bitmap(webBrowser.Width, webBrowser.Height); - webBrowser.DrawToBitmap(snap, new Rectangle(0, 0, webBrowser.Width, webBrowser.Height)); + if (e.KeyCode == (uint)Keys.R) OnAddBookmark(); - snap = CopyBitmap(snap, new Rectangle(offset, 0, x, y)); + if (e.CtrlKey == true) + { + if (e.KeyCode == (uint)Keys.P) + { + OnEnterNewLink(); - snap = MediaPortal.Util.BitmapResize.Resize(ref snap, 300, 400, false, true); + } + if (e.KeyCode == (uint)Keys.B) + { + webBrowser.Navigate("about:blank"); + } + } - Graphics g = Graphics.FromImage((Image)snap); - g.DrawRectangle(new Pen(Color.Black, 2), new Rectangle(1, 1, snap.Width - 2, snap.Height - 2)); + } + } - Bookmark.SaveSnap(snap, id); - Setup.IncAndSaveID(); + private void OnEnterNewLink() + { + webBrowser.Visible = false; + GUIGraphicsContext.form.Focus(); + + string selectedUrl = "http://"; + if (ShowKeyboard(ref selectedUrl, false) == System.Windows.Forms.DialogResult.OK) + { + if (Bookmark.isValidUrl(selectedUrl)) + { + webBrowser.Navigate(selectedUrl); + MyLog.debug("navigate to " + selectedUrl); + } + else + ShowAlert("Wrong link ?", " The link you entered seems to be not valid.", "Input:", selectedUrl); } - #endregion + webBrowser.Visible = true; + if (useMouse) + GUIGraphicsContext.form.Controls["BrowseTheWeb"].Select(); + + } + private void OnAddBookmark() + { webBrowser.Visible = false; + GUIGraphicsContext.form.Focus(); string title = webBrowser.Document.Title; string actualUrl = webBrowser.Document.Url.ToString(); @@ -587,14 +664,99 @@ System.Windows.Forms.DialogResult result = ShowKeyboard(ref title, false); if (result == System.Windows.Forms.DialogResult.OK) { - bool hasSaved = BookmarkXml.AddBookmark(title, actualUrl, Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", id); + bool hasSaved = BookmarkXml.AddBookmark(title, actualUrl, Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", 0); if (hasSaved) + { ShowAlert("Bookmark has been saved !", "Title : " + title, "URL : " + actualUrl, ""); + #region save snapshot + + if (webBrowser.Url.ToString() != "about:blank") + { + int y = webBrowser.Height; + int x = y / 4 * 3; + + int offset = (webBrowser.Width - x) / 2; + + Bitmap snap = new Bitmap(webBrowser.Width, webBrowser.Height); + webBrowser.DrawToBitmap(snap, new Rectangle(0, 0, webBrowser.Width, webBrowser.Height)); + + snap = CopyBitmap(snap, new Rectangle(offset, 0, x, y)); + + snap = MediaPortal.Util.BitmapResize.Resize(ref snap, 300, 400, false, true); + + Graphics g = Graphics.FromImage((Image)snap); + g.DrawRectangle(new Pen(Color.Black, 2), new Rectangle(1, 1, snap.Width - 2, snap.Height - 2)); + + Bookmark.SaveSnap(snap, actualUrl); + } + #endregion + + } else ShowAlert("Bookmark could not been saved !", "Title : " + title, "URL : " + actualUrl, ""); } + webBrowser.Visible = true; + if (useMouse) + GUIGraphicsContext.form.Controls["BrowseTheWeb"].Select(); } + private void OnZoomIn() + { + if (zoom < 2) zoom += 0.1f; + webBrowser.Zoom = zoom; + if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); + } + private void OnZoomOut() + { + if (zoom > 0.1f) zoom -= 0.1f; + webBrowser.Zoom = zoom; + if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); + } + private void OnMoveLeft() + { + if (!mouse.Visible) + { + if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX - 100, webBrowser.Window.ScrollY); + } + else + { + mouse.Location = new Point(mouse.Location.X - 20, mouse.Location.Y); + } + } + private void OnMoveRight() + { + if (!mouse.Visible) + { + if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX + 100, webBrowser.Window.ScrollY); + } + else + { + mouse.Location = new Point(mouse.Location.X + 20, mouse.Location.Y); + } + } + private void OnMoveUp() + { + if (!mouse.Visible) + { + if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY - 100); + } + else + { + mouse.Location = new Point(mouse.Location.X, mouse.Location.Y - 20); + } + } + private void OnMoveDown() + { + if (!mouse.Visible) + { + if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY + 100); + } + else + { + mouse.Location = new Point(mouse.Location.X, mouse.Location.Y + 20); + } + } + private Bitmap CopyBitmap(Bitmap srcBitmap, Rectangle section) { Bitmap bmp = new Bitmap(section.Width, section.Height); @@ -637,60 +799,98 @@ GUIPropertyManager.SetProperty("#btWeb.status", str); #endregion - #region add links to page - _htmlLinkNumbers = new List<HtmlLinkNumber>(); + if (!useMouse) + { + #region add links to page + _htmlLinkNumbers = new List<HtmlLinkNumber>(); - _links = webBrowser.Document.Links; - int i = 1; + _links = webBrowser.Document.Links; + int i = 1; - MyLog.debug("page links cnt : " + _links.Count); + MyLog.debug("page links cnt : " + _links.Count); - foreach (GeckoElement element in _links) - { - string link = element.GetAttribute("href"); + foreach (GeckoElement element in _links) + { + string link = element.GetAttribute("href"); - if (!link.StartsWith("javascript:")) - { - if (!element.InnerHtml.Contains("gecko_id")) + if (!link.StartsWith("javascript:")) { - element.InnerHtml += string.Format(_span, i, "", "LINK"); - } + if (!element.InnerHtml.Contains("gecko_id")) + { + element.InnerHtml += string.Format(_span, i, "", "LINK"); + } - string gb = element.GetAttribute("gb"); - string id = element.GetAttribute("id"); - string name = element.GetAttribute("name"); - if (string.IsNullOrEmpty(gb)) - { - element.SetAttribute("gb", "gecko_link" + i); + string gb = element.GetAttribute("gb"); + string id = element.GetAttribute("id"); + string name = element.GetAttribute("name"); + if (string.IsNullOrEmpty(gb)) + { + element.SetAttribute("gb", "gecko_link" + i); + } + if (string.IsNullOrEmpty(id)) + { + element.SetAttribute("id", "gb" + i); + id = "gb" + i; + } + _htmlLinkNumbers.Add(new HtmlLinkNumber(i, id, name, link, HtmlInputType.Link)); + i++; } - if (string.IsNullOrEmpty(id)) - { - element.SetAttribute("id", "gb" + i); - id = "gb" + i; - } - _htmlLinkNumbers.Add(new HtmlLinkNumber(i, id, name, link, HtmlInputType.Link)); - i++; } - } - _forms = webBrowser.Document.GetElementsByTagName("form"); - HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); + _forms = webBrowser.Document.GetElementsByTagName("form"); + HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); - MyLog.debug("page forms cnt : " + _forms.Count); + MyLog.debug("page forms cnt : " + _forms.Count); - foreach (GeckoElement element in _forms) - { - string action = element.GetAttribute("action"); - doc.LoadHtml(element.InnerHtml); - foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//*")) + foreach (GeckoElement element in _forms) { - if (link.OriginalName == "input") + string action = element.GetAttribute("action"); + doc.LoadHtml(element.InnerHtml); + foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//*")) { - if (link.Attributes["type"] != null) + if (link.OriginalName == "input") { - if (link.Attributes["type"].Value != "hidden") + if (link.Attributes["type"] != null) { + if (link.Attributes["type"].Value != "hidden") + { + string gb = link.GetAttributeValue("gb", ""); + string id = link.GetAttributeValue("id", ""); + string name = link.GetAttributeValue("name", ""); + string outerHtml = link.OuterHtml; + if (string.IsNullOrEmpty(gb)) + { + link.SetAttributeValue("gb", "gecko_link" + i); + } + if (string.IsNullOrEmpty(id)) + { + link.SetAttributeValue("id", "gb" + i); + id = "gb" + i; + } + + if (!element.InnerHtml.Contains("gecko_id=\"" + i + "\"")) + { + string newLink = link.OuterHtml + string.Format(_span, i, action, "INPUT"); + element.InnerHtml = element.InnerHtml.Replace(outerHtml, newLink); + } + if (link.Attributes["type"].Value == "submit" || + link.Attributes["type"].Value == "reset" || + link.Attributes["type"].Value == "radio" || + link.Attributes["type"].Value == "image" || + link.Attributes["type"].Value == "checkbox") + { + _htmlLinkNumbers.Add(new HtmlLinkNumber(i, id, name, action, HtmlInputType.Action)); + } + else + { + _htmlLinkNumbers.Add(new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); + } + i++; + } + } + else + { string gb = link.GetAttributeValue("gb", ""); string id = link.GetAttributeValue("id", ""); string name = link.GetAttributeValue("name", ""); @@ -710,51 +910,15 @@ string newLink = link.OuterHtml + string.Format(_span, i, action, "INPUT"); element.InnerHtml = element.InnerHtml.Replace(outerHtml, newLink); } - if (link.Attributes["type"].Value == "submit" || - link.Attributes["type"].Value == "reset" || - link.Attributes["type"].Value == "radio" || - link.Attributes["type"].Value == "image" || - link.Attributes["type"].Value == "checkbox") - { - _htmlLinkNumbers.Add(new HtmlLinkNumber(i, id, name, action, HtmlInputType.Action)); - } - else - { - _htmlLinkNumbers.Add(new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); - } + + _htmlLinkNumbers.Add(new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); i++; } } - else - { - string gb = link.GetAttributeValue("gb", ""); - string id = link.GetAttributeValue("id", ""); - string name = link.GetAttributeValue("name", ""); - string outerHtml = link.OuterHtml; - if (string.IsNullOrEmpty(gb)) - { - link.SetAttributeValue("gb", "gecko_link" + i); - } - if (string.IsNullOrEmpty(id)) - { - link.SetAttributeValue("id", "gb" + i); - id = "gb" + i; - } - - if (!element.InnerHtml.Contains("gecko_id=\"" + i + "\"")) - { - string newLink = link.OuterHtml + string.Format(_span, i, action, "INPUT"); - element.InnerHtml = element.InnerHtml.Replace(outerHtml, newLink); - } - - _htmlLinkNumbers.Add(new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); - i++; - } } } + #endregion } - #endregion - #region reset zoom if (zoomPage) { Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -1,4 +1,28 @@ -using System; +#region Copyright (C) 2005-2010 Team MediaPortal + +/* + * Copyright (C) 2005-2010 Team MediaPortal + * http://www.team-mediaportal.com + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ +#endregion + +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -13,7 +37,6 @@ public partial class GetThumb : Form { public string SelectedUrl = string.Empty; - private long id = 0; private GeckoWebBrowser browser; private Bitmap snap; @@ -21,14 +44,12 @@ private int time = 0; private int cancel = 0; - public GetThumb(long ID) + public GetThumb() { InitializeComponent(); browser = new GeckoWebBrowser(); this.Controls.Add(browser); - - id = ID; } private void GetThumb_Load(object sender, EventArgs e) { @@ -54,7 +75,7 @@ Graphics g = Graphics.FromImage((Image)snap); g.DrawRectangle(new Pen(Color.Black, 2), new Rectangle(1, 1, snap.Width - 2, snap.Height - 2)); - Bookmark.SaveSnap(snap, id); + Bookmark.SaveSnap(snap, SelectedUrl); received = true; chkGetThumb.Checked = true; } @@ -68,12 +89,13 @@ private void timer1_Tick(object sender, EventArgs e) { cancel++; - if (cancel > 30) this.Close(); + if (cancel > 100) this.Close(); if (received) { time++; - if (time > 20) this.Close(); + // implemented maybe later to get flash loaded... + if (time > 0) this.Close(); } } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -87,21 +87,17 @@ { imported++; - long id = Setup.actualID; - Setup.IncAndSaveID(); - TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); BookmarkElement addBkm = new BookmarkElement(); addBkm.Name = bkm.Name; addBkm.Url = bkm.Url; addBkm.isSubFolder = true; - addBkm.Id = id; add.Tag = addBkm; if (chkThumbs.Checked) { - GetThumb thumb = new GetThumb(id); + GetThumb thumb = new GetThumb(); thumb.SelectedUrl = bkm.Url; thumb.ShowDialog(); } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -85,21 +85,17 @@ { imported++; - long id = Setup.actualID; - Setup.IncAndSaveID(); - TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); BookmarkElement addBkm = new BookmarkElement(); addBkm.Name = bkm.Name; addBkm.Url = bkm.Url; addBkm.isSubFolder = true; - addBkm.Id = id; add.Tag = addBkm; if (chkThumbs.Checked) { - GetThumb thumb = new GetThumb(id); + GetThumb thumb = new GetThumb(); thumb.SelectedUrl = bkm.Url; thumb.ShowDialog(); } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -130,6 +130,7 @@ this.label22 = new System.Windows.Forms.Label(); this.comboBox4 = new System.Windows.Forms.ComboBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.chkMouse = new System.Windows.Forms.CheckBox(); this.contextMenuStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -328,6 +329,7 @@ // // groupBox5 // + this.groupBox5.Controls.Add(this.chkMouse); this.groupBox5.Controls.Add(this.chkWindowed); this.groupBox5.Controls.Add(this.chkOSD); this.groupBox5.Controls.Add(this.chkStatus); @@ -589,7 +591,7 @@ // this.trkZoom.LargeChange = 10; this.trkZoom.Location = new System.Drawing.Point(6, 21); - this.trkZoom.Maximum = 200; + this.trkZoom.Maximum = 300; this.trkZoom.Minimum = 10; this.trkZoom.Name = "trkZoom"; this.trkZoom.Size = new System.Drawing.Size(525, 45); @@ -1165,6 +1167,16 @@ this.checkBox1.Text = "Show diagnose on status bar"; this.checkBox1.UseVisualStyleBackColor = true; // + // chkMouse + // + this.chkMouse.AutoSize = true; + this.chkMouse.Location = new System.Drawing.Point(19, 181); + this.chkMouse.Name = "chkMouse"; + this.chkMouse.Size = new System.Drawing.Size(154, 20); + this.chkMouse.TabIndex = 6; + this.chkMouse.Text = "use mouse to browse"; + this.chkMouse.UseVisualStyleBackColor = true; + // // Setup // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1322,5 +1334,6 @@ private System.Windows.Forms.Button btnDefault; private System.Windows.Forms.Label label35; private System.Windows.Forms.ComboBox cmbShowBookmarks; + private System.Windows.Forms.CheckBox chkMouse; } } \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2010-11-17 08:13:53 UTC (rev 3939) @@ -49,8 +49,6 @@ private string remote_zoom_out = string.Empty; private string remote_status = string.Empty; - public static long actualID = 0; - #endregion public Setup() @@ -225,7 +223,7 @@ else { txtLink.Text = bkm.Url; - pictureBox1.Image = Bookmark.GetSnap(bkm.Id); + pictureBox1.Image = Bookmark.GetSnap(bkm.Url); } } else @@ -501,12 +499,9 @@ if (res != DialogResult.Yes) return; } - long id = actualID; - IncAndSaveID(); - if (chkUseThumbs.Checked) { - GetThumb thumb = new GetThumb(actualID); + GetThumb thumb = new GetThumb(); thumb.SelectedUrl = get.SelectedUrl; thumb.ShowDialog(); } @@ -522,7 +517,6 @@ addBkm.Url = get.SelectedUrl; addBkm.isSubFolder = true; addBkm.Created = DateTime.Now; - addBkm.Id = id; add.Tag = addBkm; node.ExpandAll(); @@ -535,7 +529,6 @@ addBkm.Name = get.SelectedName; addBkm.Url = get.SelectedUrl; addBkm.Created = DateTime.Now; - addBkm.Id = id; add.Tag = addBkm; node.Parent.ExpandAll(); @@ -549,7 +542,6 @@ addBkm.Name = get.SelectedName; addBkm.Url = get.SelectedUrl; addBkm.Created = DateTime.Now; - addBkm.Id = id; add.Tag = addBkm; treeView1.Nodes[0].ExpandAll(); @@ -666,6 +658,7 @@ chkStatus.Checked = xmlreader.GetValueAsBool("btWeb", "status", false); chkOSD.Checked = xmlreader.GetValueAsBool("btWeb", "osd", true); chkWindowed.Checked = xmlreader.GetValueAsBool("btWeb", "window", false); + chkMouse.Checked = xmlreader.GetValueAsBool("btWeb", "mouse", false); trkZoom.Value = xmlreader.GetValueAsInt("btWeb", "zoom", 100); trkFont.Value = xmlreader.GetValueAsInt("btWeb", "font", 100); @@ -682,8 +675,6 @@ remote_zoom_out = xmlreader.GetValueAsString("btWeb", "key_4", "ACTION_PAGE_DOWN"); remote_status = xmlreader.GetValueAsString("btWeb", "key_5", "ACTION_SHOW_GUI"); - actualID = Convert.ToInt64(xmlreader.GetValueAsString("btWeb", "actualID", "123")); - chkProxy.Checked = xmlreader.GetValueAsBool("btWeb", "proxy", false); txtHttpServer.Text = xmlreader.GetValueAsString("btWeb", "proxy_server", "127.0.0.1"); txtHttpPort.Text = xmlreader.GetValueAsInt("btWeb", "proxy_port", 8888).ToString(); @@ -704,6 +695,7 @@ xmlwriter.SetValueAsBool("btWeb", "status", chkStatus.Checked); xmlwriter.SetValueAsBool("btWeb", "osd", chkOSD.Checked); xmlwriter.SetValueAsBool("btWeb", "window", chkWindowed.Checked); + xmlwriter.SetValueAsBool("btWeb", "mouse", chkMouse.Checked); xmlwriter.SetValue("btWeb", "zoom", trkZoom.Value); xmlwriter.SetValue("btWeb", "font", trkFont.Value); @@ -725,18 +717,7 @@ xmlwriter.SetValue("btWeb", "proxy_port", txtHttpPort.Text); } } - public static void IncAndSaveID() - { - actualID++; - string dir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config); - using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(dir + "\\MediaPortal.xml")) - { - xmlwriter.SetValue("btWeb", "actualID", actualID.ToString()); - } - - } - #region zoom & font private void trkRemote_ValueChanged(object sender, EventArgs e) { @@ -761,19 +742,13 @@ { if (!bkm.isFolder) { - //if (bkm.Id == 0) - { - bkm.Id = Setup.actualID; - IncAndSaveID(); - } - pictureBox1.Image = null; - GetThumb thumb = new GetThumb(bkm.Id); + GetThumb thumb = new GetThumb(); thumb.SelectedUrl = bkm.Url; thumb.ShowDialog(); - pictureBox1.Image = Bookmark.GetSnap(bkm.Id); + pictureBox1.Image = Bookmark.GetSnap(bkm.Url); } } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2010-11-17 08:13:53 UTC (rev 3939) @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABM - CgAAAk1TRnQBSQFMAgEBAwEAATABAQEwAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CgAAAk1TRnQBSQFMAgEBAwEAATgBAQE4AQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/todo.txt =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/todo.txt 2010-11-15 19:49:11 UTC (rev 3938) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/todo.txt 2010-11-17 08:13:53 UTC (rev 3939) @@ -17,7 +17,9 @@ v0.2.4.2 fixed remote link id time todo: -better thumb support via id +better thumb support via id ? +save thumb by saving bookmark +mouseless / mouse browsing planed: better alternate OSD Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.suo =================================================================== (Binary files differ) Modified: trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.suo =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |