本文整理汇总了C#中Primitive类的典型用法代码示例。如果您正苦于以下问题:C# Primitive类的具体用法?C# Primitive怎么用?C# Primitive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Primitive类属于命名空间,在下文中一共展示了Primitive类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Remove
/// <summary>
/// Remove a file (or directory with all sub files) from an existing zip archive.
/// </summary>
/// <param name="zipFile">The zip archive to remove a file from.</param>
/// <param name="files">
/// An array of files to remove from the zip archive.
/// A single file or directory may also be deleted.
/// Any directories will be recursively removed from the zip.
/// </param>
/// <returns>An error message or "".</returns>
public static Primitive Remove(Primitive zipFile, Primitive files)
{
try
{
using (ZipFile zip = ZipFile.Read(zipFile))
{
if (SBArray.IsArray(files))
{
Primitive indices = SBArray.GetAllIndices(files);
int count = SBArray.GetItemCount(indices);
for (int i = 1; i <= count; i++)
{
RemoveFromArchive(zip, files[indices[i]]);
}
}
else
{
RemoveFromArchive(zip, files);
}
zip.Save();
}
return "";
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
return Utilities.GetCurrentMethod() + " " + ex.Message;
}
}
开发者ID:litdev1,项目名称:LitDev,代码行数:39,代码来源:Zip.cs
示例2: CreateCursor
/// <summary>
/// Create a cursor that can be set using SetUserCursor or SetShapeCursor.
/// An ImageList image can be resized with LDImage.Resize.
/// </summary>
/// <param name="imageName">The file path or ImageList image.</param>
/// <param name="xHotSpot">The x pixel to use as the hot spot.</param>
/// <param name="yHotSpot">The y pixel to use as the hot spot.</param>
/// <returns>A cursor.</returns>
public static Primitive CreateCursor(Primitive imageName, Primitive xHotSpot, Primitive yHotSpot)
{
Type ShapesType = typeof(Shapes);
Type ImageListType = typeof(ImageList);
Dictionary<string, BitmapSource> _savedImages;
BitmapSource img;
string cursorName = "";
try
{
_savedImages = (Dictionary<string, BitmapSource>)ImageListType.GetField("_savedImages", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
if (!_savedImages.TryGetValue((string)imageName, out img))
{
imageName = ImageList.LoadImage(imageName);
if (!_savedImages.TryGetValue((string)imageName, out img))
{
return cursorName;
}
}
MethodInfo method = ShapesType.GetMethod("GenerateNewName", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase);
cursorName = method.Invoke(null, new object[] { "Cursor" }).ToString();
Bitmap bmp = FastPixel.GetBitmap(img);
Cursor cursor = createCursor(bmp, xHotSpot, yHotSpot);
cursors[cursorName] = cursor;
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
}
return cursorName;
}
开发者ID:litdev1,项目名称:LitDev,代码行数:41,代码来源:Cursors.cs
示例3: FFTForward
/// <summary>
/// Compute a FFT (Fast Fourier Transform).
/// </summary>
/// <param name="real">An array of real values to calculate the FFT from.</param>
/// <returns>An array of complex data (real amplitude and imaginary phase) or "FAILED".
/// For each complex pair the index is the real part and the value is the imaginary part.</returns>
public static Primitive FFTForward(Primitive real)
{
try
{
Type PrimitiveType = typeof(Primitive);
Dictionary<Primitive, Primitive> dataMap;
dataMap = (Dictionary<Primitive, Primitive>)PrimitiveType.GetField("_arrayMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance).GetValue(real);
int length = dataMap.Count;
Complex[] complex = new Complex[length];
int i = 0;
foreach (KeyValuePair<Primitive, Primitive> kvp in dataMap)
{
double realData = double.Parse(kvp.Value);
complex[i++] = new Complex(realData, 0);
}
Fourier.BluesteinForward(complex, FourierOptions.Default);
string result = "";
for (i = 0; i < length; i++)
{
result += (i + 1).ToString() + "=" + (complex[i].Real.ToString(CultureInfo.InvariantCulture) + "\\=" + complex[i].Imaginary.ToString(CultureInfo.InvariantCulture) + "\\;") + ";";
}
return Utilities.CreateArrayMap(result);
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
return "FAILED";
}
}
开发者ID:litdev1,项目名称:LitDev,代码行数:35,代码来源:MathX.cs
示例4: StateFactory
/// <summary>
/// Initializes a new instance of the StateFactory
/// </summary>
/// <param name="device"></param>
/// <param name="enumType"></param>
/// <param name="ubershader"></param>
/// <param name="vertexInputElements"></param>
/// <param name="blendState"></param>
/// <param name="rasterizerState"></param>
private StateFactory ( Ubershader ubershader, Type enumType, Primitive primitive, VertexInputElement[] vertexInputElements )
: base(ubershader.GraphicsDevice)
{
this.ubershader = ubershader;
Enumerate( enumType, ubershader, (ps,i) => { ps.VertexInputElements = vertexInputElements; ps.Primitive = primitive; } );
}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:16,代码来源:StateFactory.cs
示例5: TransformTexCoords
public void TransformTexCoords(List<Vertex> vertices, Vector3 center, Primitive.TextureEntryFace teFace)
{
float r = teFace.Rotation;
float os = teFace.OffsetU;
float ot = teFace.OffsetV;
float ms = teFace.RepeatU;
float mt = teFace.RepeatV;
float cosAng = (float)Math.Cos(r);
float sinAng = (float)Math.Sin(r);
for (int i = 0; i < vertices.Count; i++)
{
Vertex vertex = vertices[i];
if (teFace.TexMapType == MappingType.Default)
{
TransformTexCoord(ref vertex.TexCoord, cosAng, sinAng, os, ot, ms, mt);
}
else if (teFace.TexMapType == MappingType.Planar)
{
Vector3 vec = vertex.Position;
vec.X *= vec.X;
vec.Y *= vec.Y;
vec.Z *= vec.Z;
TransformPlanarTexCoord(ref vertex.TexCoord, vertex, center, vec);
}
vertices[i] = vertex;
}
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:31,代码来源:Texture.cs
示例6: GetImage
/// <summary>
/// Do a Bing search for Web images.
/// </summary>
/// <param name="search">The search text.</param>
/// <returns>An array of results, index url and value description.</returns>
public static Primitive GetImage(Primitive search)
{
try
{
if (bNewAPI)
{
JsonWeb jsonWeb = cognitive.SearchRequest(search);
if (null == jsonWeb.images) return "";
string result = "";
foreach (var site in jsonWeb.images.value)
{
result += Utilities.ArrayParse(site.contentUrl) + "=" + Utilities.ArrayParse(site.name) + ";";
}
return Utilities.CreateArrayMap(result);
}
else
{
var query = bing.Image(search, null, cognitive.mkt, null, null, null, null);
var sites = query.Execute();
string result = "";
foreach (var site in sites)
{
result += Utilities.ArrayParse(site.MediaUrl) + "=" + Utilities.ArrayParse(site.Title) + ";";
}
return Utilities.CreateArrayMap(result);
}
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
return "";
}
}
开发者ID:litdev1,项目名称:LitDev,代码行数:40,代码来源:Search.cs
示例7: BuildFace
private static void BuildFace(ref Face face, Primitive prim, List<Vertex> vertices, Path path,
Profile profile, Primitive.TextureEntryFace teFace, bool isSculpted)
{
if (teFace != null)
face.TextureFace = teFace;
else
throw new ArgumentException("teFace cannot be null");
face.Vertices.Clear();
if ((face.Mask & FaceMask.Cap) != 0)
{
if (((face.Mask & FaceMask.Hollow) == 0) &&
((face.Mask & FaceMask.Open) == 0) &&
(prim.PrimData.PathBegin == 0f) &&
(prim.PrimData.ProfileCurve == ProfileCurve.Square) &&
(prim.PrimData.PathCurve == PathCurve.Line))
{
CreateUnCutCubeCap(ref face, vertices, path, profile);
}
else
{
CreateCap(ref face, vertices, path, profile);
}
}
else if ((face.Mask & FaceMask.End) != 0 || (face.Mask & FaceMask.Side) != 0)
{
CreateSide(ref face, prim, vertices, path, profile, isSculpted);
}
else
{
throw new RenderingException("Unknown/uninitialized face type");
}
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:34,代码来源:Face.cs
示例8: Container
public Container(Stream stream)
{
UInt16 stringLength = stream.ReadUInt16();
Name = stream.ReadAsciiString(stringLength);
ContainerType = stream.ReadUInt8();
Flags = (ContainerFlags)stream.ReadUInt16();
PrimitiveCount = stream.ReadUInt16();
PackfileBaseOffset = stream.ReadUInt32();
CompressionType = stream.ReadUInt8();
stringLength = stream.ReadUInt16();
StubContainerParentName = stream.ReadAsciiString(stringLength);
Int32 auxDataSize = stream.ReadInt32();
AuxData = new byte[auxDataSize];
stream.Read(AuxData, 0, auxDataSize);
TotalCompressedPackfileReadSize = stream.ReadInt32();
Primitives = new List<Primitive>();
PrimitiveSizes = new List<WriteTimeSizes>();
for (UInt16 i = 0; i < PrimitiveCount; i++)
{
var sizes = stream.ReadStruct<WriteTimeSizes>();
PrimitiveSizes.Add(sizes);
}
for (UInt16 i = 0; i < PrimitiveCount; i++)
{
Primitive primitive = new Primitive(stream);
Primitives.Add(primitive);
}
}
开发者ID:rodrigonh,项目名称:ThomasJepp.SaintsRow,代码行数:31,代码来源:Container.cs
示例9: Equals
public bool Equals(Primitive primitive)
{
if (this.GetType().Equals(primitive.GetType()))
{
if (this is Activity)
{
Activity a = this as Activity;
Activity target = primitive as Activity;
if (a.PrID == target.PrID)
return true;
}
else if (this is Event)
{
Event ev = this as Event;
Event target = primitive as Event;
if (ev.categ.Equals(target.categ))
return true;
}
else if (this is Flow)
{
Flow f = this as Flow;
Flow target = primitive as Flow;
if (f.categ.Equals(target.categ) &&
f.Condition.Equals(target.Condition) &&
f.SourceID == target.SourceID &&
f.TargetID == target.TargetID)
return true;
}
}
return false;
}
开发者ID:Vnepomuceno,项目名称:organix,代码行数:31,代码来源:Primitive.cs
示例10: FFTComplex
/// <summary>
/// Create an array of complex values from arrays of real and imaginary parts.
/// </summary>
/// <param name="real">An array of real data.</param>
/// <param name="imaginary">An array of imaginary data.</param>
/// <returns>An array of complex data (real amplitude and imaginary phase), "MISMATCH" or "FAILED".
/// For each complex pair the index is the real part and the value is the imaginary part.</returns>
public static Primitive FFTComplex(Primitive real, Primitive imaginary)
{
try
{
Type PrimitiveType = typeof(Primitive);
Dictionary<Primitive, Primitive> dataReal, dataImaginary;
dataReal = (Dictionary<Primitive, Primitive>)PrimitiveType.GetField("_arrayMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance).GetValue(real);
dataImaginary = (Dictionary<Primitive, Primitive>)PrimitiveType.GetField("_arrayMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance).GetValue(imaginary);
int length = dataReal.Count;
if (length != dataImaginary.Count) return "MISMATCH";
List<double> realData = new List<double>();
foreach (KeyValuePair<Primitive, Primitive> kvp in dataReal)
{
realData.Add(kvp.Value);
}
List<double> imaginaryData = new List<double>();
foreach (KeyValuePair<Primitive, Primitive> kvp in dataImaginary)
{
imaginaryData.Add(kvp.Value);
}
string result = "";
for (int i = 0; i < length; i++)
{
result += (i + 1).ToString() + "=" + (realData[i].ToString(CultureInfo.InvariantCulture) + "\\=" + imaginaryData[i].ToString(CultureInfo.InvariantCulture) + "\\;") + ";";
}
return Utilities.CreateArrayMap(result);
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
return "FAILED";
}
}
开发者ID:litdev1,项目名称:LitDev,代码行数:40,代码来源:MathX.cs
示例11: Render
public void Render(Primitive primitive, SpriteBatch spriteBatch)
{
if (this.spriteBatch == null)
{
this.spriteBatch = new SpriteBatchWrapper(spriteBatch);
}
Render(primitive);
}
开发者ID:xxy1991,项目名称:cozy,代码行数:8,代码来源:XNARenderer.cs
示例12: CachePrimitiveWrapper
private CachePrimitiveWrapper(SerializationInfo info, StreamingContext context)
{
this.Primitive = new Primitive
{
Type = (DynamoDBEntryType)info.GetValue("Type", typeof(DynamoDBEntryType)),
Value = info.GetValue("Value", typeof(object))
};
}
开发者ID:LCHarold,项目名称:linq2dynamodb,代码行数:8,代码来源:CachePrimitiveWrapper.cs
示例13: MD5HashFile
/// <summary>
/// Create an MD5 hash of a file.
/// This 32 character hash is for file data integrity checks (e.g. a file contents is unchanged).
/// </summary>
/// <param name="fileName">The full path to a file to get the hash.</param>
/// <returns>The 32 character hex MD5 Hash.</returns>
public static Primitive MD5HashFile(Primitive fileName)
{
if (!System.IO.File.Exists(fileName))
{
Utilities.OnFileError(Utilities.GetCurrentMethod(), fileName);
return "";
}
return StringEncryption.CalculateMD5HashFile(fileName);
}
开发者ID:litdev1,项目名称:LitDev,代码行数:15,代码来源:Encryption.cs
示例14: Initialize
public override void Initialize(string tableName, Type tableEntityType, Primitive hashKeyValue)
{
base.Initialize(tableName, tableEntityType, hashKeyValue);
if (GetIndexListKeyInCache(_hashKeyValue).Length > MaxKeyLength)
{
throw new ArgumentException("The hash key value is too long for MemcacheD. Cannot use cache with that value.");
}
}
开发者ID:howcheng,项目名称:linq2dynamodb,代码行数:9,代码来源:EnyimTableCache.cs
示例15: startAllAccessTrial
public Response startAllAccessTrial(int vismastersID, string acmID)
{
Hashtable vars = new Hashtable();
vars["action"] = "startAllAccessTrial";
vars["aid"] = vismastersID;
vars["acmid"] = acmID;
Primitive<string> prim = new Primitive<string>("trial");
return makePost(vars, new ResponseParser.DataParser(prim.fromResponseXml));
}
开发者ID:archvision,项目名称:vismasters_web_services_net,代码行数:9,代码来源:Acms.cs
示例16: Start
/// <summary>
/// Starts the engine, trying to run at the given framerate.
/// </summary>
/// <param name="fps">The target framerate</param>
public static void Start(Primitive fps)
{
try {
SmallTK.GameEngine.Start(fps);
}
catch (Exception e) {
TextWindow.Show();
Console.WriteLine(e);
}
}
开发者ID:kroltan,项目名称:SmallTK,代码行数:14,代码来源:GameEngine.cs
示例17: ChangePrimitive
public override void ChangePrimitive(Primitive primitive)
{
// Load sphere and apply effect to sphere.
ResourceContentManager resourceContentManager = new ResourceContentManager(_serviceProvider, Resources.ResourceManager);
Model model = resourceContentManager.Load<Model>(primitive.ToString());
foreach (ModelMesh mesh in model.Meshes)
foreach (ModelMeshPart meshPart in mesh.MeshParts)
meshPart.Effect = _effect;
Model = model;
}
开发者ID:modulexcite,项目名称:xbuilder,代码行数:10,代码来源:EffectRenderer.cs
示例18: DelayUpTo
/// <summary>
/// Delay up to a maximum interval since the last time this is called.
/// Useful in a game loop to maintain an even play speed.
/// </summary>
/// <param name="delay">The maximum delay in ms.</param>
public static void DelayUpTo(Primitive delay)
{
if (null == delayWatch)
{
delayWatch = new Stopwatch();
delayWatch.Start();
}
TimeSpan interval = TimeSpan.FromMilliseconds(delay) - delayWatch.Elapsed;
if (interval > TimeSpan.Zero) Thread.Sleep(interval);
delayWatch.Restart();
}
开发者ID:litdev1,项目名称:LitDev,代码行数:16,代码来源:Stopwatch.cs
示例19: Get
//static HashSet<OperatorAction> alls_ = new HashSet<OperatorAction>();
//public OperatorAction (Operator op, Primitive left, Primitive right)
//{
// if (this.Operator < Operator.__Binary)
// this.Left = Primitive.Undefined;
// this.Operator = op;
// this.Left = left;
// this.Right = right;
// alls_.Add(this);
//}
//public static OperatorAction GetAction (Operator op, Primitive left, Primitive right)
//{
// if (op < Operator.__Binary)
// left = Primitive.Undefined;
// foreach (OperatorAction action in alls_) {
// if (op == action.Operator && left == action.Left && right == action.Right)
// return action;
// }
// return null;
//}
//public Operator Operator { get; private set; }
//public Primitive Left { get; private set; }
//public Primitive Right { get; private set; }
//public OperatorImplem Action { get; set; }
//public override bool Equals (object obj)
//{
// OperatorAction action = obj as OperatorAction;
// if (action == null)
// return false;
// return this.Operator == action.Operator && this.Left == action.Left && this.Right == action.Right;
//}
//public override int GetHashCode ()
//{
// return (int)this.Operator ^ (int)this.Left ^ (int)this.Right;
//}
//public override string ToString ()
//{
// if (this.Operator < Operator.__Binary)
// return this.Operator + " " + this.Right;
// return this.Left + " " + this.Operator + " " + this.Right;
//}
public static OperatorImplem Get(Operator op, Primitive left, Primitive right)
{
if (op < Operator.__Binary)
left = Primitive.Undefined;
if (op == Operator.And)
return OperatorAction.andLogic;
if (op == Operator.Or)
return OperatorAction.orLogic;
if (left == Primitive.Error || right == Primitive.Error)
return OperatorAction.isError;
IOperations ops;
if (Operand.TypeIsSigned(left) && Operand.TypeIsSigned(right))
ops = OperationsSigned.I;
else if (Operand.TypeIsUnsigned(left) && Operand.TypeIsUnsigned(right))
ops = OperationsUnsigned.I;
else if (Operand.TypeIsNumber(left) || Operand.TypeIsNumber(right))
ops = OperationsDecimal.I;
else if (left == Primitive.Boolean || right == Primitive.Boolean)
ops = OperationsBoolean.I;
else
throw new Exception("Undef operator");
switch (op) {
case Operator.Add:
return ops.Add;
case Operator.Sub:
return ops.Sub;
case Operator.Mul:
return ops.Mul;
case Operator.Div:
return ops.Div;
case Operator.Equals:
return ops.Equals;
case Operator.NotEquals:
return ops.NotEquals;
case Operator.Less:
return ops.Less;
case Operator.LessEq:
return ops.LessEq;
case Operator.More:
return ops.More;
case Operator.MoreEq:
return ops.MoreEq;
case Operator.Not:
return ops.Not;
default:
throw new Exception("Undef operator");
}
throw new Exception("Undef operator");
}
开发者ID:AxFab,项目名称:amy,代码行数:95,代码来源:OperatorAction.cs
示例20: PlayDX7
/// <summary>
/// Play DX7.
/// </summary>
/// <param name="channels">An array of values for each channel (values between 0 and 1, usually 8 channels).</param>
public static void PlayDX7(Primitive channels)
{
Initialise();
try
{
int i, iServo;
double duration = 0.0225;
int sampleCount = (int)(duration * waveFormat.SamplesPerSecond);
// buffer description
SoundBufferDescription soundBufferDescription = new SoundBufferDescription();
soundBufferDescription.Format = waveFormat;
soundBufferDescription.Flags = BufferFlags.Defer;
soundBufferDescription.SizeInBytes = sampleCount * waveFormat.BlockAlignment;
SecondarySoundBuffer secondarySoundBuffer = new SecondarySoundBuffer(directSound, soundBufferDescription);
short[] rawsamples = new short[sampleCount];
int stopSamples = (int)(0.0004 * waveFormat.SamplesPerSecond);
List<int> servoSamples = new List<int>();
Primitive indices = SBArray.GetAllIndices(channels);
int servoCount = SBArray.GetItemCount(indices);
for (iServo = 1; iServo <= servoCount; iServo++)
{
servoSamples.Add((int)((0.0007 + 0.0008 * channels[indices[iServo]]) * waveFormat.SamplesPerSecond));
}
//Lead-in
int leading = sampleCount - (servoCount + 1) * stopSamples - servoSamples.Sum();
int sample = 0;
for (i = 0; i < leading; i++) rawsamples[sample++] = 0;
//Servos
for (i = 0; i < stopSamples; i++) rawsamples[sample++] = (short)(-amplitude);
for (iServo = 0; iServo < servoCount; iServo++)
{
for (i = 0; i < servoSamples[iServo]; i++) rawsamples[sample++] = amplitude;
for (i = 0; i < stopSamples; i++) rawsamples[sample++] = (short)(-amplitude);
}
//load audio samples to secondary buffer
secondarySoundBuffer.Write(rawsamples, 0, LockFlags.EntireBuffer);
//play audio buffer
secondarySoundBuffer.Play(0, PlayFlags.None);
//wait to complete before returning
while ((secondarySoundBuffer.Status & BufferStatus.Playing) != 0);
secondarySoundBuffer.Dispose();
}
catch (Exception ex)
{
TextWindow.WriteLine(ex.Message);
}
}
开发者ID:litdev1,项目名称:WaveForms,代码行数:58,代码来源:WaveForm.cs
注:本文中的Primitive类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论