/// <summary> /// 删除节点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 除节点ToolStripMenuItem_Click(object sender, EventArgs e) { if (iSelectedControlNow != null) { IDialoguePointID iDialoguePointID = iSelectedControlNow as IDialoguePointID; Control parentControl = iSelectedControlNow.GetParent(); if (iDialoguePointID.GetType().Equals(typeof(DialogueConditionControl))) { FlowLayoutPanel_Main.Controls.Remove(parentControl); iSelectedControlNow = null; } else { DialogueConditionControl dialogueConditionControl = parentControl.Controls.OfType <DialogueConditionControl>().FirstOrDefault(); if (dialogueConditionControl != null) { IDialoguePointID parentIDialoguePointID = GetParentDialoguePointID(iDialoguePointID, dialogueConditionControl); if (parentIDialoguePointID != null) { parentIDialoguePointID.RemovNextPointID(iDialoguePointID); RemoveDialoguePointIDControl(parentControl, iDialoguePointID); List <Control> tagControlList = (parentIDialoguePointID as Control).Tag as List <Control>; if (tagControlList != null) { tagControlList.Remove(iDialoguePointID as Control); } //移除所有子节点 iSelectedControlNow = null; ResetControlRect(parentControl); } } } } }
/// <summary> /// 添加一个子节点 /// </summary> /// <param name="iSelectedControlNow">要添加子节点的节点</param> private DialoguePointControl AddNewChildNode(ISelectedControl iSelectedControlNow, DialogueValue dialogueValue = null, bool updateControl = true) { IDialoguePointID iDialoguePointID = iSelectedControlNow as IDialoguePointID; if (iDialoguePointID.GetType().Equals(typeof(DialogueConditionControl)))//顶层节点(关系关系)只能添加一个子节点(数据节点) { if (iDialoguePointID.GetDialogueNextPointID.Length > 0) { return(null); } } if (iDialoguePointID != null) { DialoguePointControl dialoguePointControl = new DialoguePointControl(dialogueValue); dialoguePointControl.Size = dialoguePointControl.StopSize; dialoguePointControl.SetListenControlSelected(ListenControlSelected); dialoguePointControl.SetLiestenOpenStop(AddListenOpenStop); dialoguePointControl.Tag = new List <Control>(); Control iSelectedControl = iSelectedControlNow as Control; List <Control> childControl = iSelectedControl.Tag as List <Control>; childControl.Add(dialoguePointControl); Control parentControl = iSelectedControlNow.GetParent(); parentControl.Controls.Add(dialoguePointControl); iDialoguePointID.AddNextPointID(dialoguePointControl); if (updateControl) { ResetControlRect(parentControl); } if (searchNodeForm != null) { searchNodeForm.NodeChanged = true; } return(dialoguePointControl); } return(null); }