public void Initialize() { Window window = Window.Instance; window.BackgroundColor = Color.White; // Create a container to layout the rows of image and rating vertically FlexContainer container = new FlexContainer(); container.ParentOrigin = ParentOrigin.TopLeft; container.PivotPoint = PivotPoint.TopLeft; container.FlexDirection = (int)FlexContainer.FlexDirectionType.Column; container.WidthResizePolicy = ResizePolicyType.FillToParent; container.HeightResizePolicy = ResizePolicyType.FillToParent; window.Add(container); Random random = new Random(); for (int i = 0; i < 6; i++) // 6 rows in total { // Create a container to layout the image and rating (in each row) horizontally FlexContainer imageRow = new FlexContainer(); imageRow.ParentOrigin = ParentOrigin.TopLeft; imageRow.PivotPoint = PivotPoint.TopLeft; imageRow.FlexDirection = FlexContainer.FlexDirectionType.Row; imageRow.Flex = 1.0f; container.Add(imageRow); // Add the image view to the row ImageView image = new ImageView(resources + "/images/gallery-" + i + ".jpg"); image.Size2D = new Size2D(120, 120); image.WidthResizePolicy = ResizePolicyType.Fixed; image.HeightResizePolicy = ResizePolicyType.Fixed; image.AlignSelf = (int)FlexContainer.Alignment.AlignCenter; image.Flex = 0.3f; image.FlexMargin = new Vector4(10.0f, 0.0f, 0.0f, 0.0f); imageRow.Add(image); // Create a rating control StarRating view = new StarRating(); // Add the rating control to the row view.ParentOrigin = ParentOrigin.Center; view.PivotPoint = PivotPoint.Center; view.Size2D = new Size2D(200, 40); view.Flex = 0.7f; view.AlignSelf = (int)FlexContainer.Alignment.AlignCenter; view.FlexMargin = new Vector4(30.0f, 0.0f, 0.0f, 0.0f); imageRow.Add(view); // Set the initial rating randomly between 1 and 5 view.Rating = random.Next(1, 6); } }
public override void OnInitialize() { // Create a container for the star images _container = new FlexContainer(); _container.FlexDirection = FlexContainer.FlexDirectionType.Row; _container.WidthResizePolicy = ResizePolicyType.FillToParent; _container.HeightResizePolicy = ResizePolicyType.FillToParent; this.Add(_container); // Create the images _images = new ImageView[5]; for (int i = 0; i < 5; i++) { _images[i] = new ImageView(resources + "/images/star-dim.png"); _container.Add(_images[i]); } // Update the images according to the rating (dimmed star by default) _myRating = 0; UpdateStartImages(_myRating); // Enable pan gesture detection EnableGestureDetection(Gesture.GestureType.Pan); _myDragEnabled = true; // Allow dragging by default (can be disabled) }
public override void Create() { Window window = Window.Instance; View01 = new View() { BackgroundColor = Color.Green, Position2D = new Position2D(0, window.Size.Height / 8), Size2D = new Size2D(window.Size.Width / 2, (window.Size.Height / 8) * 7), Name = "View01" }; window.Add(View01); View02 = new View() { Position2D = new Position2D(window.Size.Width / 2, window.Size.Height / 8), WidthSpecification = (window.Size.Width / 2), HeightSpecification = (window.Size.Height / 8) * 7, BackgroundColor = Color.Blue, Layout = new LinearLayout(), Name = "View02LinearView", }; window.Add(View02); View03 = new View() { BackgroundColor = Color.Yellow, Name = "View03", Size2D = new Size2D(20, (window.Size.Height / 8) * 7) }; View01.Add(View03); LinearLayout verticalLayout = new LinearLayout(); verticalLayout.LinearOrientation = LinearLayout.Orientation.Vertical; View04 = new View() { BackgroundColor = Color.Cyan, PositionX = View03.Size2D.Width, WidthSpecification = LayoutParamPolicies.WrapContent, HeightSpecification = LayoutParamPolicies.MatchParent, Layout = verticalLayout, Name = "View04LinearView", }; View01.Add(View04); View07 = new View() { BackgroundColor = Color.Blue, Size2D = new Size2D(200, 200), Name = "View07" }; View03.Add(View07); ImageView06 = LayoutingExample.CreateChildImageView("res/images/application-icon-101.png", new Size2D(100, 100)); ImageView06.Name = "imageView-06"; View04.Add(ImageView06); ImageView04 = LayoutingExample.CreateChildImageView("res/images/application-icon-101.png", new Size2D(200, 200)); ImageView04.Name = "imageView-04"; View07.Add(ImageView04); View08 = new View() { BackgroundColor = Color.Magenta, Size2D = new Size2D(280, 280), Name = "View08" }; View04.Add(View08); ImageView03 = LayoutingExample.CreateChildImageView("res/images/application-icon-101.png", new Size2D(100, 100)); ImageView03.Name = "imageView-03"; View08.Add(ImageView03); View05 = new View() { BackgroundColor = Color.Yellow, Name = "View05", Size2D = new Size2D(10, 100) }; View02.Add(View05); FlexContainer legacyContainer = new FlexContainer(); legacyContainer.FlexDirection = FlexContainer.FlexDirectionType.Column; legacyContainer.Size2D = new Size2D(View02.Size2D.Width / 2, 280); legacyContainer.Name = "legacyFlexContainer"; View02.Add(legacyContainer); ImageView02 = LayoutingExample.CreateChildImageView("res/images/application-icon-103.png", new Size2D(100, 100)); ImageView02.Name = "imageView-02"; legacyContainer.Add(ImageView02); ImageView01 = LayoutingExample.CreateChildImageView("res/images/application-icon-104.png", new Size2D(100, 100)); ImageView01.Name = "imageView-01"; legacyContainer.Add(ImageView01); ImageView05 = LayoutingExample.CreateChildImageView("res/images/application-icon-102.png", new Size2D(100, 100)); ImageView05.Name = "imageView-05"; View05.Add(ImageView05); CreateHelpButton(); LayoutingExample.GetToolbar().Add(helpButton); }
/// <summary> /// Flex Container Sample Application initialisation. /// </summary> public void Initialize() { Window.Instance.BackgroundColor = new Color(0.8f, 0.8f, 0.8f, 1.0f); // Create FlexContainer flexContainer = new FlexContainer(); flexContainer.PositionUsesPivotPoint = true; flexContainer.PivotPoint = PivotPoint.TopLeft; flexContainer.ParentOrigin = ParentOrigin.TopLeft; flexContainer.Position = new Position(220, 160, 0); flexContainer.SizeWidth = 700; flexContainer.SizeHeight = 700; flexContainer.BackgroundColor = Color.Yellow; flexContainer.FlexDirection = FlexContainer.FlexDirectionType.Column; Window.Instance.GetDefaultLayer().Add(flexContainer); // Create flex items and add them to the container for (int i = 0; i < NUM_FLEX_ITEMS; i++) { TextLabel flexItem = new TextLabel(); flexItem.PositionUsesPivotPoint = true; flexItem.PivotPoint = PivotPoint.TopLeft; flexItem.ParentOrigin = ParentOrigin.TopLeft; // Set different background colour to help to identify different items flexItem.BackgroundColor = new Vector4(((float)i) / NUM_FLEX_ITEMS, ((float)(NUM_FLEX_ITEMS - i)) / NUM_FLEX_ITEMS, 1.0f, 1.0f); flexItem.Text = i + ""; flexItem.Name = i + ""; flexItem.HorizontalAlignment = HorizontalAlignment.Center; flexItem.VerticalAlignment = VerticalAlignment.Center; // Set a fixed size to the items so that we can wrap the line and test these // flex properties that only work when there are multiple lines in the layout flexItem.WidthResizePolicy = ResizePolicyType.Fixed; flexItem.HeightResizePolicy = ResizePolicyType.Fixed; // Make sure there are still extra space in the line after wrapping flexItem.SizeWidth = flexContainer.SizeWidth / NUM_FLEX_ITEMS * 1.25f; flexItem.SizeHeight = flexContainer.SizeHeight / NUM_FLEX_ITEMS * 1.25f; flexContainer.Add(flexItem); } // Create the tableView which is the parent of the Pushbuttons // which can change the flexcontainer's properties tableView = new TableView(6, 1); tableView.SizeWidth = 500; tableView.SizeHeight = 400; tableView.CellPadding = new Vector2(5, 5); tableView.PositionUsesPivotPoint = true; tableView.PivotPoint = PivotPoint.BottomRight; tableView.ParentOrigin = ParentOrigin.BottomRight; tableView.Position = new Position(-100, -100, 0); Window.Instance.GetDefaultLayer().Add(tableView); // Create the pushbutton which can change the property of ContentDirection. // The default value of flexcontainer's ContentDirection // is FlexContainer.ContentDirectionType.Inherit. PushButton button0 = new PushButton(); button0.Name = "ContentDirection"; button0.Label = CreateText("ContentDirection : Inherit"); button0.SizeWidth = tableView.SizeWidth; button0.Focusable = true; button0.Clicked += ButtonClick; tableView.AddChild(button0, new TableView.CellPosition(0, 0)); // Create the pushbutton which can change the property of FlexDirection. // The current value of flexcontainer's FlexDirection // is FlexContainer.ContentDirectionType.Column PushButton button1 = new PushButton(); button1.Name = "FlexDirection"; button1.Label = CreateText("FlexDirection : Column"); button1.SizeWidth = tableView.SizeWidth; button1.Clicked += ButtonClick; tableView.AddChild(button1, new TableView.CellPosition(1, 0)); // Create the pushbutton which can change the property of FlexWrap // The current value of flexcontainer's FlexWrap // is FlexContainer.WrapType.NoWrap PushButton button2 = new PushButton(); button2.Name = "FlexWrap"; button2.Label = CreateText("FlexWrap : NoWrap"); button2.SizeWidth = tableView.SizeWidth; button2.Clicked += ButtonClick; tableView.AddChild(button2, new TableView.CellPosition(2, 0)); // Create the pushbutton which can change the property of JustifyContent // The current value of flexcontainer's JustifyContent // is FlexContainer.Justification.JustifyFlexStart PushButton button3 = new PushButton(); button3.Name = "JustifyContent"; button3.Label = CreateText("JustifyContent : JustifyFlexStart"); button3.SizeWidth = tableView.SizeWidth; button3.Clicked += ButtonClick; tableView.AddChild(button3, new TableView.CellPosition(3, 0)); // Create the pushbutton which can change the property of AlignItems // The current value of flexcontainer's AlignItems // is FlexContainer.Alignment.AlignStretch PushButton button4 = new PushButton(); button4.Name = "AlignItems"; button4.Label = CreateText("AlignItems : AlignStretch"); button4.SizeWidth = tableView.SizeWidth; button4.Clicked += ButtonClick; tableView.AddChild(button4, new TableView.CellPosition(4, 0)); // Create the pushbutton which can change the property of AlignContent // The current value of flexcontainer's AlignContent // is FlexContainer.Alignment.AlignFlexStart PushButton button5 = new PushButton(); button5.Name = "AlignContent"; button5.Label = CreateText("AlignContent : AlignFlexStart"); button5.SizeWidth = tableView.SizeWidth; button5.Clicked += ButtonClick; tableView.AddChild(button5, new TableView.CellPosition(5, 0)); FocusManager.Instance.SetCurrentFocusView(button0); Window.Instance.KeyEvent += AppBack; }
/// <summary> /// Flex Container Sample Application initialisation. /// </summary> public void Initialize() { Window.Instance.BackgroundColor = Color.Black; View focusIndicator = new View(); FocusManager.Instance.FocusIndicator = focusIndicator; //Create a title, and add it to window guide = new TextLabel(); guide.HorizontalAlignment = HorizontalAlignment.Center; guide.VerticalAlignment = VerticalAlignment.Center; guide.PositionUsesPivotPoint = true; guide.ParentOrigin = ParentOrigin.TopLeft; guide.PivotPoint = PivotPoint.TopLeft; guide.Size2D = new Size2D(1920, 96); guide.FontFamily = "Samsung One 600"; guide.Position2D = new Position2D(0, 94); guide.MultiLine = false; //guide.PointSize = 15.0f; guide.PointSize = DeviceCheck.PointSize15; guide.Text = "FlexContainer Sample \n"; guide.TextColor = Color.White; //guide.BackgroundColor = new Color(43.0f / 255.0f, 145.0f / 255.0f, 175.0f / 255.0f, 1.0f); Window.Instance.GetDefaultLayer().Add(guide); // Create FlexContainer flexContainer = new FlexContainer(); flexContainer.PositionUsesPivotPoint = true; flexContainer.PivotPoint = PivotPoint.TopLeft; flexContainer.ParentOrigin = ParentOrigin.TopLeft; flexContainer.Position = new Position(710, 275, 0); flexContainer.SizeWidth = 400; flexContainer.SizeHeight = 400; flexContainer.BackgroundColor = Color.White; flexContainer.FlexDirection = FlexContainer.FlexDirectionType.Column; Window.Instance.GetDefaultLayer().Add(flexContainer); // Create flex items and add them to the container for (int i = 0; i < NUM_FLEX_ITEMS; i++) { TextLabel flexItem = new TextLabel(); flexItem.PositionUsesPivotPoint = true; flexItem.PivotPoint = PivotPoint.TopLeft; flexItem.ParentOrigin = ParentOrigin.TopLeft; // Set different background colour to help to identify different items flexItem.BackgroundColor = new Vector4(((float)i) / NUM_FLEX_ITEMS, ((float)(NUM_FLEX_ITEMS - i)) / NUM_FLEX_ITEMS, 1.0f, 1.0f); //flexItem.Text = i + ""; flexItem.Name = i + ""; flexItem.HorizontalAlignment = HorizontalAlignment.Center; flexItem.VerticalAlignment = VerticalAlignment.Center; // Set a fixed size to the items so that we can wrap the line and test these // flex properties that only work when there are multiple lines in the layout flexItem.WidthResizePolicy = ResizePolicyType.Fixed; flexItem.HeightResizePolicy = ResizePolicyType.Fixed; // Make sure there are still extra space in the line after wrapping flexItem.SizeWidth = flexContainer.SizeWidth / NUM_FLEX_ITEMS * 1.25f; flexItem.SizeHeight = flexContainer.SizeHeight / NUM_FLEX_ITEMS * 1.25f; flexContainer.Add(flexItem); } // Create the tableView which is the parent of the Pushbuttons // which can change the flexcontainer's properties tableView = new TableView(2, 3); tableView.Position2D = new Position2D(80, 880); tableView.SizeWidth = 1800; tableView.SizeHeight = 180; tableView.PivotPoint = PivotPoint.TopLeft; tableView.ParentOrigin = ParentOrigin.TopLeft; //tableView.CellPadding = new Vector2(15, 10); Window.Instance.GetDefaultLayer().Add(tableView); string[] btnName = { "ContentDirection", "FlexDirection", "FlexWrap", "JustifyContent", "AlignItems", "AlignContent" }; string[] btnLabel = { "ContentDirection : Inherit", "FlexDirection : Column", "FlexWrap : NoWrap", "JustifyContent : JustifyFlexStart", "AlignItems : AlignStretch", "AlignContent : AlignFlexStart" }; for (uint row = 0; row < 2; row++) { for (uint column = 0; column < 3; column++) { PushButton button = CreateButton(btnName[row * 3 + column], btnLabel[row * 3 + column]); button.SizeWidth = 560; button.SizeHeight = 80; button.Focusable = true; button.Clicked += ButtonClick; tableView.AddChild(button, new TableView.CellPosition(row, column)); if (0 == row && column == 0) { FocusManager.Instance.SetCurrentFocusView(button); } buttonArray[row * 3 + column] = button; } } buttonArray[5].Opacity = 0.0f; Window.Instance.KeyEvent += AppBack; }
protected override void OnCreate() { base.OnCreate(); Window.Instance.BackgroundColor = new Color(0.1f, 0.8f, 0.1f, 1.0f); container = new FlexContainer(); container.Size2D = new Size2D(Window.Instance.Size.Width, Window.Instance.Size.Height); container.PivotPoint = PivotPoint.TopLeft; container.Padding = new Vector4(100, 100, 100, 100); container.FlexWrap = FlexContainer.WrapType.Wrap; container.FlexDirection = FlexContainer.FlexDirectionType.Column; Window.Instance.Add(container); numOfSamples = samples.GetLength(0); Tizen.Log.Debug("NUI", "NUM = " + numOfSamples); label = new TextLabel[numOfSamples]; for (int i = 0; i < numOfSamples; i++) { label[i] = new TextLabel(); label[i].Focusable = true; label[i].BackgroundColor = Color.Red; //label[i].Size = new Size(100, 50, 0); label[i].Text = samples[i]; label[i].FlexMargin = new Vector4(20, 20, 20, 20); label[i].PointSize = 10; label[i].Name = "label" + i.ToString(); container.Add(label[i]); } //label[3].SetKeyInputFocus(); //removed FocusManager.Instance.SetCurrentFocusView(label[3]); FocusManager.Instance.PreFocusChange += Instance_PreFocusChange; //added FocusManager.Instance.FocusChanged += (sender, e) => { if (e.CurrentView) { Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.CurrentView.Name=" + e.CurrentView.Name); } else { Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.CurrentView is null!"); } if (e.NextView) { Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.NextView.Name=" + e.NextView.Name); } else { Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.NextView is null!"); } }; //added FocusManager.Instance.FocusedViewActivated += (sender, e) => { if (e.View) { Tizen.Log.Debug("NUI", "FocusManager FocusedViewEnterKeyPressed signal callback! e.View.Name=" + e.View.Name); } else { Tizen.Log.Debug("NUI", "FocusManager FocusChanged signal callback! e.View is null!"); } }; //added Window.Instance.TouchEvent += (sender, e) => { Tizen.Log.Debug("NUI", "Window Touch signal callback! To avoid crash, when losing key focus, set here again unless the NextView is null"); FocusManager.Instance.SetCurrentFocusView(label[3]); }; //added pushButton1 = new PushButton(); pushButton1.MinimumSize = new Size2D(400, 200); pushButton1.LabelText = "+PreFocusChange"; pushButton1.ParentOrigin = ParentOrigin.TopLeft; pushButton1.PivotPoint = PivotPoint.TopLeft; pushButton1.Position2D = new Position2D(200, 800); pushButton1.Clicked += (sender, e) => { Tizen.Log.Debug("NUI", "pushbutton1 clicked! add handler!"); _cnt++; FocusManager.Instance.PreFocusChange += Instance_PreFocusChange; _ani.Finished += _ani_Finished; pushButton1.LabelText = "Add Handler" + _cnt; pushButton2.LabelText = "Remove Handler" + _cnt; return(true); }; Window.Instance.Add(pushButton1); pushButton2 = new PushButton(); pushButton2.MinimumSize = new Size2D(400, 200); pushButton2.LabelText = "-PreFocusChange"; pushButton2.ParentOrigin = ParentOrigin.TopLeft; pushButton2.PivotPoint = PivotPoint.TopLeft; pushButton2.Position2D = new Position2D(800, 800); pushButton2.Clicked += (sender, e) => { Tizen.Log.Debug("NUI", "pushbutton2 clicked! remove handler!"); _cnt--; FocusManager.Instance.PreFocusChange -= Instance_PreFocusChange; _ani.Finished -= _ani_Finished; pushButton1.LabelText = "Add Handler" + _cnt; pushButton2.LabelText = "Remove Handler" + _cnt; return(true); }; Window.Instance.Add(pushButton2); //added _ani = new Animation(2000); _ani.AnimateTo(pushButton1, "Opacity", 0.0f); _ani.AnimateTo(pushButton2, "Opacity", 0.0f); _ani.EndAction = Animation.EndActions.Discard; _ani.Finished += _ani_Finished; }
public void Initialize() { Window window = Window.Instance; window.BackgroundColor = Color.White; // Create a container for the spins _container = new FlexContainer(); _container.FlexDirection = FlexContainer.FlexDirectionType.Row; _container.Size2D = new Size2D(480, 150); window.Add(_container); // Create a Spin control for year _spinYear = new Spin(); _spinYear.Flex = 0.3f; _spinYear.FlexMargin = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); _container.Add(_spinYear); _spinYear.MinValue = 1900; _spinYear.MaxValue = 2100; _spinYear.Value = 2016; _spinYear.Step = 1; _spinYear.MaxTextLength = 4; _spinYear.TextPointSize = 15; _spinYear.TextColor = Color.Red; _spinYear.Focusable = (true); _spinYear.Name = "_spinYear"; // Create a Spin control for month _spinMonth = new Spin(); _spinMonth.Flex = 0.3f; _spinMonth.FlexMargin = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); _container.Add(_spinMonth); _spinMonth.MinValue = 1; _spinMonth.MaxValue = 12; _spinMonth.Value = 10; _spinMonth.Step = 1; _spinMonth.MaxTextLength = 2; _spinMonth.TextPointSize = 15; _spinMonth.TextColor = Color.Green; _spinMonth.Focusable = (true); _spinMonth.Name = "_spinMonth"; // Create a Spin control for day _spinDay = new Spin(); _spinDay.Flex = 0.3f; _spinDay.FlexMargin = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); _container.Add(_spinDay); _spinDay.MinValue = 1; _spinDay.MaxValue = 31; _spinDay.Value = 26; _spinDay.Step = 1; _spinDay.MaxTextLength = 2; _spinDay.TextPointSize = 15; _spinDay.TextColor = Color.Blue; _spinDay.Focusable = (true); _spinDay.Name = "_spinDay"; FocusManager keyboardFocusManager = FocusManager.Instance; keyboardFocusManager.PreFocusChange += OnKeyboardPreFocusChange; keyboardFocusManager.FocusedViewActivated += OnFocusedViewActivated; }