Exemplo n.º 1
0
        private Kanonas GetFromSource(RuleHandlerSettings settings)
        {
            Kanonas result = null;
            Kanonas source = GetKanonas(settings);

            if (source != null)
            {
                result = new Kanonas()
                {
                    Acrostic   = source.Acrostic,
                    Annotation = source.Annotation,
                    Ihos       = source.Ihos,
                    Stihos     = source.Stihos
                };

                foreach (Odi odi in source.Odes)
                {
                    Odi o = new Odi()
                    {
                        Number = odi.Number
                    };

                    //добавляем катавасию(и)
                    o.Troparia.AddRange(odi.Troparia.FindAll(c => c.Kind == YmnosKind.Katavasia));
                    //добавляем саму песнь
                    result.Odes.Add(o);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private IEnumerable <Ymnos> GetYmnis(Odi odi)
        {
            List <Ymnos> result = new List <Ymnos>();

            //включаем фильтрацию
            //не берем ирмосы, катавасии и мученичны - если указано
            List <Ymnos> ymnis = odi.Troparia.FindAll(c => (UseMartyrion)
                                        ? c.Kind != YmnosKind.Irmos && c.Kind != YmnosKind.Katavasia
                                        : c.Kind != YmnosKind.Irmos && c.Kind != YmnosKind.Katavasia && c.Kind != YmnosKind.Martyrion);

            if (ymnis == null)
            {
                return(result);
            }

            //если есть ирмосы, вычитаем их количество
            int count = Count - IrmosCount;

            if (ymnis.Count >= count)
            {
                result.AddRange(ymnis.Take(count));
            }
            else
            {
                /*если заявленное количество больше того, что есть, выдаем с повторами
                 * например: 8 = 3 3 2
                 *           10= 4 4 3
                 */

                int appendedCount = 0;

                int i = 0;

                while (appendedCount < count)
                {
                    //округляем в большую сторону результат деления count на YmnosStructureCount
                    //в результате получаем, сколько раз необходимо повторять песнопение
                    int b = (int)Math.Ceiling((double)(count - appendedCount) / (ymnis.Count - i));

                    Ymnos ymnosToAdd = ymnis[i];

                    while (b > 0)
                    {
                        result.Add(new Ymnos(ymnosToAdd));

                        b--;
                        appendedCount++;
                    }

                    i++;
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public override DayElementBase Calculate(RuleHandlerSettings settings)
        {
            Kanonas result = null;
            Kanonas source = GetKanonas(settings);

            if (source != null)
            {
                result = new Kanonas()
                {
                    Acrostic   = source.Acrostic,
                    Annotation = source.Annotation,
                    Ihos       = source.Ihos,
                    Stihos     = source.Stihos
                };

                foreach (Odi odi in source.Odes)
                {
                    Odi o = new Odi()
                    {
                        Number = odi.Number
                    };

                    //добавляем ирмос(ы)
                    Ymnos irmos = odi.Troparia.Find(c => c.Kind == YmnosKind.Irmos);

                    int troparia = IrmosCount;
                    while (troparia > 0)
                    {
                        o.Troparia.Add(irmos);
                        troparia--;
                    }

                    //добавляем тропари
                    o.Troparia.AddRange(GetYmnis(odi));

                    //if (IncludeKatavasia
                    //     && (odi.Number == 3 || odi.Number == 6 || odi.Number == 8 || odi.Number == 9))
                    //{
                    //    //добавляем ирмос в качестве катавасии
                    //    Ymnos katavasia = new Ymnos(irmos)
                    //    {
                    //        Kind = YmnosKind.Katavasia
                    //    };
                    //    o.Troparia.Add(katavasia);
                    //}

                    //добавляем саму песнь
                    result.Odes.Add(o);
                }
            }

            return(result);
        }
Exemplo n.º 4
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
                });
            }
        }
Exemplo n.º 5
0
        public DayElementBase CalculateEveryDayKatavasia(RuleHandlerSettings settings)
        {
            Kanonas result = null;
            Kanonas source = GetKanonas(settings);

            if (source != null)
            {
                result = new Kanonas()
                {
                    Acrostic   = source.Acrostic,
                    Annotation = source.Annotation,
                    Ihos       = source.Ihos,
                    Stihos     = source.Stihos
                };

                foreach (Odi odi in source.Odes)
                {
                    Odi o = new Odi()
                    {
                        Number = odi.Number
                    };

                    //ирмос
                    Ymnos irmos = odi.Troparia.Find(c => c.Kind == YmnosKind.Irmos);

                    if ((odi.Number == 3 || odi.Number == 6 || odi.Number == 8 || odi.Number == 9))
                    {
                        //добавляем ирмос в качестве катавасии
                        Ymnos katavasia = new Ymnos(irmos)
                        {
                            Kind = YmnosKind.Katavasia
                        };
                        o.Troparia.Add(katavasia);
                    }

                    //добавляем саму песнь
                    result.Odes.Add(o);
                }
            }

            return(result);
        }