Exemplo n.º 1
0
        protected override void OnApplyTemplate()
        {
            Button   = GetTemplateChild(nameof(Button)) as FileButton;
            Progress = GetTemplateChild(nameof(Progress)) as ProgressVoice;
            Subtitle = GetTemplateChild(nameof(Subtitle)) as TextBlock;

            Button.Click += Button_Click;

            _templateApplied = true;

            if (_message != null)
            {
                UpdateMessage(_message);
            }
        }
Exemplo n.º 2
0
        public async void SetDirectItem(InstaDirectInboxThread thread, InstaDirectInboxItem item, ProgressVoice progressVoice, ToggleButton /*AppBarButton*/ button)
        {
            if (item == null)
            {
                return;
            }

            try
            {
                FasterModeButton.IsChecked = false;
            }
            catch { }
            try
            {
                if (CurrentDirectInboxItem != null)
                {
                    if (CurrentDirectInboxItem.ItemId == item.ItemId)
                    {
                        try
                        {
                            Visibility = Visibility.Visible;
                        }
                        catch { }
                        if (MainPage.Current.ME.CurrentState == MediaElementState.Paused)
                        {
                            Play();
                        }
                        else
                        {
                            Pause();
                        }
                        return;
                    }
                }
                if (VoicePlayPauseButton != null)
                {
                    VoicePlayPauseButton.Tag /*Content*/ = Helper.PlayMaterialIcon;
                }
                ProgressVoice = progressVoice;
                await Task.Delay(200);

                CurrentDirectInboxItem = item;

                VoicePlayPauseButton = button;
                var date = item.TimeStamp;

                var textDate = $"{date.ToString("MMM", CultureInfo.InvariantCulture)} {date.Day} at {date.ToString("hh:mm tt")}";
                txtTime.Text = "00:00";

                if (item.UserId == Helper.CurrentUser.Pk)
                {
                    txtInfo.Text = $"You {textDate}";
                }
                else
                {
                    var user = thread.Users.FirstOrDefault(x => x.Pk == item.UserId);
                    if (user == null)
                    {
                        txtInfo.Text = $"{textDate}";
                    }
                    else
                    {
                        txtInfo.Text = $"{user.UserName} {textDate}";
                    }
                }
            }
            catch { }

            try
            {
                MainPage.Current.ME.PlaybackRate = 1.00;
            }
            catch { }
            try
            {
                MainPage.Current.ME.Source = new Uri(CurrentDirectInboxItem.VoiceMedia.Media.Audio.AudioSource);
            }
            catch { }
            try
            {
                Visibility = Visibility.Visible;
            }
            catch { }
        }