static void InitSystems() { Logger.Init(); Logger.LogInfo("Init All Systems"); Logger.LogInfo("Init Exception Handle Systems"); Application.Current.DispatcherUnhandledException += (object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) => { Exception ex = e.Exception; try { MainWindow.Current.ShowMessageBox("错误", new TextBlock() { TextWrapping = TextWrapping.Wrap, Text = "未经处理的错误\n" + ex.ToString() + "\n你可以打开日志文件并向作者反馈" }, new List <object> { "打开日志" }, new List <RoutedEventHandler> { (object sX, RoutedEventArgs eX) => { Process.Start("OMCLC\\log.log"); MainWindow.Current.mainDialog.IsOpen = false; } }); Logger.LogError("There is an error which is UNHANDLED:" + ex + "\n" + ex.Message + "\n" + ex.StackTrace); e.Handled = true; } catch (Exception exa) { Logger.LogFatal("There is an error which is UNHANDLED:" + ex + "\n" + ex.Message + "\n" + ex.StackTrace + "\n\n\nInner:" + exa.ToString() + "\n" + exa.Message + "\n" + exa.StackTrace); Process.GetCurrentProcess().Kill(); } }; User.Init(); DownloadAPI.Init(); }
public void ObterIcones(string nomeIcon, FileManager.Directories tipo, Action <Texture2D> callback) { if (!string.IsNullOrEmpty(nomeIcon)) { if (FileManager.Exists(tipo, nomeIcon)) { Texture2D texture2d = FileManager.ConvertToTexture2D(FileManager.LoadFile(tipo, nomeIcon)); callback(texture2d); return; } StartCoroutine(DownloadAPI.DownloadImage(nomeIcon, tipo.ToString(), (texture, bytes) => { if (texture != null) { FileManager.SaveFile(tipo, nomeIcon, bytes); } callback(texture); })); } }
public void SetAPISelection(Type api, DownloadAPI value) { SelectedAPIs[api] = value; APIControls[api].Selection = value == null ? "未选择" : value.VersionName; foreach (var exapi in (api.Assembly.CreateInstance(api.FullName) as DownloadAPI).MutuallyExclusiveAPIs) { APIControls[exapi].Visibility = value == null ? Visibility.Visible : Visibility.Collapsed; } foreach (var exapi in DownloadAPI.RegisteredAPIList) { if (exapi.Value.DependentAPIs.Contains(api)) { if (value == null) { APIControls[exapi.Value.GetType()].Visibility = Visibility.Collapsed; } else { APIControls[exapi.Value.GetType()].Visibility = Visibility.Visible; } } } }