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()); } } } }
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()); } }
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); }
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()); } } } }
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(); }
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(); } }
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(); } }
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); }
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(); }
public void SetCurrentLine(PoemLine line) { if (CurrentLine != line) { SetOneLine(line); } }
private static XmlNode CreatePoemLineNode(PoemLine poemLine, XmlDocument saXmlFile) { XmlNode result = saXmlFile.CreateElement(xmlNodeNamePoemLine); result.InnerText = poemLine.Line; return(result); }
public void SetCurrentLineByID(PoemLineIdentifier curLine) { PoemLine line = systemAccumulation.GetLineByID(curLine); if (line != null) { SetOneLine(line); } }
public void SetCurrentLine(SABlockPart blockPart) { PoemLine line = blockPart.GetFirstLine(); if (CurrentLine != line) { SetOneLine(line); } }
public void SetCurrentLine(Poem poem) { PoemLine line = poem.GetFirstLine(); if (CurrentLine != line) { SetOneLine(line); } }
public PoemLineIdentifier GetCurrentLineID() { PoemLine curLine = this.CurrentLine; if (curLine != null) { return(curLine.GetID()); } return(null); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void GoBlockPrevious() { PoemLine curLine = this.CurrentLine; if (systemAccumulation != null) { if (curLine == null) { curLine = systemAccumulation.GetLastLine(); } else { curLine = this.GenerateNextBlock(curLine, false); } } SetOneLine(curLine); }
public void GoPoemPartNext() { PoemLine result = this.CurrentLine; if (systemAccumulation != null) { if (result == null) { result = systemAccumulation.GetFirstLine(); } else { result = this.GenerateNextPoemPart(result, true); } } SetOneLine(result); }
public void GoBlockNext() { PoemLine curLine = this.CurrentLine; if (systemAccumulation != null) { if (curLine == null) { curLine = systemAccumulation.GetFirstLine(); } else { curLine = this.GenerateNextBlock(curLine, true); } } SetOneLine(curLine); }
public void GoPoemPartPrevious() { PoemLine result = this.CurrentLine; if (SystemAccumulation != null) { if (result == null) { result = SystemAccumulation.GetLastLine(); } else { result = this.GenerateNextPoemPart(result, false); } } SetOneLine(result); }
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); }
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); }