public FrameTest1Page() { FrameView = new VisualView() { Size = new Size(500, 100), BackgroundColor = Tizen.NUI.Color.White, BoxShadow = new Shadow(10.0f, new Color(0.2f, 0.2f, 0.2f, 1.0f), new Vector2(5, 5)), }; FrameText = new TextVisual(); FrameText.Text = "Frame With Shadow"; FrameText.TextColor = Tizen.NUI.Color.Black; FrameText.PointSize = 10; FrameText.HorizontalAlignment = HorizontalAlignment.Center; BorderVisual borderVisual = new BorderVisual(); borderVisual.BorderSize = 2.0f; borderVisual.Color = Tizen.NUI.Color.Blue; borderVisual.RelativeSize = new RelativeVector2(1.0f, 1.0f); FrameView.AddVisual("_borderVisual", borderVisual); FrameView.AddVisual("_textVisual", FrameText); InitializeComponent(); Add(FrameView); ShadowOnBackground.Clicked += OnShadowOnButtonClicked; ShadowOffBackground.Clicked += OnShadowOffButtonClicked; }
private void printGameAttributes() { Container barsContainer = (Container)mainView.Visuals[1]; Container attributesContainer = (Container)mainView.Visuals[2]; Bar bar; TextVisual text; //Console.WriteLine("Game attributes:"); long maximum = 0; for (int i = 0; i < Game.PlayersCount * Player.AttributesCount; i++) { if (gameAttributes[i] > maximum) { maximum = gameAttributes[i]; } } for (int player = 0; player < Game.PlayersCount; player++) { //Console.WriteLine("Player {0} attributes:", player); for (int attribute = 0; attribute < Player.AttributesCount; attribute++) { int index = player * Player.AttributesCount + attribute; bar = (Bar)barsContainer.Visuals[index]; text = (TextVisual)attributesContainer.Visuals[index]; //Console.WriteLine("attribute no.{0} = {1}", attribute, gameAttributes[index]); text.Text = gameAttributes[index].ToString(); double value = gameAttributes[index]; value /= maximum; bar.Level = value; } } }
public void TextVisualUnderline() { tlog.Debug(tag, $"TextVisualUnderline START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); PropertyMap underlineMapSet = new PropertyMap(); underlineMapSet.Add("enable", new PropertyValue("true")); underlineMapSet.Add("color", new PropertyValue("green")); underlineMapSet.Add("height", new PropertyValue("1")); testingTarget.Underline = underlineMapSet; PropertyMap underlineMapGet = new PropertyMap(); underlineMapGet = testingTarget.Underline; Assert.IsNotNull(underlineMapGet, "Should not be null"); string str = ""; underlineMapGet["enable"].Get(out str); Assert.AreEqual("true", str, "Retrieved enable should equals to the set value"); underlineMapGet["color"].Get(out str); Assert.AreEqual("green", str, "Retrieved color should equals to the set value"); underlineMapGet["height"].Get(out str); Assert.AreEqual("1", str, "Retrieved height should equals to the set value"); underlineMapGet.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualUnderline END (OK)"); }
public void TextVisualConstructor() { tlog.Debug(tag, $"TextVisualConstructor START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualConstructor END (OK)"); }
public PTPMsgStrEditVM(MSGstr str, Tuple <ImageDrawing, ImageDrawing, ImageDrawing, RectangleGeometry> tuple, string oldEncoding, string newEncoding, int backgroundIndex) { this.str = str; strEW = new EventWrapper(str, this); OldEncoding = Static.EncodingManager.GetPersonaEncoding(oldEncoding); NewEncoding = Static.EncodingManager.GetPersonaEncoding(newEncoding); OldText = new TextVisual(Static.FontManager.GetPersonaFont(oldEncoding)) { Tag = "Old" }; NewText = new TextVisual(Static.FontManager.GetPersonaFont(newEncoding)) { Tag = "New" }; OldText.IsEnable = Settings.AppSetting.Default.PTPImageView; NewText.IsEnable = Settings.AppSetting.Default.PTPImageView; UpdateBackground(backgroundIndex); OldText.UpdateText(str.OldString); NewText.UpdateText(str.NewString.GetTextBaseList(NewEncoding)); DrawingGroup oldDrawingGroup = new DrawingGroup(); oldDrawingGroup.Children.Add(tuple.Item3); if (tuple.Item1 != null) { oldDrawingGroup.Children.Add(tuple.Item1); } oldDrawingGroup.Children.Add(OldText.TextDrawing); oldDrawingGroup.ClipGeometry = tuple.Item4; OldTextImage.Drawing = oldDrawingGroup; DrawingGroup newDrawingGroup = new DrawingGroup(); newDrawingGroup.Children.Add(tuple.Item3); if (tuple.Item2 != null) { newDrawingGroup.Children.Add(tuple.Item2); } newDrawingGroup.Children.Add(NewText.TextDrawing); newDrawingGroup.ClipGeometry = tuple.Item4; NewTextImage.Drawing = newDrawingGroup; MovePrefixDown = new RelayCommand(str.MovePrefixDown); MovePrefixUp = new RelayCommand(str.MovePrefixUp); MovePostfixDown = new RelayCommand(str.MovePostfixDown); MovePostfixUp = new RelayCommand(str.MovePostfixUp); }
public void TextVisualPointSize() { tlog.Debug(tag, $"TextVisualPointSize START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); testingTarget.PointSize = 1.0f; Assert.AreEqual(1.0f, testingTarget.PointSize, "Retrieved PointSize should be equal to set value"); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualPointSize END (OK)"); }
public void TextVisualEnableMarkup() { tlog.Debug(tag, $"TextVisualEnableMarkup START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); testingTarget.EnableMarkup = true; Assert.AreEqual(true, testingTarget.EnableMarkup, "Retrieved EnableMarkup should be equal to set value"); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualEnableMarkup END (OK)"); }
public void TextVisualFontFamily() { tlog.Debug(tag, $"TextVisualFontFamily START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); testingTarget.FontFamily = "FontFamily"; Assert.AreEqual("FontFamily", testingTarget.FontFamily, "Retrieved FontFamily should be equal to set value"); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualFontFamily END (OK)"); }
public BrushBorderTestPage() { InitializeComponent(); ButtonSolid.Clicked += OnClickedSolid; ButtonGradientLinear.Clicked += OnClickedLinear; ButtonGradientRadial.Clicked += OnClickedRadial; FrameView = new VisualView() { Size = new Size(500, 100), BackgroundColor = Tizen.NUI.Color.White, BoxShadow = new Shadow(10.0f, new Color(0.2f, 0.2f, 0.2f, 1.0f), new Vector2(5, 5)) }; FrameText = new TextVisual(); FrameText.Text = "Frame With Shadow"; FrameText.TextColor = Tizen.NUI.Color.Black; FrameText.PointSize = 10; FrameText.HorizontalAlignment = HorizontalAlignment.Center; PropertyArray stopColor = new PropertyArray(); stopColor.Add(new PropertyValue(new Vector4(255.0f, 0.0f, 0.0f, 255.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(0.0f, 255.0f, 0.0f, 255.0f) / 255.0f)); LinearGradient = new GradientVisual(); LinearGradient.StopColor = stopColor; LinearGradient.StartPosition = new Vector2(0.0f, 0.0f); LinearGradient.EndPosition = new Vector2(0.3f, 0.3f); LinearGradient.Origin = Visual.AlignType.TopBegin; RadialGradient = new GradientVisual(); RadialGradient.Center = new Vector2(0.0f, 0.0f); RadialGradient.Radius = 0.5f; RadialGradient.StopColor = stopColor; RadialGradient.Origin = Visual.AlignType.TopBegin; FrameBorder = new BorderVisual(); FrameBorder.BorderSize = 2.0f; FrameBorder.Color = Tizen.NUI.Color.Blue; FrameBorder.RelativeSize = new RelativeVector2(1.0f, 1.0f); FrameView.AddVisual(BorderId, FrameBorder); FrameView.AddVisual(TextId, FrameText); ContentView.Add(FrameView); }
public void VisualMapVisualFittingModeWithNullMode() { tlog.Debug(tag, $"VisualMapVisualFittingModeWithNullMode START"); TextVisual tVisual = new TextVisual(); Assert.AreEqual(VisualFittingModeType.FitKeepAspectRatio, tVisual.VisualFittingMode, "should be equal!"); BorderVisual bvisual = new BorderVisual(); Assert.AreEqual(VisualFittingModeType.Fill, bvisual.VisualFittingMode, "should be equal!"); tVisual.Dispose(); bvisual.Dispose(); tlog.Debug(tag, $"VisualMapVisualFittingModeWithNullMode END (OK)"); }
public void TextVisualShadow() { tlog.Debug(tag, $"TextVisualShadow START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); PropertyMap shadowMapSet = new PropertyMap(); shadowMapSet.Add("color", new PropertyValue(new Color(1.0f, 0.1f, 0.3f, 0.5f))); shadowMapSet.Add("offset", new PropertyValue(new Vector2(2.0f, 1.0f))); shadowMapSet.Add("blurRadius", new PropertyValue(3.0f)); testingTarget.Shadow = shadowMapSet; PropertyMap shadowMapGet = new PropertyMap(); shadowMapGet = testingTarget.Shadow; Assert.IsNotNull(shadowMapGet, "Should not be null"); using (Color color = new Color()) { shadowMapGet["color"].Get(color); Assert.AreEqual(1.0f, color.R, "Retrieved color.R should be equal to set value"); Assert.AreEqual(0.1f, color.G, "Retrieved color.G should be equal to set value"); Assert.AreEqual(0.3f, color.B, "Retrieved color.B should be equal to set value"); Assert.AreEqual(0.5f, color.A, "Retrieved color.A should be equal to set value"); } using (Vector2 vector2 = new Vector2()) { shadowMapGet["offset"].Get(vector2); Assert.AreEqual(2.0f, vector2.X, "Retrieved vector2.X should be equal to set value"); Assert.AreEqual(1.0f, vector2.Y, "Retrieved vector2.Y should be equal to set value"); } float blurRadius; shadowMapGet["blurRadius"].Get(out blurRadius); Assert.AreEqual(3.0f, blurRadius, "Retrieved blurRadius should equals to the set value"); shadowMapSet.Dispose(); shadowMapGet.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualShadow END (OK)"); }
public VisualClient() { application = new Application(); window = new Window("learn", 1280, 720, Orientation.Vertical); themeA = new Theme(new Color(255 / 8, 255 / 8, 255 / 8), new Color(255, 255, 255), Window.Theme.Font); application.Window = window; text = new TextVisual("Waiting..."); input = new TextInput("Server"); input.Input = "127.0.0.1"; Button button = new Button("Connect"); button.Theme = themeA; button.OnPressed += OnConnectClicked; window.Container.Add(text); window.Container.Add(input); window.Container.Add(button); application.Run(); gameLogicThread.Join(); }
public VisualizerVM() { Text = new TextVisual(PersonaFont) { Tag = "Text" }; Name = new TextVisual(PersonaFont) { Tag = "Name" }; Text.VisualChanged += Text_VisualChanged; Name.VisualChanged += Name_VisualChanged; FontSelect = 0; BackgroundSelect = 0; SetBack(); }
public void TextVisualTextColor() { tlog.Debug(tag, $"TextVisualTextColor START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); using (Color color = new Color(1.0f, 1.0f, 1.0f, 1.0f)) { testingTarget.TextColor = color; Assert.AreEqual(1.0f, testingTarget.TextColor.R, "Retrieved TextColor.R should be equal to set value"); Assert.AreEqual(1.0f, testingTarget.TextColor.G, "Retrieved TextColor.G should be equal to set value"); Assert.AreEqual(1.0f, testingTarget.TextColor.B, "Retrieved TextColor.B should be equal to set value"); Assert.AreEqual(1.0f, testingTarget.TextColor.A, "Retrieved TextColor.A should be equal to set value"); } testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualTextColor END (OK)"); }
/// <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); }
private void Render(bool bitmapDirty) { if (bitmapDirty) { lock (l) { _bitmap = BitmapSource.Create( _bitmapWidth, _bitmapHeight, 96, 96, _pixelFormat, null, _bitmapPixels, _bitmapStride); } } // Render the text bitmap with scaling DrawingGroup drawingGroup = new DrawingGroup(); RenderOptions.SetBitmapScalingMode(drawingGroup, BitmapScalingMode.HighQuality); //Options, Fant? ImageDrawing image = new ImageDrawing(); double textHeight = Math.Min(Height, _progressiveScroll.DrawHeight); image.Rect = new Rect(0.0, 0.0, _progressiveScroll.ActualWidth, textHeight); image.ImageSource = _bitmap; drawingGroup.Children.Add(image); using (DrawingContext drawingContext = TextVisual.RenderOpen()) { drawingContext.DrawDrawing((Drawing)drawingGroup); } if (_invalidateAgain) { Invalidate(Parts.TextContent); } }
public void TextVisualBackground() { tlog.Debug(tag, $"TextVisualBackground START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); PropertyMap backgroundMapSet = new PropertyMap(); backgroundMapSet.Add("enable", new PropertyValue(true)); backgroundMapSet.Add("color", new PropertyValue(new Color(1.0f, 0.1f, 0.3f, 0.5f))); testingTarget.Background = backgroundMapSet; PropertyMap backgroundMapGet = new PropertyMap(); backgroundMapGet = testingTarget.Background; Assert.IsNotNull(backgroundMapGet, "Should not be null"); bool enable = false; backgroundMapGet["enable"].Get(out enable); Assert.AreEqual(true, enable, "Retrieved enable should equals to the set value"); using (Color color = new Color()) { backgroundMapGet["color"].Get(color); Assert.AreEqual(1.0f, color.R, "Retrieved color.R should be equal to set value"); Assert.AreEqual(0.1f, color.G, "Retrieved color.G should be equal to set value"); Assert.AreEqual(0.3f, color.B, "Retrieved color.B should be equal to set value"); Assert.AreEqual(0.5f, color.A, "Retrieved color.A should be equal to set value"); } backgroundMapSet.Dispose(); backgroundMapGet.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualBackground END (OK)"); }
public void TextVisualOutline() { tlog.Debug(tag, $"TextVisualOutline START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); PropertyMap outlineMapSet = new PropertyMap(); outlineMapSet.Add("color", new PropertyValue(new Color(1.0f, 0.1f, 0.3f, 0.5f))); outlineMapSet.Add("width", new PropertyValue("1")); testingTarget.Outline = outlineMapSet; PropertyMap outlineMapGet = new PropertyMap(); outlineMapGet = testingTarget.Outline; Assert.IsNotNull(outlineMapGet, "Should not be null"); using (Color color = new Color()) { outlineMapGet["color"].Get(color); Assert.AreEqual(1.0f, color.R, "Retrieved color.R should be equal to set value"); Assert.AreEqual(0.1f, color.G, "Retrieved color.G should be equal to set value"); Assert.AreEqual(0.3f, color.B, "Retrieved color.B should be equal to set value"); Assert.AreEqual(0.5f, color.A, "Retrieved color.A should be equal to set value"); } string str = ""; outlineMapGet["width"].Get(out str); Assert.AreEqual("1", str, "Retrieved width should equals to the set value"); outlineMapSet.Dispose(); outlineMapGet.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualOutline END (OK)"); }
public void TextVisualVerticalAlignment() { tlog.Debug(tag, $"TextVisualVerticalAlignment START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); Assert.AreEqual(VerticalAlignment.Top, testingTarget.VerticalAlignment, "Retrieved VerticalAlignment should be equal to set value"); testingTarget.VerticalAlignment = VerticalAlignment.Center; Assert.AreEqual(VerticalAlignment.Center, testingTarget.VerticalAlignment, "Retrieved VerticalAlignment should be equal to set value"); testingTarget.VerticalAlignment = VerticalAlignment.Bottom; Assert.AreEqual(VerticalAlignment.Bottom, testingTarget.VerticalAlignment, "Retrieved VerticalAlignment should be equal to set value"); testingTarget.VerticalAlignment = VerticalAlignment.Top; Assert.AreEqual(VerticalAlignment.Top, testingTarget.VerticalAlignment, "Retrieved VerticalAlignment should be equal to set value"); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualVerticalAlignment END (OK)"); }
public void TextVisualHorizontalAlignment() { tlog.Debug(tag, $"TextVisualHorizontalAlignment START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); Assert.AreEqual(HorizontalAlignment.Begin, testingTarget.HorizontalAlignment, "Retrieved HorizontalAlignment should be equal to set value"); testingTarget.HorizontalAlignment = HorizontalAlignment.Center; Assert.AreEqual(HorizontalAlignment.Center, testingTarget.HorizontalAlignment, "Retrieved HorizontalAlignment should be equal to set value"); testingTarget.HorizontalAlignment = HorizontalAlignment.End; Assert.AreEqual(HorizontalAlignment.End, testingTarget.HorizontalAlignment, "Retrieved HorizontalAlignment should be equal to set value"); testingTarget.HorizontalAlignment = HorizontalAlignment.Begin; Assert.AreEqual(HorizontalAlignment.Begin, testingTarget.HorizontalAlignment, "Retrieved HorizontalAlignment should be equal to set value"); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualHorizontalAlignment END (OK)"); }
public void TextVisualFontStyle() { tlog.Debug(tag, $"TextVisualFontStyle START"); var testingTarget = new TextVisual(); Assert.IsNotNull(testingTarget, "Can't create success object TextVisual"); Assert.IsInstanceOf <TextVisual>(testingTarget, "Should be an instance of TextVisual type."); PropertyMap fontStyleMapSet = new PropertyMap(); fontStyleMapSet.Add("weight", new PropertyValue("bold")); fontStyleMapSet.Add("width", new PropertyValue("condensed")); fontStyleMapSet.Add("slant", new PropertyValue("italic")); testingTarget.FontStyle = fontStyleMapSet; PropertyMap fontStyleMapGet = new PropertyMap(); fontStyleMapGet = testingTarget.FontStyle; Assert.IsNotNull(fontStyleMapGet, "Should not be null"); string str = ""; fontStyleMapGet.Find(0, "weight").Get(out str); Assert.AreEqual("bold", str, "fontStyleMapGet.Find(\"weight\") should equals to the set value"); fontStyleMapGet.Find(1, "width").Get(out str); Assert.AreEqual("condensed", str, "fontStyleMapGet.Find(\"width\") should equals to the set value"); fontStyleMapGet.Find(2, "slant").Get(out str); Assert.AreEqual("italic", str, "fontStyleMapGet.Find(\"slant\") should equals to the set value"); fontStyleMapSet.Dispose(); fontStyleMapGet.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TextVisualFontStyle END (OK)"); }
protected override VisualGroup CreateVisual(IRenderContext context, INode node) { Color borderColor, backgroundColor1, backgroundColor2; if (((GraphControl)context.CanvasControl).CurrentItem == node) { borderColor = Color.Orange; backgroundColor1 = Color.White; backgroundColor2 = Color.Orange; } else { borderColor = Color.FromArgb(255, 24, 154, 231); backgroundColor1 = Color.FromArgb(255, 204, 255, 255); backgroundColor2 = Color.FromArgb(255, 24, 154, 231); } var layout = node.Layout; var employee = (Employee)node.Tag; var text = new TextVisual { Text = GetShortName(employee.Name), Font = new Font("Arial", 37, FontStyle.Regular, GraphicsUnit.Pixel), Brush = Brushes.Black, Location = new PointD(5, 5) }; double locationX = layout.Width / 2 - text.GetBounds(context).Width / 2; double locationY = layout.Height / 2 - text.GetBounds(context).Height / 2; string s1 = GetShortName(employee.Name); Font font1 = new Font("Arial", 37, FontStyle.Regular, GraphicsUnit.Pixel); Brush brush1 = Brushes.Black; IPoint location1 = new PointD(locationX, locationY); text = new TextVisual { Text = s1, Font = font1, Brush = brush1, Location = location1 }; var ribbonColor = Color.Green; if (employee.Status == EmployeeStatus.Travel) { ribbonColor = Color.Purple; } if (employee.Status == EmployeeStatus.Unavailable) { ribbonColor = Color.Red; } var border = new RectangleVisual(0, 0, layout.Width, layout.Height) { Pen = new Pen(borderColor) }; var background = new RectangleVisual(0, 0, layout.Width, layout.Height) { Brush = new LinearGradientBrush(new PointF(0, 0), new PointF((float)layout.Width, (float)layout.Height), backgroundColor1, backgroundColor2) }; var ribbonPath = new GeneralPath(); ribbonPath.MoveTo(0, 20); ribbonPath.LineTo(25, 0); ribbonPath.LineTo(40, 0); ribbonPath.LineTo(0, 35); ribbonPath.Close(); var ribbon = new GeneralPathVisual(ribbonPath) { Brush = new SolidBrush(ribbonColor) }; // Set a transform on the group, matching the node's location. // That way only the transform has to be updated instead of every single child visual. var transform = new Matrix(); transform.Translate((float)layout.X, (float)layout.Y); var group = new VisualGroup { Transform = transform, Children = { border, background, text, ribbon } }; return(group); }
protected override void OnCreate() { base.OnCreate(); view = new VisualView[2]; for (int i = 0; i < num; i++) { view[i] = new VisualView(); view[i].Size2D = new Size2D(600, 600); view[i].BackgroundColor = Color.Blue; view[i].Position = new Position(400 + i * 800, 600, 0); view[i].Focusable = true; view[i].Name = "MyView" + i; Window.Instance.Add(view[i]); view[i].FocusGained += VisualSample_FocusGained; view[i].FocusLost += VisualSample_FocusLost; view[i].KeyEvent += VisualSample_KeyEvent; } view[0].RightFocusableView = view[1]; view[1].LeftFocusableView = view[0]; imageMap = new ImageVisual(); imageMap.URL = resourcePath + "gallery-" + imgIndex++ + ".jpg"; imageMap.AnchorPoint = Visual.AlignType.TopBegin; imageMap.Origin = Visual.AlignType.TopBegin; imageMap.Position = new Vector2(0, 0); imageMap.PositionPolicy = VisualTransformPolicyType.Absolute; imageMap.Size = new Size2D(500, 500); imageMap.SizePolicy = VisualTransformPolicyType.Absolute; imageMap.DepthIndex = 0; view[0].AddVisual("bgVisual", imageMap); highlightImageMap = new ImageVisual(); highlightImageMap.URL = resourcePath + "star-highlight.png"; highlightImageMap.AnchorPoint = Visual.AlignType.TopBegin; highlightImageMap.Origin = Visual.AlignType.TopBegin; highlightImageMap.Size = new Vector2(40, 40); highlightImageMap.SizePolicy = VisualTransformPolicyType.Absolute; highlightImageMap.Position = new Vector2(10, 10); highlightImageMap.PositionPolicy = VisualTransformPolicyType.Absolute; highlightImageMap.DepthIndex = 1; view[0].AddVisual("iconVisual", highlightImageMap); textMap1 = new TextVisual(); textMap1.Text = "Hello"; textMap1.AnchorPoint = Visual.AlignType.TopBegin; textMap1.Origin = Visual.AlignType.TopBegin; textMap1.PointSize = 20; textMap1.Position = new Vector2(60, 210); textMap1.PositionPolicy = VisualTransformPolicyType.Absolute; textMap1.Size = new Vector2(600, 200); textMap1.SizePolicy = VisualTransformPolicyType.Absolute; textMap1.TextColor = Color.Red; textMap1.DepthIndex = 5; view[0].AddVisual("textVisual", textMap1); imageMap2 = new ImageVisual(); imageMap2.URL = resourcePath + "gallery-" + imgIndex + ".jpg"; imageMap2.AnchorPoint = Visual.AlignType.TopBegin; imageMap2.Origin = Visual.AlignType.TopBegin; imageMap2.Position = new Vector2(0, 0); imageMap2.PositionPolicy = VisualTransformPolicyType.Absolute; imageMap2.Size = new Vector2(500, 500); imageMap2.SizePolicy = VisualTransformPolicyType.Absolute; imageMap2.DepthIndex = 0; view[1].AddVisual("bgVisual", imageMap2); dimImageMap = new ImageVisual(); dimImageMap.URL = resourcePath + "star-dim.png"; dimImageMap.Size = new Vector2(40, 40); dimImageMap.SizePolicy = VisualTransformPolicyType.Absolute; dimImageMap.AnchorPoint = Visual.AlignType.TopBegin; dimImageMap.Origin = Visual.AlignType.TopBegin; dimImageMap.Position = new Vector2(10, 10); dimImageMap.PositionPolicy = VisualTransformPolicyType.Absolute; dimImageMap.DepthIndex = 1; view[1].AddVisual("iconVisual", dimImageMap); textMap2 = new TextVisual(); textMap2.Text = "I'm"; textMap2.PointSize = 20; textMap2.AnchorPoint = Visual.AlignType.TopBegin; textMap2.Origin = Visual.AlignType.TopBegin; textMap2.Position = new Vector2(60, 210); textMap2.PositionPolicy = VisualTransformPolicyType.Absolute; textMap2.Size = new Vector2(600, 200); textMap2.SizePolicy = VisualTransformPolicyType.Absolute; textMap2.TextColor = Color.Black; textMap2.DepthIndex = 5; view[1].AddVisual("textVisual", textMap2); guide = new TextLabel(); guide.PivotPoint = PivotPoint.TopLeft; guide.Size2D = new Size2D(800, 200); guide.Padding = new Vector4(50, 50, 50, 50); guide.MultiLine = true; guide.BackgroundColor = Color.Magenta; guide.PointSize = 10; guide.TextColor = Color.Black; guide.Text = "Left/Right - Move focus\n" + "Up/Down - Change Text\n" + "Enter - Change BG image\n"; Window.Instance.Add(guide); Window.Instance.KeyEvent += Instance_Key; FocusManager.Instance.SetCurrentFocusView(view[0]); Window.Instance.TouchEvent += Instance_Touch; _window = Window.Instance; _window.FocusChanged += _window_WindowFocusChanged; }
public void Initialize() { Window window = Window.Instance; /* Create a visual view. */ _visualView = new VisualView(); _visualView.ParentOrigin = ParentOrigin.TopLeft; _visualView.PivotPoint = PivotPoint.TopLeft; _visualView.Size2D = new Size2D((int)window.Size.Width, (int)window.Size.Height); /* color visual */ ColorVisual colorVisualMap1 = new ColorVisual(); colorVisualMap1.Color = Color.Green; _visualView.Background = colorVisualMap1.OutputVisualMap; window.Add(_visualView); /* image visual 1. */ imageVisualMap1 = new ImageVisual(); imageVisualMap1.URL = resources + "/images/image-1.jpg"; imageVisualMap1.Size = new Vector2(200.0f, 200.0f); imageVisualMap1.Position = new Vector2(10.0f, 10.0f); imageVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; Console.WriteLine("PositionPolicy:{0}", imageVisualMap1.PositionPolicy); imageVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; Console.WriteLine("SizePolicy:{0}", imageVisualMap1.SizePolicy); imageVisualMap1.Origin = Visual.AlignType.TopBegin; imageVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("imageVisual1", imageVisualMap1); imageVisualMap1.URL = resources + "/images/image-3.jpg"; /* image visual 2. */ ImageVisual imageVisualMap2 = new ImageVisual(); imageVisualMap2.URL = resources + "/images/image-2.jpg"; imageVisualMap2.Size = new Vector2(250.0f, 200.0f); imageVisualMap2.Position = new Vector2(220.0f, 10.0f); imageVisualMap2.PositionPolicy = VisualTransformPolicyType.Absolute; imageVisualMap2.SizePolicy = VisualTransformPolicyType.Absolute; imageVisualMap2.Origin = Visual.AlignType.TopBegin; imageVisualMap2.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("imageVisual2", imageVisualMap2); /* text visual. */ textVisualMap1 = new TextVisual(); textVisualMap1.Text = "Hello Goodbye"; textVisualMap1.PointSize = 20.0f; textVisualMap1.Size = new Vector2(900.0f, 250.0f); textVisualMap1.Position = new Vector2(10.0f, 220.0f); textVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; textVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; textVisualMap1.Origin = Visual.AlignType.TopBegin; textVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("textVisual1", textVisualMap1); /* border visual */ borderVisualMap1 = new BorderVisual(); borderVisualMap1.Color = Color.Red; borderVisualMap1.BorderSize = 5.0f; borderVisualMap1.Size = new Vector2(100.0f, 100.0f); borderVisualMap1.Position = new Vector2(10.0f, 380.0f); borderVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; borderVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; borderVisualMap1.Origin = Visual.AlignType.TopBegin; borderVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("borderVisual1", borderVisualMap1); /* gradient visual */ GradientVisual gradientVisualMap1 = new GradientVisual(); PropertyArray stopPosition = new PropertyArray(); stopPosition.Add(new PropertyValue(0.0f)); stopPosition.Add(new PropertyValue(0.3f)); stopPosition.Add(new PropertyValue(0.6f)); stopPosition.Add(new PropertyValue(0.8f)); stopPosition.Add(new PropertyValue(1.0f)); gradientVisualMap1.StopOffset = stopPosition; PropertyArray stopColor = new PropertyArray(); stopColor.Add(new PropertyValue(new Vector4(129.0f, 198.0f, 193.0f, 255.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(196.0f, 198.0f, 71.0f, 122.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(214.0f, 37.0f, 139.0f, 191.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(129.0f, 198.0f, 193.0f, 150.0f) / 255.0f)); stopColor.Add(new PropertyValue(Color.Yellow)); gradientVisualMap1.StopColor = stopColor; gradientVisualMap1.StartPosition = new Vector2(0.5f, 0.5f); gradientVisualMap1.EndPosition = new Vector2(-0.5f, -0.5f); gradientVisualMap1.Center = new Vector2(0.5f, 0.5f); gradientVisualMap1.Radius = 1.414f; gradientVisualMap1.Size = new Vector2(100.0f, 100.0f); gradientVisualMap1.Position = new Vector2(120.0f, 380.0f); gradientVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; gradientVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; gradientVisualMap1.Origin = Visual.AlignType.TopBegin; gradientVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("gradientVisual1", gradientVisualMap1); /* primitive visual: Cone */ PrimitiveVisual primitiveVisualMap1 = new PrimitiveVisual(); primitiveVisualMap1.Shape = PrimitiveVisualShapeType.Cone; primitiveVisualMap1.BevelPercentage = 0.3f; primitiveVisualMap1.BevelSmoothness = 0.0f; primitiveVisualMap1.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisualMap1.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisualMap1.Size = new Vector2(100.0f, 100.0f); primitiveVisualMap1.Position = new Vector2(230.0f, 380.0f); primitiveVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap1.Origin = Visual.AlignType.TopBegin; primitiveVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual1", primitiveVisualMap1); /* primitive visual: Sphere */ PrimitiveVisual primitiveVisualMap2 = new PrimitiveVisual(); primitiveVisualMap2.Shape = PrimitiveVisualShapeType.Sphere; primitiveVisualMap2.BevelPercentage = 0.3f; primitiveVisualMap2.BevelSmoothness = 0.0f; primitiveVisualMap2.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisualMap2.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisualMap2.Size = new Vector2(100.0f, 100.0f); primitiveVisualMap2.Position = new Vector2(340.0f, 380.0f); primitiveVisualMap2.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap2.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap2.Origin = Visual.AlignType.TopBegin; primitiveVisualMap2.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual2", primitiveVisualMap2); /* primitive visual: Cylinder */ PrimitiveVisual primitiveVisualMap3 = new PrimitiveVisual(); primitiveVisualMap3.Shape = PrimitiveVisualShapeType.Cylinder; primitiveVisualMap3.BevelPercentage = 0.3f; primitiveVisualMap3.BevelSmoothness = 0.0f; primitiveVisualMap3.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisualMap3.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisualMap3.Size = new Vector2(100.0f, 100.0f); primitiveVisualMap3.Position = new Vector2(10.0f, 490.0f); primitiveVisualMap3.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap3.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap3.Origin = Visual.AlignType.TopBegin; primitiveVisualMap3.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual3", primitiveVisualMap3); /* primitive visual: ConicalFrustrum */ PrimitiveVisual primitiveVisualMap4 = new PrimitiveVisual(); primitiveVisualMap4.Shape = PrimitiveVisualShapeType.ConicalFrustrum; primitiveVisualMap4.BevelPercentage = 0.3f; primitiveVisualMap4.BevelSmoothness = 0.0f; primitiveVisualMap4.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisualMap4.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisualMap4.Size = new Vector2(100.0f, 100.0f); primitiveVisualMap4.Position = new Vector2(120.0f, 490.0f); primitiveVisualMap4.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap4.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap4.Origin = Visual.AlignType.TopBegin; primitiveVisualMap4.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual4", primitiveVisualMap4); /* primitive visual: Cube */ PrimitiveVisual primitiveVisualMap5 = new PrimitiveVisual(); primitiveVisualMap5.Shape = PrimitiveVisualShapeType.Cube; primitiveVisualMap5.BevelPercentage = 0.3f; primitiveVisualMap5.BevelSmoothness = 0.0f; primitiveVisualMap5.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisualMap5.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisualMap5.Size = new Vector2(100.0f, 100.0f); primitiveVisualMap5.Position = new Vector2(230.0f, 490.0f); primitiveVisualMap5.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap5.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisualMap5.Origin = Visual.AlignType.TopBegin; primitiveVisualMap5.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual5", primitiveVisualMap5); /* mesh visual nothing show. */ MeshVisual meshVisualMap1 = new MeshVisual(); meshVisualMap1.ObjectURL = resources + "/models/Dino.obj"; meshVisualMap1.MaterialtURL = resources + "/models/Dino.mtl"; meshVisualMap1.TexturesPath = resources + "/images/"; meshVisualMap1.ShadingMode = MeshVisualShadingModeValue.TexturedWithSpecularLighting; meshVisualMap1.Size = new Size2D(400, 400); meshVisualMap1.Position = new Position2D(-50, 600); meshVisualMap1.PositionPolicy = VisualTransformPolicyType.Absolute; meshVisualMap1.SizePolicy = VisualTransformPolicyType.Absolute; meshVisualMap1.Origin = Visual.AlignType.TopBegin; meshVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("meshVisual1", meshVisualMap1); /* n-patch image visual 1. */ npatchImageVisualMap1 = new NPatchVisual(); npatchImageVisualMap1.URL = resources + "/images/gallery-4.jpg"; npatchImageVisualMap1.Size = new Size2D(400, 400); npatchImageVisualMap1.Position = new Position2D(300, 600); npatchImageVisualMap1.PositionPolicyX = VisualTransformPolicyType.Absolute; npatchImageVisualMap1.PositionPolicyY = VisualTransformPolicyType.Absolute; npatchImageVisualMap1.SizePolicyWidth = VisualTransformPolicyType.Absolute; npatchImageVisualMap1.SizePolicyHeight = VisualTransformPolicyType.Absolute; npatchImageVisualMap1.Origin = Visual.AlignType.TopBegin; npatchImageVisualMap1.AnchorPoint = Visual.AlignType.TopBegin; npatchImageVisualMap1.Border = new Rectangle(100, 100, 100, 100); _visualView.AddVisual("npatchImageVisual1", npatchImageVisualMap1); _window = Window.Instance; _window.FocusChanged += (sender, ee) => { cnt++; Tizen.Log.Debug("NUI", "[WindowFocusTest] WindowFocusChanged event comes! focus gained=" + ee.FocusGained); imageVisualMap1.Size += new Size2D(50, 50); imageVisualMap1.Position += new Vector2(20.0f, 20.0f); textVisualMap1.Text = "Hello Goodbye" + cnt; textVisualMap1.PointSize = 10.0f + (float)(cnt); npatchImageVisualMap1.URL = resources + "/images/gallery-" + (cnt % 5) + ".jpg"; borderVisualMap1.BorderSize = 1.0f + (float)cnt; }; Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable()); _window.SetAcceptFocus(false); Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=false!!!"); Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable()); _window.SetAcceptFocus(true); Tizen.Log.Debug("NUI", "[WindowFocusTest] set focus acceptable=true!!!"); Tizen.Log.Debug("NUI", "[WindowFocusTest] is focus acceptable=" + _window.IsFocusAcceptable()); }
public void OnConnectClicked(object sender, EventArgs e) { text.Text = "Connecting..."; Console.WriteLine("OnConnectClicked"); Console.WriteLine("Connecting to server: {0} ...", input.Input); Int32 port = 13000; client = new TcpClient(input.Input, port); stream = client.GetStream(); stream.Read(playerIndexBuffer, 0, playerIndexBuffer.Length); if (BitConverter.IsLittleEndian) { Array.Reverse(playerIndexBuffer); } playerIndex = BitConverter.ToInt32(playerIndexBuffer, 0); Console.WriteLine("Player index: {0}", playerIndex); if (playerIndex == 0) { isMyTurn = true; } stream.Read(attributesBuffer, 0, attributesBuffer.Length); fillGameAttributes(); mainView = new Container(Orientation.Vertical); window.Container = mainView; for (int i = 0; i < 4; i++) { window.Container.Add(new Container(Orientation.Horizontal)); } Container dummy; dummy = (Container)window.Container.Visuals[0]; dummy.Add(new TextVisual("Player: " + (playerIndex + 1).ToString())); turnVisual = new TextVisual("Turn: " + turn); dummy.Add(turnVisual); indication = new TextVisual("Indications"); dummy.Add(indication); lastPlay = new TextVisual("Last plays: none, none"); dummy.Add(lastPlay); dummy = (Container)window.Container.Visuals[1]; for (int i = 0; i < Player.AttributesCount * Game.PlayersCount; i++) { dummy.Add(new Bar(1.0)); } dummy = (Container)window.Container.Visuals[2]; for (int i = 0; i < Player.AttributesCount * Game.PlayersCount; i++) { dummy.Add(new TextVisual(32.ToString())); } dummy = (Container)window.Container.Visuals[3]; Button play1Button = new Button("Play 1"); play1Button.Theme = themeA; play1Button.OnPressed += OnPlay1Clicked; Button play2Button = new Button("Play 2"); play2Button.OnPressed += OnPlay2Clicked; Button play3Button = new Button("Play 3"); play3Button.Theme = themeA; play3Button.OnPressed += OnPlay3Clicked; Button play4Button = new Button("Play 4"); play4Button.OnPressed += OnPlay4Clicked; dummy.Add(play1Button); dummy.Add(play2Button); dummy.Add(play3Button); dummy.Add(play4Button); gameLogicThread = new Thread(new ThreadStart(GameLoop)); gameLogicThread.Start(); }
public TextBlock() { _textVisual = new TextVisual(Visual.Compositor, this); Visual.Children.InsertAtBottom(_textVisual); }
/// <summary> /// Create VisualMap /// </summary> /// <param name="type">A string that denote visual type</param> /// <param name="position">A position of the created visual</param> /// <returns>VisualView</returns> private VisualView CreateVisualMap(string type, Vector2 position) { // Visual Map declaration VisualMap visualMap = null; // TextVisual declaration TextVisual textVisual = null; switch (type) { // Image Visual case "Image": ImageVisual imageVisual = new ImageVisual(); // Set Visual URL imageVisual.URL = mImageJpgUrl; visualMap = imageVisual; // Create TextVisual textVisual = CreateTextVisual(type + " Visual"); break; case "Color": ColorVisual colorVisual = new ColorVisual(); // Set Visual Color colorVisual.Color = new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f); visualMap = colorVisual; // Create TextVisual textVisual = CreateTextVisual(type + " Visual"); break; case "NPatch": NPatchVisual nPatchVisual = new NPatchVisual(); // Set Visual URL nPatchVisual.URL = mImageNpatchUrl; visualMap = nPatchVisual; // Create TextVisual textVisual = CreateTextVisual(type + " Visual"); break; case "SVG": SVGVisual svgVisual = new SVGVisual(); // Set Visual URL svgVisual.URL = mImageSvgUrl; visualMap = svgVisual; // Create TextVisual textVisual = CreateTextVisual(type + " Visual"); break; case "Animated": AnimatedImageVisual animatedImageVisual = new AnimatedImageVisual(); // Set Visual URL animatedImageVisual.URL = mImageGifUrl; visualMap = animatedImageVisual; // Create TextVisual textVisual = CreateTextVisual(type + " Visual"); break; case "Border": BorderVisual borderVisual = new BorderVisual(); // Set Visual Color borderVisual.Color = Color.White; // Set Visual Size borderVisual.BorderSize = 5.0f; visualMap = borderVisual; // Create TextVisual textVisual = CreateTextVisual(type + " Visual"); break; case "Gradient": // Set GradientVisual properties GradientVisual gradientVisual = new GradientVisual(); PropertyArray stopOffset = new PropertyArray(); stopOffset.Add(new PropertyValue(0.0f)); stopOffset.Add(new PropertyValue(0.3f)); stopOffset.Add(new PropertyValue(0.6f)); stopOffset.Add(new PropertyValue(0.8f)); stopOffset.Add(new PropertyValue(1.0f)); gradientVisual.StopOffset = stopOffset; // Create the PropertyArray of stopColor. PropertyArray stopColor = new PropertyArray(); stopColor.Add(new PropertyValue(new Vector4(129.0f, 198.0f, 193.0f, 255.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(196.0f, 198.0f, 71.0f, 122.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(214.0f, 37.0f, 139.0f, 191.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(129.0f, 198.0f, 193.0f, 150.0f) / 255.0f)); stopColor.Add(new PropertyValue(Color.Yellow)); // Set the color at the stop offsets. // At least 2 values required to show a gradient. gradientVisual.StopColor = stopColor; // Set the start position of a linear gradient. gradientVisual.StartPosition = new Vector2(0.5f, 0.5f); // Set the end position of a linear gradient. gradientVisual.EndPosition = new Vector2(-0.5f, -0.5f); // Set the center point of a radial gradient. gradientVisual.Center = new Vector2(0.5f, 0.5f); // Set the size of the radius of a radial gradient. gradientVisual.Radius = 1.414f; visualMap = gradientVisual; // Create TextVisual textVisual = CreateTextVisual(type + " Visual"); break; case "Cone": visualMap = CreatePrimitiveVisual(PrimitiveVisualShapeType.Cone); // Create TextVisual textVisual = CreateTextVisual("PrimitiveVisual(" + type + ")"); break; case "Sphere": visualMap = CreatePrimitiveVisual(PrimitiveVisualShapeType.Sphere); // Create TextVisual textVisual = CreateTextVisual("PrimitiveVisual(" + type + ")"); break; case "Cylinder": visualMap = CreatePrimitiveVisual(PrimitiveVisualShapeType.Cylinder); // Create TextVisual textVisual = CreateTextVisual("PrimitiveVisual(" + type + ")"); break; case "ConicalFrustrum": visualMap = CreatePrimitiveVisual(PrimitiveVisualShapeType.ConicalFrustrum); // Create TextVisual textVisual = CreateTextVisual("PrimitiveVisual(" + type + ")"); break; case "Cube": visualMap = CreatePrimitiveVisual(PrimitiveVisualShapeType.Cube); // Create TextVisual textVisual = CreateTextVisual("PrimitiveVisual(" + type + ")"); break; case "Octahedron": visualMap = CreatePrimitiveVisual(PrimitiveVisualShapeType.Octahedron); // Create TextVisual textVisual = CreateTextVisual("PrimitiveVisual(" + type + ")"); break; case "BevelledCube": visualMap = CreatePrimitiveVisual(PrimitiveVisualShapeType.BevelledCube); // Create TextVisual textVisual = CreateTextVisual("PrimitiveVisual(" + type + ")"); break; default: break; } if (visualMap != null) { // Set the common properties visualMap.Size = mVisualSize; visualMap.Position = new Vector2(0.0f, 0.0f); visualMap.PositionPolicy = VisualTransformPolicyType.Absolute; visualMap.SizePolicy = VisualTransformPolicyType.Absolute; visualMap.Origin = Visual.AlignType.Center; visualMap.AnchorPoint = Visual.AlignType.Center; } if (textVisual != null) { textVisual.Position = new Vector2(0.0f, mVisualSize.Height / 2 + 25); } VisualView subVisualView = new VisualView(); subVisualView.PositionUsesPivotPoint = true; subVisualView.ParentOrigin = ParentOrigin.CenterLeft; subVisualView.PivotPoint = PivotPoint.Center; subVisualView.Position2D = position; subVisualView.Size2D = mVisualSize; subVisualView.AddVisual(type + "Visual", visualMap); subVisualView.AddVisual(type + "TextVisual", textVisual); return(subVisualView); }
protected override VisualGroup CreateVisual(IRenderContext context, INode node) { // Fetch information for the child visuals var employee = (Employee)node.Tag; Color borderColor, backgroundColor1, backgroundColor2, ribbonColor; if (((GraphControl)context.CanvasControl).CurrentItem == node) { borderColor = Color.Orange; backgroundColor1 = Color.White; backgroundColor2 = Color.Orange; } else { borderColor = Color.FromArgb(255, 24, 154, 231); backgroundColor1 = Color.FromArgb(255, 204, 255, 255); backgroundColor2 = Color.FromArgb(255, 24, 154, 231); } if (employee.Status == EmployeeStatus.Travel) { ribbonColor = Color.Purple; } else if (employee.Status == EmployeeStatus.Unavailable) { ribbonColor = Color.Red; } else { ribbonColor = Color.Green; } var layout = node.Layout; var icon = GetIcon(employee.Icon); var iconScalingFactor = (layout.Height - 10d) / icon.Height; var iconWidth = icon.Width * iconScalingFactor; var nameText = new TextVisual { Text = employee.Name, Font = new Font("Arial", 13, FontStyle.Regular, GraphicsUnit.Pixel), Brush = Brushes.Black, Location = new PointD(iconWidth + 10, 10) }; var positionText = new TextVisual { Text = employee.Position, Font = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel), Brush = Brushes.Black, Location = new PointD(iconWidth + 10, 35) }; var emailText = new TextVisual { Text = employee.Email, Font = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel), Brush = Brushes.Black, Location = new PointD(iconWidth + 10, 50) }; var phone1Text = new TextVisual { Text = employee.Phone, Font = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel), Brush = Brushes.Black, Location = new PointD(iconWidth + 10, 65) }; var faxText = new TextVisual { Text = employee.Fax, Font = new Font("Arial", 11, FontStyle.Regular, GraphicsUnit.Pixel), Brush = Brushes.Black, Location = new PointD(iconWidth + 10, 80) }; var border = new RectangleVisual(0, 0, layout.Width, layout.Height) { Pen = new Pen(borderColor) }; var background = new RectangleVisual(0, 0, layout.Width, layout.Height) { Brush = new LinearGradientBrush(new PointF(0, 0), new PointF((float)layout.Width, (float)layout.Height), backgroundColor1, backgroundColor2) }; var iconVisual = new ImageVisual { Image = icon, Rectangle = new RectD(5, 5, icon.Width * iconScalingFactor, icon.Height * iconScalingFactor) }; IRectangle rect = new RectD(layout.Width - 30, 5, 25, 25); var circle1 = new EllipseVisual(rect) { Brush = new SolidBrush(ribbonColor) }; IRectangle rect1 = new RectD(layout.Width - 25, 10, 15, 15); var circle2 = new EllipseVisual(rect1) { Brush = Brushes.White }; IRectangle rect2 = new RectD(layout.Width - 20, 15, 5, 5); var circle3 = new EllipseVisual(rect2) { Brush = circle1.Brush }; // Set a transform on the group, matching the node's location. // That way only the transform has to be updated instead of every single child visual. var transform = new Matrix(); transform.Translate((float)layout.X, (float)layout.Y); var group = new VisualGroup { Transform = transform, Children = { border, background, iconVisual, nameText, positionText, emailText, phone1Text, faxText, circle1, circle2, circle3 } }; return(group); }
/// <summary> /// Visual Sample Application initialisation. /// </summary> private void Initialize() { Window.Instance.BackgroundColor = Color.White; // Show Visuals Type. // There are 11 Visuals will be marked with text // Color visual will be used to _visualView's Background // TextVisual don't need use it. text = new TextLabel[11]; // Create a visual view. // Make it fill to Window. // Visuals will put on it. _visualView = new VisualView(); _visualView.PositionUsesPivotPoint = true; _visualView.ParentOrigin = ParentOrigin.TopLeft; _visualView.PivotPoint = PivotPoint.TopLeft; _visualView.Size2D = Window.Instance.Size; // color visual. // color.R/G/B/A range 0 - 1(contain 0 and 1) // Renders a color to the visual's quad geometry. ColorVisual colorVisual = new ColorVisual(); colorVisual.Color = new Color(0.8f, 0.8f, 0.8f, 1.0f); _visualView.Background = colorVisual.OutputVisualMap; Window.Instance.GetDefaultLayer().Add(_visualView); // Create the text mark normal image visual. text[0] = CreateTextLabel("normal image visual", new Position2D(20, 20)); Window.Instance.GetDefaultLayer().Add(text[0]); // normal image visual. // Renders a raster image ( jpg, png etc.) into the visual's quad geometry. ImageVisual imageVisual = new ImageVisual(); imageVisual.URL = image_jpg; imageVisual.Size = new Size2D(200, 200); imageVisual.Position = new Vector2(20.0f, 120.0f); imageVisual.PositionPolicy = VisualTransformPolicyType.Absolute; imageVisual.SizePolicy = VisualTransformPolicyType.Absolute; imageVisual.Origin = Visual.AlignType.TopBegin; imageVisual.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("imageVisual", imageVisual); // Create the text mark normal image visual. text[1] = CreateTextLabel("svg image visual", new Position2D(340, 20)); Window.Instance.GetDefaultLayer().Add(text[1]); // svg image visual. // Renders a svg image into the visual's quad geometry _svgVisuallView = new VisualView(); _svgVisuallView.Size2D = new Vector2(200, 200); _svgVisuallView.PositionUsesPivotPoint = true; _svgVisuallView.ParentOrigin = ParentOrigin.TopLeft; _svgVisuallView.PivotPoint = PivotPoint.TopLeft; _svgVisuallView.Position = new Position(340, 120, 0); Window.Instance.GetDefaultLayer().Add(_svgVisuallView); SVGVisual svgVisual = new SVGVisual(); svgVisual.URL = image_svg; svgVisual.Size = new Vector2(200, 200); svgVisual.PositionPolicy = VisualTransformPolicyType.Absolute; svgVisual.SizePolicy = VisualTransformPolicyType.Absolute; svgVisual.Origin = Visual.AlignType.Center; svgVisual.AnchorPoint = Visual.AlignType.TopBegin; _svgVisuallView.AddVisual("svgVisual", svgVisual); // Create the text mark npatch image visual. text[2] = CreateTextLabel("npatch image visual", new Position2D(680, 20)); Window.Instance.GetDefaultLayer().Add(text[2]); // n patch image visual. // Renders an npatch or a 9patch image. Uses nonquad // geometry. Both geometry and texture are cached to // reduce memory consumption if the same npatch image // is used elsewhere. NPatchVisual nPatchVisual = new NPatchVisual(); nPatchVisual.URL = image_9patch; nPatchVisual.Size = new Vector2(200, 200); nPatchVisual.Position = new Vector2(680, 120); nPatchVisual.PositionPolicy = VisualTransformPolicyType.Absolute; nPatchVisual.SizePolicy = VisualTransformPolicyType.Absolute; nPatchVisual.Origin = Visual.AlignType.TopBegin; nPatchVisual.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("nPatchVisual", nPatchVisual); // Create the text mark animated image visual. text[3] = CreateTextLabel("animated image visual", new Position2D(1000, 20)); Window.Instance.GetDefaultLayer().Add(text[3]); // animated image visual. // Renders an animated image into the visual's quad geometry. // Currently, only the GIF format is supported. AnimatedImageVisual animatedImageVisual = new AnimatedImageVisual(); animatedImageVisual.URL = image_gif; animatedImageVisual.Size = new Size2D(200, 200); animatedImageVisual.Position = new Vector2(1000.0f, 120.0f); animatedImageVisual.PositionPolicy = VisualTransformPolicyType.Absolute; animatedImageVisual.SizePolicy = VisualTransformPolicyType.Absolute; animatedImageVisual.Origin = Visual.AlignType.TopBegin; animatedImageVisual.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("animatedImageVisual", animatedImageVisual); // text visual. TextVisual textVisual = new TextVisual(); textVisual.Text = "This is a TextVisual"; textVisual.PointSize = 5.0f; textVisual.Size = new Vector2(400.0f, 100.0f); textVisual.Position = new Vector2(1150.0f, 60.0f); textVisual.PositionPolicy = VisualTransformPolicyType.Absolute; textVisual.SizePolicy = VisualTransformPolicyType.Absolute; textVisual.Origin = Visual.AlignType.TopBegin; textVisual.AnchorPoint = Visual.AlignType.TopBegin; textVisual.HorizontalAlignment = HorizontalAlignment.Center; _visualView.AddVisual("textVisual", textVisual); // Create the text mark border visual. text[4] = CreateTextLabel("border visual", new Position2D(20, 450)); Window.Instance.GetDefaultLayer().Add(text[4]); // borderVisual // Renders a color as an internal border to the visual's geometry. BorderVisual borderVisual = new BorderVisual(); borderVisual.Color = Color.Red; borderVisual.BorderSize = 5.0f; borderVisual.Size = new Vector2(200.0f, 200.0f); borderVisual.Position = new Vector2(20.0f, 550.0f); borderVisual.PositionPolicy = VisualTransformPolicyType.Absolute; borderVisual.SizePolicy = VisualTransformPolicyType.Absolute; borderVisual.Origin = Visual.AlignType.TopBegin; borderVisual.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("borderVisual", borderVisual); // Create the text mark gradient visual. text[5] = CreateTextLabel("gradient visual", new Position2D(240, 450)); Window.Instance.GetDefaultLayer().Add(text[5]); // gradient visual // Renders a smooth transition of colors to the visual's quad geometry. // Both Linear and Radial gradients are supported. GradientVisual gradientVisual = new GradientVisual(); // Create the PropertyArray of stopOffset. PropertyArray stopOffset = new PropertyArray(); stopOffset.Add(new PropertyValue(0.0f)); stopOffset.Add(new PropertyValue(0.3f)); stopOffset.Add(new PropertyValue(0.6f)); stopOffset.Add(new PropertyValue(0.8f)); stopOffset.Add(new PropertyValue(1.0f)); gradientVisual.StopOffset = stopOffset; // Create the PropertyArray of stopColor. PropertyArray stopColor = new PropertyArray(); stopColor.Add(new PropertyValue(new Vector4(129.0f, 198.0f, 193.0f, 255.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(196.0f, 198.0f, 71.0f, 122.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(214.0f, 37.0f, 139.0f, 191.0f) / 255.0f)); stopColor.Add(new PropertyValue(new Vector4(129.0f, 198.0f, 193.0f, 150.0f) / 255.0f)); stopColor.Add(new PropertyValue(Color.Yellow)); // Set the color at the stop offsets. // At least 2 values required to show a gradient. gradientVisual.StopColor = stopColor; // Set the start position of a linear gradient. gradientVisual.StartPosition = new Vector2(0.5f, 0.5f); // Set the end position of a linear gradient. gradientVisual.EndPosition = new Vector2(-0.5f, -0.5f); // Set the center point of a radial gradient. gradientVisual.Center = new Vector2(0.5f, 0.5f); // Set the size of the radius of a radial gradient. gradientVisual.Radius = 1.414f; gradientVisual.Size = new Vector2(200.0f, 200.0f); gradientVisual.Position = new Vector2(240.0f, 550.0f); gradientVisual.PositionPolicy = VisualTransformPolicyType.Absolute; gradientVisual.SizePolicy = VisualTransformPolicyType.Absolute; gradientVisual.Origin = Visual.AlignType.TopBegin; gradientVisual.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("gradientVisual1", gradientVisual); // Create the text mark gradient visual. text[6] = CreateTextLabel("primitive visual: Cone", new Position2D(460, 450)); Window.Instance.GetDefaultLayer().Add(text[6]); // primitive visual: Cone // Renders a simple 3D shape, such as a cube or sphere. Scaled to fit the control. // The shapes are generated with clockwise winding and backface culling on by default. // Cone : Equivalent to a conical frustrum with top radius of zero. PrimitiveVisual primitiveVisual1 = new PrimitiveVisual(); primitiveVisual1.Shape = PrimitiveVisualShapeType.Cone; primitiveVisual1.BevelPercentage = 0.3f; primitiveVisual1.BevelSmoothness = 0.0f; primitiveVisual1.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisual1.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisual1.Size = new Vector2(200.0f, 200.0f); primitiveVisual1.Position = new Vector2(460.0f, 550.0f); primitiveVisual1.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisual1.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisual1.Origin = Visual.AlignType.TopBegin; primitiveVisual1.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual1", primitiveVisual1); // Create the text mark primitive visual: Sphere. text[7] = CreateTextLabel("primitive visual: Sphere", new Position2D(680, 450)); Window.Instance.GetDefaultLayer().Add(text[7]); // primitive visual: Sphere // Sphere : Default. PrimitiveVisual primitiveVisual2 = new PrimitiveVisual(); primitiveVisual2.Shape = PrimitiveVisualShapeType.Sphere; primitiveVisual2.BevelPercentage = 0.3f; primitiveVisual2.BevelSmoothness = 0.0f; primitiveVisual2.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisual2.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisual2.Size = new Vector2(200.0f, 200.0f); primitiveVisual2.Position = new Vector2(680.0f, 550.0f); primitiveVisual2.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisual2.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisual2.Origin = Visual.AlignType.TopBegin; primitiveVisual2.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual2", primitiveVisual2); // Create the text mark primitive visual: Cylinder. text[8] = CreateTextLabel("primitive visual: Cylinder", new Position2D(1000, 450)); Window.Instance.GetDefaultLayer().Add(text[8]); // primitive visual: Cylinder // Cylinder : Equivalent to a conical frustrum with // equal radii for the top and bottom circles. PrimitiveVisual primitiveVisual3 = new PrimitiveVisual(); primitiveVisual3.Shape = PrimitiveVisualShapeType.Cylinder; primitiveVisual3.BevelPercentage = 0.3f; primitiveVisual3.BevelSmoothness = 0.0f; primitiveVisual3.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisual3.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisual3.Size = new Vector2(200.0f, 200.0f); primitiveVisual3.Position = new Vector2(1000.0f, 550.0f); primitiveVisual3.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisual3.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisual3.Origin = Visual.AlignType.TopBegin; primitiveVisual3.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual3", primitiveVisual3); // Create the text mark primitive visual: ConicalFrustrum. text[9] = CreateTextLabel("primitive visual: ConicalFrustrum", new Position2D(1220, 450)); Window.Instance.GetDefaultLayer().Add(text[9]); // primitive visual: ConicalFrustrum // ConicalFrustrum : The area bound between two circles, // i.e. a cone with the tip removed. PrimitiveVisual primitiveVisual4 = new PrimitiveVisual(); primitiveVisual4.Shape = PrimitiveVisualShapeType.ConicalFrustrum; primitiveVisual4.BevelPercentage = 0.3f; primitiveVisual4.BevelSmoothness = 0.0f; primitiveVisual4.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisual4.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisual4.Size = new Vector2(200.0f, 200.0f); primitiveVisual4.Position = new Vector2(1220.0f, 550.0f); primitiveVisual4.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisual4.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisual4.Origin = Visual.AlignType.TopBegin; primitiveVisual4.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual4", primitiveVisual4); // Create the text mark primitive visual: ConicalFrustrum. text[10] = CreateTextLabel("primitive visual: Cube", new Position2D(1460, 450)); Window.Instance.GetDefaultLayer().Add(text[10]); // primitive visual: Cube // Cube : Equivalent to a bevelled cube with a // bevel percentage of zero. PrimitiveVisual primitiveVisual5 = new PrimitiveVisual(); primitiveVisual5.Shape = PrimitiveVisualShapeType.Cube; primitiveVisual5.BevelPercentage = 0.3f; primitiveVisual5.BevelSmoothness = 0.0f; primitiveVisual5.ScaleDimensions = new Vector3(1.0f, 1.0f, 0.3f); primitiveVisual5.MixColor = new Vector4((245.0f / 255.0f), (188.0f / 255.0f), (73.0f / 255.0f), 1.0f); primitiveVisual5.Size = new Vector2(200.0f, 200.0f); primitiveVisual5.Position = new Vector2(1460.0f, 550.0f); primitiveVisual5.PositionPolicy = VisualTransformPolicyType.Absolute; primitiveVisual5.SizePolicy = VisualTransformPolicyType.Absolute; primitiveVisual5.Origin = Visual.AlignType.TopBegin; primitiveVisual5.AnchorPoint = Visual.AlignType.TopBegin; _visualView.AddVisual("primitiveVisual5", primitiveVisual5); Window.Instance.KeyEvent += AppBack; }
public void Initialize() { Window window = Window.Instance; window.BackgroundColor = Color.White; ImageVisual image = new ImageVisual() { URL = resourcePath + "/images/gallery-5.jpg", FittingMode = FittingModeType.ShrinkToFit, DesiredWidth = 400, DesiredHeight = 300, VisualFittingMode = VisualFittingModeType.FitKeepAspectRatio, }; ImageView imageV = new ImageView() { Size2D = new Size2D(500, 400), BackgroundColor = Color.Cyan, Image = image.OutputVisualMap, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, Position2D = new Position2D(-300, 0), PositionUsesPivotPoint = true, }; window.Add(imageV); PropertyMap outline = new PropertyMap(); outline.Add("color", new PropertyValue(Color.Red)); outline.Add("width", new PropertyValue(2.0f)); PropertyMap underline = new PropertyMap(); underline.Add("enable", new PropertyValue(true)); underline.Add("color", new PropertyValue("blue")); underline.Add("height", new PropertyValue(2)); PropertyMap shadow = new PropertyMap(); shadow.Add("offset", new PropertyValue(new Vector2(2.0f, 2.0f))); shadow.Add("color", new PropertyValue(Color.Green)); shadow.Add("blurRadius", new PropertyValue(5.0f)); PropertyMap bg = new PropertyMap(); bg.Add("enable", new PropertyValue(true)); bg.Add("color", new PropertyValue(Color.Cyan)); TextVisual text = new TextVisual() { Text = "I'm a text visual", PointSize = 52, Outline = outline, Underline = underline, Shadow = shadow, Background = bg, }; View view = new View() { Size2D = new Size2D(500, 400), ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, PositionUsesPivotPoint = true, Background = text.OutputVisualMap, Position2D = new Position2D(300, 0), }; window.Add(view); }