public static void AppendViewModel(this ItemText text, IRuleHandler handler, ElementViewModel viewModel) { if (text?.IsEmpty == false) { viewModel.Add(ViewModelItemFactory.Create(TextHolderKind.Text, new List <ParagraphViewModel> { ParagraphVMFactory.Create(text, handler.Settings.Language.Name) })); } }
public static ViewModelItem Create(Ymnos ymnos, IRuleHandler handler, IRuleSerializerRoot serializer) { var kind = Cast(ymnos.Kind); return(new ViewModelItem() { Kind = Cast(ymnos.Kind), KindStringValue = GetKindStringValue(kind, handler, serializer), Paragraphs = new List <ParagraphViewModel>() { ParagraphVMFactory.Create(ymnos.Text, handler.Settings.Language.Name) } }); }
private void AppendChorus(Odi odi, bool isLastKanonas, bool isOdi8, int i, ItemText defaultChorus) { var troparion = odi.Troparia[i]; var kind = ChorusKind.Common; if (isLastKanonas) { //проверяем, если последний канон, if (i == odi.Troparia.Count - 2) { if (!isOdi8) { //если предпоследний тропарь - Слава kind = ChorusKind.Slava; } else { //если 8-ая песня - Благословим kind = ChorusKind.Blagoslovim; } } else if (i == odi.Troparia.Count - 1) { //если последний - И ныне kind = ChorusKind.Inyne; } } ItemText text = GetChorus(kind, troparion, defaultChorus); if ((text?.IsEmpty == false) //добавляем пустой припев к Ирмосу в любом случае || troparion.Kind == YmnosKind.Irmos) { //добавляем припев var view = ViewModelItemFactory.Create((kind == ChorusKind.Common) ? ViewModelItemKind.Chorus : ViewModelItemKind.Text, new List <ParagraphViewModel>() { ParagraphVMFactory.Create(text, handler.Settings.Language.Name) }, handler, serializer); appendModelAction(new ElementViewModel() { view }); } }
private void AppendKanonasHeader(CreateViewModelRequest <KanonasRule> req, Kanonas kanonas) { int hash = kanonas.GetHashCode(); ViewModelItem view = null; if (!kanonasHeaders.ContainsKey(hash)) { TextHolder holder = null; string name = ""; if (kanonas.Name != null) { holder = GetHeaders(req)[2]; name = kanonas.Name[req.Handler.Settings.Language.Name]; } else { holder = GetHeaders(req)[3]; } var kanonasP = ParagraphVMFactory.Create(holder.Paragraphs[0], req.Handler.Settings.Language.Name); kanonasP.Replace("[kanonas]", name); kanonasP.Replace("[ihos]", req.Handler.Settings.Language.IntConverter.ToString(kanonas.Ihos)); view = ViewModelItemFactory.Create(TextHolderKind.Text, new List <ParagraphViewModel>() { kanonasP }); //string kanonasString = holder.Paragraphs[0][req.Handler.Settings.Language.Name]; //kanonasString = kanonasString.Replace("[kanonas]", name). // Replace("[ihos]", req.Handler.Settings.Language.IntConverter.ToString(kanonas.Ihos)); //view = ViewModelItemFactory.Create(TextHolderKind.Text, new List<string> { kanonasString }); kanonasHeaders.Add(hash, view); } else { view = kanonasHeaders[hash]; } req.AppendModelAction(new ElementViewModel() { view }); }
private static void AppendYmnis(List <Ymnos> ymnis, IRuleHandler handler, IRuleSerializerRoot serializer, ElementViewModel viewModel) { var text = GetStringValues(handler, serializer); foreach (Ymnos ymnos in ymnis) { //добавляем стих и песнопение как отдельные объекты foreach (ItemText stihos in ymnos.Stihoi) { viewModel.Add(ViewModelItemFactory.Create(TextHolderKind.Stihos, text.StihosText, new List <ParagraphViewModel> { ParagraphVMFactory.Create(stihos, handler.Settings.Language.Name) })); } viewModel.Add(ViewModelItemFactory.Create(TextHolderKind.Choir, text.ChoirText, new List <ParagraphViewModel> { ParagraphVMFactory.Create(ymnos.Text, handler.Settings.Language.Name) })); } }
public static void AppendViewModel(this Prosomoion prosomoion, IRuleHandler handler, IRuleSerializerRoot serializer, ElementViewModel viewModel, int?ihos = null) { TypiconEntity typ = handler.Settings.Rule.Owner; CommonRuleServiceRequest req = new CommonRuleServiceRequest() { RuleSerializer = serializer }; string str = ""; if (ihos != null) { //текст "Глас" req.Key = CommonRuleConstants.IhosText; string ihosString = handler.Settings.Language.IntConverter.ToString((int)ihos); str += $"{typ.GetCommonRuleTextValue(req, handler.Settings.Language.Name)} {ihosString}. "; } //самоподобен? if (prosomoion?.Self == true) { req.Key = CommonRuleConstants.SelfText; str += typ.GetCommonRuleTextValue(req, handler.Settings.Language.Name); } //если подобен else if (prosomoion?.IsEmpty == false) { req.Key = CommonRuleConstants.ProsomoionText; string p = typ.GetCommonRuleTextValue(req, handler.Settings.Language.Name); str += $"{p}: \"{ prosomoion[handler.Settings.Language.Name] }\""; } viewModel.Add(ViewModelItemFactory.Create(TextHolderKind.Text, new List <ParagraphViewModel> { ParagraphVMFactory.Create(str) })); }
private void AppendKatavasiaHeader(CreateViewModelRequest <KanonasRule> req, int ihos) { if (katavasiaHeader == null) { var katavasiaP = ParagraphVMFactory.Create(GetHeaders(req)[4].Paragraphs[0], req.Handler.Settings.Language.Name); katavasiaP.Replace("[ihos]", req.Handler.Settings.Language.IntConverter.ToString(ihos)); katavasiaHeader = ViewModelItemFactory.Create(TextHolderKind.Text, new List <ParagraphViewModel>() { katavasiaP }); //string str = GetHeaders(req)[4].Paragraphs[0][req.Handler.Settings.Language.Name]; //str = str.Replace("[ihos]", req.Handler.Settings.Language.IntConverter.ToString(ihos)); //katavasiaHeader = ViewModelItemFactory.Create(TextHolderKind.Text, new List<string> { str }); } req.AppendModelAction(new ElementViewModel() { katavasiaHeader }); }