Exemplo n.º 1
0
        private void SuraSelected()
        {
            ClosePopupSura();

            if (Sura.SuraNo != suraListBox.SelectedIndex + 1)
            {
                int suraNo   = suraListBox.SelectedIndex + 1;
                int prevQari = AppSettings.Qari;
                QuranProvider.ChangeQari(suraNo);
                scrollViewer.ScrollToVerticalOffset(0);
                toggleButtonPlayPause.Visibility = PlayPauseShown;
                LoadSura(suraNo);
                ApplyPagePadding();

                if (prevQari != AppSettings.Qari)
                {
                    QuranProvider.InitAudio();
                }

                StartSura();
            }
            else
            {
                ShowToolTip(run);
                PausePlayHandler(this, null);
            }
        }
Exemplo n.º 2
0
        private void PlayAudio(bool newQari)
        {
            if (!AppSettings.HasAudio)
            {
                return;
            }

            if (player.Source != null && !newQari)
            {
                player.Position = CurrentAudioSlice.Start;

                if (PlayerState == MediaState.Pause)
                {
                    PlayerState = MediaState.Play;
                    player.Play();
                }
            }
            else
            {
                player.Source   = new Uri(QuranProvider.GetAudioPath(Sura.SuraNo), UriKind.Relative);
                player.Position = CurrentAudioSlice.Start;
                player.Play();
                PlayerState = MediaState.Play;
            }
        }
Exemplo n.º 3
0
        private void OpenPopupQari()
        {
            try
            {
                timer.Stop();

                Pause();

                tooltip.IsOpen = false;

                BlurEffect objBlur = new BlurEffect();
                objBlur.KernelType    = KernelType.Gaussian;
                objBlur.RenderingBias = RenderingBias.Performance;
                objBlur.Radius        = 8;
                this.Effect           = objBlur;

                int prevQari = AppSettings.Qari;

                bool preAudioFileExist = QuranProvider.IsAudioFileExist(Sura.SuraNo);

                new QariSelector(Sura.SuraNo).ShowDialog();

                if (prevQari != AppSettings.Qari)
                {
                    QuranProvider.InitAudio();
                    PlayAudio(true);
                    if (AppSettings.HasAudio)
                    {
                        timer.Start();
                    }
                }
                else if (preAudioFileExist == false && QuranProvider.IsAudioFileExist(Sura.SuraNo))
                {
                    SuraSelected();
                }

                suraPopup.IsOpen = false;
                this.Effect      = null;

                qariNameContentControl.Content = QuranProvider.GetQariName();

                PlayAudio();
                ShowToolTip(run);

                toggleButtonPlayPause.Visibility = PlayPauseShown;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        private void PlayAudio(int suraNo)
        {
            if (!AppSettings.HasAudio)
            {
                player.Source = null;
                return;
            }

            //player.Volume = 0.1;

            player.Source = new Uri(QuranProvider.GetAudioPath(suraNo), UriKind.Relative);
            player.Play();
            PlayerState = MediaState.Play;
            repeat      = AppSettings.Repeat;
        }
Exemplo n.º 5
0
        private void ayaComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Run run = null;

            if (Sura.SuraNo == 1 && ayaComboBox.SelectedIndex == 0)
            {
                run = (introAyaSpan.Inlines.FirstInline as Span).Inlines.FirstInline as Run;
            }
            else
            {
                run = QuranProvider.GetRun(Sura.SuraNo, ayaComboBox.SelectedIndex + 1);
            }
            SliceInfo = run.Tag as SliceInfo;
            Run_MouseDown(run, e);

            this.Focus();
        }
Exemplo n.º 6
0
        private void LoadSura(int suraNo)
        {
            Paragraph paragraph = new Paragraph();

            QuranProvider.InitProvider(suraNo, paragraph);

            SliceInfo = QuranProvider.runs[suraNo][0].Tag as SliceInfo;
            Sura      = QuranProvider.Meta.Suras[suraNo - 1];
            introAyaSpan.Inlines.Clear();
            mainParagraph.Inlines.Clear();

            QuranProvider.InitProvider(suraNo, mainParagraph);

            if (suraNo != 9)
            {
                introAyaSpan.Inlines.Add(QuranProvider.GetIntroAya(suraNo));
            }

            suraNameContentControl.Content = string.Format("سوره {0}", QuranProvider.GetSuraName(suraNo));
            //suraInfoTextBlock.Text = SuraInfo;

            if (suraNo == 1)
            {
                mainParagraph.Inlines.Remove(mainParagraph.Inlines.FirstInline);
            }

            this.UpdateLayout();

            PlayAudio(suraNo);

            LoadAyas();

            qariNameContentControl.Content = QuranProvider.GetQariName();

            if (suraNo < 114)
            {
                NextSura.Visibility = System.Windows.Visibility.Visible;
                NextSura.Content    = QuranProvider.Meta.Suras[suraNo].NameArabic;
            }
            else
            {
                NextSura.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Exemplo n.º 7
0
        private void ShowToolTip(Run run)
        {
            if (cursorPos != new Point() && cursorPos == GetMousePosition())
            {
                //Mouse.OverrideCursor = Cursors.None;
                previousCursor = Cursor;
                Cursor         = Cursors.None;
                //SetCursorPos((int)this.ActualWidth, 100);
            }
            else
            {
                cursorPos = GetMousePosition();
            }

            Quran.Code.QuranProvider.SajdaType sajdaType = QuranProvider.GetSajdaInfo(Sura.SuraNo, SliceInfo.AyaNo);

            if (sajdaType == QuranProvider.SajdaType.Mostahab)
            {
                infoPopup.IsOpen = false;
                infoPopup.IsOpen = true;
            }
            else if (sajdaType == QuranProvider.SajdaType.Vajeb)
            {
                infoTextBlock.Text = "سجده واجب";
                infoPopup.IsOpen   = false;
                infoPopup.IsOpen   = true;
            }

            if (!this.IsActive)
            {
                return;
            }

            if (!AppSettings.HasTranslation)
            {
                return;
            }

            SliceType sliceType = SliceType.SingleLine;

            tooltip.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));


            var rectStart  = run.ContentStart.GetCharacterRect(LogicalDirection.Forward);
            var rectEnd    = run.ContentEnd.GetInsertionPosition(LogicalDirection.Forward).GetCharacterRect(LogicalDirection.Forward);
            var startPoint = flowDocSV.PointToScreen(new Point(rectStart.X - tooltip.DesiredSize.Width, rectStart.Y));
            var endPoint   = flowDocSV.PointToScreen(new Point(rectEnd.X, rectEnd.Y));

            if (endPoint.Y < 100 || rectEnd.Y > flowDocSV.ActualHeight)
            {
                tooltip.IsOpen = false;
                return;
            }


            if (rectEnd.Y > rectStart.Y)
            {
                sliceType = SliceType.MultiLine;
            }

            double freeSpace       = 0;
            bool   canCoverAtStart = true;

            if (sliceType == SliceType.SingleLine)
            {
                freeSpace = rectStart.X;

                if (freeSpace < tooltip.DesiredSize.Width)
                {
                    canCoverAtStart = false;
                }
            }
            else
            {
                freeSpace = rectEnd.X - flowDoc.PagePadding.Left;

                if (freeSpace < tooltip.DesiredSize.Width)
                {
                    canCoverAtStart = false;
                }
            }

            // Show Tooltip
            tooltip.StaysOpen = true;
            tooltip.IsOpen    = true;
            tooltip.Placement = System.Windows.Controls.Primitives.PlacementMode.Absolute;
            run.ToolTip       = tooltip;

            if (sliceType == SliceType.SingleLine)
            {
                if (canCoverAtStart)
                {
                    tooltip.PlacementRectangle = new Rect(startPoint.X, startPoint.Y, 0, 0);
                }
                else
                {
                    tooltip.PlacementRectangle = new Rect(endPoint.X, startPoint.Y, 0, 0);
                }
            }
            else
            {
                if (canCoverAtStart)
                {
                    double extraSpace   = 50;
                    double extraHeight  = rectEnd.Height + (lineHeight - rectEnd.Height) / 2 - 2;
                    Point  tooltipPoint = flowDocSV.PointToScreen(new Point(rectEnd.X - tooltip.DesiredSize.Width - extraSpace, rectEnd.Y - extraHeight));
                    tooltip.PlacementRectangle = new Rect(tooltipPoint.X, tooltipPoint.Y, 0, 0);
                }
                else
                {
                    //Rect rect = run.ContentEnd.GetLineStartPosition(1).GetCharacterRect(LogicalDirection.Forward);
                    Rect  rect         = run.ContentEnd.GetLineStartPosition(0).GetCharacterRect(LogicalDirection.Forward);
                    Point tooltipPoint = flowDocSV.PointToScreen(new Point(rect.X - tooltip.DesiredSize.Width, rectEnd.Y));
                    tooltip.PlacementRectangle = new Rect(tooltipPoint.X, tooltipPoint.Y, 0, 0);
                }
            }
        }