コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: telojagung/Quran-1
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            var surah = int.Parse(ddlSurahs.SelectedValue ?? "1");
            var ayah  = int.Parse(ddlAyahs.SelectedValue ?? "1");

            var existingTranslation = _Quran.MyTranslations.FirstOrDefault(t => t.SurahNo == surah && t.AyahNo == ayah);

            if (existingTranslation != null)
            {
                NewPara.Checked    = existingTranslation.NewParaAfterThis;
                Heading.Text       = existingTranslation.Heading;
                MyTranslation.Text = existingTranslation.Translation;
                Footnote.Text      = existingTranslation.Footnote;

                //lblMyTranslation.Text = existingTranslation.Translation;
                var text = existingTranslation.Translation;
                text = new Regex(@"\*+").Replace(text, (match) =>
                {
                    // Each * is footnote number
                    int footnoteIndex = match.Value.Length;
                    //var footnoteId = "Footnote_" + existingTranslation.SurahNo + "_" + existingTranslation.AyahNo + "_" + footnoteIndex;
                    return("<sup>" + (char)('a' + (char)(footnoteIndex - 1)) + "</sup>");
                });
                lblMyTranslation.Text = text;

                //lblFootnote.Text = existingTranslation.Footnote;
                var matches      = new Regex(@"(\*+)([^\*]*)").Matches(existingTranslation.Footnote);
                var footnoteHtml = "";
                foreach (Match match in matches)
                {
                    var footnoteCounter = match.Groups[1].Value.Length;
                    var footnoteText    = match.Groups[2].Value;

                    footnoteHtml += "<p class=\"footnote\"><sup>"
                                    + (char)('a' + (char)(footnoteCounter - 1)) + "</sup> "
                                    + footnoteText + "</p>";
                }
                lblFootnote.Text = footnoteHtml;
            }
            else
            {
                NewPara.Checked    = false;
                Heading.Text       = string.Empty;
                MyTranslation.Text = string.Empty;
                Footnote.Text      = string.Empty;

                lblMyTranslation.Text = string.Empty;
                lblFootnote.Text      = string.Empty;
            }

            LoadPageContent(surah, ayah);
            RefreshNavigationState();


            var banglaCookie = Response.Cookies.AllKeys.Contains("bangla") ? Response.Cookies["bangla"] : Request.Cookies.Get("bangla");

            if (banglaCookie != null && banglaCookie.Value == "show")
            {
                pnlMyTranslationView.Visible = true;
                ToggleBangla.Text            = "Hide";
            }
            else
            {
                if (banglaCookie != null && string.IsNullOrEmpty(banglaCookie.Value))
                {
                    banglaCookie.Value = "hide";
                }

                ToggleBangla.Text            = "Show";
                pnlMyTranslationView.Visible = false;
            }

            Response.Cookies.Set(new System.Web.HttpCookie("last", ddlSurahs.SelectedValue + "/" + ddlAyahs.SelectedValue));

            if (Request.QueryString["edit"] == null)
            {
                pnlMyTranslationEdit.Visible = false;
            }
            else
            {
                pnlMyTranslationEdit.Visible = true;
            }

            _Quran.Dispose();
        }
コード例 #2
0
ファイル: Settings.aspx.cs プロジェクト: telojagung/Quran-1
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            _Quran.Dispose();
        }