public void SetDaggerfallPopupStyle(PopupStyle style, Panel panel) { // Do nothing if DaggerfallUnity path not valid if (!DaggerfallUnity.Instance.IsPathValidated) { return; } panel.BackgroundTexture = null; panel.BackgroundColor = Color.clear; if (style == PopupStyle.Parchment) { LoadDaggerfallParchmentTextures(); panel.SetBorderTextures( daggerfallParchmentTextures[0], daggerfallParchmentTextures[1], daggerfallParchmentTextures[2], daggerfallParchmentTextures[3], daggerfallParchmentTextures[4], daggerfallParchmentTextures[5], daggerfallParchmentTextures[6], daggerfallParchmentTextures[7], daggerfallParchmentTextures[8], globalFilterMode); } panel.SetMargins(Margins.All, 10); }
public override void OnCreate(View root) { var resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource; NUIApplication.GetDefaultWindow().BackgroundColor = Color.White; popup0 = new Popup(); popup0.BackgroundColor = Color.Cyan; popup0.Title.Text = "Popup0"; popup0.Size = new Size(300, 200); popup0.ButtonHeight = 60; popup0.AddButton("Left"); popup0.AddButton("Right"); popup0.PopupButtonClickEvent += Popup0ButtonClickedEvent; popup0.Post(NUIApplication.GetDefaultWindow()); var style = new PopupStyle() { IncludeDefaultStyle = true, Size = new Size(300, 200), Position = new Position(60, 60), BackgroundColor = Color.Magenta, Title = new TextLabelStyle() { Text = "Popup1", TextColor = Color.White, }, Buttons = new ButtonStyle() { CornerRadius = 0, SizeHeight = 60, BackgroundColor = new Selector <Color>() { Normal = new Color(1, 1, 1, 1), Pressed = new Color(1, 1, 1, 0.5f), }, Overlay = new ImageViewStyle() { BackgroundColor = new Selector <Color>() { Pressed = new Color(0, 0, 0, 0.1f), Other = new Color(1, 1, 1, 0.1f), }, }, Text = new TextLabelStyle() { TextColor = new Color(0.05f, 0.63f, 0.9f, 1), } } }; popup1 = new Popup(style); popup1.AddButton("Left"); popup1.AddButton("Right"); popup1.PopupButtonClickEvent += Popup1ButtonClickedEvent; popup1.Post(NUIApplication.GetDefaultWindow()); }
private void showPopup(string text, PopupStyle style, Sprite image) { // pause the game Time.timeScale = 0f; foreach (var pair in buttons) { pair.Value.SetActive(pair.Key == style); } popupPanel.SetActive(true); Text t = popupPanel.GetComponentInChildren <Text>(); Debug.Assert(t != null, "text is null!"); t.text = text; popupPanel.transform.FindChild("EventImage").GetComponent <Image>().overrideSprite = image; }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); AddBaseLayer(CartoBaseMapStyle.CartoBasemapStyleDefault); // Initialize a local vector data source LocalVectorDataSource source = new LocalVectorDataSource(BaseProjection); // Initialize a vector layer with the previous data source VectorLayer layer = new VectorLayer(source); // Add the previous vector layer to the map MapView.Layers.Add(layer); // Create marker style Android.Graphics.Bitmap androidMarkerBitmap = Android.Graphics.BitmapFactory.DecodeResource(Resources, Resource.Drawable.marker); Carto.Graphics.Bitmap markerBitmap = Carto.Utils.BitmapUtils.CreateBitmapFromAndroidBitmap(androidMarkerBitmap); MarkerStyleBuilder markerStyleBuilder = new MarkerStyleBuilder(); markerStyleBuilder.Bitmap = markerBitmap; markerStyleBuilder.Size = 30; MarkerStyle markerStyle = markerStyleBuilder.BuildStyle(); // Add marker MapPos berlin = MapView.Options.BaseProjection.FromWgs84(new MapPos(13.38933, 52.51704)); Marker marker = new Marker(berlin, markerStyle); source.Add(marker); // Add popup PopupStyleBuilder builder = new PopupStyleBuilder(); builder.SetAttachAnchorPoint(0.5f, 0); PopupStyle popupStyle = builder.BuildStyle(); BasicCustomPopupHandler popupHandler = new BasicCustomPopupHandler("custom popup"); CustomPopup popup = new CustomPopup(marker, popupStyle, popupHandler); popup.SetAnchorPoint(-1, 0); source.Add(popup); // Animate map to the marker MapView.SetFocusPos(berlin, 1); MapView.SetZoom(12, 1); }
private PopupInfoStyle GetStyle(PopupStyle style) { PopupInfoStyle[] styles = m_styles; int num = styles.Length; for (int i = 0; i < num; i++) { PopupInfoStyle popupInfoStyle = styles[i]; if (popupInfoStyle.style == style) { return(popupInfoStyle); } } Log.Error($"Cannot find style {style}", 96, "C:\\BuildAgents\\AgentB\\work\\cub_client_win64_develop\\client\\DofusCube.Unity\\Assets\\Core\\Code\\UI\\PopupInfo\\PopupInfoUI.cs"); return(m_styles[0]); }
public void PopupStyleConstructor() { tlog.Debug(tag, $"PopupStyleConstructor START"); PopupStyle style = new PopupStyle() { BackgroundColor = Color.Cyan, }; var testingTarget = new PopupStyle(style); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <PopupStyle>(testingTarget, "Should return PopupStyle instance."); testingTarget.Dispose(); tlog.Debug(tag, $"PopupStyleConstructor END (OK)"); }
public void PopupConstructorWithPopupStyle() { tlog.Debug(tag, $"PopupConstructorWithPopupStyle START"); PopupStyle style = new PopupStyle() { Size = new Size(50, 100), }; var testingTarget = new Popup(style); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <Popup>(testingTarget, "Should return Popup instance."); testingTarget.Dispose(); tlog.Debug(tag, $"PopupConstructorWithPopupStyle END (OK)"); }
public void PopupConstructorWithPopupStyle() { tlog.Debug(tag, $"PopupConstructorWithPopupStyle START"); PopupStyle style = new PopupStyle() { Size = new Size(50, 100), }; var testingTarget = new Popup(style); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <Popup>(testingTarget, "Should return Popup instance."); //Todo: this means that letting the Popup implicitly disposed. but explicit dispose causes BLOCK. this need be fixed! //testingTarget.Dispose(); tlog.Debug(tag, $"PopupConstructorWithPopupStyle END (OK)"); }
public async Task ShowAsync(PopupStyle style) { if (style == PopupStyle.Error) { //Show error style. Text = "ACCESS DENIED"; border.Style = (Style)this.FindResource("errorStyle"); var storyBoard = (Storyboard)this.FindResource("flashInAndHide"); await storyBoard.BeginAsync(this); } else { //Show success style. Text = "Access Granted"; border.Style = (Style)this.FindResource("successStyle"); var storyBoard = (Storyboard)this.FindResource("fadeInAndHide"); await storyBoard.BeginAsync(this); } }
public async Task ShowAsync(PopupStyle style) { if (style == PopupStyle.Error) { //Show error style. Text = "ACCESS DENIED"; border.Style = (Style)this.FindResource("errorStyle"); var storyBoard = (Storyboard)this.FindResource("flashInAndHide"); await storyBoard.BeginAsync(this); } else { //Show success style. Text = "Access Granted"; border.Style = (Style)this.FindResource("successStyle"); var storyBoard = (Storyboard)this.FindResource("fadeInAndHide"); await storyBoard.BeginAsync(this); } }
public void Activate() { Window window = NUIApplication.GetDefaultWindow(); root = new View() { Size = new Size(1920, 1080), BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f), }; window.Add(root); parent1 = new View() { Size = new Size(1920, 1080), }; parent1.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size(50, 50) }; parent2 = new View() { Size = new Size(1032, 980), }; parent2.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, LinearAlignment = LinearLayout.Alignment.CenterHorizontal, CellPadding = new Size(400, 400) }; ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// createText[0] = new TextLabel(); createText[0].Text = "Create Popup just by properties"; createText[0].WidthSpecification = 500; createText[0].HeightSpecification = 100; parent2.Add(createText[0]); popup = new Popup(); popup.MinimumSize = new Size(1032, 184); popup.Size = new Size(1032, 400); popup.Position = new Position(150, 100); // Title popup.Title.PointSize = 25; popup.Title.Size = new Size(0, 68); popup.Title.PositionUsesPivotPoint = true; popup.Title.ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft; popup.Title.PivotPoint = Tizen.NUI.PivotPoint.TopLeft; popup.Title.HorizontalAlignment = HorizontalAlignment.Begin; popup.Title.VerticalAlignment = VerticalAlignment.Bottom; popup.Title.Position = new Position(64, 52); popup.Title.Text = "Popup Title"; popup.Title.Padding = 0; // Shadow popup.ImageShadow = new ImageShadow(CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png", new Rectangle(24, 24, 24, 24), extents: new Vector2(48, 48)); // Background popup.BackgroundImage = CommonResource.GetFHResourcePath() + "11. Popup/popup_background.png"; popup.BackgroundImageBorder = new Rectangle(0, 0, 81, 81); // Buttons popup.AddButton("Yes"); popup.AddButton("Exit"); popup.ButtonBackground = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png"; popup.ButtonBackgroundBorder = new Rectangle(5, 5, 5, 5); popup.ButtonOverLayBackgroundColorSelector = new Selector <Color> { Normal = new Color(1.0f, 1.0f, 1.0f, 0.5f), Pressed = new Color(0.0f, 0.0f, 0.0f, 0.5f) }; popup.ButtonImageShadow = new ImageShadow(CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png", new Rectangle(5, 5, 5, 5)); popup.ButtonTextColor = color[0]; popup.ButtonHeight = 132; popup.PopupButtonClickEvent += PopupButtonClickedEvent; popup.LayoutDirectionChanged += PopupLayoutDirectionChanged; popup.Post(window); contentText = new TextLabel(); contentText.Size = new Size(1032, 100); contentText.PointSize = 20; contentText.HorizontalAlignment = HorizontalAlignment.Begin; contentText.VerticalAlignment = VerticalAlignment.Center; contentText.Text = "Popup ButtonStyle is " + buttonStyles[index]; contentText.TextColor = new Color(0, 0, 222, 1); popup.AddContentText(contentText); ///////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// createText[1] = new TextLabel(); createText[1].Text = "Create Popup just by Attributes"; createText[1].WidthSpecification = 500; createText[1].HeightSpecification = 100; parent2.Add(createText[1]); PopupStyle attrs = new PopupStyle { MinimumSize = new Size(1032, 184), BackgroundImage = new Selector <string> { All = CommonResource.GetFHResourcePath() + "11. Popup/popup_background.png" }, BackgroundImageBorder = new Selector <Rectangle> { All = new Rectangle(0, 0, 81, 81) }, ImageShadow = new ImageShadow(CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png", new Rectangle(24, 24, 24, 24), extents: new Vector2(48, 48)), Title = new TextLabelStyle { PointSize = new Selector <float?> { All = 25 }, TextColor = new Selector <Color> { All = Color.Black }, Size = new Size(0, 68), PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, PivotPoint = Tizen.NUI.PivotPoint.TopLeft, HorizontalAlignment = HorizontalAlignment.Begin, VerticalAlignment = VerticalAlignment.Bottom, Position = new Position(64, 52), Text = new Selector <string> { All = "Popup Title" }, }, Buttons = new ButtonStyle { PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft, PivotPoint = Tizen.NUI.PivotPoint.BottomLeft, BackgroundImage = new Selector <string> { All = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png" }, BackgroundImageBorder = new Selector <Rectangle> { All = new Rectangle(5, 5, 5, 5) }, ImageShadow = new ImageShadow(CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png", new Rectangle(5, 5, 5, 5)), Overlay = new ImageViewStyle { PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent, BackgroundColor = new Selector <Color> { Normal = new Color(1.0f, 1.0f, 1.0f, 0.5f), Pressed = new Color(0.0f, 0.0f, 0.0f, 0.5f), } }, Text = new TextLabelStyle { PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, TextColor = new Selector <Color> { All = color[index2] } }, }, }; popup2 = new Popup(attrs); popup2.Size = new Size(1032, 400); popup2.Position = new Position(150, 600); popup2.AddButton("Yes"); popup2.AddButton("Exit"); popup2.ButtonHeight = 132; popup2.PopupButtonClickEvent += PopupButtonClickedEvent; popup2.LayoutDirectionChanged += Popup2LayoutDirectionChanged; popup2.Post(window); contentText2 = new TextLabel(); contentText2.Size = new Size(1032, 100); contentText2.PointSize = 20; contentText2.HorizontalAlignment = HorizontalAlignment.Begin; contentText2.VerticalAlignment = VerticalAlignment.Center; contentText2.Text = "Popup2 ButtonStyle is " + buttonStyles[index]; popup2.ContentView.Add(contentText2); button = new Button(); button.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; button.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); button.WidthSpecification = 580; button.HeightSpecification = 80; button.TextLabel.Text = "LayoutDirection is left to right"; button.Clicked += ButtonClicked; parent1.Add(parent2); parent1.Add(button); root.Add(parent1); }
protected override Style CreateControlStyle() { PopupStyle style = new PopupStyle(ViewState, this); return style; }
public override void OnCreate(View root) { var popupStyle1 = new PopupStyle() { Size = new Size(500, 200), BackgroundColor = Color.White, BoxShadow = new Shadow(6.0f, Color.Blue, extents: new Vector2(5, 5)), Title = new TextLabelStyle { TextColor = Color.Black, PixelSize = 16, Text = "PopupStyle1" }, Buttons = new ButtonStyle { SizeHeight = 50, BackgroundColor = new Selector <Color> { Pressed = Color.Black, Other = Color.Cyan, }, Text = new TextLabelStyle { TextColor = new Selector <Color> { Pressed = Color.White, Other = Color.Black, }, PixelSize = 12, }, ParentOrigin = ParentOrigin.BottomLeft, PivotPoint = PivotPoint.BottomLeft, PositionUsesPivotPoint = true }, ThemeChangeSensitive = true, }; var popupStyle2 = popupStyle1.Clone() as PopupStyle; popupStyle2.BackgroundColor = Color.Black; popupStyle2.Title.Text = "PopupStyle2"; popupStyle2.Title.TextColor = Color.Cyan; popupStyle2.Buttons.SizeHeight = 80; popupStyle2.Buttons.BackgroundColor = new Selector <Color> { Pressed = Color.Cyan, Other = Color.Black, }; popupStyle2.Buttons.Text.TextColor = new Selector <Color> { Pressed = Color.Black, Other = Color.White, }; theme1 = new Theme(); theme1.AddStyle("Popup1", popupStyle1); theme1.AddStyle("Popup2", popupStyle2); theme2 = new Theme(); theme2.AddStyle("Popup1", popupStyle2); theme2.AddStyle("Popup2", popupStyle1); ThemeManager.ApplyTheme(theme1); popup0 = new Popup("Popup1"); popup0.AddButton("ChangeTheme"); popup0.AddButton("Close"); popup0.PopupButtonClickEvent += PopupButtonClickedEvent; popup0.Post(NUIApplication.GetDefaultWindow()); popup1 = new Popup("Popup2"); popup1.Position = new Position(0, 210); popup1.AddButton("ChangeTheme"); popup1.AddButton("Close"); popup1.PopupButtonClickEvent += PopupButtonClickedEvent; popup1.Post(NUIApplication.GetDefaultWindow()); }
public override Carto.Graphics.Bitmap OnDrawPopup(PopupDrawInfo popupDrawInfo) { PopupStyle style = popupDrawInfo.Popup.Style; // Calculate scaled dimensions float DPToPX = popupDrawInfo.DPToPX; float PXTODP = 1 / DPToPX; if (style.ScaleWithDPI) { DPToPX = 1; } else { PXTODP = 1; } float screenWidth = popupDrawInfo.ScreenBounds.GetWidth() * PXTODP; float screenHeight = popupDrawInfo.ScreenBounds.GetHeight() * PXTODP; // Update sizes based on scale (uses extension method, cf. Shared/Extensions int fontSize = FontSize.Update(DPToPX); int triangleWidth = TriangleSize.Update(DPToPX); int triangleHeight = TriangleSize.Update(DPToPX); int strokeWidth = StrokeWidth.Update(DPToPX); int screenPadding = ScreenPadding.Update(DPToPX); // Set font var font = Android.Graphics.Typeface.Create("HelveticaNeue-Light", Android.Graphics.TypefaceStyle.Normal); // Calculate the maximum popup size, adjust with dpi int maxPopupWidth = (int)(Math.Min(screenWidth, screenHeight)); float halfStrokeWidth = strokeWidth * 0.5f; int maxTextWidth = maxPopupWidth - (2 * screenPadding + strokeWidth); // Measure text TextPaint textPaint = new TextPaint { Color = TextColor, TextSize = fontSize }; textPaint.SetTypeface(font); var textLayout = new StaticLayout(text, textPaint, maxTextWidth, Layout.Alignment.AlignNormal, 1, 0, false); int textX = (int)Math.Min(textPaint.MeasureText(text), textLayout.Width); int textY = textLayout.Height; int popupWidth = textX + (2 * PopupPadding + strokeWidth + triangleWidth); int popupHeight = textY + (2 * PopupPadding + strokeWidth); var bitmap = Android.Graphics.Bitmap.CreateBitmap(popupWidth, popupHeight, Android.Graphics.Bitmap.Config.Argb8888); var canvas = new Android.Graphics.Canvas(bitmap); var trianglePath = new Android.Graphics.Path(); trianglePath.MoveTo(triangleWidth, 0); trianglePath.LineTo(halfStrokeWidth, triangleHeight * 0.5f); trianglePath.LineTo(triangleWidth, triangleHeight); trianglePath.Close(); int triangleOffsetX = 0; int triangleOffsetY = (popupHeight - triangleHeight) / 2; // Create paint object var paint = new Android.Graphics.Paint(); paint.AntiAlias = true; paint.SetStyle(Android.Graphics.Paint.Style.Stroke); paint.StrokeWidth = strokeWidth; paint.Color = StrokeColor; // Stroke background var background = new Android.Graphics.RectF(); background.Left = triangleWidth; background.Top = halfStrokeWidth; background.Right = popupWidth - strokeWidth; background.Bottom = popupHeight - strokeWidth; canvas.DrawRect(background, paint); // Stroke triangle canvas.Save(); canvas.Translate(triangleOffsetX, triangleOffsetY); canvas.DrawPath(trianglePath, paint); canvas.Restore(); // Fill background paint.SetStyle(Android.Graphics.Paint.Style.Fill); paint.Color = BackgroundColor; canvas.DrawRect(background, paint); // Fill triangle canvas.Save(); canvas.Translate(triangleOffsetX, triangleOffsetY); canvas.DrawPath(trianglePath, paint); canvas.Restore(); if (textLayout != null) { // Draw text canvas.Save(); canvas.Translate(halfStrokeWidth + triangleWidth + PopupPadding, halfStrokeWidth + PopupPadding); textLayout.Draw(canvas); canvas.Restore(); } return(BitmapUtils.CreateBitmapFromAndroidBitmap(bitmap)); }
public void SetDaggerfallPopupStyle(PopupStyle style, Panel panel) { // Do nothing if DaggerfallUnity path not valid if (!DaggerfallUnity.Instance.IsPathValidated) return; panel.BackgroundTexture = null; panel.BackgroundColor = Color.clear; if (style == PopupStyle.Parchment) { LoadDaggerfallParchmentTextures(); panel.SetBorderTextures( daggerfallParchmentTextures[0], daggerfallParchmentTextures[1], daggerfallParchmentTextures[2], daggerfallParchmentTextures[3], daggerfallParchmentTextures[4], daggerfallParchmentTextures[5], daggerfallParchmentTextures[6], daggerfallParchmentTextures[7], daggerfallParchmentTextures[8], globalFilterMode); } panel.SetMargins(Margins.All, 16); }
public override Bitmap OnDrawPopup(PopupDrawInfo popupDrawInfo) { string text = "Custom Popup"; PopupStyle style = popupDrawInfo.Popup.Style; // Calculate scaled dimensions float DPToPX = popupDrawInfo.DPToPX; float PXTODP = 1 / DPToPX; if (style.ScaleWithDPI) { DPToPX = 1; } else { PXTODP = 1; } float screenWidth = popupDrawInfo.ScreenBounds.GetWidth() * PXTODP; float screenHeight = popupDrawInfo.ScreenBounds.GetHeight() * PXTODP; // Update sizes based on scale (uses extension method, cf. Shared/Extensions int fontSize = FontSize.Update(DPToPX); int triangleWidth = TriangleSize.Update(DPToPX); int triangleHeight = TriangleSize.Update(DPToPX); int strokeWidth = StrokeWidth.Update(DPToPX); int screenPadding = ScreenPadding.Update(DPToPX); UIFont font = UIFont.FromName("HelveticaNeue-Light", fontSize); // Calculate the maximum popup size, adjust with dpi float maxPopupWidth = Math.Min(screenWidth, screenHeight); // Calculate maximum text and description width float halfStrokeWidth = strokeWidth * 0.5f; float maxTextWidth = maxPopupWidth - (2 * screenPadding + strokeWidth); CGSize textSize = text.StringSize(font, new CGSize(maxTextWidth, nfloat.MaxValue)); // Calculate bitmap size nfloat popupWidth = textSize.Width + 2 * PopupPadding + strokeWidth + triangleWidth; nfloat popupHeight = textSize.Height + 2 * PopupPadding + strokeWidth; CGSize popupSize = new CGSize(popupWidth, popupHeight); // Create graphics context; UIGraphics.BeginImageContext(popupSize); CGContext context = UIGraphics.GetCurrentContext(); CGRect backgroundStrokeRect = new CGRect( triangleWidth, halfStrokeWidth, popupWidth - (strokeWidth + triangleWidth), popupHeight - strokeWidth ); UIBezierPath backgroundPath = UIBezierPath.FromRoundedRect(backgroundStrokeRect, 1); backgroundPath.LineWidth = strokeWidth; // Prepare triangle path CGPath trianglePath = new CGPath(); trianglePath.MoveToPoint(triangleWidth, 0); trianglePath.AddLineToPoint(halfStrokeWidth, triangleHeight * 0.5f); trianglePath.AddLineToPoint(triangleWidth, triangleHeight); trianglePath.CloseSubpath(); // Calculate anchor point and triangle position nfloat triangleOffsetX = 0; nfloat triangleOffsetY = (popupHeight - triangleHeight) / 2; // Stroke background StrokeColor.SetStroke(); backgroundPath.Stroke(); // Stroke triangle context.SaveState(); context.TranslateCTM(triangleOffsetX, triangleOffsetY); context.SetLineWidth(strokeWidth); context.AddPath(trianglePath); context.SetStrokeColor(StrokeColor.CGColor); context.StrokePath(); context.RestoreState(); // Fill background BackgroundColor.SetFill(); backgroundPath.Fill(); // Fill triangle context.SaveState(); context.TranslateCTM(triangleOffsetX, triangleOffsetY); context.AddPath(trianglePath); context.SetFillColor(BackgroundColor.CGColor); context.FillPath(); context.RestoreState(); // Draw text context.SetFillColor(TextColor.CGColor); CGRect textRect = new CGRect( halfStrokeWidth + PopupPadding + triangleWidth, PopupPadding, textSize.Width, textSize.Height ); text.DrawString(textRect, font, UILineBreakMode.WordWrap); // Extract image UIImage image = UIGraphics.GetImageFromCurrentImageContext(); // Clean up UIGraphics.EndImageContext(); return(BitmapUtils.CreateBitmapFromUIImage(image)); }
public void Activate() { Window window = Window.Instance; root = new View() { Size2D = new Size2D(1920, 1080), BackgroundColor = Color.White, }; window.Add(root); ///////////////////////////////////////////////Create by Property////////////////////////////////////////////////////////// createText[0] = new TextLabel(); createText[0].Text = "Create Popup just by properties"; createText[0].Size2D = new Size2D(500, 100); createText[0].Position2D = new Position2D(500, 50); root.Add(createText[0]); popup = new Popup(); popup.MinimumSize = new Size2D(1032, 184); popup.Size = new Size(1032, 400); popup.Position = new Position(200, 100); // Title popup.Style.Title.PointSize = 25; popup.Style.Title.SizeHeight = 68; popup.Style.Title.HorizontalAlignment = HorizontalAlignment.Begin; popup.Style.Title.Position = new Position(64, 52); popup.Style.Title.Text = "Popup Title"; // Shadow popup.Style.ImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png", Border = new Rectangle(24, 24, 24, 24), Offset = new Vector2(-24, -24), // TODO We do not have shadow extents now, so replace it to scale value Scale = new Vector2(1080f / 1032f, 448f / 400f), }; // Background popup.BackgroundImage = CommonResource.GetFHResourcePath() + "11. Popup/popup_background.png"; popup.BackgroundImageBorder = new Rectangle(0, 0, 81, 81); // Buttons popup.AddButton("Yes"); popup.AddButton("Exit"); popup.ButtonBackground = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png"; popup.ButtonBackgroundBorder = new Rectangle(5, 5, 5, 5); popup.ButtonOverLayBackgroundColorSelector = new Selector <Color> { Normal = new Color(1.0f, 1.0f, 1.0f, 1.0f), Pressed = new Color(0.0f, 0.0f, 0.0f, 0.1f), Selected = new Color(1.0f, 1.0f, 1.0f, 1.0f), }; popup.ButtonImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png", Border = new Rectangle(5, 5, 5, 5) }; popup.ButtonTextColor = color[0]; popup.ButtonHeight = 132; popup.PopupButtonClickEvent += PopupButtonClickedEvent; popup.LayoutDirectionChanged += PopupLayoutDirectionChanged; popup.Post(window); contentText = new TextLabel(); contentText.Size2D = new Size2D(904, 100); contentText.PointSize = 20; contentText.HorizontalAlignment = HorizontalAlignment.Begin; contentText.VerticalAlignment = VerticalAlignment.Center; contentText.Text = "Popup ButtonStyle is " + buttonStyles[index]; contentText.TextColor = new Color(0, 0, 222, 1); popup.AddContentText(contentText); ///////////////////////////////////////////////Create by Attributes////////////////////////////////////////////////////////// createText[1] = new TextLabel(); createText[1].Text = "Create Popup just by Attributes"; createText[1].Size2D = new Size2D(500, 100); createText[1].Position2D = new Position2D(500, 550); root.Add(createText[1]); PopupStyle attrs = new PopupStyle { MinimumSize = new Size2D(1032, 184), BackgroundImage = new Selector <string> { All = CommonResource.GetFHResourcePath() + "11. Popup/popup_background.png" }, BackgroundImageBorder = new Selector <Rectangle> { All = new Rectangle(0, 0, 81, 81) }, ImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "11. Popup/popup_background_shadow.png", Border = new Rectangle(24, 24, 24, 24), Offset = new Vector2(-24, -24), // TODO We do not have shadow extents now, so replace it to scale value Scale = new Vector2(1080f / 1032f, 448f / 400f), }, Title = new TextLabelStyle { PointSize = new Selector <float?> { All = 25 }, TextColor = new Selector <Color> { All = Color.Black }, Size = new Size(0, 68), PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, PivotPoint = Tizen.NUI.PivotPoint.TopLeft, HorizontalAlignment = HorizontalAlignment.Begin, VerticalAlignment = VerticalAlignment.Bottom, Position = new Position(64, 52), Text = new Selector <string> { All = "Popup Title" }, }, Buttons = new ButtonStyle { PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft, PivotPoint = Tizen.NUI.PivotPoint.BottomLeft, BackgroundImage = new Selector <string> { All = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png" }, BackgroundImageBorder = new Selector <Rectangle> { All = new Rectangle(5, 5, 5, 5) }, ImageShadow = new ImageShadow { Url = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_shadow.png", Border = new Rectangle(5, 5, 5, 5), }, Overlay = new ImageViewStyle { PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent, BackgroundColor = new Selector <Color> { Normal = new Color(1.0f, 1.0f, 1.0f, 1.0f), Pressed = new Color(0.0f, 0.0f, 0.0f, 0.1f), Selected = new Color(1.0f, 1.0f, 1.0f, 1.0f), } }, Text = new TextLabelStyle { PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, TextColor = new Selector <Color> { All = color[index2] }, }, }, }; popup2 = new Popup(attrs); popup2.Size = new Size(1032, 400); popup2.Position = new Position(200, 600); popup2.AddButton("Yes"); popup2.AddButton("Exit"); popup2.ButtonHeight = 132; popup2.PopupButtonClickEvent += PopupButtonClickedEvent; popup2.LayoutDirectionChanged += Popup2LayoutDirectionChanged; popup2.Post(window); contentText2 = new TextLabel(); contentText2.Size2D = new Size2D(904, 100); contentText2.PointSize = 20; contentText2.HorizontalAlignment = HorizontalAlignment.Begin; contentText2.VerticalAlignment = VerticalAlignment.Center; contentText2.Text = "Popup2 ButtonStyle is " + buttonStyles[index]; popup2.ContentView.Add(contentText2); button = new Button(); button.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png"; button.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5); button.Size2D = new Size2D(580, 80); button.Position2D = new Position2D(1300, 500); button.Style.Text.Text = "LayoutDirection is left to right"; button.ClickEvent += ButtonClickEvent; root.Add(button); }
protected override Style CreateControlStyle() { var style = new PopupStyle(ViewState, this); return(style); }
private void showPopup(string text, PopupStyle style, Sprite image) { // pause the game Time.timeScale = 0f; foreach (var pair in buttons) { pair.Value.SetActive(pair.Key == style); } popupPanel.SetActive(true); Text t = popupPanel.GetComponentInChildren<Text>(); Debug.Assert(t != null, "text is null!"); t.text = text; popupPanel.transform.FindChild("EventImage").GetComponent<Image>().overrideSprite = image; }