Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private void SearchInLineCollection(string searchPattern, PoemLinesCollection poemLines, Collection <PoemLine> result)
        {
            foreach (PoemLine item in poemLines)
            {
                string line = item.Line;

                if (CommonOperations.MatchPattern(line, searchPattern))
                {
                    result.Add(item);
                }
            }
        }
Ejemplo n.º 3
0
        private void FillPoemLineCollection(TreeNode parentNode, PoemLinesCollection lines)
        {
            foreach (PoemLine poemLine in lines)
            {
                TreeNode nodeLine = new TreeNode();
                nodeLine.Text = poemLine.ToString();
                nodeLine.Tag  = poemLine;

                nodeLine.ImageKey         = nodeLine.SelectedImageKey = "PoemLine";
                nodeLine.ContextMenuStrip = contMSTreeNode;

                parentNode.Nodes.Add(nodeLine);
            }
        }
Ejemplo n.º 4
0
 public PoemPart()
 {
     this.Lines = new PoemLinesCollection(this);
 }
Ejemplo n.º 5
0
        internal PoemLine GetLineByID(PoemLineIdentifier lineId)
        {
            SABlock block = null;

            if (!string.IsNullOrEmpty(lineId.BlockName))
            {
                SABlock[] searchBlocks = this.GetBlockByName(lineId.BlockName);

                if (searchBlocks.Length == 1)
                {
                    block = searchBlocks[0];
                }
                else if (searchBlocks.Length > 1)
                {
                    foreach (SABlock item in searchBlocks)
                    {
                        if (this.Blocks.IndexOf(item) == lineId.BlockIndex)
                        {
                            block = item;
                            break;
                        }
                    }
                }
            }

            if (block == null)
            {
                return(null);
            }

            PoemCollection poemColl = null;

            if (!string.IsNullOrEmpty(lineId.BlockPartFirstLine) && lineId.BlockPartIndex.HasValue)
            {
                SABlockPart[] searchBlockParts = block.GetPartsByFirstLine(lineId.BlockPartFirstLine);

                if (searchBlockParts.Length == 1)
                {
                    poemColl = searchBlockParts[0].Poems;
                }
                else if (searchBlockParts.Length > 1)
                {
                    foreach (SABlockPart item in searchBlockParts)
                    {
                        if (block.Parts.IndexOf(item) == lineId.BlockPartIndex)
                        {
                            poemColl = item.Poems;
                            break;
                        }
                    }
                }
            }
            else
            {
                poemColl = block.Poems;
            }

            if (poemColl == null)
            {
                return(null);
            }

            Poem poem = null;

            if (!string.IsNullOrEmpty(lineId.PoemFirstLine) && lineId.PoemIndex.HasValue)
            {
                Poem[] searchBlockParts = poemColl.GetPoemsByFirstLine(lineId.PoemFirstLine);

                if (searchBlockParts.Length == 1)
                {
                    poem = searchBlockParts[0];
                }
                else if (searchBlockParts.Length > 1)
                {
                    foreach (Poem item in searchBlockParts)
                    {
                        if (poemColl.IndexOf(item) == lineId.PoemIndex)
                        {
                            poem = item;
                            break;
                        }
                    }
                }
            }

            if (poem == null)
            {
                return(null);
            }


            PoemLinesCollection linesColl = null;

            if (!string.IsNullOrEmpty(lineId.PoemPartFirstLine) && lineId.PoemPartIndex.HasValue)
            {
                PoemPart[] searchBlockParts = poem.GetPartsByFirstLine(lineId.PoemPartFirstLine);

                if (searchBlockParts.Length == 1)
                {
                    linesColl = searchBlockParts[0].Lines;
                }
                else if (searchBlockParts.Length > 1)
                {
                    foreach (PoemPart item in searchBlockParts)
                    {
                        if (poem.Parts.IndexOf(item) == lineId.PoemPartIndex)
                        {
                            linesColl = item.Lines;
                            break;
                        }
                    }
                }
            }
            else
            {
                linesColl = poem.Lines;
            }

            if (linesColl == null)
            {
                return(null);
            }


            PoemLine line = null;

            if (!string.IsNullOrEmpty(lineId.LineString) && lineId.LineIndex.HasValue)
            {
                PoemLine[] searchBlockParts = linesColl.GetPoemsByFirstLine(lineId.LineString);

                if (searchBlockParts.Length == 1)
                {
                    line = searchBlockParts[0];
                }
                else if (searchBlockParts.Length > 1)
                {
                    foreach (PoemLine item in searchBlockParts)
                    {
                        if (linesColl.IndexOf(item) == lineId.LineIndex)
                        {
                            line = item;
                            break;
                        }
                    }
                }
            }

            if (line == null)
            {
                return(null);
            }

            return(line);
        }
Ejemplo n.º 6
0
        //public SA SystemAccumulation { get; set; }

        public PoemLine GetNextLine(PoemLine currentLine, bool forward)
        {
            {
                PoemLinesCollection coll = null;

                if (currentLine.ParentPoemPart != null)
                {
                    coll = currentLine.ParentPoemPart.Lines;
                }
                else
                {
                    coll = currentLine.ParentPoem.Lines;
                }

                int indexLine = coll.IndexOf(currentLine);
                if (indexLine != -1)
                {
                    int nextIndex = indexLine + (forward ? 1 : -1);

                    if (0 <= nextIndex && nextIndex < coll.Count)
                    {
                        return(coll[nextIndex]);
                    }
                }
            }

            if (currentLine.ParentPoemPart != null)
            {
                PoemPart nextPoemPart = GetNextPoemPart(currentLine.ParentPoemPart, forward);

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

            {
                Poem nextPoem = GetNextPoem(currentLine.ParentPoem, forward);
                if (nextPoem != null)
                {
                    if (forward)
                    {
                        return(nextPoem.GetFirstLine());
                    }
                    else
                    {
                        return(nextPoem.GetLastLine());
                    }
                }
            }

            if (currentLine.ParentPoem.ParentBlockPart != null)
            {
                SABlockPart nextPart = GetNextBlockPart(currentLine.ParentPoem.ParentBlockPart, forward);
                if (nextPart != null)
                {
                    if (forward)
                    {
                        return(nextPart.GetFirstLine());
                    }
                    else
                    {
                        return(nextPart.GetLastLine());
                    }
                }
            }

            {
                SABlock nextBlock = GetNextBlock(currentLine.ParentPoem.ParentBlock, forward);
                if (nextBlock != null)
                {
                    if (forward)
                    {
                        return(nextBlock.GetFirstLine());
                    }
                    else
                    {
                        return(nextBlock.GetLastLine());
                    }
                }
            }

            if (forward)
            {
                return(currentLine.ParentPoem.ParentBlock.ParentSA.GetFirstLine());
            }
            else
            {
                return(currentLine.ParentPoem.ParentBlock.ParentSA.GetLastLine());
            }
        }
Ejemplo n.º 7
0
 public Poem()
 {
     this.Parts = new PoemPartCollection(this);
     this.Lines = new PoemLinesCollection(this);
 }