Ejemplo n.º 1
0
        public void GoPoemBegining()
        {
            PoemLine curLine = this.CurrentLine;

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

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

                    bool isFirstLine = curPoem.IsFirstLine(curLine);

                    if (!isFirstLine)
                    {
                        SetOneLine(curPoem.GetFirstLine());
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override string ToString()
        {
            string result = string.Empty;

            if (!string.IsNullOrEmpty(this.Name))
            {
                result = this.Name;
            }

            PoemLine line = null;

            if (this.Lines.Count > 0)
            {
                line = this.Lines[0];
            }
            else if (this.Parts.Count > 0 && this.Parts[0].Lines.Count > 0)
            {
                line = this.Parts[0].Lines[0];
            }

            if (line != null)
            {
                result += (!string.IsNullOrEmpty(result) ? " - " : string.Empty) + line.ToString();
            }

            if (!string.IsNullOrEmpty(result))
            {
                return(result);
            }
            else
            {
                return(base.ToString());
            }
        }
Ejemplo n.º 3
0
        public void GoBlockPreviousOrBegining()
        {
            PoemLine curLine = this.CurrentLine;

            if (systemAccumulation != null)
            {
                if (curLine == null)
                {
                    curLine = systemAccumulation.GetLastLine();
                }
                else
                {
                    bool isFirstLine = curLine.ParentPoem.ParentBlock.IsFirstLine(curLine);

                    if (!isFirstLine)
                    {
                        curLine = curLine.ParentPoem.ParentBlock.GetFirstLine();
                    }
                    else
                    {
                        curLine = this.GenerateNextBlock(curLine, false);
                    }
                }
            }

            SetOneLine(curLine);
        }
Ejemplo n.º 4
0
        public void GoBlockBegining()
        {
            PoemLine curLine = this.CurrentLine;

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

                    SetOneLine(curLine);
                }
                else
                {
                    SABlock curBlock = curLine.ParentPoem.ParentBlock;

                    bool isFirstLine = curBlock.IsFirstLine(curLine);

                    if (!isFirstLine)
                    {
                        SetOneLine(curBlock.GetFirstLine());
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void GoLineNext()
        {
            PoemLine curLine = this.CurrentLine;

            if (systemAccumulation != null)
            {
                if (curLine == null)
                {
                    curLine = systemAccumulation.GetFirstLine();
                }
                else
                {
                    curLine = this.mySAIterator.GetNextLine(curLine, true);
                }
            }

            if (curLine != null)
            {
                selectedLines.Add(curLine);
            }

            //this.HistoryNextLines.Clear();
            //OnHistoryChanged();

            while (selectedLines.Count > selectedLinesCount)
            {
                selectedLines.RemoveAt(0);
            }

            OnCurrentLineChanged();
        }
Ejemplo n.º 6
0
        public void MoveHistoryNextLine()
        {
            if (CanMoveHistoryNextLine)
            {
                PoemLine curLine = this.CurrentLine;
                PoemLine line    = HistoryNextLines[0];

                selectedLines.Clear();
                selectedLines.Add(line);

                if (curLine != null)
                {
                    HistoryPreviousLines.Insert(0, curLine);

                    while (HistoryPreviousLines.Count > maxHistoryElement)
                    {
                        HistoryPreviousLines.RemoveAt(HistoryPreviousLines.Count - 1);
                    }
                }

                HistoryNextLines.RemoveAt(0);

                OnHistoryChanged();
                OnCurrentLineChanged();
            }
        }
Ejemplo n.º 7
0
        public void MoveHistoryPreviousLineByIndex(int itemIndex)
        {
            if (CanMoveHistoryPreviousLine)
            {
                PoemLine curLine = this.CurrentLine;
                if (curLine != null)
                {
                    HistoryNextLines.Insert(0, curLine);
                }

                for (int index = 0; index < itemIndex; index++)
                {
                    HistoryNextLines.Insert(0, HistoryPreviousLines[index]);
                }

                for (int i = 0; i < itemIndex; i++)
                {
                    HistoryPreviousLines.RemoveAt(0);
                }

                PoemLine line = HistoryPreviousLines[0];

                selectedLines.Clear();
                selectedLines.Add(line);

                HistoryPreviousLines.RemoveAt(0);

                OnHistoryChanged();
                OnCurrentLineChanged();
            }
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        private void SetOneLine(PoemLine line)
        {
            PoemLine curLine = this.CurrentLine;

            selectedLines.Clear();

            if (line != null)
            {
                selectedLines.Add(line);

                if (curLine != null && curLine != line)
                {
                    HistoryPreviousLines.Insert(0, curLine);
                    HistoryNextLines.Clear();

                    while (HistoryPreviousLines.Count > maxHistoryElement)
                    {
                        HistoryPreviousLines.RemoveAt(HistoryPreviousLines.Count - 1);
                    }
                }
            }

            OnHistoryChanged();
            OnCurrentLineChanged();
        }
Ejemplo n.º 10
0
 public void SetCurrentLine(PoemLine line)
 {
     if (CurrentLine != line)
     {
         SetOneLine(line);
     }
 }
Ejemplo n.º 11
0
        private static XmlNode CreatePoemLineNode(PoemLine poemLine, XmlDocument saXmlFile)
        {
            XmlNode result = saXmlFile.CreateElement(xmlNodeNamePoemLine);

            result.InnerText = poemLine.Line;

            return(result);
        }
Ejemplo n.º 12
0
        public void SetCurrentLineByID(PoemLineIdentifier curLine)
        {
            PoemLine line = systemAccumulation.GetLineByID(curLine);

            if (line != null)
            {
                SetOneLine(line);
            }
        }
Ejemplo n.º 13
0
        public void SetCurrentLine(SABlockPart blockPart)
        {
            PoemLine line = blockPart.GetFirstLine();

            if (CurrentLine != line)
            {
                SetOneLine(line);
            }
        }
Ejemplo n.º 14
0
        public void SetCurrentLine(Poem poem)
        {
            PoemLine line = poem.GetFirstLine();

            if (CurrentLine != line)
            {
                SetOneLine(line);
            }
        }
Ejemplo n.º 15
0
        public PoemLineIdentifier GetCurrentLineID()
        {
            PoemLine curLine = this.CurrentLine;

            if (curLine != null)
            {
                return(curLine.GetID());
            }

            return(null);
        }
Ejemplo n.º 16
0
        private PoemLine GenerateNextBlockPart(PoemLine currentLine, bool forward)
        {
            if (currentLine.ParentPoem.ParentBlockPart != null)
            {
                SABlockPart nextPart = this.mySAIterator.GetNextBlockPart(currentLine.ParentPoem.ParentBlockPart, forward);
                if (nextPart != null)
                {
                    return(nextPart.GetFirstLine());
                }
            }

            return(GenerateNextBlock(currentLine, forward));
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
        public void GetRandomLine()
        {
            PoemLine result = null;

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

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

                result = systemAccumulation.GetLineByIndex(randomIndex);
            }

            SetOneLine(result);
        }
Ejemplo n.º 19
0
        public void GetRandomLine(SABlock block)
        {
            PoemLine result = null;

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

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

                result = block.GetLineByIndex(randomIndex);
            }

            SetOneLine(result);
        }
Ejemplo n.º 20
0
        public void GetRandomPoem()
        {
            PoemLine result = null;

            if (systemAccumulation != null)
            {
                int poemCount = systemAccumulation.PoemCount;

                int randomPoemIndex = CommonOperations.rnd.Next(poemCount);

                Poem randomPoem = systemAccumulation.GetPoemByIndex(randomPoemIndex);

                result = randomPoem.GetFirstLine();
            }

            SetOneLine(result);
        }
Ejemplo n.º 21
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);
        }
Ejemplo n.º 22
0
        public void GetRandomBlockPart(SABlock block)
        {
            PoemLine result = null;

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

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

                SABlockPart blockPart = block.Parts[randomIndex];

                result = blockPart.GetFirstLine();
            }

            SetOneLine(result);
        }
Ejemplo n.º 23
0
        public void GetRandomPoem(SABlockPart blockPart)
        {
            PoemLine result = null;

            if (blockPart != null)
            {
                int poemCount = blockPart.PoemCount;

                int randomPoemIndex = CommonOperations.rnd.Next(poemCount);

                Poem randomPoem = blockPart.GetPoemByIndex(randomPoemIndex);

                result = randomPoem.GetFirstLine();
            }

            SetOneLine(result);
        }
Ejemplo n.º 24
0
        public void GetRandomBlock()
        {
            PoemLine result = null;

            if (systemAccumulation != null)
            {
                int blockCount = systemAccumulation.Blocks.Count;

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

                SABlock block = systemAccumulation.Blocks[randomIndex];

                result = block.GetFirstLine();
            }

            SetOneLine(result);
        }
Ejemplo n.º 25
0
        public void GoBlockPrevious()
        {
            PoemLine curLine = this.CurrentLine;

            if (systemAccumulation != null)
            {
                if (curLine == null)
                {
                    curLine = systemAccumulation.GetLastLine();
                }
                else
                {
                    curLine = this.GenerateNextBlock(curLine, false);
                }
            }

            SetOneLine(curLine);
        }
Ejemplo n.º 26
0
        public void GoPoemPartNext()
        {
            PoemLine result = this.CurrentLine;

            if (systemAccumulation != null)
            {
                if (result == null)
                {
                    result = systemAccumulation.GetFirstLine();
                }
                else
                {
                    result = this.GenerateNextPoemPart(result, true);
                }
            }

            SetOneLine(result);
        }
Ejemplo n.º 27
0
        public void GoBlockNext()
        {
            PoemLine curLine = this.CurrentLine;

            if (systemAccumulation != null)
            {
                if (curLine == null)
                {
                    curLine = systemAccumulation.GetFirstLine();
                }
                else
                {
                    curLine = this.GenerateNextBlock(curLine, true);
                }
            }

            SetOneLine(curLine);
        }
Ejemplo n.º 28
0
        public void GoPoemPartPrevious()
        {
            PoemLine result = this.CurrentLine;

            if (SystemAccumulation != null)
            {
                if (result == null)
                {
                    result = SystemAccumulation.GetLastLine();
                }
                else
                {
                    result = this.GenerateNextPoemPart(result, false);
                }
            }

            SetOneLine(result);
        }
Ejemplo n.º 29
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);
        }
Ejemplo n.º 30
0
        private static Collection <PoemLine> GetLines(string text)
        {
            Collection <PoemLine> result = new Collection <PoemLine>();

            string[] splitBlockParts = text.Trim('\n').Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string itemText in splitBlockParts)
            {
                string newLineText = itemText.Trim();

                string testText = newLineText.Replace(".", "");
                testText = newLineText.Replace(" ", "");

                if (!string.IsNullOrEmpty(testText))
                {
                    PoemLine newLine = new PoemLine(newLineText);

                    result.Add(newLine);
                }
            }

            return(result);
        }