private static void WriteWatchFace(string outputDirectory, string outputFileName, string imagesDirectory, Parser.WatchFace watchFace) { try { Logger.Debug("从 '{0}' 读取参考图像", imagesDirectory); var imagesReader = new ResourcesLoader(imagesDirectory); imagesReader.Process(watchFace); Logger.Trace("建构表盘参数..."); var descriptor = ParametersConverter.Build(watchFace); var baseFilename = Path.GetFileNameWithoutExtension(outputFileName); GeneratePreviews(descriptor, imagesReader.Images, outputDirectory, baseFilename); Logger.Debug("写入表盘到: '{0}'", outputFileName); using (var fileStream = File.OpenWrite(outputFileName)) { var writer = new Writer(fileStream, imagesReader.Resources); writer.Write(descriptor); fileStream.Flush(); } } catch (Exception e) { Logger.Fatal(e); File.Delete(outputFileName); } }
private static void WriteWatchFace(string outputDirectory, string outputFileName, string imagesDirectory, WatchFace.Parser.WatchFace watchFace) { try { Logger.Debug("Reading referenced images from '{0}'", imagesDirectory); var imagesReader = new ResourcesLoader(imagesDirectory); imagesReader.Process(watchFace); Logger.Trace("Building parameters for watch face..."); var descriptor = ParametersConverter.Build(watchFace); var baseFilename = Path.GetFileNameWithoutExtension(outputFileName); GeneratePreviews(descriptor, imagesReader.Images, outputDirectory, baseFilename); Logger.Debug("Writing watch face to '{0}'", outputFileName); using (var fileStream = File.OpenWrite(outputFileName)) { var writer = new Writer(fileStream, imagesReader.Resources, ColorType.colorType); writer.Write(descriptor); fileStream.Flush(); } } catch (Exception e) { Logger.Fatal(e); File.Delete(outputFileName); } }
private static void WriteWatchFace(string outputDirectory, string outputFileName, string imagesDirectory, Parser.WatchFace watchFace) { try { Logger.Debug("Reading referenced images from '{0}'", imagesDirectory); var imagesReader = new ResourcesLoader(imagesDirectory); if (previewSize.Width == 360) { imagesReader.Process(watchFace as WatchFaceVerge); } else if (previewSize.Width == 454 || previewSize.Width == 390) { imagesReader.Process(watchFace as WatchFaceGTR); } else if (previewSize.Width == 176) { imagesReader.Process(watchFace as WatchFaceBip); } else { imagesReader.Process(watchFace); } Logger.Trace("Building parameters for watch face..."); List <Parameter> descriptor; if (previewSize.Width == 360) { descriptor = ParametersConverter.Build(watchFace as WatchFaceVerge); } else if (previewSize.Width == 454 || previewSize.Width == 390) { descriptor = ParametersConverter.Build(watchFace as WatchFaceGTR); } else if (previewSize.Width == 176) { descriptor = ParametersConverter.Build(watchFace as WatchFaceBip); } else { descriptor = ParametersConverter.Build(watchFace); } var baseFilename = Path.GetFileNameWithoutExtension(outputFileName); GeneratePreviews(descriptor, imagesReader.Images, outputDirectory, baseFilename); Logger.Debug("Writing watch face to '{0}'", outputFileName); using (var fileStream = File.OpenWrite(outputFileName)) { var writer = new Writer(fileStream, imagesReader.Resources) { OutputDirectory = outputDirectory, }; writer.Write(descriptor); fileStream.Flush(); } } catch (Exception e) { Logger.Fatal(e); File.Delete(outputFileName); } }