private void TestController() { Controller saController = new Controller(); saController.SystemAccumulation = Engine.controller.SystemAccumulation; IteratorSA iter = new IteratorSA(); PoemLine firstLine = Engine.controller.SystemAccumulation.GetFirstLine(); PoemLine curLine = firstLine; do { saController.SetCurrentLine(curLine); PoemLineIdentifier position = saController.GetCurrentLineID(); saController.Clear(); saController.SetCurrentLineByID(position); if (saController.CurrentLine != curLine) { MessageBox.Show("Ошибка"); } curLine = iter.GetNextLine(curLine, true); } while (curLine != firstLine); }
//public void LoadConfigurationFromFile(string fileName) //{ // if (!File.Exists(fileName)) // { // return; // } // XmlDocument saXmlFile = new XmlDocument(); // saXmlFile.Load(fileName); // XmlNode node = saXmlFile[objName]; // if (node != null) // { // LoadConfigurationFromNode(node); // } //} public void LoadConfigurationFromNode(XmlNode nodeControllerConfig) { //{ // XmlNode nodeCurrentPosition = nodeControllerConfig[objCurrentPosition]; // if (nodeCurrentPosition != null && nodeCurrentPosition.ChildNodes.Count == 1) // { // PoemLineIdentifier lineId = PoemLineIdentifier.CreateFromXmlNode(nodeCurrentPosition.ChildNodes[0]); // PoemLine line = systemAccumulation.GetLineByID(lineId); // if (line != null) // { // selectedLines.Clear(); // selectedLines.Add(line); // } // } //} { this.selectedLines.Clear(); XmlNode nodeSelectedLines = nodeControllerConfig[objSelectedLines]; if (nodeSelectedLines != null) { foreach (XmlNode node in nodeSelectedLines) { PoemLineIdentifier lineId = PoemLineIdentifier.CreateFromXmlNode(node); if (lineId != null) { PoemLine line = systemAccumulation.GetLineByID(lineId); if (line != null) { bool addLine = true; if (this.selectedLines.Count > 0) { PoemLine lastLine = selectedLines[selectedLines.Count - 1]; PoemLine nextLine = mySAIterator.GetNextLine(lastLine, true); addLine = nextLine == line; } else { addLine = true; } if (addLine) { this.selectedLines.Add(line); } } } } } while (this.selectedLines.Count > this.selectedLinesCount) { this.selectedLines.RemoveAt(0); } } { this.HistoryPreviousLines.Clear(); XmlNode nodePreviousLines = nodeControllerConfig[objHistoryPreviousLines]; if (nodePreviousLines != null) { foreach (XmlNode node in nodePreviousLines) { PoemLineIdentifier lineId = PoemLineIdentifier.CreateFromXmlNode(node); if (lineId != null) { PoemLine line = systemAccumulation.GetLineByID(lineId); if (line != null) { this.HistoryPreviousLines.Add(line); } } } } while (HistoryPreviousLines.Count > maxHistoryElement) { HistoryPreviousLines.RemoveAt(HistoryPreviousLines.Count - 1); } } { this.HistoryNextLines.Clear(); XmlNode nodeNextLines = nodeControllerConfig[objHistoryNextLines]; if (nodeNextLines != null) { foreach (XmlNode node in nodeNextLines) { PoemLineIdentifier lineId = PoemLineIdentifier.CreateFromXmlNode(node); if (lineId != null) { PoemLine line = systemAccumulation.GetLineByID(lineId); if (line != null) { this.HistoryNextLines.Add(line); } } } } } OnCurrentLineChanged(); OnHistoryChanged(); }