Creating manifest file dynamically

This commit is contained in:
Jaex 2015-08-27 09:18:18 +03:00
parent e15efd8855
commit 1080d899cf
8 changed files with 30 additions and 35 deletions

View file

@ -33,6 +33,7 @@ private void InitializeComponent()
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ApplicationSettingsForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ApplicationSettingsForm));
this.tcSettings = new System.Windows.Forms.TabControl(); this.tcSettings = new System.Windows.Forms.TabControl();
this.tpGeneral = new System.Windows.Forms.TabPage(); this.tpGeneral = new System.Windows.Forms.TabPage();
this.btnChromeSupport = new System.Windows.Forms.Button();
this.btnLanguages = new ShareX.HelpersLib.MenuButton(); this.btnLanguages = new ShareX.HelpersLib.MenuButton();
this.cmsLanguages = new System.Windows.Forms.ContextMenuStrip(this.components); this.cmsLanguages = new System.Windows.Forms.ContextMenuStrip(this.components);
this.llTranslators = new System.Windows.Forms.LinkLabel(); this.llTranslators = new System.Windows.Forms.LinkLabel();
@ -108,7 +109,6 @@ private void InitializeComponent()
this.tpAdvanced = new System.Windows.Forms.TabPage(); this.tpAdvanced = new System.Windows.Forms.TabPage();
this.pgSettings = new System.Windows.Forms.PropertyGrid(); this.pgSettings = new System.Windows.Forms.PropertyGrid();
this.tttvMain = new ShareX.HelpersLib.TabToTreeView(); this.tttvMain = new ShareX.HelpersLib.TabToTreeView();
this.btnChromeSupport = new System.Windows.Forms.Button();
this.tcSettings.SuspendLayout(); this.tcSettings.SuspendLayout();
this.tpGeneral.SuspendLayout(); this.tpGeneral.SuspendLayout();
this.tpPaths.SuspendLayout(); this.tpPaths.SuspendLayout();
@ -161,6 +161,13 @@ private void InitializeComponent()
this.tpGeneral.Name = "tpGeneral"; this.tpGeneral.Name = "tpGeneral";
this.tpGeneral.UseVisualStyleBackColor = true; 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 // btnLanguages
// //
resources.ApplyResources(this.btnLanguages, "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.TreeViewFont = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
this.tttvMain.TreeViewSize = 175; 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 // ApplicationSettingsForm
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");

View file

@ -126,14 +126,14 @@
<value>8, 272</value> <value>8, 272</value>
</data> </data>
<data name="btnChromeSupport.Size" type="System.Drawing.Size, System.Drawing"> <data name="btnChromeSupport.Size" type="System.Drawing.Size, System.Drawing">
<value>144, 24</value> <value>224, 24</value>
</data> </data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="btnChromeSupport.TabIndex" type="System.Int32, mscorlib"> <data name="btnChromeSupport.TabIndex" type="System.Int32, mscorlib">
<value>12</value> <value>12</value>
</data> </data>
<data name="btnChromeSupport.Text" xml:space="preserve"> <data name="btnChromeSupport.Text" xml:space="preserve">
<value>Chrome support...</value> <value>Chrome extension support...</value>
</data> </data>
<data name="&gt;&gt;btnChromeSupport.Name" xml:space="preserve"> <data name="&gt;&gt;btnChromeSupport.Name" xml:space="preserve">
<value>btnChromeSupport</value> <value>btnChromeSupport</value>

View file

@ -121,7 +121,7 @@ private void InitializeComponent()
this.MaximizeBox = false; this.MaximizeBox = false;
this.Name = "ChromeForm"; this.Name = "ChromeForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ShareX - Chrome support"; this.Text = "ShareX - Chrome extension support";
this.ResumeLayout(false); this.ResumeLayout(false);
} }

View file

@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
#endregion License Information (GPL v3) #endregion License Information (GPL v3)
using Newtonsoft.Json;
using ShareX.HelpersLib; using ShareX.HelpersLib;
using ShareX.Properties; using ShareX.Properties;
using System; using System;
@ -45,13 +46,27 @@ public ChromeForm()
Icon = ShareXResources.Icon; 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) private void btnRegister_Click(object sender, EventArgs e)
{ {
try try
{ {
string manifest = Encoding.UTF8.GetString(Resources.Chrome_host_manifest); CreateChromeHostManifest(Program.ChromeHostManifestPath);
manifest = manifest.Replace("{path}", Program.ChromeHostPath);
File.WriteAllText(Program.ChromeHostManifestPath, manifest, Encoding.UTF8);
RegistryHelpers.RegisterChromeSupport(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) private void btnInstallExtension_Click(object sender, EventArgs e)
{ {
URLHelpers.OpenURL("");
} }
} }
} }

View file

@ -454,16 +454,6 @@ public static System.Drawing.Bitmap checkbox_uncheck {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
public static byte[] Chrome_host_manifest {
get {
object obj = ResourceManager.GetObject("Chrome_host_manifest", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>

View file

@ -784,7 +784,4 @@ Would you like to restart ShareX?</value>
<data name="arrow-270" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="arrow-270" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\arrow-270.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\arrow-270.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Chrome_host_manifest" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\chrome-host-manifest.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root> </root>

View file

@ -1,7 +0,0 @@
{
"name": "com.test.test",
"description": "ShareX",
"path": "{path}",
"type": "stdio",
"allowed_origins": [ "" ]
}

View file

@ -866,7 +866,6 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</None> </None>
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Resources\Chrome-host-manifest.json" />
<None Include="Resources\RoundedRectangle.png" /> <None Include="Resources\RoundedRectangle.png" />
<None Include="Resources\Rectangle.png" /> <None Include="Resources\Rectangle.png" />
<None Include="Resources\Polygon.png" /> <None Include="Resources\Polygon.png" />