protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_banner_programmatic); adStatusTextView = FindViewById <TextView>(Resource.Id.status_label); adView = new AppLovinAdView(AppLovinAdSize.Banner, "YOUR_ZONE_ID", this); adView.Id = ViewCompat.GenerateViewId(); var loadButton = FindViewById <Button>(Resource.Id.load_button); loadButton.Click += LoadButton_Click; adView.SetAdLoadListener(this); adView.SetAdDisplayListener(this); adView.SetAdClickListener(this); adView.SetAdViewEventListener(this); // Add programmatically created banner into our container var bannerProgrammaticContentLayout = FindViewById <ConstraintLayout>(Resource.Id.banner_programmatic_layout); bannerProgrammaticContentLayout.AddView(adView, new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, AppLovinSdkUtils.DpToPx(this, 50))); var constraintSet = new ConstraintSet(); constraintSet.Clone(bannerProgrammaticContentLayout); constraintSet.Connect(adView.Id, ConstraintSet.Bottom, Resource.Id.banner_programmatic_layout, ConstraintSet.Bottom, 0); constraintSet.ApplyTo(bannerProgrammaticContentLayout); // Load an ad! adView.LoadNextAd(); }
public List <ConstraintSet> GetAllConstraintSets(int poolId) { try { List <ConstraintSet> constraintSets = EpicCutPlanes.GetAllConstraintSets(poolId); List <ConstraintSet> serializableConstraintSets = new List <ConstraintSet>(); foreach (ConstraintSet constraintSet in constraintSets) { ConstraintSet serializableConstraintSet = new ConstraintSet(); serializableConstraintSet.Id = constraintSet.Id; serializableConstraintSet.Name = constraintSet.Name; serializableConstraintSet.DateCreated = constraintSet.DateCreated; serializableConstraintSet.DateUpdated = constraintSet.DateUpdated; serializableConstraintSet.PoolId = constraintSet.PoolId; serializableConstraintSet.UserCreatedId = constraintSet.UserCreatedId; serializableConstraintSet.UserUpdatedId = constraintSet.UserUpdatedId; serializableConstraintSets.Add(serializableConstraintSet); } return(serializableConstraintSets); } catch (Exception ex) { //Log.Error("CutPlaneManagement::GetAllConstraintSets: Exception" + ex.Message + ex.StackTrace); throw; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_mrec_programmatic); adStatusTextView = FindViewById <TextView>(Resource.Id.status_label); // Create MRec adView = new AppLovinAdView(AppLovinAdSize.Mrec, this); adView.Id = ViewCompat.GenerateViewId(); var mrecConstraintLayout = FindViewById <ConstraintLayout>(Resource.Id.mrec_programmatic_constraint_layout); var layoutParams = new ConstraintLayout.LayoutParams(AppLovinSdkUtils.DpToPx(this, AppLovinAdSize.Mrec.Width), AppLovinSdkUtils.DpToPx(this, AppLovinAdSize.Mrec.Height)); mrecConstraintLayout.AddView(adView, layoutParams); var set = new ConstraintSet(); set.Clone(mrecConstraintLayout); set.Connect(adView.Id, ConstraintSet.Top, mrecConstraintLayout.Id, ConstraintSet.Top, AppLovinSdkUtils.DpToPx(this, 80)); set.CenterHorizontally(adView.Id, mrecConstraintLayout.Id); set.ApplyTo(mrecConstraintLayout); var loadButton = FindViewById <Button>(Resource.Id.load_button); loadButton.Click += LoadButton_Click; adView.SetAdLoadListener(this); adView.SetAdDisplayListener(this); adView.SetAdClickListener(this); adView.SetAdViewEventListener(this); }
private void InitLayout() { _constraintLayoutRoot = this.BindingInflate(LayoutId, null) as ConstraintLayout; ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MatchConstraint, ConstraintLayout.LayoutParams.MatchConstraint); _constraintLayoutRoot.LayoutParameters = layoutParams; BaseMainConstraintLayout.RemoveView(BaseScrollView); BaseScrollView.RemoveView(BaseElementsConstraintLayout); BaseMainConstraintLayout.AddView(BaseElementsConstraintLayout); BaseMainConstraintLayout.BringChildToFront(BasePreLoaderConstraintLayout); var rootElementSet = new ConstraintSet(); rootElementSet.Clone(BaseMainConstraintLayout); rootElementSet.Connect(BaseElementsConstraintLayout.Id, ConstraintSet.Top, BaseMainConstraintLayout.Id, ConstraintSet.Top); rootElementSet.Connect(BaseElementsConstraintLayout.Id, ConstraintSet.Bottom, BaseMainConstraintLayout.Id, ConstraintSet.Bottom); rootElementSet.Connect(BaseElementsConstraintLayout.Id, ConstraintSet.Left, BaseMainConstraintLayout.Id, ConstraintSet.Left); rootElementSet.Connect(BaseElementsConstraintLayout.Id, ConstraintSet.Right, BaseMainConstraintLayout.Id, ConstraintSet.Right); rootElementSet.ApplyTo(BaseMainConstraintLayout); BaseElementsConstraintLayout.AddView(_constraintLayoutRoot); ConstraintSet elementsSet = new ConstraintSet(); elementsSet.Clone(BaseElementsConstraintLayout); elementsSet.Connect(_constraintLayoutRoot.Id, ConstraintSet.Top, _toolbar.Id, ConstraintSet.Bottom); elementsSet.Connect(_constraintLayoutRoot.Id, ConstraintSet.Bottom, BaseElementsConstraintLayout.Id, ConstraintSet.Bottom); elementsSet.Connect(_constraintLayoutRoot.Id, ConstraintSet.Left, BaseElementsConstraintLayout.Id, ConstraintSet.Left); elementsSet.Connect(_constraintLayoutRoot.Id, ConstraintSet.Right, BaseElementsConstraintLayout.Id, ConstraintSet.Right); elementsSet.ApplyTo(BaseElementsConstraintLayout); }
private void CreateMainConstraintSet() { var constraintSet = new ConstraintSet(); constraintSet.Clone(BaseMainConstraintLayout); constraintSet.ApplyTo(BaseMainConstraintLayout); }
public ApiTemplateElementDescriptor(ElementDescriptorType descriptorType, int templateCode, JObject properties, ConstraintSet constraintSet, PlacementDescriptor placement) { Type = descriptorType; TemplateCode = templateCode; Properties = properties; Constraints = constraintSet; Placement = placement; }
private void CreateBasePreLoaderConstraintSet() { ConstraintSet BasePreLoaderConstraintSet = new ConstraintSet(); BasePreLoaderConstraintSet.Clone(BasePreLoaderConstraintLayout); BasePreLoaderConstraintSet.Connect(BaseProgressBar.Id, ConstraintSet.Top, BasePreLoaderConstraintLayout.Id, ConstraintSet.Top, PixelsConverter.DpToPx(300)); BasePreLoaderConstraintSet.Connect(BaseProgressBar.Id, ConstraintSet.Left, BasePreLoaderConstraintLayout.Id, ConstraintSet.Left, PixelsConverter.DpToPx(23)); BasePreLoaderConstraintSet.Connect(BaseProgressBar.Id, ConstraintSet.Right, BasePreLoaderConstraintLayout.Id, ConstraintSet.Right, PixelsConverter.DpToPx(23)); BasePreLoaderConstraintSet.ApplyTo(BasePreLoaderConstraintLayout); }
private void CreateMainConstraintSet() { var constraintSet = new ConstraintSet(); constraintSet.Clone(BaseMainConstraintLayout); constraintSet.Connect(_toolbar.Id, ConstraintSet.Top, BaseElementsConstraintLayout.Id, ConstraintSet.Top); constraintSet.Connect(_toolbar.Id, ConstraintSet.Left, BaseElementsConstraintLayout.Id, ConstraintSet.Left); constraintSet.Connect(_toolbar.Id, ConstraintSet.Right, BaseElementsConstraintLayout.Id, ConstraintSet.Right); constraintSet.ApplyTo(BaseMainConstraintLayout); }
/********* ** Private methods *********/ /// <summary>Create a constraint set and assert that its values match the expected values.</summary> /// <typeparam name="T">The set type.</typeparam> /// <param name="comparer">The equality comparer to use.</param> private ConstraintSet <T> CreateAndAssertSet <T>(IEqualityComparer <T?>?comparer = null) { // act ConstraintSet <T> set = new ConstraintSet <T>(comparer ?? EqualityComparer <T?> .Default); // assert set.IsInfinite.Should().BeTrue("the set should be infinite immediately after construction because no bounds have been set"); set.IsBounded.Should().BeFalse("the set should be unbounded immediately after construction because no bounds have been set"); set.ExcludeValues.Should().BeEmpty("the set should has no exclusions immediately after construction because none were added"); set.RestrictToValues.Should().BeEmpty("the set should has no restrictions immediately after construction because none were added"); return(set); }
public void AddBound_MultipleValues_WithCaseInsensitiveComparer(string[] input, string[] expected) { // arrange ConstraintSet <string> set = this.CreateAndAssertSet(StringComparer.InvariantCultureIgnoreCase); // act bool added = set.AddBound(input); bool reAdded = set.AddBound(input); // assert this.AssertBounds(set, expected, new string[0]); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void AddBound_MultipleValues(params int[] values) { // arrange ConstraintSet <int> set = this.CreateAndAssertSet <int>(); // act bool added = set.AddBound(values); bool reAdded = set.AddBound(values); // assert this.AssertBounds(set, values, Array.Empty <int>()); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void Exclude_MultipleValues_WithCaseSensitiveComparer(string[] restrict, string[] exclude) { // arrange ConstraintSet <string> set = this.CreateAndAssertSet <string>(); // act bool added = set.Exclude(restrict); bool reAdded = set.Exclude(restrict); // assert this.AssertBounds(set, Array.Empty <string>(), exclude); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void Exclude_MultipleValues(params int[] values) { // arrange ConstraintSet <int> set = this.CreateAndAssertSet <int>(); // act bool added = set.Exclude(values); bool reAdded = set.Exclude(values); // assert this.AssertBounds(set, new int[0], values); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void AddBound_MultipleValues_WithCaseSensitiveComparer(string[] input, string[] expected) { // arrange ConstraintSet <string> set = this.CreateAndAssertSet <string>(); // act bool added = set.AddBound(input); bool reAdded = set.AddBound(input); // assert this.AssertBounds(set, expected, Array.Empty <string>()); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void Exclude_SingleValue <T>(T value) { // arrange ConstraintSet <T> set = this.CreateAndAssertSet <T>(); // act bool added = set.Exclude(value); bool reAdded = set.Exclude(value); // assert this.AssertBounds(set, new T[0], new[] { value }); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void AddBound_SingleValue <T>(T value) { // arrange ConstraintSet <T> set = this.CreateAndAssertSet <T>(); // act bool added = set.AddBound(value); bool reAdded = set.AddBound(value); // assert this.AssertBounds(set, new[] { value }, Array.Empty <T>()); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void Exclude_MultipleValues_WithCaseInsensitiveComparer(string[] input, string[] expected) { // arrange ConstraintSet <string> set = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase); // act bool added = set.Exclude(input); bool reAdded = set.Exclude(input); // assert this.AssertBounds(set, Array.Empty <string>(), expected); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void Exclude_SingleValue_WithCaseInsensitiveComparer() { // arrange const string value = "boop"; ConstraintSet <string> set = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase); // act bool added = set.Exclude(value); bool reAdded = set.Exclude(value.ToUpper()); // assert this.AssertBounds(set, Array.Empty <string>(), new[] { value }); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void Allows_WithFloats(float[] restrict, float[] exclude, float[] test, bool expectedResult) { // arrange ConstraintSet <float> set = this.CreateAndAssertSet <float>(); set.AddBound(restrict); set.Exclude(exclude); this.AssertBounds(set, restrict, exclude); // act/assert foreach (float value in test) { set.Allows(value).Should().Be(expectedResult, $"expected '{value}' to {(expectedResult ? "be allowed" : "be excluded")}"); } }
public void AddBound_SingleValue_WithCaseInsensitiveComparer() { // arrange const string value = "boop"; ConstraintSet <string> set = this.CreateAndAssertSet(StringComparer.InvariantCultureIgnoreCase); // act bool added = set.AddBound(value); bool reAdded = set.AddBound(value.ToUpper()); // assert this.AssertBounds(set, new[] { value }, new string[0]); added.Should().BeTrue(); reAdded.Should().BeFalse(); }
public void Allows_WithCaseSensitiveComparer(string[] restrict, string[] exclude, string?[] test, bool expectedResult) { // arrange ConstraintSet <string?> set = this.CreateAndAssertSet <string?>(); set.AddBound(restrict); set.Exclude(exclude); this.AssertBounds(set, restrict, exclude); // act/assert foreach (string?value in test) { set.Allows(value).Should().Be(expectedResult, $"expected '{value}' to {(expectedResult ? "be allowed" : "be excluded")}"); } }
public void AddBound_SingleValue_WithCaseSensitiveComparer() { // arrange const string value = "boop"; ConstraintSet <string> set = this.CreateAndAssertSet <string>(); // act bool added = set.AddBound(value); bool reAdded = set.AddBound(value.ToUpper()); // assert this.AssertBounds(set, new[] { value, value.ToUpper() }, Array.Empty <string>()); added.Should().BeTrue(); reAdded.Should().BeTrue(); }
/// <summary>Assert that the boundary values match the expected values.</summary> /// <typeparam name="T">The set type.</typeparam> /// <param name="set">The set to validate.</param> /// <param name="restrictions">The expected restriction values.</param> /// <param name="exclusions">The expected exclusion values.</param> private void AssertBounds <T>(ConstraintSet <T> set, T[] restrictions, T[] exclusions) { if (restrictions.Any()) { set.IsInfinite.Should().BeFalse("bound restrictions were added"); set.IsBounded.Should().BeTrue("bound restrictions ere added"); } else { set.IsInfinite.Should().BeTrue("no bound restriction was added"); set.IsBounded.Should().BeFalse("no bound restriction was added"); } set.RestrictToValues.Should().BeEquivalentTo(restrictions); set.ExcludeValues.Should().BeEquivalentTo(exclusions); }
public void Intersects_OneInfinite_NonIntersection() { // arrange ConstraintSet <string> left = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase); ConstraintSet <string> right = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase); left.Exclude(new[] { "A", "B", "C" }); right.AddBound(new[] { "A", "B", "C" }); // act bool leftIntersects = left.Intersects(right); bool rightIntersects = right.Intersects(left); // assert leftIntersects.Should().BeFalse(); rightIntersects.Should().BeFalse(); }
public void Intersects_BothInfinite_Intersection() { // arrange ConstraintSet <string> left = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase); ConstraintSet <string> right = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase); left.Exclude("C"); right.Exclude("D"); // act bool leftIntersects = left.Intersects(right); bool rightIntersects = right.Intersects(left); // assert leftIntersects.Should().BeTrue(); rightIntersects.Should().BeTrue(); }
public void Allows_WithCaseInsensitiveComparer(string[] restrict, string[] exclude, string[] test, bool expectedResult) { // arrange ConstraintSet <string> set = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase); set.AddBound(restrict); set.Exclude(exclude); this.AssertBounds( set, new HashSet <string>(restrict, StringComparer.OrdinalIgnoreCase).ToArray(), new HashSet <string>(exclude, StringComparer.OrdinalIgnoreCase).ToArray() ); // act/assert foreach (string value in test) { set.Allows(value).Should().Be(expectedResult, $"expected '{value}' to {(expectedResult ? "be allowed" : "be excluded")}"); } }
public void Intersects_Bounded_Intersection() { // arrange ConstraintSet <string> left = this.CreateAndAssertSet(StringComparer.InvariantCultureIgnoreCase); ConstraintSet <string> right = this.CreateAndAssertSet(StringComparer.InvariantCultureIgnoreCase); left.AddBound(new[] { "A", "B", "C", "D" }); right.AddBound(new[] { "C", "D" }); left.Exclude("C"); right.Exclude("C"); // act bool leftIntersects = left.Intersects(right); bool rightIntersects = right.Intersects(left); // assert leftIntersects.Should().BeTrue(); rightIntersects.Should().BeTrue(); }
protected override void OnCreate(Bundle savedInstanceState) { SetTheme(Resource.Style.Theme_AppCompat_NoActionBar); base.OnCreate(savedInstanceState); callback = new DualNavigationLocationCallback(this); InitializeViews(savedInstanceState); navigationView.Initialize(this); navigationMapConstraint = new ConstraintSet(); navigationMapConstraint.Clone(dualNavigationMap); navigationMapExpandedConstraint = new ConstraintSet(); navigationMapExpandedConstraint.Clone(this, Resource.Layout.activity_dual_navigation_map_expanded); constraintChanged = new bool[] { false }; launchNavigationFab.SetOnClickListener(new LaunchNavigationFabClickListener((v) => { ExpandCollapse(); LaunchNavigation(); })); }
public SuburbanGenerator() { // using sample constraint set until constraint stuff is finished Constraints = new ConstraintSet(); // Temporary constraints until we add building grammar Constraints.Add("LivingRooms", new MinMax(1, 1)); Constraints.Add("AreaLivingRooms", new MinMax(400, 500)); Constraints.Add("BedRooms", new MinMax(1, 2)); Constraints.Add("AreaBedRooms", new MinMax(400, 500)); Constraints.Add("Bathrooms", new MinMax(0, 1)); Constraints.Add("AreaBathrooms", new MinMax(200, 200)); Constraints.Add("Kitchens", new MinMax(0, 1)); Constraints.Add("AreaKitchens", new MinMax(200, 200)); Constraints.Add("ExtraRoom", new MinMax(0, 1)); Constraints.Add("AreaCloset", new MinMax(100, 100)); }
public ConstraintSet GetConstraintSet(int constraintSetId) { //string ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["EpicDB"].ConnectionString; //EpicCutPlanes epicCutPlanes = new EpicCutPlanes(ConnectionString); try { ConstraintSet constraintset = EpicCutPlanes.GetConstraintSet(constraintSetId); ConstraintSet serializableconstraintset = new ConstraintSet(); serializableconstraintset.Id = constraintset.Id; serializableconstraintset.DateCreated = constraintset.DateCreated; serializableconstraintset.DateUpdated = constraintset.DateUpdated; serializableconstraintset.Name = constraintset.Name; serializableconstraintset.PoolId = constraintset.PoolId; serializableconstraintset.UserCreatedId = constraintset.UserCreatedId; serializableconstraintset.UserUpdatedId = constraintset.UserUpdatedId; return(serializableconstraintset); } catch (Exception ex) { //Log.Error("CutPlaneManagement::GetConstraintSet: Exception" + ex.Message + ex.StackTrace); throw; } }