From: <kro...@us...> - 2010-11-13 16:23:03
|
Revision: 3929 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3929&view=rev Author: kroko_koenig Date: 2010-11-13 16:22:50 +0000 (Sat, 13 Nov 2010) Log Message: ----------- adding import (not finshed), bug fixes Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/todo.txt trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.suo trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.suo Added Paths: ----------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.resx trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/SqlLite.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/res/icon-48x48-mouse.png Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs 2010-11-12 08:40:45 UTC (rev 3928) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Bookmark.cs 2010-11-13 16:22:50 UTC (rev 3929) @@ -143,7 +143,7 @@ catch { } } - public static void AddSavedFolder(string Path) + public static void AddFolder(string Path, string FolderName) { if (!File.Exists(Path)) { @@ -163,7 +163,7 @@ { foreach (XmlNode one in r.ChildNodes) { - if (one.FirstChild.InnerText == "Saved by MP") found = true; + if (one.FirstChild.InnerText == FolderName) found = true; } } @@ -171,7 +171,7 @@ { XmlElement childElement = xmlDocument.CreateElement("Entry"); - XmlElement sub1 = xmlDocument.CreateElement("Name"); sub1.InnerText = "Saved by MP"; + XmlElement sub1 = xmlDocument.CreateElement("Name"); sub1.InnerText = FolderName; childElement.AppendChild(sub1); XmlElement sub2 = xmlDocument.CreateElement("URL"); sub2.InnerText = string.Empty; childElement.AppendChild(sub2); @@ -179,7 +179,7 @@ childElement.AppendChild(sub3); XmlElement sub4 = xmlDocument.CreateElement("LastVisited"); sub4.InnerText = "0001-01-01T00:00:00"; childElement.AppendChild(sub4); - XmlElement sub5 = xmlDocument.CreateElement("Created"); sub5.InnerText = "0001-01-01T00:00:00"; + XmlElement sub5 = xmlDocument.CreateElement("Created"); sub5.InnerText = DateTime.UtcNow.ToString("u", null); childElement.AppendChild(sub5); XmlElement sub6 = xmlDocument.CreateElement("isFolder"); sub6.InnerText = "true"; childElement.AppendChild(sub6); @@ -226,7 +226,7 @@ childElement.AppendChild(sub3); XmlElement sub4 = xmlDocument.CreateElement("LastVisited"); sub4.InnerText = "0001-01-01T00:00:00"; childElement.AppendChild(sub4); - XmlElement sub5 = xmlDocument.CreateElement("Created"); sub5.InnerText = "0001-01-01T00:00:00"; + XmlElement sub5 = xmlDocument.CreateElement("Created"); sub5.InnerText = DateTime.UtcNow.ToString("u", null); childElement.AppendChild(sub5); XmlElement sub6 = xmlDocument.CreateElement("isFolder"); sub6.InnerText = "false"; childElement.AppendChild(sub6); @@ -405,7 +405,7 @@ } public static void InitCachePath() { - if(!Directory.Exists(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb")) + if (!Directory.Exists(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb")) Directory.CreateDirectory(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\BrowseTheWeb"); } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2010-11-12 08:40:45 UTC (rev 3928) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2010-11-13 16:22:50 UTC (rev 3929) @@ -16,12 +16,13 @@ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> - <Optimize>false</Optimize> + <Optimize>true</Optimize> <OutputPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <UseVSHostingProcess>false</UseVSHostingProcess> + <PlatformTarget>x86</PlatformTarget> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -35,18 +36,22 @@ <Reference Include="Core, Version=1.1.1.11854, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Core.dll</HintPath> + <Private>False</Private> </Reference> <Reference Include="Dialogs, Version=1.1.1.11860, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\Dialogs.dll</HintPath> + <Private>False</Private> </Reference> <Reference Include="HtmlAgilityPack, Version=1.4.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\HtmlAgilityPack.dll</HintPath> + <Private>False</Private> </Reference> <Reference Include="Skybound.Gecko, Version=1.9.1.1, Culture=neutral, PublicKeyToken=3209ac31600d1857, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\Skybound.Gecko.dll</HintPath> + <Private>False</Private> </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> @@ -57,6 +62,7 @@ <Reference Include="Utils, Version=2.2.7.11849, Culture=neutral, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Utils.dll</HintPath> + <Private>False</Private> </Reference> </ItemGroup> <ItemGroup> @@ -83,6 +89,12 @@ <Compile Include="GUIPlugin.cs" /> <Compile Include="HtmlInputType.cs" /> <Compile Include="HtmlLinkNumber.cs" /> + <Compile Include="ImportIE.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="ImportIE.Designer.cs"> + <DependentUpon>ImportIE.cs</DependentUpon> + </Compile> <Compile Include="Mouse.cs"> <SubType>UserControl</SubType> </Compile> @@ -108,6 +120,7 @@ <Compile Include="Setup.Designer.cs"> <DependentUpon>Setup.cs</DependentUpon> </Compile> + <Compile Include="SqlLite.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="GetFolder.resx"> @@ -144,7 +157,11 @@ <Content Include="todo.txt" /> <EmbeddedResource Include="GetThumb.resx"> <DependentUpon>GetThumb.cs</DependentUpon> + <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="ImportIE.resx"> + <DependentUpon>ImportIE.cs</DependentUpon> + </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 2010-11-12 08:40:45 UTC (rev 3928) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user 2010-11-13 16:22:50 UTC (rev 3929) @@ -1,7 +1,7 @@ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <StartAction>Program</StartAction> - <StartProgram>C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe</StartProgram> + <StartProgram>C:\Program Files\Team MediaPortal\MediaPortal\Mediaportal.exe</StartProgram> </PropertyGroup> <PropertyGroup> <ProjectView>ProjectFiles</ProjectView> Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2010-11-12 08:40:45 UTC (rev 3928) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2010-11-13 16:22:50 UTC (rev 3929) @@ -172,6 +172,7 @@ { Xpcom.Initialize(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\xulrunner"); + #region add forms webBrowser = new GeckoWebBrowser(); GUIGraphicsContext.form.Controls.Add(webBrowser); webBrowser.Visible = false; @@ -183,71 +184,84 @@ mouse = new Mouse(); GUIGraphicsContext.form.Controls.Add(mouse); mouse.Visible = false; + #endregion LoadSettings(); - Bookmark.AddSavedFolder(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml"); + Bookmark.AddFolder(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", "Saved by MP"); return Load(GUIGraphicsContext.Skin + @"\BrowseTheWeb.xml"); } protected override void OnPageLoad() { - GUIPropertyManager.SetProperty("#btWeb.status", "Init browser"); - GUIPropertyManager.SetProperty("#btWeb.linkid", ""); - linkId = string.Empty; + try + { + MyLog.debug("Init browser"); - timer.Interval = 100; - timer.Tick += new EventHandler(timer_Tick); - timer.Start(); + GUIPropertyManager.SetProperty("#btWeb.status", "Init browser"); + GUIPropertyManager.SetProperty("#btWeb.linkid", ""); + linkId = string.Empty; - #region init browser - webBrowser.Visible = true; - webBrowser.Enabled = false; + #region init browser + webBrowser.Visible = true; + webBrowser.Enabled = false; - webBrowser.Dock = System.Windows.Forms.DockStyle.None; - webBrowser.Location = new System.Drawing.Point(0, 0); + webBrowser.Dock = System.Windows.Forms.DockStyle.None; + webBrowser.Location = new System.Drawing.Point(0, 0); - if (statusBar) - webBrowser.Size = new System.Drawing.Size(GUIGraphicsContext.form.Width, GUIGraphicsContext.form.Height - 100); - else - webBrowser.Size = new System.Drawing.Size(GUIGraphicsContext.form.Width, GUIGraphicsContext.form.Height); + if (statusBar) + webBrowser.Size = new System.Drawing.Size(GUIGraphicsContext.form.Width, GUIGraphicsContext.form.Height - 100); + else + webBrowser.Size = new System.Drawing.Size(GUIGraphicsContext.form.Width, GUIGraphicsContext.form.Height); - webBrowser.Window.TextZoom = font; - webBrowser.Zoom = zoom; + webBrowser.Window.TextZoom = font; + webBrowser.Zoom = zoom; - webBrowser.DocumentCompleted += new EventHandler(webBrowser_DocumentCompleted); - webBrowser.StatusTextChanged += new EventHandler(webBrowser_StatusTextChanged); + MyLog.debug("Create eventhandler"); - if (windowed) - { - MyLog.debug("switch to windowed fullscreen mode"); - GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 0, 0, null); - GUIWindowManager.SendMessage(msg); - } + webBrowser.DocumentCompleted += new EventHandler(webBrowser_DocumentCompleted); + webBrowser.StatusTextChanged += new EventHandler(webBrowser_StatusTextChanged); - string loadFav = StartupLink; + if (windowed) + { + MyLog.debug("switch to windowed fullscreen mode"); + GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 0, 0, null); + GUIWindowManager.SendMessage(msg); + } - if (webBrowser.Document.Domain == string.Empty) - { - if ((usehome) && (string.IsNullOrEmpty(loadFav))) + string loadFav = StartupLink; + + if (webBrowser.Document.Domain == string.Empty) { - webBrowser.Navigate(homepage); - MyLog.debug("load home page " + homepage); + if ((usehome) && (string.IsNullOrEmpty(loadFav))) + { + webBrowser.Navigate(homepage); + MyLog.debug("load home page " + homepage); + } } + + if (!string.IsNullOrEmpty(loadFav)) + { + webBrowser.Navigate(loadFav); + MyLog.debug("load favorite " + loadFav); + StartupLink = string.Empty; + } + + #endregion + + osd_linkID.Location = new System.Drawing.Point((GUIGraphicsContext.form.Width / 2) - (osd_linkID.Width / 2), + (GUIGraphicsContext.form.Height / 2) - (osd_linkID.Height / 2)); + + timer.Interval = 100; + timer.Tick += new EventHandler(timer_Tick); + timer.Start(); } - - if (!string.IsNullOrEmpty(loadFav)) + catch (Exception ex) { - webBrowser.Navigate(loadFav); - MyLog.debug("load favorite " + loadFav); - StartupLink = string.Empty; + MyLog.debug("Exception OnLoad : " + ex.Message); + MyLog.debug("Exception OnLoad : " + ex.StackTrace); } - #endregion - - osd_linkID.Location = new System.Drawing.Point((GUIGraphicsContext.form.Width / 2) - (osd_linkID.Width / 2), - (GUIGraphicsContext.form.Height / 2) - (osd_linkID.Height / 2)); - base.OnPageLoad(); } @@ -258,7 +272,7 @@ { usehome = xmlreader.GetValueAsBool("btWeb", "usehome", true); homepage = xmlreader.GetValueAsString("btWeb", "homepage", "http://team-mediaportal.com"); - remoteTime = xmlreader.GetValueAsInt("btWeb", "remote", 15); + remoteTime = xmlreader.GetValueAsInt("btWeb", "remotetime", 15); pluginName = xmlreader.GetValueAsString("btWeb", "name", "Browse Web"); blankBrowser = xmlreader.GetValueAsBool("btWeb", "blank", false); statusBar = xmlreader.GetValueAsBool("btWeb", "status", true); @@ -515,13 +529,13 @@ #region zoom & move case Action.ActionType.ACTION_ZOOM_IN: - case Action.ActionType.ACTION_PAGE_DOWN: + case Action.ActionType.ACTION_PAGE_UP: if (zoom < 2) zoom += 0.1f; webBrowser.Zoom = zoom; GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); break; case Action.ActionType.ACTION_ZOOM_OUT: - case Action.ActionType.ACTION_PAGE_UP: + case Action.ActionType.ACTION_PAGE_DOWN: if (zoom > 0.1f) zoom -= 0.1f; webBrowser.Zoom = zoom; GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); @@ -745,6 +759,10 @@ private void OnLinkId(string LinkId) { + linkId = string.Empty; + osd_linkID.Visible = false; + Application.DoEvents(); + HtmlLinkNumber hln = null; if (GetLinkById(Convert.ToInt32(LinkId), out hln)) { Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.Designer.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.Designer.cs 2010-11-13 16:22:50 UTC (rev 3929) @@ -0,0 +1,78 @@ +namespace BrowseTheWeb +{ + partial class ImportIE + { + /// <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.btnClose = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.Location = new System.Drawing.Point(12, 22); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(502, 251); + this.listBox1.TabIndex = 0; + // + // btnClose + // + this.btnClose.Location = new System.Drawing.Point(12, 279); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(502, 31); + this.btnClose.TabIndex = 1; + this.btnClose.Text = "Close"; + this.btnClose.UseVisualStyleBackColor = true; + this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + // + // ImportIE + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(526, 323); + this.Controls.Add(this.btnClose); + this.Controls.Add(this.listBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ImportIE"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Import Internet Explorer"; + this.Load += new System.EventHandler(this.ImportIE_Load); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.Button btnClose; + } +} \ No newline at end of file Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.cs 2010-11-13 16:22:50 UTC (rev 3929) @@ -0,0 +1,109 @@ +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 + { + public List<Bookmark> EntryList = new List<Bookmark>(); + + public ImportIE() + { + InitializeComponent(); + } + + private void btnClose_Click(object sender, EventArgs e) + { + this.Close(); + } + private void ImportIE_Load(object sender, EventArgs e) + { + string favPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); + string[] favFiles; + + listBox1.Items.Add("Import folder is " + favPath); + listBox1.Items.Add("Reading folder"); + + if (Directory.Exists(favPath)) + { + string[] favDirs = Directory.GetDirectories(favPath); + listBox1.Items.Add("Found " + favDirs.Length.ToString() + " folder"); + + foreach (string folder in favDirs) + { + listBox1.Items.Add("Work on folder '" + Path.GetFileName(folder) + "'"); + + favFiles = Directory.GetFiles(folder, "*.url", SearchOption.TopDirectoryOnly); + listBox1.Items.Add(favFiles.Length.ToString() + " files to import"); + + foreach (string s in favFiles) + { + FileInfo f = new FileInfo(s); + string name = Path.GetFileNameWithoutExtension(f.Name); + + listBox1.Items.Add("Found '" + name + "'"); + string url = GetUrlFile(s); + + if (url != null) + { + Bookmark bkm = new Bookmark(); + bkm.Url = url; + bkm.Name = name; + + EntryList.Add(bkm); + } + } + } + + listBox1.Items.Add("Reading root folder"); + + favFiles = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Favorites), "*.url", SearchOption.TopDirectoryOnly); + listBox1.Items.Add(favFiles.Length.ToString() + " files to import"); + + foreach (string s in favFiles) + { + FileInfo f = new FileInfo(s); + string name = Path.GetFileNameWithoutExtension(f.Name); + + listBox1.Items.Add("Found '" + name + "'"); + string url = GetUrlFile(s); + + if (url != null) + { + Bookmark bkm = new Bookmark(); + bkm.Url = url; + bkm.Name = name; + + EntryList.Add(bkm); + } + } + listBox1.Items.Add("Reading finished. Found " + EntryList.Count + " bookmarks"); + } + else + { + listBox1.Items.Add("Directory does not exist."); + } + } + + private string GetUrlFile(string File) + { + using (StreamReader sr = new StreamReader(File)) + { + while (!sr.EndOfStream) + { + string line = sr.ReadLine(); + if (line.StartsWith("URL=")) + return line.Substring(4); + } + } + return null; + } + } +} Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.resx (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/ImportIE.resx 2010-11-13 16:22:50 UTC (rev 3929) @@ -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 2010-11-12 08:40:45 UTC (rev 3928) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2010-11-13 16:22:50 UTC (rev 3929) @@ -49,6 +49,7 @@ this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.chkWindowed = new System.Windows.Forms.CheckBox(); this.chkOSD = new System.Windows.Forms.CheckBox(); this.chkStatus = new System.Windows.Forms.CheckBox(); this.chkBlank = new System.Windows.Forms.CheckBox(); @@ -73,6 +74,8 @@ this.txtZoom = new System.Windows.Forms.Label(); this.trkZoom = new System.Windows.Forms.TrackBar(); this.tabPage3 = new System.Windows.Forms.TabPage(); + this.btnImportFF = new System.Windows.Forms.Button(); + this.btnImportIE = new System.Windows.Forms.Button(); this.label7 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); @@ -89,7 +92,6 @@ this.comboBox1 = new System.Windows.Forms.ComboBox(); this.chkRemote = new System.Windows.Forms.CheckBox(); this.listBox1 = new System.Windows.Forms.ListBox(); - this.chkWindowed = new System.Windows.Forms.CheckBox(); this.contextMenuStrip1.SuspendLayout(); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); @@ -298,6 +300,16 @@ this.groupBox5.TabStop = false; this.groupBox5.Text = "Other settings"; // + // chkWindowed + // + this.chkWindowed.AutoSize = true; + this.chkWindowed.Location = new System.Drawing.Point(19, 155); + this.chkWindowed.Name = "chkWindowed"; + this.chkWindowed.Size = new System.Drawing.Size(223, 20); + this.chkWindowed.TabIndex = 5; + this.chkWindowed.Text = "use windowed mode in fullscreen"; + this.chkWindowed.UseVisualStyleBackColor = true; + // // chkOSD // this.chkOSD.AutoSize = true; @@ -548,6 +560,8 @@ // tabPage3 // this.tabPage3.BackColor = System.Drawing.SystemColors.Control; + this.tabPage3.Controls.Add(this.btnImportFF); + this.tabPage3.Controls.Add(this.btnImportIE); this.tabPage3.Controls.Add(this.label7); this.tabPage3.Controls.Add(this.label4); this.tabPage3.Controls.Add(this.label3); @@ -561,6 +575,26 @@ this.tabPage3.TabIndex = 2; this.tabPage3.Text = "Bookmarks"; // + // btnImportFF + // + this.btnImportFF.Location = new System.Drawing.Point(87, 442); + this.btnImportFF.Name = "btnImportFF"; + this.btnImportFF.Size = new System.Drawing.Size(75, 23); + this.btnImportFF.TabIndex = 19; + this.btnImportFF.Text = "Import FF"; + this.btnImportFF.UseVisualStyleBackColor = true; + this.btnImportFF.Click += new System.EventHandler(this.btnImportFF_Click); + // + // btnImportIE + // + this.btnImportIE.Location = new System.Drawing.Point(6, 442); + this.btnImportIE.Name = "btnImportIE"; + this.btnImportIE.Size = new System.Drawing.Size(75, 23); + this.btnImportIE.TabIndex = 18; + this.btnImportIE.Text = "Import IE"; + this.btnImportIE.UseVisualStyleBackColor = true; + this.btnImportIE.Click += new System.EventHandler(this.btnImportIE_Click); + // // label7 // this.label7.AutoSize = true; @@ -724,16 +758,6 @@ this.listBox1.Size = new System.Drawing.Size(550, 372); this.listBox1.TabIndex = 0; // - // chkWindowed - // - this.chkWindowed.AutoSize = true; - this.chkWindowed.Location = new System.Drawing.Point(19, 155); - this.chkWindowed.Name = "chkWindowed"; - this.chkWindowed.Size = new System.Drawing.Size(223, 20); - this.chkWindowed.TabIndex = 5; - this.chkWindowed.Text = "use windowed mode in fullscreen"; - this.chkWindowed.UseVisualStyleBackColor = true; - // // Setup // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -845,5 +869,7 @@ private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label7; private System.Windows.Forms.CheckBox chkWindowed; + private System.Windows.Forms.Button btnImportIE; + private System.Windows.Forms.Button btnImportFF; } } \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2010-11-12 08:40:45 UTC (rev 3928) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2010-11-13 16:22:50 UTC (rev 3929) @@ -1,4 +1,4 @@ -#region Copyright (C) 2005-2010 Team MediaPortal +#region Copyright (C) 2005-2010 Team MediaPortal /* * Copyright (C) 2005-2010 Team MediaPortal @@ -464,6 +464,7 @@ addBkm.Name = get.SelectedName; addBkm.Url = get.SelectedUrl; addBkm.isSubFolder = true; + addBkm.Created = DateTime.Now; add.Tag = addBkm; node.ExpandAll(); @@ -475,6 +476,7 @@ Bookmark addBkm = new Bookmark(); addBkm.Name = get.SelectedName; addBkm.Url = get.SelectedUrl; + addBkm.Created = DateTime.Now; add.Tag = addBkm; node.Parent.ExpandAll(); @@ -487,6 +489,7 @@ Bookmark addBkm = new Bookmark(); addBkm.Name = get.SelectedName; addBkm.Url = get.SelectedUrl; + addBkm.Created = DateTime.Now; add.Tag = addBkm; treeView1.Nodes[0].ExpandAll(); @@ -597,7 +600,7 @@ { chkHome.Checked = xmlreader.GetValueAsBool("btWeb", "usehome", true); txtHome.Text = xmlreader.GetValueAsString("btWeb", "homepage", "http://team-mediaportal.com"); - trkRemote.Value = xmlreader.GetValueAsInt("btWeb", "remote", 25); + trkRemote.Value = xmlreader.GetValueAsInt("btWeb", "remotetime", 25); txtName.Text = xmlreader.GetValueAsString("btWeb", "name", "Browse Web"); chkBlank.Checked = xmlreader.GetValueAsBool("btWeb", "blank", false); chkStatus.Checked = xmlreader.GetValueAsBool("btWeb", "status", false); @@ -629,7 +632,7 @@ { xmlwriter.SetValueAsBool("btWeb", "usehome", chkHome.Checked); xmlwriter.SetValue("btWeb", "homepage", txtHome.Text); - xmlwriter.SetValue("btWeb", "remote", trkRemote.Value); + xmlwriter.SetValue("btWeb", "remotetime", trkRemote.Value); xmlwriter.SetValue("btWeb", "name", txtName.Text); xmlwriter.SetValueAsBool("btWeb", "blank", chkBlank.Checked); xmlwriter.SetValueAsBool("btWeb", "status", chkStatus.Checked); @@ -720,5 +723,97 @@ { TrySetProxy(); } + + private void btnImportIE_Click(object sender, EventArgs e) + { + if (!Bookmark.Exists(treeView1, "Import IE")) + { + TreeNode newNode = treeView1.Nodes[0].Nodes.Add("Import IE"); + newNode.ImageIndex = 1; + newNode.SelectedImageIndex = 1; + + Bookmark bkm = new Bookmark(); + bkm.Name = "Import IE"; + bkm.isFolder = true; + newNode.Tag = bkm; + + treeView1.Nodes[0].ExpandAll(); + } + + ImportIE import = new ImportIE(); + import.ShowDialog(); + + int max = import.EntryList.Count; + int imported = 0; + + TreeNode node = null; + foreach (TreeNode n in treeView1.Nodes[0].Nodes) + { + if (n.Text == "Import IE") + { + node = n; + break; + } + } + + if (node != null) + { + foreach (Bookmark bkm in import.EntryList) + { + if (!Bookmark.Exists(treeView1, bkm.Name)) + { + if (!Bookmark.isValidUrl(bkm.Url)) + { + DialogResult res = MessageBox.Show("The url seems not to be valid !\nContinue anyway ?", "Error home page address", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + //if (res != DialogResult.Yes) break; + } + + if (chkUseThumbs.Checked) + { + GetThumb thumb = new GetThumb(); + thumb.SelectedUrl = bkm.Url; + thumb.ShowDialog(); + } + + TreeNode add = node.Nodes.Add(bkm.Url, bkm.Name); + + Bookmark addBkm = new Bookmark(); + addBkm.Name = bkm.Name; + addBkm.Url = bkm.Url; + addBkm.isSubFolder = true; + add.Tag = addBkm; + + node.ExpandAll(); + + } + } + } + } + private void btnImportFF_Click(object sender, EventArgs e) + { + SQLite db = new SQLite(); + + string path = @"C:\Users\mka\AppData\Roaming\Mozilla\Firefox\Profiles\wyhhe7f5.default\places.sqlite"; + + db.OpenDatabase(path); + //db.OpenDatabase(path);"Data Source=" + path + ";Version=3;New=True;Compress=True;" + + //DataTable table = db.ExecuteQuery("select * from moz_places"); + DataTable table = db.ExecuteQuery("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%';"); + + + foreach (DataRow row in table.Rows) + { + string t = Convert.ToString(row["title"]); + string u = Convert.ToString(row["url"]); + + System.Diagnostics.Debug.WriteLine("--------"); + System.Diagnostics.Debug.WriteLine(t); + System.Diagnostics.Debug.WriteLine(u); + } + + db.CloseDatabase(); + } } } Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2010-11-12 08:40:45 UTC (rev 3928) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx 2010-11-13 16:22:50 UTC (rev 3929) @@ -124,52 +124,51 @@ <value> AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABM - CgAAAk1TRnQBSQFMAgEBAwEAAfABAAHwAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo - AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA - AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 - AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA - AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm - AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM - AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA - ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz - AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ - AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM - AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA - AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA - AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ - AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/ - AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA - AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm - ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ - Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz - AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA - AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM - AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM - ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM - Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA - AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM - AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ - AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz - AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm - AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw - AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/wQAAXQB9AcAAfMB9BYA - AfMB9AUAAbwBGxUAARoMKgQABCoBGwsABCoBmQEAASoBKQIqASkUAAIqAVgBMQUqAVIBWAIqAwABKgMx - BCoBGggAASoBoAJYAyoBUgF5AVIBKRQAASoFWAF5A3oBWAEqAbwDAAEqBjEEKgH/BQABdAGgAVIBeQFY - ASoCUgF5AVIBGhQAASoBoAJYAXkDegHlAXoBWAEqBAABKgE4AVkHMQIqBgABKgGaAVIBeQFYATEBUgFY - ASoVAAEqAaAFWAN6AVIBKgQAASoBOAFYCDEBKgEcBQABKgHDATECUgExAlIBKhUAASoBwwVYAXkCegEq - AXQEAAExAVkBMQFSCDEBKgMAARsCKgFYAzcBMQJSAioUAAEqAcMFWAF5AnoBKgG8BAABUgJZAcMIMQEq - AwABKgFYAXkBWAQ3AVICeQFSASoTAAExAcMDegF5AVgDegFSAXQDAAEaA1kBWAH2AVIGMQEwAZkBAAF0 - AXoCWAE3AjgCNwExAlIBeQExAfQSAAExAcMIegFYASoDAAF5A+UCWQExAVIBwwF5BDEBKgEAAVIBNwHD - AfYBwwGgATgBNwFYATcDoAEqAfMSAAExAfYCoAHlBXoBWAEqAwABMQTlA1kCOAExAVgBegExASoCAAFS - AzEB9gE4AlgEKgH/EwABMQLDAaAB5QJ6AnkDKgMAATEBoAPlATEDWQI4AXQBGgEqAfQFAAHzATcBwwJY - ASoXAAF5AVgC9gHlAnoCWAIqAfMDAAExAVgBoALlATEBGgEwASoBMQEwAfYJAAExAcMBWAExAZkYAAIx - AXoBoALDAaABWAEqAZkGAAH2ARoBUgEbDwAB/wExAaABKhsAAXkCMQMqAfMbAAF0ATEBG1YAAUIBTQE+ - BwABPgMAASgDAAFAAwABEAMAAQEBAAEBBQABgBcAA/8BAAHnAfMC/wHzAecCAAHAAQEB4AH/AeABgwIA - AcABAQHAAR8B4AEDAgABwAEBAcABAwHgAQMCAAHAAQMBwAEDAfABBwIAAcABAwHAAQEB8AEHAgABwAED - AcABAQHAAQMCAAHAAQMBwAEBAcABAQIAAcABAwGAAQABgAMAAcABAwGAAQABgAMAAcABAwGAAQABwAEB - AgABwAEDAYABAAH4AR8CAAHAAQMBgAEHAfwBHwIAAeABBwHhAf8B/AE/AgAB+AEPAv8B/gE/AgAG/wIA - Cw== + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABK + CgAAAk1TRnQBSQFMAgEBAwIAAQEBAAEBARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA + AUADAAEQAwABAQEAAQgGAAEEGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA + AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEA + AYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFm + AwABmQMAAcwCAAEzAwACMwIAATMBZgIAATMBmQIAATMBzAIAATMB/wIAAWYDAAFmATMCAAJmAgABZgGZ + AgABZgHMAgABZgH/AgABmQMAAZkBMwIAAZkBZgIAApkCAAGZAcwCAAGZAf8CAAHMAwABzAEzAgABzAFm + AgABzAGZAgACzAIAAcwB/wIAAf8BZgIAAf8BmQIAAf8BzAEAATMB/wIAAf8BAAEzAQABMwEAAWYBAAEz + AQABmQEAATMBAAHMAQABMwEAAf8BAAH/ATMCAAMzAQACMwFmAQACMwGZAQACMwHMAQACMwH/AQABMwFm + AgABMwFmATMBAAEzAmYBAAEzAWYBmQEAATMBZgHMAQABMwFmAf8BAAEzAZkCAAEzAZkBMwEAATMBmQFm + AQABMwKZAQABMwGZAcwBAAEzAZkB/wEAATMBzAIAATMBzAEzAQABMwHMAWYBAAEzAcwBmQEAATMCzAEA + ATMBzAH/AQABMwH/ATMBAAEzAf8BZgEAATMB/wGZAQABMwH/AcwBAAEzAv8BAAFmAwABZgEAATMBAAFm + AQABZgEAAWYBAAGZAQABZgEAAcwBAAFmAQAB/wEAAWYBMwIAAWYCMwEAAWYBMwFmAQABZgEzAZkBAAFm + ATMBzAEAAWYBMwH/AQACZgIAAmYBMwEAA2YBAAJmAZkBAAJmAcwBAAFmAZkCAAFmAZkBMwEAAWYBmQFm + AQABZgKZAQABZgGZAcwBAAFmAZkB/wEAAWYBzAIAAWYBzAEzAQABZgHMAZkBAAFmAswBAAFmAcwB/wEA + AWYB/wIAAWYB/wEzAQABZgH/AZkBAAFmAf8BzAEAAcwBAAH/AQAB/wEAAcwBAAKZAgABmQEzAZkBAAGZ + AQABmQEAAZkBAAHMAQABmQMAAZkCMwEAAZkBAAFmAQABmQEzAcwBAAGZAQAB/wEAAZkBZgIAAZkBZgEz + AQABmQEzAWYBAAGZAWYBmQEAAZkBZgHMAQABmQEzAf8BAAKZATMBAAKZAWYBAAOZAQACmQHMAQACmQH/ + AQABmQHMAgABmQHMATMBAAFmAcwBZgEAAZkBzAGZAQABmQLMAQABmQHMAf8BAAGZAf8CAAGZAf8BMwEA + AZkBzAFmAQABmQH/AZkBAAGZAf8BzAEAAZkC/wEAAcwDAAGZAQABMwEAAcwBAAFmAQABzAEAAZkBAAHM + AQABzAEAAZkBMwIAAcwCMwEAAcwBMwFmAQABzAEzAZkBAAHMATMBzAEAAcwBMwH/AQABzAFmAgABzAFm + ATMBAAGZAmYBAAHMAWYBmQEAAcwBZgHMAQABmQFmAf8BAAHMAZkCAAHMAZkBMwEAAcwBmQFmAQABzAKZ + AQABzAGZAcwBAAHMAZkB/wEAAswCAALMATMBAALMAWYBAALMAZkBAAPMAQACzAH/AQABzAH/AgABzAH/ + ATMBAAGZAf8BZgEAAcwB/wGZAQABzAH/AcwBAAHMAv8BAAHMAQABMwEAAf8BAAFmAQAB/wEAAZkBAAHM + ATMCAAH/AjMBAAH/ATMBZgEAAf8BMwGZAQAB/wEzAcwBAAH/ATMB/wEAAf8BZgIAAf8BZgEzAQABzAJm + AQAB/wFmAZkBAAH/AWYBzAEAAcwBZgH/AQAB/wGZAgAB/wGZATMBAAH/AZkBZgEAAf8CmQEAAf8BmQHM + AQAB/wGZAf8BAAH/AcwCAAH/AcwBMwEAAf8BzAFmAQAB/wHMAZkBAAH/AswBAAH/AcwB/wEAAv8BMwEA + AcwB/wFmAQAC/wGZAQAC/wHMAQACZgH/AQABZgH/AWYBAAFmAv8BAAH/AmYBAAH/AWYB/wEAAv8BZgEA + ASEBAAGlAQADXwEAA3cBAAOGAQADlgEAA8sBAAOyAQAD1wEAA90BAAPjAQAD6gEAA/EBAAP4AQAB8AH7 + Af8BAAGkAqABAAOAAwAB/wIAAf8DAAL/AQAB/wMAAf8BAAH/AQAC/wIAA/8EAAF0AfQHAAHzAfQWAAHz + AfQFAAG8ARsVAAEaDCoEAAQqARsLAAQqAZkBAAEqASkCKgEpFAACKgFYATEFKgFSAVgCKgMAASoDMQQq + ARoIAAEqAaACWAMqAVIBeQFSASkUAAEqBVgBeQN6AVgBKgG8AwABKgYxBCoB/wUAAXQBoAFSAXkBWAEq + AlIBeQFSARoUAAEqAaACWAF5A3oB5QF6AVgBKgQAASoBOAFZBzECKgYAASoBmgFSAXkBWAExAVIBWAEq + FQABKgGgBVgDegFSASoEAAEqATgBWAgxASoBHAUAASoBwwExAlIBMQJSASoVAAEqAcMFWAF5AnoBKgF0 + BAABMQFZATEBUggxASoDAAEbAioBWAM3ATECUgIqFAABKgHDBVgBeQJ6ASoBvAQAAVICWQHDCDEBKgMA + ASoBWAF5AVgENwFSAnkBUgEqEwABMQHDA3oBeQFYA3oBUgF0AwABGgNZAVgB9gFSBjEBMAGZAQABdAF6 + AlgBNwI4AjcBMQJSAXkBMQH0EgABMQHDCHoBWAEqAwABeQPlAlkBMQFSAcMBeQQxASoBAAFSATcBwwH2 + AcMBoAE4ATcBWAE3A6ABKgHzEgABMQH2AqAB5QV6AVgBKgMAATEE5QNZAjgBMQFYAXoBMQEqAgABUgMx + AfYBOAJYBCoB/xMAATECwwGgAeUCegJ5AyoDAAExAaAD5QExA1kCOAF0ARoBKgH0BQAB8wE3AcMCWAEq + FwABeQFYAvYB5QJ6AlgCKgHzAwABMQFYAaAC5QExARoBMAEqATEBMAH2CQABMQHDAVgBMQGZGAACMQF6 + AaACwwGgAVgBKgGZBgAB9gEaAVIBGw8AAf8BMQGgASobAAF5AjEDKgHzGwABdAExARtWAAFCAU0BPgcA + AT4DAAEoAwABQAMAARADAAEBAQABAQUAAYAXAAP/AQAB5wHzAv8B8wHnAgABwAEBAeAB/wHgAYMCAAHA + AQEBwAEfAeABAwIAAcABAQHAAQMB4AEDAgABwAEDAcABAwHwAQcCAAHAAQMBwAEBAfABBwIAAcABAwHA + AQEBwAEDAgABwAEDAcABAQHAAQECAAHAAQMBgAEAAYADAAHAAQMBgAEAAYADAAHAAQMBgAEAAcABAQIA + AcABAwGAAQAB+AEfAgABwAEDAYABBwH8AR8CAAHgAQcB4QH/AfwBPwIAAfgBDwL/Af4BPwIABv8CAAs= </value> </data> <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/SqlLite.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/SqlLite.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/SqlLite.cs 2010-11-13 16:22:50 UTC (rev 3929) @@ -0,0 +1,191 @@ +using System; +using System.Data; +using System.Runtime.InteropServices; + +namespace BrowseTheWeb +{ + public class SQLiteException : Exception + { + public SQLiteException(string message) : + base(message) + { + + } + } + + public class SQLite + { + const int SQLITE_OK = 0; + const int SQLITE_ROW = 100; + const int SQLITE_DONE = 101; + const int SQLITE_INTEGER = 1; + const int SQLITE_FLOAT = 2; + const int SQLITE_TEXT = 3; + const int SQLITE_BLOB = 4; + const int SQLITE_NULL = 5; + + //const string path = @"C:\Program Files\Team MediaPortal\MediaPortal\Plugins\Windows\"; + const string path = ""; + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_open")] + static extern int sqlite3_open(string filename, out IntPtr db); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_close")] + static extern int sqlite3_close(IntPtr db); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_prepare_v2")] + static extern int sqlite3_prepare_v2(IntPtr db, string zSql, + int nByte, out IntPtr ppStmpt, IntPtr pzTail); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_step")] + static extern int sqlite3_step(IntPtr stmHandle); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_finalize")] + static extern int sqlite3_finalize(IntPtr stmHandle); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_errmsg")] + static extern string sqlite3_errmsg(IntPtr db); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_column_count")] + static extern int sqlite3_column_count(IntPtr stmHandle); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_column_origin_name")] + static extern string sqlite3_column_origin_name( + IntPtr stmHandle, int iCol); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_column_type")] + static extern int sqlite3_column_type(IntPtr stmHandle, int iCol); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_column_int")] + static extern int sqlite3_column_int(IntPtr stmHandle, int iCol); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_column_text")] + static extern string sqlite3_column_text(IntPtr stmHandle, int iCol); + + [DllImport(path + "sqlite3.dll", EntryPoint = "sqlite3_column_double")] + static extern double sqlite3_column_double(IntPtr stmHandle, int iCol); + + private IntPtr _db; //pointer to SQLite database + private bool _open; //whether or not the database is open + + /// <summary> + /// Opens or creates SQLite database with the specified path + /// </summary> + /// <param name="path">Path to SQLite database</param> + public void OpenDatabase(string path) + { + if (sqlite3_open(path, out _db) != SQLITE_OK) + throw new SQLiteException("Could not open database file: " + path); + + _open = true; + } + + /// <summary> + /// Closes the SQLite database + /// </summary> + public void CloseDatabase() + { + if (_open) + sqlite3_close(_db); + + _open = false; + } + + /// <summary> + /// Executes a query that returns no results + /// </summary> + /// <param name="query">SQL query to execute</param> + public void ExecuteNonQuery(string query) + { + if (!_open) + throw new SQLiteException("SQLite database is not open."); + + //prepare the statement + IntPtr stmHandle = Prepare(query); + + if (sqlite3_step(stmHandle) != SQLITE_DONE) + throw new SQLiteException("Could not execute SQL statement."); + + Finalize(stmHandle); + } + + /// <summary> + /// Executes a query and stores the results in + /// a DataTable + /// </summary> + /// <param name="query">SQL query to execute</param> + /// <returns>DataTable of results</returns> + public DataTable ExecuteQuery(string query) + { + if (!_open) + throw new SQLiteException("SQLite database is not open."); + + //prepare the statement + IntPtr stmHandle = Prepare(query); + + //get the number of returned columns + int columnCount = sqlite3_column_count(stmHandle); + + //create datatable and columns + DataTable dTable = new DataTable(); + for (int i = 0; i < columnCount; i++) + dTable.Columns.Add(sqlite3_column_origin_name(stmHandle, i)); + + //populate datatable + while (sqlite3_step(stmHandle) == SQLITE_ROW) + { + object[] row = new object[columnCount]; + for (int i = 0; i < columnCount; i++) + { + switch (sqlite3_column_type(stmHandle, i)) + { + case SQLITE_INTEGER: + row[i] = sqlite3_column_int(stmHandle, i); + break; + case SQLITE_TEXT: + row[i] = sqlite3_column_text(stmHandle, i); + break; + case SQLITE_FLOAT: + row[i] = sqlite3_column_double(stmHandle, i); + break; + } + } + + dTable.Rows.Add(row); + } + + Finalize(stmHandle); + + return dTable; + } + + /// <summary> + /// Prepares a SQL statement for execution + /// </summary> + /// <param name="query">SQL query</param> + /// <returns>Pointer to SQLite prepared statement</returns> + private IntPtr Prepare(string query) + { + IntPtr stmHandle; + + if (sqlite3_prepare_v2(_db, query, query.Length, + out stmHandle, IntPtr.Zero) != SQLITE_OK) + throw new SQLiteException(sqlite3_errmsg(_db)); + + return stmHandle; + } + + /// <summary> + /// Finalizes a SQLite statement + /// </summary> + /// <param name="stmHandle"> + /// Pointer to SQLite prepared statement + /// </param> + private void Finalize(IntPtr stmHandle) + { + if (sqlite3_finalize(stmHandle) != SQLITE_OK) + throw new SQLiteException("Could not finalize SQL statement."); + } + } +} + Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/res/icon-48x48-mouse.png =================================================================== (Binary files differ) Property changes on: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/res/icon-48x48-mouse.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/todo.txt =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/todo.txt 2010-11-12 08:40:45 UTC (rev 3928) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/todo.txt 2010-11-13 16:22:50 UTC (rev 3929) @@ -7,9 +7,13 @@ bookmark add / edit can be set even url is not valid Ready for Info Service, Thanks to SilentExeption +V0.2.1 extract xulrunner first in setup +V0.2.2 add proxy support +V0.2.3 add force windowed mode + todo: nothing yet Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.suo =================================================================== (Binary files differ) Modified: trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.suo =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kro...@us...> - 2011-01-27 15:34:06
|
Revision: 4082 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4082&view=rev Author: kroko_koenig Date: 2011-01-27 15:34:00 +0000 (Thu, 27 Jan 2011) Log Message: ----------- change zip packer Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.suo trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.suo Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2011-01-27 08:09:30 UTC (rev 4081) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2011-01-27 15:34:00 UTC (rev 4082) @@ -53,6 +53,11 @@ <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\HtmlAgilityPack.dll</HintPath> <Private>False</Private> </Reference> + <Reference Include="Ionic.Zip, Version=1.7.2.18, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Ionic.Zip.dll</HintPath> + <Private>False</Private> + </Reference> <Reference Include="Skybound.Gecko, Version=1.9.1.1, Culture=neutral, PublicKeyToken=3209ac31600d1857, processorArchitecture=x86"> <SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\Skybound.Gecko.dll</HintPath> Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user 2011-01-27 08:09:30 UTC (rev 4081) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user 2011-01-27 15:34:00 UTC (rev 4082) @@ -1,7 +1,7 @@ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <StartAction>Program</StartAction> - <StartProgram>C:\Program Files\Team MediaPortal\MediaPortal\Mediaportal.exe</StartProgram> + <StartProgram>C:\Program Files\Team MediaPortal\MediaPortal\MediaPortal.exe</StartProgram> </PropertyGroup> <PropertyGroup> <ProjectView>ProjectFiles</ProjectView> Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2011-01-27 08:09:30 UTC (rev 4081) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2011-01-27 15:34:00 UTC (rev 4082) @@ -1,7 +1,7 @@ -#region Copyright (C) 2005-2010 Team MediaPortal +#region Copyright (C) 2005-2011 Team MediaPortal /* - * Copyright (C) 2005-2010 Team MediaPortal + * Copyright (C) 2005-2011 Team MediaPortal * http://www.team-mediaportal.com * * This Program is free software; you can redistribute it and/or modify @@ -175,7 +175,15 @@ public override bool Init() { - Xpcom.Initialize(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\xulrunner"); + try + { + Xpcom.Initialize(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\xulrunner"); + } + catch (Exception ex) + { + MyLog.debug("Could not find xulrunner under : " + Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\xulrunner"); + MyLog.debug("Reason : " + ex.Message); + } #region add forms webBrowser = new GeckoWebBrowser(); @@ -412,9 +420,18 @@ } } + public override bool OnMessage(GUIMessage message) + { + Console.WriteLine("message :" + message.Label); + return base.OnMessage(message); + } + public override void OnAction(Action action) { - base.OnAction(action); + if (linkId != string.Empty) + GUIPropertyManager.SetProperty("#btWeb.linkid", "Link ID = " + linkId); + else + GUIPropertyManager.SetProperty("#btWeb.linkid", linkId); #region remote diagnostic if (remote) @@ -540,45 +557,44 @@ case Action.ActionType.ACTION_PLAY: case Action.ActionType.ACTION_MUSIC_PLAY: OnEnterNewLink(); - break; + return; case Action.ActionType.ACTION_PAUSE: webBrowser.Navigate(homepage); MyLog.debug("load home page " + homepage); if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "go to homepage"); - break; + return; case Action.ActionType.ACTION_STOP: webBrowser.Navigate("about:blank"); if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "Stop"); - break; + return; case Action.ActionType.ACTION_PREV_ITEM: case Action.ActionType.ACTION_REWIND: webBrowser.GoBack(); if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "go backward"); MyLog.debug("navigate go back"); - break; + return; case Action.ActionType.ACTION_NEXT_ITEM: case Action.ActionType.ACTION_FORWARD: webBrowser.GoForward(); if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "go forward"); MyLog.debug("navigate go forward"); - break; + return; case Action.ActionType.ACTION_RECORD: OnAddBookmark(); - break; + return; #region move case Action.ActionType.ACTION_MOVE_RIGHT: OnMoveRight(); - break; + return; case Action.ActionType.ACTION_MOVE_LEFT: OnMoveLeft(); - break; + return; case Action.ActionType.ACTION_MOVE_UP: OnMoveUp(); - break; + return; case Action.ActionType.ACTION_MOVE_DOWN: - OnMoveDown(); - break; + return; case Action.ActionType.ACTION_SELECT_ITEM: if (mouse.Visible) { @@ -587,16 +603,11 @@ int y = GUIGraphicsContext.form.Location.Y + mouse.Location.Y + 50; System.Windows.Forms.Cursor.Position = new Point(x, y); } - break; + return; #endregion } - if (linkId != string.Empty) - GUIPropertyManager.SetProperty("#btWeb.linkid", "Link ID = " + linkId); - else - GUIPropertyManager.SetProperty("#btWeb.linkid", linkId); + } - - } private void webBrowser_DomKeyDown(object sender, GeckoDomKeyEventArgs e) { if (useMouse) @@ -945,6 +956,7 @@ } #endregion } + #region reset zoom if (zoomPage) { Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2011-01-27 08:09:30 UTC (rev 4081) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs 2011-01-27 15:34:00 UTC (rev 4082) @@ -1,7 +1,7 @@ -#region Copyright (C) 2005-2010 Team MediaPortal +#region Copyright (C) 2005-2011 Team MediaPortal /* - * Copyright (C) 2005-2010 Team MediaPortal + * Copyright (C) 2005-2011 Team MediaPortal * http://www.team-mediaportal.com * * This Program is free software; you can redistribute it and/or modify @@ -34,7 +34,10 @@ using System.IO; using Skybound.Gecko; +using Ionic.Zip; + using MediaPortal.Configuration; +using MediaPortal.GUI.Library; namespace BrowseTheWeb { @@ -56,33 +59,48 @@ InitializeComponent(); #region create xulrunner if needed - string dir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\xulrunner"; - string dirCache = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache); - try + string zipToUnpack = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Cache) + "\\xulrunner.zip"; + string unpackDirectory = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config); + + if (File.Exists(zipToUnpack)) { - if (!Directory.Exists(dir)) + Log.Debug("BrowseTheWeb | zip found : " + zipToUnpack, new object[0]); + try { - System.Diagnostics.ProcessStartInfo procStartInfo = - new System.Diagnostics.ProcessStartInfo("cmd", "/c unzip.exe -o xulrunner -d ../"); - procStartInfo.WorkingDirectory = dirCache; + using (ZipFile zip1 = ZipFile.Read(zipToUnpack)) + { + foreach (ZipEntry e in zip1) + { + e.Extract(unpackDirectory, true); + } + } + Log.Debug("BrowseTheWeb | unpack finished to " + unpackDirectory, new object[0]); + } + catch (Exception ex) + { + Log.Debug("BrowseTheWeb | Exception : " + ex.Message, new object[0]); + } + } - procStartInfo.RedirectStandardOutput = true; - procStartInfo.UseShellExecute = false; + #endregion - procStartInfo.CreateNoWindow = true; + string plugins = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Plugins); - System.Diagnostics.Process proc = new System.Diagnostics.Process(); - proc.StartInfo = procStartInfo; - proc.Start(); + FileInfo info = new FileInfo(plugins + "\\Windows\\HtmlAgilityPack.dll"); + Log.Debug("BrowseTheWeb | HtmlAgilityPack: " + info.CreationTime); - string result = proc.StandardOutput.ReadToEnd(); - } + info = new FileInfo(plugins + "\\Windows\\Skybound.Gecko.dll.dll"); + Log.Debug("BrowseTheWeb | Skybound.Gecko.dll: " + info.CreationTime); + + try + { + Xpcom.Initialize(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\xulrunner"); } - catch { } - #endregion - - Xpcom.Initialize(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\xulrunner"); + catch (Exception ex) + { + Log.Debug("BrowseTheWeb | Exception on init Xpcom : " + ex.Message, new object[0]); + } } private void Setup_Load(object sender, EventArgs e) Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.suo =================================================================== (Binary files differ) Modified: trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.suo =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2012-03-12 19:34:34
|
Revision: 4465 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4465&view=rev Author: doskabouter Date: 2012-03-12 19:34:28 +0000 (Mon, 12 Mar 2012) Log Message: ----------- deleted user-specific files Removed Paths: ------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.suo trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.csproj.user trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.suo Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user 2012-03-05 20:45:05 UTC (rev 4464) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj.user 2012-03-12 19:34:28 UTC (rev 4465) @@ -1,9 +0,0 @@ -<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> - </PropertyGroup> - <PropertyGroup> - <ProjectView>ProjectFiles</ProjectView> - </PropertyGroup> -</Project> \ No newline at end of file Deleted: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.suo =================================================================== (Binary files differ) Deleted: trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.csproj.user =================================================================== --- trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.csproj.user 2012-03-05 20:45:05 UTC (rev 4464) +++ trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.csproj.user 2012-03-12 19:34:28 UTC (rev 4465) @@ -1,16 +0,0 @@ -<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <PublishUrlHistory> - </PublishUrlHistory> - <InstallUrlHistory> - </InstallUrlHistory> - <SupportUrlHistory> - </SupportUrlHistory> - <UpdateUrlHistory> - </UpdateUrlHistory> - <BootstrapperUrlHistory> - </BootstrapperUrlHistory> - <FallbackCulture>de-DE</FallbackCulture> - <VerifyUploadedFiles>false</VerifyUploadedFiles> - </PropertyGroup> -</Project> \ No newline at end of file Deleted: trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.suo =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dos...@us...> - 2012-04-04 21:12:52
|
Revision: 4470 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4470&view=rev Author: doskabouter Date: 2012-04-04 21:12:44 +0000 (Wed, 04 Apr 2012) Log Message: ----------- - skybound.gecko now on 3.5 also - rework of configuration settings - added pageup/pagedown functionality 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/Setup.Designer.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.cs trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.resx trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/Skybound.Gecko.csproj Added Paths: ----------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2012-04-02 12:04:32 UTC (rev 4469) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2012-04-04 21:12:44 UTC (rev 4470) @@ -145,6 +145,7 @@ <DesignTime>True</DesignTime> <DependentUpon>Resources.resx</DependentUpon> </Compile> + <Compile Include="Settings.cs" /> <Compile Include="Setup.cs"> <SubType>Form</SubType> </Compile> Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2012-04-02 12:04:32 UTC (rev 4469) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIBookmark.cs 2012-04-04 21:12:44 UTC (rev 4470) @@ -46,8 +46,6 @@ [SkinControlAttribute(3)] protected GUISortButtonControl btnSortBy = null; - private static string view = string.Empty; - public override int GetID { get @@ -67,27 +65,10 @@ protected override void OnPageLoad() { - string dir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config); - - view = "Large icons"; - using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(dir + "\\MediaPortal.xml")) - { - view = xmlreader.GetValueAsString("btWeb", "bookmark", "Large icons"); - } - LoadFacade(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", ""); Bookmark.InitCachePath(); base.OnPageLoad(); } - protected override void OnPageDestroy(int new_windowId) - { - string dir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config); - using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(dir + "\\MediaPortal.xml")) - { - xmlwriter.SetValue("btWeb", "bookmark", view); - } - base.OnPageDestroy(new_windowId); - } protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType) { if (actionType == MediaPortal.GUI.Library.Action.ActionType.ACTION_SELECT_ITEM) @@ -112,32 +93,21 @@ if (control == btnViewAs) { - switch (view) - { - case "Small icons": - view = "Large icons"; - break; - case "Large icons": - view = "List view"; - break; - case "List view": - view = "Small icons"; - break; - } + Settings.Instance.View++; + if (Settings.Instance.View > GUIFacadeControl.Layout.LargeIcons) + Settings.Instance.View = GUIFacadeControl.Layout.List; string strLine = string.Empty; - switch (view) + facade.CurrentLayout = Settings.Instance.View; + switch (Settings.Instance.View) { - case "Small icons": - facade.CurrentLayout = GUIFacadeControl.Layout.SmallIcons; + case GUIFacadeControl.Layout.SmallIcons: strLine = GUILocalizeStrings.Get(100); break; - case "Large icons": - facade.CurrentLayout = GUIFacadeControl.Layout.LargeIcons; + case GUIFacadeControl.Layout.LargeIcons: strLine = GUILocalizeStrings.Get(417); break; - case "List view": - facade.CurrentLayout = GUIFacadeControl.Layout.List; + case GUIFacadeControl.Layout.List: strLine = GUILocalizeStrings.Get(101); break; } @@ -147,18 +117,7 @@ public void LoadFacade(string Path, string Folder) { - switch (view) - { - case "Small icons": - facade.CurrentLayout = GUIFacadeControl.Layout.SmallIcons; - break; - case "Large icons": - facade.CurrentLayout = GUIFacadeControl.Layout.LargeIcons; - break; - case "List view": - facade.CurrentLayout = GUIFacadeControl.Layout.List; - break; - } + facade.CurrentLayout = Settings.Instance.View; facade.Clear(); GUIListItem item = new GUIListItem(); Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-02 12:04:32 UTC (rev 4469) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-04 21:12:44 UTC (rev 4470) @@ -70,40 +70,15 @@ private int linkTime = 0; private System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); - private bool usehome = false; - private string homepage = string.Empty; - private int remoteTime = 0; - private string pluginName = "Browse Web"; - private bool blankBrowser = false; - private bool statusBar = true; - private bool osd = false; - private bool windowed = false; - private bool useMouse = false; - private bool zoomPage = false; - private bool zoomDomain = false; private string lastDomain = string.Empty; - private bool cacheThumbs = false; - private bool remote = false; - private string remote_confirm = string.Empty; - private string remote_bookmark = string.Empty; - private string remote_zoom_in = string.Empty; - private string remote_zoom_out = string.Empty; - private string remote_status = string.Empty; - - private bool useProxy = false; - private string Server = string.Empty; - private int Port = 8080; - - private float defaultZoom = 1.0f; private float zoom = 1.0f; - private float font = 1.0f; + private Settings settings = Settings.Instance; public static bool ParameterSupported = false; public static string Parameter = string.Empty; public static string loadFav = string.Empty; - private string lastUrl = string.Empty; #endregion @@ -127,7 +102,7 @@ } public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) { - strButtonText = pluginName; + strButtonText = settings.PluginName; strButtonImage = String.Empty; strButtonImageFocus = String.Empty; strPictureImage = @"hover_browsetheweb.png"; @@ -201,7 +176,7 @@ } #endregion - LoadSettings(); + TrySetProxy(); BookmarkXml.AddFolder(Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config) + "\\bookmarks.xml", "Saved by MP"); @@ -245,7 +220,7 @@ protected override void OnPageLoad() { - GUIPropertyManager.SetProperty("#currentmodule", pluginName); + GUIPropertyManager.SetProperty("#currentmodule", settings.PluginName); try { @@ -255,7 +230,7 @@ GUIPropertyManager.SetProperty("#btWeb.linkid", ""); linkId = string.Empty; - if (useMouse) + if (settings.UseMouse) { MyLog.debug("Mouse support is enabled"); GUIGraphicsContext.MouseSupport = true; @@ -270,7 +245,7 @@ #region init browser webBrowser.Visible = true; - if (!useMouse) webBrowser.Enabled = false; + if (!settings.UseMouse) webBrowser.Enabled = false; else webBrowser.Enabled = true; webBrowser.Dock = System.Windows.Forms.DockStyle.None; @@ -285,17 +260,17 @@ webBrowser.DomKeyDown += new GeckoDomKeyEventHandler(webBrowser_DomKeyDown); webBrowser.DomClick += new GeckoDomEventHandler(webBrowser_DomClick); - if (statusBar) + if (settings.StatusBar) webBrowser.Size = new System.Drawing.Size(GUIGraphicsContext.form.Width, GUIGraphicsContext.form.Height - 100); else webBrowser.Size = new System.Drawing.Size(GUIGraphicsContext.form.Width, GUIGraphicsContext.form.Height); - MyLog.debug("set zoom size to " + font + "/" + zoom); + MyLog.debug("set zoom size to " + settings.FontZoom + "/" + zoom); - webBrowser.Window.TextZoom = font; + webBrowser.Window.TextZoom = settings.FontZoom; webBrowser.Zoom = zoom; - if (windowed) + if (settings.Windowed) { MyLog.debug("switch to windowed fullscreen mode"); GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SWITCH_FULL_WINDOWED, 0, 0, 0, 0, 0, null); @@ -306,10 +281,10 @@ if (webBrowser.Document.Domain == string.Empty) { - if ((usehome) && (string.IsNullOrEmpty(loadFav))) + if ((settings.UseHome) && (string.IsNullOrEmpty(loadFav))) { - webBrowser.Navigate(homepage); - MyLog.debug("load home page " + homepage); + webBrowser.Navigate(settings.HomePage); + MyLog.debug("load home page " + settings.HomePage); } } @@ -329,7 +304,7 @@ timer.Tick += new EventHandler(timer_Tick); timer.Start(); - if (useMouse) + if (settings.UseMouse) GUIGraphicsContext.form.Controls["BrowseTheWeb"].Select(); } catch (Exception ex) @@ -345,12 +320,13 @@ { if (new_windowId != 54537688) { // not if you got favs - if (blankBrowser) + if (settings.BlankBrowser) { webBrowser.Navigate("about:blank"); MyLog.debug("blank on destroy"); } } + settings.SaveToXml(false); webBrowser.Visible = false; GUIGraphicsContext.form.Focus(); @@ -367,64 +343,16 @@ base.OnPageDestroy(new_windowId); } - private void LoadSettings() - { - string dir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config); - using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(dir + "\\MediaPortal.xml")) - { - usehome = xmlreader.GetValueAsBool("btWeb", "usehome", true); - homepage = xmlreader.GetValueAsString("btWeb", "homepage", "http://team-mediaportal.com"); - remoteTime = xmlreader.GetValueAsInt("btWeb", "remotetime", 15); - pluginName = xmlreader.GetValueAsString("btWeb", "name", "Browse Web"); - blankBrowser = xmlreader.GetValueAsBool("btWeb", "blank", false); - statusBar = xmlreader.GetValueAsBool("btWeb", "status", true); - osd = xmlreader.GetValueAsBool("btWeb", "osd", true); - windowed = xmlreader.GetValueAsBool("btWeb", "window", false); - useMouse = xmlreader.GetValueAsBool("btWeb", "mouse", false); - - defaultZoom = (float)xmlreader.GetValueAsInt("btWeb", "zoom", 100) / 100; - zoom = defaultZoom; - font = (float)xmlreader.GetValueAsInt("btWeb", "font", 100) / 100; - zoomPage = xmlreader.GetValueAsBool("btWeb", "page", true); - zoomDomain = xmlreader.GetValueAsBool("btWeb", "domain", false); - - cacheThumbs = xmlreader.GetValueAsBool("btWeb", "cachethumbs", false); - - remote = xmlreader.GetValueAsBool("btWeb", "remote", false); - - remote_confirm = xmlreader.GetValueAsString("btWeb", "key_1", "ACTION_SELECT_ITEM"); - remote_bookmark = xmlreader.GetValueAsString("btWeb", "key_2", "ACTION_SHOW_INFO"); - remote_zoom_in = xmlreader.GetValueAsString("btWeb", "key_3", "ACTION_PAGE_DOWN"); - remote_zoom_out = xmlreader.GetValueAsString("btWeb", "key_4", "ACTION_PAGE_UP"); - remote_status = xmlreader.GetValueAsString("btWeb", "key_5", "ACTION_SHOW_GUI"); - - lastUrl = xmlreader.GetValueAsString("btWeb", "lastUrl", string.Empty); - - useProxy = xmlreader.GetValueAsBool("btWeb", "proxy", false); - Server = xmlreader.GetValueAsString("btWeb", "proxy_server", "127.0.0.1"); - Port = xmlreader.GetValueAsInt("btWeb", "proxy_port", 8888); - TrySetProxy(); - } - } - private void SaveSettings() - { - string dir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config); - using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(dir + "\\MediaPortal.xml")) - { - xmlwriter.SetValue("btWeb", "lastUrl", lastUrl); - } - } - private void TrySetProxy() { try { - if (useProxy) + if (settings.UseProxy) MyLog.debug("use proxy settings"); else MyLog.debug("no proxy selected"); - SetProxy(Server, Port, useProxy); + SetProxy(settings.Server, settings.Port, settings.UseProxy); } catch (Exception ex) { @@ -446,12 +374,12 @@ private void timer_Tick(object sender, EventArgs e) { - if (useMouse) + if (settings.UseMouse) Cursor.Show(); if (linkId != string.Empty) { - if (osd) + if (settings.OSD) { osd_linkID.Visible = true; osd_linkID.BringToFront(); @@ -464,7 +392,7 @@ osd_linkID.Visible = false; } - if (linkTime > remoteTime) + if (linkTime > settings.RemoteTime) { linkId = string.Empty; linkTime = 0; @@ -487,7 +415,7 @@ GUIPropertyManager.SetProperty("#btWeb.linkid", linkId); #region remote diagnostic - if (remote) + if (settings.Remote) { if (action.wID != MediaPortal.GUI.Library.Action.ActionType.ACTION_KEY_PRESSED) GUIPropertyManager.SetProperty("#btWeb.status", DateTime.Now.ToLongTimeString() + " : " + @@ -498,13 +426,12 @@ } #endregion - string strAction = action.wID.ToString(); #region selectable buttons - if (strAction == remote_confirm) + if (action.wID == settings.Remote_Confirm) { if (!mouse.Visible) { - if (!useMouse) + if (!settings.UseMouse) { if (linkId != string.Empty) @@ -538,29 +465,37 @@ mouse.BringToFront(); } } - if (strAction == remote_bookmark) + if (action.wID == settings.Remote_Bookmark) { GUIWindowManager.ActivateWindow(54537688); return; } - if ((strAction == remote_zoom_in) || + if ((action.wID == settings.Remote_Zoom_In) || (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_MUSIC_FORWARD)) { OnZoomIn(); } - if ((strAction == remote_zoom_out) || + if ((action.wID == settings.Remote_Zoom_Out) || (action.wID == MediaPortal.GUI.Library.Action.ActionType.ACTION_MUSIC_REWIND)) { OnZoomOut(); } - if (strAction == remote_status) + if (action.wID == settings.Remote_Status) { - statusBar = !statusBar; - if (statusBar) + settings.StatusBar = !settings.StatusBar; + if (settings.StatusBar) webBrowser.Size = new System.Drawing.Size(GUIGraphicsContext.form.Width, GUIGraphicsContext.form.Height - 100); else webBrowser.Size = new System.Drawing.Size(GUIGraphicsContext.form.Width, GUIGraphicsContext.form.Height); } + if (action.wID == settings.Remote_PageUp) + { + OnPageUp(); + } + if (action.wID == settings.Remote_PageDown) + { + OnPageDown(); + } #endregion switch (action.wID) @@ -570,7 +505,7 @@ break; } case MediaPortal.GUI.Library.Action.ActionType.ACTION_MOUSE_MOVE: - if (useMouse) + if (settings.UseMouse) { } @@ -590,7 +525,7 @@ } break; case MediaPortal.GUI.Library.Action.ActionType.ACTION_KEY_PRESSED: - if (!useMouse) + if (!settings.UseMouse) { linkTime = 0; MyLog.debug("action key press=" + action.m_key.KeyChar); @@ -622,24 +557,24 @@ OnEnterNewLink(); return; case MediaPortal.GUI.Library.Action.ActionType.ACTION_PAUSE: - webBrowser.Navigate(homepage); - MyLog.debug("load home page " + homepage); - if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "go to homepage"); + webBrowser.Navigate(settings.HomePage); + MyLog.debug("load home page " + settings.HomePage); + if (!settings.Remote) GUIPropertyManager.SetProperty("#btWeb.status", "go to homepage"); return; case MediaPortal.GUI.Library.Action.ActionType.ACTION_STOP: webBrowser.Navigate("about:blank"); - if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "Stop"); + if (!settings.Remote) GUIPropertyManager.SetProperty("#btWeb.status", "Stop"); return; case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREV_ITEM: case MediaPortal.GUI.Library.Action.ActionType.ACTION_REWIND: webBrowser.GoBack(); - if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "go backward"); + if (!settings.Remote) GUIPropertyManager.SetProperty("#btWeb.status", "go backward"); MyLog.debug("navigate go back"); return; case MediaPortal.GUI.Library.Action.ActionType.ACTION_NEXT_ITEM: case MediaPortal.GUI.Library.Action.ActionType.ACTION_FORWARD: webBrowser.GoForward(); - if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "go forward"); + if (!settings.Remote) GUIPropertyManager.SetProperty("#btWeb.status", "go forward"); MyLog.debug("navigate go forward"); return; case MediaPortal.GUI.Library.Action.ActionType.ACTION_RECORD: @@ -675,7 +610,7 @@ private void webBrowser_DomKeyDown(object sender, GeckoDomKeyEventArgs e) { - if (useMouse) + if (settings.UseMouse) { //System.Diagnostics.Debug.WriteLine("DOM " + e.KeyCode.ToString()); @@ -706,7 +641,7 @@ } void webBrowser_DomClick(object sender, GeckoDomEventArgs e) { - if (useMouse) + if (settings.UseMouse) { // this is a workarround until i know what wrong on the links... GeckoWebBrowser g = (GeckoWebBrowser)sender; @@ -737,9 +672,9 @@ GUIGraphicsContext.form.Focus(); string selectedUrl = "http://"; - if (lastUrl != string.Empty) + if (settings.LastUrl != string.Empty) { - selectedUrl = lastUrl; + selectedUrl = settings.LastUrl; } if (ShowKeyboard(ref selectedUrl, false) == System.Windows.Forms.DialogResult.OK) @@ -749,15 +684,14 @@ webBrowser.Navigate(selectedUrl); MyLog.debug("navigate to " + selectedUrl); - lastUrl = selectedUrl; - SaveSettings(); + settings.LastUrl = selectedUrl; } else ShowAlert("Wrong link ?", " The link you entered seems to be not valid.", "Input:", selectedUrl); } webBrowser.Visible = true; - if (useMouse) + if (settings.UseMouse) GUIGraphicsContext.form.Controls["BrowseTheWeb"].Select(); } @@ -807,20 +741,20 @@ } webBrowser.Visible = true; - if (useMouse) + if (settings.UseMouse) GUIGraphicsContext.form.Controls["BrowseTheWeb"].Select(); } private void OnZoomIn() { if (zoom < 3) zoom += 0.1f; webBrowser.Zoom = zoom; - if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); + if (!settings.Remote) GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); } private void OnZoomOut() { if (zoom > 0.1f) zoom -= 0.1f; webBrowser.Zoom = zoom; - if (!remote) GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); + if (!settings.Remote) GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); } private void OnMoveLeft() { @@ -870,6 +804,34 @@ Cursor.Position = new Point(mouse.Location.X, mouse.Location.Y); } } + private void OnPageUp() + { + if (!mouse.Visible) + { + int height = webBrowser.Size.Height; + if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY - height + 100); + } + 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); + } + } + private void OnPageDown() + { + if (!mouse.Visible) + { + int height = webBrowser.Size.Height; + if (webBrowser.Window != null) ScrollTo(webBrowser.Window.ScrollX, webBrowser.Window.ScrollY + height - 100); + } + 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); + } + } private Bitmap CopyBitmap(Bitmap srcBitmap, Rectangle section) { @@ -917,7 +879,7 @@ GUIPropertyManager.SetProperty("#btWeb.status", str); #endregion - if (!useMouse) + if (!settings.UseMouse) { #region add links to page _htmlLinkNumbers.Clear(); @@ -1039,19 +1001,19 @@ } #region reset zoom - if (zoomPage) + if (settings.ZoomPage) { - webBrowser.Zoom = defaultZoom; - zoom = defaultZoom; + webBrowser.Zoom = settings.DefaultZoom; + zoom = settings.DefaultZoom; GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); } - if (zoomDomain) + if (settings.ZoomDomain) { if (lastDomain != webBrowser.Document.Domain) { { - webBrowser.Zoom = defaultZoom; - zoom = defaultZoom; + webBrowser.Zoom = settings.DefaultZoom; + zoom = settings.DefaultZoom; GUIPropertyManager.SetProperty("#btWeb.status", "Zoom set to " + (int)(zoom * 100)); } } Added: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs (rev 0) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Settings.cs 2012-04-04 21:12:44 UTC (rev 4470) @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using MediaPortal.GUI.Library; +using MediaPortal.Dialogs; +using MediaPortal.Util; +using MediaPortal.Configuration; +using Action = MediaPortal.GUI.Library.Action; + +namespace BrowseTheWeb +{ + public class Settings + { + public bool UseHome { get; set; } + public string HomePage { get; set; } + public int RemoteTime { get; set; } + public string PluginName { get; set; } + public bool BlankBrowser { get; set; } + public bool StatusBar { get; set; } + public bool OSD { get; set; } + public bool Windowed { get; set; } + public bool UseMouse { get; set; } + + public int DefaultZoom_percentage { get; set; } + public int FontZoom_percentage { get; set; } + public float FontZoom { get { return FontZoom_percentage / 100; } } + public float DefaultZoom { get { return DefaultZoom_percentage / 100; } } + + public bool ZoomPage { get; set; } + public bool ZoomDomain { get; set; } + public bool UseThumbs { get; set; } + public bool CacheThumbs { get; set; } + public bool Remote { get; set; } + public Action.ActionType Remote_Confirm { get; set; } + public Action.ActionType Remote_Bookmark { get; set; } + public Action.ActionType Remote_Zoom_In { get; set; } + public Action.ActionType Remote_Zoom_Out { get; set; } + public Action.ActionType Remote_Status { get; set; } + public Action.ActionType Remote_PageUp { get; set; } + public Action.ActionType Remote_PageDown { get; set; } + + public static Action.ActionType Default_Remote_Confirm = Action.ActionType.ACTION_SELECT_ITEM; + public static Action.ActionType Default_Remote_Bookmark = Action.ActionType.ACTION_SHOW_INFO; + public static Action.ActionType Default_Remote_Zoom_In = Action.ActionType.ACTION_ZOOM_IN; + public static Action.ActionType Default_Remote_Zoom_Out = Action.ActionType.ACTION_ZOOM_OUT; + public static Action.ActionType Default_Remote_Status = Action.ActionType.ACTION_SHOW_GUI; + public static Action.ActionType Default_Remote_PageUp = Action.ActionType.ACTION_PAGE_UP; + public static Action.ActionType Default_Remote_PageDown = Action.ActionType.ACTION_PAGE_DOWN; + + public string LastUrl { get; set; } + public bool UseProxy { get; set; } + public string Server { get; set; } + public int Port { get; set; } + public GUIFacadeControl.Layout View { get; set; } + + private const string section = "btweb"; + + #region Singleton + private static Settings _Instance = null; + public static Settings Instance + { + get + { + if (_Instance == null) _Instance = new Settings(); + return _Instance; + } + } + private Settings() { LoadFromXml(); } + #endregion + + private void LoadFromXml() + { + string dir = Config.GetFolder(Config.Dir.Config); + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(dir + "\\MediaPortal.xml")) + { + UseHome = xmlreader.GetValueAsBool(section, "usehome", true); + HomePage = xmlreader.GetValueAsString(section, "homepage", "http://team-mediaportal.com"); + RemoteTime = xmlreader.GetValueAsInt(section, "remotetime", 15); + PluginName = xmlreader.GetValueAsString(section, "name", "Browse Web"); + BlankBrowser = xmlreader.GetValueAsBool(section, "blank", false); + StatusBar = xmlreader.GetValueAsBool(section, "status", true); + OSD = xmlreader.GetValueAsBool(section, "osd", true); + Windowed = xmlreader.GetValueAsBool(section, "window", false); + UseMouse = xmlreader.GetValueAsBool(section, "mouse", false); + + DefaultZoom_percentage = xmlreader.GetValueAsInt(section, "zoom", 100); // /100 + FontZoom_percentage = xmlreader.GetValueAsInt(section, "font", 100);// /100 + ZoomPage = xmlreader.GetValueAsBool(section, "page", true); + ZoomDomain = xmlreader.GetValueAsBool(section, "domain", false); + + UseThumbs = xmlreader.GetValueAsBool(section, "usethumbs", true); + CacheThumbs = xmlreader.GetValueAsBool(section, "cachethumbs", false); + + Remote = xmlreader.GetValueAsBool(section, "remote", false); + + Remote_Confirm = GetActionFromString(xmlreader, "remote_confirm", Default_Remote_Confirm); + Remote_Bookmark = GetActionFromString(xmlreader, "remote_bookmark", Default_Remote_Bookmark); + Remote_Zoom_In = GetActionFromString(xmlreader, "remote_zoom_in", Default_Remote_Zoom_In); + Remote_Zoom_Out = GetActionFromString(xmlreader, "remote_zoom_out", Default_Remote_Zoom_Out); + Remote_Status = GetActionFromString(xmlreader, "remote_status", Default_Remote_Status); + Remote_PageUp = GetActionFromString(xmlreader, "remote_pageup", Default_Remote_PageUp); + Remote_PageDown = GetActionFromString(xmlreader, "remote_pagedown", Default_Remote_PageDown); + + LastUrl = xmlreader.GetValueAsString(section, "lastUrl", 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); + 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); + } + } + + private Action.ActionType GetActionFromString(MediaPortal.Profile.Settings xmlReader, string entry, Action.ActionType defaultAction) + { + return (Action.ActionType)Enum.Parse(typeof(Action.ActionType), xmlReader.GetValueAsString(section, entry, defaultAction.ToString()), true); + } + + public void SaveToXml(bool fromSetup) + { + string dir = Config.GetFolder(MediaPortal.Configuration.Config.Dir.Config); + using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(dir + "\\MediaPortal.xml")) + { + if (fromSetup) + { + xmlwriter.SetValueAsBool(section, "usehome", UseHome); + xmlwriter.SetValue(section, "homepage", HomePage); + xmlwriter.SetValue(section, "remotetime", RemoteTime); + xmlwriter.SetValue(section, "name", PluginName); + xmlwriter.SetValueAsBool(section, "blank", BlankBrowser); + xmlwriter.SetValueAsBool(section, "status", StatusBar); + xmlwriter.SetValueAsBool(section, "osd", OSD); + xmlwriter.SetValueAsBool(section, "window", Windowed); + xmlwriter.SetValueAsBool(section, "mouse", UseMouse); + + xmlwriter.SetValue(section, "zoom", DefaultZoom_percentage); + xmlwriter.SetValue(section, "font", FontZoom_percentage); + xmlwriter.SetValueAsBool(section, "page", ZoomPage); + xmlwriter.SetValueAsBool(section, "domain", ZoomDomain); + + xmlwriter.SetValueAsBool(section, "usethumbs", UseThumbs); + xmlwriter.SetValueAsBool(section, "cachethumbs", CacheThumbs); + + xmlwriter.SetValueAsBool(section, "remote", Remote); + xmlwriter.SetValue(section, "remote_confirm", Remote_Confirm); + xmlwriter.SetValue(section, "remote_bookmark", Remote_Bookmark); + xmlwriter.SetValue(section, "remote_zoom_in", Remote_Zoom_In); + xmlwriter.SetValue(section, "remote_zoom_out", Remote_Zoom_Out); + xmlwriter.SetValue(section, "remote_status", Remote_Status); + xmlwriter.SetValue(section, "remote_pageup", Remote_PageUp); + xmlwriter.SetValue(section, "remote_pagedown", Remote_PageDown); + + xmlwriter.SetValue(section, "bookmark", View); + + xmlwriter.SetValueAsBool(section, "proxy", UseProxy); + xmlwriter.SetValue(section, "proxy_server", Server); + xmlwriter.SetValue(section, "proxy_port", Port); + } + else + { + xmlwriter.SetValue(section, "bookmark", View); + xmlwriter.SetValue(section, "lastUrl", LastUrl); + } + } + } + + } +} Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2012-04-02 12:04:32 UTC (rev 4469) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/Setup.Designer.cs 2012-04-04 21:12:44 UTC (rev 4470) @@ -1,203 +1,207 @@ namespace BrowseTheWeb { - partial class Setup - { - /// <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) + partial class Setup { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; - #region Windows Form Designer generated code + /// <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); + } - /// <summary> - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// </summary> - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Setup)); - this.treeView1 = new System.Windows.Forms.TreeView(); - this.imageList1 = new System.Windows.Forms.ImageList(this.components); - this.btnSave = new System.Windows.Forms.Button(); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.titelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator(); - this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator(); - this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.btnCancel = new System.Windows.Forms.Button(); - this.txtLink = new System.Windows.Forms.Label(); - this.txtHome = new System.Windows.Forms.TextBox(); - this.chkHome = new System.Windows.Forms.CheckBox(); - this.tabControl1 = new System.Windows.Forms.TabControl(); - this.tabPage1 = new System.Windows.Forms.TabPage(); - this.groupBox5 = new System.Windows.Forms.GroupBox(); - this.chkMouse = new System.Windows.Forms.CheckBox(); - this.chkWindowed = new System.Windows.Forms.CheckBox(); - this.chkOSD = new System.Windows.Forms.CheckBox(); - this.chkStatus = new System.Windows.Forms.CheckBox(); - this.chkBlank = new System.Windows.Forms.CheckBox(); - this.txtName = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.txtRemote = new System.Windows.Forms.Label(); - 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(); - this.groupBox6 = new System.Windows.Forms.GroupBox(); - this.optNoZoom = new System.Windows.Forms.RadioButton(); - this.optZoomDomain = new System.Windows.Forms.RadioButton(); - this.optZoomPage = new System.Windows.Forms.RadioButton(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.txtFont = new System.Windows.Forms.Label(); - this.trkFont = new System.Windows.Forms.TrackBar(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.txtZoom = new System.Windows.Forms.Label(); - this.trkZoom = new System.Windows.Forms.TrackBar(); - this.tabPage3 = new System.Windows.Forms.TabPage(); - this.btnImportFF = new System.Windows.Forms.Button(); - this.btnImportIE = new System.Windows.Forms.Button(); - this.label7 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.tabPage5 = new System.Windows.Forms.TabPage(); - this.groupBox8 = new System.Windows.Forms.GroupBox(); - this.txtHttpPort = new System.Windows.Forms.TextBox(); - this.txtHttpServer = new System.Windows.Forms.TextBox(); - this.label6 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.chkProxy = new System.Windows.Forms.CheckBox(); - this.tabPage4 = new System.Windows.Forms.TabPage(); - this.btnDefault = new System.Windows.Forms.Button(); - this.groupBox11 = new System.Windows.Forms.GroupBox(); - this.label33 = new System.Windows.Forms.Label(); - this.label34 = new System.Windows.Forms.Label(); - this.cmbZoomOut = new System.Windows.Forms.ComboBox(); - this.label31 = new System.Windows.Forms.Label(); - this.label32 = new System.Windows.Forms.Label(); - this.cmbZoomIn = new System.Windows.Forms.ComboBox(); - this.groupBox10 = new System.Windows.Forms.GroupBox(); - this.label35 = new System.Windows.Forms.Label(); - this.cmbShowBookmarks = new System.Windows.Forms.ComboBox(); - this.label29 = new System.Windows.Forms.Label(); - this.label30 = new System.Windows.Forms.Label(); - this.label27 = new System.Windows.Forms.Label(); - this.label28 = new System.Windows.Forms.Label(); - this.label25 = new System.Windows.Forms.Label(); - this.label26 = new System.Windows.Forms.Label(); - this.label23 = new System.Windows.Forms.Label(); - this.label24 = new System.Windows.Forms.Label(); - this.label13 = new System.Windows.Forms.Label(); - this.label14 = new System.Windows.Forms.Label(); - this.label11 = new System.Windows.Forms.Label(); - this.label12 = new System.Windows.Forms.Label(); - this.groupBox9 = new System.Windows.Forms.GroupBox(); - this.cmbStatusBar = new System.Windows.Forms.ComboBox(); - this.label10 = new System.Windows.Forms.Label(); - this.label9 = new System.Windows.Forms.Label(); - this.label8 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.cmbConfirmLink = new System.Windows.Forms.ComboBox(); - this.chkRemote = new System.Windows.Forms.CheckBox(); - this.label15 = new System.Windows.Forms.Label(); - this.label16 = new System.Windows.Forms.Label(); - this.label17 = new System.Windows.Forms.Label(); - this.label18 = new System.Windows.Forms.Label(); - this.comboBox3 = new System.Windows.Forms.ComboBox(); - this.label19 = new System.Windows.Forms.Label(); - this.label20 = new System.Windows.Forms.Label(); - this.label21 = new System.Windows.Forms.Label(); - this.label22 = new System.Windows.Forms.Label(); - this.comboBox4 = new System.Windows.Forms.ComboBox(); - this.checkBox1 = new System.Windows.Forms.CheckBox(); - this.btnImportChr = new System.Windows.Forms.Button(); - this.contextMenuStrip1.SuspendLayout(); - this.tabControl1.SuspendLayout(); - this.tabPage1.SuspendLayout(); - this.groupBox5.SuspendLayout(); - this.groupBox4.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.trkRemote)).BeginInit(); - this.groupBox3.SuspendLayout(); - this.tabPage2.SuspendLayout(); - this.groupBox12.SuspendLayout(); - this.groupBox7.SuspendLayout(); - this.groupBox6.SuspendLayout(); - this.groupBox2.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.trkFont)).BeginInit(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.trkZoom)).BeginInit(); - this.tabPage3.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.tabPage5.SuspendLayout(); - this.groupBox8.SuspendLayout(); - this.tabPage4.SuspendLayout(); - this.groupBox11.SuspendLayout(); - this.groupBox10.SuspendLayout(); - this.groupBox9.SuspendLayout(); - this.SuspendLayout(); - // - // treeView1 - // - this.treeView1.AllowDrop = true; - this.treeView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.treeView1.ImageIndex = 0; - this.treeView1.ImageList = this.imageList1; - this.treeView1.Location = new System.Drawing.Point(6, 34); - this.treeView1.Name = "treeView1"; - this.treeView1.SelectedImageIndex = 0; - this.treeView1.Size = new System.Drawing.Size(539, 313); - this.treeView1.TabIndex = 9; - this.treeView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeView1_DragDrop); - this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); - this.treeView1.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeView1_DragEnter); - this.treeView1.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView1_ItemDrag); - this.treeView1.Click += new System.EventHandler(this.treeView1_Click); - // - // imageList1 - // - this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); - this.imageList1.TransparentColor = System.Drawing.Color.Transparent; - this.imageList1.Images.SetKeyName(0, "file-icon.png"); - this.imageList1.Images.SetKeyName(1, "folder-icon.png"); - this.imageList1.Images.SetKeyName(2, "fav-b-icon.png"); - // - // btnSave - // - this.btnSave.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnSave.Location = new System.Drawing.Point(12, 523); - this.btnSave.Name = "btnSave"; - this.btnSave.Size = new System.Drawing.Size(104, 38); - this.btnSave.TabIndex = 10; - this.btnSave.Text = "Save"; - this.btnSave.UseVisualStyleBackColor = true; - this.btnSave.Click += new System.EventHandler(this.btnSave_Click); - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + #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.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Setup)); + this.treeView1 = new System.Windows.Forms.TreeView(); + this.imageList1 = new System.Windows.Forms.ImageList(this.components); + this.btnOk = new System.Windows.Forms.Button(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.titelToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator(); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator(); + this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.btnCancel = new System.Windows.Forms.Button(); + this.txtLink = new System.Windows.Forms.Label(); + this.txtHome = new System.Windows.Forms.TextBox(); + this.chkHome = new System.Windows.Forms.CheckBox(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.chkMouse = new System.Windows.Forms.CheckBox(); + this.chkWindowed = new System.Windows.Forms.CheckBox(); + this.chkOSD = new System.Windows.Forms.CheckBox(); + this.chkStatus = new System.Windows.Forms.CheckBox(); + this.chkBlank = new System.Windows.Forms.CheckBox(); + this.txtName = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.txtRemote = new System.Windows.Forms.Label(); + 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(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.optNoZoom = new System.Windows.Forms.RadioButton(); + this.optZoomDomain = new System.Windows.Forms.RadioButton(); + this.optZoomPage = new System.Windows.Forms.RadioButton(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.txtFont = new System.Windows.Forms.Label(); + this.trkFont = new System.Windows.Forms.TrackBar(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.txtZoom = new System.Windows.Forms.Label(); + this.trkZoom = new System.Windows.Forms.TrackBar(); + this.tabPage3 = new System.Windows.Forms.TabPage(); + this.btnImportChr = new System.Windows.Forms.Button(); + this.btnImportFF = new System.Windows.Forms.Button(); + this.btnImportIE = new System.Windows.Forms.Button(); + this.label7 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.tabPage5 = new System.Windows.Forms.TabPage(); + this.groupBox8 = new System.Windows.Forms.GroupBox(); + this.txtHttpPort = new System.Windows.Forms.TextBox(); + this.txtHttpServer = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.chkProxy = new System.Windows.Forms.CheckBox(); + this.tabPage4 = new System.Windows.Forms.TabPage(); + this.btnDefault = new System.Windows.Forms.Button(); + this.groupBox11 = new System.Windows.Forms.GroupBox(); + this.cmbPageDown = new System.Windows.Forms.ComboBox(); + this.cmbPageUp = new System.Windows.Forms.ComboBox(); + this.label37 = new System.Windows.Forms.Label(); + this.label36 = new System.Windows.Forms.Label(); + this.label33 = new System.Windows.Forms.Label(); + this.label34 = new System.Windows.Forms.Label(); + this.cmbZoomOut = new System.Windows.Forms.ComboBox(); + this.label31 = new System.Windows.Forms.Label(); + this.label32 = new System.Windows.Forms.Label(); + this.cmbZoomIn = new System.Windows.Forms.ComboBox(); + this.groupBox10 = new System.Windows.Forms.GroupBox(); + this.label35 = new System.Windows.Forms.Label(); + this.cmbShowBookmarks = new System.Windows.Forms.ComboBox(); + this.label29 = new System.Windows.Forms.Label(); + this.label30 = new System.Windows.Forms.Label(); + this.label27 = new System.Windows.Forms.Label(); + this.label28 = new System.Windows.Forms.Label(); + this.label25 = new System.Windows.Forms.Label(); + this.label26 = new System.Windows.Forms.Label(); + this.label23 = new System.Windows.Forms.Label(); + this.label24 = new System.Windows.Forms.Label(); + this.label13 = new System.Windows.Forms.Label(); + this.label14 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.groupBox9 = new System.Windows.Forms.GroupBox(); + this.cmbStatusBar = new System.Windows.Forms.ComboBox(); + this.label10 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.cmbConfirmLink = new System.Windows.Forms.ComboBox(); + this.chkRemote = new System.Windows.Forms.CheckBox(); + this.label15 = new System.Windows.Forms.Label(); + this.label16 = new System.Windows.Forms.Label(); + this.label17 = new System.Windows.Forms.Label(); + this.label18 = new System.Windows.Forms.Label(); + this.comboBox3 = new System.Windows.Forms.ComboBox(); + this.label19 = new System.Windows.Forms.Label(); + this.label20 = new System.Windows.Forms.Label(); + this.label21 = new System.Windows.Forms.Label(); + this.label22 = new System.Windows.Forms.Label(); + this.comboBox4 = new System.Windows.Forms.ComboBox(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.contextMenuStrip1.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.groupBox5.SuspendLayout(); + this.groupBox4.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.trkRemote)).BeginInit(); + this.groupBox3.SuspendLayout(); + this.tabPage2.SuspendLayout(); + this.groupBox12.SuspendLayout(); + this.groupBox7.SuspendLayout(); + this.groupBox6.SuspendLayout(); + this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.trkFont)).BeginInit(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.trkZoom)).BeginInit(); + this.tabPage3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.tabPage5.SuspendLayout(); + this.groupBox8.SuspendLayout(); + this.tabPage4.SuspendLayout(); + this.groupBox11.SuspendLayout(); + this.groupBox10.SuspendLayout(); + this.groupBox9.SuspendLayout(); + this.SuspendLayout(); + // + // treeView1 + // + this.treeView1.AllowDrop = true; + this.treeView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.treeView1.ImageIndex = 0; + this.treeView1.ImageList = this.imageList1; + this.treeView1.Location = new System.Drawing.Point(6, 34); + this.treeView1.Name = "treeView1"; + this.treeView1.SelectedImageIndex = 0; + this.treeView1.Size = new System.Drawing.Size(539, 313); + this.treeView1.TabIndex = 9; + this.treeView1.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeView1_ItemDrag); + this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); + this.treeView1.Click += new System.EventHandler(this.treeView1_Click); + this.treeView1.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeView1_DragDrop); + this.treeView1.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeView1_DragEnter); + // + // imageList1 + // + this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream"))); + this.imageList1.TransparentColor = System.Drawing.Color.Transparent; + this.imageList1.Images.SetKeyName(0, "file-icon.png"); + this.imageList1.Images.SetKeyName(1, "folder-icon.png"); + this.imageList1.Images.SetKeyName(2, "fav-b-icon.png"); + // + // btnOk + // + this.btnOk.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnOk.Location = new System.Drawing.Point(12, 523); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(104, 38); + this.btnOk.TabIndex = 10; + this.btnOk.Text = "OK"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.titelToolStripMenuItem, this.toolStripMenuItem4, this.toolStripMenuItem1, @@ -206,1172 +210,1232 @@ this.editToolStripMenuItem, this.toolStripMenuItem5, this.deleteToolStripMenuItem}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(154, 142); - this.contextMenuStrip1.MouseLeave += new System.EventHandler(this.contextMenuStrip1_MouseLeave); - // - // titelToolStripMenuItem - // - this.titelToolStripMenuItem.BackColor = System.Drawing.Color.Silver; - this.titelToolStripMenuItem.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.titelToolStripMenuItem.Name = "titelToolStripMenuItem"; - this.titelToolStripMenuItem.Size = new System.Drawing.Size(153, 24); - this.titelToolStripMenuItem.Text = "Titel"; - // - // toolStripMenuItem4 - // - this.toolStripMenuItem4.Name = "toolStripMenuItem4"; - this.toolStripMenuItem4.Size = new System.Drawing.Size(150, 6); - // - ... [truncated message content] |
From: <dos...@us...> - 2012-04-15 14:13:32
|
Revision: 4481 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4481&view=rev Author: doskabouter Date: 2012-04-15 14:13:24 +0000 (Sun, 15 Apr 2012) Log Message: ----------- - removed reference to htmlagilitypack - cleanup code - added ParentNode to GeckoNode Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/GeckoDom.cs Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2012-04-15 14:08:54 UTC (rev 4480) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2012-04-15 14:13:24 UTC (rev 4481) @@ -66,9 +66,6 @@ <Reference Include="Dialogs"> <HintPath>C:\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\Dialogs.dll</HintPath> </Reference> - <Reference Include="HtmlAgilityPack"> - <HintPath>C:\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\HtmlAgilityPack.dll</HintPath> - </Reference> <Reference Include="Ionic.Zip"> <HintPath>C:\Program Files\Team MediaPortal\MediaPortal\Ionic.Zip.dll</HintPath> </Reference> Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-15 14:08:54 UTC (rev 4480) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/GUIPlugin.cs 2012-04-15 14:13:24 UTC (rev 4481) @@ -48,13 +48,14 @@ private const int MOUSEEVENTF_LEFTUP = 0x04; private const int MOUSEEVENTF_RIGHTDOWN = 0x08; private const int MOUSEEVENTF_RIGHTUP = 0x10; + private const bool logHtml = false; #region Links 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}\" class=\"{3}\">{0}</span>"; + 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-left: 2px; max-width: 20px; max-height: 10px ! important; overflow: visible ! important; float: none ! important; display: inline;"; #endregion #region declare vars @@ -859,9 +860,44 @@ GUIPropertyManager.SetProperty("#btWeb.status", str); } } + + private void AddElements(List<GeckoElement> list, GeckoNode parent, string elName) + { + if (parent is GeckoElement && ((GeckoElement)parent).TagName.ToLowerInvariant() == elName) + list.Add((GeckoElement)parent); + foreach (GeckoNode child in parent.ChildNodes) + AddElements(list, child, elName); + } + + private List<GeckoElement> getElements(GeckoNode parent, string elName) + { + List<GeckoElement> res = new List<GeckoElement>(); + 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"); + GeckoElement newChild = after.OwnerDocument.CreateElement("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.NextSibling != null) + after.ParentNode.InsertBefore(newChild, after.NextSibling); + else + after.ParentNode.AppendChild(newChild); + return newChild; + } + private void webBrowser_DocumentCompleted(object sender, EventArgs e) { - MyLog.debug("page completetd : " + webBrowser.Url.ToString()); + MyLog.debug("page completed : " + webBrowser.Url.ToString()); try { @@ -900,7 +936,8 @@ }; if (!element.InnerHtml.Contains("gecko_id")) { - element.InnerHtml += string.Format(_span, i, "", "LINK", lastSpan.ClassName); + insertSpan(i, String.Empty, "LINK", lastSpan.ClassName, + element.LastChild == null ? element : element.LastChild); } string gb = element.GetAttribute("gb"); @@ -921,86 +958,79 @@ } GeckoElementCollection forms = webBrowser.Document.GetElementsByTagName("form"); - HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); MyLog.debug("page forms cnt : " + forms.Count); foreach (GeckoElement element in forms) { + List<GeckoElement> inps = getElements(element, "input"); string action = element.GetAttribute("action"); - doc.LoadHtml(element.InnerHtml); - foreach (HtmlAgilityPack.HtmlNode link in doc.DocumentNode.SelectNodes("//*")) + foreach (GeckoElement link in inps) { - if (link.OriginalName == "input") + string linkType = link.GetAttribute("type"); + if (!String.IsNullOrEmpty(linkType)) { - if (link.Attributes["type"] != null) + if (linkType != "hidden") { - if (link.Attributes["type"].Value != "hidden") - { - string gb = link.GetAttributeValue("gb", ""); - string id = link.GetAttributeValue("id", ""); - string name = link.GetAttributeValue("name", ""); - string outerHtml = link.OuterHtml; - if (string.IsNullOrEmpty(gb)) - { - link.SetAttributeValue("gb", "gecko_link" + i); - } - if (string.IsNullOrEmpty(id)) - { - link.SetAttributeValue("id", "gb" + i); - id = "gb" + i; - } - - if (!element.InnerHtml.Contains("gecko_id=\"" + i + "\"")) - { - string newLink = link.OuterHtml + string.Format(_span, i, action, "INPUT", ""); - element.InnerHtml = element.InnerHtml.Replace(outerHtml, newLink); - } - if (link.Attributes["type"].Value == "submit" || - link.Attributes["type"].Value == "reset" || - link.Attributes["type"].Value == "radio" || - link.Attributes["type"].Value == "image" || - link.Attributes["type"].Value == "checkbox") - { - _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.Action)); - } - else - { - 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++; - } - } - else - { - string gb = link.GetAttributeValue("gb", ""); - string id = link.GetAttributeValue("id", ""); - string name = link.GetAttributeValue("name", ""); - string outerHtml = link.OuterHtml; + string gb = link.GetAttribute("gb"); + string id = link.GetAttribute("id"); + string name = link.GetAttribute("name"); if (string.IsNullOrEmpty(gb)) { - link.SetAttributeValue("gb", "gecko_link" + i); + link.SetAttribute("gb", "gecko_link" + i); } if (string.IsNullOrEmpty(id)) { - link.SetAttributeValue("id", "gb" + i); + link.SetAttribute("id", "gb" + i); id = "gb" + i; } if (!element.InnerHtml.Contains("gecko_id=\"" + i + "\"")) { - string newLink = link.OuterHtml + string.Format(_span, i, action, "INPUT", ""); - element.InnerHtml = element.InnerHtml.Replace(outerHtml, newLink); + insertSpan(i, action, "INPUT", null, link); } - - _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); + 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 gb = link.GetAttribute("gb"); + string id = link.GetAttribute("id"); + string name = link.GetAttribute("name"); + if (string.IsNullOrEmpty(gb)) + { + link.SetAttribute("gb", "gecko_link" + i); + } + if (string.IsNullOrEmpty(id)) + { + link.SetAttribute("id", "gb" + i); + id = "gb" + i; + } + + if (!element.InnerHtml.Contains("gecko_id=\"" + i + "\"")) + { + insertSpan(i, action, "INPUT", null, link); + } + + _htmlLinkNumbers.Add(i, new HtmlLinkNumber(i, id, name, action, HtmlInputType.Input)); + i++; + } } } #endregion @@ -1026,6 +1056,13 @@ lastDomain = webBrowser.Document.Domain; } #endregion + if (logHtml) + { + using (System.IO.StreamWriter tw = new System.IO.StreamWriter(@"e:\last.html")) + { + tw.WriteLine(webBrowser.Document.DocumentElement.InnerHtml); + } + } } catch (Exception ex) { @@ -1105,27 +1142,27 @@ string result = string.Empty; if (ShowKeyboard(ref result, id.Type == HtmlInputType.InputPassword) == DialogResult.OK) { - SetInputFieldText(id.Number, result); + SetInputElementValue(webBrowser.Document, id.Number, result); } webBrowser.Visible = true; } - public void SetInputFieldText(int id, string text) + + private bool SetInputElementValue(GeckoNode parent, int geckoId, string text) { - HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); - doc.LoadHtml(webBrowser.Document.Body.InnerHtml); - - foreach (HtmlAgilityPack.HtmlNode element in doc.DocumentNode.SelectNodes("//input")) + GeckoElement el = parent as GeckoElement; + if (el != null && el.TagName.ToLowerInvariant() == "input" && el.GetAttribute("gb") == "gecko_link" + geckoId) { - string name = element.GetAttributeValue("gb", ""); - if (!string.IsNullOrEmpty(name)) + el.SetAttribute("value", text); + return true; + } + else + { + foreach (GeckoNode child in parent.ChildNodes) { - if (name == "gecko_link" + id) - { - element.SetAttributeValue("value", text); - webBrowser.Document.Body.InnerHtml = doc.DocumentNode.InnerHtml; - break; - } + if (SetInputElementValue(child, geckoId, text)) + return true; } + return false; } } Modified: trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/GeckoDom.cs =================================================================== --- trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/GeckoDom.cs 2012-04-15 14:08:54 UTC (rev 4480) +++ trunk/plugins/BrowseTheWeb/Source/Skybound.Gecko/GeckoDom.cs 2012-04-15 14:13:24 UTC (rev 4481) @@ -40,1033 +40,1038 @@ namespace Skybound.Gecko { - /// <summary> - /// Provides a base class for DOM nodes. - /// </summary> - public class GeckoNode - { - internal GeckoNode(nsIDOMNode domObject) - { - _DomObject = domObject; - } - - internal static GeckoNode Create(nsIDOMNode domObject) - { - if (domObject == null) - return null; - - nsIDOMHTMLElement element = Xpcom.QueryInterface<nsIDOMHTMLElement>(domObject); - if (element != null) - return GeckoElement.Create(element); - - nsIDOMAttr attr = Xpcom.QueryInterface<nsIDOMAttr>(domObject); - if (attr != null) - return GeckoAttribute.Create(attr); - - return new GeckoNode(domObject); - } - - /// <summary> - /// Gets the underlying XPCOM object. - /// </summary> - public object DomObject - { - get { return _DomObject; } - } - nsIDOMNode _DomObject; - - public override bool Equals(object obj) - { - if (this == obj) - return true; - else if (obj is GeckoNode) - return this.GetHashCode() == (obj as GeckoNode).GetHashCode(); - - return base.Equals(obj); - } - - public override int GetHashCode() - { - IntPtr pUnk = Marshal.GetIUnknownForObject(this._DomObject); - try - { - return pUnk.GetHashCode(); - } - finally - { - if (pUnk != IntPtr.Zero) - Marshal.Release(pUnk); - } - } - - /// <summary> - /// Gets the text contents of the node. - /// </summary> - public string TextContent - { - get { return nsString.Get(((nsIDOM3Node)_DomObject).GetTextContent); } - set { nsString.Set(((nsIDOM3Node)_DomObject).SetTextContent, value); } - } - - /// <summary> - /// Gets or sets the value of the node. - /// </summary> - public string NodeValue - { - get { return nsString.Get(((nsIDOMNode)_DomObject).GetNodeValue); } - set { nsString.Set(((nsIDOMNode)_DomObject).SetNodeValue, value); } - } - - /// <summary> - /// Gets a collection containing all child nodes of this node. - /// </summary> - public GeckoNodeCollection ChildNodes - { - get { return new GeckoNodeCollection(_DomObject.GetChildNodes()); } - } - - public GeckoNode FirstChild { get { return GeckoNode.Create(_DomObject.GetFirstChild()); } } - public GeckoNode LastChild { get { return GeckoNode.Create(_DomObject.GetLastChild()); } } - public GeckoNode NextSibling { get { return GeckoNode.Create(_DomObject.GetNextSibling()); } } - public GeckoNode PreviousSibling { get { return GeckoNode.Create(_DomObject.GetPreviousSibling()); } } - public bool HasChildNodes { get { return _DomObject.HasChildNodes(); } } - public bool HasAttributes { get { return _DomObject.HasAttributes(); } } - - public GeckoDocument OwnerDocument { get { return GeckoDocument.Create(Xpcom.QueryInterface<nsIDOMHTMLDocument>(_DomObject.GetOwnerDocument())); } } - - public GeckoNode AppendChild(GeckoNode node) - { - if (node == null) - throw new ArgumentNullException("node"); - - _DomObject.AppendChild(node._DomObject); - return node; - } - - public GeckoNode CloneNode(bool deep) - { - return GeckoNode.Create(_DomObject.CloneNode(deep)); - } - - public GeckoNode InsertBefore(GeckoNode newChild, GeckoNode before) - { - if (newChild == null) - throw new ArgumentNullException("newChild"); - if (before == null) - throw new ArgumentNullException("before"); - - _DomObject.InsertBefore(newChild._DomObject, before._DomObject); - return newChild; - } - - public GeckoNode RemoveChild(GeckoNode node) - { - if (node == null) - throw new ArgumentNullException("node"); - - _DomObject.RemoveChild(node._DomObject); - return node; - } - - public GeckoNode ReplaceChild(GeckoNode newChild, GeckoNode oldChild) - { - if (newChild == null) - throw new ArgumentNullException("newChild"); - if (oldChild == null) - throw new ArgumentNullException("oldChild"); - - _DomObject.ReplaceChild(newChild._DomObject, oldChild._DomObject); - return newChild; - } - - public GeckoNamedNodeMap Attributes - { - get { return new GeckoNamedNodeMap(_DomObject.GetAttributes()); } - } - } - - /// <summary> - /// Represents a DOM attribute. - /// </summary> - public class GeckoAttribute : GeckoNode - { - internal GeckoAttribute(nsIDOMAttr attr) : base(attr) - { - this.DomAttr = attr; - } - nsIDOMAttr DomAttr; - - internal static GeckoAttribute Create(nsIDOMAttr attr) - { - return (attr == null) ? null : new GeckoAttribute(attr); - } - - /// <summary> - /// Gets the name of the attribute. - /// </summary> - public string Name - { - get { return nsString.Get(DomAttr.GetName); } - } - - /// <summary> - /// Gets the value of the attribute. - /// </summary> - public string Value - { - get { return nsString.Get(DomAttr.GetValue); } - set { nsString.Set(DomAttr.SetValue, value); } - } - - /// <summary> - /// Gets a value indicating whether the attribute is specified. - /// </summary> - public bool Specified - { - get { return DomAttr.GetSpecified(); } - } - - /// <summary> - /// Gets the <see cref="GeckoElement"/> which contains this attribute. - /// </summary> - public GeckoElement OwnerElement - { - get { return GeckoElement.Create((nsIDOMHTMLElement)DomAttr.GetOwnerElement()); } - } - } - - /// <summary> - /// Represents a DOM element. - /// </summary> - public class GeckoElement : GeckoNode - { - internal GeckoElement(nsIDOMHTMLElement element) : base(element) - { - this.DomElement = element; - this.DomNSElement = (nsIDOMNSElement)element; - this.DomNSHTMLElement = (nsIDOMNSHTMLElement)element; - - // since a reference is stored in the base class, we only need weak references here - Marshal.ChangeWrapperHandleStrength(DomNSElement, true); - Marshal.ChangeWrapperHandleStrength(DomNSHTMLElement, true); - } - - internal static GeckoElement Create(nsIDOMHTMLElement element) - { - return (element == null) ? null : new GeckoElement(element); - } - - nsIDOMHTMLElement DomElement; - nsIDOMNSElement DomNSElement; - nsIDOMNSHTMLElement DomNSHTMLElement; - - /// <summary> - /// Gets the parent element of this one. - /// </summary> - public GeckoElement Parent - { - get - { - // note: the parent node could also be the document - return GeckoElement.Create(Xpcom.QueryInterface<nsIDOMHTMLElement>(DomElement.GetParentNode())); - } - } - - /// <summary> - /// Gets the name of the tag. - /// </summary> - public string TagName - { - get { return nsString.Get(DomElement.GetTagName); } - } - - /// <summary> - /// Gets the value of the id attribute. - /// </summary> - public string Id - { - get { return nsString.Get(DomElement.GetId); } - set { nsString.Set(DomElement.SetId, value); } - } - - /// <summary> - /// Gets the value of the class attribute. - /// </summary> - public string ClassName - { - get { return nsString.Get(DomElement.GetClassName); } - set { nsString.Set(DomElement.SetClassName, value); } - } - - /// <summary> - /// Returns a collection containing the child elements of this element with a given tag name. - /// </summary> - /// <param name="tagName"></param> - /// <returns></returns> - public GeckoElementCollection GetElementsByTagName(string tagName) - { - if (string.IsNullOrEmpty(tagName)) - return null; - - return new GeckoElementCollection(DomElement.GetElementsByTagName(new nsAString(tagName))); - } - - /// <summary> - /// Gets the value of an attribute on this element with the specified name. - /// </summary> - /// <param name="attributeName"></param> - /// <returns></returns> - public string GetAttribute(string attributeName) - { - if (string.IsNullOrEmpty(attributeName)) - throw new ArgumentException("attributeName"); - - using (nsAString retval = new nsAString()) - { - DomElement.GetAttribute(new nsAString(attributeName), retval); - return retval.ToString(); - } - } - - /// <summary> - /// Gets the value of an attribute on this element with the specified name and namespace. - /// </summary> - /// <param name="attributeName"></param> - /// <returns></returns> - public string GetAttributeNS(string namespaceUri, string attributeName) - { - if (string.IsNullOrEmpty(namespaceUri)) - return GetAttribute(attributeName); - - if (string.IsNullOrEmpty(attributeName)) - throw new ArgumentException("attributeName"); - - using (nsAString retval = new nsAString()) - { - DomElement.GetAttributeNS(new nsAString(namespaceUri), new nsAString(attributeName), retval); - return retval.ToString(); - } - } - - /// <summary> - /// Sets the value of an attribute on this element with the specified name. - /// </summary> - /// <param name="attributeName"></param> - /// <param name="value"></param> - public void SetAttribute(string attributeName, string value) - { - if (string.IsNullOrEmpty(attributeName)) - throw new ArgumentException("attributeName"); - - DomElement.SetAttribute(new nsAString(attributeName), new nsAString(value)); - } - - /// <summary> - /// Sets the value of an attribute on this element with the specified name and namespace. - /// </summary> - /// <param name="attributeName"></param> - /// <param name="value"></param> - public void SetAttributeNS(string namespaceUri, string attributeName, string value) - { - if (string.IsNullOrEmpty(namespaceUri)) - { - SetAttribute(attributeName, value); - } - else - { - if (string.IsNullOrEmpty(attributeName)) - throw new ArgumentException("attributeName"); - - DomElement.SetAttributeNS(new nsAString(namespaceUri), new nsAString(attributeName), new nsAString(value)); - } - } - - /// <summary> - /// Removes an attribute from this element. - /// </summary> - /// <param name="attributeName"></param> - public void RemoveAttribute(string attributeName) - { - if (string.IsNullOrEmpty(attributeName)) - throw new ArgumentException("attributeName"); - - DomElement.RemoveAttribute(new nsAString(attributeName)); - } - - #if GECKO_1_9_1 - public int ScrollLeft { get { return DomNSElement.GetScrollLeft(); } set { DomNSElement.SetScrollLeft(value); } } - public int ScrollTop { get { return DomNSElement.GetScrollTop(); } set { DomNSElement.SetScrollTop(value); } } - public int ScrollWidth { get { return DomNSElement.GetScrollWidth(); } } - public int ScrollHeight { get { return DomNSElement.GetScrollHeight(); } } - public int ClientWidth { get { return DomNSElement.GetClientWidth(); } } - public int ClientHeight { get { return DomNSElement.GetClientHeight(); } } - #else + /// <summary> + /// Provides a base class for DOM nodes. + /// </summary> + public class GeckoNode + { + internal GeckoNode(nsIDOMNode domObject) + { + _DomObject = domObject; + } + + internal static GeckoNode Create(nsIDOMNode domObject) + { + if (domObject == null) + return null; + + nsIDOMHTMLElement element = Xpcom.QueryInterface<nsIDOMHTMLElement>(domObject); + if (element != null) + return GeckoElement.Create(element); + + nsIDOMAttr attr = Xpcom.QueryInterface<nsIDOMAttr>(domObject); + if (attr != null) + return GeckoAttribute.Create(attr); + + return new GeckoNode(domObject); + } + + /// <summary> + /// Gets the underlying XPCOM object. + /// </summary> + public object DomObject + { + get { return _DomObject; } + } + nsIDOMNode _DomObject; + + public override bool Equals(object obj) + { + if (this == obj) + return true; + else if (obj is GeckoNode) + return this.GetHashCode() == (obj as GeckoNode).GetHashCode(); + + return base.Equals(obj); + } + + public override int GetHashCode() + { + IntPtr pUnk = Marshal.GetIUnknownForObject(this._DomObject); + try + { + return pUnk.GetHashCode(); + } + finally + { + if (pUnk != IntPtr.Zero) + Marshal.Release(pUnk); + } + } + + /// <summary> + /// Gets the text contents of the node. + /// </summary> + public string TextContent + { + get { return nsString.Get(((nsIDOM3Node)_DomObject).GetTextContent); } + set { nsString.Set(((nsIDOM3Node)_DomObject).SetTextContent, value); } + } + + /// <summary> + /// Gets or sets the value of the node. + /// </summary> + public string NodeValue + { + get { return nsString.Get(((nsIDOMNode)_DomObject).GetNodeValue); } + set { nsString.Set(((nsIDOMNode)_DomObject).SetNodeValue, value); } + } + + /// <summary> + /// Gets a collection containing all child nodes of this node. + /// </summary> + public GeckoNodeCollection ChildNodes + { + get { return new GeckoNodeCollection(_DomObject.GetChildNodes()); } + } + + public GeckoNode ParentNode { get { return GeckoNode.Create(_DomObject.GetParentNode()); } } + public GeckoNode FirstChild { get { return GeckoNode.Create(_DomObject.GetFirstChild()); } } + public GeckoNode LastChild { get { return GeckoNode.Create(_DomObject.GetLastChild()); } } + public GeckoNode NextSibling { get { return GeckoNode.Create(_DomObject.GetNextSibling()); } } + public GeckoNode PreviousSibling { get { return GeckoNode.Create(_DomObject.GetPreviousSibling()); } } + public bool HasChildNodes { get { return _DomObject.HasChildNodes(); } } + public bool HasAttributes { get { return _DomObject.HasAttributes(); } } + + public GeckoDocument OwnerDocument { get { return GeckoDocument.Create(Xpcom.QueryInterface<nsIDOMHTMLDocument>(_DomObject.GetOwnerDocument())); } } + + public GeckoNode AppendChild(GeckoNode node) + { + if (node == null) + throw new ArgumentNullException("node"); + + _DomObject.AppendChild(node._DomObject); + return node; + } + + public GeckoNode CloneNode(bool deep) + { + return GeckoNode.Create(_DomObject.CloneNode(deep)); + } + + public GeckoNode InsertBefore(GeckoNode newChild, GeckoNode before) + { + if (newChild == null) + throw new ArgumentNullException("newChild"); + if (before == null) + throw new ArgumentNullException("before"); + + _DomObject.InsertBefore(newChild._DomObject, before._DomObject); + return newChild; + } + + public GeckoNode RemoveChild(GeckoNode node) + { + if (node == null) + throw new ArgumentNullException("node"); + + _DomObject.RemoveChild(node._DomObject); + return node; + } + + public GeckoNode ReplaceChild(GeckoNode newChild, GeckoNode oldChild) + { + if (newChild == null) + throw new ArgumentNullException("newChild"); + if (oldChild == null) + throw new ArgumentNullException("oldChild"); + + _DomObject.ReplaceChild(newChild._DomObject, oldChild._DomObject); + return newChild; + } + + public GeckoNamedNodeMap Attributes + { + get { return new GeckoNamedNodeMap(_DomObject.GetAttributes()); } + } + } + + /// <summary> + /// Represents a DOM attribute. + /// </summary> + public class GeckoAttribute : GeckoNode + { + internal GeckoAttribute(nsIDOMAttr attr) + : base(attr) + { + this.DomAttr = attr; + } + nsIDOMAttr DomAttr; + + internal static GeckoAttribute Create(nsIDOMAttr attr) + { + return (attr == null) ? null : new GeckoAttribute(attr); + } + + /// <summary> + /// Gets the name of the attribute. + /// </summary> + public string Name + { + get { return nsString.Get(DomAttr.GetName); } + } + + /// <summary> + /// Gets the value of the attribute. + /// </summary> + public string Value + { + get { return nsString.Get(DomAttr.GetValue); } + set { nsString.Set(DomAttr.SetValue, value); } + } + + /// <summary> + /// Gets a value indicating whether the attribute is specified. + /// </summary> + public bool Specified + { + get { return DomAttr.GetSpecified(); } + } + + /// <summary> + /// Gets the <see cref="GeckoElement"/> which contains this attribute. + /// </summary> + public GeckoElement OwnerElement + { + get { return GeckoElement.Create((nsIDOMHTMLElement)DomAttr.GetOwnerElement()); } + } + } + + /// <summary> + /// Represents a DOM element. + /// </summary> + public class GeckoElement : GeckoNode + { + internal GeckoElement(nsIDOMHTMLElement element) + : base(element) + { + this.DomElement = element; + this.DomNSElement = (nsIDOMNSElement)element; + this.DomNSHTMLElement = (nsIDOMNSHTMLElement)element; + + // since a reference is stored in the base class, we only need weak references here + Marshal.ChangeWrapperHandleStrength(DomNSElement, true); + Marshal.ChangeWrapperHandleStrength(DomNSHTMLElement, true); + } + + internal static GeckoElement Create(nsIDOMHTMLElement element) + { + return (element == null) ? null : new GeckoElement(element); + } + + nsIDOMHTMLElement DomElement; + nsIDOMNSElement DomNSElement; + nsIDOMNSHTMLElement DomNSHTMLElement; + + /// <summary> + /// Gets the parent element of this one. + /// </summary> + public GeckoElement Parent + { + get + { + // note: the parent node could also be the document + return GeckoElement.Create(Xpcom.QueryInterface<nsIDOMHTMLElement>(DomElement.GetParentNode())); + } + } + + /// <summary> + /// Gets the name of the tag. + /// </summary> + public string TagName + { + get { return nsString.Get(DomElement.GetTagName); } + } + + /// <summary> + /// Gets the value of the id attribute. + /// </summary> + public string Id + { + get { return nsString.Get(DomElement.GetId); } + set { nsString.Set(DomElement.SetId, value); } + } + + /// <summary> + /// Gets the value of the class attribute. + /// </summary> + public string ClassName + { + get { return nsString.Get(DomElement.GetClassName); } + set { nsString.Set(DomElement.SetClassName, value); } + } + + /// <summary> + /// Returns a collection containing the child elements of this element with a given tag name. + /// </summary> + /// <param name="tagName"></param> + /// <returns></returns> + public GeckoElementCollection GetElementsByTagName(string tagName) + { + if (string.IsNullOrEmpty(tagName)) + return null; + + return new GeckoElementCollection(DomElement.GetElementsByTagName(new nsAString(tagName))); + } + + /// <summary> + /// Gets the value of an attribute on this element with the specified name. + /// </summary> + /// <param name="attributeName"></param> + /// <returns></returns> + public string GetAttribute(string attributeName) + { + if (string.IsNullOrEmpty(attributeName)) + throw new ArgumentException("attributeName"); + + using (nsAString retval = new nsAString()) + { + DomElement.GetAttribute(new nsAString(attributeName), retval); + return retval.ToString(); + } + } + + /// <summary> + /// Gets the value of an attribute on this element with the specified name and namespace. + /// </summary> + /// <param name="attributeName"></param> + /// <returns></returns> + public string GetAttributeNS(string namespaceUri, string attributeName) + { + if (string.IsNullOrEmpty(namespaceUri)) + return GetAttribute(attributeName); + + if (string.IsNullOrEmpty(attributeName)) + throw new ArgumentException("attributeName"); + + using (nsAString retval = new nsAString()) + { + DomElement.GetAttributeNS(new nsAString(namespaceUri), new nsAString(attributeName), retval); + return retval.ToString(); + } + } + + /// <summary> + /// Sets the value of an attribute on this element with the specified name. + /// </summary> + /// <param name="attributeName"></param> + /// <param name="value"></param> + public void SetAttribute(string attributeName, string value) + { + if (string.IsNullOrEmpty(attributeName)) + throw new ArgumentException("attributeName"); + + DomElement.SetAttribute(new nsAString(attributeName), new nsAString(value)); + } + + /// <summary> + /// Sets the value of an attribute on this element with the specified name and namespace. + /// </summary> + /// <param name="attributeName"></param> + /// <param name="value"></param> + public void SetAttributeNS(string namespaceUri, string attributeName, string value) + { + if (string.IsNullOrEmpty(namespaceUri)) + { + SetAttribute(attributeName, value); + } + else + { + if (string.IsNullOrEmpty(attributeName)) + throw new ArgumentException("attributeName"); + + DomElement.SetAttributeNS(new nsAString(namespaceUri), new nsAString(attributeName), new nsAString(value)); + } + } + + /// <summary> + /// Removes an attribute from this element. + /// </summary> + /// <param name="attributeName"></param> + public void RemoveAttribute(string attributeName) + { + if (string.IsNullOrEmpty(attributeName)) + throw new ArgumentException("attributeName"); + + DomElement.RemoveAttribute(new nsAString(attributeName)); + } + +#if GECKO_1_9_1 + public int ScrollLeft { get { return DomNSElement.GetScrollLeft(); } set { DomNSElement.SetScrollLeft(value); } } + public int ScrollTop { get { return DomNSElement.GetScrollTop(); } set { DomNSElement.SetScrollTop(value); } } + public int ScrollWidth { get { return DomNSElement.GetScrollWidth(); } } + public int ScrollHeight { get { return DomNSElement.GetScrollHeight(); } } + public int ClientWidth { get { return DomNSElement.GetClientWidth(); } } + public int ClientHeight { get { return DomNSElement.GetClientHeight(); } } +#else public int ScrollLeft { get { return DomNSHTMLElement.GetScrollLeft(); } set { DomNSHTMLElement.SetScrollLeft(value); } } public int ScrollTop { get { return DomNSHTMLElement.GetScrollTop(); } set { DomNSHTMLElement.SetScrollTop(value); } } public int ScrollWidth { get { return DomNSHTMLElement.GetScrollWidth(); } } public int ScrollHeight { get { return DomNSHTMLElement.GetScrollHeight(); } } public int ClientWidth { get { return DomNSHTMLElement.GetClientWidth(); } } public int ClientHeight { get { return DomNSHTMLElement.GetClientHeight(); } } - #endif - public int OffsetLeft { get { return DomNSHTMLElement.GetOffsetLeft(); } } - public int OffsetTop { get { return DomNSHTMLElement.GetOffsetTop(); } } - public int OffsetWidth { get { return DomNSHTMLElement.GetOffsetWidth(); } } - public int OffsetHeight { get { return DomNSHTMLElement.GetOffsetHeight(); } } - - public GeckoElement OffsetParent - { - get { return GeckoElement.Create((nsIDOMHTMLElement)DomNSHTMLElement.GetOffsetParent()); } - } - - public void ScrollIntoView(bool top) - { - DomNSHTMLElement.ScrollIntoView(top); - } - - public string InnerHtml - { - get { return nsString.Get(DomNSHTMLElement.GetInnerHTML); } - set { nsString.Set(DomNSHTMLElement.SetInnerHTML, value); } - } - - public void Focus() - { - DomNSHTMLElement.Focus(); - } - - public void Blur() - { - DomNSHTMLElement.Blur(); - } +#endif + public int OffsetLeft { get { return DomNSHTMLElement.GetOffsetLeft(); } } + public int OffsetTop { get { return DomNSHTMLElement.GetOffsetTop(); } } + public int OffsetWidth { get { return DomNSHTMLElement.GetOffsetWidth(); } } + public int OffsetHeight { get { return DomNSHTMLElement.GetOffsetHeight(); } } - public int TabIndex - { - get { return DomNSHTMLElement.GetTabIndex(); } - set { DomNSHTMLElement.SetTabIndex(value); } - } - - #if GECKO_1_9 - /// <summary> - /// Returns a set of elements with the given class name. This element and all child elements are searched. - /// </summary> - /// <param name="classes"></param> - /// <returns></returns> - public GeckoNodeCollection GetElementsByClassName(string classes) - { - using (nsAString str = new nsAString(classes)) - return new GeckoNodeCollection(((nsIDOMNSElement)DomElement).GetElementsByClassName(str)); - } - - /// <summary> - /// Gets a rectangle which represents the union of all bounding rectangles within the element. - /// </summary> - public RectangleF BoundingClientRect - { - get - { - nsIDOMNSElement ns = (nsIDOMNSElement)DomElement; - nsIDOMClientRect rect = ns.GetBoundingClientRect(); - return RectangleF.FromLTRB(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom()); - } - } - - /// <summary> - /// Returns an array containing all bounding rectangles within the element. - /// </summary> - /// <returns></returns> - public RectangleF [] GetClientRects() - { - nsIDOMNSElement ns = (nsIDOMNSElement)DomElement; - nsIDOMClientRectList rects = ns.GetClientRects(); - RectangleF [] result = new RectangleF[rects.GetLength()]; - for (int i = 0; i < result.Length; i++) - { - nsIDOMClientRect rect = rects.Item(i); - result[i] = RectangleF.FromLTRB(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom()); - } - return result; - } - #endif - } - - /// <summary> - /// Represents a DOM document. - /// </summary> - public class GeckoDocument : GeckoNode - { - internal GeckoDocument(nsIDOMHTMLDocument document) : base(document) - { - this.DomDocument = document; - } - - internal static GeckoDocument Create(nsIDOMHTMLDocument document) - { - return (document == null) ? null : new GeckoDocument(document); - } - - nsIDOMHTMLDocument DomDocument; - - /// <summary> - /// Gets the document title. - /// </summary> - public string Title - { - get { return nsString.Get(DomDocument.GetTitle); } - set { nsString.Set(DomDocument.SetTitle, value); } - } - - /// <summary> - /// Gets the HTML body element. - /// </summary> - public GeckoElement Body - { - get { return GeckoElement.Create(DomDocument.GetBody()); } - } - - /// <summary> - /// Gets the top-level document element (for HTML documents, this is the html tag). - /// </summary> - public GeckoElement DocumentElement - { - get { return GeckoElement.Create((nsIDOMHTMLElement)DomDocument.GetDocumentElement()); } - } - - /// <summary> - /// Searches for and returns the element in the document with the given id. - /// </summary> - /// <param name="id"></param> - /// <returns></returns> - public GeckoElement GetElementById(string id) - { - if (string.IsNullOrEmpty(id)) - return null; - - return GeckoElement.Create((nsIDOMHTMLElement)DomDocument.GetElementById(new nsAString(id))); - } - - /// <summary> - /// Represents a collection of style sheets in a <see cref="GeckoDocument"/>. - /// </summary> - public class StyleSheetCollection : IEnumerable<GeckoStyleSheet> - { - internal StyleSheetCollection(GeckoDocument document) - { - this.List = ((nsIDOMDocumentStyle)document.DomDocument).GetStyleSheets(); - } - nsIDOMStyleSheetList List; - - /// <summary> - /// Gets the number of items in the collection. - /// </summary> - public int Count - { - get { return (List == null) ? 0 : List.GetLength(); } - } - - /// <summary> - /// Gets the item at the specified index in the collection. - /// </summary> - /// <param name="index"></param> - /// <returns></returns> - public GeckoStyleSheet this[int index] - { - get - { - if (index < 0 || index >= Count) - throw new ArgumentOutOfRangeException("index"); - - return GeckoStyleSheet.Create((nsIDOMCSSStyleSheet)List.Item(index)); - } - } - - #region IEnumerable<GeckoStyleSheet> Members - - /// <summary> - /// Returns an <see cref="IEnumerator{GeckoStyleSheet}"/> which can enumerate through the collection. - /// </summary> - /// <returns></returns> - public IEnumerator<GeckoStyleSheet> GetEnumerator() - { - int length = Count; - for (int i = 0; i < length; i++) - { - yield return GeckoStyleSheet.Create((nsIDOMCSSStyleSheet)List.Item(i)); - } - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - foreach (GeckoStyleSheet element in this) - yield return element; - } + public GeckoElement OffsetParent + { + get { return GeckoElement.Create((nsIDOMHTMLElement)DomNSHTMLElement.GetOffsetParent()); } + } - #endregion - } - - /// <summary> - /// Gets the collection of style sheets in the <see cref="GeckoDocument"/>. - /// </summary> - public StyleSheetCollection StyleSheets - { - get { return (_StyleSheets == null) ? ( _StyleSheets = new StyleSheetCollection(this)) : _StyleSheets; } - } - StyleSheetCollection _StyleSheets; - - /// <summary> - /// Gets the URL of the document. - /// </summary> - public Uri Url - { - get { return new Uri(nsString.Get(DomDocument.GetURL)); } - } - - public GeckoElementCollection Frames - { - get { return new GeckoHtmlElementCollection(DomDocument.GetForms()); } - } - - public GeckoElementCollection Images - { - get { return new GeckoHtmlElementCollection(DomDocument.GetImages()); } - } - - public GeckoElementCollection Anchors - { - get { return new GeckoHtmlElementCollection(DomDocument.GetAnchors()); } - } - - public GeckoElementCollection Applets - { - get { return new GeckoHtmlElementCollection(DomDocument.GetApplets()); } - } - - public GeckoElementCollection Links - { - get { return new GeckoHtmlElementCollection(DomDocument.GetLinks()); } - } - - public string Cookie - { - get { return nsString.Get(DomDocument.GetCookie); } - set { nsString.Set(DomDocument.SetCookie, value); } - } - - public string Domain - { - get { return nsString.Get(DomDocument.GetDomain); } - } - - /// <summary> - /// Returns a collection containing all elements in the document with a given tag name. - /// </summary> - /// <param name="tagName"></param> - /// <returns></returns> - public GeckoElementCollection GetElementsByTagName(string tagName) - { - if (string.IsNullOrEmpty(tagName)) - return null; - - return new GeckoElementCollection(DomDocument.GetElementsByTagName(new nsAString(tagName))); - } - - /// <summary> - /// Returns a collection containing all elements in the document with a given name. - /// </summary> - /// <param name="name"></param> - /// <returns></returns> - public GeckoElementCollection GetElementsByName(string name) - { - if (string.IsNullOrEmpty(name)) - return null; - - return new GeckoElementCollection(DomDocument.GetElementsByName(new nsAString(name))); - } - - public GeckoElement CreateElement(string tagName) - { - if (string.IsNullOrEmpty(tagName)) - throw new ArgumentException("tagName"); - - return GeckoElement.Create((nsIDOMHTMLElement)DomDocument.CreateElement(new nsAString(tagName))); - } - - public GeckoElement CreateElement(string tagName, string qualifiedName) - { - if (string.IsNullOrEmpty(tagName)) - throw new ArgumentException("tagName"); - if (string.IsNullOrEmpty(qualifiedName)) - throw new ArgumentException("qualifiedName"); - - return GeckoElement.Create((nsIDOMHTMLElement)DomDocument.CreateElementNS(new nsAString(tagName), new nsAString(qualifiedName))); - } - - public GeckoAttribute CreateAttribute(string name) - { - if (string.IsNullOrEmpty(name)) - throw new ArgumentException("name"); - - return GeckoAttribute.Create(DomDocument.CreateAttribute(new nsAString(name))); - } - - public GeckoAttribute CreateAttribute(string namespaceUri, string qualifiedName) - { - if (string.IsNullOrEmpty(namespaceUri)) - throw new ArgumentException("namespaceUri"); - if (string.IsNullOrEmpty(qualifiedName)) - throw new ArgumentException("qualifiedName"); - - return GeckoAttribute.Create(DomDocument.CreateAttributeNS(new nsAString(namespaceUri), new nsAString(qualifiedName))); - } - - public GeckoNode ImportNode(GeckoNode node, bool deep) - { - if (node == null) - throw new ArgumentNullException("node"); - - return GeckoNode.Create(DomDocument.ImportNode((nsIDOMNode)node.DomObject, deep)); - } - - public bool IsSupported(string feature, string version) - { - if (string.IsNullOrEmpty(feature)) - throw new ArgumentException("feature"); - if (string.IsNullOrEmpty(version)) - throw new ArgumentException("version"); - - return DomDocument.IsSupported(new nsAString(feature), new nsAString(version)); - } - - #if GECKO_1_9 - /// <summary> - /// Gets the currently focused element. - /// </summary> - public GeckoElement ActiveElement - { - get { return (GeckoElement)GeckoElement.Create(((nsIDOMNSDocument)DomDocument).GetActiveElement()); } - } - - /// <summary> - /// Returns a set of elements with the given class name. When called on the document object, the complete document is searched, including the root node. - /// </summary> - /// <param name="classes"></param> - /// <returns></returns> - public GeckoNodeCollection GetElementsByClassName(string classes) - { - using (nsAString str = new nsAString(classes)) - return new GeckoNodeCollection(((nsIDOMNSDocument)DomDocument).GetElementsByClassName(str)); - } - - /// <summary> - /// Returns the element visible at the given point, relative to the upper-left-most visible point in the document. - /// </summary> - /// <param name="x"></param> - /// <param name="y"></param> - /// <returns></returns> - public GeckoElement ElementFromPoint(int x, int y) - { - return GeckoElement.Create((nsIDOMHTMLElement)((nsIDOMNSDocument)DomDocument).ElementFromPoint(x, y)); - } - #endif - } - - public class GeckoNamedNodeMap : IEnumerable<GeckoNode> - { - internal GeckoNamedNodeMap(nsIDOMNamedNodeMap map) - { - this.Map = map; - } - - nsIDOMNamedNodeMap Map; - - /// <summary> - /// Gets the number of items in the map. - /// </summary> - public int Count - { - get { return (Map == null) ? 0 : Map.GetLength(); } - } - - public GeckoNode this[int index] - { - get - { - if (index < 0 || index >= Count) - throw new ArgumentOutOfRangeException("index"); - - return GeckoNode.Create(Map.Item(index)); - } - } - - public GeckoNode this[string name] - { - get - { - return GeckoNode.Create(Map.GetNamedItem(new nsAString(name))); - } - } - - public GeckoNode this[string namespaceUri, string localName] - { - get - { - return GeckoNode.Create(Map.GetNamedItemNS(new nsAString(namespaceUri), new nsAString(localName))); - } - } + public void ScrollIntoView(bool top) + { + DomNSHTMLElement.ScrollIntoView(top); + } - #region IEnumerable<GeckoNode> Members + public string InnerHtml + { + get { return nsString.Get(DomNSHTMLElement.GetInnerHTML); } + set { nsString.Set(DomNSHTMLElement.SetInnerHTML, value); } + } - public IEnumerator<GeckoNode> GetEnumerator() - { - int length = Count; - for (int i = 0; i < length; i++) - { - yield return GeckoNode.Create(Map.Item(i)); - } - } + public void Focus() + { + DomNSHTMLElement.Focus(); + } - #endregion + public void Blur() + { + DomNSHTMLElement.Blur(); + } - #region IEnumerable Members + public int TabIndex + { + get { return DomNSHTMLElement.GetTabIndex(); } + set { DomNSHTMLElement.SetTabIndex(value); } + } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - foreach (GeckoNode node in this) - yield return node; - } +#if GECKO_1_9 + /// <summary> + /// Returns a set of elements with the given class name. This element and all child elements are searched. + /// </summary> + /// <param name="classes"></param> + /// <returns></returns> + public GeckoNodeCollection GetElementsByClassName(string classes) + { + using (nsAString str = new nsAString(classes)) + return new GeckoNodeCollection(((nsIDOMNSElement)DomElement).GetElementsByClassName(str)); + } - #endregion - } - - /// <summary> - /// Represents a DOM window. - /// </summary> - public class GeckoWindow - { - private GeckoWindow(nsIDOMWindow window) - { - _DomWindow = window; - } - - /// <summary> - /// Gets the underlying unmanaged DOM object. - /// </summary> - public object DomWindow - { - get { return _DomWindow; } - } - nsIDOMWindow _DomWindow; - - internal static GeckoWindow Create(nsIDOMWindow window) - { - return (window == null) ? null : new GeckoWindow(window); - } - - /// <summary> - /// Gets the document displayed in the window. - /// </summary> - public GeckoDocument Document - { - get { return GeckoDocument.Create((nsIDOMHTMLDocument)_DomWindow.GetDocument()); } - } - - /// <summary> - /// Gets the parent window of this one. - /// </summary> - public GeckoWindow Parent - { - get { return GeckoWindow.Create((nsIDOMWindow)_DomWindow.GetParent()); } - } + /// <summary> + /// Gets a rectangle which represents the union of all bounding rectangles within the element. + /// </summary> + public RectangleF BoundingClientRect + { + get + { + nsIDOMNSElement ns = (nsIDOMNSElement)DomElement; + nsIDOMClientRect rect = ns.GetBoundingClientRect(); + return RectangleF.FromLTRB(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom()); + } + } - public int ScrollX - { - get { return _DomWindow.GetScrollX(); } - } - - public int ScrollY - { - get { return _DomWindow.GetScrollY(); } - } + /// <summary> + /// Returns an array containing all bounding rectangles within the element. + /// </summary> + /// <returns></returns> + public RectangleF[] GetClientRects() + { + nsIDOMNSElement ns = (nsIDOMNSElement)DomElement; + nsIDOMClientRectList rects = ns.GetClientRects(); + RectangleF[] result = new RectangleF[rects.GetLength()]; + for (int i = 0; i < result.Length; i++) + { + nsIDOMClientRect rect = rects.Item(i); + result[i] = RectangleF.FromLTRB(rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom()); + } + return result; + } +#endif + } - public float TextZoom - { - get { return _DomWindow.GetTextZoom(); } - set { _DomWindow.SetTextZoom(value); } - } + /// <summary> + /// Represents a DOM document. + /// </summary> + public class GeckoDocument : GeckoNode + { + internal GeckoDocument(nsIDOMHTMLDocument document) + : base(document) + { + this.DomDocument = document; + } - public void ScrollTo(int x, int y) + internal static GeckoDocument Create(nsIDOMHTMLDocument document) + { + return (document == null) ? null : new GeckoDocument(document); + } + + nsIDOMHTMLDocument DomDocument; + + /// <summary> + /// Gets the document title. + /// </summary> + public string Title + { + get { return nsString.Get(DomDocument.GetTitle); } + set { nsString.Set(DomDocument.SetTitle, value); } + } + + /// <summary> + /// Gets the HTML body element. + /// </summary> + public GeckoElement Body + { + get { return GeckoElement.Create(DomDocument.GetBody()); } + } + + /// <summary> + /// Gets the top-level document element (for HTML documents, this is the html tag). + /// </summary> + public GeckoElement DocumentElement + { + get { return GeckoElement.Create((nsIDOMHTMLElement)DomDocument.GetDocumentElement()); } + } + + /// <summary> + /// Searches for and returns the element in the document with the given id. + /// </summary> + /// <param name="id"></param> + /// <returns></returns> + public GeckoElement GetElementById(string id) + { + if (string.IsNullOrEmpty(id)) + return null; + + return GeckoElement.Create((nsIDOMHTMLElement)DomDocument.GetElementById(new nsAString(id))); + } + + /// <summary> + /// Represents a collection of style sheets in a <see cref="GeckoDocument"/>. + /// </summary> + public class StyleSheetCollection : IEnumerable<GeckoStyleSheet> + { + internal StyleSheetCollection(GeckoDocument document) + { + this.List = ((nsIDOMDocumentStyle)document.DomDocument).GetStyleSheets(); + } + nsIDOMStyleSheetList List; + + /// <summary> + /// Gets the number of items in the collection. + /// </summary> + public int Count + { + get { return (List == null) ? 0 : List.GetLength(); } + } + + /// <summary> + /// Gets the item at the specified index in the collection. + /// </summary> + /// <param name="index"></param> + /// <returns></returns> + public GeckoStyleSheet this[int index] + { + get + { + if (index < 0 || index >= Count) + throw new ArgumentOutOfRangeException("index"); + + return GeckoStyleSheet.Create((nsIDOMCSSStyleSheet)List.Item(index)); + } + } + + #region IEnumerable<GeckoStyleSheet> Members + + /// <summary> + /// Returns an <see cref="IEnumerator{GeckoStyleSheet}"/> which can enumerate through the collection. + /// </summary> + /// <returns></returns> + public IEnumerator<GeckoStyleSheet> GetEnumerator() + { + int length = Count; + for (int i = 0; i < length; i++) + { + yield return GeckoStyleSheet.Create((nsIDOMCSSStyleSheet)List.Item(i)); + } + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() + ... [truncated message content] |
From: <dos...@us...> - 2014-01-23 20:59:26
|
Revision: 4751 http://sourceforge.net/p/mp-plugins/code/4751 Author: doskabouter Date: 2014-01-23 20:59:24 +0000 (Thu, 23 Jan 2014) Log Message: ----------- Added solution configuration to easily debug setup Modified Paths: -------------- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.sln Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2014-01-19 19:34:48 UTC (rev 4750) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb/BrowseTheWeb.csproj 2014-01-23 20:59:24 UTC (rev 4751) @@ -53,6 +53,24 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug Config|AnyCPU'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>C:\Program Files %28x86%29\Team MediaPortal\MediaPortal\plugins\Windows\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>x86</PlatformTarget> + <CodeAnalysisLogFile>C:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\BrowseTheWeb.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile> + <CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression> + <CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile> + <UseVSHostingProcess>false</UseVSHostingProcess> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + <CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories> + <CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets> + <CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories> + <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules> + <CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules> + </PropertyGroup> <ItemGroup> <Reference Include="Common.Utils"> <HintPath>$(ProgramFiles)\Team MediaPortal\MediaPortal\Common.Utils.dll</HintPath> @@ -207,6 +225,6 @@ </Target> --> <PropertyGroup> - <PostBuildEvent>if $(ConfigurationName) == Release "$(ProgramFiles)\Team MediaPortal\MediaPortal\MpeMaker" ..\..\BrowseTheWeb.xmp2 /B /UpdateXML</PostBuildEvent> + <PostBuildEvent>if "$(ConfigurationName)" == "Release" "$(ProgramFiles)\Team MediaPortal\MediaPortal\MpeMaker" ..\..\BrowseTheWeb.xmp2 /B /UpdateXML</PostBuildEvent> </PropertyGroup> </Project> \ No newline at end of file Modified: trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.sln =================================================================== --- trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.sln 2014-01-19 19:34:48 UTC (rev 4750) +++ trunk/plugins/BrowseTheWeb/Source/BrowseTheWeb.sln 2014-01-23 20:59:24 UTC (rev 4751) @@ -5,6 +5,9 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Config|Any CPU = Debug Config|Any CPU + Debug Config|Mixed Platforms = Debug Config|Mixed Platforms + Debug Config|x86 = Debug Config|x86 Debug|Any CPU = Debug|Any CPU Debug|Mixed Platforms = Debug|Mixed Platforms Debug|x86 = Debug|x86 @@ -13,6 +16,11 @@ Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {70ECF0E8-19B6-43A9-B3B5-B1BB13F6E241}.Debug Config|Any CPU.ActiveCfg = Debug Config|Any CPU + {70ECF0E8-19B6-43A9-B3B5-B1BB13F6E241}.Debug Config|Any CPU.Build.0 = Debug Config|Any CPU + {70ECF0E8-19B6-43A9-B3B5-B1BB13F6E241}.Debug Config|Mixed Platforms.ActiveCfg = Debug Config|Any CPU + {70ECF0E8-19B6-43A9-B3B5-B1BB13F6E241}.Debug Config|Mixed Platforms.Build.0 = Debug Config|Any CPU + {70ECF0E8-19B6-43A9-B3B5-B1BB13F6E241}.Debug Config|x86.ActiveCfg = Debug Config|Any CPU {70ECF0E8-19B6-43A9-B3B5-B1BB13F6E241}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {70ECF0E8-19B6-43A9-B3B5-B1BB13F6E241}.Debug|Any CPU.Build.0 = Debug|Any CPU {70ECF0E8-19B6-43A9-B3B5-B1BB13F6E241}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |