Пример #1
0
        public SABlock GetNextBlock(SABlock block, bool forward)
        {
            SA parentSA = block.ParentSA;

            int indexBlock = parentSA.Blocks.IndexOf(block);

            if (indexBlock != -1)
            {
                int nextIndex = indexBlock + (forward ? 1 : -1);

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

            if (forward)
            {
                return(parentSA.GetFirstBlock());
            }
            else
            {
                return(parentSA.GetLastBlock());
            }
        }
Пример #2
0
        public Poem GetNextPoem(Poem poem, bool forward)
        {
            {
                PoemCollection coll = null;

                if (poem.ParentBlockPart != null)
                {
                    coll = poem.ParentBlockPart.Poems;
                }
                else
                {
                    coll = poem.ParentBlock.Poems;
                }

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

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

            if (poem.ParentBlockPart != null)
            {
                SABlockPart nextBlockPart = GetNextBlockPart(poem.ParentBlockPart, forward);

                if (nextBlockPart != null)
                {
                    if (forward)
                    {
                        return(nextBlockPart.GetFirstPoem());
                    }
                    else
                    {
                        return(nextBlockPart.GetLastPoem());
                    }
                }
            }

            {
                SABlock nextBlock = GetNextBlock(poem.ParentBlock, forward);

                if (forward)
                {
                    return(nextBlock.GetFirstPoem());
                }
                else
                {
                    return(nextBlock.GetLastPoem());
                }
            }
        }
Пример #3
0
        private void tSMIRandomBlockPart_Click(object sender, EventArgs e)
        {
            if (clickedNode != null && clickedNode.Tag != null && clickedNode.Tag is SABlock)
            {
                SABlock block = (SABlock)clickedNode.Tag;

                if (block.Parts.Count > 0)
                {
                    Engine.controller.GetRandomBlockPart(block);
                    this.Close();
                }
            }
        }
Пример #4
0
        private void cmBSABlock_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (IsUpdating())
            {
                return;
            }

            SABlock block = cmBSABlock.SelectedItem as SABlock;

            if (block != null)
            {
                saController.SetCurrentLine(block);
            }
        }
Пример #5
0
        private void FillSABlockElements(SABlock curBlock)
        {
            BeginUpdate();

            cmBSABlockPart.Items.Clear();

            foreach (SABlockPart item in curBlock.Parts)
            {
                cmBSABlockPart.Items.Add(item);
            }

            FillPoems(curBlock.Poems);

            EndUpdate();
        }
Пример #6
0
        public SABlockPart GetNextBlockPart(SABlockPart blockPart, bool forward)
        {
            SABlock parentBlock = blockPart.ParentBlock;

            int indexPart = parentBlock.Parts.IndexOf(blockPart);

            if (indexPart != -1)
            {
                int nextIndex = indexPart + (forward ? 1 : -1);

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

            return(null);
        }
Пример #7
0
        private void FillBlockContent(TreeNode nodeBlock, SABlock block)
        {
            if (block.Parts.Count > 0)
            {
                foreach (SABlockPart blockPart in block.Parts)
                {
                    TreeNode nodeBlockPart = new TreeNode();
                    nodeBlockPart.Text = blockPart.ToString();
                    nodeBlockPart.Tag  = blockPart;

                    nodeBlockPart.ImageKey         = nodeBlockPart.SelectedImageKey = "SABlockPart";
                    nodeBlockPart.ContextMenuStrip = contMSTreeNode;

                    nodeBlock.Nodes.Add(nodeBlockPart);

                    FillPoemCollection(nodeBlockPart, blockPart.Poems);
                }
            }
            else
            {
                FillPoemCollection(nodeBlock, block.Poems);
            }
        }
Пример #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();
            }
        }
Пример #9
0
 public BlockPartCollection(SABlock Owner)
 {
     this.owner = Owner;
 }
Пример #10
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());
            }
        }
Пример #11
0
 public PoemCollection(SABlock ownerBlock)
 {
     this.ownerBlock = ownerBlock;
 }
Пример #12
0
        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();
        }