public void KeyValueRelativeVector2Value() { tlog.Debug(tag, $"KeyValueRelativeVector2Value START"); using (RelativeVector2 rVec2 = new RelativeVector2(0, 0)) { keyValue.RelativeVector2Value = rVec2; tlog.Debug(tag, "RelativeVector2Value : " + keyValue.RelativeVector2Value); } tlog.Debug(tag, $"KeyValueRelativeVector2Value END (OK)"); }
public void RelativeVector2Constructor() { tlog.Debug(tag, $"RelativeVector2Constructor START"); var testingTarget = new RelativeVector2(); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should return RelativeVector2 instance."); testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2Constructor END (OK)"); }
public override string ConvertToString(object value) { RelativeVector2 vector = value as RelativeVector2; if (null != vector) { return(vector.X.ToString() + " " + vector.Y.ToString()); } else { return(null); } }
public override string ConvertToString(object value) { RelativeVector2 vector = value as RelativeVector2; if (null != vector) { return(vector.X.ToString() + TypeConverter.UnifiedDelimiter + vector.Y.ToString()); } else { return(null); } }
public void RelativeVector2GetY() { tlog.Debug(tag, $"RelativeVector2GetY START"); var testingTarget = new RelativeVector2(1.0f, 0.5f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); Assert.AreEqual(0.5f, testingTarget.Y, "The Y of the vector is not correct here!"); testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2GetY END (OK)"); }
public void RelativeVector2ConstructorWithFloat() { tlog.Debug(tag, $"RelativeVector2ConstructorWithFloat START"); var testingTarget = new RelativeVector2(0.5f, 0.6f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should return Vector2 instance."); Assert.AreEqual(0.5f, testingTarget.X, "Retrieved vector.X should be equal to set value"); Assert.AreEqual(0.6f, testingTarget.Y, "Retrieved vector.Y should be equal to set value"); testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2ConstructorWithFloat END (OK)"); }
public void RelativeVector2GetValueBySubscriptIndex() { tlog.Debug(tag, $"RelativeVector2GetValueBySubscriptIndex START"); var testingTarget = new RelativeVector2(1.0f, 0.5f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); Assert.AreEqual(1.0f, testingTarget[0], "The value of index[0] is not correct!"); Assert.AreEqual(0.5f, testingTarget[1], "The value of index[1] is not correct!"); testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2GetValueBySubscriptIndex END (OK)"); }
public void RelativeVector2GetHashCode() { tlog.Debug(tag, $"RelativeVector2GetHashCode START"); var testingTarget = new RelativeVector2(1.0f, 0.0f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); var result = testingTarget.GetHashCode(); Assert.IsTrue(result >= Int32.MinValue && result <= Int32.MaxValue, "The value of hash is out of Integer range"); testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2GetHashCode END (OK)"); }
public void RelativeVector2ImplicitToVector2() { tlog.Debug(tag, $"RelativeVector2ImplicitToVector2 START"); Vector2 testingTarget = null; using (RelativeVector2 relativeVector2 = new RelativeVector2(1.0f, 0.5f)) { testingTarget = relativeVector2; Assert.AreEqual(relativeVector2.X, testingTarget.X, "The value of X is not correct."); Assert.AreEqual(relativeVector2.Y, testingTarget.Y, "The value of Y is not correct."); } testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2ImplicitToVector2 END (OK)"); }
public void RelativeVector2MultiplyByFloat() { tlog.Debug(tag, $"RelativeVector2MultiplyByFloat START"); var testingTarget = new RelativeVector2(0.02f, 0.04f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); var result = testingTarget * 10.0f; Assert.Less(Math.Abs(0.2f - result.X), 0.0001f, "The X of the vector is not correct here!"); Assert.Less(Math.Abs(0.4f - result.Y), 0.0001f, "The Y of the vector is not correct here!"); testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2MultiplyByFloat END (OK)"); }
public void RelativeVector2NotEqualTo() { tlog.Debug(tag, $"RelativeVector2NotEqualTo START"); var testingTarget = new RelativeVector2(1.0f, 0.5f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); using (RelativeVector2 vector = new RelativeVector2(1.0f, 0.6f)) { Assert.IsTrue((testingTarget.NotEqualTo(vector)), "Should be equal"); } testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2NotEqualTo END (OK)"); }
public void RelativeVector2DivisionByFloat() { tlog.Debug(tag, $"RelativeVector2DivisionByFloat START"); var testingTarget = new RelativeVector2(0.02f, 0.02f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); var result = testingTarget / 0.5f; Assert.AreEqual(0.04f, result.X, "The X of the vector is not correct here!"); Assert.AreEqual(0.04f, result.Y, "The Y of the vector is not correct here!"); testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2DivisionByFloat END (OK)"); }
public void KeyValueRelativeVector2Value() { tlog.Debug(tag, $"KeyValueRelativeVector2Value START"); RelativeVector2 b1 = new RelativeVector2(0, 0); KeyValue a1 = new KeyValue { RelativeVector2Value = b1 }; b1 = a1.RelativeVector2Value; b1.Dispose(); a1.Dispose(); tlog.Debug(tag, $"KeyValueRelativeVector2Value END (OK)"); Assert.Pass("KeyValueRelativeVector2Value"); }
public void RelativeVector2ConstructorWithRelativeVector3() { tlog.Debug(tag, $"RelativeVector2ConstructorWithRelativeVector3 START"); using (RelativeVector3 vec3 = new RelativeVector3(0.5f, 0.6f, 0.7f)) { var testingTarget = new RelativeVector2(vec3); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should return RelativeVector2 instance."); Assert.AreEqual(0.5f, testingTarget.X, "Retrieved vector2.X should be equal to set value"); Assert.AreEqual(0.6f, testingTarget.Y, "Retrieved vector2.Y should be equal to set value"); testingTarget.Dispose(); } tlog.Debug(tag, $"RelativeVector2ConstructorWithRelativeVector3 END (OK)"); }
public void RelativeVector2Equals() { tlog.Debug(tag, $"RelativeVector2Equals START"); var testingTarget = new RelativeVector2(0.02f, 0.02f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); using (RelativeVector2 vector = new RelativeVector2(0.02f, 0.02f)) { var result = testingTarget.Equals(vector); Assert.IsTrue(result, "Should be true here!"); } testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2Equals END (OK)"); }
public void RelativeVector2Subtraction() { tlog.Debug(tag, $"RelativeVector2Subtraction START"); var testingTarget = new RelativeVector2(1.0f, 0.8f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); using (RelativeVector2 vector = new RelativeVector2(1.0f, 0.6f)) { var result = testingTarget - vector; Assert.AreEqual(0.0f, result.X, "The X of the vector is not correct here!"); Assert.Less(Math.Abs(0.2f - result.Y), 0.0001f, "The Y of the vector is not correct here!"); } testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2Subtraction END (OK)"); }
public void RelativeVector2MultiplyByRelativeVector2() { tlog.Debug(tag, $"RelativeVector2MultiplyByRelativeVector2 START"); var testingTarget = new RelativeVector2(0.5f, 0.4f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); using (RelativeVector2 vector = new RelativeVector2(1.0f, 0.0f)) { var result = testingTarget * vector; Assert.AreEqual(0.5f, result.X, "The X of the vector is not correct here!"); Assert.AreEqual(0.0f, result.Y, "The Y of the vector is not correct here!"); } testingTarget.Dispose(); tlog.Debug(tag, $"RelativeVector2MultiplyByRelativeVector2 END (OK)"); }
public void RelativeVector3ConstructorWithRelativeVector2() { tlog.Debug(tag, $"RelativeVector3ConstructorWithRelativeVector2 START"); using (RelativeVector2 vec2 = new RelativeVector2(0.5f, 0.6f)) { var testingTarget = new RelativeVector3(vec2); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector3"); Assert.IsInstanceOf <RelativeVector3>(testingTarget, "Should return Vector3 instance."); Assert.AreEqual(0.5f, testingTarget.X, "Retrieved vector.X should be equal to set value"); Assert.AreEqual(0.6f, testingTarget.Y, "Retrieved vector.Y should be equal to set value"); Assert.AreEqual(0.0f, testingTarget.Z, "Retrieved vector.Z should be equal to set value"); testingTarget.Dispose(); } tlog.Debug(tag, $"RelativeVector3ConstructorWithRelativeVector2 END (OK)"); }
public void RelativeVector2Dispose() { tlog.Debug(tag, $"RelativeVector2Dispose START"); var testingTarget = new RelativeVector2(1.0f, 0.0f); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2"); Assert.IsInstanceOf <RelativeVector2>(testingTarget, "Should be an instance of RelativeVector2 type."); try { testingTarget.Dispose(); } catch (Exception e) { Assert.Fail("Caught Exception" + e.ToString()); } tlog.Debug(tag, $"RelativeVector2Dispose END (OK)"); }
/// <summary> /// The method to set the visual view visible after clicking the button3 /// - contains visuals primitives /// </summary> /// <returns> The created VisualView </returns> private VisualView CreateVisualView3() { VisualView CurrentVisualView = new VisualView(); CurrentVisualView.Size2D = new Size2D(CurrentWidth, CurrentHeight); CurrentVisualView.ParentOrigin = ParentOrigin.TopLeft; CurrentVisualView.PositionUsesPivotPoint = true; CurrentVisualView.PivotPoint = PivotPoint.TopLeft; CurrentVisualView.Position2D = new Position2D(2 * WindowWidth + FrameSize, 0); CurrentVisualView.BackgroundColor = Color.White; VisualMap ThisVisualMap = null; /// the main title ThisVisualMap = CreateTextVisual("VISUALS", 20.0f, new RelativeVector2(0.5f, 0.0f)); CurrentVisualView.AddVisual("TextVisuals", ThisVisualMap); float DeltaWidth = (1.0f + PrimitiveRelativeWidth) / 6.0f; float DeltaHeight = (float)((0.9f - Math.Ceiling(PrimitiveCount / 2.0f) * PrimitiveRelativeHeight) / (1.0f + Math.Ceiling(PrimitiveCount / 2.0f))); RelativeVector2 VisualRelativePosition = new RelativeVector2(-DeltaWidth, 0.1f + DeltaHeight); for (uint i = 0; i < PrimitiveCount; ++i) { ThisVisualMap = CreateVisualMap(PrimitiveName[i]); ThisVisualMap.RelativePosition = VisualRelativePosition + new RelativeVector2(0, 0.06f); CurrentVisualView.AddVisual(PrimitiveName[i], ThisVisualMap); CurrentVisualView.AddVisual("Text" + PrimitiveName[i], CreateTextVisual(PrimitiveName[i], 9.0f, VisualRelativePosition + new RelativeVector2(0.5f, PrimitiveRelativeHeight))); if (i % 2 == 0) { VisualRelativePosition += new RelativeVector2(2.0f * DeltaWidth, (DeltaHeight + PrimitiveRelativeHeight) / 2.0f); } else { VisualRelativePosition += new RelativeVector2(-2.0f * DeltaWidth, (DeltaHeight + PrimitiveRelativeHeight) / 2.0f); } } MainVisualView.Add(CurrentVisualView); return(CurrentVisualView); }
/// <summary> /// The method to create the TextVisual /// </summary> /// <param name="label"> The label of the Visual centered horizontally and /// vertically aligned to the top within the Visual's area </param> /// <param name="size"> The label's font size in points </param> /// <param name="relativePosition"> The relative position of the Visual /// determined as the shift of the anchor point (the visual's top center) /// from the origin (the parent's top begin) </param> /// <returns> TextVisual with given properties </returns> private TextVisual CreateTextVisual(string label, float size, RelativeVector2 relativePosition) { TextVisual LabelText = new TextVisual(); LabelText.Text = label; LabelText.RelativePosition = relativePosition; LabelText.PointSize = size; LabelText.MultiLine = true; LabelText.FontFamily = "Arial"; LabelText.HorizontalAlignment = HorizontalAlignment.Center; LabelText.VerticalAlignment = VerticalAlignment.Top; LabelText.Origin = Visual.AlignType.TopBegin; LabelText.AnchorPoint = Visual.AlignType.TopCenter; PropertyMap TextFontStyle = new PropertyMap(); TextFontStyle.Add("weight", new PropertyValue("bold")); TextFontStyle.Add("slant", new PropertyValue("italic")); LabelText.FontStyle = TextFontStyle; return(LabelText); }
public void RelativeVector2TypeConverterConvertToString() { tlog.Debug(tag, $"RelativeVector2TypeConverterConvertToString START"); var testingTarget = new RelativeVector2TypeConverterImpl(); Assert.IsNotNull(testingTarget, "Can't create success object RelativeVector2TypeConverter."); Assert.IsInstanceOf <RelativeVector2TypeConverter>(testingTarget, "Should return RelativeVector2TypeConverter instance."); // null var result = testingTarget.ConvertToString(0.3f); tlog.Debug(tag, "ConvertToString : " + result); using (RelativeVector2 vec = new RelativeVector2(0.1f, 0.3f)) { result = testingTarget.ConvertToString(vec); tlog.Debug(tag, "ConvertToString : " + result); } tlog.Debug(tag, $"RelativeVector2TypeConverterConvertToString END"); }
public override object ConvertFromInvariantString(string value) { if (value != null) { string[] parts = value.Split(TypeConverter.UnifiedDelimiter); if (parts.Length == 4) { return(new RelativeVector4(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture), Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture), Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture), Single.Parse(parts[3].Trim(), CultureInfo.InvariantCulture))); } else if (parts.Length == 3) { var vector3 = new RelativeVector3(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture), Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture), Single.Parse(parts[2].Trim(), CultureInfo.InvariantCulture)); var vector4 = new RelativeVector4(vector3); vector3.Dispose(); return(vector4); } else if (parts.Length == 2) { var vector2 = new RelativeVector2(Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture), Single.Parse(parts[1].Trim(), CultureInfo.InvariantCulture)); var vector4 = new RelativeVector4(vector2); vector2.Dispose(); return(vector4); } else if (parts.Length == 1) { var x = Single.Parse(parts[0].Trim(), CultureInfo.InvariantCulture); return(new RelativeVector4(x, x, x, x)); } } throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(RelativeVector4)}"); }
public override string ConvertToString(object value) { RelativeVector2 vector = (RelativeVector2)value; return(vector.X.ToString() + " " + vector.Y.ToString()); }