public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            focusGuide = new UIFocusGuide();
            View.AddLayoutGuide(focusGuide);

            focusGuide.LeftAnchor.ConstraintEqualTo(TopRightButton.LeftAnchor).Active = true;
            focusGuide.TopAnchor.ConstraintEqualTo(BottomLeftButton.TopAnchor).Active = true;

            // Anchor the width and height of the focus guide.
            focusGuide.WidthAnchor.ConstraintEqualTo(BottomLeftButton.WidthAnchor).Active   = true;
            focusGuide.HeightAnchor.ConstraintEqualTo(BottomLeftButton.HeightAnchor).Active = true;
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			focusGuide = new UIFocusGuide ();
			View.AddLayoutGuide (focusGuide);

			focusGuide.LeftAnchor.ConstraintEqualTo (TopRightButton.LeftAnchor).Active = true;
			focusGuide.TopAnchor.ConstraintEqualTo (BottomLeftButton.TopAnchor).Active = true;

			// Anchor the width and height of the focus guide.
			focusGuide.WidthAnchor.ConstraintEqualTo (BottomLeftButton.WidthAnchor).Active = true;
			focusGuide.HeightAnchor.ConstraintEqualTo (BottomLeftButton.HeightAnchor).Active = true;
		}
Exemplo n.º 3
0
        /// <summary>
        /// The view has loaded, now we can create any child views.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            BackgroundImageView = new UIImageView(new CGRect(0, 0, 1920, 1080));
            View.AddSubview(BackgroundImageView);

            MenuBarView = new Views.MenuBarView(new CGRect(0, 960, 1920, 120));
            MenuBarView.ButtonClicked += MenuBarView_ButtonClicked;
            View.AddSubview(MenuBarView);

            //
            // Setup the notification view controller.
            //
            NotificationViewController = new NotificationViewController();
            AddChildViewController(NotificationViewController);
            View.AddSubview(NotificationViewController.View);
            NotificationViewController.DidMoveToParentViewController(this);
            NotificationViewController.NotificationWasDismissed += (sender, arg) =>
            {
                View.SetNeedsFocusUpdate();

                Task.Run(async() =>
                {
                    //
                    // Slight pause to let the focus animations settle.
                    //
                    await Task.Delay(500);

                    InvokeOnMainThread(ShowNextNotification);
                });
            };
            NotificationViewController.FocusGuide.PreferredFocusEnvironments = new[] { MenuBarView };

            //
            // Setup the focus guide for when the users moves up from the menu bar.
            //
            var menuBarUpFocusGuide = new UIFocusGuide();

            View.AddLayoutGuide(menuBarUpFocusGuide);
            menuBarUpFocusGuide.LeftAnchor.ConstraintEqualTo(MenuBarView.LeftAnchor).Active    = true;
            menuBarUpFocusGuide.RightAnchor.ConstraintEqualTo(MenuBarView.RightAnchor).Active  = true;
            menuBarUpFocusGuide.TopAnchor.ConstraintEqualTo(MenuBarView.TopAnchor, -64).Active = true;
            menuBarUpFocusGuide.BottomAnchor.ConstraintEqualTo(MenuBarView.TopAnchor).Active   = true;
            menuBarUpFocusGuide.PreferredFocusEnvironments = new[] { NotificationViewController.View };
        }
        /// <summary>
        /// The view has loaded and is ready for final preparation.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //
            // Create the image view.
            //
            ImageView = new UIImageView(new CGRect(40, 40, 288, 162))
            {
                ContentMode = UIViewContentMode.ScaleAspectFit
            };
            View.AddSubview(ImageView);

            //
            // Create the message text area.
            //
            MessageLabel = new UILabel(new CGRect(368, 40, 1184, 162))
            {
                Lines         = 4,
                LineBreakMode = UILineBreakMode.TailTruncation,
                TextAlignment = UITextAlignment.Center,
                TextColor     = "#ffdddddd".AsUIColor(),
                Font          = UIFont.SystemFontOfSize(33)
            };
            View.AddSubview(MessageLabel);

            //
            // Create the dismiss button.
            //
            DismissButton = new MenuButton(new CGRect(1594, 136, 288, 64));
            DismissButton.SetTitle("Dismiss", UIControlState.Normal);
            DismissButton.PrimaryActionTriggered += DismissButton_PrimaryActionTriggered;
            View.AddSubview(DismissButton);

            //
            // Setup the focus guide for when the users moves down from dismiss
            // button.
            //
            FocusGuide = new UIFocusGuide();
            View.AddLayoutGuide(FocusGuide);
            FocusGuide.LeftAnchor.ConstraintEqualTo(DismissButton.LeftAnchor).Active   = true;
            FocusGuide.RightAnchor.ConstraintEqualTo(DismissButton.RightAnchor).Active = true;
            FocusGuide.TopAnchor.ConstraintEqualTo(DismissButton.BottomAnchor).Active  = true;
            FocusGuide.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active        = true;
        }
Exemplo n.º 5
0
        public override async void ViewDidLoad()
        {
            Console.WriteLine("viewdidload");

            Variables.ScreenHeight = View.Frame.Size.Height;
            Variables.ScreenWidth  = View.Frame.Size.Width;

            await RemoteConfigService.GetCloudData("serviceconfig");

            await RemoteConfigService.GetAppConfig("kconfig");

            await MusicService.GetAndStoreRecentSongsAsync();

            if (!string.IsNullOrEmpty(Variables.NowPlaying.ArtistId))
            {
                NPArtist = await MusicService.GetArtistById(Convert.ToInt32(Variables.NowPlaying.ArtistId));
            }
            SR = new SignalRService();
            await SR.ConnectAsync();

            SR.SongChanged += SignalR_SongChange;


            if (NPArtist != null)
            {
                NowPlayingArtistImageView       = new UIImageView(View.Frame);
                NowPlayingArtistImageView.Image = await Functions.LoadImage(NPArtist.ImageUrl);

                NowPlayingArtistImageView.Frame = new CGRect(x: 0, y: 0, width: Variables.ScreenWidth, height: Variables.ScreenWidth / 2);
                // Add the Image View to the parent view
                View.AddSubview(NowPlayingArtistImageView);

                DarkGradientImageView       = new UIImageView(View.Frame);
                DarkGradientImageView.Image = UIImage.FromBundle("dark-gradient.png");
                DarkGradientImageView.Frame = new CGRect(x: 0, y: 0, width: Variables.ScreenWidth, height: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2));
                View.AddSubview(DarkGradientImageView);

                RecentsImageView = new UIImageView(View.Frame);
                UIImage xI = await Functions.LoadImage(Variables.NowPlaying.AlbumImage);

                RecentsImageView.Image = xI;
                RecentsImageView.Frame = new CGRect(x: 0, y: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2), width: Variables.ScreenWidth, height: (Variables.ScreenHeight / 5) * 2);

                // Add the Image View to the parent view
                View.AddSubview(RecentsImageView);
                var   blur     = UIBlurEffect.FromStyle(UIBlurEffectStyle.Dark);
                float x        = 0;
                float y        = (float)(Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2));
                float width    = (float)Variables.ScreenWidth;
                float height   = (float)(Variables.ScreenHeight / 5 * 2);
                var   blurView = new UIVisualEffectView(blur)
                {
                    Frame = new RectangleF(x, y, width, height)
                };

                View.Add(blurView);
            }

            TagLineImageView             = new UIImageView(View.Frame);
            TagLineImageView.Image       = UIImage.FromBundle("kl-logo-tagline-white.png");
            TagLineImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            TagLineImageView.Frame       = new CGRect(x: Variables.ScreenWidth * .042, y: Variables.ScreenHeight * .011, width: Variables.ScreenWidth * .13, height: Variables.ScreenWidth * .13);
            View.AddSubview(TagLineImageView);

            StartStopButton = new UIButton(UIButtonType.System);
            StartStopButton.SetTitle("Play", UIControlState.Normal);
            StartStopButton.TitleLabel.Font = UIFont.SystemFontOfSize(24, UIFontWeight.Bold);
            StartStopButton.TitleEdgeInsets = new UIEdgeInsets(0, -50, 0, -50);
            UIImage SSButtonIconImage = UIImage.FromBundle("play-fill.png");

            StartStopButton.SetImage(SSButtonIconImage, UIControlState.Normal);
            StartStopButton.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            StartStopButton.ImageEdgeInsets       = new UIEdgeInsets(-5, 0, -5, 50);
            StartStopButton.Frame = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02) + 32, y: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2) - 32, width: 220, height: 64);
            StartStopButton.PrimaryActionTriggered += async(sender, e) =>
            {
                await AudioControl();
            };
            View.AddSubview(StartStopButton);

            LyricsButton = new UIButton(UIButtonType.System);
            LyricsButton.TitleLabel.Font = UIFont.SystemFontOfSize(24, UIFontWeight.Bold);
            LyricsButton.SetTitle("Lyrics", UIControlState.Normal);
            LyricsButton.TitleEdgeInsets = new UIEdgeInsets(0, -50, 0, -50);
            //LyricsButton.ImageEdgeInsets = new UIEdgeInsets(-5, 0, -5, 50);
            //UIImage LyButtonIconImage = UIImage.FromBundle("lyrics.png");
            //LyricsButton.SetImage(LyButtonIconImage, UIControlState.Normal);
            //LyricsButton.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            LyricsButton.Frame = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02) + 284, y: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2) - 32, width: 220, height: 64);
            LyricsButton.PrimaryActionTriggered += async(sender, e) =>
            {
                //await DisplayLyricsModal();
            };

            View.AddSubview(LyricsButton);
            ChannelsButton = new UIButton(UIButtonType.System);
            ChannelsButton.SetTitle("Channels", UIControlState.Normal);
            ChannelsButton.TitleLabel.Font = UIFont.SystemFontOfSize(24, UIFontWeight.Bold);
            ChannelsButton.TitleEdgeInsets = new UIEdgeInsets(0, -50, 0, -50);
            //UIImage ChButtonIconImage = UIImage.FromBundle("caret-down.png");
            //ChannelsButton.ImageEdgeInsets = new UIEdgeInsets(-5, 0, -5, 50);
            //ChannelsButton.SetImage(ChButtonIconImage, UIControlState.Normal);
            //ChannelsButton.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit;
            ChannelsButton.Frame = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02) + 536, y: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2) - 32, width: 220, height: 64);
            ChannelsButton.PrimaryActionTriggered += async(sender, e) =>
            {
                await DisplayChannelModal();
            };
            View.AddSubview(ChannelsButton);


            NowPlayingImageView       = new UIImageView(View.Frame);
            NowPlayingImageView.Image = await Functions.LoadImage(Variables.NowPlaying.AlbumImage);

            NowPlayingImageView.Frame = new CGRect(x: Variables.ScreenWidth * .042, y: (Variables.ScreenHeight * .55) - ((Variables.ScreenWidth / 4.5) / 2), width: Variables.ScreenHeight * .3, height: Variables.ScreenHeight * .3);
            // Add the Image View to the parent view
            View.AddSubview(NowPlayingImageView);

            ChannelTitleLabel           = new UILabel();
            ChannelTitleLabel.Text      = Variables.CurrentChannel.Title.ToUpper();
            ChannelTitleLabel.Font      = UIFont.SystemFontOfSize(24);
            ChannelTitleLabel.TextColor = UIColor.White;
            ChannelTitleLabel.Alpha     = .5f;
            ChannelTitleLabel.Frame     = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02), y: (Variables.ScreenHeight * .55) - ((Variables.ScreenWidth / 4.5) / 2), width: Variables.ScreenWidth / 2, height: 46);
            View.AddSubview(ChannelTitleLabel);

            NowPlayingTitleLabel           = new UILabel();
            NowPlayingTitleLabel.Text      = Variables.NowPlaying.SongTitle;
            NowPlayingTitleLabel.Font      = UIFont.SystemFontOfSize(60, UIFontWeight.Bold);
            NowPlayingTitleLabel.TextColor = UIColor.White;
            NowPlayingTitleLabel.Frame     = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02), y: ((Variables.ScreenHeight * .55) - ((Variables.ScreenWidth / 4.5) / 2)) + 31, width: (Variables.ScreenWidth / 3) * 2, height: 100);
            View.AddSubview(NowPlayingTitleLabel);

            NowPlayingArtistLabel           = new UILabel();
            NowPlayingArtistLabel.Text      = Variables.NowPlaying.ArtistName;
            NowPlayingArtistLabel.Font      = UIFont.SystemFontOfSize(48);
            NowPlayingArtistLabel.TextColor = UIColor.White;
            NowPlayingArtistLabel.Frame     = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02), y: ((Variables.ScreenHeight * .55) - ((Variables.ScreenWidth / 4.5) / 2)) + 108, width: Variables.ScreenWidth / 2, height: 60);
            View.AddSubview(NowPlayingArtistLabel);

            LastPlayedLabel           = new UILabel();
            LastPlayedLabel.Text      = "Last Played";
            LastPlayedLabel.Font      = UIFont.SystemFontOfSize(36, UIFontWeight.Bold);
            LastPlayedLabel.TextColor = UIColor.White;
            LastPlayedLabel.Frame     = new CGRect(x: Variables.ScreenWidth * .042, y: (Variables.ScreenHeight * .7), width: Variables.ScreenWidth / 4, height: 54);
            View.AddSubview(LastPlayedLabel);

            await UpdateLastPlayedList();

            FocusGuide = new UIFocusGuide();
            View.AddLayoutGuide(FocusGuide);

            FocusGuide.LeftAnchor.ConstraintEqualTo(Recent4.LeftAnchor).Active            = true;
            FocusGuide.TopAnchor.ConstraintEqualTo(ChannelsButton.TopAnchor).Active       = true;
            FocusGuide.WidthAnchor.ConstraintEqualTo(Recent4.WidthAnchor).Active          = true;
            FocusGuide.HeightAnchor.ConstraintEqualTo(ChannelsButton.HeightAnchor).Active = true;

            FocusGuide.PreferredFocusedView = StartStopButton;

            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
        }