2 * Copyright (c) 2017 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using TVMediaHub.Tizen.Utils;
19 using TVMediaHub.Tizen.ViewModels;
22 namespace TVMediaHub.Tizen.Views
25 /// A custom ContentPage for displaying the music player
27 public partial class MusicPlayer : RelativeLayout
29 private bool IsInitailized;
30 private Rectangle ShadowImageFocusedBounds;
31 private Rectangle ShadowImageNormalBounds;
33 private Rectangle AlbumImageFocusedBounds;
34 private Rectangle AlbumImageNormalBounds;
36 private Rectangle PausePlayButtonBounds;
38 private Rectangle TitleBounds;
39 private Rectangle ArtistBounds;
40 private Rectangle AlbumNameBounds;
43 /// Gets FocusArea for focus chain
45 public Button GetFocusArea()
47 return MusicPlayerFocusArea;
55 BindingContext = MusicPlayerViewModelLocator.ViewModel;
56 IsInitailized = false;
57 InitializeComponent();
61 private void MusicPlayerFocusAreaFocused(object sender, FocusEventArgs e)
63 MusicPlayerShadowImage.LayoutTo(ShadowImageFocusedBounds);
64 MusicPlayerAlbumArt.LayoutTo(AlbumImageFocusedBounds);
67 private void MusicPlayerFocusAreaUnfocused(object sender, FocusEventArgs e)
69 MusicPlayerShadowImage.LayoutTo(ShadowImageNormalBounds);
70 MusicPlayerAlbumArt.LayoutTo(AlbumImageNormalBounds);
73 private void InitializeSize()
75 WidthRequest = SizeUtils.GetWidthSize(546);
76 HeightRequest = SizeUtils.GetHeightSize(546);
77 Margin = new Thickness(SizeUtils.GetWidthSize(-14), SizeUtils.GetHeightSize(-14), 0, 0);
80 MusicPlayerShadowImage.BorderTop = SizeUtils.GetHeightSize(67);
81 MusicPlayerShadowImage.BorderBottom = SizeUtils.GetHeightSize(67);
82 MusicPlayerShadowImage.BorderLeft = SizeUtils.GetWidthSize(67);
83 MusicPlayerShadowImage.BorderRight = SizeUtils.GetWidthSize(67);
85 ShadowImageFocusedBounds = new Rectangle(0, 0, SizeUtils.GetWidthSize(546), SizeUtils.GetHeightSize(546));
86 ShadowImageNormalBounds = new Rectangle(SizeUtils.GetWidthSize(6), SizeUtils.GetHeightSize(6), SizeUtils.GetWidthSize(532), SizeUtils.GetHeightSize(532));
88 AlbumImageFocusedBounds = new Rectangle(SizeUtils.GetWidthSize(64), SizeUtils.GetHeightSize(64), SizeUtils.GetWidthSize(418), SizeUtils.GetHeightSize(418));
89 AlbumImageNormalBounds = new Rectangle(SizeUtils.GetWidthSize(70), SizeUtils.GetHeightSize(70), SizeUtils.GetWidthSize(406), SizeUtils.GetHeightSize(406));
91 PausePlayButtonBounds = new Rectangle(SizeUtils.GetWidthSize(223), SizeUtils.GetHeightSize(223), SizeUtils.GetWidthSize(100), SizeUtils.GetHeightSize(100));
93 TitleBounds = new Rectangle(SizeUtils.GetWidthSize(72), SizeUtils.GetHeightSize(498), SizeUtils.GetWidthSize(406), SizeUtils.GetHeightSize(32));
94 ArtistBounds = new Rectangle(SizeUtils.GetWidthSize(72), SizeUtils.GetHeightSize(542), SizeUtils.GetWidthSize(418), SizeUtils.GetHeightSize(28));
95 AlbumNameBounds = new Rectangle(SizeUtils.GetWidthSize(72), SizeUtils.GetHeightSize(572), SizeUtils.GetWidthSize(418), SizeUtils.GetHeightSize(28));
97 MusicPlayerTitle.FontSize = SizeUtils.GetFontSize(28);
99 MusicPlayerArtist.FontSize = SizeUtils.GetFontSize(24);
100 MusicPlayerArtist.Opacity = 0.5;
102 MusicPlayerAlbum.FontSize = SizeUtils.GetFontSize(24);
103 MusicPlayerAlbum.Opacity = 0.25;
106 protected override void LayoutChildren(double x, double y, double width, double height)
108 if (IsInitailized == false)
110 base.LayoutChildren(x, y, width, height);
111 MusicPlayerAlbumArt.Layout(AlbumImageNormalBounds);
112 MusicPlayerTitle.Layout(TitleBounds);
113 MusicPlayerArtist.Layout(ArtistBounds);
114 MusicPlayerAlbum.Layout(AlbumNameBounds);
115 MusicPlayerShadowImage.Layout(ShadowImageNormalBounds);
116 MusicPlayerPausePlayButton.Layout(PausePlayButtonBounds);
117 MusicPlayerFocusArea.Layout(PausePlayButtonBounds);
118 IsInitailized = true;