public void ExtentsConstructor() { tlog.Debug(tag, $"ExtentsConstructor START"); var testingTarget = new Extents(); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!"); testingTarget.Dispose(); tlog.Debug(tag, $"ExtentsConstructor END (OK)"); }
public void ExtentsTop() { tlog.Debug(tag, $"ExtentsTop START"); Extents testingTarget = new Extents(1, 2, 3, 4); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!"); Assert.AreEqual(3, testingTarget.Top, "extents.Top should be equal to 3!"); testingTarget.Top = 5; Assert.AreEqual(5, testingTarget.Top, "extents.Top should be equal to 5!"); testingTarget.Dispose(); tlog.Debug(tag, $"ExtentsTop END (OK)"); }
public void ExtentsBottom() { tlog.Debug(tag, $"ExtentsBottom START"); Extents testingTarget = new Extents(1, 2, 3, 4); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!"); Assert.AreEqual(4, testingTarget.Bottom, "extents.Bottom should be equal to 4!"); testingTarget.Bottom = 5; Assert.AreEqual(5, testingTarget.Bottom, "extents.Bottom should be equal to 4!"); testingTarget.Dispose(); tlog.Debug(tag, $"ExtentsBottom END (OK)"); }
public void ExtentsStart() { tlog.Debug(tag, $"ExtentsStart START"); var testingTarget = new Extents(1, 2, 3, 4); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!"); Assert.AreEqual(1, testingTarget.Start, "testingTarget.Start should be equal to the set value!"); testingTarget.Start = 5; Assert.AreEqual(5, testingTarget.Start, "testingTarget.Start should be equal to the set value!"); testingTarget.Dispose(); tlog.Debug(tag, $"ExtentsStart END (OK)"); }
public void ExtentsEnd() { tlog.Debug(tag, $"ExtentsEnd START"); var testingTarget = new Extents(1, 2, 3, 4); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!"); Assert.AreEqual(2, testingTarget.End, "extents.End should be equal to 2!"); testingTarget.End = 5; Assert.AreEqual(5, testingTarget.End, "extents.End should be equal to 5!"); testingTarget.Dispose(); tlog.Debug(tag, $"ExtentsEnd END (OK)"); }
public void ExtentsConstructorWithUInt16Parameters() { tlog.Debug(tag, $"ExtentsConstructorWithUInt16Parameters START"); var testingTarget = new Extents(1, 2, 3, 4); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!"); Assert.AreEqual(1, testingTarget.Start, "Retrieved extents.Start should be equal to 1"); Assert.AreEqual(2, testingTarget.End, "Retrieved extents.End should be equal to 2"); Assert.AreEqual(3, testingTarget.Top, "Retrieved extents.Top should be equal to 3"); Assert.AreEqual(4, testingTarget.Bottom, "Retrieved extents.Bottom should be equal 4"); testingTarget.Dispose(); tlog.Debug(tag, $"ExtentsConstructorWithUInt16Parameters END (OK)"); }
public void KeyValueExtentsValue() { tlog.Debug(tag, $"KeyValueExtentsValue START"); Extents b1 = new Extents(0, 0, 0, 0); KeyValue a1 = new KeyValue { ExtentsValue = b1 }; b1 = a1.ExtentsValue; b1.Dispose(); a1.Dispose(); tlog.Debug(tag, $"KeyValueExtentsValue END (OK)"); Assert.Pass("KeyValueExtentsValue"); }
public void ExtentsAssign() { tlog.Debug(tag, $"ExtentsAssign START"); var testingTarget = new Extents(); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!"); Assert.AreEqual(0, testingTarget.Top, "Should be equal!"); using (Extents extents = new Extents(20, 20, 20, 20)) { testingTarget.Assign(extents); Assert.AreEqual(20, testingTarget.Top, "Should be equal!"); } testingTarget.Dispose(); tlog.Debug(tag, $"ExtentsAssign END (OK)"); }
public void ExtentsNotEqualTo() { tlog.Debug(tag, $"ExtentsNotEqualTo START"); Extents testingTarget1 = new Extents(1, 2, 3, 4); Assert.IsNotNull(testingTarget1, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget1, "should be an instance of Extents class!"); Extents testingTarget2 = new Extents(2, 3, 4, 5); Assert.IsNotNull(testingTarget2, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget2, "should be an instance of Extents class!"); Assert.IsTrue((testingTarget1.NotEqualTo(testingTarget2)), "Should be not equal"); testingTarget2.Dispose(); testingTarget1.Dispose(); tlog.Debug(tag, $"ExtentsNotEqualTo END (OK)"); }
public void ExtentsEqualTo() { tlog.Debug(tag, $"ExtentsEqualTo START"); Extents testingTarget = new Extents(1, 2, 3, 4); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!"); var result = testingTarget; Assert.IsNotNull(result, "should be not null"); Assert.IsInstanceOf <Extents>(result, "should be an instance of Extents class!"); Assert.IsTrue((testingTarget.EqualTo(result)), "Should be equal"); result.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"ExtentsEqualTo END (OK)"); }
public void ExtentsCopyFromNullExtents() { tlog.Debug(tag, $"ExtentsCopyFromNullExtents START"); var testingTarget = new Extents(); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Extents>(testingTarget, "should be an instance of testing target class!"); Assert.AreEqual(0, testingTarget.Top, "Should be equal!"); try { Extents extents = null; testingTarget.CopyFrom(extents); } catch (ArgumentNullException) { testingTarget.Dispose(); tlog.Debug(tag, $"ExtentsCopyFromNullExtents END (OK)"); Assert.Pass("Caught ArgumentNullException : Passed!"); } }
public void PropertyValueGetExtentsValue() { tlog.Debug(tag, $"PropertyValueGetExtentsValue START"); var testingTarget = new PropertyValue(new Extents(1, 2, 3, 4)); Assert.IsNotNull(testingTarget, "Should be not null!"); Assert.IsInstanceOf <PropertyValue>(testingTarget, "Should be an Instance of PropertyValue class!"); Extents extents = new Extents(0, 0, 0, 0); var result = testingTarget.Get(extents); Assert.IsTrue(result); Assert.AreEqual(1, extents.Start, "should be equal."); Assert.AreEqual(2, extents.End, "should be equal."); Assert.AreEqual(3, extents.Top, "should be equal."); Assert.AreEqual(4, extents.Bottom, "should be equal."); extents.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"PropertyValueGetExtentsValue END (OK)"); }
private void UpdateSizeAndSpacing() { if (styleApplied == false) { return; } if ((Icon == null) && (TextLabel == null)) { return; } // FIXME: set Selector<Extents> to padding var padding = new Extents(40, 40, 24, 24); var iconPadding = IconPadding; var textPadding = TextPadding; // Calculate size of TextLabel. if (TextLabel != null) { // TODO: Other orientation cases are not implemented yet. if ((IconRelativeOrientation == IconOrientation.Left) || (IconRelativeOrientation == IconOrientation.Right)) { var naturalWidthSum = (ushort)padding?.Start + (ushort)padding?.End + iconPadding.Start + iconPadding.End + (float)Icon?.SizeWidth + TextLabel.GetNaturalSize().Width; var naturalWidthDiff = SizeWidth - naturalWidthSum; if (naturalWidthDiff > 0) { TextLabel.SizeWidth = TextLabel.GetNaturalSize().Width; } else { TextLabel.SizeWidth = SizeWidth - (ushort)padding?.Start - (ushort)padding?.End - iconPadding.Start - iconPadding.End - textPadding.Start - textPadding.End - (float)Icon?.SizeWidth; } } } // Calculate positions of Icon and TextLabel. switch (IconRelativeOrientation) { // TODO: Other orientation cases are not implemented yet. case IconOrientation.Left: if (LayoutDirection == ViewLayoutDirectionType.LTR) { if (Icon != null) { float iconX = 0; float iconY = (ushort)padding?.Top + iconPadding.Top; if (string.IsNullOrEmpty(TextLabel?.Text)) { iconX = (SizeWidth - Icon.SizeWidth) / 2; } else { var widthSum = (ushort)padding?.Start + (ushort)padding?.End + iconPadding.Start + iconPadding.End + textPadding.Start + textPadding.End + Icon.SizeWidth + (float)TextLabel?.SizeWidth; var widthDiff = SizeWidth - widthSum; if (widthDiff > 0) { iconX = (ushort)padding?.Start + iconPadding.Start + (widthDiff / 2); } else { iconX = (ushort)padding?.Start + iconPadding.Start; } } Icon.Position = new Position(iconX, iconY); } if (TextLabel != null) { TextLabel.HorizontalAlignment = HorizontalAlignment.Begin; float textX = 0; float textY = 0; if (string.IsNullOrEmpty(Icon?.ResourceUrl)) { textX = (SizeWidth - TextLabel.SizeWidth) / 2; textY = (ushort)padding?.Top + textPadding.Top; } else { textX = (float)Icon?.PositionX + (float)Icon?.SizeWidth; textY = (ushort)padding?.Top + textPadding.Top + (((float)Icon?.SizeHeight - TextLabel.SizeHeight) / 2); } TextLabel.Position = new Position(textX, textY); } } break; default: break; } padding?.Dispose(); }