private void 修复字体ToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult FontCheck; FontCheck = MessageBox.Show("缺失非必要的字体文件,是否进行安装?\n若不安装会导致显示发生变化,但不影响正常使用", "提示", MessageBoxButtons.YesNo); if (FontCheck == DialogResult.Yes) { if (File.Exists("FZXIANGSU12.TTF")) { _ = MessageBox.Show("已找到文件。\n请点击新窗口中的【安装】按钮并重新启动计算器。"); } else { _ = MessageBox.Show("未找到文件。\n需要从网络中下载指定字体文件。"); ReadFile down = new ReadFile(); down.Download("https://genshincalc.oss-cn-beijing.aliyuncs.com/font/FZXIANGSU12.TTF", "FZXIANGSU12.TTF"); _ = MessageBox.Show("已下载文件。\n请点击新窗口中的【安装】按钮并重新启动计算器。"); } try { File.Copy("FZXIANGSU12.TTF", @"C:\Windows\Fonts" + @"\FZXIANGSU12.TTF", true); } catch (UnauthorizedAccessException) { _ = MessageBox.Show("没有安装字体的权限。\n请使用管理员权限重新打开再试试。"); } catch (Exception error) { _ = MessageBox.Show($"由于某些信息安装失败。\n错误信息:{error.Message}。"); } } }
/// <summary> /// 读取文件中的值 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void FileWriter() { var xlsx_url = "https://genshincalc.oss-cn-beijing.aliyuncs.com/xlsx/%E8%AF%A6%E7%BB%86%E6%95%B0%E6%8D%AE.xlsx"; var conf_url = "https://genshincalc.oss-cn-beijing.aliyuncs.com/conf/Configuration.Config"; var font_url = "https://genshincalc.oss-cn-beijing.aliyuncs.com/font/FZXIANGSU12.TTF"; if (File.Exists("详细数据.xlsx")) { FileInfo xlsx = new FileInfo("详细数据.xlsx"); xlsx.CopyTo(FileLocation + "详细数据.xlsx", true); } else { ReadFile Document = new ReadFile(); Document.Download(xlsx_url, FileLocation + "详细数据.xlsx"); } if (File.Exists("Configuration.Config")) { FileInfo conf = new FileInfo("Configuration.Config"); conf.CopyTo(FileLocation + "Configuration.Config", true); } else { ReadFile configuration = new ReadFile(); configuration.Download(conf_url, FileLocation + "Configuration.Config"); } if (File.Exists("FZXIANGSU12.TTF")) { FileInfo conf = new FileInfo("FZXIANGSU12.TTF"); conf.CopyTo(FileLocation + "FZXIANGSU12.TTF", true); } else { ReadFile configuration = new ReadFile(); configuration.Download(font_url, FileLocation + "FZXIANGSU12.TTF"); } }