本文整理汇总了C#中OutputFormat类的典型用法代码示例。如果您正苦于以下问题:C# OutputFormat类的具体用法?C# OutputFormat怎么用?C# OutputFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OutputFormat类属于命名空间,在下文中一共展示了OutputFormat类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetBytes
public static byte[] GetBytes(this Bitmap bitmap, OutputFormat outputFormat)
{
using (var memStream = new MemoryStream())
{
bitmap.MakeTransparent(BackgroundColour);
switch (outputFormat)
{
case OutputFormat.Jpeg:
bitmap.Save(memStream, ImageFormat.Jpeg);
break;
case OutputFormat.Gif:
bitmap.Save(memStream, ImageFormat.Gif);
break;
case OutputFormat.Png:
bitmap.Save(memStream, ImageFormat.Png);
break;
case OutputFormat.HighQualityJpeg:
var p = new EncoderParameters(1);
p.Param[0] = new EncoderParameter(Encoder.Quality, (long)95);
bitmap.Save(memStream, GetImageCodeInfo("image/jpeg"), p);
break;
}
return memStream.ToArray();
}
}
开发者ID:markalpine,项目名称:ImageManager,代码行数:25,代码来源:Utilities.cs
示例2: GetBytes
public static byte[] GetBytes(this Bitmap bitmap, OutputFormat outputFormat)
{
using (var memStream = (MemoryStream) bitmap.GetStream(outputFormat))
{
return memStream.ToArray();
}
}
开发者ID:cimex,项目名称:ImageManager,代码行数:7,代码来源:Utilities.cs
示例3: FlexWikiWebApplication
public FlexWikiWebApplication(string configPath, LinkMaker linkMaker,
OutputFormat outputFormat)
{
_configPath = configPath;
_linkMaker = linkMaker;
_outputFormat = outputFormat;
}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:7,代码来源:FlexWikiWebApplication.cs
示例4: GrabSingleView
private void GrabSingleView(EditorWindow view, FileInfo targetFile, OutputFormat format)
{
var width = Mathf.FloorToInt(view.position.width);
var height = Mathf.FloorToInt(view.position.height);
Texture2D screenShot = new Texture2D(width, height);
this.HideOnGrabbing();
var colorArray = InternalEditorUtility.ReadScreenPixel(view.position.position, width, height);
screenShot.SetPixels(colorArray);
byte[] encodedBytes = null;
if (format == OutputFormat.jpg)
{
encodedBytes = screenShot.EncodeToJPG();
}
else
{
encodedBytes = screenShot.EncodeToPNG();
}
File.WriteAllBytes(targetFile.FullName, encodedBytes);
this.ShowAfterHiding();
}
开发者ID:xfleckx,项目名称:MF_Unity3D_Utilities,代码行数:27,代码来源:WindowGrabber.cs
示例5: ValidateUrl
public IValidatorReportItem ValidateUrl(string url, Stream output, OutputFormat outputFormat)
{
if (!IsValidUrl(url))
{
return ReportFailure(url, string.Empty, "The url is not in a valid format.");
}
var validatorUrl = mContext.ValidatorUrl;
var input = url;
var inputFormat = InputFormat.Uri;
// wrap in try/catch so any error can be reported in the output
try
{
if (mContext.DirectInputMode)
{
// Retrieve the text from the webserver and input it directly
// to the W3C API
inputFormat = InputFormat.Fragment;
input = mHttpClient.GetResponseText(url);
}
var validatorResult = mValidator.Validate(output, outputFormat, input, inputFormat, mContext, validatorUrl);
return ReportSuccess(
url,
GetDomainName(url),
validatorResult.Errors,
validatorResult.IsValid);
}
catch (Exception ex)
{
return ReportFailure(url, GetDomainName(url), ex.Message);
}
}
开发者ID:NightOwl888,项目名称:ContinuousSeo,代码行数:35,代码来源:CssValidatorWrapper.cs
示例6: FormatNumber
/// <summary>
/// Formats number as requested by <paramref name="outputFormat"/>.
/// </summary>
/// <param name="number">Number to be formatted.</param>
/// <param name="outputFormat">Format to be applied.</param>
/// <exception cref="ArgumentNullException">Thrown when no number parameter is provided.</exception>
/// <exception cref="ArgumentException">Thrown when invalid format parameted is provided.</exception>
/// <returns>Formatted number as string.</returns>
public static string FormatNumber(object number, OutputFormat outputFormat)
{
double parsedNumber;
if (number != null && double.TryParse(number.ToString(), out parsedNumber))
{
if (Enum.IsDefined(typeof(OutputFormat), outputFormat))
{
string result;
switch (outputFormat)
{
case OutputFormat.Float:
result = string.Format("{0:f2}", number);
break;
case OutputFormat.Percentage:
result = string.Format("{0:p0}", number);
break;
case OutputFormat.Normal:
result = string.Format("{0,8}", number);
break;
default:
throw new ArgumentException("Illegal format parameter provided!");
}
return result;
}
throw new ArgumentException("Invalid format argument provided!");
}
throw new ArgumentNullException("number", "No number provided to be formated!");
}
开发者ID:tormibg,项目名称:SoftUni-1,代码行数:39,代码来源:NumberUtils.cs
示例7: ProcessingWindow
public ProcessingWindow(string[] pathsOfFilesToProcess, DestinationShape destinationShape, OutputFormat outputFormat)
{
InitializeComponent();
_paths = pathsOfFilesToProcess;
_destinationShape = destinationShape;
_outputFormat = outputFormat;
}
开发者ID:SteveDunn,项目名称:GifToSpriteMap,代码行数:7,代码来源:ProcessingWindow.cs
示例8: CreateSession
/// <summary>
/// Creates a new session for assembling documents using the HotDocs Cloud Services Rest API.
/// </summary>
/// <param name="template">The template to use with the session.</param>
/// <param name="billingRef">This parameter lets you specify information that will be included in usage logs for this call. For example, you can use a string to uniquely identify the end user that initiated the request and/or the context in which the call was made. When you review usage logs, you can then see which end users initiated each request. That information could then be used to pass costs on to those end users if desired.</param>
/// <param name="answers">The answers to use.</param>
/// <param name="markedVariables">An array of variable names, whose prompts should be "marked" when displayed in an interview.</param>
/// <param name="interviewFormat">The format to use when displaying an interview.</param>
/// <param name="outputFormat">The format to use when assembling a document.</param>
/// <param name="settings">The settings to use with the session.</param>
/// <param name="theme">The interview theme.</param>
/// <param name="showDownloadLinks">Indicates whether or not links for downloading the assembled document(s) should appear at the end of the interview.</param>
/// <returns></returns>
public string CreateSession(
Template template,
string billingRef = null,
string answers = null,
string[] markedVariables = null,
InterviewFormat interviewFormat = InterviewFormat.JavaScript,
OutputFormat outputFormat = OutputFormat.Native,
Dictionary<string, string> settings = null,
string theme = null,
bool showDownloadLinks = true
)
{
return (string)TryWithoutAndWithPackage(
(uploadPackage) => CreateSessionImpl(
template,
billingRef,
answers,
markedVariables,
interviewFormat,
outputFormat,
settings,
theme,
showDownloadLinks,
uploadPackage)
);
}
开发者ID:MMetodiew,项目名称:hotdocs-open-sdk,代码行数:39,代码来源:RestClientSession.cs
示例9: Get
public byte[] Get(string relativeFilePath, int width, int height, ImageMod imageMod, string hexBackgroundColour, AnchorPosition? anchor, OutputFormat outputFormat)
{
using (var bitmap = Get(relativeFilePath, width, height, imageMod, hexBackgroundColour, anchor))
{
return bitmap.GetBytes(outputFormat);
}
}
开发者ID:markalpine,项目名称:ImageManager,代码行数:7,代码来源:ImageService.cs
示例10: Export
public string Export(OutputFormat format = OutputFormat.Html)
{
using(StringWriter sw = new StringWriter())
{
Export(sw, format);
return sw.ToString();
}
}
开发者ID:boombuler,项目名称:CommonMark.NET,代码行数:8,代码来源:Document.cs
示例11: MockWikiApplication
public MockWikiApplication(FederationConfiguration configuration, LinkMaker linkMaker,
OutputFormat outputFormat, ITimeProvider timeProvider)
{
_configuration = configuration;
_linkMaker = linkMaker;
_ouputFormat = outputFormat;
_timeProvider = timeProvider;
}
开发者ID:nuxleus,项目名称:flexwikicore,代码行数:8,代码来源:MockWikiApplication.cs
示例12: SHA1Hash
/// <summary>
/// Returns SHA1 Digest of UTF8 representation of input string
/// </summary>
/// <param name="source">String that will use UTF8 encoding</param>
/// <param name="outputFormat">Formatting to be applied to output string.</param>
/// <returns>SHA1 digest in format specified by <paramref name="outputFormat"/></returns>
/// <exception cref="ValidationException">Thrown if <paramref name="source"/> is null or empty</exception>
public static string SHA1Hash(this string source, OutputFormat outputFormat = OutputFormat.Hex)
{
Validate.Begin()
.IsNotNull(source, "source")
.IsNotEmpty(source, "source")
.CheckForExceptions();
return SHA1HashImplementation(source, outputFormat);
}
开发者ID:jcomtois,项目名称:CustomExtensions,代码行数:16,代码来源:SHA1Hash.cs
示例13: Generate
public Stream Generate(string dotSource, LayoutEngine engine, OutputFormat fmt)
{
var res = processRunner.Run(dotExe, new MemoryStream(Encoding.ASCII.GetBytes(dotSource)), engine.AsCmdLineParam(), fmt.AsCmdLineParam());
if (res.ExitCode!=0)
throw new Exception(
string.Format("Process [{4}] finished with non-zero code:[{0}] \nwhile generating data format: [{1}] using layout engine: [{2}]\nsrc={3}",
res.ExitCode, fmt, engine, dotSource.Shorter(), dotExe));
return res.StdOut;
}
开发者ID:ku3mich,项目名称:dot,代码行数:10,代码来源:DotProcessor.cs
示例14: Write
public void Write(OutputFormat format, string text, params object[] args)
{
var str =
format == OutputFormat.Error ? "<!e!>" + text + "</!e!>" :
format == OutputFormat.Important ? "<!i!>" + text + "</!i!>" :
format == OutputFormat.Header ? "<!h!>" + text + "</!h!>" :
format == OutputFormat.Warning ? "<!w!>" + text + "</!w!>" :
text;
View().WriteString(str, args);
}
开发者ID:rizwan3d,项目名称:elalang,代码行数:10,代码来源:OutputService.cs
示例15: CreateImageMedia
/// <summary>
/// Creates an image media.
/// </summary>
/// <param name = "parentId">The parent media id.</param>
/// <param name = "mediaName">Name of the media.</param>
/// <param name = "image">The image.</param>
/// <param name = "outputFormat">The output format.</param>
/// <returns>Media Url</returns>
public static int CreateImageMedia(int parentId, string mediaName, Image image, OutputFormat outputFormat)
{
// Create media item
mediaName = LegalizeString(mediaName.Replace(" ", "-"));
var mediaItem = Media.MakeNew(mediaName, MediaType.GetByAlias("image"), new User(0), parentId);
// Filename
// i.e. 1234.jpg
var mediaFileName = string.Format("{0}.{1}", mediaItem.Id, outputFormat);
var mediaThumbName = string.Format("{0}_thumb.{1}", mediaItem.Id, outputFormat);
// Client side Paths
//
// sample folder : /media/1234/
// : /media/1234/1234.jpg
//
var clientMediaFolder = string.Format("{0}/../media/{1}", GlobalSettings.Path, mediaItem.Id);
var clientMediaFile = string.Format("{0}/{1}", clientMediaFolder, mediaFileName);
var clientMediaThumb = string.Format("{0}/{1}", clientMediaFolder, mediaThumbName);
// Server side Paths
var serverMediaFolder = IOHelper.MapPath(clientMediaFolder);
var serverMediaFile = IOHelper.MapPath(clientMediaFile);
var serverMediaThumb = IOHelper.MapPath(clientMediaThumb);
var extension = Path.GetExtension(serverMediaFile).ToLower();
// Create media folder if it doesn't exist
if (!Directory.Exists(serverMediaFolder))
Directory.CreateDirectory(serverMediaFolder);
// Save Image and thumb for new media item
image.Save(serverMediaFile);
var savedImage = Image.FromFile(serverMediaFile);
savedImage.GetThumbnailImage((int) (image.Size.Width*.3), (int) (image.Size.Height*.3), null, new IntPtr()).
Save(serverMediaThumb);
mediaItem.getProperty(Constants.Umbraco.Media.Width).Value = savedImage.Size.Width.ToString();
mediaItem.getProperty(Constants.Umbraco.Media.Height).Value = savedImage.Size.Height.ToString();
mediaItem.getProperty(Constants.Umbraco.Media.File).Value = clientMediaFile;
mediaItem.getProperty(Constants.Umbraco.Media.Extension).Value = extension;
mediaItem.getProperty(Constants.Umbraco.Media.Bytes).Value = File.Exists(serverMediaFile)
? new FileInfo(serverMediaFile).Length.ToString()
: "0";
mediaItem.Save();
mediaItem.XmlGenerate(new XmlDocument());
image.Dispose();
savedImage.Dispose();
// assign output parameters
return mediaItem.Id;
}
开发者ID:bokmadsen,项目名称:uComponents,代码行数:62,代码来源:MediaHelper.cs
示例16: FormattedTopic
/// <summary>
/// Answer the formatted text for a given topic, formatted using a given OutputFormat and possibly showing diffs with the previous revision
/// </summary>
/// <param name="topic">The topic</param>
/// <param name="format">What format</param>
/// <param name="showDiffs">true to show diffs</param>
/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
/// <returns></returns>
public static string FormattedTopic(AbsoluteTopicName topic, OutputFormat format, bool showDiffs, Federation aFederation, LinkMaker lm, CompositeCacheRule accumulator)
{
// Show the current topic (including diffs if there is a previous version)
AbsoluteTopicName previousVersion = null;
ContentBase relativeToBase = aFederation.ContentBaseForNamespace(topic.Namespace);
if (showDiffs)
previousVersion = relativeToBase.VersionPreviousTo(topic.LocalName);
return FormattedTopicWithSpecificDiffs(topic, format, previousVersion, aFederation, lm, accumulator);
}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:20,代码来源:Formatter.cs
示例17: FormattedString
/// <summary>
/// Format a string of wiki content in a given OutputFormat with references all being relative to a given namespace
/// </summary>
/// <param name="input">The input wiki text</param>
/// <param name="format">The desired output format</param>
/// <param name="relativeToContentBase">References will be relative to this namespace</param>
/// <param name="lm">Link maker (unless no relativeTo content base is provide)</param>
/// <param name="accumulator">composite cache rule in which to accumulate cache rules</param>
/// <returns></returns>
public static string FormattedString(string input, OutputFormat format, ContentBase relativeToContentBase, LinkMaker lm, CompositeCacheRule accumulator)
{
// TODO -- some of the cases in which this call happens actually *are* nested, even though the false arg
// below says that they aren't. This causes scripts to be emitted multiple times -- should clean up.
WikiOutput output = WikiOutput.ForFormat(format, null);
Hashtable ew;
if (relativeToContentBase != null)
ew = relativeToContentBase.ExternalWikiHash();
else
ew = new Hashtable();
Format(null, input, output, relativeToContentBase, lm, ew, 0, accumulator);
return output.ToString();
}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:22,代码来源:Formatter.cs
示例18: CheckText
public SpellResult CheckText(string text, Lang[] lang = null, SpellerOptions? options = null, OutputFormat? format = null)
{
RestRequest request = new RestRequest("checkText");
request.AddParameter("text", text);
if (lang != null && lang.Length != 0)
request.AddParameter("lang", string.Join(",", lang.Select(l => l.ToString().ToLowerInvariant())));
if (options.HasValue)
request.AddParameter("options", (int)options.Value);
if (format.HasValue)
request.AddParameter("format", format.Value.ToString().ToLowerInvariant());
return SendRequest<SpellResult>(request);
}
开发者ID:nus-ii,项目名称:Yandex-Linguistics.NET,代码行数:13,代码来源:Speller.cs
示例19: GetOutput
public static string GetOutput(this Table table, OutputFormat format, int tableWidth = 77, string separator = ",")
{
switch (format)
{
case OutputFormat.Table:
return GetTextOutput(table, tableWidth);
case OutputFormat.HTML:
return GetHTLMOutput(table, tableWidth);
case OutputFormat.DataList:
return GetDataListOutput(table, separator);
default:
throw new ArgumentOutOfRangeException("format");
}
}
开发者ID:Genbox,项目名称:SPARQL.NET,代码行数:14,代码来源:OutputHelper.cs
示例20: ForFormat
public static WikiOutput ForFormat(OutputFormat aFormat, WikiOutput parent)
{
switch (aFormat)
{
case OutputFormat.HTML:
return new HTMLWikiOutput(parent);
case OutputFormat.Testing:
return new TestWikiOutput(parent);
default:
throw new Exception("Unsupported output type requested: " + aFormat.ToString());
}
}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:14,代码来源:WikiOutput.cs
注:本文中的OutputFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论