private void MainPage_SizeChanged(object sender, EventArgs e) { _storyboard = new Storyboard(); var width = this.Width; var height = this.Height; // shopping cart Rectangle basketRect = new Rectangle( x: width - (BasketIcon.Width + margin), y: margin, width: BasketIcon.Width, height: BasketIcon.Height ); AbsoluteLayout.SetLayoutBounds(BasketIcon, basketRect); // search icon Rectangle searchRect = new Rectangle( x: margin, y: 200, width: SearchIcon.Width, height: SearchIcon.Height ); AbsoluteLayout.SetLayoutBounds(SearchIcon, searchRect); Rectangle searchRectCollapsed = new Rectangle( x: BasketIcon.Bounds.Left - (margin + SettingsIcon.Width + margin + SearchIcon.Width), y: margin, width: SearchIcon.Width, height: SearchIcon.Height ); // settings icon Rectangle settingsRect = new Rectangle( x: width - (SettingsIcon.Width + margin), y: 200, width: SettingsIcon.Width, height: SettingsIcon.Height ); AbsoluteLayout.SetLayoutBounds(SettingsIcon, settingsRect); Rectangle settingsRectCollapsed = new Rectangle( x: BasketIcon.Bounds.Left - (margin + SettingsIcon.Width), y: margin, width: SettingsIcon.Width, height: SettingsIcon.Height ); Rectangle searchBackgroundRect = new Rectangle( x: margin, y: 200, width: SettingsIcon.Bounds.X - (margin + margin), height: SearchBackground.Height ); AbsoluteLayout.SetLayoutBounds(SearchBackground, searchBackgroundRect); Rectangle searchBackgroundCollapsedRect = new Rectangle( x: BasketIcon.Bounds.Left - (margin + SettingsIcon.Width + margin + SearchIcon.Width), y: margin, width: SettingsIcon.Width, height: SettingsIcon.Height ); // ScrollContainer Rectangle scrollContainerRect = new Rectangle( x: margin, y: SearchIcon.Bounds.Bottom + margin, width: width - (2 * margin), height: height - (SearchIcon.Bounds.Bottom + margin) ); AbsoluteLayout.SetLayoutBounds(ScrollContainer, scrollContainerRect); Rectangle scrollContainerRectCollapsed = new Rectangle( x: margin, y: margin + BasketIcon.Height + margin, width: width - (2 * margin), height: height - (margin + BasketIcon.Height + margin) ); // add the positions to the state machine _storyboard.Add(States.SearchExpanded, new[] { new ViewTransition(Header, AnimationType.Opacity, 1, animationSpeed), new ViewTransition(SearchEntry, AnimationType.Opacity, 1, animationSpeed), new ViewTransition(SettingsIcon, AnimationType.Layout, settingsRect, animationSpeed), new ViewTransition(SearchIcon, AnimationType.Layout, searchRect, animationSpeed), new ViewTransition(SearchBackground, AnimationType.Layout, searchBackgroundRect, animationSpeed), new ViewTransition(ScrollContainer, AnimationType.Layout, scrollContainerRect, animationSpeed) }); _storyboard.Add(States.SearchHidden, new[] { new ViewTransition(Header, AnimationType.Opacity, 0.01, 50), new ViewTransition(SearchEntry, AnimationType.Opacity, 0.01, 50), new ViewTransition(SettingsIcon, AnimationType.Layout, settingsRectCollapsed, animationSpeed), new ViewTransition(SearchIcon, AnimationType.Layout, searchRectCollapsed, animationSpeed), new ViewTransition(SearchBackground, AnimationType.Layout, searchBackgroundCollapsedRect, animationSpeed), new ViewTransition(ScrollContainer, AnimationType.Layout, scrollContainerRectCollapsed, animationSpeed) }); }
private void MainPage_SizeChanged(object sender, EventArgs e) { _storyboard = new Storyboard(); var width = this.Width; var height = this.Height; //購物車 Rectangle baskedRect = new Rectangle( x: width - (icon購物.Width + margin), y: margin, width: icon購物.Width, height: icon購物.Height); AbsoluteLayout.SetLayoutBounds(icon購物, baskedRect); #region 查詢區塊 Rectangle searchRect = new Rectangle( x: margin, y: 200, width: icon查詢.Width, height: icon查詢.Height); AbsoluteLayout.SetLayoutBounds(icon查詢, searchRect); Rectangle searchBackGroundRect = new Rectangle( x: margin, y: 200, width: icon設定.Bounds.X - (margin + margin), height: boxView查詢.Height); AbsoluteLayout.SetLayoutBounds(boxView查詢, searchBackGroundRect); Rectangle searchRectCollapsed = new Rectangle( x: icon購物.Bounds.Left - (margin + icon設定.Width + margin + icon查詢.Width), y: margin, width: icon查詢.Width, height: icon查詢.Height); Rectangle searchBackGroundCollapsed = new Rectangle( x: icon購物.Bounds.Left - (margin + icon設定.Width + margin + icon查詢.Width), y: margin, width: icon設定.Width, height: icon設定.Height); #endregion #region 設定區塊 Rectangle settingRect = new Rectangle( x: this.Width - (icon設定.Width + margin), y: 200, width: icon設定.Width, height: icon設定.Height); AbsoluteLayout.SetLayoutBounds(icon設定, settingRect); Rectangle settingRectCollapsed = new Rectangle( x: icon購物.Bounds.Left - (margin + icon設定.Width), y: margin, width: icon設定.Width, height: icon設定.Height); #endregion //可捲動的區塊 Rectangle scrollContainerRect = new Rectangle( x: margin, y: icon查詢.Bounds.Bottom + margin, width: width - (2 * margin), height: height - (icon查詢.Bounds.Bottom + margin)); AbsoluteLayout.SetLayoutBounds(scrollContainer, scrollContainerRect); Rectangle scrollContainerRectCollapsed = new Rectangle( x: margin, y: margin + icon購物.Height + margin, width: width - (2 * margin), height: height - (margin + icon購物.Height + margin)); AbsoluteLayout.SetLayoutBounds(scrollContainer, scrollContainerRect); //方塊的排序 //if (width > height) // flexLayoutProducts.Direction = FlexDirection.Row; //else // flexLayoutProducts.Direction = FlexDirection.Column; //設定畫面元件定位 _storyboard.Add(States.SearchExpanded, new[] { new ViewTransition(Header, AnimationType.Opacity, 1), new ViewTransition(SearchEntry, AnimationType.Opacity, 1), new ViewTransition(icon設定, AnimationType.Layout, settingRect), new ViewTransition(icon查詢, AnimationType.Layout, searchRect), new ViewTransition(boxView查詢, AnimationType.Layout, searchBackGroundRect), new ViewTransition(scrollContainer, AnimationType.Layout, scrollContainerRect) }); _storyboard.Add(States.SearchHidden, new[] { new ViewTransition(Header, AnimationType.Opacity, 0.01), new ViewTransition(SearchEntry, AnimationType.Opacity, 0.01), new ViewTransition(icon設定, AnimationType.Layout, settingRectCollapsed), new ViewTransition(icon查詢, AnimationType.Layout, searchRectCollapsed), new ViewTransition(boxView查詢, AnimationType.Layout, searchBackGroundCollapsed), new ViewTransition(scrollContainer, AnimationType.Layout, scrollContainerRectCollapsed) }); }