/// <summary> /// Builds a new SaveFileDialog instance for saving something as an image file /// </summary> /// <returns></returns> public SaveFileDialog Build() { var imageFormatEnumParser = new ImageFormatEnumParser(); var enumFields = imageFormatEnumParser.Parse(); var defaultFormat = enumFields .Where(ef => ef.Extensions.Contains(".png")) .Select((ef, idx) => new { Field = ef, Position = idx }) .First(); return new SaveFileDialog { AddExtension = true, DefaultExt = ".png", Filter = BuildFilterString(enumFields), FilterIndex = defaultFormat.Position, OverwritePrompt = true }; }
/// <summary> /// Converts a dot file to an image file, using the file extension of the <i>outputFilePath</i> /// parameter to determine the file format to use /// </summary> /// <param name="dotFilePath">The path to the dot file to convert</param> /// <param name="outputFilePath">The file path of where to save the image</param> /// <returns>A task representing the async operation</returns> public Task ConvertAsync(string dotFilePath, string outputFilePath) { var fileinfo = new FileInfo(outputFilePath); var imageFormatEnumParser = new ImageFormatEnumParser(); var imageFormat = imageFormatEnumParser.Parse() .Where(ef => ef.Extensions.Contains(fileinfo.Extension)) .Select(ef => ef.Field.Name) .First(); return ConvertAsync(dotFilePath, outputFilePath, (ImageFormat)Enum.Parse(typeof(ImageFormat), imageFormat)); }