/// <summary> /// Creates and register label visual. /// </summary> /// <param name="text">String viewed by created label</param> private void CreateLabel(string text) { PropertyMap textVisual = new PropertyMap(); textVisual.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text)) .Add(TextVisualProperty.Text, new PropertyValue(text)) .Add(TextVisualProperty.TextColor, new PropertyValue(Color.Black)) .Add(TextVisualProperty.PointSize, new PropertyValue(12)) .Add(TextVisualProperty.HorizontalAlignment, new PropertyValue("CENTER")) .Add(TextVisualProperty.VerticalAlignment, new PropertyValue("CENTER")); VisualBase label = VisualFactory.Instance.CreateVisual(textVisual); RegisterVisual(LabelVisualIndex, label); label.DepthIndex = LabelVisualIndex; PropertyMap imageVisualTransform = new PropertyMap(); imageVisualTransform.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(new Vector2(30, 5))) .Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute))) .Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute))) .Add((int)VisualTransformPropertyType.Size, new PropertyValue(new Vector2(350, 100))); label.SetTransformAndSize(imageVisualTransform, new Vector2(this.SizeWidth, this.SizeHeight)); }
public void AddVisual(PropertyMap propertyMap) { int visualIndex = RegisterProperty("MyVisual", new PropertyValue("MyVisual"), PropertyAccessMode.ReadWrite); if (visualIndex > 0) { VisualBase visual = VisualFactory.Instance.CreateVisual(propertyMap); // Create a visual for the new one. RegisterVisual(visualIndex, visual); RelayoutRequest(); } }
public void VisualBaseConstructor() { tlog.Debug(tag, $"VisualBaseConstructor START"); var testingTarget = new VisualBase(); Assert.IsNotNull(testingTarget, "Can't create success object VisualBase"); Assert.IsInstanceOf <VisualBase>(testingTarget, "Should return VisualBase instance."); testingTarget.Dispose(); tlog.Debug(tag, $"VisualBaseConstructor END (OK)"); }
/// <summary> /// Creates and register background color visual. /// </summary> /// <param name="color">RGBA color vector</param> private void CreateBackground(Vector4 color) { PropertyMap map = new PropertyMap(); map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Color)) .Add(ColorVisualProperty.MixColor, new PropertyValue(color)); VisualBase background = VisualFactory.Instance.CreateVisual(map); RegisterVisual(BackgroundVisualIndex, background); background.DepthIndex = BackgroundVisualIndex; }
/// <summary> /// Adds or updates a visual to visual view. /// </summary> /// <param name="visualName">The name of a visual to add. If a name is added to an existing visual name, the visual will be replaced.</param> /// <param name="visualMap">The property map of a visual to create.</param> /// <exception cref="ArgumentNullException"> Thrown when visualMap is null. </exception> /// <since_tizen> 3 </since_tizen> public void AddVisual(string visualName, VisualMap visualMap) { VisualBase visual = null; int visualIndex = -1; /* If the visual had added, then replace it using RegisterVusal. */ //visual.Name = name; foreach (var item in visualDictionary) { if (item.Value.Name == visualName) { /* Find a existed visual, its key also exited. */ visualIndex = item.Key; UnregisterVisual(visualIndex); visualDictionary.Remove(visualIndex); tranformDictionary.Remove(visualIndex); break; } } if (visualIndex == -1) // The visual is a new one, create index for it. */ { using (var temp = new PropertyValue(visualName)) { visualIndex = RegisterProperty(visualName, temp, PropertyAccessMode.ReadWrite); } } if (visualIndex > 0) { if (visualMap == null) { throw new ArgumentNullException(nameof(visualMap)); } visual = VisualFactory.Instance.CreateVisual(visualMap.OutputVisualMap); // Create a visual for the new one. visual.Name = visualName; visual.DepthIndex = visualMap.DepthIndex; RegisterVisual(visualIndex, visual); visualDictionary.Add(visualIndex, visual); tranformDictionary.Add(visualIndex, visualMap.OutputTransformMap); visualMap.VisualIndex = visualIndex; visualMap.Name = visualName; visualMap.Parent = this; RelayoutRequest(); } }
//temporary fix to pass TCT internal void UpdateVisual(int visualIndex, string visualName, VisualMap visualMap) { VisualBase visual = null; visual = VisualFactory.Instance.CreateVisual(visualMap.OutputVisualMap); visual.Name = visualName; visual.DepthIndex = visualMap.DepthIndex; RegisterVisual(visualIndex, visual); visualDictionary[visualIndex] = visual; tranformDictionary[visualIndex] = visualMap.OutputTransformMap; RelayoutRequest(); NUILog.Debug("UpdateVisual() name=" + visualName); }
public void VisualBaseDispose() { tlog.Debug(tag, $"VisualBaseDispose START"); var testingTarget = new VisualBase(); Assert.IsNotNull(testingTarget, "Can't create success object VisualBase"); Assert.IsInstanceOf <VisualBase>(testingTarget, "Should return VisualBase instance."); try { testingTarget.Dispose(); } catch (Exception e) { Assert.Fail("Caught Exception" + e.ToString()); } testingTarget.Dispose(); tlog.Debug(tag, $"VisualBaseDispose END (OK)"); }
/// <summary> /// Creates and register icon image. /// </summary> /// <param name="url">Icon absolute path</param> /// <param name="x">x icon position</param> /// <param name="y">y icon position</param> /// <param name="w">icon width</param> /// <param name="h">icon height</param> /// <param name="index">visuals registration index</param> private void CreateIcon(string url, float x, float y, float w, float h, int index) { PropertyMap map = new PropertyMap(); PropertyMap transformMap = new PropertyMap(); map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)) .Add(ImageVisualProperty.URL, new PropertyValue(url)); VisualBase icon = VisualFactory.Instance.CreateVisual(map); PropertyMap imageVisualTransform = new PropertyMap(); imageVisualTransform.Add((int)VisualTransformPropertyType.Offset, new PropertyValue(new Vector2(x, y))) .Add((int)VisualTransformPropertyType.OffsetPolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute))) .Add((int)VisualTransformPropertyType.SizePolicy, new PropertyValue(new Vector2((int)VisualTransformPolicyType.Absolute, (int)VisualTransformPolicyType.Absolute))) .Add((int)VisualTransformPropertyType.Size, new PropertyValue(new Vector2(w, h))) .Add((int)VisualTransformPropertyType.Origin, new PropertyValue((int)Visual.AlignType.CenterBegin)) .Add((int)VisualTransformPropertyType.AnchorPoint, new PropertyValue((int)Visual.AlignType.CenterBegin)); icon.SetTransformAndSize(imageVisualTransform, new Vector2(this.SizeWidth, this.SizeHeight)); RegisterVisual(index, icon); icon.DepthIndex = index; }
public void VisualTest2() { try { Tizen.Log.Debug("NUI", "##### VisualTest2() start! ######"); VisualFactory visualfactory = VisualFactory.Instance; PropertyMap textMap1 = new PropertyMap(); textMap1.Insert(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text)); textMap1.Insert(TextVisualProperty.Text, new PropertyValue("Hello")); textMap1.Insert(TextVisualProperty.PointSize, new PropertyValue(10.0f)); PropertyMap textMap2 = new PropertyMap(); VisualBase textVisual1 = visualfactory.CreateVisual(textMap1); textVisual1.Creation = textMap2; } catch (Exception e) { Tizen.Log.Error("NUI", "Caught Exception" + e.ToString()); throw new System.InvalidOperationException("visual test2 error!!!"); //LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); //Assert.IsTrue(e is ArgumentException, "Argument Exception Not Recieved"); } }
/// <summary> /// Registers a visual by the property index, linking a view to visual when required.<br /> /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br /> /// If enabled is false, then the visual is not set on the stage until enabled by the derived class.<br /> /// </summary> /// <param name="index">The property index of the visual used to reference visual.</param> /// <param name="visual">The visual to register.</param> /// <param name="enabled">False if derived class wants to control when the visual is set on the stage.</param> /// <since_tizen> 3 </since_tizen> protected void RegisterVisual(int index, VisualBase visual, bool enabled) { viewWrapperImpl.RegisterVisual(index, visual, enabled); }
/// <summary> /// Registers a visual by property index, linking a view to visual when required.<br /> /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br /> /// No parenting is done during registration, this should be done by a derived class.<br /> /// </summary> /// <param name="index">The property index of the visual used to reference visual.</param> /// <param name="visual">The visual to register.</param> /// <since_tizen> 3 </since_tizen> protected void RegisterVisual(int index, VisualBase visual) { viewWrapperImpl.RegisterVisual(index, visual); }
public override void OnPaint() { BackColor = Color.White; switch (Entities) { case Entitykind.Boxentity: { Box.Paint(this); break; } case Entitykind.PolyCurveExtruder: { PolyCurveEx.Paint(this); break; } case Entitykind.CoordinateAxis: { Axis.Paint(this); break; } case Entitykind.TextEntity: { Text.Paint(this); break; } case Entitykind.Interpolator: { Interpolator.Paint(this); break; } case Entitykind.Zoom: { drawSphere(new xyz(0, 0, 0), 7, 80, 80); drawBox(new xyz(-10, -10, -1), new xyz(20, 20, 1)); drawBox(new xyz(0, 0, 0), new xyz(2, 2, 2)); break; } case Entitykind.CtrlRectangle: { PenWidth = 2; PolygonMode = PolygonMode.Line; drawPolyLine(Triangle); PolygonMode = PolygonMode.Fill; PenWidth = 1; break; } case Entitykind.Profiler: { Profil.Paint(this); break; } case Entitykind.ActiveCursor: { PolyCurveEx = new PolyCurveExtruder(); Loca _Loca = new Loca(); CurveArray Curves0 = new CurveArray(); Curves0.Count = 4; Curves0[0] = new Line(new xy(-3, -3), new xy(-3, 4)); Curves0[1] = new Line(new xy(-3, 4), new xy(4, 4)); Curves0[2] = new Line(new xy(4, 4), new xy(4, -3)); Curves0[3] = new Line(new xy(4, -3), new xy(-3, -3)); _Loca.Add(Curves0); OpenGlDevice.CheckError(); CurveArray Curves1 = new CurveArray(); Curves1.Count = 4; Curves1[0] = new Line(new xy(0, 0), new xy(1, 0)); Curves1[1] = new Line(new xy(1, 0), new xy(1, 1)); Curves1[2] = new Line(new xy(1, 1), new xy(0, 1)); Curves1[3] = new Line(new xy(0, 1), new xy(0, 0)); _Loca.Add(Curves1); PolyCurveEx.DownPlane = new Plane(new xyz(0, 0, 0), new xyz(0, 0, 1)); PolyCurveEx.UpPlane = new Plane(new xyz(0, 0, 4), new xyz(0, 0.5, 1)); PolyCurveEx.Loca = _Loca; PolyCurveEx.ShowUpPlane = true; PolyCurveEx.ShowDownPlane = true; PolyCurveEx.Height = -1; PolyCurveEx.Direction = new xyz(0, 1, 1); PolyCurveEx.Paint(this); ActiveC.Paint(this); break; } case Entitykind.SphereEntity: { Sphere.Paint(this); break; } case Entitykind.Cone: { Cone.Paint(this); break; } case Entitykind.Arrow: { Arrow.Paint(this); break; } case Entitykind.VisualBase: { VisualBase VB = new VisualBase(); VB.SnappEnable = false; VB.xAxis.ShaftColor = Color.Blue; VB.yAxis.ShaftColor = Color.Green; VB.zAxis.ShaftColor = Color.Yellow; VB.xAxis.TopColor = Color.Red; VB.yAxis.TopColor = Color.Red; VB.zAxis.TopColor = Color.Red; VB.Paint(this); break; } } ActiveC.Paint(this); base.OnPaint(); }
protected void RegisterVisual(int index, VisualBase visual, bool enabled) { customView.RegisterVisual(index, visual, enabled); }
protected void RegisterVisual(int index, VisualBase visual) { customView.RegisterVisual(index, visual); }
/// <summary> /// Registers a visual by the property index, linking a view to visual when required.<br /> /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br /> /// If enabled is false, then the visual is not set on the stage until enabled by the derived class.<br /> /// </summary> /// <param name="index">The property index of the visual used to reference visual.</param> /// <param name="visual">The visual to register.</param> /// <param name="enabled">False if derived class wants to control when the visual is set on the stage.</param> /// <since_tizen> 6 </since_tizen> public new void RegisterVisual(int index, VisualBase visual, bool enabled) { base.RegisterVisual(index, visual, enabled); }
/// <summary> /// Registers a visual by property index, linking a view to visual when required.<br /> /// In the case of the visual being a view or control deeming visual not required, then the visual should be an empty handle.<br /> /// No parenting is done during registration, this should be done by a derived class.<br /> /// </summary> /// <param name="index">The property index of the visual used to reference visual.</param> /// <param name="visual">The visual to register.</param> /// <since_tizen> 6 </since_tizen> public new void RegisterVisual(int index, VisualBase visual) { base.RegisterVisual(index, visual); }