From: <Sil...@us...> - 2010-11-09 21:06:16
|
Revision: 3911 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3911&view=rev Author: SilentException Date: 2010-11-09 21:06:10 +0000 (Tue, 09 Nov 2010) Log Message: ----------- BrowseTheWeb: added ability to load startup link from property Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2010-11-09 11:23:40 UTC (rev 3910) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2010-11-09 21:06:10 UTC (rev 3911) @@ -78,7 +78,7 @@ } else { - GUIPlugin.loadFav = item.Path; + GUIPlugin.StartupLink = item.Path; GUIWindowManager.ActivateWindow(54537689); } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2010-11-09 11:23:40 UTC (rev 3910) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2010-11-09 21:06:10 UTC (rev 3911) @@ -134,6 +134,19 @@ base.GetID = value; } } + + public static string StartupLink + { + get + { + string value = GUIPropertyManager.GetProperty("#btWeb.startup.link"); + if (null != value && !string.IsNullOrEmpty(value.Trim())) + return value.Trim(); + return string.Empty; + } + set { GUIPropertyManager.SetProperty("#btWeb.startup.link", string.IsNullOrEmpty(value) ? " " : value.Trim()); } + } + public override bool Init() { Xpcom.Initialize(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\xulrunner"); @@ -180,19 +193,22 @@ webBrowser.DocumentCompleted += new EventHandler(webBrowser_DocumentCompleted); webBrowser.StatusTextChanged += new EventHandler(webBrowser_StatusTextChanged); + string loadFav = StartupLink; + if (webBrowser.Document.Domain == string.Empty) { - if ((usehome) && (loadFav == string.Empty)) + if ((usehome) && (string.IsNullOrEmpty(loadFav))) { webBrowser.Navigate(homepage); MyLog.debug("load home page " + homepage); } } - if (loadFav != string.Empty) + + if (!string.IsNullOrEmpty(loadFav)) { webBrowser.Navigate(loadFav); MyLog.debug("load favorite " + loadFav); - loadFav = string.Empty; + StartupLink = string.Empty; } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kro...@us...> - 2011-03-27 19:59:09
|
Revision: 4154 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4154&view=rev Author: kroko_koenig Date: 2011-03-27 19:59:02 +0000 (Sun, 27 Mar 2011) Log Message: ----------- add chrome import Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx Added Paths: ----------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.resx Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2011-03-26 09:50:29 UTC (rev 4153) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2011-03-27 19:59:02 UTC (rev 4154) @@ -22,7 +22,7 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <UseVSHostingProcess>false</UseVSHostingProcess> - <PlatformTarget>x86</PlatformTarget> + <PlatformTarget>AnyCPU</PlatformTarget> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -113,6 +113,12 @@ <Compile Include="ImportFF.Designer.cs"> <DependentUpon>ImportFF.cs</DependentUpon> </Compile> + <Compile Include="ImportChrome.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="ImportChrome.Designer.cs"> + <DependentUpon>ImportChrome.cs</DependentUpon> + </Compile> <Compile Include="Mouse.cs"> <SubType>UserControl</SubType> </Compile> @@ -183,6 +189,10 @@ <DependentUpon>ImportFF.cs</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="ImportChrome.resx"> + <DependentUpon>ImportChrome.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> <EmbeddedResource Include="Mouse.resx"> <DependentUpon>Mouse.cs</DependentUpon> <SubType>Designer</SubType> Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user 2011-03-26 09:50:29 UTC (rev 4153) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user 2011-03-27 19:59:02 UTC (rev 4154) @@ -1,9 +1,9 @@ <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\Configuration.exe</StartProgram> </PropertyGroup> <PropertyGroup> - <ProjectView>ShowAllFiles</ProjectView> + <ProjectView>ProjectFiles</ProjectView> </PropertyGroup> </Project> \ No newline at end of file Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.Designer.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.Designer.cs 2011-03-27 19:59:02 UTC (rev 4154) @@ -0,0 +1,143 @@ +namespace BrowseTheWeb +{ + partial class ImportChrome + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.listBox1 = new System.Windows.Forms.ListBox(); + this.btnImport = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.btnSelect = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.prgState = new System.Windows.Forms.ProgressBar(); + this.chkThumbs = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.Location = new System.Drawing.Point(12, 35); + this.listBox1.Name = "listBox1"; + this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; + this.listBox1.Size = new System.Drawing.Size(502, 225); + this.listBox1.TabIndex = 0; + // + // btnImport + // + this.btnImport.Location = new System.Drawing.Point(12, 341); + this.btnImport.Name = "btnImport"; + this.btnImport.Size = new System.Drawing.Size(139, 31); + this.btnImport.TabIndex = 1; + this.btnImport.Text = "Import"; + this.btnImport.UseVisualStyleBackColor = true; + this.btnImport.Click += new System.EventHandler(this.btnImport_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(135, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Select bookmarks to import"; + // + // btnSelect + // + this.btnSelect.Location = new System.Drawing.Point(12, 266); + this.btnSelect.Name = "btnSelect"; + this.btnSelect.Size = new System.Drawing.Size(139, 23); + this.btnSelect.TabIndex = 3; + this.btnSelect.Text = "select / deselect all"; + this.btnSelect.UseVisualStyleBackColor = true; + this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click); + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(375, 341); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(139, 31); + this.btnCancel.TabIndex = 4; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // prgState + // + this.prgState.Location = new System.Drawing.Point(12, 302); + this.prgState.Name = "prgState"; + this.prgState.Size = new System.Drawing.Size(502, 23); + this.prgState.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.prgState.TabIndex = 5; + this.prgState.Visible = false; + // + // chkThumbs + // + this.chkThumbs.AutoSize = true; + this.chkThumbs.Location = new System.Drawing.Point(187, 270); + this.chkThumbs.Name = "chkThumbs"; + this.chkThumbs.Size = new System.Drawing.Size(164, 17); + this.chkThumbs.TabIndex = 6; + this.chkThumbs.Text = "make thumbs (take long time)"; + this.chkThumbs.UseVisualStyleBackColor = true; + // + // ImportChrome + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(526, 384); + this.Controls.Add(this.chkThumbs); + this.Controls.Add(this.prgState); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnSelect); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnImport); + this.Controls.Add(this.listBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ImportChrome"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Import Chrome"; + this.Load += new System.EventHandler(this.ImportChr_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.Button btnImport; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button btnSelect; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.ProgressBar prgState; + private System.Windows.Forms.CheckBox chkThumbs; + } +} \ No newline at end of file Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.cs 2011-03-27 19:59:02 UTC (rev 4154) @@ -0,0 +1,234 @@ +#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; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.IO; +using MediaPortal.Configuration; + +namespace BrowseTheWeb +{ + public partial class ImportChrome : Form + { + private List<BookmarkElement> EntryList = new List<BookmarkElement>(); + private TreeView tree; + private bool select = true; + + public ImportChrome(TreeView SetupTreeview) + { + InitializeComponent(); + tree = SetupTreeview; + } + + private void btnImport_Click(object sender, EventArgs e) + { + btnImport.Visible = false; + btnSelect.Visible = false; + prgState.Visible = true; + chkThumbs.Enabled = false; + + int max = listBox1.SelectedItems.Count; + int imported = 0; + int counter = 1; + + #region get parent + TreeNode node = null; + foreach (TreeNode n in tree.Nodes[0].Nodes) + { + if (n.Text == "Import Chrome") + { + node = n; + break; + } + } + #endregion + + if (node != null) + { + foreach (Object item in listBox1.SelectedItems) + { + Application.DoEvents(); + prgState.Value = (counter * 100 / max); + + string name = (string)item; + BookmarkElement bkm = GetBookmark(name); + + if (bkm != null) + { + if (!Bookmark.Exists(tree, bkm.Name)) + { + imported++; + + TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); + + BookmarkElement addBkm = new BookmarkElement(); + addBkm.Name = bkm.Name; + addBkm.Url = bkm.Url; + addBkm.isSubFolder = true; + add.Tag = addBkm; + + if (chkThumbs.Checked) + { + GetThumb thumb = new GetThumb(); + thumb.SelectedUrl = bkm.Url; + thumb.ShowDialog(); + } + + node.ExpandAll(); + } + } + counter++; + } + } + + MessageBox.Show("Import is done. Imported " + imported.ToString() + " links."); + this.Close(); + } + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void ImportChr_Load(object sender, EventArgs e) + { + try + { + string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + path += "\\Google\\Chrome\\User Data\\Default"; + + MyLog.debug("Chrome folder is " + path); + + if (Directory.Exists(path)) + { + if (File.Exists(path + "\\Bookmarks")) + { + MyLog.debug("Open bookmarks"); + + StreamReader sr = new StreamReader(path + "\\Bookmarks"); + string line = sr.ReadToEnd(); + sr.Close(); + + MyLog.debug("Read " + line.Length + " bytes"); + + int x = 0; + int secNo = 1; + + while ((x = line.IndexOf("children\": [", x + 1)) > 0) + { + int y = line.IndexOf("]", x + 12); + string section = line.Substring(x + 12, y - x - 12); + + MyLog.debug("Read section " + secNo); + secNo++; + + int start = 0; + while ((start = section.IndexOf("{", start + 1)) > 0) + { + int stop = section.IndexOf("}", start + 1); + string entry = section.Substring(start + 1, stop - start - 3); + + string[] sep = new string[1]; + sep[0] = "\r\n"; + string[] lines = entry.Split(sep, StringSplitOptions.RemoveEmptyEntries); + + for (int i = 0; i < lines.Length; i++) + { + lines[i] = lines[i].Replace("\"", ""); + lines[i] = lines[i].Trim(); + } + + string name = string.Empty; + string url = string.Empty; + string typ = string.Empty; + + for (int i = 0; i < lines.Length; i++) + { + if (lines[i].StartsWith("type:")) + { + typ = lines[i].Replace("type:", "").Trim(); + if (typ.EndsWith(",")) typ = typ.Substring(0, typ.Length - 1); + } + if (lines[i].StartsWith("name:")) + { + name = lines[i].Replace("name:", "").Trim(); + if (name.EndsWith(",")) name = name.Substring(0, name.Length - 1); + } + if (lines[i].StartsWith("url:")) + { // with / + url = lines[i].Replace("url:", "").Trim(); + } + } + + if ((name != "") && (typ == "url") && (url != "")) + { + MyLog.debug("Found bookmark " + name); + + BookmarkElement bkm = new BookmarkElement(); + bkm.Url = url; + bkm.Name = name; + + EntryList.Add(bkm); + listBox1.Items.Add(bkm.Name); + } + } + } + + + + + } + + } + } + catch (Exception ex) + { + MyLog.debug("Exception import chrome : " + ex.Message); + MyLog.debug("Exception import chrome : " + ex.StackTrace); + } + } + + private BookmarkElement GetBookmark(string Name) + { + foreach (BookmarkElement bkm in EntryList) + { + if (bkm.Name == Name) return bkm; + } + return null; + } + + private void btnSelect_Click(object sender, EventArgs e) + { + for (int i = 0; i < listBox1.Items.Count; i++) + { + listBox1.SetSelected(i, select); + } + select = !select; + } + } +} Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.resx (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.resx 2011-03-27 19:59:02 UTC (rev 4154) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2011-03-26 09:50:29 UTC (rev 4153) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2011-03-27 19:59:02 UTC (rev 4154) @@ -61,6 +61,8 @@ this.trkRemote = new System.Windows.Forms.TrackBar(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.groupBox12 = new System.Windows.Forms.GroupBox(); + this.cmbBookmarkView = new System.Windows.Forms.ComboBox(); this.groupBox7 = new System.Windows.Forms.GroupBox(); this.chkThumbsOnVisit = new System.Windows.Forms.CheckBox(); this.chkUseThumbs = new System.Windows.Forms.CheckBox(); @@ -131,8 +133,7 @@ this.label22 = new System.Windows.Forms.Label(); this.comboBox4 = new System.Windows.Forms.ComboBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); - this.groupBox12 = new System.Windows.Forms.GroupBox(); - this.cmbBookmarkView = new System.Windows.Forms.ComboBox(); + this.btnImportChr = new System.Windows.Forms.Button(); this.contextMenuStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -141,6 +142,7 @@ ((System.ComponentModel.ISupportInitialize)(this.trkRemote)).BeginInit(); this.groupBox3.SuspendLayout(); this.tabPage2.SuspendLayout(); + this.groupBox12.SuspendLayout(); this.groupBox7.SuspendLayout(); this.groupBox6.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -155,7 +157,6 @@ this.groupBox11.SuspendLayout(); this.groupBox10.SuspendLayout(); this.groupBox9.SuspendLayout(); - this.groupBox12.SuspendLayout(); this.SuspendLayout(); // // treeView1 @@ -471,6 +472,24 @@ this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Appeareance"; // + // groupBox12 + // + this.groupBox12.Controls.Add(this.cmbBookmarkView); + this.groupBox12.Location = new System.Drawing.Point(6, 391); + this.groupBox12.Name = "groupBox12"; + this.groupBox12.Size = new System.Drawing.Size(550, 79); + this.groupBox12.TabIndex = 22; + this.groupBox12.TabStop = false; + this.groupBox12.Text = "Bookmarks view"; + // + // cmbBookmarkView + // + this.cmbBookmarkView.FormattingEnabled = true; + this.cmbBookmarkView.Location = new System.Drawing.Point(26, 37); + this.cmbBookmarkView.Name = "cmbBookmarkView"; + this.cmbBookmarkView.Size = new System.Drawing.Size(145, 24); + this.cmbBookmarkView.TabIndex = 0; + // // groupBox7 // this.groupBox7.Controls.Add(this.chkThumbsOnVisit); @@ -618,6 +637,7 @@ // tabPage3 // this.tabPage3.BackColor = System.Drawing.SystemColors.Control; + this.tabPage3.Controls.Add(this.btnImportChr); this.tabPage3.Controls.Add(this.btnImportFF); this.tabPage3.Controls.Add(this.btnImportIE); this.tabPage3.Controls.Add(this.label7); @@ -1181,24 +1201,16 @@ this.checkBox1.Text = "Show diagnose on status bar"; this.checkBox1.UseVisualStyleBackColor = true; // - // groupBox12 + // btnImportChr // - this.groupBox12.Controls.Add(this.cmbBookmarkView); - this.groupBox12.Location = new System.Drawing.Point(6, 391); - this.groupBox12.Name = "groupBox12"; - this.groupBox12.Size = new System.Drawing.Size(550, 79); - this.groupBox12.TabIndex = 22; - this.groupBox12.TabStop = false; - this.groupBox12.Text = "Bookmarks view"; + this.btnImportChr.Location = new System.Drawing.Point(168, 442); + this.btnImportChr.Name = "btnImportChr"; + this.btnImportChr.Size = new System.Drawing.Size(79, 23); + this.btnImportChr.TabIndex = 20; + this.btnImportChr.Text = "Import Chr"; + this.btnImportChr.UseVisualStyleBackColor = true; + this.btnImportChr.Click += new System.EventHandler(this.btnImportChr_Click); // - // cmbBookmarkView - // - this.cmbBookmarkView.FormattingEnabled = true; - this.cmbBookmarkView.Location = new System.Drawing.Point(26, 37); - this.cmbBookmarkView.Name = "cmbBookmarkView"; - this.cmbBookmarkView.Size = new System.Drawing.Size(145, 24); - this.cmbBookmarkView.TabIndex = 0; - // // Setup // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1226,6 +1238,7 @@ this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); this.tabPage2.ResumeLayout(false); + this.groupBox12.ResumeLayout(false); this.groupBox7.ResumeLayout(false); this.groupBox7.PerformLayout(); this.groupBox6.ResumeLayout(false); @@ -1250,7 +1263,6 @@ this.groupBox10.PerformLayout(); this.groupBox9.ResumeLayout(false); this.groupBox9.PerformLayout(); - this.groupBox12.ResumeLayout(false); this.ResumeLayout(false); } @@ -1360,5 +1372,6 @@ private System.Windows.Forms.CheckBox chkMouse; private System.Windows.Forms.GroupBox groupBox12; private System.Windows.Forms.ComboBox cmbBookmarkView; + private System.Windows.Forms.Button btnImportChr; } } \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2011-03-26 09:50:29 UTC (rev 4153) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2011-03-27 19:59:02 UTC (rev 4154) @@ -860,7 +860,30 @@ treeView1.Invalidate(); } + private void btnImportChr_Click(object sender, EventArgs e) + { + #region generate folder + if (!Bookmark.Exists(treeView1, "Import Chrome")) + { + TreeNode newNode = treeView1.Nodes[0].Nodes.Add("Import Chrome"); + newNode.ImageIndex = 1; + newNode.SelectedImageIndex = 1; + BookmarkElement bkm = new BookmarkElement(); + bkm.Name = "Import Chrome"; + bkm.isFolder = true; + newNode.Tag = bkm; + + treeView1.Nodes[0].ExpandAll(); + } + #endregion + + ImportChrome import = new ImportChrome(treeView1); + import.ShowDialog(); + + treeView1.Invalidate(); + } + private void btnDefault_Click(object sender, EventArgs e) { cmbConfirmLink.SelectedItem = MediaPortal.GUI.Library.Action.ActionType.ACTION_PARENT_DIR; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2011-03-26 09:50:29 UTC (rev 4153) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2011-03-27 19:59:02 UTC (rev 4154) @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABM - CgAAAk1TRnQBSQFMAgEBAwEAAUABAQFAAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CgAAAk1TRnQBSQFMAgEBAwEAAUgBAQFIAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Sil...@us...> - 2011-06-03 08:10:21
|
Revision: 4237 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4237&view=rev Author: SilentException Date: 2011-06-03 08:10:14 +0000 (Fri, 03 Jun 2011) Log Message: ----------- BrowseTheWeb - load with parameter, thanks JiRo - thread safe initialization - select first item in bookmarks screen - minor bug fixes Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2011-05-30 07:45:45 UTC (rev 4236) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2011-06-03 08:10:14 UTC (rev 4237) @@ -245,6 +245,7 @@ } GUIPropertyManager.SetProperty("#itemcount", facade.Count.ToString()); + facade.SelectedListItemIndex = 0; } catch { } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2011-05-30 07:45:45 UTC (rev 4236) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2011-06-03 08:10:14 UTC (rev 4237) @@ -98,6 +98,9 @@ private float zoom = 1.0f; private float font = 1.0f; + public static bool ParameterSupported = false; + public static string Parameter = string.Empty; + public static string loadFav = string.Empty; private string lastUrl = string.Empty; @@ -167,9 +170,17 @@ { get { - string value = GUIPropertyManager.GetProperty("#btWeb.startup.link"); + string value = Parameter; if (null != value && !string.IsNullOrEmpty(value.Trim())) + { return value.Trim(); + } + else + { + value = GUIPropertyManager.GetProperty("#btWeb.startup.link"); + if (null != value && !string.IsNullOrEmpty(value.Trim())) + return value.Trim(); + } return string.Empty; } set { GUIPropertyManager.SetProperty("#btWeb.startup.link", string.IsNullOrEmpty(value) ? " " : value.Trim()); } @@ -179,6 +190,29 @@ { MyLog.debug("Init Browse the web"); + AddFormsDelegate d = AddForms; + GUIGraphicsContext.form.Invoke(d); + + #region parameters test + ParameterSupported = false; + if (typeof(GUIWindow).GetField("_loadParameter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) != null) + { + ParameterSupported = true; + } + #endregion + + LoadSettings(); + BookmarkXml.AddFolder(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + + "\\bookmarks.xml", "Saved by MP"); + + MyLog.debug("Init Browse the web finished"); + + return Load(GUIGraphicsContext.Skin + @"\BrowseTheWeb.xml"); + } + + private delegate void AddFormsDelegate(); + + private void AddForms() { try { Xpcom.Initialize(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\xulrunner"); @@ -195,7 +229,6 @@ webBrowser.NoDefaultContextMenu = true; GUIGraphicsContext.form.Controls.Add(webBrowser); - webBrowser.Enabled = false; webBrowser.Visible = false; @@ -207,14 +240,6 @@ GUIGraphicsContext.form.Controls.Add(mouse); mouse.Visible = false; #endregion - - LoadSettings(); - BookmarkXml.AddFolder(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + - "\\bookmarks.xml", "Saved by MP"); - - MyLog.debug("Init Browse the web finished"); - - return Load(GUIGraphicsContext.Skin + @"\BrowseTheWeb.xml"); } protected override void OnPageLoad() @@ -235,6 +260,12 @@ GUIGraphicsContext.MouseSupport = true; } + Parameter = null; + if (ParameterSupported) + { + Parameter = _loadParameter; + } + #region init browser webBrowser.Visible = true; @@ -443,7 +474,7 @@ public override bool OnMessage(GUIMessage message) { - Console.WriteLine("message :" + message.Label); + //Console.WriteLine("message :" + message.Label); return base.OnMessage(message); } @@ -602,7 +633,7 @@ // escape if (!osd_linkID.Visible) { - GUIWindowManager.ShowPreviousWindow(); + //GUIWindowManager.ShowPreviousWindow(); } else { @@ -670,6 +701,7 @@ return; #endregion } + base.OnAction(action); } private void webBrowser_DomKeyDown(object sender, GeckoDomKeyEventArgs e) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2012-04-08 17:33:30
|
Revision: 4475 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4475&view=rev Author: doskabouter Date: 2012-04-08 17:33:24 +0000 (Sun, 08 Apr 2012) Log Message: ----------- - fixed initial DefaultZoom - fixed crash in configuration Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-08 16:30:48 UTC (rev 4474) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-08 17:33:24 UTC (rev 4475) @@ -71,7 +71,7 @@ private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); private string lastDomain = string.Empty; - private float zoom = 1.0f; + private float zoom = Settings.Instance.DefaultZoom; private Settings settings = Settings.Instance; public static bool ParameterSupported = false; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs 2012-04-08 16:30:48 UTC (rev 4474) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs 2012-04-08 17:33:24 UTC (rev 4475) @@ -109,7 +109,14 @@ Port = xmlreader.GetValueAsInt(section, "proxy_port", 8888); string tmp = xmlreader.GetValueAsString(section, "bookmark", GUIFacadeControl.Layout.LargeIcons.ToString()); tmp = tmp.Replace(" ", String.Empty);// for backwards compatibility - View = (GUIFacadeControl.Layout)Enum.Parse(typeof(GUIFacadeControl.Layout), tmp, true); + try + { + View = (GUIFacadeControl.Layout)Enum.Parse(typeof(GUIFacadeControl.Layout), tmp, true); + } + catch + { + View = GUIFacadeControl.Layout.LargeIcons; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2012-04-08 21:51:07
|
Revision: 4477 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4477&view=rev Author: doskabouter Date: 2012-04-08 21:50:59 +0000 (Sun, 08 Apr 2012) Log Message: ----------- general cleanup/formatting Modified Paths: -------------- 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/GUIBookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlLinkNumber.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/OSD_LinkId.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -23,8 +23,6 @@ #endregion using System; -using System.Collections.Generic; -using System.Text; using System.Xml; using System.IO; using System.Windows.Forms; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -23,21 +23,19 @@ #endregion using System; -using System.Collections.Generic; -using System.Text; namespace BrowseTheWeb { - public class BookmarkElement - { - public string Name = string.Empty; - public string Url = string.Empty; + public class BookmarkElement + { + public string Name = string.Empty; + public string Url = string.Empty; - public int Visited = 0; - public DateTime LastVisited; - public DateTime Created = DateTime.Now; + public int Visited = 0; + public DateTime LastVisited; + public DateTime Created = DateTime.Now; - public bool isFolder = false; - public bool isSubFolder = false; - } + public bool isFolder = false; + public bool isSubFolder = false; + } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -24,167 +24,166 @@ using System; using System.Collections.Generic; -using System.Text; using System.Xml; using System.IO; namespace BrowseTheWeb { - public class BookmarkXml - { - public static List<BookmarkElement> BookmarkItems = new List<BookmarkElement>(); - - private static void InitBookmarks(string Path) + public class BookmarkXml { - if (!File.Exists(Path)) - { - string s = "<?xml version=\"1.0\"?>\n<Bookmarks />"; - StreamWriter sr = new StreamWriter(Path); - sr.Write(s); - sr.Close(); - } - } + public static List<BookmarkElement> BookmarkItems = new List<BookmarkElement>(); - public static bool LoadBookmarks(string Path) - { - InitBookmarks(Path); - - BookmarkItems = new List<BookmarkElement>(); - try - { - XmlDocument xmlDocument = new XmlDocument(); - xmlDocument.Load(Path); - - XmlNodeList col = xmlDocument.GetElementsByTagName("Entry"); - foreach (XmlNode node in col) + private static void InitBookmarks(string Path) { - BookmarkElement elem = GetData(node); - BookmarkItems.Add(elem); + if (!File.Exists(Path)) + { + string s = "<?xml version=\"1.0\"?>\n<Bookmarks />"; + StreamWriter sr = new StreamWriter(Path); + sr.Write(s); + sr.Close(); + } } - } - catch - { - return false; - } - return true; - } - public static BookmarkElement GetData(XmlNode Node) - { - BookmarkElement result = new BookmarkElement(); - result.Name = Node.SelectSingleNode("Name").InnerText; - result.Url = Node.SelectSingleNode("URL").InnerText; + public static bool LoadBookmarks(string Path) + { + InitBookmarks(Path); - result.Visited = Convert.ToInt32(Node.SelectSingleNode("Visited").InnerText); - result.LastVisited = Convert.ToDateTime(Node.SelectSingleNode("LastVisited").InnerText); - result.Created = Convert.ToDateTime(Node.SelectSingleNode("Created").InnerText); + BookmarkItems = new List<BookmarkElement>(); + try + { + XmlDocument xmlDocument = new XmlDocument(); + xmlDocument.Load(Path); - result.isFolder = Convert.ToBoolean(Node.SelectSingleNode("isFolder").InnerText); - result.isSubFolder = Convert.ToBoolean(Node.SelectSingleNode("isSubFolder").InnerText); + XmlNodeList col = xmlDocument.GetElementsByTagName("Entry"); + foreach (XmlNode node in col) + { + BookmarkElement elem = GetData(node); + BookmarkItems.Add(elem); + } + } + catch + { + return false; + } + return true; + } + public static BookmarkElement GetData(XmlNode Node) + { + BookmarkElement result = new BookmarkElement(); - return result; - } + result.Name = Node.SelectSingleNode("Name").InnerText; + result.Url = Node.SelectSingleNode("URL").InnerText; - public static void AddFolder(string Path, string FolderName) - { - InitBookmarks(Path); + result.Visited = Convert.ToInt32(Node.SelectSingleNode("Visited").InnerText); + result.LastVisited = Convert.ToDateTime(Node.SelectSingleNode("LastVisited").InnerText); + result.Created = Convert.ToDateTime(Node.SelectSingleNode("Created").InnerText); - try - { - XmlDocument xmlDocument = new XmlDocument(); - xmlDocument.Load(Path); + result.isFolder = Convert.ToBoolean(Node.SelectSingleNode("isFolder").InnerText); + result.isSubFolder = Convert.ToBoolean(Node.SelectSingleNode("isSubFolder").InnerText); - bool found = false; - - foreach (XmlNode r in xmlDocument.ChildNodes) - { - foreach (XmlNode one in r.ChildNodes) - { - if (one.FirstChild.InnerText == FolderName) found = true; - } + return result; } - if (!found) + public static void AddFolder(string Path, string FolderName) { - XmlElement childElement = xmlDocument.CreateElement("Entry"); + InitBookmarks(Path); - XmlElement sub1 = xmlDocument.CreateElement("Name"); sub1.InnerText = FolderName; - childElement.AppendChild(sub1); - XmlElement sub2 = xmlDocument.CreateElement("URL"); sub2.InnerText = string.Empty; - childElement.AppendChild(sub2); - XmlElement sub3 = xmlDocument.CreateElement("ID"); sub3.InnerText = "0"; - childElement.AppendChild(sub3); - XmlElement sub4 = xmlDocument.CreateElement("Visited"); sub4.InnerText = "0"; - childElement.AppendChild(sub4); - XmlElement sub5 = xmlDocument.CreateElement("LastVisited"); sub5.InnerText = "0001-01-01T00:00:00"; - childElement.AppendChild(sub5); - XmlElement sub6 = xmlDocument.CreateElement("Created"); sub6.InnerText = DateTime.UtcNow.ToString("u", null); - childElement.AppendChild(sub6); - XmlElement sub7 = xmlDocument.CreateElement("isFolder"); sub7.InnerText = "true"; - childElement.AppendChild(sub7); - XmlElement sub8 = xmlDocument.CreateElement("isSubFolder"); sub8.InnerText = "false"; - childElement.AppendChild(sub8); + try + { + XmlDocument xmlDocument = new XmlDocument(); + xmlDocument.Load(Path); - XmlNode parentNode = xmlDocument.SelectSingleNode("Bookmarks"); - parentNode.InsertBefore(childElement, parentNode.FirstChild); - } - xmlDocument.Save(Path); - } - catch - { } - } - public static bool AddBookmark(string Title, string Url, string Path, long ID) - { - try - { - XmlDocument xmlDocument = new XmlDocument(); - xmlDocument.Load(Path); + bool found = false; - bool found = false; - XmlNode folder = null; + foreach (XmlNode r in xmlDocument.ChildNodes) + { + foreach (XmlNode one in r.ChildNodes) + { + if (one.FirstChild.InnerText == FolderName) found = true; + } + } - foreach (XmlNode r in xmlDocument.ChildNodes) - { + if (!found) + { + XmlElement childElement = xmlDocument.CreateElement("Entry"); - foreach (XmlNode one in r.ChildNodes) - { - if (one.FirstChild.InnerText == Title) found = true; - if (one.FirstChild.InnerText == "Saved by MP") folder = one; - } - } + XmlElement sub1 = xmlDocument.CreateElement("Name"); sub1.InnerText = FolderName; + childElement.AppendChild(sub1); + XmlElement sub2 = xmlDocument.CreateElement("URL"); sub2.InnerText = string.Empty; + childElement.AppendChild(sub2); + XmlElement sub3 = xmlDocument.CreateElement("ID"); sub3.InnerText = "0"; + childElement.AppendChild(sub3); + XmlElement sub4 = xmlDocument.CreateElement("Visited"); sub4.InnerText = "0"; + childElement.AppendChild(sub4); + XmlElement sub5 = xmlDocument.CreateElement("LastVisited"); sub5.InnerText = "0001-01-01T00:00:00"; + childElement.AppendChild(sub5); + XmlElement sub6 = xmlDocument.CreateElement("Created"); sub6.InnerText = DateTime.UtcNow.ToString("u", null); + childElement.AppendChild(sub6); + XmlElement sub7 = xmlDocument.CreateElement("isFolder"); sub7.InnerText = "true"; + childElement.AppendChild(sub7); + XmlElement sub8 = xmlDocument.CreateElement("isSubFolder"); sub8.InnerText = "false"; + childElement.AppendChild(sub8); - if ((!found) && (folder != null)) + XmlNode parentNode = xmlDocument.SelectSingleNode("Bookmarks"); + parentNode.InsertBefore(childElement, parentNode.FirstChild); + } + xmlDocument.Save(Path); + } + catch + { } + } + public static bool AddBookmark(string Title, string Url, string Path, long ID) { - XmlElement childElement = xmlDocument.CreateElement("Entry"); + try + { + XmlDocument xmlDocument = new XmlDocument(); + xmlDocument.Load(Path); - XmlElement sub1 = xmlDocument.CreateElement("Name"); sub1.InnerText = Title; - childElement.AppendChild(sub1); - XmlElement sub2 = xmlDocument.CreateElement("URL"); sub2.InnerText = Url; - childElement.AppendChild(sub2); - XmlElement sub3 = xmlDocument.CreateElement("ID"); sub3.InnerText = ID.ToString(); - childElement.AppendChild(sub3); - XmlElement sub4 = xmlDocument.CreateElement("Visited"); sub4.InnerText = "0"; - childElement.AppendChild(sub4); - XmlElement sub5 = xmlDocument.CreateElement("LastVisited"); sub5.InnerText = "0001-01-01T00:00:00"; - childElement.AppendChild(sub5); - XmlElement sub6 = xmlDocument.CreateElement("Created"); sub6.InnerText = DateTime.UtcNow.ToString("u", null); - childElement.AppendChild(sub6); - XmlElement sub7 = xmlDocument.CreateElement("isFolder"); sub7.InnerText = "false"; - childElement.AppendChild(sub7); - XmlElement sub8 = xmlDocument.CreateElement("isSubFolder"); sub8.InnerText = "true"; - childElement.AppendChild(sub8); + bool found = false; + XmlNode folder = null; - XmlNode parentNode = xmlDocument.SelectSingleNode("Bookmarks"); - parentNode.InsertAfter(childElement, folder); + foreach (XmlNode r in xmlDocument.ChildNodes) + { - xmlDocument.Save(Path); - return true; - } + foreach (XmlNode one in r.ChildNodes) + { + if (one.FirstChild.InnerText == Title) found = true; + if (one.FirstChild.InnerText == "Saved by MP") folder = one; + } + } - } - catch - { } - return false; + if ((!found) && (folder != null)) + { + XmlElement childElement = xmlDocument.CreateElement("Entry"); + + XmlElement sub1 = xmlDocument.CreateElement("Name"); sub1.InnerText = Title; + childElement.AppendChild(sub1); + XmlElement sub2 = xmlDocument.CreateElement("URL"); sub2.InnerText = Url; + childElement.AppendChild(sub2); + XmlElement sub3 = xmlDocument.CreateElement("ID"); sub3.InnerText = ID.ToString(); + childElement.AppendChild(sub3); + XmlElement sub4 = xmlDocument.CreateElement("Visited"); sub4.InnerText = "0"; + childElement.AppendChild(sub4); + XmlElement sub5 = xmlDocument.CreateElement("LastVisited"); sub5.InnerText = "0001-01-01T00:00:00"; + childElement.AppendChild(sub5); + XmlElement sub6 = xmlDocument.CreateElement("Created"); sub6.InnerText = DateTime.UtcNow.ToString("u", null); + childElement.AppendChild(sub6); + XmlElement sub7 = xmlDocument.CreateElement("isFolder"); sub7.InnerText = "false"; + childElement.AppendChild(sub7); + XmlElement sub8 = xmlDocument.CreateElement("isSubFolder"); sub8.InnerText = "true"; + childElement.AppendChild(sub8); + + XmlNode parentNode = xmlDocument.SelectSingleNode("Bookmarks"); + parentNode.InsertAfter(childElement, folder); + + xmlDocument.Save(Path); + return true; + } + + } + catch + { } + return false; + } } - } } \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -22,15 +22,8 @@ */ #endregion -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Drawing; using MediaPortal.GUI.Library; -using MediaPortal.Dialogs; -using MediaPortal.Util; using MediaPortal.Configuration; using System.Xml; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -24,13 +24,10 @@ using System; using System.Collections.Generic; -using System.Text; -using System.IO; using System.Drawing; using MediaPortal.GUI.Library; using MediaPortal.Dialogs; -using MediaPortal.Util; using MediaPortal.Configuration; using System.Windows.Forms; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -23,52 +23,47 @@ #endregion using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Windows.Forms; namespace BrowseTheWeb { - public partial class GetFolder : Form - { - public string SelectedFolderName = string.Empty; - - public GetFolder() + public partial class GetFolder : Form { - InitializeComponent(); - this.DialogResult = DialogResult.Cancel; - } - private void GetFolder_Load(object sender, EventArgs e) - { - txtName.Text = SelectedFolderName; - } + public string SelectedFolderName = string.Empty; - private void btnOK_Click(object sender, EventArgs e) - { - if (txtName.Text != string.Empty) - { - this.DialogResult = DialogResult.OK; - SelectedFolderName = txtName.Text; - Close(); - } - } - private void btnCancel_Click(object sender, EventArgs e) - { - this.DialogResult = DialogResult.Cancel; - Close(); - } + public GetFolder() + { + InitializeComponent(); + this.DialogResult = DialogResult.Cancel; + } + private void GetFolder_Load(object sender, EventArgs e) + { + txtName.Text = SelectedFolderName; + } - private void txtName_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - btnOK_Click(this, new EventArgs()); - } - } + private void btnOK_Click(object sender, EventArgs e) + { + if (txtName.Text != string.Empty) + { + this.DialogResult = DialogResult.OK; + SelectedFolderName = txtName.Text; + Close(); + } + } + private void btnCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + Close(); + } - - } + private void txtName_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + btnOK_Click(this, new EventArgs()); + } + } + + + } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -23,80 +23,76 @@ #endregion using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; -using System.Text; using System.Windows.Forms; using Skybound.Gecko; namespace BrowseTheWeb { - public partial class GetThumb : Form - { - public string SelectedUrl = string.Empty; - private GeckoWebBrowser browser; - private Bitmap snap; + public partial class GetThumb : Form + { + public string SelectedUrl = string.Empty; + private GeckoWebBrowser browser; + private Bitmap snap; - private bool received = false; - private int time = 0; - private int cancel = 0; + private bool received = false; + private int time = 0; + private int cancel = 0; - public GetThumb() - { - InitializeComponent(); + public GetThumb() + { + InitializeComponent(); - browser = new GeckoWebBrowser(); - this.Controls.Add(browser); - } - private void GetThumb_Load(object sender, EventArgs e) - { - browser.Visible = false; - chkUrl.Checked = true; + browser = new GeckoWebBrowser(); + this.Controls.Add(browser); + } + private void GetThumb_Load(object sender, EventArgs e) + { + browser.Visible = false; + chkUrl.Checked = true; - txtUrl.Text = SelectedUrl; + txtUrl.Text = SelectedUrl; - browser.Size = new Size(800, 1024); - browser.DocumentCompleted += new EventHandler(browser_DocumentCompleted); - browser.Navigate(SelectedUrl); - } + browser.Size = new Size(800, 1024); + browser.DocumentCompleted += new EventHandler(browser_DocumentCompleted); + browser.Navigate(SelectedUrl); + } - private void browser_DocumentCompleted(object sender, EventArgs e) - { - if (browser.Url.ToString() != "about:blank") - { - snap = new Bitmap(browser.Width, browser.Height); - browser.DrawToBitmap(snap, new Rectangle(0, 0, browser.Width, browser.Height)); + private void browser_DocumentCompleted(object sender, EventArgs e) + { + if (browser.Url.ToString() != "about:blank") + { + snap = new Bitmap(browser.Width, browser.Height); + browser.DrawToBitmap(snap, new Rectangle(0, 0, browser.Width, browser.Height)); - snap = MediaPortal.Util.BitmapResize.Resize(ref snap, 300, 400, false, true); + 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)); + 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, SelectedUrl); - received = true; - chkGetThumb.Checked = true; - } - } + Bookmark.SaveSnap(snap, SelectedUrl); + received = true; + chkGetThumb.Checked = true; + } + } - private void button1_Click(object sender, EventArgs e) - { - this.Close(); - } + private void button1_Click(object sender, EventArgs e) + { + this.Close(); + } - private void timer1_Tick(object sender, EventArgs e) - { - cancel++; - if (cancel > 100) this.Close(); + private void timer1_Tick(object sender, EventArgs e) + { + cancel++; + if (cancel > 100) this.Close(); - if (received) - { - time++; - // implemented maybe later to get flash loaded... - if (time > 0) this.Close(); - } + if (received) + { + time++; + // implemented maybe later to get flash loaded... + if (time > 0) this.Close(); + } + } } - } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -23,71 +23,66 @@ #endregion using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Windows.Forms; namespace BrowseTheWeb { - public partial class GetUrl : Form - { - public string SelectedName = string.Empty; - public string SelectedUrl = string.Empty; - - public GetUrl() + public partial class GetUrl : Form { - InitializeComponent(); - this.DialogResult = DialogResult.Cancel; - } - private void GetUrl_Load(object sender, EventArgs e) - { - txtName.Text = SelectedName; - txtUrl.Text = SelectedUrl; - } + public string SelectedName = string.Empty; + public string SelectedUrl = string.Empty; - private void btnCancel_Click(object sender, EventArgs e) - { - this.DialogResult = DialogResult.Cancel; - this.Close(); - } - private void btnOK_Click(object sender, EventArgs e) - { - try - { - Uri u = new Uri(txtUrl.Text); - if (SelectedName != string.Empty) + public GetUrl() { - SelectedName = txtName.Text; - SelectedUrl = txtUrl.Text; + InitializeComponent(); + this.DialogResult = DialogResult.Cancel; + } + private void GetUrl_Load(object sender, EventArgs e) + { + txtName.Text = SelectedName; + txtUrl.Text = SelectedUrl; + } - if (SelectedName.EndsWith("/")) SelectedName = SelectedName.Substring(0, SelectedName.Length - 1); + private void btnCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + private void btnOK_Click(object sender, EventArgs e) + { + try + { + Uri u = new Uri(txtUrl.Text); + if (SelectedName != string.Empty) + { + SelectedName = txtName.Text; + SelectedUrl = txtUrl.Text; - this.DialogResult = DialogResult.OK; - this.Close(); + if (SelectedName.EndsWith("/")) SelectedName = SelectedName.Substring(0, SelectedName.Length - 1); + + this.DialogResult = DialogResult.OK; + this.Close(); + } + } + catch + { + MessageBox.Show("Wrong URL !!!"); + } } - } - catch - { - MessageBox.Show("Wrong URL !!!"); - } - } - private void txtUrl_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - btnOK_Click(this, new EventArgs()); - } + private void txtUrl_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + btnOK_Click(this, new EventArgs()); + } + } + private void txtName_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + txtUrl.Focus(); + } + } } - private void txtName_KeyDown(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Enter) - { - txtUrl.Focus(); - } - } - } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -22,16 +22,13 @@ */ #endregion -using System; -using System.Collections.Generic; -using System.Text; namespace BrowseTheWeb { - public enum HtmlInputType + public enum HtmlInputType { - Input, - Link, - Action + Input, + Link, + Action } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlLinkNumber.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlLinkNumber.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlLinkNumber.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -22,28 +22,25 @@ */ #endregion -using System; -using System.Collections.Generic; -using System.Text; namespace BrowseTheWeb { - public class HtmlLinkNumber - { - public HtmlLinkNumber(int number, string id, string name, string link, HtmlInputType type) + public class HtmlLinkNumber { - Type = type; - Number = number; - Name = name; - Id = id; - Link = link; + public HtmlLinkNumber(int number, string id, string name, string link, HtmlInputType type) + { + Type = type; + Number = number; + Name = name; + Id = id; + Link = link; - } + } - public int Number { get; set; } - public string Id { get; set; } - public string Name { get; set; } - public HtmlInputType Type { get; set; } - public string Link { get; set; } - } + public int Number { get; set; } + public string Id { get; set; } + public string Name { get; set; } + public HtmlInputType Type { get; set; } + public string Link { get; set; } + } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -24,211 +24,206 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Windows.Forms; using System.IO; -using MediaPortal.Configuration; namespace BrowseTheWeb { - public partial class ImportChrome : Form - { - private List<BookmarkElement> EntryList = new List<BookmarkElement>(); - private TreeView tree; - private bool select = true; - - public ImportChrome(TreeView SetupTreeview) + public partial class ImportChrome : Form { - InitializeComponent(); - tree = SetupTreeview; - } + private List<BookmarkElement> EntryList = new List<BookmarkElement>(); + private TreeView tree; + private bool select = true; - private void btnImport_Click(object sender, EventArgs e) - { - btnImport.Visible = false; - btnSelect.Visible = false; - prgState.Visible = true; - chkThumbs.Enabled = false; - - int max = listBox1.SelectedItems.Count; - int imported = 0; - int counter = 1; - - #region get parent - TreeNode node = null; - foreach (TreeNode n in tree.Nodes[0].Nodes) - { - if (n.Text == "Import Chrome") + public ImportChrome(TreeView SetupTreeview) { - node = n; - break; + InitializeComponent(); + tree = SetupTreeview; } - } - #endregion - if (node != null) - { - foreach (Object item in listBox1.SelectedItems) + private void btnImport_Click(object sender, EventArgs e) { - Application.DoEvents(); - prgState.Value = (counter * 100 / max); + btnImport.Visible = false; + btnSelect.Visible = false; + prgState.Visible = true; + chkThumbs.Enabled = false; - string name = (string)item; - BookmarkElement bkm = GetBookmark(name); + int max = listBox1.SelectedItems.Count; + int imported = 0; + int counter = 1; - if (bkm != null) - { - if (!Bookmark.Exists(tree, bkm.Name)) + #region get parent + TreeNode node = null; + foreach (TreeNode n in tree.Nodes[0].Nodes) { - imported++; + if (n.Text == "Import Chrome") + { + node = n; + break; + } + } + #endregion - TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); + if (node != null) + { + foreach (Object item in listBox1.SelectedItems) + { + Application.DoEvents(); + prgState.Value = (counter * 100 / max); - BookmarkElement addBkm = new BookmarkElement(); - addBkm.Name = bkm.Name; - addBkm.Url = bkm.Url; - addBkm.isSubFolder = true; - add.Tag = addBkm; + string name = (string)item; + BookmarkElement bkm = GetBookmark(name); - if (chkThumbs.Checked) - { - GetThumb thumb = new GetThumb(); - thumb.SelectedUrl = bkm.Url; - thumb.ShowDialog(); - } + if (bkm != null) + { + if (!Bookmark.Exists(tree, bkm.Name)) + { + imported++; - node.ExpandAll(); + TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); + + BookmarkElement addBkm = new BookmarkElement(); + addBkm.Name = bkm.Name; + addBkm.Url = bkm.Url; + addBkm.isSubFolder = true; + add.Tag = addBkm; + + if (chkThumbs.Checked) + { + GetThumb thumb = new GetThumb(); + thumb.SelectedUrl = bkm.Url; + thumb.ShowDialog(); + } + + node.ExpandAll(); + } + } + counter++; + } } - } - counter++; + + MessageBox.Show("Import is done. Imported " + imported.ToString() + " links."); + this.Close(); } - } + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } - MessageBox.Show("Import is done. Imported " + imported.ToString() + " links."); - this.Close(); - } - private void btnCancel_Click(object sender, EventArgs e) - { - this.Close(); - } + private void ImportChr_Load(object sender, EventArgs e) + { + try + { + string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + path += "\\Google\\Chrome\\User Data\\Default"; - private void ImportChr_Load(object sender, EventArgs e) - { - try - { - string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - path += "\\Google\\Chrome\\User Data\\Default"; + MyLog.debug("Chrome folder is " + path); - MyLog.debug("Chrome folder is " + path); + if (Directory.Exists(path)) + { + if (File.Exists(path + "\\Bookmarks")) + { + MyLog.debug("Open bookmarks"); - if (Directory.Exists(path)) - { - if (File.Exists(path + "\\Bookmarks")) - { - MyLog.debug("Open bookmarks"); + StreamReader sr = new StreamReader(path + "\\Bookmarks"); + string line = sr.ReadToEnd(); + sr.Close(); - StreamReader sr = new StreamReader(path + "\\Bookmarks"); - string line = sr.ReadToEnd(); - sr.Close(); + MyLog.debug("Read " + line.Length + " bytes"); - MyLog.debug("Read " + line.Length + " bytes"); + int x = 0; + int secNo = 1; - int x = 0; - int secNo = 1; + while ((x = line.IndexOf("children\": [", x + 1)) > 0) + { + int y = line.IndexOf("]", x + 12); + string section = line.Substring(x + 12, y - x - 12); - while ((x = line.IndexOf("children\": [", x + 1)) > 0) - { - int y = line.IndexOf("]", x + 12); - string section = line.Substring(x + 12, y - x - 12); + MyLog.debug("Read section " + secNo); + secNo++; - MyLog.debug("Read section " + secNo); - secNo++; + int start = 0; + while ((start = section.IndexOf("{", start + 1)) > 0) + { + int stop = section.IndexOf("}", start + 1); + string entry = section.Substring(start + 1, stop - start - 3); - int start = 0; - while ((start = section.IndexOf("{", start + 1)) > 0) - { - int stop = section.IndexOf("}", start + 1); - string entry = section.Substring(start + 1, stop - start - 3); + string[] sep = new string[1]; + sep[0] = "\r\n"; + string[] lines = entry.Split(sep, StringSplitOptions.RemoveEmptyEntries); - string[] sep = new string[1]; - sep[0] = "\r\n"; - string[] lines = entry.Split(sep, StringSplitOptions.RemoveEmptyEntries); + for (int i = 0; i < lines.Length; i++) + { + lines[i] = lines[i].Replace("\"", ""); + lines[i] = lines[i].Trim(); + } - for (int i = 0; i < lines.Length; i++) - { - lines[i] = lines[i].Replace("\"", ""); - lines[i] = lines[i].Trim(); - } + string name = string.Empty; + string url = string.Empty; + string typ = string.Empty; - string name = string.Empty; - string url = string.Empty; - string typ = string.Empty; + for (int i = 0; i < lines.Length; i++) + { + if (lines[i].StartsWith("type:")) + { + typ = lines[i].Replace("type:", "").Trim(); + if (typ.EndsWith(",")) typ = typ.Substring(0, typ.Length - 1); + } + if (lines[i].StartsWith("name:")) + { + name = lines[i].Replace("name:", "").Trim(); + if (name.EndsWith(",")) name = name.Substring(0, name.Length - 1); + } + if (lines[i].StartsWith("url:")) + { // with / + url = lines[i].Replace("url:", "").Trim(); + } + } - for (int i = 0; i < lines.Length; i++) - { - if (lines[i].StartsWith("type:")) - { - typ = lines[i].Replace("type:", "").Trim(); - if (typ.EndsWith(",")) typ = typ.Substring(0, typ.Length - 1); - } - if (lines[i].StartsWith("name:")) - { - name = lines[i].Replace("name:", "").Trim(); - if (name.EndsWith(",")) name = name.Substring(0, name.Length - 1); - } - if (lines[i].StartsWith("url:")) - { // with / - url = lines[i].Replace("url:", "").Trim(); - } - } + if ((name != "") && (typ == "url") && (url != "")) + { + MyLog.debug("Found bookmark " + name); - if ((name != "") && (typ == "url") && (url != "")) - { - MyLog.debug("Found bookmark " + name); + BookmarkElement bkm = new BookmarkElement(); + bkm.Url = url; + bkm.Name = name; - BookmarkElement bkm = new BookmarkElement(); - bkm.Url = url; - bkm.Name = name; + EntryList.Add(bkm); + listBox1.Items.Add(bkm.Name); + } + } + } - EntryList.Add(bkm); - listBox1.Items.Add(bkm.Name); - } - } - } + } - } + } + } + catch (Exception ex) + { + MyLog.debug("Exception import chrome : " + ex.Message); + MyLog.debug("Exception import chrome : " + ex.StackTrace); + } + } + private BookmarkElement GetBookmark(string Name) + { + foreach (BookmarkElement bkm in EntryList) + { + if (bkm.Name == Name) return bkm; + } + return null; } - } - catch (Exception ex) - { - MyLog.debug("Exception import chrome : " + ex.Message); - MyLog.debug("Exception import chrome : " + ex.StackTrace); - } - } - private BookmarkElement GetBookmark(string Name) - { - foreach (BookmarkElement bkm in EntryList) - { - if (bkm.Name == Name) return bkm; - } - return null; + private void btnSelect_Click(object sender, EventArgs e) + { + for (int i = 0; i < listBox1.Items.Count; i++) + { + listBox1.SetSelected(i, select); + } + select = !select; + } } - - private void btnSelect_Click(object sender, EventArgs e) - { - for (int i = 0; i < listBox1.Items.Count; i++) - { - listBox1.SetSelected(i, select); - } - select = !select; - } - } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -24,166 +24,161 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Windows.Forms; using System.IO; -using MediaPortal.Configuration; using SQLite.NET; namespace BrowseTheWeb { - public partial class ImportFF : Form - { - private List<BookmarkElement> EntryList = new List<BookmarkElement>(); - private TreeView tree; - private bool select = true; - - public ImportFF(TreeView SetupTreeview) + public partial class ImportFF : Form { - InitializeComponent(); - tree = SetupTreeview; - } + private List<BookmarkElement> EntryList = new List<BookmarkElement>(); + private TreeView tree; + private bool select = true; - private void btnImport_Click(object sender, EventArgs e) - { - btnImport.Visible = false; - btnSelect.Visible = false; - prgState.Visible = true; - chkThumbs.Enabled = false; - - int max = listBox1.SelectedItems.Count; - int imported = 0; - int counter = 1; - - #region get parent - TreeNode node = null; - foreach (TreeNode n in tree.Nodes[0].Nodes) - { - if (n.Text == "Import FF") + public ImportFF(TreeView SetupTreeview) { - node = n; - break; + InitializeComponent(); + tree = SetupTreeview; } - } - #endregion - if (node != null) - { - foreach (Object item in listBox1.SelectedItems) + private void btnImport_Click(object sender, EventArgs e) { - Application.DoEvents(); - prgState.Value = (counter * 100 / max); + btnImport.Visible = false; + btnSelect.Visible = false; + prgState.Visible = true; + chkThumbs.Enabled = false; - string name = (string)item; - BookmarkElement bkm = GetBookmark(name); + int max = listBox1.SelectedItems.Count; + int imported = 0; + int counter = 1; - if (bkm != null) - { - if (!Bookmark.Exists(tree, bkm.Name)) + #region get parent + TreeNode node = null; + foreach (TreeNode n in tree.Nodes[0].Nodes) { - imported++; + if (n.Text == "Import FF") + { + node = n; + break; + } + } + #endregion - TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); + if (node != null) + { + foreach (Object item in listBox1.SelectedItems) + { + Application.DoEvents(); + prgState.Value = (counter * 100 / max); - BookmarkElement addBkm = new BookmarkElement(); - addBkm.Name = bkm.Name; - addBkm.Url = bkm.Url; - addBkm.isSubFolder = true; - add.Tag = addBkm; + string name = (string)item; + BookmarkElement bkm = GetBookmark(name); - if (chkThumbs.Checked) - { - GetThumb thumb = new GetThumb(); - thumb.SelectedUrl = bkm.Url; - thumb.ShowDialog(); - } + if (bkm != null) + { + if (!Bookmark.Exists(tree, bkm.Name)) + { + imported++; - node.ExpandAll(); + TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); + + BookmarkElement addBkm = new BookmarkElement(); + addBkm.Name = bkm.Name; + addBkm.Url = bkm.Url; + addBkm.isSubFolder = true; + add.Tag = addBkm; + + if (chkThumbs.Checked) + { + GetThumb thumb = new GetThumb(); + thumb.SelectedUrl = bkm.Url; + thumb.ShowDialog(); + } + + node.ExpandAll(); + } + } + counter++; + } } - } - counter++; + + MessageBox.Show("Import is done. Imported " + imported.ToString() + " links."); + this.Close(); } - } + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } - MessageBox.Show("Import is done. Imported " + imported.ToString() + " links."); - this.Close(); - } - private void btnCancel_Click(object sender, EventArgs e) - { - this.Close(); - } + private void ImportFF_Load(object sender, EventArgs e) + { + try + { + string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + path += "\\Mozilla\\Firefox\\Profiles"; - private void ImportFF_Load(object sender, EventArgs e) - { - try - { - string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - path += "\\Mozilla\\Firefox\\Profiles"; + MyLog.debug("Morzilla folder is " + path); - MyLog.debug("Morzilla folder is " + path); + if (Directory.Exists(path)) + { + string[] dir = Directory.GetDirectories(path); + if (dir.Length == 1) + { + MyLog.debug("Morzilla profile under " + dir[0]); + path = dir[0] + "\\places.sqlite"; - if (Directory.Exists(path)) - { - string[] dir = Directory.GetDirectories(path); - if (dir.Length == 1) - { - MyLog.debug("Morzilla profile under " + dir[0]); - path = dir[0] + "\\places.sqlite"; + MyLog.debug("open database"); + SQLiteClient client = new SQLiteClient(path); - MyLog.debug("open database"); - SQLiteClient client = new SQLiteClient(path); + SQLiteResultSet result = client.Execute("SELECT moz_bookmarks.title,moz_places.url,moz_bookmarks.type FROM moz_bookmarks LEFT JOIN moz_places " + + "WHERE moz_bookmarks.fk = moz_places.id AND moz_bookmarks.title != 'null' AND moz_places.url LIKE '%http%';"); - SQLiteResultSet result = client.Execute("SELECT moz_bookmarks.title,moz_places.url,moz_bookmarks.type FROM moz_bookmarks LEFT JOIN moz_places " + - "WHERE moz_bookmarks.fk = moz_places.id AND moz_bookmarks.title != 'null' AND moz_places.url LIKE '%http%';"); + MyLog.debug("Morzilla bookmarks found : " + result.Rows.Count); - MyLog.debug("Morzilla bookmarks found : " + result.Rows.Count); + foreach (SQLite.NET.SQLiteResultSet.Row row in result.Rows) + { + string title = row.fields[0].ToString(); + string url = row.fields[1].ToString(); - foreach (SQLite.NET.SQLiteResultSet.Row row in result.Rows) - { - string title = row.fields[0].ToString(); - string url = row.fields[1].ToString(); + BookmarkElement bkm = new BookmarkElement(); + bkm.Url = url; + bkm.Name = title; - BookmarkElement bkm = new BookmarkElement(); - bkm.Url = url; - bkm.Name = title; + EntryList.Add(bkm); + listBox1.Items.Add(bkm.Name); + } - EntryList.Add(bkm); - listBox1.Items.Add(bkm.Name); + MyLog.debug("close database"); + client.Close(); + } + } } + catch (Exception ex) + { + MyLog.debug("Exception import ff : " + ex.Message); + MyLog.debug("Exception import ff : " + ex.StackTrace); + } + } - MyLog.debug("close database"); - client.Close(); - } + private BookmarkElement GetBookmark(string Name) + { + foreach (BookmarkElement bkm in EntryList) + { + if (bkm.Name == Name) return bkm; + } + return null; } - } - catch (Exception ex) - { - MyLog.debug("Exception import ff : " + ex.Message); - MyLog.debug("Exception import ff : " + ex.StackTrace); - } - } - private BookmarkElement GetBookmark(string Name) - { - foreach (BookmarkElement bkm in EntryList) - { - if (bkm.Name == Name) return bkm; - } - return null; + private void btnSelect_Click(object sender, EventArgs e) + { + for (int i = 0; i < listBox1.Items.Count; i++) + { + listBox1.SetSelected(i, select); + } + select = !select; + } } - - private void btnSelect_Click(object sender, EventArgs e) - { - for (int i = 0; i < listBox1.Items.Count; i++) - { - listBox1.SetSelected(i, select); - } - select = !select; - } - } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs 2012-04-08 18:36:02 UTC (rev 4476) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs 2012-04-08 21:50:59 UTC (rev 4477) @@ -24,193 +24,188 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Windows.Forms; using System.IO; -using MediaPortal.Configuration; namespace BrowseTheWeb { - public partial class ImportIE : Form - { - private List<BookmarkElement> EntryList = new List<BookmarkElement>(); - private TreeView tree; - private bool select = true; - - public ImportIE(TreeView SetupTreeview) + public partial class ImportIE : Form { - InitializeComponent(); - tree = SetupTreeview; - } + private List<BookmarkElement> EntryList = new List<BookmarkElement>(); + private TreeView tree; + private bool select = true; - private void btnImport_Click(object sender, EventArgs e) - { - btnImport.Visible = false; - btnSelect.Visible = false; - prgState.Visible = true; - chkThumbs.Enabled = false; - - int max = listBox1.SelectedItems.Count; - int imported = 0; - int counter = 1; - - #region get parent - TreeNode node = null; - foreach (TreeNode n in tree.Nodes[0].Nodes) - { - if (n.Text == "Import IE") + public ImportIE(TreeView SetupTreeview) { - node = n; - break; + InitializeComponent(); + tree = SetupTreeview; } - } - #endregion - if (node != null) - { - foreach (Object item in listBox1.SelectedItems) + private void btnImport_Click(object sender, EventArgs e) { - Application.DoEvents(); - prgState.Value = (counter * 100 / max); + btnImport.Visible = false; + btnSelect.Visible = false; + prgState.Visible = true; + chkThumbs.Enabled = false; - string name = (string)item; - BookmarkElement bkm = GetBookmark(name); + int max = listBox1.SelectedItems.Count; + int imported = 0; + int counter = 1; - if (bkm != null) - { - if (!Bookmark.Exists(tree, bkm.Name)) + #region get parent + TreeNode node = null; + foreach (TreeNode n in tree.Nodes[0].Nodes) { - imported++; + if (n.Text == "Import IE") + { + node = n; + break; + } + } + #endregion - TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); + if (node != null) + { + foreach (Object item in listBox1.SelectedItems) + { + Application.DoEvents(); + prgState.Value = (counter * 100 / max); - BookmarkElement addBkm = new BookmarkElement(); - addBkm.Name = bkm.Name; - addBkm.Url = bkm.Url; - addBkm.isSubFolder = true; - add.Tag = addBkm; + string name = (string)item; + BookmarkElement bkm = GetBookmark(name); - if (chkThumbs.Checked) - { - GetThumb thumb = new GetThumb(); - thumb.SelectedUrl = bkm.Url; - thumb.ShowDialog(); - } + if (bkm != null) + { + if (!Bookmark.Exists(tree, bkm.Name)) + { + imported++; - node.ExpandAll(); - } - } - counter++; - } - } + TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); - MessageBox.Show("Import is done. Imported " + imported.ToString() + " links."); - this.Close(); - } - private void btnCancel_Click(object sender, EventArgs e) - { - this.Close(); - } + BookmarkElement addBkm = new BookmarkElement(); + addBkm.Name = bkm.Name; + addBkm.Url = bkm.Url; + addBkm.isSubFolder = true; + add.Tag = addBkm; - private void ImportIE_Load(object sender, EventArgs e) - { - string favPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); - string[] favFiles; + if (chkThumbs.Checked) + { + GetThumb thumb = new GetThumb(); + thumb.SelectedUrl = bkm.Url; + thumb.ShowDialog(); + } - MyLog.debug("Import folder is " + favPath); + node.ExpandAll(); + } + } + counter++; + } + } - if (Directory.Exists(favPath)) - { - string[] favDirs = Directory.GetDirectories(favPath); - MyLog.debug("Found " + favDirs.Length.ToString() + " folder"); + MessageBox.Show("Import is done. Imported " + imported.ToString() + " links."); + this.Close(); + } + private void btnCancel_Click(object sender, EventArgs e) + { + this.Close(); + } - foreach (string folder in favDirs) + private void ImportIE_Load(object sender, EventArgs e) { - MyLog.debug("Work on folder '" + Path.GetFileName(folder) + "'"); + string favPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); + string[] favFiles; - favFiles = Directory.GetFiles(folder, "*.url", SearchOption.TopDirectoryOnly); - MyLog.debug(favFiles.Length.ToString() + " files to import"); + MyLog.debug("Import folder is " + favPath); - foreach (string s in favFiles) - { - FileInfo f = new FileInfo(s); - string name = Path.GetFileNameWithoutExtension(f.Name); + if (Directory.Exists(favPath)) + { + string[] favDirs = Directory.GetDirectories(favPath); + MyLog.debug("Found " + favDirs.Length.ToString() + " folder"); - string url = GetUrlFile(s); + foreach (string folder in favDirs) + { + MyLog.debug("Work on folder '" + Path.GetFileName(folder) + "'"); - if (url != null) - { - BookmarkElement bkm = new BookmarkElement(); - bkm.Url = url; - bkm.Name = name; + favFiles = Directory.GetFiles(folder, "*.url", SearchOption.TopDirectoryOnly); + MyLog.debug(favFiles.Length.ToString() + " files to import"); - EntryList.Add(bkm); - listBox1.Items.Add(bkm.Name); - } - } - } + ... [truncated message content] |
From: <dos...@us...> - 2012-04-14 21:01:16
|
Revision: 4479 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4479&view=rev Author: doskabouter Date: 2012-04-14 21:01:09 +0000 (Sat, 14 Apr 2012) Log Message: ----------- - improved display of the numbers of the urls - fixed the password dialog to show '*' instead of the actual characters - fixed mouse cursor not disappearing Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-09 12:21:20 UTC (rev 4478) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-14 21:01:09 UTC (rev 4479) @@ -50,13 +50,11 @@ private const int MOUSEEVENTF_RIGHTUP = 0x10; #region Links - private static GeckoElementCollection _links; - private static GeckoElementCollection _forms; - private static Dictionary<int, HtmlLinkNumber> _htmlLinkNumbers = new Dictionary<int, HtmlLinkNumber>(); + private Dictionary<int, HtmlLinkNumber> _htmlLinkNumbers = new Dictionary<int, HtmlLinkNumber>(); #endregion #region Constants - private const string _span = "<span style=\"font-family: arial,sans-serif; font-size: 12px ! important; line-height: 130% ! important; border-width: 1px ! important; border-style: solid ! important; -moz-border-radius: 2px 2px 2px 2px ! important; padding: 0px 2px ! important; margin-left: 2px; max-width: 20px; max-height: 10px ! important; overflow: visible ! important; float: none ! important; display: inline;\" gecko_id=\"{0}\" gecko_action=\"{1}\" gecko_type=\"{2}\">{0}</span>"; + private const string _span = "<span style=\"font-family: arial,sans-serif; font-size: 12px ! important; line-height: 130% ! important; border-width: 1px ! important; border-style: solid ! important; -moz-border-radius: 2px 2px 2px 2px ! important; padding: 0px 2px ! important; margin-left: 2px; max-width: 20px; max-height: 10px ! important; overflow: visible ! important; float: none ! important; display: inline;\" gecko_id=\"{0}\" gecko_action=\"{1}\" gecko_type=\"{2}\" class=\"{3}\">{0}</span>"; #endregion #region declare vars @@ -65,7 +63,7 @@ private Mouse mouse; private string linkId = string.Empty; private int linkTime = 0; - private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); + private Timer timer = new Timer(); private string lastDomain = string.Empty; private float zoom = Settings.Instance.DefaultZoom; @@ -231,6 +229,7 @@ { MyLog.debug("Mouse support is enabled"); GUIGraphicsContext.MouseSupport = true; + Cursor.Show(); } Parameter = null; @@ -242,10 +241,9 @@ #region init browser webBrowser.Visible = true; - if (!settings.UseMouse) webBrowser.Enabled = false; - else webBrowser.Enabled = true; + webBrowser.Enabled = settings.UseMouse; - webBrowser.Dock = System.Windows.Forms.DockStyle.None; + webBrowser.Dock = DockStyle.None; webBrowser.Location = new System.Drawing.Point(0, 0); MyLog.debug("Create eventhandler"); @@ -336,7 +334,8 @@ timer.Tick -= new EventHandler(timer_Tick); timer.Stop(); - + if (settings.UseMouse) + Cursor.Hide(); base.OnPageDestroy(new_windowId); } @@ -371,9 +370,6 @@ private void timer_Tick(object sender, EventArgs e) { - if (settings.UseMouse) - Cursor.Show(); - if (linkId != string.Empty) { if (settings.OSD) @@ -594,10 +590,10 @@ case MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM: if (mouse.Visible) { - //System.Windows.Forms.Cursor.Show(); + //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); + Cursor.Position = new Point(x, y); } return; #endregion @@ -674,7 +670,7 @@ selectedUrl = settings.LastUrl; } - if (ShowKeyboard(ref selectedUrl, false) == System.Windows.Forms.DialogResult.OK) + if (ShowKeyboard(ref selectedUrl, false) == DialogResult.OK) { if (Bookmark.isValidUrl(selectedUrl)) { @@ -702,8 +698,8 @@ title = title.Replace("\0", ""); - System.Windows.Forms.DialogResult result = ShowKeyboard(ref title, false); - if (result == System.Windows.Forms.DialogResult.OK) + DialogResult result = ShowKeyboard(ref title, false); + if (result == DialogResult.OK) { bool hasSaved = BookmarkXml.AddBookmark(title, actualUrl, Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", 0); if (hasSaved) @@ -881,20 +877,30 @@ #region add links to page _htmlLinkNumbers.Clear(); - _links = webBrowser.Document.Links; + GeckoElementCollection 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) + foreach (GeckoElement element in links) { string link = element.GetAttribute("href"); if (!link.StartsWith("javascript:")) { + GeckoElement lastSpan = element; + bool ready = false; + while (!ready) + { + GeckoElement ls = lastSpan.LastChild as GeckoElement; + if (ls == null || ls.TagName != "SPAN") + ready = true; + else + lastSpan = ls; + }; if (!element.InnerHtml.Contains("gecko_id")) { - element.InnerHtml += string.Format(_span, i, "", "LINK"); + element.InnerHtml += string.Format(_span, i, "", "LINK", lastSpan.ClassName); } string gb = element.GetAttribute("gb"); @@ -914,12 +920,12 @@ } } - _forms = webBrowser.Document.GetElementsByTagName("form"); + GeckoElementCollection 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) + foreach (GeckoElement element in forms) { string action = element.GetAttribute("action"); doc.LoadHtml(element.InnerHtml); @@ -948,7 +954,7 @@ if (!element.InnerHtml.Contains("gecko_id=\"" + i + "\"")) { - string newLink = link.OuterHtml + string.Format(_span, i, action, "INPUT"); + string newLink = link.OuterHtml + string.Format(_span, i, action, "INPUT", ""); element.InnerHtml = element.InnerHtml.Replace(outerHtml, newLink); } if (link.Attributes["type"].Value == "submit" || @@ -961,7 +967,10 @@ } else { - _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); + if (link.Attributes["type"].Value == "password") + _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.InputPassword)); + else + _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); } i++; } @@ -984,7 +993,7 @@ if (!element.InnerHtml.Contains("gecko_id=\"" + i + "\"")) { - string newLink = link.OuterHtml + string.Format(_span, i, action, "INPUT"); + string newLink = link.OuterHtml + string.Format(_span, i, action, "INPUT", ""); element.InnerHtml = element.InnerHtml.Replace(outerHtml, newLink); } @@ -1040,6 +1049,7 @@ MyLog.debug("navigate to linkid=" + LinkId + " URL=" + hln.Link); break; case HtmlInputType.Input: + case HtmlInputType.InputPassword: ShowInputDialog(hln); break; case HtmlInputType.Action: @@ -1075,12 +1085,15 @@ return true; } case HtmlInputType.Input: + case HtmlInputType.InputPassword: case HtmlInputType.Action: hln = id; return true; //return "javascript:document.getElementById(\"" + id.Name + "\").click()"; } } + else + MyLog.debug(String.Format("LinkId {0} not found in _htmlLinkNumbers", value)); hln = null; return false; } @@ -1090,7 +1103,7 @@ webBrowser.Visible = false; string result = string.Empty; - if (ShowKeyboard(ref result, false) == System.Windows.Forms.DialogResult.OK) + if (ShowKeyboard(ref result, id.Type == HtmlInputType.InputPassword) == DialogResult.OK) { SetInputFieldText(id.Number, result); } @@ -1116,7 +1129,7 @@ } } - public static System.Windows.Forms.DialogResult ShowKeyboard(ref string DefaultText, bool PasswordInput) + public static DialogResult ShowKeyboard(ref string DefaultText, bool PasswordInput) { VirtualKeyboard vk = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD); @@ -1128,10 +1141,10 @@ if (vk.IsConfirmed) { DefaultText = vk.Text; - return System.Windows.Forms.DialogResult.OK; + return DialogResult.OK; } else - return System.Windows.Forms.DialogResult.Cancel; + return DialogResult.Cancel; } public static void ShowAlert(String headline, String line1, String line2, String line3) { Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs 2012-04-09 12:21:20 UTC (rev 4478) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs 2012-04-14 21:01:09 UTC (rev 4479) @@ -28,6 +28,7 @@ public enum HtmlInputType { Input, + InputPassword, Link, Action } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2012-07-01 15:15:06
|
Revision: 4492 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4492&view=rev Author: doskabouter Date: 2012-07-01 15:14:59 +0000 (Sun, 01 Jul 2012) Log Message: ----------- cleanup old mouse stuff Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/Resources.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/Resources.resx Removed Paths: ------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.resx trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/res/icon-48x48-mouse.png Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2012-05-25 10:34:08 UTC (rev 4491) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2012-07-01 15:14:59 UTC (rev 4492) @@ -123,12 +123,6 @@ <Compile Include="ImportChrome.Designer.cs"> <DependentUpon>ImportChrome.cs</DependentUpon> </Compile> - <Compile Include="Mouse.cs"> - <SubType>UserControl</SubType> - </Compile> - <Compile Include="Mouse.Designer.cs"> - <DependentUpon>Mouse.cs</DependentUpon> - </Compile> <Compile Include="MyLog.cs" /> <Compile Include="OSD_LinkId.cs"> <SubType>UserControl</SubType> @@ -181,7 +175,6 @@ <ItemGroup> <None Include="res\edit-icon.png" /> <Content Include="res\fav-b-icon.png" /> - <None Include="res\icon-48x48-mouse.png" /> <Content Include="todo.txt" /> <EmbeddedResource Include="GetThumb.resx"> <DependentUpon>GetThumb.cs</DependentUpon> @@ -198,10 +191,6 @@ <DependentUpon>ImportChrome.cs</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> - <EmbeddedResource Include="Mouse.resx"> - <DependentUpon>Mouse.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> <EmbeddedResource Include="OSD_LinkId.resx"> <DependentUpon>OSD_LinkId.cs</DependentUpon> <SubType>Designer</SubType> Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-05-25 10:34:08 UTC (rev 4491) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-07-01 15:14:59 UTC (rev 4492) @@ -49,6 +49,7 @@ private const int MOUSEEVENTF_RIGHTDOWN = 0x08; private const int MOUSEEVENTF_RIGHTUP = 0x10; private const bool logHtml = false; + private bool mouseVisible = false; #region Links private Dictionary<int, HtmlLinkNumber> _htmlLinkNumbers = new Dictionary<int, HtmlLinkNumber>(); @@ -61,7 +62,6 @@ #region declare vars private GeckoWebBrowser webBrowser; private OSD_LinkId osd_linkID; - private Mouse mouse; private string linkId = string.Empty; private int linkTime = 0; private Timer timer = new Timer(); @@ -208,9 +208,6 @@ GUIGraphicsContext.form.Controls.Add(osd_linkID); osd_linkID.Visible = false; - mouse = new Mouse(); - GUIGraphicsContext.form.Controls.Add(mouse); - mouse.Visible = false; #endregion } @@ -302,7 +299,7 @@ timer.Start(); if (settings.UseMouse) - GUIGraphicsContext.form.Controls["BrowseTheWeb"].Select(); + webBrowser.Select(); } catch (Exception ex) { @@ -408,11 +405,7 @@ public override void OnAction(MediaPortal.GUI.Library.Action action) { - if (linkId != string.Empty) - GUIPropertyManager.SetProperty("#btWeb.linkid", "Link ID = " + linkId); - else - GUIPropertyManager.SetProperty("#btWeb.linkid", linkId); - + GUIPropertyManager.SetProperty("#btWeb.linkid", String.IsNullOrEmpty(linkId) ? String.Empty : "Link ID = " + linkId); #region remote diagnostic if (settings.Remote) { @@ -428,7 +421,7 @@ #region selectable buttons if (action.wID == settings.Remote_Confirm) { - if (!mouse.Visible) + if (!mouseVisible) { if (!settings.UseMouse) { @@ -461,7 +454,7 @@ //webBrowser.Enabled = false; GUIGraphicsContext.form.BringToFront(); - mouse.BringToFront(); + //mouse.BringToFront(); } } if (action.wID == settings.Remote_Bookmark) @@ -510,17 +503,17 @@ } break; case MediaPortal.GUI.Library.Action.ActionType.ACTION_NEXT_SUBTITLE: - if (mouse.Visible) + if (mouseVisible) { - mouse.Visible = false; + mouseVisible = false; } else { Point x = Cursor.Position; - mouse.Location = x; - mouse.Visible = true; - mouse.BringToFront(); - } + //mouse.Location = x; + mouseVisible = true; + //mouse.BringToFront(); + } break; case MediaPortal.GUI.Library.Action.ActionType.ACTION_KEY_PRESSED: if (!settings.UseMouse) @@ -593,13 +586,6 @@ OnMoveDown(); return; case MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM: - if (mouse.Visible) - { - //Cursor.Show(); - int x = GUIGraphicsContext.form.Location.X + mouse.Location.X + 20; - int y = GUIGraphicsContext.form.Location.Y + mouse.Location.Y + 50; - Cursor.Position = new Point(x, y); - } return; #endregion } @@ -608,7 +594,7 @@ private void webBrowser_DomKeyDown(object sender, GeckoDomKeyEventArgs e) { - if (settings.UseMouse) + if (settings.UseMouse || mouseVisible) { //System.Diagnostics.Debug.WriteLine("DOM " + e.KeyCode.ToString()); @@ -690,7 +676,7 @@ webBrowser.Visible = true; if (settings.UseMouse) - GUIGraphicsContext.form.Controls["BrowseTheWeb"].Select(); + webBrowser.Select(); } private void OnAddBookmark() @@ -740,7 +726,7 @@ webBrowser.Visible = true; if (settings.UseMouse) - GUIGraphicsContext.form.Controls["BrowseTheWeb"].Select(); + webBrowser.Select(); } private void OnZoomIn() { @@ -756,55 +742,51 @@ } private void OnMoveLeft() { - if (!mouse.Visible) + if (!mouseVisible) { if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX - 100, webBrowser.Window.ScrollY); } else { - mouse.Location = new Point(mouse.Location.X - 20, mouse.Location.Y); - Cursor.Position = new Point(mouse.Location.X, mouse.Location.Y); + Cursor.Position = new Point(Cursor.Position.X - 20, Cursor.Position.Y); } } private void OnMoveRight() { - if (!mouse.Visible) + if (!mouseVisible) { if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX + 100, webBrowser.Window.ScrollY); } else { - mouse.Location = new Point(mouse.Location.X + 20, mouse.Location.Y); - Cursor.Position = new Point(mouse.Location.X, mouse.Location.Y); + Cursor.Position = new Point(Cursor.Position.X + 20, Cursor.Position.Y); } } private void OnMoveUp() { - if (!mouse.Visible) + if (!mouseVisible) { if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY - 100); } else { - mouse.Location = new Point(mouse.Location.X, mouse.Location.Y - 20); - Cursor.Position = new Point(mouse.Location.X, mouse.Location.Y); + Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - 20); } } private void OnMoveDown() { - if (!mouse.Visible) + if (!mouseVisible) { if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY + 100); } else { - mouse.Location = new Point(mouse.Location.X, mouse.Location.Y + 20); - Cursor.Position = new Point(mouse.Location.X, mouse.Location.Y); + Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 20); } } private void OnPageUp() { - if (!mouse.Visible) + if (!mouseVisible) { int height = webBrowser.Size.Height; if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY - height + 100); @@ -812,13 +794,12 @@ else { //not yet tested - mouse.Location = new Point(mouse.Location.X, mouse.Location.Y - 20); - Cursor.Position = new Point(mouse.Location.X, mouse.Location.Y); + Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - 20); } } private void OnPageDown() { - if (!mouse.Visible) + if (!mouseVisible) { int height = webBrowser.Size.Height; if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY + height - 100); @@ -826,8 +807,7 @@ else { //not yet tested - mouse.Location = new Point(mouse.Location.X, mouse.Location.Y - 20); - Cursor.Position = new Point(mouse.Location.X, mouse.Location.Y); + Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 20); } } @@ -919,6 +899,7 @@ { MyLog.debug("page completed : " + webBrowser.Url.ToString()); + GUIPropertyManager.SetProperty("#btWeb.linkid", webBrowser.Url.ToString()); try { #region MP gui stuff Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.Designer.cs 2012-05-25 10:34:08 UTC (rev 4491) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.Designer.cs 2012-07-01 15:14:59 UTC (rev 4492) @@ -1,64 +0,0 @@ -namespace BrowseTheWeb -{ - partial class Mouse - { - /// <summary> - /// Erforderliche Designervariable. - /// </summary> - private System.ComponentModel.IContainer components = null; - - /// <summary> - /// Verwendete Ressourcen bereinigen. - /// </summary> - /// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param> - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Vom Komponenten-Designer generierter Code - - /// <summary> - /// Erforderliche Methode für die Designerunterstützung. - /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. - /// </summary> - private void InitializeComponent() - { - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // pictureBox1 - // - this.pictureBox1.Image = global::BrowseTheWeb.Properties.Resources.icon_48x48_mouse; - this.pictureBox1.Location = new System.Drawing.Point(0, 0); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(48, 48); - this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.pictureBox1.TabIndex = 0; - this.pictureBox1.TabStop = false; - // - // Mouse - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.Color.White; - this.Controls.Add(this.pictureBox1); - this.Name = "Mouse"; - this.Size = new System.Drawing.Size(48, 48); - this.Load += new System.EventHandler(this.Mouse_Load); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.PictureBox pictureBox1; - - } -} Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.cs 2012-05-25 10:34:08 UTC (rev 4491) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.cs 2012-07-01 15:14:59 UTC (rev 4492) @@ -1,47 +0,0 @@ -#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.Windows.Forms; - -namespace BrowseTheWeb -{ - public partial class Mouse : UserControl - { - public Mouse() - { - InitializeComponent(); - } - - private void label1_Click(object sender, EventArgs e) - { - - } - - private void Mouse_Load(object sender, EventArgs e) - { - - } - } -} Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.resx 2012-05-25 10:34:08 UTC (rev 4491) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Mouse.resx 2012-07-01 15:14:59 UTC (rev 4492) @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<root> - <!-- - Microsoft ResX Schema - - Version 2.0 - - The primary goals of this format is to allow a simple XML format - that is mostly human readable. The generation and parsing of the - various data types are done through the TypeConverter classes - associated with the data types. - - Example: - - ... ado.net/XML headers & schema ... - <resheader name="resmimetype">text/microsoft-resx</resheader> - <resheader name="version">2.0</resheader> - <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> - <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> - <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> - <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> - <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> - <value>[base64 mime encoded serialized .NET Framework object]</value> - </data> - <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> - <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> - <comment>This is a comment</comment> - </data> - - There are any number of "resheader" rows that contain simple - name/value pairs. - - Each data row contains a name, and value. The row also contains a - type or mimetype. Type corresponds to a .NET class that support - text/value conversion through the TypeConverter architecture. - Classes that don't support this are serialized and stored with the - mimetype set. - - The mimetype is used for serialized objects, and tells the - ResXResourceReader how to depersist the object. This is currently not - extensible. For a given mimetype the value must be set accordingly: - - Note - application/x-microsoft.net.object.binary.base64 is the format - that the ResXResourceWriter will generate, however the reader can - read any of the formats listed below. - - mimetype: application/x-microsoft.net.object.binary.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.soap.base64 - value : The object must be serialized with - : System.Runtime.Serialization.Formatters.Soap.SoapFormatter - : and then encoded with base64 encoding. - - mimetype: application/x-microsoft.net.object.bytearray.base64 - value : The object must be serialized into a byte array - : using a System.ComponentModel.TypeConverter - : and then encoded with base64 encoding. - --> - <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> - <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> - <xsd:element name="root" msdata:IsDataSet="true"> - <xsd:complexType> - <xsd:choice maxOccurs="unbounded"> - <xsd:element name="metadata"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" /> - </xsd:sequence> - <xsd:attribute name="name" use="required" type="xsd:string" /> - <xsd:attribute name="type" type="xsd:string" /> - <xsd:attribute name="mimetype" type="xsd:string" /> - <xsd:attribute ref="xml:space" /> - </xsd:complexType> - </xsd:element> - <xsd:element name="assembly"> - <xsd:complexType> - <xsd:attribute name="alias" type="xsd:string" /> - <xsd:attribute name="name" type="xsd:string" /> - </xsd:complexType> - </xsd:element> - <xsd:element name="data"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> - <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> - <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> - <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> - <xsd:attribute ref="xml:space" /> - </xsd:complexType> - </xsd:element> - <xsd:element name="resheader"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> - </xsd:sequence> - <xsd:attribute name="name" type="xsd:string" use="required" /> - </xsd:complexType> - </xsd:element> - </xsd:choice> - </xsd:complexType> - </xsd:element> - </xsd:schema> - <resheader name="resmimetype"> - <value>text/microsoft-resx</value> - </resheader> - <resheader name="version"> - <value>2.0</value> - </resheader> - <resheader name="reader"> - <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </resheader> - <resheader name="writer"> - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> - </resheader> -</root> \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/Resources.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/Resources.Designer.cs 2012-05-25 10:34:08 UTC (rev 4491) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/Resources.Designer.cs 2012-07-01 15:14:59 UTC (rev 4492) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. -// Runtime Version:4.0.30319.261 +// Runtime Version:4.0.30319.269 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -87,12 +87,5 @@ return ((System.Drawing.Bitmap)(obj)); } } - - internal static System.Drawing.Bitmap icon_48x48_mouse { - get { - object obj = ResourceManager.GetObject("icon-48x48-mouse", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/Resources.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/Resources.resx 2012-05-25 10:34:08 UTC (rev 4491) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/Resources.resx 2012-07-01 15:14:59 UTC (rev 4492) @@ -117,7 +117,7 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> - <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> + <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <data name="edit-icon" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\res\edit-icon.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> @@ -130,7 +130,4 @@ <data name="file-icon" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>..\res\file-icon.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> </data> - <data name="icon-48x48-mouse" type="System.Resources.ResXFileRef, System.Windows.Forms"> - <value>..\res\icon-48x48-mouse.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> - </data> </root> \ No newline at end of file Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/res/icon-48x48-mouse.png =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2012-09-09 20:42:49
|
Revision: 4510 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4510&view=rev Author: doskabouter Date: 2012-09-09 20:42:42 +0000 (Sun, 09 Sep 2012) Log Message: ----------- Added option to change default useragent Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-08-12 17:51:38 UTC (rev 4509) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-09-09 20:42:42 UTC (rev 4510) @@ -177,6 +177,9 @@ #endregion TrySetProxy(); + if (!String.IsNullOrEmpty(settings.UserAgent)) + GeckoPreferences.User["general.useragent.override"] = settings.UserAgent; + BookmarkXml.AddFolder(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", "Saved by MP"); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs 2012-08-12 17:51:38 UTC (rev 4509) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs 2012-09-09 20:42:42 UTC (rev 4510) @@ -48,6 +48,7 @@ public string Server { get; set; } public int Port { get; set; } public GUIFacadeControl.Layout View { get; set; } + public string UserAgent { get; set; } private const string section = "btWeb"; @@ -98,6 +99,7 @@ Remote_PageDown = GetActionFromString(xmlreader, "remote_pagedown", Default_Remote_PageDown); LastUrl = xmlreader.GetValueAsString(section, "lastUrl", string.Empty); + UserAgent = xmlreader.GetValueAsString(section, "useragent", string.Empty); UseProxy = xmlreader.GetValueAsBool(section, "proxy", false); Server = xmlreader.GetValueAsString(section, "proxy_server", "127.0.0.1"); @@ -160,6 +162,7 @@ xmlwriter.SetValue(section, "remote_pagedown", Remote_PageDown); xmlwriter.SetValue(section, "bookmark", View); + xmlwriter.SetValue(section, "useragent", UserAgent); xmlwriter.SetValueAsBool(section, "proxy", UseProxy); xmlwriter.SetValue(section, "proxy_server", Server); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2012-08-12 17:51:38 UTC (rev 4509) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2012-09-09 20:42:42 UTC (rev 4510) @@ -85,6 +85,9 @@ this.label3 = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.tabPage5 = new System.Windows.Forms.TabPage(); + this.groupBox13 = new System.Windows.Forms.GroupBox(); + this.cbOverrideUserAgent = new System.Windows.Forms.CheckBox(); + this.cmbUserAgent = new System.Windows.Forms.ComboBox(); this.groupBox8 = new System.Windows.Forms.GroupBox(); this.txtHttpPort = new System.Windows.Forms.TextBox(); this.txtHttpServer = new System.Windows.Forms.TextBox(); @@ -156,6 +159,7 @@ this.tabPage3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.tabPage5.SuspendLayout(); + this.groupBox13.SuspendLayout(); this.groupBox8.SuspendLayout(); this.tabPage4.SuspendLayout(); this.groupBox11.SuspendLayout(); @@ -731,14 +735,57 @@ // tabPage5 // this.tabPage5.BackColor = System.Drawing.SystemColors.Control; + this.tabPage5.Controls.Add(this.groupBox13); this.tabPage5.Controls.Add(this.groupBox8); this.tabPage5.Location = new System.Drawing.Point(4, 25); this.tabPage5.Name = "tabPage5"; this.tabPage5.Padding = new System.Windows.Forms.Padding(3); this.tabPage5.Size = new System.Drawing.Size(562, 476); this.tabPage5.TabIndex = 4; - this.tabPage5.Text = "Proxy"; + this.tabPage5.Text = "Proxy/UserAgent"; // + // groupBox13 + // + this.groupBox13.Controls.Add(this.cbOverrideUserAgent); + this.groupBox13.Controls.Add(this.cmbUserAgent); + this.groupBox13.Location = new System.Drawing.Point(6, 157); + this.groupBox13.Name = "groupBox13"; + this.groupBox13.Size = new System.Drawing.Size(550, 100); + this.groupBox13.TabIndex = 2; + this.groupBox13.TabStop = false; + this.groupBox13.Text = "UserAgent"; + // + // cbOverrideUserAgent + // + this.cbOverrideUserAgent.AutoSize = true; + this.cbOverrideUserAgent.Location = new System.Drawing.Point(6, 21); + this.cbOverrideUserAgent.Name = "cbOverrideUserAgent"; + this.cbOverrideUserAgent.Size = new System.Drawing.Size(146, 20); + this.cbOverrideUserAgent.TabIndex = 1; + this.cbOverrideUserAgent.Text = "Override UserAgent"; + this.cbOverrideUserAgent.UseVisualStyleBackColor = true; + this.cbOverrideUserAgent.CheckedChanged += new System.EventHandler(this.cbOverrideUserAgent_CheckedChanged); + // + // cmbUserAgent + // + this.cmbUserAgent.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cmbUserAgent.FormattingEnabled = true; + this.cmbUserAgent.Items.AddRange(new object[] { + "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2" + + ".0.50727; Media Center PC 5.0; .NET CLR 3.0.30729; .NET CLR 3.5.30729; .NET4.0C;" + + " .NET4.0E)", + "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.19) Gecko", + "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0", + "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.1.3) Gecko/20090824 Firefox/3" + + ".5.3", + "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHT" + + "ML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10"}); + this.cmbUserAgent.Location = new System.Drawing.Point(6, 46); + this.cmbUserAgent.Name = "cmbUserAgent"; + this.cmbUserAgent.Size = new System.Drawing.Size(538, 24); + this.cmbUserAgent.TabIndex = 0; + // // groupBox8 // this.groupBox8.Controls.Add(this.txtHttpPort); @@ -1313,6 +1360,8 @@ this.tabPage3.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.tabPage5.ResumeLayout(false); + this.groupBox13.ResumeLayout(false); + this.groupBox13.PerformLayout(); this.groupBox8.ResumeLayout(false); this.groupBox8.PerformLayout(); this.tabPage4.ResumeLayout(false); @@ -1437,5 +1486,8 @@ private System.Windows.Forms.ComboBox cmbPageUp; private System.Windows.Forms.Label label37; private System.Windows.Forms.Label label36; + private System.Windows.Forms.GroupBox groupBox13; + private System.Windows.Forms.ComboBox cmbUserAgent; + private System.Windows.Forms.CheckBox cbOverrideUserAgent; } } \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2012-08-12 17:51:38 UTC (rev 4509) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2012-09-09 20:42:42 UTC (rev 4510) @@ -643,6 +643,9 @@ cmbPageDown.SelectedItem = settings.Remote_PageDown; cmbBookmarkView.SelectedItem = settings.View; + cmbUserAgent.Text = settings.UserAgent; + cbOverrideUserAgent.Checked = !String.IsNullOrEmpty(cmbUserAgent.Text); + chkProxy.Checked = settings.UseProxy; txtHttpServer.Text = settings.Server; txtHttpPort.Text = settings.Port.ToString(); @@ -678,6 +681,10 @@ settings.Remote_Status = (Action.ActionType)cmbStatusBar.SelectedItem; settings.View = (GUIFacadeControl.Layout)cmbBookmarkView.SelectedItem; + if (cbOverrideUserAgent.Checked) + settings.UserAgent = cmbUserAgent.Text; + else + settings.UserAgent = String.Empty; settings.UseProxy = chkProxy.Checked; settings.Server = txtHttpServer.Text; @@ -733,8 +740,7 @@ // http://geckofx.org/viewtopic.php?id=832 GeckoPreferences.User["network.proxy.http"] = Server; GeckoPreferences.User["network.proxy.http_port"] = Port; - int ena = 0; if (useProxy) ena = 1; - GeckoPreferences.User["network.proxy.type"] = ena; + GeckoPreferences.User["network.proxy.type"] = useProxy ? 1 : 0; // maybe possible... not sure... // network.proxy.login @@ -835,5 +841,10 @@ cmbPageDown.SelectedItem = Settings.Default_Remote_PageDown; } + private void cbOverrideUserAgent_CheckedChanged(object sender, EventArgs e) + { + cmbUserAgent.Enabled = cbOverrideUserAgent.Checked; + } + } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2012-08-12 17:51:38 UTC (rev 4509) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2012-09-09 20:42:42 UTC (rev 4510) @@ -176,6 +176,6 @@ <value>26, 16</value> </metadata> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>47</value> + <value>46</value> </metadata> </root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2013-03-05 22:46:23
|
Revision: 4524 http://sourceforge.net/p/mp-plugins/code/4524 Author: doskabouter Date: 2013-03-05 22:46:21 +0000 (Tue, 05 Mar 2013) Log Message: ----------- - cleanup - fixed bug: goto previous window unnecessarily shows bookmarks and webpage again Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2013-01-26 17:41:24 UTC (rev 4523) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2013-03-05 22:46:21 UTC (rev 4524) @@ -39,11 +39,13 @@ [SkinControlAttribute(3)] protected GUISortButtonControl btnSortBy = null; + public const int BookmarkWindowId = 54537688; + public override int GetID { get { - return 54537688; + return BookmarkWindowId; } set { @@ -79,7 +81,10 @@ else { GUIPlugin.StartupLink = item.Path; - GUIWindowManager.ActivateWindow(54537689); + if (GUIWindowManager.GetPreviousActiveWindow() == GUIPlugin.PluginWindowId) + GUIWindowManager.ShowPreviousWindow(); + else + GUIWindowManager.ActivateWindow(GUIPlugin.PluginWindowId); } } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2013-01-26 17:41:24 UTC (rev 4523) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2013-03-05 22:46:21 UTC (rev 4524) @@ -61,6 +61,7 @@ #region Constants private const string _spanstyle = "font-family: arial,sans-serif; font-size: 12px ! important; line-height: 130% ! important; border-width: 1px ! important; border-style: solid ! important; -moz-border-radius: 2px 2px 2px 2px ! important; padding: 0px 2px ! important; margin-right: 2px; max-width: 20px; max-height: 10px ! important; overflow: visible ! important; float: none ! important; display: inline;"; + public const int PluginWindowId = 54537689; #endregion #region declare vars @@ -86,7 +87,7 @@ public string Author() { - return "Mark Koenig (kroko) 2010"; + return "Doskabouter"; } public bool CanEnable() { @@ -133,7 +134,7 @@ { get { - return 54537689; + return PluginWindowId; } set { @@ -346,7 +347,7 @@ protected override void OnPageDestroy(int new_windowId) { - if (new_windowId != 54537688) + if (new_windowId != GUIBookmark.BookmarkWindowId) { // not if you got favs if (settings.BlankBrowser) { @@ -483,7 +484,7 @@ } if (action.wID == settings.Remote_Bookmark) { - GUIWindowManager.ActivateWindow(54537688); + GUIWindowManager.ActivateWindow(GUIBookmark.BookmarkWindowId); return; } if ((action.wID == settings.Remote_Zoom_In) || @@ -636,7 +637,7 @@ if (e.KeyCode == (uint)Keys.Left) OnMoveLeft(); if (e.KeyCode == (uint)Keys.Right) OnMoveRight(); - if (e.KeyCode == (uint)Keys.F3) GUIWindowManager.ActivateWindow(54537688); + if (e.KeyCode == (uint)Keys.F3) GUIWindowManager.ActivateWindow(GUIBookmark.BookmarkWindowId); if (e.KeyCode == (uint)Keys.F7) webBrowser.GoBack(); if (e.KeyCode == (uint)Keys.F8) webBrowser.GoForward(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2013-04-07 19:47:32
|
Revision: 4559 http://sourceforge.net/p/mp-plugins/code/4559 Author: doskabouter Date: 2013-04-07 19:47:28 +0000 (Sun, 07 Apr 2013) Log Message: ----------- - version increased to 1.1 - Major rework of DOM-interaction. Increases the number of items to click on, better handling of textboxes (value prefilled on clicking) - Explicit loading of preferences Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/AssemblyInfo.cs Added Paths: ----------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs Removed Paths: ------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlLinkNumber.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2013-04-06 19:42:56 UTC (rev 4558) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2013-04-07 19:47:28 UTC (rev 4559) @@ -83,6 +83,7 @@ <Compile Include="Bookmark.cs" /> <Compile Include="BookmarkElement.cs" /> <Compile Include="BookmarkXml.cs" /> + <Compile Include="DomHelper.cs" /> <Compile Include="GetFolder.cs"> <SubType>Form</SubType> </Compile> @@ -103,8 +104,6 @@ </Compile> <Compile Include="GUIBookmark.cs" /> <Compile Include="GUIPlugin.cs" /> - <Compile Include="HtmlInputType.cs" /> - <Compile Include="HtmlLinkNumber.cs" /> <Compile Include="ImportIE.cs"> <SubType>Form</SubType> </Compile> Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs 2013-04-07 19:47:28 UTC (rev 4559) @@ -0,0 +1,285 @@ +using System; +using System.Drawing; +using System.Linq; +using Gecko; +using Gecko.DOM; + +namespace BrowseTheWeb +{ + public class DomHelper + { + private const string _spanstyle = "font-family: arial,sans-serif; font-size: 12px ! important; line-height: 130% ! important; border-width: 1px ! important; border-style: solid ! important; -moz-border-radius: 2px 2px 2px 2px ! important; padding: 0px 2px ! important; margin-right: 2px; max-width: 20px; max-height: 10px ! important; overflow: visible ! important; float: none ! important; display: inline;"; + private const string btwebId = "btweb_id"; + + public static void AddLinksToPage(GeckoDocument document) + { + int maxId = GetMaxId(document); + AddLinksToPage(document, maxId + 1); + } + + public static GeckoHtmlElement GetElement(string linkId, GeckoDocument document) + { + GeckoHtmlElement ge = document.GetElements(String.Format("//*[@{0}='{1}']", btwebId, linkId)).FirstOrDefault(); + if (ge != null) + return ge; + + GeckoElementCollection iframes = document.GetElementsByTagName("iframe"); + foreach (GeckoIFrameElement element in iframes) + { + ge = GetElement(linkId, element.ContentDocument); + if (ge != null) + return ge; + } + return null; + } + + public static Point GetCenterCoordinate(GeckoDocument root, GeckoHtmlElement element) + { + Point documentOffset = DocumentOffset(root, element.OwnerDocument); + RectangleF rect = element.BoundingClientRect; + Point p = new Point(Convert.ToInt32(rect.Left + rect.Width / 2), Convert.ToInt32(rect.Top + rect.Height / 2)); + p.X += documentOffset.X; + p.Y += documentOffset.Y; + return p; + } + + public static int NrOfChildElementsDone(GeckoHtmlElement element) + { + return element.GetElements(".//*[@" + btwebId + "]").Count(); + } + + private static Point DocumentOffset(GeckoDocument root, GeckoDocument current) + { + Point result = new Point(0, 0); + if (root.Equals(current)) + return result; + + GeckoElementCollection iframes = root.GetElementsByTagName("iframe"); + foreach (GeckoIFrameElement element in iframes) + { + if (element.ContentDocument.Equals(current)) + { + Point tmp = DocumentOffset(root, element.OwnerDocument); + result.X += element.BoundingClientRect.Left + tmp.X; + result.Y += element.BoundingClientRect.Top + tmp.Y; + return result; + } + } + return new Point(0, 0); + } + + private static void AddLinksToPage(GeckoDocument document, int id) + { + GeckoElementCollection links = document.Links; + MyLog.debug("page links cnt : " + links.Count); + foreach (GeckoHtmlElement element in links) // no casting to GeckoAnchorElement, because document.links also returns GeckoAreaElemenets + if (!element.GetAttribute("href").StartsWith("javascript:")) + { + GeckoHtmlElement lastSpan = element; + bool ready = false; + while (!ready) + { + GeckoHtmlElement ls = lastSpan.LastChild as GeckoHtmlElement; + if (ls == null || ls.TagName != "SPAN") + ready = true; + else + lastSpan = ls; + }; + if (!elementDone(element)) + { + GeckoElement ls = element; + while (ls.LastChild != null && ls.LastChild is GeckoElement && !String.IsNullOrEmpty(ls.LastChild.TextContent)) + ls = (GeckoElement)ls.LastChild; + insertSpanAfter(id, lastSpan.ClassName, ls); + SetLinkAttributes(element, id); + id++; + } + } + + foreach (GeckoHtmlElement element in links) // no casting to GeckoAnchorElement, because document.links also returns GeckoAreaElemenets + if (!element.GetAttribute("href").StartsWith("javascript:") && element.ClientRects.Length == 0) + //invisible, so find visible previousSibling/parent and put a number on that + { + GeckoNode el = element; + while (el != null && !ElementVisible(el)) + { + GeckoNode ps = el.PreviousSibling; + if (ps != null) + el = ps; + else + el = el.ParentNode; + } + + if (el != null)// -> ElementVisible(el)=true, and thus el is a GeckoHtmlElement + { + GeckoHtmlElement geckoEl = (GeckoHtmlElement)el; + + GeckoHtmlElement lastSpan = geckoEl; + bool ready = false; + while (!ready) + { + GeckoHtmlElement ls = lastSpan.LastChild as GeckoHtmlElement; + if (ls == null || ls.TagName != "SPAN") + ready = true; + else + lastSpan = ls; + }; + + if (!elementDone(geckoEl)) + { + + GeckoElement ls = geckoEl; + while (ls.LastChild != null && ls.LastChild is GeckoElement && !String.IsNullOrEmpty(ls.LastChild.TextContent)) + ls = (GeckoElement)ls.LastChild; + insertSpanAfter(id, lastSpan.ClassName, ls); + SetLinkAttributes(geckoEl, id); + id++; + } + } + } + + GeckoElementCollection objects = document.GetElementsByTagName("object"); + MyLog.debug("page objects cnt : " + objects.Count); + foreach (GeckoObjectElement element in objects) + if (element.Type == "application/x-shockwave-flash") + { + if (!elementDone(element)) + { + insertSpanAfter(id, null, element.Parent, "color:black;background-color:white"); + SetLinkAttributes(element, id); + id++; + } + } + + GeckoElementCollection forms = document.GetElementsByTagName("form"); + MyLog.debug("page forms cnt : " + forms.Count); + foreach (GeckoHtmlElement element in forms) + { + GeckoElementCollection inps = element.GetElementsByTagName("input"); + foreach (GeckoInputElement inp in inps) + if (!elementDone(inp)) + { + string linkType = inp.Type; + if (!String.IsNullOrEmpty(linkType)) + { + if (linkType != "hidden") + { + SetLinkAttributes(inp, id); + + GeckoNode ps = inp.PreviousSibling; + while (ps != null && !(ps is GeckoHtmlElement)) + ps = ps.PreviousSibling; + + if (inp.PreviousSibling != null) + insertSpanBefore(id, null, inp); + else + insertSpanAfter(id, null, inp.Parent); + id++; + } + } + else + { + SetLinkAttributes(inp, id); + insertSpanAfter(id, null, inp.Parent); + id++; + } + } + + GeckoElementCollection buttons = element.GetElementsByTagName("button"); + foreach (GeckoHtmlElement button in buttons) + if (!elementDone(button) && button.ClientRects.Length != 0) + { + SetLinkAttributes(button, id); + insertSpanBefore(id, null, button); + id++; + } + + GeckoElementCollection selects = element.GetElementsByTagName("select"); + foreach (GeckoHtmlElement select in selects) + if (!elementDone(select) && select.ClientRects.Length != 0) + { + SetLinkAttributes(select, id); + insertSpanBefore(id, null, select); + id++; + } + } + + GeckoElementCollection iframes = document.GetElementsByTagName("iframe"); + MyLog.debug("page iframes cnt : " + iframes.Count); + foreach (GeckoIFrameElement element in iframes) + AddLinksToPage(element.ContentDocument, id); + } + + private static int GetMaxId(GeckoDocument document) + { + int maxId = 0; + try + { + foreach (GeckoHtmlElement ge in document.GetElements("//*[@" + btwebId + "]")) + { + int j; + if (Int32.TryParse(ge.Attributes[btwebId].NodeValue, out j)) + maxId = Math.Max(maxId, j); + } + } + catch + { + // sometimes this causes an exception... + }; + + GeckoElementCollection iframes = document.GetElementsByTagName("iframe"); + foreach (GeckoIFrameElement element in iframes) + maxId = Math.Max(maxId, GetMaxId(element.ContentDocument)); + return maxId; + } + + private static GeckoHtmlElement CreateSpan(GeckoDocument owner, int geckoId, string className, string extra) + { + GeckoHtmlElement result = owner.CreateHtmlElement("span"); + result.SetAttribute("style", _spanstyle + extra); + result.InnerHtml = geckoId.ToString(); + if (!String.IsNullOrEmpty(className)) + result.SetAttribute("class", className); + return result; + } + + private static GeckoElement insertSpanAfter(int geckoId, string className, GeckoNode after, string extra = "") + { + if (after == null) + throw new ArgumentNullException("after"); + GeckoHtmlElement newChild = CreateSpan(after.OwnerDocument, geckoId, className, extra); + if (after.FirstChild == null) + after.AppendChild(newChild); + else + after.InsertBefore(newChild, after.FirstChild); + return newChild; + } + + private static GeckoElement insertSpanBefore(int geckoId, string className, GeckoNode before, string extra = "") + { + if (before == null) + throw new ArgumentNullException("after"); + GeckoHtmlElement newElement = CreateSpan(before.OwnerDocument, geckoId, className, extra); + before.ParentNode.InsertBefore(newElement, before); + return newElement; + } + + private static void SetLinkAttributes(GeckoElement link, int linkNumber) + { + link.SetAttribute(btwebId, linkNumber.ToString()); + } + + private static bool elementDone(GeckoElement element) + { + return !String.IsNullOrEmpty(element.GetAttribute(btwebId)); + } + + private static bool ElementVisible(GeckoNode el) + { + GeckoHtmlElement ge = el as GeckoHtmlElement; + return ge != null && ge.OffsetHeight > 0; + } + + + } +} Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2013-04-06 19:42:56 UTC (rev 4558) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2013-04-07 19:47:28 UTC (rev 4559) @@ -23,9 +23,9 @@ #endregion using System; -using System.Collections.Generic; using System.Drawing; using System.IO; +using System.Text; using MediaPortal.GUI.Library; using MediaPortal.Dialogs; @@ -35,6 +35,7 @@ using System.Runtime.InteropServices; using Gecko; +using Gecko.DOM; namespace BrowseTheWeb { @@ -57,12 +58,8 @@ private bool mouseVisible = false; private bool clickFromPlugin = false; private bool aeroDisabled = false; - #region Links - private Dictionary<int, HtmlLinkNumber> _htmlLinkNumbers = new Dictionary<int, HtmlLinkNumber>(); - #endregion #region Constants - private const string _spanstyle = "font-family: arial,sans-serif; font-size: 12px ! important; line-height: 130% ! important; border-width: 1px ! important; border-style: solid ! important; -moz-border-radius: 2px 2px 2px 2px ! important; padding: 0px 2px ! important; margin-right: 2px; max-width: 20px; max-height: 10px ! important; overflow: visible ! important; float: none ! important; display: inline;"; public const int PluginWindowId = 54537689; #endregion @@ -217,6 +214,9 @@ osd_linkID = new OSD_LinkId(); GUIGraphicsContext.form.Controls.Add(osd_linkID); osd_linkID.Visible = false; + string preferenceFile = Path.Combine(Config.GetFolder(Config.Dir.Config), "btwebprefs.js"); + if (File.Exists(preferenceFile)) + GeckoPreferences.Load(preferenceFile); #endregion } @@ -291,7 +291,7 @@ webBrowser.Visible = true; webBrowser.Enabled = settings.UseMouse; - //webBrowser.ClearCachedCOMPtrs();possibly not needed anymore + webBrowser.ClearCachedCOMPtrs(); webBrowser.Dock = DockStyle.None; SetBrowserWindow(); @@ -410,8 +410,7 @@ // http://geckofx.org/viewtopic.php?id=832 GeckoPreferences.User["network.proxy.http"] = Server; GeckoPreferences.User["network.proxy.http_port"] = Port; - int ena = 0; if (useProxy) ena = 1; - GeckoPreferences.User["network.proxy.type"] = ena; + GeckoPreferences.User["network.proxy.type"] = useProxy ? 1 : 0; // maybe possible... not sure... // network.proxy.login @@ -903,56 +902,6 @@ } } - private void AddElements(List<GeckoHtmlElement> list, GeckoNode parent, string elName) - { - if (parent is GeckoHtmlElement && ((GeckoHtmlElement)parent).TagName.ToLowerInvariant() == elName) - list.Add((GeckoHtmlElement)parent); - foreach (GeckoNode child in parent.ChildNodes) - AddElements(list, child, elName); - } - - private List<GeckoHtmlElement> getElements(GeckoNode parent, string elName) - { - List<GeckoHtmlElement> res = new List<GeckoHtmlElement>(); - AddElements(res, parent, elName); - return res; - } - - private GeckoElement insertSpan(int geckoId, string geckoAction, string geckoType, string className, GeckoNode after) - { - if (after == null) - throw new ArgumentNullException("after"); - GeckoHtmlElement newChild = after.OwnerDocument.CreateHtmlElement("span"); - newChild.SetAttribute("style", _spanstyle); - newChild.SetAttribute("gecko_id", geckoId.ToString()); - newChild.SetAttribute("gecko_action", geckoAction); - newChild.SetAttribute("gecko_type", geckoType); - newChild.InnerHtml = geckoId.ToString(); - if (!String.IsNullOrEmpty(className)) - newChild.SetAttribute("class", className); - if (after.FirstChild == null) - after.AppendChild(newChild); - else - after.InsertBefore(newChild, after.FirstChild); - return newChild; - } - - private void SetLinkAttributes(GeckoElement link, int linkNumber, out string id, out string name) - { - string gb = link.GetAttribute("gb"); - id = link.GetAttribute("id"); - name = link.GetAttribute("name"); - if (string.IsNullOrEmpty(gb)) - { - link.SetAttribute("gb", "gecko_link" + linkNumber); - } - if (string.IsNullOrEmpty(id)) - { - link.SetAttribute("id", "gb" + linkNumber); - id = "gb" + linkNumber; - } - } - private void webBrowser_DocumentCompleted(object sender, EventArgs e) { MyLog.debug("page completed : " + webBrowser.Url.ToString()); @@ -968,123 +917,8 @@ #endregion if (!settings.UseMouse) - { - #region add links to page - _htmlLinkNumbers.Clear(); + DomHelper.AddLinksToPage(webBrowser.Document); - GeckoElementCollection links = webBrowser.Document.Links; - int i = 1; - - MyLog.debug("page links cnt : " + links.Count); - - foreach (GeckoHtmlElement element in links) - { - string link = element.GetAttribute("href"); - - if (!link.StartsWith("javascript:")) - { - GeckoHtmlElement lastSpan = element; - bool ready = false; - while (!ready) - { - GeckoHtmlElement ls = lastSpan.LastChild as GeckoHtmlElement; - if (ls == null || ls.TagName != "SPAN") - ready = true; - else - lastSpan = ls; - }; - if (!element.InnerHtml.Contains("gecko_id")) - { - GeckoElement ls = element; - while (ls.LastChild != null && ls.LastChild is GeckoElement && !String.IsNullOrEmpty(ls.LastChild.TextContent)) - ls = (GeckoElement)ls.LastChild; - insertSpan(i, String.Empty, "LINK", lastSpan.ClassName, ls); - } - - string id, name; - SetLinkAttributes(element, i, out id, out name); - _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, link, HtmlInputType.Link)); - i++; - } - } - - GeckoElementCollection objects = webBrowser.Document.GetElementsByTagName("object"); - MyLog.debug("page objects cnt : " + objects.Count); - foreach (GeckoHtmlElement element in objects) - if (element.GetAttribute("type") == "application/x-shockwave-flash") - { - string id, name; - GeckoHtmlElement element2 = element.Parent; - SetLinkAttributes(element2, i, out id, out name); - - if (!element2.InnerHtml.Contains("gecko_id=\"" + i + "\"")) - { - insertSpan(i, String.Empty, "LINK", null, element2); - } - RectangleF rect = element2.BoundingClientRect; - Point p = new Point(Convert.ToInt32(rect.Left + rect.Width / 2), Convert.ToInt32(rect.Top + rect.Height / 2)); - _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, p, HtmlInputType.FlashObject)); - i++; - } - - GeckoElementCollection forms = webBrowser.Document.GetElementsByTagName("form"); - - MyLog.debug("page forms cnt : " + forms.Count); - - foreach (GeckoHtmlElement element in forms) - { - List<GeckoHtmlElement> inps = getElements(element, "input"); - string action = element.GetAttribute("action"); - foreach (GeckoHtmlElement link in inps) - { - string linkType = link.GetAttribute("type"); - if (!String.IsNullOrEmpty(linkType)) - { - if (linkType != "hidden") - { - string id, name; - SetLinkAttributes(link, i, out id, out name); - - if (!element.InnerHtml.Contains("gecko_id=\"" + i + "\"")) - { - insertSpan(i, action, "INPUT", null, link.Parent); - } - if (linkType == "submit" || - linkType == "reset" || - linkType == "radio" || - linkType == "image" || - linkType == "checkbox") - { - _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.Action)); - } - else - { - if (linkType == "password") - _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.InputPassword)); - else - _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); - } - i++; - } - } - else - { - string id, name; - SetLinkAttributes(link, i, out id, out name); - - if (!element.InnerHtml.Contains("gecko_id=\"" + i + "\"")) - { - insertSpan(i, action, "INPUT", null, link.Parent); - } - - _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); - i++; - } - } - } - #endregion - } - #region reset zoom if (settings.ZoomPage) { @@ -1125,118 +959,120 @@ osd_linkID.Visible = false; Application.DoEvents(); - HtmlLinkNumber hln = null; - if (GetLinkById(Convert.ToInt32(LinkId), out hln)) + GeckoHtmlElement ge = DomHelper.GetElement(LinkId, webBrowser.Document); + + if (ge == null) { - switch (hln.Type) - { - case HtmlInputType.Link: - string link = (string)hln.Obj; - webBrowser.Navigate(link); - MyLog.debug("navigate to linkid=" + LinkId + " URL=" + link); - break; - case HtmlInputType.Input: - case HtmlInputType.InputPassword: - ShowInputDialog(hln); - break; - case HtmlInputType.Action: - webBrowser.Navigate("javascript:document.getElementById(\"" + hln.Id + "\").click()"); - MyLog.debug("action linkid=" + LinkId); - break; - case HtmlInputType.FlashObject: - MyLog.debug("flash click on " + Cursor.Position.ToString()); - Point p = (Point)hln.Obj; - webBrowser.Enabled = true; + MyLog.debug(String.Format("LinkId {0} not found in _htmlLinkNumbers", LinkId)); + return; + } - System.Threading.Thread.Sleep(200); - Cursor.Position = webBrowser.PointToScreen(p); - int X = Cursor.Position.X; - int Y = Cursor.Position.Y; - clickFromPlugin = true; - mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); - break; - } + if (ge is GeckoAnchorElement) + { + string link = ((GeckoAnchorElement)ge).Href; + webBrowser.Navigate(link); + MyLog.debug("navigate to linkid=" + LinkId + " URL=" + link); } - } - private bool GetLinkById(int value, out HtmlLinkNumber hln) - { - if (_htmlLinkNumbers.ContainsKey(value)) - { - HtmlLinkNumber id = _htmlLinkNumbers[value]; - switch (id.Type) + else + if (ge is GeckoButtonElement) { - case HtmlInputType.Link: + ge.Click(); + } + else + if (ge is GeckoSelectElement) + { + ShowSelect(ge as GeckoSelectElement); + } + else + if (ge is GeckoInputElement) { - string link = (string)id.Obj; - if (!Uri.IsWellFormedUriString(link, UriKind.Absolute)) + string linkType = ((GeckoInputElement)ge).Type; + if (!String.IsNullOrEmpty(linkType)) { - Uri baseUri = webBrowser.Url; - - GeckoElementCollection baseElements = webBrowser.Document.GetElementsByTagName("base"); - if (baseElements != null && baseElements.Count > 0) + switch (linkType) { - GeckoNode gn = baseElements[0].Attributes["href"]; - if (gn != null && !String.IsNullOrEmpty(gn.NodeValue)) - baseUri = new Uri(gn.NodeValue); + case "password": ShowInputDialog(true, ge as GeckoInputElement); break; + case "submit": + case "reset": + case "radio": + case "image": + case "checkbox": + ge.Click(); + MyLog.debug("action linkid=" + LinkId); + break; + case "hidden": break; + default: ShowInputDialog(false, ge as GeckoInputElement); break; } - id.Obj = new Uri(baseUri, link).AbsoluteUri; } - hln = id; - return true; } - case HtmlInputType.FlashObject: - case HtmlInputType.Input: - case HtmlInputType.InputPassword: - case HtmlInputType.Action: - hln = id; - return true; - //return "javascript:document.getElementById(\"" + id.Name + "\").click()"; - } - } - else - MyLog.debug(String.Format("LinkId {0} not found in _htmlLinkNumbers", value)); - hln = null; - return false; + else + //if (ge is GeckoObjectElement) + // some items just need a mousehover, and a ge.Click won't do that + { + Point p = DomHelper.GetCenterCoordinate(webBrowser.Document, ge); + MyLog.debug("perform click on " + p.ToString()); + + webBrowser.Enabled = true; + System.Threading.Thread.Sleep(200); + Cursor.Position = webBrowser.PointToScreen(p); + clickFromPlugin = true; + mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); + } + //else + // ge.Click(); } - public void ShowInputDialog(HtmlLinkNumber id) + public void ShowInputDialog(bool isPassword, GeckoInputElement element) { webBrowser.Visible = false; - string result = string.Empty; - if (ShowKeyboard(ref result, id.Type == HtmlInputType.InputPassword) == DialogResult.OK) + string result = element.Value; + if (ShowKeyboard(ref result, isPassword) == DialogResult.OK) { - SetInputElementValue(webBrowser.Document, id.Number, result); - } - webBrowser.Visible = true; - } + if (element != null) + element.SetAttribute("value", result); + GeckoFormElement form = element.Form; + if (form != null) + { + //List<GeckoHtmlElement> inps = DomHelper.GetElements(form, "input"); + GeckoElementCollection inps = form.GetElementsByTagName("input"); + if (DomHelper.NrOfChildElementsDone(form) == 1) + { + StringBuilder sb = new StringBuilder(); + foreach (GeckoInputElement inp in inps) + { + if (sb.Length != 0) + sb.Append('&'); + sb.Append(inp.Name); + sb.Append('='); + sb.Append(inp.Value); + } - private bool SetInputElementValue(GeckoNode parent, int geckoId, string text) - { - GeckoElement el = parent as GeckoElement; - if (el != null && el.TagName.ToLowerInvariant() == "input" && el.GetAttribute("gb") == "gecko_link" + geckoId) - { - el.SetAttribute("value", text); - return true; - } - else - { - foreach (GeckoNode child in parent.ChildNodes) - { - if (SetInputElementValue(child, geckoId, text)) - return true; + if (form.Method == "get") + webBrowser.Navigate(form.Action + '?' + sb.ToString()); + else + { + using (GeckoMIMEInputStream stream = new GeckoMIMEInputStream()) + { + stream.AddHeader("Content-Type", "application/x-www-form-urlencoded"); + stream.AddContentLength = true; + stream.SetData(sb.ToString()); + webBrowser.Navigate(form.Action, 0, null, stream); + } + } + } } - return false; } + webBrowser.Visible = true; } public static DialogResult ShowKeyboard(ref string DefaultText, bool PasswordInput) { VirtualKeyboard vk = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD); - vk.Reset(); vk.Password = PasswordInput; vk.Text = DefaultText; + vk.SetLabelAsInitialText(false); // set to false, otherwise our intial text is cleared vk.DoModal(GUIWindowManager.ActiveWindow); if (vk.IsConfirmed) @@ -1256,7 +1092,30 @@ dlg.SetLine(3, line3); dlg.DoModal(GUIWindowManager.ActiveWindow); } + public void ShowSelect(GeckoSelectElement select) + { + webBrowser.Visible = false; + GUIDialogSelect2 dlgMenu = (GUIDialogSelect2)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_SELECT2); + dlgMenu.Reset(); + dlgMenu.SetHeading(select.Name); + dlgMenu.SelectedLabel = select.SelectedIndex; + GeckoOptionsCollection options = select.Options; + for (uint i = 0; i < options.Length; i++) + { + GeckoOptionElement option = options.item(i); + dlgMenu.Add(option.Label); + } + dlgMenu.DoModal(GUIWindowManager.ActiveWindow); + webBrowser.Visible = true; + + if (dlgMenu.SelectedLabel == -1) + return; + select.SelectedIndex = dlgMenu.SelectedLabel; + return; + + } + private void OnRenderSound(string strFilePath) { MediaPortal.Util.Utils.PlaySound(strFilePath, false, true); Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs 2013-04-06 19:42:56 UTC (rev 4558) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlInputType.cs 2013-04-07 19:47:28 UTC (rev 4559) @@ -1,36 +0,0 @@ -#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 - - -namespace BrowseTheWeb -{ - public enum HtmlInputType - { - Input, - InputPassword, - Link, - Action, - FlashObject - } -} Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlLinkNumber.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlLinkNumber.cs 2013-04-06 19:42:56 UTC (rev 4558) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/HtmlLinkNumber.cs 2013-04-07 19:47:28 UTC (rev 4559) @@ -1,46 +0,0 @@ -#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 - - -namespace BrowseTheWeb -{ - public class HtmlLinkNumber - { - public HtmlLinkNumber(int number, string id, string name, object obj, HtmlInputType type) - { - Type = type; - Number = number; - Name = name; - Id = id; - Obj =obj; - - } - - public int Number { get; set; } - public string Id { get; set; } - public string Name { get; set; } - public HtmlInputType Type { get; set; } - public object Obj { get; set; } - } -} Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/AssemblyInfo.cs 2013-04-06 19:42:56 UTC (rev 4558) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Properties/AssemblyInfo.cs 2013-04-07 19:47:28 UTC (rev 4559) @@ -16,7 +16,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("MP")] [assembly: AssemblyProduct("BrowseTheWeb")] -[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyCopyright("Copyright © 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -38,5 +38,5 @@ // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2013-07-01 20:30:40
|
Revision: 4590 http://sourceforge.net/p/mp-plugins/code/4590 Author: doskabouter Date: 2013-07-01 20:30:37 +0000 (Mon, 01 Jul 2013) Log Message: ----------- - Better handling of <a> elements with onclick handler - Reuse numbers for <a> elements with same href Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs 2013-07-01 18:54:43 UTC (rev 4589) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs 2013-07-01 20:30:37 UTC (rev 4590) @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Linq; using Gecko; @@ -85,6 +86,7 @@ private static void AddLinksToPage(GeckoDocument document, int id) { + Dictionary<string, int> hrefs = new Dictionary<string, int>(); GeckoElementCollection links = document.Links; MyLog.debug("page links cnt : " + links.Count); foreach (GeckoHtmlElement element in links) // no casting to GeckoAnchorElement, because document.links also returns GeckoAreaElemenets @@ -105,9 +107,24 @@ GeckoElement ls = element; while (ls.LastChild != null && ls.LastChild is GeckoElement && !String.IsNullOrEmpty(ls.LastChild.TextContent)) ls = (GeckoElement)ls.LastChild; - insertSpanAfter(id, lastSpan.ClassName, ls); - SetLinkAttributes(element, id); - id++; + + int newId; + string url = element.GetAttribute("href"); + if (!element.HasAttribute("onclick")) + { + if (hrefs.ContainsKey(url)) + newId = hrefs[url]; + else + { + newId = id++; + hrefs.Add(url, newId); + } + } + else + newId = id++; + + insertSpanAfter(newId, lastSpan.ClassName, ls); + SetLinkAttributes(element, newId); } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2013-07-01 18:54:43 UTC (rev 4589) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2013-07-01 20:30:37 UTC (rev 4590) @@ -956,7 +956,7 @@ return; } - if (ge is GeckoAnchorElement) + if (ge is GeckoAnchorElement && !ge.HasAttribute("onclick")) { string link = ((GeckoAnchorElement)ge).Href; webBrowser.Navigate(link); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2013-12-30 20:26:13
|
Revision: 4714 http://sourceforge.net/p/mp-plugins/code/4714 Author: doskabouter Date: 2013-12-30 20:26:09 +0000 (Mon, 30 Dec 2013) Log Message: ----------- Preserve folder structure when importing bookmarks from other browsers Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs Added Paths: ----------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.resx trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/JSONNode.cs Removed Paths: ------------- 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/ImportChrome.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportChrome.resx trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportFF.resx trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.resx Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -1,276 +0,0 @@ -#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.Xml; -using System.IO; -using System.Windows.Forms; -using System.Net; -using MediaPortal.Configuration; - -using System.Drawing; - -namespace BrowseTheWeb -{ - public class Bookmark - { - private static XmlTextWriter textWriter; - - public static bool Save(TreeView Treeview, string Path) - { - bool result = false; - - try - { - textWriter = new XmlTextWriter(Path, null); - textWriter.Formatting = Formatting.Indented; - - textWriter.WriteStartDocument(); - textWriter.WriteStartElement("Bookmarks"); - - foreach (TreeNode t in Treeview.Nodes[0].Nodes) - { - BookmarkElement bkm = (BookmarkElement)t.Tag; - if (bkm != null) - { - WriteOneEntry(bkm); - - foreach (TreeNode sub in t.Nodes) - { - BookmarkElement bkm2 = (BookmarkElement)sub.Tag; - WriteOneEntry(bkm2); - } - } - } - - textWriter.WriteEndElement(); - - textWriter.WriteEndDocument(); - textWriter.Close(); - - result = true; - } - catch - { - // error - } - finally - { - if (textWriter != null) textWriter.Close(); - } - - return result; - } - public static void Load(TreeView Treeview, string Path) - { - Treeview.Nodes.Clear(); - - TreeNode main = Treeview.Nodes.Add("Bookmarks", "Bookmarks"); - main.ImageIndex = 2; - main.SelectedImageIndex = 2; - - try - { - BookmarkXml.LoadBookmarks(Path); - TreeNode akt = new TreeNode(); - - foreach (BookmarkElement bkm in BookmarkXml.BookmarkItems) - { - if (bkm.isFolder) - { - akt = main.Nodes.Add(bkm.Name); - akt.Tag = bkm; - akt.ImageIndex = 1; - akt.SelectedImageIndex = 1; - } - if (bkm.isSubFolder) - { - TreeNode sub = akt.Nodes.Add(bkm.Name); - sub.Tag = bkm; - } - if ((!bkm.isFolder) && (!bkm.isSubFolder)) - { - TreeNode add = main.Nodes.Add(bkm.Name); - add.Tag = bkm; - } - } - - Treeview.Invalidate(); - - } - catch { } - } - - private static void WriteOneEntry(BookmarkElement bkm) - { - textWriter.WriteStartElement("Entry"); - - textWriter.WriteStartElement("Name"); - textWriter.WriteValue(bkm.Name); - textWriter.WriteEndElement(); - - textWriter.WriteStartElement("URL"); - textWriter.WriteValue(bkm.Url); - textWriter.WriteEndElement(); - - textWriter.WriteStartElement("Visited"); - textWriter.WriteValue(bkm.Visited); - textWriter.WriteEndElement(); - - textWriter.WriteStartElement("LastVisited"); - textWriter.WriteValue(bkm.LastVisited); - textWriter.WriteEndElement(); - - textWriter.WriteStartElement("Created"); - textWriter.WriteValue(bkm.Created); - textWriter.WriteEndElement(); - - textWriter.WriteStartElement("isFolder"); - textWriter.WriteValue(bkm.isFolder); - textWriter.WriteEndElement(); - - textWriter.WriteStartElement("isSubFolder"); - textWriter.WriteValue(bkm.isSubFolder); - textWriter.WriteEndElement(); - - textWriter.WriteEndElement(); - - } - - public static bool Exists(TreeView Treeview, string Name) - { - foreach (TreeNode t in Treeview.Nodes[0].Nodes) - { - if (Name == t.Text) - return true; - foreach (TreeNode sub in t.Nodes) - { - if (Name == sub.Text) - return true; - } - } - return false; - } - - public static bool isValidUrl(string URL) - { - try - { - Uri urlCheck = new Uri(URL); - WebRequest request = WebRequest.Create(urlCheck); - request.Timeout = 10000; - - WebResponse response; - - response = request.GetResponse(); - } - catch (Exception) - { - return false; //url does not exist - } - return true; - } - - public static void SaveSnap(Bitmap Snap, string Url) - { - try - { - string filename = GetThumbString(Url); - filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + filename; - Snap.Save(filename); - } - catch (Exception e) - { - MyLog.debug("Exception: " + e.ToString()); - } - } - public static Bitmap GetSnap(string Url) - { - Bitmap snap = null; - - try - { - string filename = GetThumbString(Url); - filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + filename; - - if (File.Exists(filename)) - { - snap = (Bitmap)Bitmap.FromFile(filename); - return snap; - } - else - MyLog.debug("Getsnap does not exist"); - - } - catch (Exception e) - { - MyLog.debug("Exception: " + e.ToString()); - } - - return snap; - } - - public static string GetSnapPath(string Url) - { - string filename = GetThumbString(Url); - filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + filename; - - return filename; - } - public static void InitCachePath() - { - if (!Directory.Exists(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb")) - Directory.CreateDirectory(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb"); - - - if (Directory.Exists(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb")) - { - string[] files = Directory.GetFiles(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb", "*.*"); - foreach (string f in files) - { - File.Move(f, Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + Path.GetFileName(f)); - } - } - - } - - 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); - } - - foreach (char c in Path.GetInvalidFileNameChars()) - result = result.Replace(c, '_'); - result = result + ".png"; - return result; - } - } -} Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -0,0 +1,137 @@ +#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.Xml; + +namespace BrowseTheWeb +{ + public class BookmarkBase + { + public string Name = String.Empty; + public DateTime Created = DateTime.Now; + + virtual public void ToXml(XmlTextWriter textWriter) + { + textWriter.WriteStartElement("Name"); + textWriter.WriteValue(Name); + textWriter.WriteEndElement(); + textWriter.WriteStartElement("Created"); + textWriter.WriteValue(Created); + textWriter.WriteEndElement(); + } + + virtual public void FromXml(XmlNode node) + { + XmlNode nameNode = node.SelectSingleNode("Name"); + if (nameNode != null) + { + Name = nameNode.InnerText; + Created = Convert.ToDateTime(node.SelectSingleNode("Created").InnerText); + } + } + } + + public class BookmarkItem : BookmarkBase + { + public string Url = string.Empty; + + public int Visited = 0; + public DateTime LastVisited; + + public override void ToXml(XmlTextWriter textWriter) + { + textWriter.WriteStartElement("Entry"); + base.ToXml(textWriter); + + textWriter.WriteStartElement("URL"); + textWriter.WriteValue(Url); + textWriter.WriteEndElement(); + + textWriter.WriteStartElement("Visited"); + textWriter.WriteValue(Visited); + textWriter.WriteEndElement(); + textWriter.WriteStartElement("LastVisited"); + textWriter.WriteValue(LastVisited); + textWriter.WriteEndElement(); + + textWriter.WriteEndElement(); + } + + public override void FromXml(XmlNode node) + { + base.FromXml(node); + Url = node.SelectSingleNode("URL").InnerText; + + Visited = Convert.ToInt32(node.SelectSingleNode("Visited").InnerText); + LastVisited = Convert.ToDateTime(node.SelectSingleNode("LastVisited").InnerText); + } + + } + + public class BookmarkFolder : BookmarkBase + { + public List<BookmarkBase> Items; + public BookmarkFolder Parent; + + public BookmarkFolder() + { + Items = new List<BookmarkBase>(); + } + + public override void ToXml(XmlTextWriter textWriter) + { + textWriter.WriteStartElement("Folder"); + base.ToXml(textWriter); + foreach (BookmarkBase item in Items) + item.ToXml(textWriter); + + + textWriter.WriteEndElement(); + } + + public override void FromXml(XmlNode node) + { + base.FromXml(node); + foreach (XmlNode subNode in node.SelectNodes("Entry|Folder")) + { + if (subNode.Name == "Folder") + { + BookmarkFolder item = new BookmarkFolder(); + item.FromXml(subNode); + Items.Add(item); + } + else + { + BookmarkItem bmItem = new BookmarkItem(); + bmItem.FromXml(subNode); + Items.Add(bmItem); + } + + } + } + } + +} Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkElement.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -1,41 +0,0 @@ -#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; - -namespace BrowseTheWeb -{ - public class BookmarkElement - { - public string Name = string.Empty; - public string Url = string.Empty; - - public int Visited = 0; - public DateTime LastVisited; - public DateTime Created = DateTime.Now; - - public bool isFolder = false; - public bool isSubFolder = false; - } -} Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BookmarkXml.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -1,189 +0,0 @@ -#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.Xml; -using System.IO; - -namespace BrowseTheWeb -{ - public class BookmarkXml - { - public static List<BookmarkElement> BookmarkItems = new List<BookmarkElement>(); - - private static void InitBookmarks(string Path) - { - if (!File.Exists(Path)) - { - string s = "<?xml version=\"1.0\"?>\n<Bookmarks />"; - StreamWriter sr = new StreamWriter(Path); - sr.Write(s); - sr.Close(); - } - } - - public static bool LoadBookmarks(string Path) - { - InitBookmarks(Path); - - BookmarkItems = new List<BookmarkElement>(); - try - { - XmlDocument xmlDocument = new XmlDocument(); - xmlDocument.Load(Path); - - XmlNodeList col = xmlDocument.GetElementsByTagName("Entry"); - foreach (XmlNode node in col) - { - BookmarkElement elem = GetData(node); - BookmarkItems.Add(elem); - } - } - catch - { - return false; - } - return true; - } - public static BookmarkElement GetData(XmlNode Node) - { - BookmarkElement result = new BookmarkElement(); - - result.Name = Node.SelectSingleNode("Name").InnerText; - result.Url = Node.SelectSingleNode("URL").InnerText; - - result.Visited = Convert.ToInt32(Node.SelectSingleNode("Visited").InnerText); - result.LastVisited = Convert.ToDateTime(Node.SelectSingleNode("LastVisited").InnerText); - result.Created = Convert.ToDateTime(Node.SelectSingleNode("Created").InnerText); - - result.isFolder = Convert.ToBoolean(Node.SelectSingleNode("isFolder").InnerText); - result.isSubFolder = Convert.ToBoolean(Node.SelectSingleNode("isSubFolder").InnerText); - - return result; - } - - public static void AddFolder(string Path, string FolderName) - { - InitBookmarks(Path); - - try - { - XmlDocument xmlDocument = new XmlDocument(); - xmlDocument.Load(Path); - - bool found = false; - - foreach (XmlNode r in xmlDocument.ChildNodes) - { - foreach (XmlNode one in r.ChildNodes) - { - if (one.FirstChild.InnerText == FolderName) found = true; - } - } - - if (!found) - { - XmlElement childElement = xmlDocument.CreateElement("Entry"); - - XmlElement sub1 = xmlDocument.CreateElement("Name"); sub1.InnerText = FolderName; - childElement.AppendChild(sub1); - XmlElement sub2 = xmlDocument.CreateElement("URL"); sub2.InnerText = string.Empty; - childElement.AppendChild(sub2); - XmlElement sub3 = xmlDocument.CreateElement("ID"); sub3.InnerText = "0"; - childElement.AppendChild(sub3); - XmlElement sub4 = xmlDocument.CreateElement("Visited"); sub4.InnerText = "0"; - childElement.AppendChild(sub4); - XmlElement sub5 = xmlDocument.CreateElement("LastVisited"); sub5.InnerText = "0001-01-01T00:00:00"; - childElement.AppendChild(sub5); - XmlElement sub6 = xmlDocument.CreateElement("Created"); sub6.InnerText = DateTime.UtcNow.ToString("u", null); - childElement.AppendChild(sub6); - 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); - } - xmlDocument.Save(Path); - } - catch - { } - } - public static bool AddBookmark(string Title, string Url, string Path, long ID) - { - try - { - XmlDocument xmlDocument = new XmlDocument(); - xmlDocument.Load(Path); - - bool found = false; - XmlNode folder = null; - - foreach (XmlNode r in xmlDocument.ChildNodes) - { - - foreach (XmlNode one in r.ChildNodes) - { - if (one.FirstChild.InnerText == Title) found = true; - if (one.FirstChild.InnerText == "Saved by MP") folder = one; - } - } - - if ((!found) && (folder != null)) - { - XmlElement childElement = xmlDocument.CreateElement("Entry"); - - XmlElement sub1 = xmlDocument.CreateElement("Name"); sub1.InnerText = Title; - childElement.AppendChild(sub1); - XmlElement sub2 = xmlDocument.CreateElement("URL"); sub2.InnerText = Url; - childElement.AppendChild(sub2); - XmlElement sub3 = xmlDocument.CreateElement("ID"); sub3.InnerText = ID.ToString(); - childElement.AppendChild(sub3); - XmlElement sub4 = xmlDocument.CreateElement("Visited"); sub4.InnerText = "0"; - childElement.AppendChild(sub4); - XmlElement sub5 = xmlDocument.CreateElement("LastVisited"); sub5.InnerText = "0001-01-01T00:00:00"; - childElement.AppendChild(sub5); - XmlElement sub6 = xmlDocument.CreateElement("Created"); sub6.InnerText = DateTime.UtcNow.ToString("u", null); - childElement.AppendChild(sub6); - XmlElement sub7 = xmlDocument.CreateElement("isFolder"); sub7.InnerText = "false"; - childElement.AppendChild(sub7); - XmlElement sub8 = xmlDocument.CreateElement("isSubFolder"); sub8.InnerText = "true"; - childElement.AppendChild(sub8); - - XmlNode parentNode = xmlDocument.SelectSingleNode("Bookmarks"); - parentNode.InsertAfter(childElement, folder); - - xmlDocument.Save(Path); - return true; - } - - } - catch - { } - return false; - } - } -} \ No newline at end of file Copied: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs (from rev 4675, trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs) =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -0,0 +1,305 @@ +#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.Xml; +using System.IO; +using System.Windows.Forms; +using System.Net; +using MediaPortal.Configuration; + +using System.Drawing; + +namespace BrowseTheWeb +{ + + public class Bookmarks + { + public static string SavedByMp = "Saved by MP"; + public List<BookmarkBase> root; + + #region singleton + private static Bookmarks instance; + + public static Bookmarks Instance + { + get + { + if (instance == null) + instance = new Bookmarks(); + return instance; + } + } + #endregion + + private Bookmarks() + { + root = new List<BookmarkBase>(); + } + + public void Clear() + { + root.Clear(); + } + + private void LoadOldVersion(XmlDocument doc) + { + + try + { + List<BookmarkBase> last = root; + foreach (XmlNode node in doc.DocumentElement.SelectNodes("//Entry")) + { + if (Convert.ToBoolean(node.SelectSingleNode("isFolder").InnerText)) + { + BookmarkFolder bmf = new BookmarkFolder(); + bmf.FromXml(node); + last = bmf.Items; + root.Add(bmf); + } + else + { + BookmarkItem item = new BookmarkItem(); + item.FromXml(node); + if (Convert.ToBoolean(node.SelectSingleNode("isSubFolder").InnerText)) + last.Add(item); + else + root.Add(item); + } + } + + } + catch (Exception e) + { + MyLog.debug("Exception: " + e.ToString()); + } + } + + private void SetParent(List<BookmarkBase> items, BookmarkFolder parent) + { + foreach (BookmarkBase sub in items) + { + BookmarkFolder bmf = sub as BookmarkFolder; + if (bmf != null) + { + bmf.Parent = parent; + SetParent(bmf.Items, bmf); + } + } + + } + + public void LoadFromXml(string fileName) + { + Clear(); + XmlDocument doc = new XmlDocument(); + if (File.Exists(fileName)) + { + doc.Load(fileName); + + if (doc.DocumentElement.SelectSingleNode("//isFolder") != null) + { + LoadOldVersion(doc); + } + else + { + BookmarkFolder dummy = new BookmarkFolder(); + dummy.Items = root; + dummy.FromXml(doc.DocumentElement); + } + + SetParent(root, null); + } + else + { + BookmarkFolder bmf = new BookmarkFolder(); + bmf.Name = SavedByMp; + root.Add(bmf); + } + + } + + public bool SaveToXml(string fileName) + { + try + { + using (XmlTextWriter textWriter = new XmlTextWriter(fileName, null)) + { + textWriter.Formatting = Formatting.Indented; + textWriter.WriteStartDocument(); + textWriter.WriteStartElement("Bookmarks"); + foreach (BookmarkBase item in root) + { + item.ToXml(textWriter); + } + + textWriter.WriteEndElement(); + textWriter.WriteEndDocument(); + } + return true; + } + catch (Exception e) + { + MyLog.debug("Exception: " + e.ToString()); + return false; + } + } + + public bool AddBookmark(string title, string url, string path) + { + BookmarkFolder bmf = root.Find(x => x.Name == SavedByMp && x is BookmarkFolder) as BookmarkFolder; + if (bmf != null) + { + bmf.Items.Add(new BookmarkItem() { Name = title, Url = url }); + return true; + } + return false; + } + + } + + public class Bookmark + { + public static TreeNode FindNode(TreeView Treeview, string Name) + { + foreach (TreeNode t in Treeview.Nodes[0].Nodes) + { + if (Name == t.Text) + return t; + foreach (TreeNode sub in t.Nodes) + { + if (Name == sub.Text) + return sub; + } + } + return null; + } + + public static bool Exists(TreeView treeview, string name) + { + return FindNode(treeview, name) != null; + } + + public static bool isValidUrl(string URL) + { + try + { + Uri urlCheck = new Uri(URL); + WebRequest request = WebRequest.Create(urlCheck); + request.Timeout = 10000; + + WebResponse response; + + response = request.GetResponse(); + } + catch (Exception) + { + return false; //url does not exist + } + return true; + } + + public static void SaveSnap(Bitmap Snap, string Url) + { + try + { + string filename = GetThumbString(Url); + filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + filename; + Snap.Save(filename); + } + catch (Exception e) + { + MyLog.debug("Exception: " + e.ToString()); + } + } + public static Bitmap GetSnap(string Url) + { + Bitmap snap = null; + + try + { + string filename = GetThumbString(Url); + filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + filename; + + if (File.Exists(filename)) + { + snap = (Bitmap)Bitmap.FromFile(filename); + return snap; + } + else + MyLog.debug("Getsnap does not exist"); + + } + catch (Exception e) + { + MyLog.debug("Exception: " + e.ToString()); + } + + return snap; + } + + public static string GetSnapPath(string Url) + { + string filename = GetThumbString(Url); + filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + filename; + + return filename; + } + public static void InitCachePath() + { + if (!Directory.Exists(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb")) + Directory.CreateDirectory(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb"); + + + if (Directory.Exists(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb")) + { + string[] files = Directory.GetFiles(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb", "*.*"); + foreach (string f in files) + { + File.Move(f, Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + Path.GetFileName(f)); + } + } + + } + + 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); + } + + foreach (char c in Path.GetInvalidFileNameChars()) + result = result.Replace(c, '_'); + result = result + ".png"; + return result; + } + } +} Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2013-12-30 20:26:09 UTC (rev 4714) @@ -73,6 +73,7 @@ <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> <Reference Include="System.Web" /> + <Reference Include="System.Web.Extensions" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> <Reference Include="Utils"> @@ -81,8 +82,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Bookmark.cs" /> - <Compile Include="BookmarkElement.cs" /> - <Compile Include="BookmarkXml.cs" /> + <Compile Include="Bookmarks.cs" /> <Compile Include="DomHelper.cs" /> <Compile Include="GetFolder.cs"> <SubType>Form</SubType> @@ -104,24 +104,13 @@ </Compile> <Compile Include="GUIBookmark.cs" /> <Compile Include="GUIPlugin.cs" /> - <Compile Include="ImportIE.cs"> + <Compile Include="ImportBrowser.cs"> <SubType>Form</SubType> </Compile> - <Compile Include="ImportIE.Designer.cs"> - <DependentUpon>ImportIE.cs</DependentUpon> + <Compile Include="ImportBrowser.Designer.cs"> + <DependentUpon>ImportBrowser.cs</DependentUpon> </Compile> - <Compile Include="ImportFF.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="ImportFF.Designer.cs"> - <DependentUpon>ImportFF.cs</DependentUpon> - </Compile> - <Compile Include="ImportChrome.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="ImportChrome.Designer.cs"> - <DependentUpon>ImportChrome.cs</DependentUpon> - </Compile> + <Compile Include="JSONNode.cs" /> <Compile Include="MyLog.cs" /> <Compile Include="OSD_LinkId.cs"> <SubType>UserControl</SubType> @@ -152,6 +141,9 @@ <DependentUpon>GetUrl.cs</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="ImportBrowser.resx"> + <DependentUpon>ImportBrowser.cs</DependentUpon> + </EmbeddedResource> <EmbeddedResource Include="Properties\Resources.resx"> <Generator>ResXFileCodeGenerator</Generator> <LastGenOutput>Resources.Designer.cs</LastGenOutput> @@ -180,17 +172,6 @@ <DependentUpon>GetThumb.cs</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> - <EmbeddedResource Include="ImportIE.resx"> - <DependentUpon>ImportIE.cs</DependentUpon> - </EmbeddedResource> - <EmbeddedResource Include="ImportFF.resx"> - <DependentUpon>ImportFF.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="ImportChrome.resx"> - <DependentUpon>ImportChrome.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> <EmbeddedResource Include="OSD_LinkId.resx"> <DependentUpon>OSD_LinkId.cs</DependentUpon> <SubType>Designer</SubType> Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -23,13 +23,18 @@ #endregion +using System.Collections.Generic; using MediaPortal.GUI.Library; using MediaPortal.Configuration; -using System.Xml; namespace BrowseTheWeb { + public class BtwebGuiListItem : GUIListItem + { + public BookmarkBase bookmark; + } + public class GUIBookmark : GUIWindow { [SkinControlAttribute(50)] @@ -52,15 +57,19 @@ base.GetID = value; } } + public override bool Init() { + MyLog.debug("Init Browse the web bookmarks"); bool result = Load(GUIGraphicsContext.Skin + @"\BrowseTheWebBook.xml"); + Bookmarks.Instance.LoadFromXml(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml"); + return result; } protected override void OnPageLoad() { - LoadFacade(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", ""); + LoadFacade(null); Bookmark.InitCachePath(); base.OnPageLoad(); } @@ -68,15 +77,12 @@ { if (actionType == MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM) { - GUIListItem item = facade.SelectedListItem; + BtwebGuiListItem item = facade.SelectedListItem as BtwebGuiListItem; if (item != null) { if (item.IsFolder) { - if (item.Label == "..") - LoadFacade(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", ""); - else - LoadFacade(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", item.Label); + LoadFacade((BookmarkFolder)item.bookmark); } else { @@ -113,98 +119,49 @@ } } - public void LoadFacade(string Path, string Folder) + public void LoadFacade(BookmarkFolder parent) { facade.CurrentLayout = Settings.Instance.View; facade.Clear(); + if (parent != null) + { + BtwebGuiListItem item = new BtwebGuiListItem(); + item.bookmark = parent.Parent; + item.IsFolder = true; + item.Label = ".."; + item.Path = ".."; + item.IconImage = "defaultFolderBack.png"; + item.IconImageBig = "defaultFolderBackBig.png"; + facade.Add(item); + } - GUIListItem item = new GUIListItem(); + List<BookmarkBase> list = parent == null ? Bookmarks.Instance.root : parent.Items; - try + foreach (BookmarkBase bookmark in list) { - XmlDocument xmlDocument = new XmlDocument(); - xmlDocument.Load(Path); + BtwebGuiListItem item = new BtwebGuiListItem(); + item.IsFolder = bookmark is BookmarkFolder; + item.Label = bookmark.Name; + item.bookmark = bookmark; - if (Folder == string.Empty) + if (item.IsFolder) { - XmlNodeList col = xmlDocument.GetElementsByTagName("Entry"); - foreach (XmlNode node in col) - { - BookmarkElement bkm = BookmarkXml.GetData(node); - - string name = bkm.Name.Replace(" ", "_"); - name = name.Replace(".", "_"); - - if ((bkm.isFolder) || - (!bkm.isFolder) && (!bkm.isSubFolder)) - { - item = new GUIListItem(); - item.IsFolder = bkm.isFolder; - item.Label = bkm.Name; - item.Path = bkm.Url; - if (item.IsFolder) - { - item.IconImage = "defaultFolder.png"; - item.IconImageBig = "defaultFolderBig.png"; - } - else - { - string file = Bookmark.GetSnapPath(bkm.Url); - item.IconImage = file; - item.IconImageBig = file; - } - - facade.Add(item); - } - } + item.IconImage = "defaultFolder.png"; + item.IconImageBig = "defaultFolderBig.png"; } - - if (Folder != string.Empty) + else { - item = new GUIListItem(); - item.IsFolder = true; - item.Label = ".."; - item.Path = ".."; - item.IconImage = "defaultFolderBack.png"; - item.IconImageBig = "defaultFolderBackBig.png"; - facade.Add(item); - - bool found = false; - - XmlNodeList col = xmlDocument.GetElementsByTagName("Entry"); - foreach (XmlNode node in col) - { - BookmarkElement bkm = BookmarkXml.GetData(node); - - if ((bkm.isFolder) || ((!bkm.isSubFolder && !bkm.isFolder))) found = false; - - if (Folder == bkm.Name) - { - found = true; - } - if (found) - { - if (bkm.isSubFolder) - { - item = new GUIListItem(); - item.IsFolder = bkm.isFolder; - item.Label = bkm.Name; - item.Path = bkm.Url; - - string file = Bookmark.GetSnapPath(bkm.Url); - item.IconImage = file; - item.IconImageBig = file; - - facade.Add(item); - } - } - } + item.Path = ((BookmarkItem)bookmark).Url; + string file = Bookmark.GetSnapPath(item.Path); + item.IconImage = file; + item.IconImageBig = file; } - GUIPropertyManager.SetProperty("#itemcount", facade.Count.ToString()); - facade.SelectedListItemIndex = 0; + facade.Add(item); } - catch { } + GUIPropertyManager.SetProperty("#itemcount", facade.Count.ToString()); + facade.SelectedListItemIndex = 0; + } } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -123,7 +123,7 @@ } public void ShowPlugin() { - Setup setup = new Setup(); + Setup.Setup setup = new Setup.Setup(); setup.ShowDialog(); } @@ -164,12 +164,6 @@ public override bool Init() { MyLog.debug("Init Browse the web"); - - BookmarkXml.AddFolder(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + - "\\bookmarks.xml", "Saved by MP"); - - MyLog.debug("Init Browse the web finished"); - return Load(GUIGraphicsContext.Skin + @"\BrowseTheWeb.xml"); } @@ -746,7 +740,7 @@ DialogResult result = ShowKeyboard(ref title, false); if (result == DialogResult.OK) { - bool hasSaved = BookmarkXml.AddBookmark(title, actualUrl, Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", 0); + bool hasSaved = Bookmarks.Instance.AddBookmark(title, actualUrl, Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml"); if (hasSaved) { ShowAlert("Bookmark has been saved !", "Title : " + title, "URL : " + actualUrl, ""); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -25,7 +25,7 @@ using System; using System.Windows.Forms; -namespace BrowseTheWeb +namespace BrowseTheWeb.Setup { public partial class GetFolder : Form { Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.designer.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetFolder.designer.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -1,4 +1,4 @@ -namespace BrowseTheWeb +namespace BrowseTheWeb.Setup { partial class GetFolder { @@ -90,7 +90,7 @@ this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Inpu folder name"; + this.Text = "Input folder name"; this.Load += new System.EventHandler(this.GetFolder_Load); this.ResumeLayout(false); this.PerformLayout(); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.Designer.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.Designer.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -1,4 +1,4 @@ -namespace BrowseTheWeb +namespace BrowseTheWeb.Setup { partial class GetThumb { Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -29,7 +29,7 @@ using Gecko; using Gecko.Utils; -namespace BrowseTheWeb +namespace BrowseTheWeb.Setup { public partial class GetThumb : Form { Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -25,7 +25,7 @@ using System; using System.Windows.Forms; -namespace BrowseTheWeb +namespace BrowseTheWeb.Setup { public partial class GetUrl : Form { Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.designer.cs 2013-12-29 11:01:21 UTC (rev 4713) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetUrl.designer.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -1,4 +1,4 @@ -namespace BrowseTheWeb +namespace BrowseTheWeb.Setup { partial class GetUrl { Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.Designer.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.Designer.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -0,0 +1,156 @@ +namespace BrowseTheWeb.Setup +{ + partial class ImportBrowser + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.btnImport = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.btnCancel = new System.Windows.Forms.Button(); + this.prgState = new System.Windows.Forms.ProgressBar(); + this.chkThumbs = new System.Windows.Forms.CheckBox(); + this.treeView1 = new System.Windows.Forms.TreeView(); + this.buttonSelAll = new System.Windows.Forms.Button(); + this.buttonDeselAll = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // btnImport + // + this.btnImport.Location = new System.Drawing.Point(12, 341); + this.btnImport.Name = "btnImport"; + this.btnImport.Size = new System.Drawing.Size(139, 31); + this.btnImport.TabIndex = 1; + this.btnImport.Text = "Import"; + this.btnImport.UseVisualStyleBackColor = true; + this.btnImport.Click += new System.EventHandler(this.btnImport_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(135, 13); + this.label1.TabIndex = 2; + this.label1.Text = "Select bookmarks to import"; + // + // btnCancel + // + this.btnCancel.Location = new System.Drawing.Point(375, 341); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(139, 31); + this.btnCancel.TabIndex = 4; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // prgState + // + this.prgState.Location = new System.Drawing.Point(12, 302); + this.prgState.Name = "prgState"; + this.prgState.Size = new System.Drawing.Size(502, 23); + this.prgState.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + this.prgState.TabIndex = 5; + this.prgState.Visible = false; + // + // chkThumbs + // + this.chkThumbs.AutoSize = true; + this.chkThumbs.Location = new System.Drawing.Point(187, 270); + this.chkThumbs.Name = "chkThumbs"; + this.chkThumbs.Size = new System.Drawing.Size(164, 17); + this.chkThumbs.TabIndex = 6; + this.chkThumbs.Text = "make thumbs (take long time)"; + this.chkThumbs.UseVisualStyleBackColor = true; + // + // treeView1 + // + this.treeView1.CheckBoxes = true; + this.treeView1.Location = new System.Drawing.Point(12, 35); + this.treeView1.Name = "treeView1"; + this.treeView1.Size = new System.Drawing.Size(502, 225); + this.treeView1.TabIndex = 7; + this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck); + // + // buttonSelAll + // + this.buttonSelAll.Location = new System.Drawing.Point(15, 264); + this.buttonSelAll.Name = "buttonSelAll"; + this.buttonSelAll.Size = new System.Drawing.Size(60, 23); + this.buttonSelAll.TabIndex = 8; + this.buttonSelAll.Text = "Select all"; + this.buttonSelAll.UseVisualStyleBackColor = true; + this.buttonSelAll.Click += new System.EventHandler(this.buttonSelAll_Click); + // + // buttonDeselAll + // + this.buttonDeselAll.Location = new System.Drawing.Point(81, 264); + this.buttonDeselAll.Name = "buttonDeselAll"; + this.buttonDeselAll.Size = new System.Drawing.Size(70, 23); + this.buttonDeselAll.TabIndex = 9; + this.buttonDeselAll.Text = "Deselect all"; + this.buttonDeselAll.UseVisualStyleBackColor = true; + this.buttonDeselAll.Click += new System.EventHandler(this.buttonDeselAll_Click); + // + // ImportBrowser + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(526, 384); + this.Controls.Add(this.buttonDeselAll); + this.Controls.Add(this.buttonSelAll); + this.Controls.Add(this.treeView1); + this.Controls.Add(this.chkThumbs); + this.Controls.Add(this.prgState); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.label1); + this.Controls.Add(this.btnImport); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ImportBrowser"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Import Browser"; + this.Load += new System.EventHandler(this.ImportBase_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button btnImport; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.ProgressBar prgState; + private System.Windows.Forms.CheckBox chkThumbs; + private System.Windows.Forms.TreeView treeView1; + private System.Windows.Forms.Button buttonSelAll; + private System.Windows.Forms.Button buttonDeselAll; + } +} \ No newline at end of file Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.cs 2013-12-30 20:26:09 UTC (rev 4714) @@ -0,0 +1,313 @@ +#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.Windows.Forms; +using System.IO; + +using SQLite.NET; + +namespace BrowseTheWeb.Setup +{ + public partial class ImportBrowser : Form + { + private TreeNode importRootNode; + private BrowserType browserType; + + public enum BrowserType { IE, FireFox, Chrome }; + + public ImportBrowser(TreeNode importRootNode, ImageList imageList, BrowserType browserType) + { + InitializeComponent(); + this.importRootNode = importRootNode; + this.browserType = browserType; + treeView1.ImageList = imageList; + } + + ... [truncated message content] |
From: <dos...@us...> - 2014-02-16 11:46:11
|
Revision: 4759 http://sourceforge.net/p/mp-plugins/code/4759 Author: doskabouter Date: 2014-02-16 11:46:08 +0000 (Sun, 16 Feb 2014) Log Message: ----------- Fixed typo, enabled adding bookmarks in, and moving bookmarks to the root of the bookmarklist Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-01-25 20:42:00 UTC (rev 4758) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-02-16 11:46:08 UTC (rev 4759) @@ -763,7 +763,7 @@ } else - ShowAlert("Bookmark could not been saved !", "Title : " + title, "URL : " + actualUrl, ""); + ShowAlert("Bookmark could not be saved !", "Title : " + title, "URL : " + actualUrl, ""); } webBrowser.Visible = true; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2014-01-25 20:42:00 UTC (rev 4758) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2014-02-16 11:46:08 UTC (rev 4759) @@ -287,18 +287,21 @@ } #endregion - if (targetNode.Tag is BookmarkFolder) + if (targetNode != null) { - sourceNode.Remove(); - targetNode.Nodes.Insert(0, sourceNode); - } - else - { - if (targetNode.Parent != null) + if (targetNode.Tag is BookmarkFolder) { sourceNode.Remove(); - targetNode.Parent.Nodes.Insert(targetNode.Index, sourceNode); + targetNode.Nodes.Insert(0, sourceNode); } + else + { + sourceNode.Remove(); + if (targetNode.Parent != null) + targetNode.Parent.Nodes.Insert(targetNode.Index, sourceNode); + else + targetNode.Nodes.Insert(targetNode.Index, sourceNode); + } } } @@ -360,8 +363,14 @@ thumb.ShowDialog(); } - TreeNode newNode = node.Tag is BookmarkFolder ? node.Nodes.Add(get.SelectedName) : - node.Parent.Nodes.Insert(node.Index + 1, get.SelectedName); + TreeNode newNode; + if (node.Parent == null)//root node "Bookmarks" + newNode = node.Nodes.Insert(node.Index + 1, get.SelectedName); + else + if (node.Tag is BookmarkFolder) + newNode = node.Nodes.Add(get.SelectedName); + else + newNode = node.Parent.Nodes.Insert(node.Index + 1, get.SelectedName); newNode.ImageIndex = 1; newNode.SelectedImageIndex = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2014-04-01 20:04:59
|
Revision: 4777 http://sourceforge.net/p/mp-plugins/code/4777 Author: doskabouter Date: 2014-04-01 20:04:56 +0000 (Tue, 01 Apr 2014) Log Message: ----------- Refactor Bookmarks.Instance.root to BookmarkFolder Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-03-27 16:17:25 UTC (rev 4776) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-04-01 20:04:56 UTC (rev 4777) @@ -23,7 +23,6 @@ #endregion using System; -using System.Collections.Generic; using System.Xml; using System.IO; using System.Windows.Forms; @@ -38,7 +37,7 @@ public class Bookmarks { public static string SavedByMp = "Saved by MP"; - public List<BookmarkBase> root; + public BookmarkFolder root; #region singleton private static Bookmarks instance; @@ -56,12 +55,13 @@ private Bookmarks() { - root = new List<BookmarkBase>(); + root = new BookmarkFolder(); + root.Parent = null; } public void Clear() { - root.Clear(); + root.Items.Clear(); } private void LoadOldVersion(XmlDocument doc) @@ -69,24 +69,24 @@ try { - List<BookmarkBase> last = root; + BookmarkFolder last = root; foreach (XmlNode node in doc.DocumentElement.SelectNodes("//Entry")) { if (Convert.ToBoolean(node.SelectSingleNode("isFolder").InnerText)) { BookmarkFolder bmf = new BookmarkFolder(); bmf.FromXml(node); - last = bmf.Items; - root.Add(bmf); + last = bmf; + root.Items.Add(bmf); } else { BookmarkItem item = new BookmarkItem(); item.FromXml(node); if (Convert.ToBoolean(node.SelectSingleNode("isSubFolder").InnerText)) - last.Add(item); + last.Items.Add(item); else - root.Add(item); + root.Items.Add(item); } } @@ -97,15 +97,15 @@ } } - private void SetParent(List<BookmarkBase> items, BookmarkFolder parent) + private void SetParent(BookmarkFolder item) { - foreach (BookmarkBase sub in items) + foreach (BookmarkBase sub in item.Items) { BookmarkFolder bmf = sub as BookmarkFolder; if (bmf != null) { - bmf.Parent = parent; - SetParent(bmf.Items, bmf); + bmf.Parent = item; + SetParent(bmf); } } @@ -126,18 +126,16 @@ } else { - BookmarkFolder dummy = new BookmarkFolder(); - dummy.Items = root; - dummy.FromXml(doc.DocumentElement); + root.FromXml(doc.DocumentElement); } - SetParent(root, null); + SetParent(root); } else { BookmarkFolder bmf = new BookmarkFolder(); bmf.Name = SavedByMp; - root.Add(bmf); + root.Items.Add(bmf); } } @@ -151,7 +149,7 @@ textWriter.Formatting = Formatting.Indented; textWriter.WriteStartDocument(); textWriter.WriteStartElement("Bookmarks"); - foreach (BookmarkBase item in root) + foreach (BookmarkBase item in root.Items) { item.ToXml(textWriter); } @@ -170,7 +168,7 @@ public bool AddBookmark(string title, string url, string path) { - BookmarkFolder bmf = root.Find(x => x.Name == SavedByMp && x is BookmarkFolder) as BookmarkFolder; + BookmarkFolder bmf = root.Items.Find(x => x.Name == SavedByMp && x is BookmarkFolder) as BookmarkFolder; if (bmf != null) { bmf.Items.Add(new BookmarkItem() { Name = title, Url = url }); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2014-03-27 16:17:25 UTC (rev 4776) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2014-04-01 20:04:56 UTC (rev 4777) @@ -23,7 +23,6 @@ #endregion -using System.Collections.Generic; using MediaPortal.GUI.Library; using MediaPortal.Configuration; @@ -135,9 +134,9 @@ facade.Add(item); } - List<BookmarkBase> list = parent == null ? Bookmarks.Instance.root : parent.Items; + BookmarkFolder bmf = parent == null ? Bookmarks.Instance.root : parent; - foreach (BookmarkBase bookmark in list) + foreach (BookmarkBase bookmark in bmf.Items) { BtwebGuiListItem item = new BtwebGuiListItem(); item.IsFolder = bookmark is BookmarkFolder; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.cs 2014-03-27 16:17:25 UTC (rev 4776) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportBrowser.cs 2014-04-01 20:04:56 UTC (rev 4777) @@ -195,8 +195,8 @@ MyLog.debug("open database"); SQLiteClient client = new SQLiteClient(path); - List<BookmarkBase> dummy = new List<BookmarkBase>(); - ImportFFFolder(client, "2", dummy); + BookmarkFolder dummy = new BookmarkFolder(); + ImportFFFolder(client, "2", dummy.Items); Setup.FillTreeview(dummy, treeView1.Nodes); MyLog.debug("close database"); client.Close(); @@ -250,11 +250,11 @@ private void ImportIE() { - List<BookmarkBase> dummy = new List<BookmarkBase>(); + BookmarkFolder dummy = new BookmarkFolder(); string favPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); if (Directory.Exists(favPath)) { - ImportIEFolder(favPath, dummy); + ImportIEFolder(favPath, dummy.Items); Setup.FillTreeview(dummy, treeView1.Nodes); } else @@ -299,8 +299,8 @@ string s = File.ReadAllText(path); JSONNode node = JSONNode.LoadJSON(s); List<JSONNode> res = node.GetNodes("roots/bookmark_bar/children", null); - List<BookmarkBase> dummy = new List<BookmarkBase>(); - ImportChromeFolder(res, dummy); + BookmarkFolder dummy = new BookmarkFolder(); + ImportChromeFolder(res, dummy.Items); Setup.FillTreeview(dummy, treeView1.Nodes); } else Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2014-03-27 16:17:25 UTC (rev 4776) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2014-04-01 20:04:56 UTC (rev 4777) @@ -70,9 +70,9 @@ } - public static void FillTreeview(List<BookmarkBase> bookmarks, TreeNodeCollection nodes) + public static void FillTreeview(BookmarkFolder bmf, TreeNodeCollection nodes) { - foreach (BookmarkBase item in bookmarks) + foreach (BookmarkBase item in bmf.Items) { TreeNode newNode = nodes.Add(item.Name); newNode.Tag = item; @@ -80,7 +80,7 @@ { newNode.ImageIndex = 1; newNode.SelectedImageIndex = 1; - FillTreeview(((BookmarkFolder)item).Items, newNode.Nodes); + FillTreeview((BookmarkFolder)item, newNode.Nodes); } } } @@ -95,18 +95,18 @@ treeview.Invalidate(); } - private void FillBookmarks(TreeNodeCollection nodes, List<BookmarkBase> bms) + private void FillBookmarks(TreeNodeCollection nodes, BookmarkFolder bms) { foreach (TreeNode node in nodes) { BookmarkBase bkm = (BookmarkBase)node.Tag; - bms.Add(bkm); + bms.Items.Add(bkm); BookmarkFolder bmf = node.Tag as BookmarkFolder; if (bmf != null) { bmf.Items.Clear(); - FillBookmarks(node.Nodes, bmf.Items); + FillBookmarks(node.Nodes, bmf); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2014-04-02 20:27:55
|
Revision: 4779 http://sourceforge.net/p/mp-plugins/code/4779 Author: doskabouter Date: 2014-04-02 20:27:51 +0000 (Wed, 02 Apr 2014) Log Message: ----------- Refactor Bookmarks.cs Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-04-01 20:13:04 UTC (rev 4778) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-04-02 20:27:51 UTC (rev 4779) @@ -31,6 +31,9 @@ using System.Drawing; +using Gecko; +using Gecko.Utils; + namespace BrowseTheWeb { @@ -181,6 +184,8 @@ public class Bookmark { + private static string ThumbDir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb"; + public static TreeNode FindNode(TreeView Treeview, string Name) { foreach (TreeNode t in Treeview.Nodes[0].Nodes) @@ -224,8 +229,7 @@ { try { - string filename = GetThumbString(Url); - filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + filename; + string filename = GetSnapPath(Url); Snap.Save(filename); } catch (Exception e) @@ -233,22 +237,20 @@ MyLog.debug("Exception: " + e.ToString()); } } + public static Bitmap GetSnap(string Url) { - Bitmap snap = null; try { - string filename = GetThumbString(Url); - filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + filename; + string filename = GetSnapPath(Url); if (File.Exists(filename)) { - snap = (Bitmap)Bitmap.FromFile(filename); - return snap; + return (Bitmap)Bitmap.FromFile(filename); } else - MyLog.debug("Getsnap does not exist"); + MyLog.debug("Getsnap " + filename + " does not exist"); } catch (Exception e) @@ -256,31 +258,19 @@ MyLog.debug("Exception: " + e.ToString()); } - return snap; + return null; } public static string GetSnapPath(string Url) { string filename = GetThumbString(Url); - filename = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + filename; + return Path.Combine(ThumbDir, filename); + } - return filename; - } public static void InitCachePath() { - if (!Directory.Exists(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb")) - Directory.CreateDirectory(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb"); - - - if (Directory.Exists(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb")) - { - string[] files = Directory.GetFiles(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb", "*.*"); - foreach (string f in files) - { - File.Move(f, Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb\\" + Path.GetFileName(f)); - } - } - + if (!Directory.Exists(ThumbDir)) + Directory.CreateDirectory(ThumbDir); } private static string GetThumbString(string Name) @@ -300,5 +290,22 @@ result = result + ".png"; return result; } + + public static bool GetAndSaveSnap(GeckoWebBrowser browser) + { + if (browser.Url.ToString() != "about:blank") + { + Bitmap snap = browser.GetBitmap((uint)browser.Width, (uint)browser.Height); + + 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, browser.Url.ToString()); + return true; + } + return false; + } } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2014-04-01 20:13:04 UTC (rev 4778) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2014-04-02 20:27:51 UTC (rev 4779) @@ -27,7 +27,6 @@ using System.Windows.Forms; using Gecko; -using Gecko.Utils; namespace BrowseTheWeb.Setup { @@ -62,16 +61,8 @@ private void browser_DocumentCompleted(object sender, EventArgs e) { - if (browser.Url.ToString() != "about:blank") + if (Bookmark.GetAndSaveSnap(browser)) { - Bitmap snap = browser.GetBitmap((uint)browser.Width, (uint)browser.Height); - - 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, SelectedUrl); received = true; chkGetThumb.Checked = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2014-04-02 21:05:38
|
Revision: 4781 http://sourceforge.net/p/mp-plugins/code/4781 Author: doskabouter Date: 2014-04-02 21:05:35 +0000 (Wed, 02 Apr 2014) Log Message: ----------- Refactor Bookmarks.cs Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-04-02 20:30:44 UTC (rev 4780) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-04-02 21:05:35 UTC (rev 4781) @@ -292,7 +292,7 @@ return result; } - public static bool GetAndSaveSnap(GeckoWebBrowser browser) + public static bool GetAndSaveSnap(GeckoWebBrowser browser, string url) { if (browser.Url.ToString() != "about:blank") { @@ -303,7 +303,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, browser.Url.ToString()); + Bookmark.SaveSnap(snap, url); return true; } return false; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2014-04-02 20:30:44 UTC (rev 4780) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GetThumb.cs 2014-04-02 21:05:35 UTC (rev 4781) @@ -61,7 +61,7 @@ private void browser_DocumentCompleted(object sender, EventArgs e) { - if (Bookmark.GetAndSaveSnap(browser)) + if (Bookmark.GetAndSaveSnap(browser, SelectedUrl)) { received = true; chkGetThumb.Checked = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2014-04-02 21:07:09
|
Revision: 4782 http://sourceforge.net/p/mp-plugins/code/4782 Author: doskabouter Date: 2014-04-02 21:07:03 +0000 (Wed, 02 Apr 2014) Log Message: ----------- Fixed bug: thumbs were not created when bookmark was added in mediaportal Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-04-02 21:05:35 UTC (rev 4781) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-04-02 21:07:03 UTC (rev 4782) @@ -226,7 +226,7 @@ return true; } - public static void SaveSnap(Bitmap Snap, string Url) + private static void SaveSnap(Bitmap Snap, string Url) { try { Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-04-02 21:05:35 UTC (rev 4781) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-04-02 21:07:03 UTC (rev 4782) @@ -738,29 +738,7 @@ 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 - + Bookmark.GetAndSaveSnap(webBrowser, actualUrl); } else ShowAlert("Bookmark could not be saved !", "Title : " + title, "URL : " + actualUrl, ""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2014-09-26 21:02:56
|
Revision: 4884 http://sourceforge.net/p/mp-plugins/code/4884 Author: doskabouter Date: 2014-09-26 21:02:46 +0000 (Fri, 26 Sep 2014) Log Message: ----------- Added option for previous and next pages Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/DomHelper.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -39,10 +39,17 @@ private const string btwebId = "btweb_id"; - public static void AddLinksToPage(GeckoDocument document) + private static string previousUrl; + private static string nextUrl; + + public static Tuple<string, string> AddLinksToPage(GeckoDocument document, Settings settings) { + previousUrl = null; + nextUrl = null; + int maxId = GetMaxId(document); - AddLinksToPage(document, maxId + 1); + AddLinksToPage(document, maxId + 1, settings); + return new Tuple<string, string>(previousUrl, nextUrl); } public static GeckoHtmlElement GetElement(string linkId, GeckoDocument document) @@ -96,8 +103,16 @@ return new Point(0, 0); } - private static int AddLinksToPage(GeckoDocument document, int id) + private static void Check(GeckoAnchorElement element, string[] tags, ref string url) { + if (String.IsNullOrEmpty(url)) + foreach (string tag in tags) + if (element.TextContent.ToUpperInvariant().Contains(tag.ToUpperInvariant())) + url = element.Href; + } + + private static int AddLinksToPage(GeckoDocument document, int id, Settings settings) + { Dictionary<string, int> hrefs = new Dictionary<string, int>(); GeckoElementCollection links = document.Links; MyLog.debug("page links cnt : " + links.Count<GeckoHtmlElement>()); @@ -131,6 +146,12 @@ newId = id++; hrefs.Add(url, newId); } + + if (!String.IsNullOrEmpty(url) && element is GeckoAnchorElement) + { + Check((GeckoAnchorElement)element, settings.PreviousTags, ref previousUrl); + Check((GeckoAnchorElement)element, settings.NextTags, ref nextUrl); + } } else newId = id++; @@ -264,7 +285,7 @@ GeckoElementCollection iframes = document.GetElementsByTagName("iframe"); MyLog.debug("page iframes cnt : " + iframes.Count<GeckoHtmlElement>()); foreach (GeckoIFrameElement element in iframes) - id = AddLinksToPage(element.ContentDocument, id); + id = AddLinksToPage(element.ContentDocument, id, settings); return id; } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -81,6 +81,8 @@ private bool clickFromPlugin = false; private bool aeroDisabled = false; + private Tuple<string, string> prevNextUrls; + #region Constants public const int PluginWindowId = 54537689; #endregion @@ -659,6 +661,19 @@ return; #endregion } + + if (prevNextUrls != null) + switch (action.wID) + { + case Action.ActionType.ACTION_PREV_CHAPTER: + if (!String.IsNullOrEmpty(prevNextUrls.Item1)) + webBrowser.Navigate(prevNextUrls.Item1); + return; + case Action.ActionType.ACTION_NEXT_CHAPTER: + if (!String.IsNullOrEmpty(prevNextUrls.Item2)) + webBrowser.Navigate(prevNextUrls.Item2); + return; + } base.OnAction(action); } @@ -893,7 +908,7 @@ #endregion if (!settings.UseMouse) - DomHelper.AddLinksToPage(webBrowser.Document); + prevNextUrls = DomHelper.AddLinksToPage(webBrowser.Document, settings); #region reset zoom if (settings.ZoomPage) Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -52,6 +52,8 @@ public GUIFacadeControl.Layout View { get; set; } public string UserAgent { get; set; } + public string[] PreviousTags; + public string[] NextTags; private const string section = "btWeb"; #region Singleton @@ -73,6 +75,16 @@ Path.Combine("Windows", "xulrunner")); } + public static string TagsToString(string[] tags) + { + return String.Join(";", tags); + } + + public static string[] StringToTags(string tags) + { + return tags.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + } + private void LoadFromXml() { string dir = Config.GetFolder(Config.Dir.Config); @@ -110,6 +122,9 @@ LastUrl = xmlreader.GetValueAsString(section, "lastUrl", string.Empty); UserAgent = xmlreader.GetValueAsString(section, "useragent", string.Empty); + PreviousTags = StringToTags(xmlreader.GetValueAsString(section, "previousTags", string.Empty)); + NextTags = StringToTags(xmlreader.GetValueAsString(section, "nextTags", string.Empty)); + UseProxy = xmlreader.GetValueAsBool(section, "proxy", false); Server = xmlreader.GetValueAsString(section, "proxy_server", "127.0.0.1"); Port = xmlreader.GetValueAsInt(section, "proxy_port", 8888); @@ -174,6 +189,9 @@ xmlwriter.SetValue(section, "bookmark", View); xmlwriter.SetValue(section, "useragent", UserAgent); + xmlwriter.SetValue(section, "previousTags", TagsToString(PreviousTags)); + xmlwriter.SetValue(section, "nextTags", TagsToString(NextTags)); + xmlwriter.SetValueAsBool(section, "proxy", UseProxy); xmlwriter.SetValue(section, "proxy_server", Server); xmlwriter.SetValue(section, "proxy_port", Port); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -131,6 +131,11 @@ this.label1 = new System.Windows.Forms.Label(); this.cmbConfirmLink = new System.Windows.Forms.ComboBox(); this.chkRemote = new System.Windows.Forms.CheckBox(); + this.tabPage6 = new System.Windows.Forms.TabPage(); + this.textBoxNext = new System.Windows.Forms.TextBox(); + this.label39 = new System.Windows.Forms.Label(); + this.textBoxPrevious = new System.Windows.Forms.TextBox(); + this.label38 = new System.Windows.Forms.Label(); this.label15 = new System.Windows.Forms.Label(); this.label16 = new System.Windows.Forms.Label(); this.label17 = new System.Windows.Forms.Label(); @@ -142,6 +147,7 @@ this.label22 = new System.Windows.Forms.Label(); this.comboBox4 = new System.Windows.Forms.ComboBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.contextMenuStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -1300,6 +1306,58 @@ this.chkRemote.Text = "Show diagnose on status bar"; this.chkRemote.UseVisualStyleBackColor = true; // + // tabPage6 + // + this.tabPage6.Controls.Add(this.textBoxNext); + this.tabPage6.Controls.Add(this.label39); + this.tabPage6.Controls.Add(this.textBoxPrevious); + this.tabPage6.Controls.Add(this.label38); + this.tabPage6.Location = new System.Drawing.Point(4, 25); + this.tabPage6.Name = "tabPage6"; + this.tabPage6.Padding = new System.Windows.Forms.Padding(3); + this.tabPage6.Size = new System.Drawing.Size(562, 476); + this.tabPage6.TabIndex = 5; + this.tabPage6.Text = "Prev/Next"; + this.tabPage6.UseVisualStyleBackColor = true; + // + // textBoxNext + // + this.textBoxNext.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxNext.Location = new System.Drawing.Point(9, 91); + this.textBoxNext.Name = "textBoxNext"; + this.textBoxNext.Size = new System.Drawing.Size(547, 22); + this.textBoxNext.TabIndex = 3; + this.toolTip1.SetToolTip(this.textBoxNext, "Values must be separated by \";\""); + // + // label39 + // + this.label39.AutoSize = true; + this.label39.Location = new System.Drawing.Point(6, 72); + this.label39.Name = "label39"; + this.label39.Size = new System.Drawing.Size(64, 16); + this.label39.TabIndex = 2; + this.label39.Text = "Next tags"; + // + // textBoxPrevious + // + this.textBoxPrevious.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxPrevious.Location = new System.Drawing.Point(9, 33); + this.textBoxPrevious.Name = "textBoxPrevious"; + this.textBoxPrevious.Size = new System.Drawing.Size(547, 22); + this.textBoxPrevious.TabIndex = 1; + this.toolTip1.SetToolTip(this.textBoxPrevious, "Values must be separated by \";\""); + // + // label38 + // + this.label38.AutoSize = true; + this.label38.Location = new System.Drawing.Point(6, 14); + this.label38.Name = "label38"; + this.label38.Size = new System.Drawing.Size(90, 16); + this.label38.TabIndex = 0; + this.label38.Text = "Previous tags"; + // // label15 // this.label15.AutoSize = true; @@ -1452,6 +1510,8 @@ this.groupBox10.PerformLayout(); this.groupBox9.ResumeLayout(false); this.groupBox9.PerformLayout(); + this.tabPage6.ResumeLayout(false); + this.tabPage6.PerformLayout(); this.ResumeLayout(false); } @@ -1570,5 +1630,11 @@ private System.Windows.Forms.ComboBox cmbUserAgent; private System.Windows.Forms.CheckBox cbOverrideUserAgent; private System.Windows.Forms.CheckBox chkDisableAero; + private System.Windows.Forms.TabPage tabPage6; + private System.Windows.Forms.TextBox textBoxNext; + private System.Windows.Forms.Label label39; + private System.Windows.Forms.TextBox textBoxPrevious; + private System.Windows.Forms.Label label38; + private System.Windows.Forms.ToolTip toolTip1; } } \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2014-09-26 21:02:46 UTC (rev 4884) @@ -502,6 +502,9 @@ cmbUserAgent.Text = settings.UserAgent; cbOverrideUserAgent.Checked = !String.IsNullOrEmpty(cmbUserAgent.Text); + textBoxPrevious.Text = Settings.TagsToString(settings.PreviousTags); + textBoxNext.Text = Settings.TagsToString(settings.NextTags); + chkProxy.Checked = settings.UseProxy; txtHttpServer.Text = settings.Server; txtHttpPort.Text = settings.Port.ToString(); @@ -543,6 +546,9 @@ else settings.UserAgent = String.Empty; + settings.PreviousTags = Settings.StringToTags(textBoxPrevious.Text); + settings.NextTags = Settings.StringToTags(textBoxNext.Text); + settings.UseProxy = chkProxy.Checked; settings.Server = txtHttpServer.Text; settings.Port = Int32.Parse(txtHttpPort.Text); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2014-09-26 20:57:52 UTC (rev 4883) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2014-09-26 21:02:46 UTC (rev 4884) @@ -112,12 +112,12 @@ <value>2.0</value> </resheader> <resheader name="reader"> - <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> - <metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>180, 22</value> </metadata> <data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64"> @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABM - CgAAAk1TRnQBSQFMAgEBAwEAAUgBAQFIAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CgAAAk1TRnQBSQFMAgEBAwEAAVgBAQFYAQEBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -172,10 +172,16 @@ Cw== </value> </data> - <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>26, 16</value> </metadata> - <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>285, 22</value> + </metadata> + <metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>285, 22</value> + </metadata> + <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>46</value> </metadata> </root> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2014-10-05 20:59:16
|
Revision: 4888 http://sourceforge.net/p/mp-plugins/code/4888 Author: doskabouter Date: 2014-10-05 20:59:12 +0000 (Sun, 05 Oct 2014) Log Message: ----------- Fixed bug: Bookmarks added in Mediaportal were not saved Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/MyLog.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-10-01 20:47:49 UTC (rev 4887) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2014-10-05 20:59:12 UTC (rev 4888) @@ -391,6 +391,9 @@ } } settings.SaveToXml(false); + bool result = Bookmarks.Instance.SaveToXml(Config.GetFolder(Config.Dir.Config) + "\\bookmarks.xml"); + if (!result) + MyLog.error("Bookmarks could not be saved !"); webBrowser.Visible = false; GUIGraphicsContext.form.Focus(); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/MyLog.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/MyLog.cs 2014-10-01 20:47:49 UTC (rev 4887) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/MyLog.cs 2014-10-05 20:59:12 UTC (rev 4888) @@ -36,6 +36,11 @@ { Log.Debug("BrowseTheWeb | " + str, new object[0]); } + + public static void error(string str) + { + Log.Error("BrowseTheWeb | " + str, new object[0]); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2014-12-22 20:16:34
|
Revision: 4900 http://sourceforge.net/p/mp-plugins/code/4900 Author: doskabouter Date: 2014-12-22 20:16:00 +0000 (Mon, 22 Dec 2014) Log Message: ----------- Refactoring Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj Added Paths: ----------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/VersionSpecific.cs Removed Paths: ------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/MyLog.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-12-21 20:41:16 UTC (rev 4899) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmarks.cs 2014-12-22 20:16:00 UTC (rev 4900) @@ -27,7 +27,6 @@ using System.IO; using System.Windows.Forms; using System.Net; -using MediaPortal.Configuration; using System.Drawing; @@ -185,7 +184,7 @@ public class Bookmark { - private static string ThumbDir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb"; + private static string ThumbDir = VersionSpecific.ThumbDir; public static TreeNode FindNode(TreeView Treeview, string Name) { @@ -226,7 +225,7 @@ return true; } - private static void SaveSnap(Bitmap Snap, string Url) + private static void SaveSnap(Image Snap, string Url) { try { @@ -241,7 +240,6 @@ public static Bitmap GetSnap(string Url) { - try { string filename = GetSnapPath(Url); @@ -296,14 +294,17 @@ { if (browser.Url.ToString() != "about:blank") { - Bitmap snap = browser.GetBitmap((uint)browser.Width, (uint)browser.Height); - - 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, url); + using (Bitmap snap = browser.GetBitmap((uint)browser.Width, (uint)browser.Height)) + { + using (Image newImage = VersionSpecific.Resize(snap)) + { + using (Graphics g = Graphics.FromImage(newImage)) + { + g.DrawRectangle(new Pen(Color.Black, 2), new Rectangle(1, 1, newImage.Width - 2, newImage.Height - 2)); + } + Bookmark.SaveSnap(newImage, url); + } + } return true; } return false; Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2014-12-21 20:41:16 UTC (rev 4899) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2014-12-22 20:16:00 UTC (rev 4900) @@ -131,7 +131,6 @@ <DependentUpon>ImportBrowser.cs</DependentUpon> </Compile> <Compile Include="JSONNode.cs" /> - <Compile Include="MyLog.cs" /> <Compile Include="OSD_LinkId.cs"> <SubType>UserControl</SubType> </Compile> @@ -151,6 +150,7 @@ <Compile Include="Setup.Designer.cs"> <DependentUpon>Setup.cs</DependentUpon> </Compile> + <Compile Include="VersionSpecific.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="GetFolder.resx"> Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/MyLog.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/MyLog.cs 2014-12-21 20:41:16 UTC (rev 4899) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/MyLog.cs 2014-12-22 20:16:00 UTC (rev 4900) @@ -1,46 +0,0 @@ -#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 MediaPortal.GUI.Library; - -namespace BrowseTheWeb -{ - /// <summary> - /// just some log if needed - /// </summary> - public static class MyLog - { - public static void debug(string str) - { - Log.Debug("BrowseTheWeb | " + str, new object[0]); - } - - public static void error(string str) - { - Log.Error("BrowseTheWeb | " + str, new object[0]); - } - } -} - Copied: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/VersionSpecific.cs (from rev 4888, trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/MyLog.cs) =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/VersionSpecific.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/VersionSpecific.cs 2014-12-22 20:16:00 UTC (rev 4900) @@ -0,0 +1,59 @@ +#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.Drawing; +using MediaPortal.Configuration; +using MediaPortal.GUI.Library; + +namespace BrowseTheWeb +{ + /// <summary> + /// just some log if needed + /// </summary> + public static class MyLog + { + public static void debug(string str) + { + Log.Debug("BrowseTheWeb | " + str, new object[0]); + } + + public static void error(string str) + { + Log.Error("BrowseTheWeb | " + str, new object[0]); + } + } + + public static class VersionSpecific + { + public static string ThumbDir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Thumbs) + "\\BrowseTheWeb"; + + public static Image Resize(Bitmap image) + { + return MediaPortal.Util.BitmapResize.Resize(ref image, 300, 400, false, true); + } + + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |