From 1080d899cf27a9f2f17f0637d750c68c74a3a7a1 Mon Sep 17 00:00:00 2001 From: Jaex Date: Thu, 27 Aug 2015 09:18:18 +0300 Subject: [PATCH] Creating manifest file dynamically --- .../Forms/ApplicationSettingsForm.Designer.cs | 16 +++++++------- ShareX/Forms/ApplicationSettingsForm.resx | 4 ++-- ShareX/Forms/ChromeForm.Designer.cs | 2 +- ShareX/Forms/ChromeForm.cs | 22 ++++++++++++++++--- ShareX/Properties/Resources.Designer.cs | 10 --------- ShareX/Properties/Resources.resx | 3 --- ShareX/Resources/Chrome-host-manifest.json | 7 ------ ShareX/ShareX.csproj | 1 - 8 files changed, 30 insertions(+), 35 deletions(-) delete mode 100644 ShareX/Resources/Chrome-host-manifest.json diff --git a/ShareX/Forms/ApplicationSettingsForm.Designer.cs b/ShareX/Forms/ApplicationSettingsForm.Designer.cs index 2d3aafbf1..86cf805f4 100644 --- a/ShareX/Forms/ApplicationSettingsForm.Designer.cs +++ b/ShareX/Forms/ApplicationSettingsForm.Designer.cs @@ -33,6 +33,7 @@ private void InitializeComponent() System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ApplicationSettingsForm)); this.tcSettings = new System.Windows.Forms.TabControl(); this.tpGeneral = new System.Windows.Forms.TabPage(); + this.btnChromeSupport = new System.Windows.Forms.Button(); this.btnLanguages = new ShareX.HelpersLib.MenuButton(); this.cmsLanguages = new System.Windows.Forms.ContextMenuStrip(this.components); this.llTranslators = new System.Windows.Forms.LinkLabel(); @@ -108,7 +109,6 @@ private void InitializeComponent() this.tpAdvanced = new System.Windows.Forms.TabPage(); this.pgSettings = new System.Windows.Forms.PropertyGrid(); this.tttvMain = new ShareX.HelpersLib.TabToTreeView(); - this.btnChromeSupport = new System.Windows.Forms.Button(); this.tcSettings.SuspendLayout(); this.tpGeneral.SuspendLayout(); this.tpPaths.SuspendLayout(); @@ -161,6 +161,13 @@ private void InitializeComponent() this.tpGeneral.Name = "tpGeneral"; this.tpGeneral.UseVisualStyleBackColor = true; // + // btnChromeSupport + // + resources.ApplyResources(this.btnChromeSupport, "btnChromeSupport"); + this.btnChromeSupport.Name = "btnChromeSupport"; + this.btnChromeSupport.UseVisualStyleBackColor = true; + this.btnChromeSupport.Click += new System.EventHandler(this.btnChromeSupport_Click); + // // btnLanguages // resources.ApplyResources(this.btnLanguages, "btnLanguages"); @@ -718,13 +725,6 @@ private void InitializeComponent() this.tttvMain.TreeViewFont = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162))); this.tttvMain.TreeViewSize = 175; // - // btnChromeSupport - // - resources.ApplyResources(this.btnChromeSupport, "btnChromeSupport"); - this.btnChromeSupport.Name = "btnChromeSupport"; - this.btnChromeSupport.UseVisualStyleBackColor = true; - this.btnChromeSupport.Click += new System.EventHandler(this.btnChromeSupport_Click); - // // ApplicationSettingsForm // resources.ApplyResources(this, "$this"); diff --git a/ShareX/Forms/ApplicationSettingsForm.resx b/ShareX/Forms/ApplicationSettingsForm.resx index c1a761091..8b4edbfb7 100644 --- a/ShareX/Forms/ApplicationSettingsForm.resx +++ b/ShareX/Forms/ApplicationSettingsForm.resx @@ -126,14 +126,14 @@ 8, 272 - 144, 24 + 224, 24 12 - Chrome support... + Chrome extension support... btnChromeSupport diff --git a/ShareX/Forms/ChromeForm.Designer.cs b/ShareX/Forms/ChromeForm.Designer.cs index c6e003a9b..e7c2c4f30 100644 --- a/ShareX/Forms/ChromeForm.Designer.cs +++ b/ShareX/Forms/ChromeForm.Designer.cs @@ -121,7 +121,7 @@ private void InitializeComponent() this.MaximizeBox = false; this.Name = "ChromeForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "ShareX - Chrome support"; + this.Text = "ShareX - Chrome extension support"; this.ResumeLayout(false); } diff --git a/ShareX/Forms/ChromeForm.cs b/ShareX/Forms/ChromeForm.cs index 9a0298d28..ae8db5d2e 100644 --- a/ShareX/Forms/ChromeForm.cs +++ b/ShareX/Forms/ChromeForm.cs @@ -23,6 +23,7 @@ #endregion License Information (GPL v3) +using Newtonsoft.Json; using ShareX.HelpersLib; using ShareX.Properties; using System; @@ -45,13 +46,27 @@ public ChromeForm() Icon = ShareXResources.Icon; } + private void CreateChromeHostManifest(string filepath) + { + var manifest = new + { + name = "com.test.test", + description = "ShareX", + path = Program.ChromeHostPath, + type = "stdio", + allowed_origins = new string[] { "" } + }; + + string json = JsonConvert.SerializeObject(manifest, Formatting.Indented); + + File.WriteAllText(filepath, json, Encoding.UTF8); + } + private void btnRegister_Click(object sender, EventArgs e) { try { - string manifest = Encoding.UTF8.GetString(Resources.Chrome_host_manifest); - manifest = manifest.Replace("{path}", Program.ChromeHostPath); - File.WriteAllText(Program.ChromeHostManifestPath, manifest, Encoding.UTF8); + CreateChromeHostManifest(Program.ChromeHostManifestPath); RegistryHelpers.RegisterChromeSupport(Program.ChromeHostManifestPath); } @@ -80,6 +95,7 @@ private void btnUnregister_Click(object sender, EventArgs e) private void btnInstallExtension_Click(object sender, EventArgs e) { + URLHelpers.OpenURL(""); } } } \ No newline at end of file diff --git a/ShareX/Properties/Resources.Designer.cs b/ShareX/Properties/Resources.Designer.cs index b94ac0143..ebd76117d 100644 --- a/ShareX/Properties/Resources.Designer.cs +++ b/ShareX/Properties/Resources.Designer.cs @@ -454,16 +454,6 @@ public class Resources { } } - /// - /// Looks up a localized resource of type System.Byte[]. - /// - public static byte[] Chrome_host_manifest { - get { - object obj = ResourceManager.GetObject("Chrome_host_manifest", resourceCulture); - return ((byte[])(obj)); - } - } - /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShareX/Properties/Resources.resx b/ShareX/Properties/Resources.resx index e689a943c..87e4991cd 100644 --- a/ShareX/Properties/Resources.resx +++ b/ShareX/Properties/Resources.resx @@ -784,7 +784,4 @@ Would you like to restart ShareX? ..\Resources\arrow-270.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\resources\chrome-host-manifest.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - \ No newline at end of file diff --git a/ShareX/Resources/Chrome-host-manifest.json b/ShareX/Resources/Chrome-host-manifest.json deleted file mode 100644 index 8a9dd6a47..000000000 --- a/ShareX/Resources/Chrome-host-manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "com.test.test", - "description": "ShareX", - "path": "{path}", - "type": "stdio", - "allowed_origins": [ "" ] -} \ No newline at end of file diff --git a/ShareX/ShareX.csproj b/ShareX/ShareX.csproj index 2db60ead6..a7e3b7384 100644 --- a/ShareX/ShareX.csproj +++ b/ShareX/ShareX.csproj @@ -866,7 +866,6 @@ Designer -