Пример #1
0
        private void AppendTroparion(Ymnos troparion)
        {
            var view = OutputSectionFactory.Create(troparion, handler.Settings.TypiconVersionId, serializer);

            appendModelAction(new OutputSectionModelCollection()
            {
                view
            });
        }
        protected virtual void InnerAppendCustomForm(CreateViewModelRequest <YmnosStructureRule> req, string key)
        {
            var header = Serializer.GetCommonRuleFirstChild <TextHolder>(req.Handler.Settings.TypiconVersionId, key);

            req.AppendModelAction(new OutputSectionModelCollection()
            {
                OutputSectionFactory.Create(header, req.Handler.Settings.TypiconVersionId, Serializer)
            });
        }
Пример #3
0
        private void AppendHeader(CreateViewModelRequest <KanonasRule> req)
        {
            TextHolder header = GetHeaders(req)[0];

            req.AppendModelAction(new OutputSectionModelCollection()
            {
                OutputSectionFactory.Create(header, req.Handler.Settings.TypiconVersionId, Serializer)
            });
        }
Пример #4
0
        protected virtual void ConstructWithCommonRule(CreateViewModelRequest <YmnosStructureRule> req, string key)
        {
            var children = Serializer.GetCommonRuleChildren(req.Handler.Settings.TypiconVersionId, key);

            //List<RuleElement> children = req.Handler.Settings.TypiconRule.Owner.GetChildren(
            //    new CommonRuleServiceRequest() { Key = key, RuleSerializer = Serializer }).ToList();

            if (req.Element.Structure.Groups.Count > 0)
            {
                //заполняем header - вставляем номер гласа
                ItemText header = (children[0] as TextHolder).Paragraphs[0];

                header.ReplaceForEach("[ihos]", req.Element.Structure.Groups[0].Ihos);
                //string headerText = header.StringExpression;
                //header.StringExpression = headerText.Replace("[ihos]",
                //    req.Handler.Settings.Language.IntConverter.ToString(req.Element.Structure.Groups[0].Ihos));

                //а теперь отсчитываем от последней стихиры и добавляем к ней стих из псалма
                //сам стих удаляем из псалма

                TextHolder psalm = new TextHolder(children[2] as TextHolder);

                for (int i = req.Element.Structure.Groups.Count - 1; i >= 0; i--)
                {
                    YmnosGroup group = req.Element.Structure.Groups[i];

                    for (int n = group.Ymnis.Count - 1; n >= 0; n--)
                    {
                        Ymnos ymnos = group.Ymnis[n];

                        ItemTextNoted stihos = psalm.Paragraphs.Last();

                        ymnos.Stihoi.Add(stihos);

                        psalm.Paragraphs.Remove(stihos);
                    }
                }
            }

            //теперь вставляем шапку
            AppendItem(children[0] as TextHolder);
            AppendItem(children[1] as TextHolder);

            //вставляем псалмы
            if ((req.Element as KekragariaRule).ShowPsalm)
            {
                AppendItem(children[2] as TextHolder);
            }

            void AppendItem(TextHolder textHolder)
            {
                req.AppendModelAction(new OutputSectionModelCollection()
                {
                    OutputSectionFactory.Create(textHolder, req.Handler.Settings.TypiconVersionId, Serializer)
                });
            }
        }
Пример #5
0
        /// <summary>
        /// Добавляет "Хвалим, благословим..."
        /// </summary>
        private void AppendStihosOdi8(CreateViewModelRequest <KanonasRule> req)
        {
            TextHolder odi8TextHolder = GetHeaders(req)[5];
            var        viewModel      = OutputSectionFactory.Create(odi8TextHolder, req.Handler.Settings.TypiconVersionId, Serializer);

            req.AppendModelAction(new OutputSectionModelCollection()
            {
                viewModel
            });
        }
Пример #6
0
 public static void AppendViewModel(this ItemText text, IRuleHandler handler, OutputSectionModelCollection viewModel)
 {
     if (text?.IsEmpty == false)
     {
         viewModel.Add(OutputSectionFactory.Create(TextHolderKind.Text,
                                                   new List <ItemTextNoted> {
             new ItemTextNoted(text)
         }));
     }
 }
        private (OutputSectionModel Kontakion, OutputSectionModel Ikos) GetHeaders(CreateViewModelRequest <KontakionRule> req, Kontakion kontakion)
        {
            var headers = Serializer.GetCommonRuleChildren <TextHolder>(req.Handler.Settings.TypiconVersionId, CommonRuleConstants.Kontakion);

            var viewKontakion = OutputSectionFactory.Create(headers[0], req.Handler.Settings.TypiconVersionId, Serializer);

            viewKontakion.Paragraphs[0].ReplaceForEach(IHOS_STRING, kontakion.Ihos);

            var viewIkos = OutputSectionFactory.Create(headers[1], req.Handler.Settings.TypiconVersionId, Serializer);

            return(viewKontakion, viewIkos);
        }
        private void AppendText(CreateViewModelRequest <PsalmRule> req, BookReading psalmReading)
        {
            //List<string> paragraphs = psalmReading.Text.Select(c => c[req.Handler.Settings.Language.Name]).ToList();
            var paragraphs = new List <ItemTextNoted>();

            psalmReading.Text.ForEach(c => paragraphs.Add(new ItemTextNoted(c)));

            req.AppendModelAction(new OutputSectionModelCollection()
            {
                OutputSectionFactory.Create(TextHolderKind.Lector, paragraphs)
            });
        }
Пример #9
0
        private void AppenOdiHeader(CreateViewModelRequest <KanonasRule> req, int i)
        {
            TextHolder odiTextHolder = GetHeaders(req)[1];

            var viewModel = OutputSectionFactory.Create(odiTextHolder, req.Handler.Settings.TypiconVersionId, Serializer);

            viewModel.Paragraphs[0].ReplaceForEach("[odinumber]", i);

            req.AppendModelAction(new OutputSectionModelCollection()
            {
                viewModel
            });
        }
Пример #10
0
 protected override void AppendCustomForm(CreateViewModelRequest <YmnosStructureRule> req)
 {
     if ((req.Element as SedalenRule)?.Header is ItemTextHeader header)
     {
         req.AppendModelAction(new OutputSectionModelCollection()
         {
             OutputSectionFactory.Create(header)
         });
     }
     else
     {
         InnerAppendCustomForm(req, CommonRuleConstants.SedalenRule);
     }
 }
Пример #11
0
        private void AppendHeader(CreateViewModelRequest <PsalmRule> req)
        {
            TextHolder header = Serializer.GetCommonRuleFirstChild <TextHolder>(req.Handler.Settings.TypiconVersionId, CommonRuleConstants.Psalm);

            var viewHeader = OutputSectionFactory.Create(header, req.Handler.Settings.TypiconVersionId, Serializer);

            //вставляем номер Псалма
            viewHeader.Paragraphs[0].ReplaceForEach(NUMBER, req.Element.Number);

            req.AppendModelAction(new OutputSectionModelCollection()
            {
                viewHeader
            });
        }
        public override void Create(CreateViewModelRequest <TextHolder> req)
        {
            if (req.Element == null)
            {
                //TODO: просто ничего не делаем, хотя надо бы это обрабатывать
                return;
            }

            OutputSectionModel item = OutputSectionFactory.Create(req.Element, req.Handler.Settings.TypiconVersionId, Serializer);

            req.AppendModelAction(new OutputSectionModelCollection()
            {
                item
            });
        }
Пример #13
0
        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 = OutputSectionFactory.Create((kind == ChorusKind.Common) ? ElementViewModelKind.Chorus : ElementViewModelKind.Text,
                                                       new List <ItemTextNoted>()
                {
                    new ItemTextNoted(text)
                }, handler.Settings.TypiconVersionId, serializer);

                appendModelAction(new OutputSectionModelCollection()
                {
                    view
                });
            }
        }
Пример #14
0
        private void AppendKanonasHeader(CreateViewModelRequest <KanonasRule> req, Kanonas kanonas)
        {
            int hash = kanonas.GetHashCode();

            OutputSectionModel view = null;

            if (!kanonasHeaders.ContainsKey(hash))
            {
                TextHolder holder = null;
                ItemText   name   = null;
                if (kanonas.Name != null)
                {
                    holder = GetHeaders(req)[2];
                    name   = kanonas.Name;
                }
                else
                {
                    holder = GetHeaders(req)[3];
                }

                var kanonasP = new ItemTextNoted(holder.Paragraphs[0]);
                kanonasP.ReplaceForEach("[kanonas]", name);
                kanonasP.ReplaceForEach("[ihos]", kanonas.Ihos);

                view = OutputSectionFactory.Create(TextHolderKind.Text, new List <ItemTextNoted>()
                {
                    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 OutputSectionModelCollection()
            {
                view
            });
        }
Пример #15
0
        public static void AppendViewModel(this Prosomoion prosomoion, int typiconVersionId,
                                           IRuleSerializerRoot serializer, OutputSectionModelCollection viewModel, int?ihos = null)
        {
            ItemText ihosItemText       = null;
            ItemText prosomoionItemText = null;

            if (ihos != null)
            {
                //текст "Глас"
                ihosItemText = serializer.GetCommonRuleItemTextValue(typiconVersionId, CommonRuleConstants.IhosText);
                ihosItemText.ReplaceForEach("[ihos]", ihos.Value);
            }
            else
            {
                ihosItemText = new ItemText();
            }

            //самоподобен?
            if (prosomoion?.Self == true)
            {
                prosomoionItemText = serializer.GetCommonRuleItemTextValue(typiconVersionId, CommonRuleConstants.SelfText);
            }
            //если подобен
            else if (prosomoion?.IsEmpty == false)
            {
                prosomoionItemText = serializer.GetCommonRuleItemTextValue(typiconVersionId, CommonRuleConstants.ProsomoionText);
                prosomoionItemText.ReplaceForEach("[name]", prosomoion);
            }
            else
            {
                prosomoionItemText = new ItemText();
            }

            //соединяем воедино
            ihosItemText.Merge(prosomoionItemText);

            viewModel.Add(OutputSectionFactory.Create(TextHolderKind.Text,
                                                      new List <ItemTextNoted> {
                new ItemTextNoted(ihosItemText)
            }));
        }
Пример #16
0
        private static void AppendYmnis(List <Ymnos> ymnis, IRuleHandler handler,
                                        IRuleSerializerRoot serializer, OutputSectionModelCollection viewModel)
        {
            var(StihosText, ChoirText) = GetStringValues(handler, serializer);

            foreach (Ymnos ymnos in ymnis)
            {
                //добавляем стих и песнопение как отдельные объекты
                foreach (ItemText stihos in ymnos.Stihoi)
                {
                    viewModel.Add(OutputSectionFactory.Create(TextHolderKind.Stihos, StihosText,
                                                              new List <ItemTextNoted> {
                        new ItemTextNoted(stihos)
                    }));
                }

                viewModel.Add(OutputSectionFactory.Create(TextHolderKind.Choir, ChoirText,
                                                          new List <ItemTextNoted> {
                    new ItemTextNoted(ymnos.Text)
                }));
            }
        }
Пример #17
0
        private void AppendKatavasiaHeader(CreateViewModelRequest <KanonasRule> req, int ihos)
        {
            if (katavasiaHeader == null)
            {
                var katavasiaP = new ItemTextNoted(GetHeaders(req)[4].Paragraphs[0]);
                katavasiaP.ReplaceForEach("[ihos]", ihos);

                katavasiaHeader = OutputSectionFactory.Create(TextHolderKind.Text, new List <ItemTextNoted>()
                {
                    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 OutputSectionModelCollection()
            {
                katavasiaHeader
            });
        }