public void ToRecovery() { try { name = ChangeEFIDisk(mount: true); string text = ""; text = Path.Combine(name + ":\\", "EFI\\Lenovo\\Logo"); DeleteOtherDirectory(text); } catch (Exception ex) { LogoDiy.LogHelper.Error(ex); } finally { ChangeEFIDisk(mount: false); } int num = DiyHelper.SetLogoDIYInfo(0); LogoDiy.LogHelper.Info($"set logoinfo ret = {num}"); if (num == 0) { LogoDiy.LogHelper.Info($"set logoinfo error: ret = {num}"); return; } ShowSuccessText = "*默认设置恢复成功"; ShowSuccessTip = true; FunEnable = false; }
public void SaveLogoClick() { try { Console.WriteLine("SaveLogoClick"); int num = DiyHelper.SetLogoDIYInfo(1); LogoDiy.LogHelper.Info($"set logoinfo ret = {num}"); if (num == 0) { ShowSuccessTip = false; LogoDiy.LogHelper.Info($"set logoinfo error: ret = {num}"); return; } LogoDiy.LogHelper.Info($"set logoinfo success: ret = {num}"); name = ChangeEFIDisk(mount: true); string text = ""; try { string extension = Path.GetExtension(ImagePath1); if (!string.IsNullOrWhiteSpace(fileExtension) && extension != fileExtension) { extension = fileExtension; } text = Path.Combine(name + ":\\", "EFI\\Lenovo\\Logo", $"mylogo_{DefaultWidth}x{DefaultHeight}" + extension); LogoDiy.LogHelper.Info($"path = {text}"); DeleteOtherFile(text); LogoDiy.LogHelper.Info($"source path = {ImagePath1}; dest path = {text}"); File.Copy(ImagePath1, text); } catch (Exception ex) { LogoDiy.LogHelper.Info("copy file error:" + ex.Message); return; } if (DiyHelper.SetLogDIYCRC(text) > 0) { LogoDiy.LogHelper.Info("Set CRC success"); ChangeEFIDisk(mount: false); ShowSuccessText = "*设置成功,请重启电脑查看效果"; ShowSuccessTip = true; } else { LogoDiy.LogHelper.Info("Set CRC ERROR"); ShowSuccessTip = false; } } catch (Exception ex2) { LogoDiy.LogHelper.Error(ex2); ShowSuccessTip = false; } finally { CanRecovery = true; ChangeEFIDisk(mount: false); } }