本文整理汇总了C#中Pattern类的典型用法代码示例。如果您正苦于以下问题:C# Pattern类的具体用法?C# Pattern怎么用?C# Pattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Pattern类属于命名空间,在下文中一共展示了Pattern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsosTri90Tess
/// <summary>
/// Customize this child
/// </summary>
public IsosTri90Tess()
{
InitializeComponent();
double size = 40d;
double temp = Math.Tan(Math.PI / 4d) * (size / 2);
Pattern pat = new Pattern(size, temp * 2d, 0);
List<DoublePoint> tri1 = new List<DoublePoint>();
List<DoublePoint> tri2 = new List<DoublePoint>();
List<DoublePoint> tri3 = new List<DoublePoint>();
List<DoublePoint> tri4 = new List<DoublePoint>();
addStartZone(new Point(0, 0), new Point((int)size, 0));
setShapeHeight(temp);
tri1.Add(new DoublePoint(0, 0));
tri1.Add(new DoublePoint(size / 2, temp));
tri1.Add(new DoublePoint(0, temp*2));
tri2.Add(new DoublePoint(0, 0));
tri2.Add(new DoublePoint(size, 0));
tri2.Add(new DoublePoint(size / 2, temp));
tri3.Add(new DoublePoint(size, temp * 2));
tri3.Add(new DoublePoint(0, temp * 2));
tri3.Add(new DoublePoint(size / 2, temp));
tri4.Add(new DoublePoint(size, temp * 2));
tri4.Add(new DoublePoint(size, 0));
tri4.Add(new DoublePoint(size / 2, temp));
pat.addPattern(tri1);
pat.addPattern(tri2);
pat.addPattern(tri3);
pat.addPattern(tri4);
setPattern(pat);
}
示例2: RectTess
/// <summary>
/// Customize this child
/// </summary>
public RectTess(double ratio)
{
InitializeComponent();
double patBase = 30;
// ratioOver1 is used to scale down the rectangle
double ratioOver1 = ratio - 1;
if (ratioOver1 > 0)
{
// If the ratioOver1 is over 1, the scale down will be much to small, so we will make 1 the max.
if (ratioOver1 > 1d)
ratioOver1 = 1d;
patBase /= ratioOver1 + 1;
}
double heightRatio = ratio;
double patHeight = patBase * heightRatio;
double patWidth = patBase;
addStartZone(new Point(0, 0), new Point((int)patWidth, 0));
setShapeHeight(patHeight);
Pattern pat = new Pattern(patWidth, patHeight, 0d);
List<DoublePoint> tri1 = new List<DoublePoint>();
tri1.Add(new DoublePoint(0, 0));
tri1.Add(new DoublePoint(0, patHeight));
tri1.Add(new DoublePoint(patWidth, patHeight));
tri1.Add(new DoublePoint(patWidth, 0));
pat.addPattern(tri1);
setPattern(pat);
}
示例3: SchematronValidationEventArgs
/// <summary>
/// Creates a new instance of the <see cref="SchematronValidationEventArgs"/>.
/// </summary>
/// <param name="schematron">The <see cref="SchematronDocument"/> that detected the event.</param>
/// <param name="queryEngine">The <see cref="IQueryLanguage"/> that detected the event.</param>
/// <param name="pattern">The active <see cref="Pattern"/>.</param>
/// <param name="rule">The <see cref="Sepia.Schematron.Rule"/> that caused the event to be raised.</param>
/// <param name="assertion">The <see cref="Sepia.Schematron.Assertion"/> that caused the event to be raised.</param>
/// <param name="context">An <see cref="object"/> that provides the context for the <paramref name="rule"/> and <paramref name="assertion"/>.</param>
/// <param name="instance">An <see cref="XPathNavigator"/> to the document node that cause the event to be raised.</param>
public SchematronValidationEventArgs(SchematronDocument schematron, IQueryLanguage queryEngine, Pattern pattern, Rule rule, Assertion assertion, object context, XPathNavigator instance)
{
this.schematron = schematron;
this.queryEngine = queryEngine;
this.pattern = pattern;
this.rule = rule;
this.assertion = assertion;
this.instance = instance.Clone();
if (assertion == null)
{
message = "A schematron validation event occured.";
}
else
{
message = assertion.Message.ToString(instance, context);
}
List<string> diagnostics = new List<string>();
if (assertion != null && !string.IsNullOrEmpty(assertion.Diagnostics))
{
foreach (string id in assertion.Diagnostics.Split(' '))
{
Diagnostic diagnostic = schematron.Diagnostics[id];
diagnostics.Add(diagnostic.Message.ToString(instance, context));
}
}
this.diagnostics = diagnostics.ToArray();
}
示例4: MatchResult
public MatchResult(Pattern pattern, int x, int y, E_BlockType type)
{
this.pattern = pattern;
this.x = x;
this.y = y;
this.type = type;
}
示例5: PlayTact
public static void PlayTact(Note root, Pattern pattern, OutputDevice outputDevice)
{
PlayAccord(root, pattern, Direction.Down, outputDevice);
Thread.Sleep(400);
PlayAccord(root, pattern, Direction.Down, outputDevice);
Thread.Sleep(150);
PlayAccord(root, pattern, Direction.Up, outputDevice);
Thread.Sleep(400);
PlayAccord(root, pattern, Direction.Up, outputDevice);
Thread.Sleep(200);
PlayAccord(root, pattern, Direction.Down, outputDevice);
Thread.Sleep(150);
PlayAccord(root, pattern, Direction.Up, outputDevice);
Thread.Sleep(200);
PlayAccord(root, pattern, Direction.Down, outputDevice);
Thread.Sleep(400);
PlayAccord(root, pattern, Direction.Down, outputDevice);
Thread.Sleep(150);
PlayAccord(root, pattern, Direction.Up, outputDevice);
Thread.Sleep(400);
PlayAccord(root, pattern, Direction.Up, outputDevice);
Thread.Sleep(200);
PlayAccord(root, pattern, Direction.Down, outputDevice);
//Thread.Sleep(150);
//PlayAccord(root, pattern, Direction.Up, outputDevice);
Thread.Sleep(400);
}
示例6: GeneratePattern
private void GeneratePattern()
{
Pattern pattern = new Pattern();
int count = Random.Range(GameController.instance.minPatternSize_, GameController.instance.maxPatternSize_ + 1);
var node = nodes_.Last;
for (int index = Random.Range(0, nodes_.Count); index > 0; --index, node = node.Previous) ;
node.Value.isActive = false;
pattern.pattern.AddLast(node.Value);
for (int i = 0; i < count; ++i) {
LinkedList<PatternNode> adjacentNodes = node.Value.GetActiveAdjacentNodes();
if (adjacentNodes.Count < 0) {
break;
}
var adjacentNode = adjacentNodes.Last;
for (int index = Random.Range(0, adjacentNodes.Count); index > 0; --index, adjacentNode = adjacentNode.Previous) ;
pattern.pattern.AddLast(adjacentNode.Value);
node = nodes_.Find(adjacentNode.Value);
node.Value.isActive = false;
}
GameController.instance.RegisterPattern(pattern);
for (node = nodes_.First; node != null; node.Value.isActive = true, node = node.Next) ;
}
示例7: DragAndDrop
/// <summary>
/// This Method Performs Drag and Drop an element from scrolllist to Workfield by Sikuli4net
/// </summary>
/// <param name="scrollElement">Scroll Element class</param>
public void DragAndDrop(ScrollElement scrollElement)
{
Pattern pattern_Drag = new Pattern(Configuration.PathToImgs()+scrollElement.GetImageDragPatern());
Pattern pattern_Drop = new Pattern(Configuration.PathToImgs() + "wrk.png",0.5f);
Screen scrn = new Screen();
scrn.DragDrop(pattern_Drag,pattern_Drop);
}
示例8: Init
public override void Init(ParsingContext context, ParseTreeNode parseNode)
{
base.Init(context, parseNode);
foreach (var node in parseNode.ChildNodes)
{
if (node.AstNode is Pattern)
{
Pattern = node.AstNode as Pattern;
}
else if (node.AstNode is AuxiliaryNode)
{
var nodes = (node.AstNode as AuxiliaryNode).ChildNodes;
Conditions = nodes.OfType<Conditions>().FirstOrDefault();
Expression = nodes.OfType<Expression>().FirstOrDefault();
}
}
foreach (var astNode in new AstNode[] { Pattern, Conditions, Expression })
{
if (astNode != null)
{
astNode.Parent = this;
}
}
AsString = "match";
}
示例9: Captcha
public Captcha(int pattern, int leftOperand, int operatorValue, int rightOperand)
{
this.leftOperand = leftOperand;
this.rightOperand = rightOperand;
this.operatorValue = operatorValue;
this.pattern = (Pattern)pattern;
}
示例10: ParseMatcher
public static Pattern ParseMatcher(string feature, bool applyToMembers)
{
Match m = Parser.Match(feature);
if (!m.Success)
{
DLog.Warning(DContext.CompilerStart, "pattern parsing error :" + feature);
return null;
}
Pattern match = new Pattern();
if (m.Groups[1].Success) match.TypeMatcher = m.Groups[1].Value;
if (m.Groups[2].Success) match.TypeInheritanceKeyword = m.Groups[2].Value;
if (m.Groups[3].Success) match.TypeInheritanceName = m.Groups[3].Value;
if (m.Groups[4].Success) match.MemberMatcher = m.Groups[4].Value;
if (m.Groups[5].Success) match.MembersPublicOnly = true;
if (m.Groups[6].Success) match.Attributes.Add(m.Groups[6].Value);
if (m.Groups[7].Success)
foreach (Capture cap in m.Groups[7].Captures)
match.Attributes.Add(cap.Value);
match.ApplyToMembers = applyToMembers;
if (match.TypeMatcher == null && match.MemberMatcher == null)
{
DLog.Warning(DContext.CompilerStart, "either type or member matcher should be specified: " + feature);
return match;
}
return match;
}
示例11: Main
public static void Main(string[] args)
{
string inputname = args[0];
string outputname = args[1];
string[] lines = File.ReadAllLines(inputname);
int ncases = int.Parse(lines[0]);
int nline = 0;
IList<string> results = new List<string>();
for (int k = 0; k < ncases; k++)
{
Console.WriteLine(string.Format("Solving Case #{0}", k + 1));
nline++;
string[] numbers = lines[nline].Split(' ');
int height = int.Parse(numbers[0]);
int width = int.Parse(numbers[1]);
Pattern pattern = new Pattern(width, height);
for (int j = 0; j < height; j++)
{
nline++;
pattern.SetRow(j, lines[nline]);
Console.WriteLine(lines[nline]);
}
results.Add(string.Format("Case #{0}: {1}", k+1, pattern.HasSolution() ? "YES" : "NO"));
}
File.WriteAllLines(outputname, results.ToArray());
}
示例12: CreateEnvironmentPattern
private static Pattern<Word, ShapeNode> CreateEnvironmentPattern(Pattern<Word, ShapeNode> env)
{
Pattern<Word, ShapeNode> pattern = null;
if (!env.IsEmpty)
pattern = new Pattern<Word, ShapeNode>(env.Children.DeepCloneExceptBoundaries());
return pattern;
}
示例13: SynthesisRewriteRuleSpec
public SynthesisRewriteRuleSpec(SpanFactory<ShapeNode> spanFactory, MatcherSettings<ShapeNode> matcherSettings, bool isIterative, Pattern<Word, ShapeNode> lhs,
IEnumerable<RewriteSubrule> subrules)
: base(lhs.IsEmpty)
{
Pattern.Acceptable = match => CheckTarget(match, lhs);
if (lhs.IsEmpty)
{
Pattern.Children.Add(new Constraint<Word, ShapeNode>(FeatureStruct.New().Symbol(HCFeatureSystem.Segment, HCFeatureSystem.Anchor).Value));
}
else
{
foreach (Constraint<Word, ShapeNode> constraint in lhs.Children.Cast<Constraint<Word, ShapeNode>>())
{
var newConstraint = constraint.DeepClone();
if (isIterative)
newConstraint.FeatureStruct.AddValue(HCFeatureSystem.Modified, HCFeatureSystem.Clean);
Pattern.Children.Add(newConstraint);
}
}
Pattern.Freeze();
int i = 0;
foreach (RewriteSubrule subrule in subrules)
{
if (lhs.Children.Count == subrule.Rhs.Children.Count)
SubruleSpecs.Add(new FeatureSynthesisRewriteSubruleSpec(spanFactory, matcherSettings, isIterative, subrule, i));
else if (lhs.Children.Count > subrule.Rhs.Children.Count)
SubruleSpecs.Add(new NarrowSynthesisRewriteSubruleSpec(spanFactory, matcherSettings, isIterative, lhs.Children.Count, subrule, i));
else if (lhs.Children.Count == 0)
SubruleSpecs.Add(new EpenthesisSynthesisRewriteSubruleSpec(spanFactory, matcherSettings, isIterative, subrule, i));
i++;
}
}
示例14: Init
public void Init(string s)
{
animation = GetComponent<VillagerAnimation>();
animation.Init (s);
skinMaterial = GetComponentInChildren<MeshRenderer>().material;
origColor = skinMaterial.color;
// music stuff
musicToggle = GetComponent<ToggleSuspend>();
musicPattern = GetComponent<Pattern>();
SetMusicPattern();
musicSample = GetComponent<Sampler>();
SetMusicSample();
keyboardPosition = transform.localPosition;
textMesh = GetComponentInChildren<TextMesh>();
letter = s;
textMesh.text = s;
currentState = State.Idle;
timeSinceLastDanced = Time.time;
}
示例15: TwoColumns
public static Pattern TwoColumns()
{
var pattern = new Pattern();
pattern.WholeColumns.Add(-1);
pattern.WholeColumns.Add(-2);
return pattern;
}