public string GetFullInfo()
        {
            StringBuilder strBuilder = new StringBuilder();

            PoemPart    curPoemPart  = this.ParentPoemPart;
            Poem        curPoem      = this.ParentPoem;
            SABlockPart curBlockPart = curPoem.ParentBlockPart;
            SABlock     curBlock     = curPoem.ParentBlock;

            strBuilder.AppendFormat("Блок: {0}", curBlock.ToString());

            if (curBlockPart != null)
            {
                strBuilder.AppendLine();
                strBuilder.AppendFormat("Часть блока: {0}", curBlockPart.ToString());
            }

            strBuilder.AppendLine();
            strBuilder.AppendFormat("Стих: {0}", curPoem.ToString());

            if (curPoemPart != null)
            {
                strBuilder.AppendLine();
                strBuilder.AppendFormat("Часть стиха: {0}", curPoemPart.ToString());
            }

            return(strBuilder.ToString());
        }
        private static Collection <PoemPart> GetPoemParts(string fullText)
        {
            Collection <PoemPart> result = new Collection <PoemPart>();

            string[] splitPoemParts = fullText.Trim('\n').Split(new string[] { PoemPartSplitter }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string itemText in splitPoemParts)
            {
                string name = string.Empty;
                string text = CutName(itemText, out name);

                PoemPart newPoemPart = new PoemPart();
                newPoemPart.Name = name;

                result.Add(newPoemPart);

                Collection <PoemLine> poems = GetLines(text);
                foreach (PoemLine item in poems)
                {
                    newPoemPart.Lines.Add(item);
                }
            }

            return(result);
        }
Exemple #3
0
        internal PoemPart[] GetPartsByFirstLine(string firstLine)
        {
            int count = 0;

            foreach (PoemPart item in this.Parts)
            {
                string itemFirstLine = item.GetFirstLine().Line;

                if (string.Compare(itemFirstLine, firstLine, true) == 0)
                {
                    count++;
                }
            }

            PoemPart[] result = new PoemPart[count];

            count = 0;

            foreach (PoemPart item in this.Parts)
            {
                string itemFirstLine = item.GetFirstLine().Line;

                if (string.Compare(itemFirstLine, firstLine, true) == 0)
                {
                    result[count] = item;
                    count++;
                }
            }

            return(result);
        }
Exemple #4
0
        private static PoemPart CreatePoemPartFromXml(XmlNode itemPart)
        {
            PoemPart result = new PoemPart();

            XmlAttribute attr;

            attr = itemPart.Attributes[xmlFieldName];
            if (attr != null)
            {
                result.Name = attr.Value;
            }

            XmlNode nodePoems = itemPart[xmlNodeNamePoemLineCollection];

            if (nodePoems != null)
            {
                foreach (XmlNode itemPoem in nodePoems)
                {
                    PoemLine lines = CreatePoemLineFromXml(itemPoem);

                    result.Lines.Add(lines);
                }
            }

            return(result);
        }
Exemple #5
0
        public void SetCurrentLine(PoemPart poemPart)
        {
            PoemLine line = poemPart.GetFirstLine();

            if (CurrentLine != line)
            {
                SetOneLine(line);
            }
        }
        internal PoemLineIdentifier GetID()
        {
            PoemLineIdentifier result = new PoemLineIdentifier();

            result.LineString = this.Line;

            PoemPart curPoemPart = this.ParentPoemPart;
            Poem     curPoem     = this.ParentPoem;

            result.PoemName      = curPoem.Name;
            result.PoemFirstLine = curPoem.GetFirstLine().Line;

            PoemLinesCollection collLines = null;

            if (curPoemPart != null)
            {
                collLines = curPoemPart.Lines;

                result.PoemPartName      = curPoemPart.Name;
                result.PoemPartFirstLine = curPoemPart.GetFirstLine().Line;
                result.PoemPartIndex     = curPoem.Parts.IndexOf(curPoemPart);
            }
            else
            {
                collLines = curPoem.Lines;
            }

            result.LineIndex = collLines.IndexOf(this);

            SABlockPart curBlockPart = curPoem.ParentBlockPart;
            SABlock     curBlock     = curPoem.ParentBlock;

            result.BlockName  = curBlock.Name;
            result.BlockIndex = curBlock.ParentSA.Blocks.IndexOf(curBlock);


            PoemCollection collPoems = null;

            if (curBlockPart != null)
            {
                collPoems = curBlockPart.Poems;

                result.BlockPartName      = curBlockPart.Name;
                result.BlockPartFirstLine = curBlockPart.GetFirstLine().Line;
                result.BlockPartIndex     = curBlock.Parts.IndexOf(curBlockPart);
            }
            else
            {
                collPoems = curBlock.Poems;
            }

            result.PoemIndex = collPoems.IndexOf(curPoem);

            return(result);
        }
Exemple #7
0
        private PoemLine GenerateNextPoemPart(PoemLine currentLine, bool forward)
        {
            if (currentLine.ParentPoemPart != null)
            {
                PoemPart nextPoemPart = this.mySAIterator.GetNextPoemPart(currentLine.ParentPoemPart, forward);

                if (nextPoemPart != null)
                {
                    return(nextPoemPart.GetFirstLine());
                }
            }

            return(GenerateNextPoem(currentLine, forward));
        }
Exemple #8
0
        public void GetRandomLine(PoemPart poemPart)
        {
            PoemLine result = null;

            if (poemPart != null)
            {
                int lineCount = poemPart.LinesCount;

                int randomIndex = CommonOperations.rnd.Next(lineCount);

                result = poemPart.GetLineByIndex(randomIndex);
            }

            SetOneLine(result);
        }
Exemple #9
0
        public void GetRandomPoemPart(Poem poem)
        {
            PoemLine result = null;

            if (poem != null && poem.Parts.Count > 0)
            {
                int partsCount = poem.Parts.Count;

                int randomIndex = CommonOperations.rnd.Next(partsCount);

                PoemPart poemPart = poem.Parts[randomIndex];

                result = poemPart.GetFirstLine();
            }

            SetOneLine(result);
        }
Exemple #10
0
        private static Poem CreatePoemFromXml(XmlNode itemPoem)
        {
            Poem result = new Poem();

            XmlAttribute attr;

            attr = itemPoem.Attributes[xmlFieldName];
            if (attr != null)
            {
                result.Name = attr.Value;
            }

            XmlNode nodeParts = itemPoem[objNamePoemPartCollection];

            if (nodeParts != null)
            {
                foreach (XmlNode itemPart in nodeParts)
                {
                    PoemPart poemPart = CreatePoemPartFromXml(itemPart);

                    result.Parts.Add(poemPart);
                }
            }
            else
            {
                XmlNode nodeLines = itemPoem[xmlNodeNamePoemLineCollection];
                if (nodeLines != null)
                {
                    foreach (XmlNode itemLine in nodeLines)
                    {
                        PoemLine poemLine = CreatePoemLineFromXml(itemLine);

                        result.Lines.Add(poemLine);
                    }
                }
            }

            return(result);
        }
Exemple #11
0
        public void GoPoemPartBegining()
        {
            PoemLine curLine = this.CurrentLine;

            if (systemAccumulation != null)
            {
                if (curLine == null)
                {
                    curLine = systemAccumulation.GetFirstLine();

                    SetOneLine(curLine);
                }
                else
                {
                    PoemPart curPoemPart = curLine.ParentPoemPart;
                    Poem     curPoem     = curLine.ParentPoem;

                    if (curPoemPart != null)
                    {
                        bool isFirstLine = curPoemPart.IsFirstLine(curLine);

                        if (!isFirstLine)
                        {
                            SetOneLine(curPoemPart.GetFirstLine());
                        }
                    }
                    else
                    {
                        bool isFirstLine = curPoem.IsFirstLine(curLine);

                        if (!isFirstLine)
                        {
                            SetOneLine(curPoem.GetFirstLine());
                        }
                    }
                }
            }
        }
Exemple #12
0
        private static XmlNode CreatePoemPartNode(PoemPart part, XmlDocument saXmlFile)
        {
            XmlNode result = saXmlFile.CreateElement(xmlNodeNamePoemPart);

            XmlAttribute attr;

            attr = saXmlFile.CreateAttribute(xmlFieldName);
            result.Attributes.Append(attr);
            attr.Value = part.Name;

            XmlNode nodeLines = saXmlFile.CreateElement(xmlNodeNamePoemLineCollection);

            result.AppendChild(nodeLines);

            foreach (PoemLine poemLine in part.Lines)
            {
                XmlNode node = CreatePoemLineNode(poemLine, saXmlFile);

                nodeLines.AppendChild(node);
            }

            return(result);
        }