private TreeNode FindStageNode(TreeNode tnParent, ContentStage stage) { if (tnParent == null) return null; if (tnParent.Tag == stage) return tnParent; else if (tnParent.Nodes.Count == 0) return null; TreeNode tnCurrent, tnCurrentPar; //Init node tnCurrentPar = tnParent; tnCurrent = tnCurrentPar.FirstNode; while (tnCurrent != null && tnCurrent != tnParent) { while (tnCurrent != null) { if (tnCurrent.Tag == stage) return tnCurrent; else if (tnCurrent.Nodes.Count > 0) { //Go into the deepest node in current sub-path tnCurrentPar = tnCurrent; tnCurrent = tnCurrent.FirstNode; } else if (tnCurrent != tnCurrentPar.LastNode) { //Goto next sible node tnCurrent = tnCurrent.NextNode; } else break; } //Go back to parent node till its has next sible node while (tnCurrent != tnParent && tnCurrent == tnCurrentPar.LastNode) { tnCurrent = tnCurrentPar; tnCurrentPar = tnCurrentPar.Parent; } //Goto next sible node if (tnCurrent != tnParent) tnCurrent = tnCurrent.NextNode; } return null; }
public ContentStage NewStage() { var stage = new ContentStage(); this.m_baseId++; stage.Id = this.m_baseId; this.m_stages.Add(stage); return stage; }
private void OKBtn_Click(object sender, EventArgs e) { m_chooseStage = null; m_chooseText = ""; if (this.stageTree.SelectedNode != null) { m_chooseStage = this.stageTree.SelectedNode.Tag as ContentStage; m_chooseText = this.chooseText.Text; } this.DialogResult = DialogResult.OK; Close(); }
private void SetEditContentStage(ContentStage stage) { m_editingStage = stage; if (stage != null) { this.stageId.Text = stage.Id.ToString(); this.stageName.Text = stage.Name; this.chooseBtn1.Text = stage.GoId[0] != 0 ? stage.GoString[0] : "--"; this.chooseBtn2.Text = stage.GoId[1] != 0 ? stage.GoString[1] : "--"; this.StageAutoNext.Checked = stage.AutoGoto; this.backMusic.Text = stage.BackMusic; } else { this.stageId.Text = ""; this.stageName.Text = ""; this.backMusic.Text = ""; this.chooseBtn1.Text = "--"; this.chooseBtn2.Text = "--"; this.StageAutoNext.Checked = false; } SetEditContentAction(null); this.contentList.BeginUpdate(); this.contentList.Items.Clear(); if (stage != null) { for (int i = 0; i < stage.ContentList.Count(); i++) { var lvi = new ListViewItem(); SetListViewItemActionInfo(i, stage.ContentList[i], lvi); this.contentList.Items.Add(lvi); if (i == 0) { this.contentList.SelectedIndices.Clear(); this.contentList.SelectedIndices.Add(0); } } } this.contentList.EndUpdate(); }