public static async Task <string> GeneratePreviewAsync(GenerationConfig config) { var pathes = Helper.GetFontPairs() .Select(x => x.Path) .ToArray(); var path = pathes[config.FontIndex]; var gen = new DLL(); gen.SetFontName(path); gen.SetFontSize(config.FontSize); var c = config.FontColor; gen.SetFontColor(c.Red, c.Green, c.Blue, c.Alpha); var co = config.OutlineColor; gen.SetOutlineColor(co.Red, co.Green, co.Blue, co.Alpha); gen.SetOutlineSize(config.OutlineSize); //gen.SetOutlineSampling(config.OutlineSampling); return(await Task.Run(() => gen.SavePreview())); }
public static void Save(GenerationConfig config, string path) { var serializer = new DataContractJsonSerializer(typeof(GenerationConfig)); using (var file = File.Create(path)) { serializer.WriteObject(file, config); } }
public static void Save(GenerationConfig config, string path) { var serializer = new DataContractJsonSerializer(typeof(GenerationConfig)); using (var file = File.Create(path)) { serializer.WriteObject(file, config); } }
public static async Task GenerateAsync(GenerationConfig config) { var pathes = Helper.GetFontPairs() .Select(x => x.Path) .ToArray(); var path = pathes[config.FontIndex]; if (!File.Exists(path)) { throw new FileNotFoundException("指定されたフォントファイルは存在しません。", path); } if (!File.Exists(config.TextPath)) { throw new FileNotFoundException("指定されたテキストファイルは存在しません。", config.TextPath); } if (!Directory.Exists(config.ExportPath)) { throw new FileNotFoundException("指定された出力先ディレクトリは存在しません。", config.ExportPath); } var gen = new DLL(); gen.SetFontName(path); gen.SetTextFilePath(config.TextPath); gen.SetExportPath(Path.Combine(config.ExportPath, config.SheetName)); gen.SetFontSize(config.FontSize); gen.SetSheetSize(config.TextureSize); var c = config.FontColor; gen.SetFontColor(c.Red, c.Green, c.Blue, c.Alpha); var co = config.OutlineColor; gen.SetOutlineColor(co.Red, co.Green, co.Blue, co.Alpha); gen.SetOutlineSize(config.OutlineSize); gen.SetOutlineSampling(config.OutlineSampling); await Task.Run(() => gen.Run()); }
public static async Task GenerateAsync(GenerationConfig config) { var pathes = Helper.GetFontPairs() .Select(x => x.Path) .ToArray(); var path = pathes[config.FontIndex]; if(!File.Exists(path)) { throw new FileNotFoundException("指定されたフォントファイルは存在しません。", path); } if(!File.Exists(config.TextPath)) { throw new FileNotFoundException("指定されたテキストファイルは存在しません。", config.TextPath); } if(!Directory.Exists(config.ExportPath)) { throw new FileNotFoundException("指定され出力先ディレクトリは存在しません。", config.ExportPath); } var gen = new DLL(); gen.SetFontName(path); gen.SetTextFilePath(config.TextPath); gen.SetExportPath(Path.Combine(config.ExportPath, config.SheetName)); gen.SetFontSize(config.FontSize); gen.SetSheetSize(config.TextureSize); var c = config.FontColor; gen.SetFontColor(c.Red, c.Green, c.Blue, c.Alpha); var co = config.OutlineColor; gen.SetOutlineColor(co.Red, co.Green, co.Blue, co.Alpha); gen.SetOutlineSize(config.OutlineSize); gen.SetOutlineSampling(config.OutlineSampling); await Task.Run(() => gen.Run()); }
public static async Task<string> GeneratePreviewAsync(GenerationConfig config) { var pathes = Helper.GetFontPairs() .Select(x => x.Path) .ToArray(); var path = pathes[config.FontIndex]; var gen = new DLL(); gen.SetFontName(path); gen.SetFontSize(config.FontSize); var c = config.FontColor; gen.SetFontColor(c.Red, c.Green, c.Blue, c.Alpha); var co = config.OutlineColor; gen.SetOutlineColor(co.Red, co.Green, co.Blue, co.Alpha); gen.SetOutlineSize(config.OutlineSize); //gen.SetOutlineSampling(config.OutlineSampling); return await Task.Run(() => gen.SavePreview()); }
public GeneratorViewModel() { config = new GenerationConfig(); Red = 255; Green = 255; Blue = 255; Alpha = 255; FontSize = 14; TextureSize = 1024; OpenFontFileCommand = new DelegateCommand { CommandHandler = OpenFontFile }; OpenTextFileCommand = new DelegateCommand { CommandHandler = OpenTextFile }; OpenExportPathCommand = new DelegateCommand { CommandHandler = OpenExportPath }; SaveConfigurationCommand = new DelegateCommand { CommandHandler = SaveConfiguration }; LoadConfigurationCommand = new DelegateCommand { CommandHandler = LoadConfiguration }; OutlineAlpha = 255; OutlineSize = 0; OutlineSampling = 1; Observable.FromEventPattern<PropertyChangedEventArgs>(this, "PropertyChanged") .Where(x => x.EventArgs.PropertyName != "PreviewImage") .Throttle(TimeSpan.FromMilliseconds(500)) .Subscribe(x => GeneratePreviewAsync()); CanGenerate = true; }