public void QueryOptionsWithFluentlyExpandUserFieldReturnsTheNestedExpandUserField() { var sut = CG.QueryOptions() .ExpandUserField(true); sut.ToString().ShouldBe("<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>"); }
public void BoolValueFalseReturnsAValueOfZero() { var expected = @"<Value Type=""Boolean"">0</Value>".AsXml(); var sut = CG.BooleanValue(false); sut.ToString().AsXml().ShouldBe(expected); }
public void BoolValueTrueReturnsAValueOfOne() { var expected = @"<Value Type=""Boolean"">1</Value>".AsXml(); var sut = CG.BooleanValue(true); sut.ToString().AsXml().ShouldBe(expected); }
ilPSP.LinSolvers.monkey.Solver GetSolver(IMutableMatrixEx Mtx) { ilPSP.LinSolvers.monkey.Solver solver; switch (WhichSolver) { case _whichSolver.CG: { var _solver = new CG(); solver = _solver; _solver.DevType = ilPSP.LinSolvers.monkey.DeviceType.Cuda; _solver.MaxIterations = Switcher <int>(_solver.MaxIterations, LinConfig.MaxSolverIterations); _solver.Tolerance = Switcher <double>(_solver.Tolerance, LinConfig.ConvergenceCriterion); break; } case _whichSolver.PCG: { var _solver = new PCG(); solver = _solver; _solver.DevType = ilPSP.LinSolvers.monkey.DeviceType.Cuda; _solver.MaxIterations = Switcher <int>(_solver.MaxIterations, LinConfig.MaxSolverIterations); _solver.Tolerance = Switcher <double>(_solver.Tolerance, LinConfig.ConvergenceCriterion); break; } default: throw new NotImplementedException(); } solver.DefineMatrix(Mtx); return(solver); }
private void CG_MouseWheel(object sender, MouseEventArgs e) { var delta = e.Delta; Transform(CG.ScaleP(eps(delta))); Draw(); }
public void AViewCanSetARowLimit() { var limit = Fixture.Create <int>(); var sut = CG.View().RowLimit(limit); sut.ToString().ShouldBe(string.Format("<View><RowLimit>{0}</RowLimit></View>", limit)); }
private void OnTriggerEnter2D(Collider2D other) { if (!isSwitched) { //objectsOnSwitch.Add(other.gameObject); // register object to get called on tick // TODO toffa: make this work in case it is another object than player that trigger //GameObject.Find("GameLoop").GetComponent<WorldManager>().AddObserver(other.gameObject.GetComponent<PlayerController>() as ITickObserver, this); CG.observeWire(this); pulsate(true); GetComponentInChildren <AudioSource>().Play(); isSwitched = true; SwitchTick = GameObject.Find("GameLoop").GetComponent <WorldManager>().TL.GetCursorIndex(); SpriteRenderer sr = GetComponentInChildren <SpriteRenderer>(); if (!!sr) { sr.sprite = spriteSwitched; } } TryReset(); }
public override void SendMouseDown(MouseButton button) { var pos = _getMousePoint(); MouseState[button] = true; if ((button == MouseButton.Left)) { var e = CG.CGEventCreateMouseEvent(IntPtr.Zero, CGEventType.LeftMouseDown, new CGPoint() { x = pos.X, y = pos.Y }, CGMouseButton.Left); //CG.EventSetIntegerValueField(e, CGEventField.MouseEventClickState,1); CG.CGEventPost(CGEventTapLocation.HIDEventTap, e); CF.CFRelease(e); } if ((button == MouseButton.Right)) { var e = CG.CGEventCreateMouseEvent(IntPtr.Zero, CGEventType.RightMouseDown, new CGPoint() { x = pos.X, y = pos.Y }, CGMouseButton.Right); CG.CGEventPost(CGEventTapLocation.HIDEventTap, e); CF.CFRelease(e); } if ((button == MouseButton.Middle)) { var e = CG.CGEventCreateMouseEvent(IntPtr.Zero, CGEventType.OtherMouseDown, new CGPoint() { x = pos.X, y = pos.Y }, CGMouseButton.Center); CG.CGEventPost(CGEventTapLocation.HIDEventTap, e); CF.CFRelease(e); } if ((button == MouseButton.Button1)) { var e = CG.CGEventCreateMouseEvent(IntPtr.Zero, CGEventType.OtherMouseDown, new CGPoint() { x = pos.X, y = pos.Y }, CGMouseButton.Right); CG.EventSetIntegerValueField(e, CGEventField.MouseEventButtonNumber, 3); CG.CGEventPost(CGEventTapLocation.HIDEventTap, e); CF.CFRelease(e); } if ((button == MouseButton.Button2)) { var e = CG.CGEventCreateMouseEvent(IntPtr.Zero, CGEventType.OtherMouseDown, new CGPoint() { x = pos.X, y = pos.Y }, CGMouseButton.Right); CG.EventSetIntegerValueField(e, CGEventField.MouseEventButtonNumber, 4); CG.CGEventPost(CGEventTapLocation.HIDEventTap, e); CF.CFRelease(e); } }
// After the generated lexer code determines the boundaries of the token, // one of these methods extracts the value of the token (e.g. "17L" => (long)17) // There are value parsers for identifiers, numbers, and strings; certain // parser cores are also accessible as public static methods. #region String parsing void ParseSQStringValue() { int len = InputPosition - _startPosition; if (!_parseNeeded && len == 3) { _value = CG.Cache(CharSource[_startPosition + 1]); } else { string s = ParseStringCore(_startPosition); _value = s; if (s.Length == 1) { _value = CG.Cache(s[0]); } else if (s.Length == 0) { Error(_startPosition - InputPosition, "Empty character literal".Localized()); } else { Error(_startPosition - InputPosition, "Character literal has {0} characters (there should be exactly one)".Localized(s.Length)); } } }
public void QueryOptionsWithDatesInUtcReturnsAFilledQueryOptionsTag() { var sut = CG.QueryOptions( CG.DatesInUtc(true)); sut.ToString().ShouldBe("<QueryOptions><DatesInUtc>True</DatesInUtc></QueryOptions>"); }
public void BareFieldRefReturnsAFieldRefTagWithANameAttributes() { var name = Fixture.Create <string>(); var sut = CG.FieldRef(name); sut.ToString().ShouldBe(string.Format(@"<FieldRef Name=""{0}"" />", name)); }
public void WarpMouse(double x, double y) { CG.WarpMouseCursorPosition(new NSPoint() { X = x, Y = y }); _ignoreNextMovement = true; }
public void FluentOrderByWithFieldRefReturnsAnOrderByAndAFieldRef() { var name = Fixture.Create <string>(); var sut = CG.Query().OrderBy(o => o.AddFieldRef(name, false)); var expected = string.Format(@"<Query><OrderBy><FieldRef Name=""{0}"" Ascending=""FALSE"" /></OrderBy></Query>", name).AsXml(); sut.ToString().AsXml().ShouldBe(expected); }
public void OrderByWithFieldRefAscendingReturnsAnOrderByAndAnAscendingFieldRef() { var name = Fixture.Create <string>(); var sut = CG.OrderBy().AddFieldRefAscending(name); var expected = string.Format(@"<OrderBy><FieldRef Name=""{0}"" Ascending=""TRUE"" /></OrderBy>", name).AsXml(); sut.ToString().AsXml().ShouldBe(expected); }
void ParseStringValue() { _value = ParseStringCore(_startPosition); if (_value.ToString().Length < 16) { _value = CG.Cache(_value); } }
public void ValueOnCgReturnsAValueTag() { var val = Fixture.Create <string>(); var expected = string.Format(@"<Value Type=""Number"">{0}</Value>", val).AsXml(); var sut = CG.Value(CG.ValueType.Number, val); sut.ToString().AsXml().ShouldBe(expected); }
public void QueryOptionsInAViewWithFluentlyDatesInUtcReturnsAllNestedTags() { var sut = CG.View() .QueryOptions(qo => qo .DatesInUtc(true)); sut.ToString().ShouldBe("<View><QueryOptions><DatesInUtc>True</DatesInUtc></QueryOptions></View>"); }
public void NumberValueOnCgReturnsAValueTagWithTypeNumber() { var val = Fixture.Create <double>(); var expected = string.Format(@"<Value Type=""Number"">{0}</Value>", val).AsXml(); var sut = CG.NumberValue(val); sut.ToString().AsXml().ShouldBe(expected); }
public void BareEqReturnsAnEqTagWithNoAttributes() { var lhs = Fixture.Create <BaseCoreElement>(); var rhs = Fixture.Create <BaseCoreElement>(); var sut = CG.Contains(lhs, rhs); sut.ToString().ShouldBe(string.Format(@"<Contains>{0}{1}</Contains>", lhs, rhs)); }
void ParseStringValue(bool isTripleQuoted) { _value = ParseStringCore(isTripleQuoted); if (_value.ToString().Length < 64) { _value = CG.Cache(_value); } }
private CGEventFlags BuildFlags(IntPtr e) { var flags = CG.CGEventGetFlags(e); if (KeyboardState.IsKeyDown(Key.ShiftLeft) || KeyboardState.IsKeyDown(Key.ShiftLeft)) { flags = flags | CGEventFlags.Shift; } if (KeyboardState.IsKeyDown(Key.CapsLock)) //not sure about this, i likely need to poll for caps state and then toggle. { flags = flags | CGEventFlags.CapsLock; } if (KeyboardState.IsKeyDown(Key.AltLeft) || KeyboardState.IsKeyDown(Key.AltRight)) //not sure about this, i likely need to poll for caps state and then toggle. { flags = flags | CGEventFlags.Alt; } if (KeyboardState.IsKeyDown(Key.ControlLeft) || KeyboardState.IsKeyDown(Key.ControlRight)) //not sure about this, i likely need to poll for caps state and then toggle. { flags = flags | CGEventFlags.Control; } if (KeyboardState.IsKeyDown(Key.WinLeft)) //not sure about this, i likely need to poll for caps state and then toggle. { flags = flags | CGEventFlags.Command; } //treat winright as a function key on osx??? Do i really need to set this flag? if (KeyboardState.IsKeyDown(Key.WinRight)) //not sure about this, i likely need to poll for caps state and then toggle. { flags = flags | CGEventFlags.SecondaryFn; } if (KeyboardState.IsKeyDown(Key.KeypadDecimal) || KeyboardState.IsKeyDown(Key.KeypadPeriod) || KeyboardState.IsKeyDown(Key.KeypadAdd) || KeyboardState.IsKeyDown(Key.KeypadPlus) || KeyboardState.IsKeyDown(Key.KeypadMinus) || KeyboardState.IsKeyDown(Key.KeypadSubtract) || KeyboardState.IsKeyDown(Key.KeypadMultiply) || KeyboardState.IsKeyDown(Key.KeypadDivide) || KeyboardState.IsKeyDown(Key.KeypadEnter) || KeyboardState.IsKeyDown(Key.Keypad0) || KeyboardState.IsKeyDown(Key.Keypad1) || KeyboardState.IsKeyDown(Key.Keypad2) || KeyboardState.IsKeyDown(Key.Keypad3) || KeyboardState.IsKeyDown(Key.Keypad4) || KeyboardState.IsKeyDown(Key.Keypad5) || KeyboardState.IsKeyDown(Key.Keypad6) || KeyboardState.IsKeyDown(Key.Keypad7) || KeyboardState.IsKeyDown(Key.Keypad8) || KeyboardState.IsKeyDown(Key.Keypad9)) { flags = flags | CGEventFlags.NumericPad; } return(flags); }
public void InnerJoinProducesAJoinElementWithTheTypeOfInner() { var list = Fixture.Create <string>(); var field = Fixture.Create <string>(); var sut = CG.InnerJoin(list, field); sut.ToString(false).ShouldBe(string.Format(@"<Join Type=""INNER"" ListAlias=""{0}""><Eq><FieldRef Name=""{1}"" RefType=""Id"" /><FieldRef Name=""ID"" List=""{0}"" /></Eq></Join>", list, field)); }
public void BareFieldRefWithAdditionalAttributesReturnsAFieldRefTagWithANameAndAdditionalAttributes() { var name = Fixture.Create <string>(); var additionalName = Fixture.Create <string>(); var additionalValue = Fixture.Create <string>(); var sut = CG.FieldRef(name, new Tuple <string, string>(additionalName, additionalValue)); sut.ToString().ShouldBe(string.Format(@"<FieldRef Name=""{0}"" {1}=""{2}"" />", name, additionalName, additionalValue)); }
public override void OnFrame() { float imageAspectRatio = DrawableWidth / DrawableWidth; float b, t, l, r; CG.gluPerspective(angleOfView, imageAspectRatio, near, out b, out t, out l, out r); CG.glFrustum(b, t, l, r, near, far, projMatrix); base.OnFrame(); }
public void JoinWithJoinTypeAndOneStringProducesAJoinElementWithTheTypeAndListAlias() { var list = Fixture.Create <string>(); var field = Fixture.Create <string>(); var sut = CG.Join(list, CG.JoinType.Left, field); sut.ToString(false).ShouldBe(string.Format(@"<Join Type=""LEFT"" ListAlias=""{0}""><Eq><FieldRef Name=""{1}"" RefType=""Id"" /><FieldRef Name=""ID"" List=""{0}"" /></Eq></Join>", list, field)); }
static object ParseSingletonLiteral(UString text) { object value; if (NamedLiterals.TryGetValue(text, out value)) { return(value); } return(new CustomLiteral(CG.Cache(text.ToString()), _AtAt)); }
private object ParseAtAtLiteral(UString text) { Debug.Assert(text.StartsWith("@@")); text = text.Substring(2); if (PreferCustomLiterals) { return(new CustomLiteral(CG.Cache(text.ToString()), _AtAt)); } return(ParseSingletonLiteral(text)); }
public void BareJoinReturnsAJoinTagWithNoAttributes() { var list = Fixture.Create <string>(); var lhs = Fixture.Create <BaseCoreElement>(); var rhs = Fixture.Create <BaseCoreElement>(); var sut = CG.Join(list, CG.JoinType.Inner, lhs, rhs); sut.ToString().ShouldBe(string.Format(@"<Join Type=""INNER"" ListAlias=""{0}""><Eq>{1}{2}</Eq></Join>", list, lhs, rhs)); }
public virtual void Reset(IProjectorEngine projector) { if (Model3D == default) { return; } Transform(CG.RotY(.5f)); Transform(CG.RotX(.5f)); Transform(CG.TranslateZ(-12)); }
public void BareCgProjectedFieldReturnsAProjectedFieldTagWithAttributes() { var name = Fixture.Create <string>(); var type = Fixture.Create <string>(); var list = Fixture.Create <string>(); var showFileld = Fixture.Create <string>(); var sut = CG.ProjectedField(name, type, list, showFileld); sut.ToString() .ShouldBe(string.Format(@"<Field Name=""{0}"" Type=""{1}"" List=""{2}"" ShowField=""{3}"" />", name, type, list, showFileld)); }
/// <summary> /// Generates all code for parts of geometric product, substract, add, negate, dual, and so on. /// /// The results go into cgd.m_def and cgd.m_gmvGPpartFuncNames and cgd.m_gmvDualPartFuncNames. /// /// Is also called by TestSuite because the declarations are in the source file by default which /// makes them unavailable to the testing code. /// </summary> /// <param name="S"></param> /// <param name="cgd">Results go into cgd.m_def and cgd.m_gmvGPpartFuncNames and cgd.m_gmvDualPartFuncNames.</param> /// <param name="declOnly">When true, only the declarations are generated and written to <c>cgd.m_defSB</c>.</param> public static void GeneratePartsCode(Specification S, CG.Shared.CGdata cgd, bool declOnly) { // generate all parts of the geometric product (in parallel) const int NB_PARTS_CODE = 4; // get a temporary cgd for each type of parts code CG.Shared.CGdata[] tmpCgd = new G25.CG.Shared.CGdata[NB_PARTS_CODE]; for (int i = 0; i < NB_PARTS_CODE; i++) tmpCgd[i] = new G25.CG.Shared.CGdata(cgd); // get parts code generators G25.CG.Shared.GmvGpParts p1 = new G25.CG.Shared.GmvGpParts(S, tmpCgd[0]); // [0] = GP G25.CG.Shared.GmvCASNparts p2 = new G25.CG.Shared.GmvCASNparts(S, tmpCgd[1]); // [1] = CASN G25.CG.Shared.GmvDualParts p3 = new G25.CG.Shared.GmvDualParts(S, tmpCgd[2]); // [2] = DUAL G25.CG.Shared.GmvGomParts p4 = new G25.CG.Shared.GmvGomParts(S, tmpCgd[3]); // [3] = GOM X GMV // run threads System.Threading.Thread[] T = new System.Threading.Thread[NB_PARTS_CODE]; T[0] = new Thread(p1.WriteGmvGpParts); T[1] = new Thread(p2.WriteGmvCASNparts); T[2] = new Thread(p3.WriteGmvDualParts); T[3] = new Thread(p4.WriteGmvGomParts); G25.CG.Shared.Threads.StartThreadArray(T); G25.CG.Shared.Threads.JoinThreadArray(T); // merge declarations and definitions go into cgd.m_declSB or cgd.m_defSB, depending on the language for (int i = 0; i < NB_PARTS_CODE; i++) { // StringBuilder SB = (S.OutputC()) ? cgd.m_defSB : cgd.m_declSB; StringBuilder SB = cgd.m_defSB; SB.Append(tmpCgd[i].m_declSB); } if (!declOnly) // if only declarations are wanted, don't copy the definitions for (int i = 0; i < NB_PARTS_CODE; i++) cgd.m_defSB.Append(tmpCgd[i].m_defSB); // copy names of part functions from appropriate temporary cgd cgd.m_gmvGPpartFuncNames = tmpCgd[0].m_gmvGPpartFuncNames; // this assumes [0] = GP cgd.m_gmvDualPartFuncNames = tmpCgd[2].m_gmvDualPartFuncNames; // this assumes [2] = DUAL cgd.m_gmvGomPartFuncNames = tmpCgd[3].m_gmvGomPartFuncNames; // this assumes [3] = GOM }
/// <summary> /// Writes code for all 'set' function and various other function (largest coordinate, coordinate extraction, etc) /// </summary> /// <param name="S"></param> /// <param name="plugins"></param> /// <param name="cgd"></param> protected void GenerateSetFunctions(Specification S, List<CodeGeneratorPlugin> plugins, CG.Shared.CGdata cgd) { const int NB_SET_CODE = 4; // get a temporary cgd for each type of parts code CG.Shared.CGdata[] tmpCgd = new G25.CG.Shared.CGdata[] {new G25.CG.Shared.CGdata(cgd), new G25.CG.Shared.CGdata(cgd), new G25.CG.Shared.CGdata(cgd), new G25.CG.Shared.CGdata(cgd) }; // get parts code generators G25.CG.C.GMV p1 = new G25.CG.C.GMV(S, tmpCgd[0]); // [0] = GMV G25.CG.C.SMV p2 = new G25.CG.C.SMV(S, tmpCgd[1]); // [1] = SMV G25.CG.C.GOM p3 = new G25.CG.C.GOM(S, tmpCgd[2]); // [2] = GOM G25.CG.C.SOM p4 = new G25.CG.C.SOM(S, tmpCgd[3]); // [3] = SOM // run threads System.Threading.Thread[] T = new System.Threading.Thread[NB_SET_CODE]; T[0] = new Thread(p1.WriteSetFunctions); T[1] = new Thread(p2.WriteSetFunctions); T[2] = new Thread(p3.WriteSetFunctions); T[3] = new Thread(p4.WriteSetFunctions); G25.CG.Shared.Threads.StartThreadArray(T); G25.CG.Shared.Threads.JoinThreadArray(T); // merge declarations and definitions for (int i = 0; i < NB_SET_CODE; i++) { cgd.m_declSB.Append(tmpCgd[i].m_declSB); cgd.m_defSB.Append(tmpCgd[i].m_defSB); cgd.m_inlineDefSB.Append(tmpCgd[i].m_inlineDefSB); } }
public GMV(Specification S, CG.Shared.CGdata cgd) { m_specification = S; m_cgd = cgd; }
private void AddTextAttribute (CG.List<Atk.Attribute> attrs, Atk.TextAttribute atkAttr, ITextRangeProvider textRange) { if (textRange == null) { return; } string name = Atk.TextAdapter.AttributeGetName (atkAttr); string val = null; object tmp; switch (atkAttr) { case Atk.TextAttribute.Style: if (IsAttrNotNullOrMultiValued (TextPattern.IsItalicAttribute.Id, textRange, out tmp)) val = ((bool) tmp) ? "italic" : "normal"; break; case Atk.TextAttribute.Justification: if (!IsAttrNotNullOrMultiValued (TextPattern.HorizontalTextAlignmentAttribute.Id, textRange, out tmp)) break; HorizontalTextAlignment align = (HorizontalTextAlignment) tmp; if (align == HorizontalTextAlignment.Left) val = "left"; else if (align == HorizontalTextAlignment.Right) val = "right"; else if (align == HorizontalTextAlignment.Centered) val = "center"; else if (align == HorizontalTextAlignment.Justified) val = "fill"; break; case Atk.TextAttribute.FgColor: if (IsAttrNotNullOrMultiValued (TextPattern.ForegroundColorAttribute.Id, textRange, out tmp)) { Color fgColor = Color.FromArgb ((int) tmp); val = String.Format ("{0},{1},{2}", fgColor.R, fgColor.G, fgColor.B); } break; case Atk.TextAttribute.BgColor: if (IsAttrNotNullOrMultiValued (TextPattern.BackgroundColorAttribute.Id, textRange, out tmp)) { Color fgColor = Color.FromArgb ((int) tmp); val = String.Format ("{0},{1},{2}", fgColor.R, fgColor.G, fgColor.B); } break; case Atk.TextAttribute.FamilyName: if (IsAttrNotNullOrMultiValued (TextPattern.FontNameAttribute.Id, textRange, out tmp)) val = (string) tmp; break; case Atk.TextAttribute.Weight: if (IsAttrNotNullOrMultiValued (TextPattern.FontWeightAttribute.Id, textRange, out tmp)) val = ((int) tmp).ToString (); break; case Atk.TextAttribute.Strikethrough: if (IsAttrNotNullOrMultiValued (TextPattern.StrikethroughStyleAttribute.Id, textRange, out tmp)) { TextDecorationLineStyle strikeStyle = (TextDecorationLineStyle) tmp; val = strikeStyle == TextDecorationLineStyle.None ? "false" : "true"; } break; case Atk.TextAttribute.Underline: if (!IsAttrNotNullOrMultiValued (TextPattern.UnderlineStyleAttribute.Id, textRange, out tmp)) break; TextDecorationLineStyle underlineStyle = (TextDecorationLineStyle) tmp; if (underlineStyle == TextDecorationLineStyle.None) val = "none"; else if (underlineStyle == TextDecorationLineStyle.Double || underlineStyle == TextDecorationLineStyle.DoubleWavy) val = "double"; else val = "single"; break; case Atk.TextAttribute.PixelsBelowLines: if (IsAttrNotNullOrMultiValued (TextPattern.IndentationTrailingAttribute.Id, textRange, out tmp)) val = ((int) tmp).ToString (); break; case Atk.TextAttribute.PixelsAboveLines: if (IsAttrNotNullOrMultiValued (TextPattern.IndentationLeadingAttribute.Id, textRange, out tmp)) val = ((int) tmp).ToString (); break; case Atk.TextAttribute.Editable: if (IsAttrNotNullOrMultiValued (TextPattern.IsReadOnlyAttribute.Id, textRange, out tmp)) val = !((bool) tmp) ? "true" : "false"; break; case Atk.TextAttribute.Invisible: if (IsAttrNotNullOrMultiValued (TextPattern.IsHiddenAttribute.Id, textRange, out tmp)) val = ((bool) tmp) ? "true" : "false"; break; case Atk.TextAttribute.Indent: if (IsAttrNotNullOrMultiValued (TextPattern.IndentationFirstLineAttribute.Id, textRange, out tmp)) val = ((int) tmp).ToString (); break; } if (val != null) { attrs.Add (new Atk.Attribute {Name = name, Value = val}); } }