Example #1
0
        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);
        }
Example #2
0
        public ControlPoemLine(PoemLine line)
            : this()
        {
            this.PoemLine = line;

            this.lblText.Text = this.PoemLine.Line;

            LineIsStart lineStatus = line.LineStartStatus;

            int height = 0;

            if ((lineStatus & LineIsStart.OfBlock) != 0)
            {
                height = 50;
            }
            else if ((lineStatus & LineIsStart.OfBlockPart) != 0)
            {
                height = 40;
            }
            else if ((lineStatus & LineIsStart.OfPoem) != 0)
            {
                height = 30;
            }
            else if ((lineStatus & LineIsStart.OfPoemPart) != 0)
            {
                height = 20;
            }

            picBox.Image = Common.GetImageByLine(line);

            this.Padding = new Padding(0, height, 0, 0);
            this.Height += height;
        }
 protected void OnLineSelectionChanged(PoemLine line)
 {
     if (LineSelectionChanged != null)
     {
         LineSelectionChanged(this, new SelectInTreeEventArgs(line));
     }
 }
        private void tSMIOpenInTree_Click(object sender, EventArgs e)
        {
            if (lVSearchResult.SelectedItems.Count == 1)
            {
                ListViewItem item = lVSearchResult.SelectedItems[0];

                PoemLine line = item.Tag as PoemLine;
                if (line != null)
                {
                    this.Hide();
                    OnLineSelectionChanged(line);
                }
            }
        }
        private void OpenFormSAConfig(PoemLine line)
        {
            FormSAConfig form = GetFormSAConfig();

            form.Owner = this;

            if (line != null)
            {
                form.SelectInTree(line);
            }

            form.Activate();
            form.Show();
        }
Example #6
0
        public XNode ToXML()
        {
            XElement xStanza = new XElement(Fb2Const.fb2DefaultNamespace + Fb2StanzaElementName);

            if (!string.IsNullOrEmpty(Lang))
            {
                xStanza.Add(new XAttribute(XNamespace.Xml + "lang", Lang));
            }
            if (Title != null)
            {
                xStanza.Add(Title.ToXML());
            }
            if (SubTitle != null)
            {
                xStanza.Add(SubTitle.ToXML());
            }
            foreach (VPoemParagraph PoemLine in lines)
            {
                xStanza.Add(PoemLine.ToXML());
            }
            return(xStanza);
        }
Example #7
0
        internal static Image GetImageByLine(PoemLine line)
        {
            LineIsStart lineStatus = line.LineStartStatus;

            if ((lineStatus & LineIsStart.OfBlock) != 0)
            {
                return(Resources.SABlock);
            }
            else if ((lineStatus & LineIsStart.OfBlockPart) != 0)
            {
                return(Resources.SABlockPart);
            }
            else if ((lineStatus & LineIsStart.OfPoem) != 0)
            {
                return(Resources.Poem);
            }
            else if ((lineStatus & LineIsStart.OfPoemPart) != 0)
            {
                return(Resources.PoemPart);
            }

            return(null);
        }
Example #8
0
        public void SelectInTree(PoemLine line)
        {
            PoemPart poemPart = line.ParentPoemPart;
            Poem     poem     = line.ParentPoem;

            SABlockPart blockPart = poem.ParentBlockPart;
            SABlock     block     = poem.ParentBlock;

            SA sa = block.ParentSA;

            if (tVSA.Nodes.Count == 0)
            {
                return;
            }

            TreeNode nodeSA = tVSA.Nodes[0];

            if (nodeSA.Tag != sa)
            {
                return;
            }

            TreeNode nodeBlock = null;

            foreach (TreeNode item in nodeSA.Nodes)
            {
                if (item.Tag == block)
                {
                    nodeBlock = item;
                    break;
                }
            }

            if (nodeBlock == null)
            {
                return;
            }

            if (blockPart != null)
            {
                TreeNode nodeBlockPart = null;

                foreach (TreeNode item in nodeBlock.Nodes)
                {
                    if (item.Tag == blockPart)
                    {
                        nodeBlockPart = item;
                        break;
                    }
                }

                if (nodeBlockPart == null)
                {
                    return;
                }

                nodeBlock = nodeBlockPart;
            }

            TreeNode nodePoem = null;

            foreach (TreeNode item in nodeBlock.Nodes)
            {
                if (item.Tag == poem)
                {
                    nodePoem = item;
                    break;
                }
            }

            if (nodePoem == null)
            {
                return;
            }

            if (poemPart != null)
            {
                TreeNode nodePoemPart = null;

                foreach (TreeNode item in nodeBlock.Nodes)
                {
                    if (item.Tag == poemPart)
                    {
                        nodePoemPart = item;
                        break;
                    }
                }

                if (nodePoemPart == null)
                {
                    return;
                }

                nodePoem = nodePoemPart;
            }

            TreeNode nodeLine = null;

            foreach (TreeNode item in nodePoem.Nodes)
            {
                if (item.Tag == line)
                {
                    nodeLine = item;
                    break;
                }
            }

            if (nodeLine != null)
            {
                tVSA.BeginUpdate();

                tVSA.CollapseAll();
                tVSA.SelectedNode = nodeLine;
                nodeLine.EnsureVisible();

                tVSA.EndUpdate();
            }
        }
        //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());
            }
        }
        private void OperateLines()
        {
            if (saController.CurrentLine != null)
            {
                PoemLine curLine = saController.CurrentLine;

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

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

                if (cmBSABlock.Items.Contains(curBlock))
                {
                    if (cmBSABlock.SelectedItem != curBlock)
                    {
                        BeginUpdate();

                        cmBSABlock.SelectedItem = curBlock;

                        FillSABlockElements(curBlock);

                        EndUpdate();
                    }
                }

                if (curBlockPart != null)
                {
                    if (!cmBSABlockPart.Items.Contains(curBlockPart))
                    {
                        FillSABlockElements(curBlock);
                    }

                    if (cmBSABlockPart.SelectedItem != curBlockPart)
                    {
                        BeginUpdate();

                        cmBSABlockPart.SelectedItem = curBlockPart;

                        FillPoems(curBlockPart.Poems);

                        EndUpdate();
                    }
                }
                else
                {
                    cmBSABlockPart.Items.Clear();
                }

                {
                    if (!cmBPoem.Items.Contains(curPoem))
                    {
                        if (curBlockPart != null)
                        {
                            FillPoems(curBlockPart.Poems);
                        }
                        else
                        {
                            FillPoems(curBlock.Poems);
                        }
                    }

                    if (cmBPoem.SelectedItem != curPoem)
                    {
                        BeginUpdate();

                        cmBPoem.SelectedItem = curPoem;

                        EndUpdate();
                    }
                }

                if (curPoemPart != null)
                {
                    if (!cmBPoemPart.Items.Contains(curPoemPart))
                    {
                        FillPoemParts(curPoem.Parts);
                    }

                    if (cmBPoemPart.SelectedItem != curPoemPart)
                    {
                        BeginUpdate();

                        cmBPoemPart.SelectedItem = curPoemPart;

                        EndUpdate();
                    }
                }
                else
                {
                    cmBPoemPart.Items.Clear();
                }
            }
            else
            {
                cmBSABlock.SelectedIndex = -1;

                cmBSABlockPart.Items.Clear();
                cmBPoem.Items.Clear();
                cmBPoemPart.Items.Clear();
            }

            gBSABlockPart.Enabled = cmBSABlockPart.Items.Count > 0;
            gBPoem.Enabled        = cmBPoem.Items.Count > 0;
            gBPoemPart.Enabled    = cmBPoemPart.Items.Count > 0;

            {
                Collection <ControlPoemLine> controlsToDelete = new Collection <ControlPoemLine>();

                foreach (Control item in panelLines.Controls)
                {
                    ControlPoemLine controlPoemLine = item as ControlPoemLine;
                    if (controlPoemLine != null)
                    {
                        if (!saController.SelectedLines.Contains(controlPoemLine.PoemLine))
                        {
                            controlsToDelete.Add(controlPoemLine);
                        }
                    }
                }

                panelLines.SuspendLayout();

                foreach (ControlPoemLine item in controlsToDelete)
                {
                    panelLines.Controls.Remove(item);
                }

                foreach (PoemLine line in saController.SelectedLines)
                {
                    ControlPoemLine controlPoemLine = null;
                    foreach (Control item in panelLines.Controls)
                    {
                        ControlPoemLine searchControlPoemLine = item as ControlPoemLine;
                        if (searchControlPoemLine != null)
                        {
                            if (searchControlPoemLine.PoemLine == line)
                            {
                                controlPoemLine = searchControlPoemLine;
                                break;
                            }
                        }
                    }

                    if (controlPoemLine == null)
                    {
                        controlPoemLine      = new ControlPoemLine(line);
                        controlPoemLine.Dock = DockStyle.Bottom;

                        panelLines.Controls.Add(controlPoemLine);
                    }

                    int childIndex = panelLines.Controls.GetChildIndex(controlPoemLine);
                    if (childIndex != saController.SelectedLines.IndexOf(line))
                    {
                        panelLines.Controls.SetChildIndex(controlPoemLine, saController.SelectedLines.IndexOf(line));
                    }
                }

                panelLines.ResumeLayout(true);
            }

            panelLines.Select();
        }
Example #11
0
 public SelectInTreeEventArgs(PoemLine line)
 {
     this.Line = line;
 }