|
@@ -16,6 +16,76 @@ namespace EdgeVoyager
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
InitializeAsync();
|
|
|
+ string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
|
|
+ string filePath = Path.Combine(docPath, @"EdgeVoyager\favoritesMenuItem.resx");
|
|
|
+ string edgeVoyagerPath = Path.Combine(docPath, "EdgeVoyager");
|
|
|
+ if (!Directory.Exists(edgeVoyagerPath))
|
|
|
+ Directory.CreateDirectory(edgeVoyagerPath);
|
|
|
+ if (!File.Exists(filePath))
|
|
|
+ {
|
|
|
+ using (StreamWriter sw = File.CreateText(filePath))
|
|
|
+ {
|
|
|
+ sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
|
|
+ sw.WriteLine("<root>");
|
|
|
+ sw.WriteLine(" <!-- ");
|
|
|
+ sw.WriteLine(" Microsoft ResX Schema ");
|
|
|
+ sw.WriteLine(" ");
|
|
|
+ sw.WriteLine(" Version 2.0");
|
|
|
+ sw.WriteLine(" ");
|
|
|
+ sw.WriteLine(" The primary goals of this format is to allow a simple XML info path, ");
|
|
|
+ sw.WriteLine(" yet also allow others to add their own info beyond the main info ");
|
|
|
+ sw.WriteLine(" needed for a form without breaking any existing code. ");
|
|
|
+ sw.WriteLine(" ");
|
|
|
+ sw.WriteLine(" -->");
|
|
|
+ sw.WriteLine(" <xsd:schema id=\"root\" xmlns=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">");
|
|
|
+ sw.WriteLine(" <xsd:import namespace=\"http://www.w3.org/XML/1998/namespace\" />");
|
|
|
+ sw.WriteLine(" <xsd:element name=\"root\" msdata:IsDataSet=\"true\">");
|
|
|
+ sw.WriteLine(" <xsd:complexType>");
|
|
|
+ sw.WriteLine(" <xsd:choice maxOccurs=\"unbounded\">");
|
|
|
+ sw.WriteLine(" <xsd:element name=\"metadata\">");
|
|
|
+ sw.WriteLine(" <xsd:complexType>");
|
|
|
+ sw.WriteLine(" <xsd:attribute name=\"name\" type=\"xsd:string\" />");
|
|
|
+ sw.WriteLine(" <xsd:attribute name=\"value\" type=\"xsd:string\" />");
|
|
|
+ sw.WriteLine(" </xsd:complexType>");
|
|
|
+ sw.WriteLine(" </xsd:element>");
|
|
|
+ sw.WriteLine(" <xsd:element name=\"assembly\">");
|
|
|
+ sw.WriteLine(" <xsd:complexType>");
|
|
|
+ sw.WriteLine(" <xsd:attribute name=\"alias\" type=\"xsd:string\" />");
|
|
|
+ sw.WriteLine(" <xsd:attribute name=\"name\" type=\"xsd:string\" />");
|
|
|
+ sw.WriteLine(" </xsd:complexType>");
|
|
|
+ sw.WriteLine(" </xsd:element>");
|
|
|
+ sw.WriteLine(" <xsd:element name=\"data\">");
|
|
|
+ sw.WriteLine(" <xsd:complexType>");
|
|
|
+ sw.WriteLine(" <xsd:attribute name=\"name\" type=\"xsd:string\" />");
|
|
|
+ sw.WriteLine(" <xsd:attribute name=\"type\" type=\"xsd:string\" />");
|
|
|
+ sw.WriteLine(" <xsd:attribute name=\"mimetype\" type=\"xsd:string\" />");
|
|
|
+ sw.WriteLine(" <xsd:attribute name=\"xml:space\" type=\"xsd:string\" />");
|
|
|
+ sw.WriteLine(" </xsd:complexType>");
|
|
|
+ sw.WriteLine(" </xsd:element>");
|
|
|
+ sw.WriteLine(" <xsd:element name=\"resheader\">");
|
|
|
+ sw.WriteLine(" <xsd:complexType>");
|
|
|
+ sw.WriteLine(" <xsd:attribute name=\"name\" type=\"xsd:string\" />");
|
|
|
+ sw.WriteLine(" </xsd:complexType>");
|
|
|
+ sw.WriteLine(" </xsd:element>");
|
|
|
+ sw.WriteLine(" </xsd:choice>");
|
|
|
+ sw.WriteLine(" </xsd:complexType>");
|
|
|
+ sw.WriteLine(" </xsd:element>");
|
|
|
+ sw.WriteLine(" </xsd:schema>");
|
|
|
+ sw.WriteLine(" <resheader name=\"resmimetype\">");
|
|
|
+ sw.WriteLine(" <value>text/microsoft-resx</value>");
|
|
|
+ sw.WriteLine(" </resheader>");
|
|
|
+ sw.WriteLine(" <resheader name=\"version\">");
|
|
|
+ sw.WriteLine(" <value>2.0</value>");
|
|
|
+ sw.WriteLine(" </resheader>");
|
|
|
+ sw.WriteLine(" <resheader name=\"reader\">");
|
|
|
+ sw.WriteLine(" <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>");
|
|
|
+ sw.WriteLine(" </resheader>");
|
|
|
+ sw.WriteLine(" <resheader name=\"writer\">");
|
|
|
+ sw.WriteLine(" <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>");
|
|
|
+ sw.WriteLine(" </resheader>");
|
|
|
+ sw.WriteLine("</root>");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void CoreWebView2_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEventArgs e)
|
|
@@ -30,7 +100,8 @@ namespace EdgeVoyager
|
|
|
async void InitializeAsync()
|
|
|
{
|
|
|
await webView21.EnsureCoreWebView2Async(null);
|
|
|
- string resxFilePath = "favoritesMenuItem.resx";
|
|
|
+ string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
|
|
+ string resxFilePath = Path.Combine(docPath, @"EdgeVoyager\favoritesMenuItem.resx");
|
|
|
using (ResXResourceReader reader = new ResXResourceReader(resxFilePath))
|
|
|
{
|
|
|
foreach (DictionaryEntry entry in reader)
|
|
@@ -770,7 +841,8 @@ background-position: right top;
|
|
|
|
|
|
private async void 添加到收藏夹ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- string resxFilePath = "favoritesMenuItem.resx";
|
|
|
+ string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
|
|
+ string resxFilePath = Path.Combine(docPath, @"EdgeVoyager\favoritesMenuItem.resx");
|
|
|
string title = await webView21.CoreWebView2.ExecuteScriptAsync("document.title;");
|
|
|
string pageTitle = title.Trim('"');
|
|
|
string pageUrl = webView21.CoreWebView2.Source.ToString();
|
|
@@ -839,20 +911,7 @@ background-position: right top;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- private async Task<byte[]> DownloadFaviconAsync(string faviconUrl)
|
|
|
- {
|
|
|
- using (HttpClient client = new HttpClient())
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- return await client.GetByteArrayAsync(faviconUrl);
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
private void MenuItem_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
|
|
@@ -864,19 +923,18 @@ background-position: right top;
|
|
|
{
|
|
|
Form2 form2 = new Form2();
|
|
|
form2.ShowDialog();
|
|
|
- string resxFilePath = "favoritesMenuItem.resx";
|
|
|
+ string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
|
|
+ string resxFilePath = Path.Combine(docPath, @"EdgeVoyager\favoritesMenuItem.resx");
|
|
|
for (int i = 0; i < 收藏夹AToolStripMenuItem.DropDownItems.Count; i++)
|
|
|
{
|
|
|
- // 如果找到了toolStripSeparator10
|
|
|
if (收藏夹AToolStripMenuItem.DropDownItems[i] is ToolStripSeparator &&
|
|
|
收藏夹AToolStripMenuItem.DropDownItems[i].Name == "toolStripSeparator10")
|
|
|
{
|
|
|
- // 从toolStripSeparator10下方开始,删除所有按钮
|
|
|
for (int j = 收藏夹AToolStripMenuItem.DropDownItems.Count - 1; j > i; j--)
|
|
|
{
|
|
|
收藏夹AToolStripMenuItem.DropDownItems.RemoveAt(j);
|
|
|
}
|
|
|
- break; // 找到并处理完毕后退出循环
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
using (ResXResourceReader reader1 = new ResXResourceReader(resxFilePath))
|
|
@@ -898,19 +956,18 @@ background-position: right top;
|
|
|
|
|
|
private void Form1_Activated(object sender, EventArgs e)
|
|
|
{
|
|
|
- string resxFilePath = "favoritesMenuItem.resx";
|
|
|
+ string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
|
|
+ string resxFilePath = Path.Combine(docPath, @"EdgeVoyager\favoritesMenuItem.resx");
|
|
|
for (int i = 0; i < 收藏夹AToolStripMenuItem.DropDownItems.Count; i++)
|
|
|
{
|
|
|
- // 如果找到了toolStripSeparator10
|
|
|
if (收藏夹AToolStripMenuItem.DropDownItems[i] is ToolStripSeparator &&
|
|
|
收藏夹AToolStripMenuItem.DropDownItems[i].Name == "toolStripSeparator10")
|
|
|
{
|
|
|
- // 从toolStripSeparator10下方开始,删除所有按钮
|
|
|
for (int j = 收藏夹AToolStripMenuItem.DropDownItems.Count - 1; j > i; j--)
|
|
|
{
|
|
|
收藏夹AToolStripMenuItem.DropDownItems.RemoveAt(j);
|
|
|
}
|
|
|
- break; // 找到并处理完毕后退出循环
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
using (ResXResourceReader reader1 = new ResXResourceReader(resxFilePath))
|