本文整理汇总了C#中Format类的典型用法代码示例。如果您正苦于以下问题:C# Format类的具体用法?C# Format怎么用?C# Format使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Format类属于命名空间,在下文中一共展示了Format类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlurComponent
public BlurComponent(Device graphics, int size)
{
_graphics = graphics;
Dims = size;
Format = Format.A8R8G8B8;
_sampleOffsetsHoriz = new Vector4D[SampleCount];
_sampleOffsetsVert = new Vector4D[SampleCount];
_sampleWeightsHoriz = new float[SampleCount];
_sampleWeightsVert = new float[SampleCount];
int width = Dims - 5;
int height = Dims - 5;
SetBlurEffectParameters(1.0f / width, 0, ref _sampleOffsetsHoriz, ref _sampleWeightsHoriz);
SetBlurEffectParameters(0, 1.0f / height, ref _sampleOffsetsVert, ref _sampleWeightsVert);
_effect = new GaussianBlurEffect(_graphics);
OutputTexture = new Texture(_graphics, Dims, Dims, 1, Usage.RenderTarget, Format, Pool.Default);
_intermediateTexture = new Texture(_graphics, Dims, Dims, 1, Usage.RenderTarget, Format, Pool.Default);
_sprite = new Sprite(_graphics);
}
示例2: DisplayMode
/// <summary>Initializes a new instance of the <see cref="DisplayMode"/> class.</summary>
/// <param name="pixelFormat">The pixel format.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="refreshRate">The refresh rate.</param>
public DisplayMode(Format pixelFormat, int width, int height, Rational refreshRate)
{
this.pixelFormat = pixelFormat;
this.width = width;
this.height = height;
this.refreshRate = refreshRate;
}
示例3: D3DDevice
public D3DDevice(IntPtr windowPtr, bool bWindowed, long Width, long Height)
{
m_bWindowed = bWindowed;
m_Format = Find16BitMode();
PresentParameters presentParameters = new PresentParameters();
presentParameters.Windowed = m_bWindowed;
presentParameters.SwapEffect = SwapEffect.Discard;
presentParameters.BackBufferCount = 1;
presentParameters.PresentationInterval = PresentInterval.Immediate;
presentParameters.AutoDepthStencilFormat = DepthFormat.D16;
presentParameters.EnableAutoDepthStencil = true;
if(!bWindowed)
{
presentParameters.BackBufferFormat = m_Format;
presentParameters.BackBufferWidth = (int)Width;
presentParameters.BackBufferHeight = (int)Height;
}
else
{
presentParameters.BackBufferFormat = Format.Unknown;
presentParameters.BackBufferWidth = (int)Width;
presentParameters.BackBufferHeight = (int)Height;
}
m_D3DDevice = new Microsoft.DirectX.Direct3D.Device(0,
DeviceType.Hardware, windowPtr,
CreateFlags.SoftwareVertexProcessing, presentParameters);
}
示例4: Clear
internal void Clear()
{
m_deviceContext.ClearState();
m_inputLayout = null;
m_primitiveTopology = PrimitiveTopology.Undefined;
m_indexBufferRef = null;
m_indexBufferFormat = Format.Unknown;
m_indexBufferOffset = 0;
for (int i = 0; i < m_vertexBuffers.Length; i++)
m_vertexBuffers[i] = null;
for (int i = 0; i < m_vertexBuffersStrides.Length; i++)
m_vertexBuffersStrides[i] = 0;
m_blendState = null;
m_stencilRef = 0;
m_depthStencilState = null;
m_rtvsCount = 0;
for (int i = 0; i < m_rtvs.Length; i++)
m_rtvs[i] = null;
m_dsv = null;
m_rasterizerState = null;
m_scissorLeftTop = new Vector2I(-1, -1);
m_scissorRightBottom = new Vector2I(-1, -1);
m_viewport = default(RawViewportF);
m_targetBuffer = null;
m_targetOffsets = 0;
m_statistics.ClearStates++;
}
示例5: GetAlphaChannelBits
/// <summary>
/// Gets the number of alpha channel bits.
/// </summary>
public static int GetAlphaChannelBits(Format format)
{
switch (format)
{
case Format.R8G8B8:
return 0;
case Format.A8R8G8B8:
return 8;
case Format.X8R8G8B8:
return 0;
case Format.R5G6B5:
return 0;
case Format.X1R5G5B5:
return 0;
case Format.A1R5G5B5:
return 1;
case Format.A4R4G4B4:
return 4;
case Format.R3G3B2:
return 0;
case Format.A8R3G3B2:
return 8;
case Format.X4R4G4B4:
return 0;
case Format.A2B10G10R10:
return 2;
case Format.A2R10G10B10:
return 2;
default:
return 0;
}
}
示例6: EvaluateFormat
public void EvaluateFormat(object current, Format format, ref bool handled, IOutput output, FormatDetails formatDetails)
{
if (format != null && format.HasNested) return;
var formatText = format != null ? format.Text : "";
TimeSpan fromTime;
if (current is TimeSpan)
{
fromTime = (TimeSpan)current;
}
else if (current is DateTime && formatText.StartsWith("timestring"))
{
formatText = formatText.Substring(10);
fromTime = DateTime.Now.Subtract((DateTime)current);
}
else
{
return;
}
var timeTextInfo = GetTimeTextInfo(formatDetails.Provider);
if (timeTextInfo == null)
{
return;
}
var formattingOptions = TimeSpanFormatOptionsConverter.Parse(formatText);
var timeString = TimeSpanUtility.ToTimeString(fromTime, formattingOptions, timeTextInfo);
output.Write(timeString, formatDetails);
handled = true;
}
示例7: Inflate
/// <summary>
/// Inflate the data with the given format stored in a buffer
/// </summary>
/// <param name="buffer">A view with the encoded data</param>
/// <param name="format">An inflated format object</param>
/// <returns>Return null, an ArrayList or a single value (ulong, long, float, Token or string)</returns>
internal static object Inflate(BufferView buffer, Format format)
{
ArrayList data = new ArrayList();
if (InflateData.ReadElement(buffer, data, format.Root).Length != 0)
throw new ArgumentException("Unable to read data in the given format");
return data.Count == 0 ? null : (data.Count == 1 ? data[0] : data);
}
示例8: FormattingInfo
public FormattingInfo(FormattingInfo parent, FormatDetails formatDetails, Format format, object currentValue)
{
this.Parent = parent;
CurrentValue = currentValue;
Format = format;
FormatDetails = formatDetails;
}
示例9: Decompress
public static byte[] Decompress(int width, int height, byte[] source, Format format)
{
using (var strm = new MemoryStream(source))
{
return Decompress(width, height, new BinaryReader(strm), format);
}
}
示例10: Consumer
public Consumer(string host, string groupName, string instanceId, Format format, string offset = "smallest")
{
this.host = host;
this.groupName = groupName;
this.instanceId = instanceId;
this.format = format;
var contentType = "application/vnd.kafka.v1+json";
var data = new Dictionary<string, string>
{
{"name", instanceId},
{"format", format.ToString().ToLower()},
{"auto.offset.reset", offset}
};
try
{
var responseString = WebRequestHelper.Post(host, $"consumers/{groupName}", JsonConvert.SerializeObject(data),
contentType);
dynamic response = JsonConvert.DeserializeObject<dynamic>(responseString);
this.instanceId = response.instance_id.ToObject<string>();
baseUri = response.base_uri.ToObject<string>();
}
catch (Exception e)
{
// it means, that consumer with this name already exists
log.Warn(e.Message);
baseUri = $"{host}/consumers/{groupName}/instances/{instanceId}";
}
}
示例11: VertexElementAttribute
/// <summary>
/// Initializes a new instance of the <see cref="VertexElement" /> struct.
/// </summary>
/// <param name="semanticName">Name of the semantic.</param>
/// <param name="semanticIndex">Index of the semantic.</param>
/// <param name="format">The format.</param>
/// <param name="alignedByteOffset">The aligned byte offset.</param>
public VertexElementAttribute(string semanticName, int semanticIndex, Format format, int alignedByteOffset = VertexElement.AppendAligned)
{
this.semanticName = semanticName;
this.semanticIndex = semanticIndex;
this.format = format;
this.alignedByteOffset = alignedByteOffset;
}
示例12: GetContentType
public static string GetContentType(Format formats)
{
switch (formats)
{
case Format.Soap11:
case Format.Soap12:
case Format.Xml:
return Xml;
case Format.Json:
return Json;
case Format.Jsv:
return JsvText;
case Format.Csv:
return Csv;
case Format.ProtoBuf:
return ProtoBuf;
case Format.MsgPack:
return MsgPack;
default:
return null;
}
}
示例13: OnGUI
void OnGUI()
{
GUILayout.BeginHorizontal();
GUI.enabled = m_Format != Format.Pretty;
if( GUILayout.Button ("PrettyFormat") )
{
m_Format = Format.Pretty;
}
GUI.enabled = m_Format != Format.Plain;
if( GUILayout.Button ("Plain Format") )
{
m_Format = Format.Plain;
}
GUILayout.EndHorizontal();
GUI.enabled = true;
if( GUILayout.Button("Serialize", GUILayout.Height (100)) )
{
_TestSerialInfo();
}
m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos, GUILayout.Width (Screen.width-200));
if( m_str1.Length > 0)
{
GUILayout.TextArea(m_str1);
}
GUILayout.EndScrollView();
}
示例14: CompressedImageSize
public static int CompressedImageSize(Format format, int width, int height, int depth, int byteAlignment)
{
int rowPitch, slicePitch, totalSize;
switch (format)
{
case Format.CompressedRgbaS3tcDxt1Ext:
case Format.CompressedSrgbAlphaS3tcDxt1Ext:
case Format.CompressedRedRgtc1: // bc4
case Format.CompressedSignedRedRgtc1:
TextureHelper.GetInfoForSetDataCompressed(4, width, height, depth, byteAlignment, out rowPitch, out slicePitch, out totalSize);
return totalSize;
case Format.CompressedRgbaS3tcDxt3Ext:
case Format.CompressedSrgbAlphaS3tcDxt3Ext:
case Format.CompressedRgbaS3tcDxt5Ext:
case Format.CompressedSrgbAlphaS3tcDxt5Ext:
case Format.CompressedRgRgtc2:
case Format.CompressedSignedRgRgtc2:
case Format.CompressedRgbaBptcUf:
case Format.CompressedRgbaBptcSf:
case Format.CompressedRgbaBptc:
case Format.CompressedSrgbAlphaBptc:
TextureHelper.GetInfoForSetDataCompressed(8, width, height, depth, byteAlignment, out rowPitch, out slicePitch, out totalSize);
return totalSize;
default:
throw new InvalidOperationException(string.Format("Format '{0}' is not a known compressed format", format));
}
}
示例15: SqlUserDefinedTypeAttribute
public SqlUserDefinedTypeAttribute (Format f)
{
Format = f;
IsByteOrdered = false;
IsFixedLength = false;
MaxByteSize = MaxByteSizeValue;
}