/// <summary> /// Opens online parashah provider. /// </summary> static public void OpenParashahProvider(string url, Parashah parashah, bool openLinked = false) { if (parashah is null) { DisplayManager.Show(HebrewTranslations.ParashahNotFound.GetLang()); return; } open(parashah); if (openLinked && url.IndexOf('%') >= 0) { var linked = parashah.GetLinked(); if (linked is not null) { open(linked); } } // void open(Parashah item) { SystemManager.TryCatchManage(ShowExceptionMode.OnlyMessage, () => { string link = url.Replace("%WIKIPEDIA-EN%", OnlineParashot.WikipediaEN[item.Book][item.Number - 1]) .Replace("%WIKIPEDIA-FR%", OnlineParashot.WikipediaFR[item.Book][item.Number - 1]) .Replace("%TORAHBOX%", OnlineParashot.TorahBox[item.Book][item.Number - 1]) .Replace("%TORAHORG%", OnlineParashot.TorahOrg[item.Book][item.Number - 1]) .Replace("%TORAHJEWS%", OnlineParashot.TorahJews[item.Book][item.Number - 1]) .Replace("%YESHIVACO%", OnlineParashot.YeshivaCo[item.Book][item.Number - 1]) .Replace("%THEYESHIVA%", OnlineParashot.TheYeshivaNet[item.Book][item.Number - 1]) .Replace("%MYJEWISHLEARNING%", OnlineParashot.MyJewishLearning[item.Book][item.Number - 1]) .Replace("%CHABAD-EN%", OnlineParashot.ChabadEN[item.Book][item.Number - 1]) .Replace("%CHABAD-FR%", OnlineParashot.ChabadFR[item.Book][item.Number - 1]) .Replace("%AISH-EN%", OnlineParashot.AishEN[item.Book][item.Number - 1]) .Replace("%AISH-FR%", OnlineParashot.AishFR[item.Book][item.Number - 1]) .Replace("%AISH-IW%", OnlineParashot.AishIW[item.Book][item.Number - 1]); SystemManager.OpenWebLink(link); }); } }
static public bool ShowDescription( this List <Parashah> parashot, Parashah parashah, bool withLinked, Func <Form> runBoard) { // Prepare var form = (MessageBoxEx)Application.OpenForms.GetAll(f => f is MessageBoxEx && f.Tag == parashah).FirstOrDefault(); if (form is not null) { form.Popup(); return(true); } var linked = withLinked ? parashah.GetLinked(parashot) : null; if (parashah is null) { return(false); } // Message box var message = parashah.ToStringReadable(); if (linked is not null) { message += Globals.NL2 + linked.ToStringReadable(); } string title = HebrewTranslations.WeeklyParashah.GetLang() + " : " + parashah.Name; form = new MessageBoxEx(title, message, width: MessageBoxEx.DefaultWidthMedium) { StartPosition = FormStartPosition.CenterScreen, ForceNoTopMost = true, ShowInTaskbar = true, AllowClose = true, Tag = parashah }; // Button Open board form.ActionYes.Visible = runBoard is not null; form.ActionYes.Text = SysTranslations.Board.GetLang(); form.ActionYes.Click += async(_, _) => { Form form = null; SystemManager.TryCatchManage(() => form = runBoard.Invoke()); await Task.Delay(1000).ConfigureAwait(false); if (form is not null) { SystemManager.TryCatchManage(() => form.Popup()); } }; // Button Open memo form.ActionNo.Visible = !parashah.Memo.IsNullOrEmpty() || (!linked?.Memo.IsNullOrEmpty() ?? false); form.ActionNo.Text = SysTranslations.Memo.GetLang(); form.ActionNo.Click += (_, _) => DisplayManager.Show(string.Join(Globals.NL2, parashah.Memo, linked?.Memo ?? "")); // Button Copy to clipboard form.ActionRetry.Visible = true; form.ActionRetry.Text = SysTranslations.ActionCopy.GetLang(); form.ActionRetry.DialogResult = DialogResult.None; form.ActionRetry.Click -= form.ActionClose_Click; form.ActionRetry.Click += (_, _) => { Clipboard.SetText(message); DisplayManager.ShowSuccessOrSound(SysTranslations.DataCopiedToClipboard.GetLang(), Globals.ClipboardSoundFilePath); }; // Show form.Show(); return(true); }