private void Re_OnPropertyChange(ConditionComponent re) { TreeNode tn = GetReverseLookup(re); UpdateNodeIcon(tn); tn.Text = re.ToString(); }
private void AttachConditionComponentToNode(TreeNode tn, ConditionComponent re) { tn.Tag = re; tn.Text = re.ToString(); tn.Checked = re.Enabled; if (re != null) { SetReverseLookup(re, tn); } re.OnPropertyChange += Re_OnPropertyChange; UpdateNodeIcon(tn); }
private void btnDelete_Click(object sender, EventArgs e) { TreeNode tn = trvNodes.SelectedNode; ConditionComponent re = (ConditionComponent)tn.Tag; if (re is ConditionSingle) { if (MessageBox.Show(this, I18n.Translate("internal/ConditionViewer/areyousuresingle", "Are you sure you want to remove the selected condition?") + Environment.NewLine + Environment.NewLine + re.ToString(), I18n.Translate("internal/ConditionViewer/confirm", "Confirm removal"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { RemoveReverseLookup(re); re.Parent.Children.Remove(re); tn.Parent.Nodes.Remove(tn); } } if (re is ConditionGroup) { int numgroups = 0, numconditions = 0; CountItems((ConditionGroup)re, ref numgroups, ref numconditions); string temp = ""; if (numgroups > 0 || numconditions > 0) { temp += Environment.NewLine + Environment.NewLine + I18n.Translate("internal/ConditionViewer/operationwillremove", "This operation will remove:") + Environment.NewLine; if (numgroups > 1) { temp += Environment.NewLine + "∙ " + I18n.Translate("internal/ConditionViewer/groupplural", "{0} groups", numgroups); } else if (numgroups > 0) { temp += Environment.NewLine + "∙ " + I18n.Translate("internal/ConditionViewer/groupsingular", "{0} group", numgroups); } if (numconditions > 1) { temp += Environment.NewLine + "∙ " + I18n.Translate("internal/ConditionViewer/conditionplural", "{0} conditions", numconditions); } else if (numconditions > 0) { temp += Environment.NewLine + "∙ " + I18n.Translate("internal/ConditionViewer/conditionsingular", "{0} condition", numconditions); } } if (MessageBox.Show(this, I18n.Translate("internal/ConditionViewer/areyousuregroup", "Are you sure you want to remove the selected condition group?") + temp, I18n.Translate("internal/ConditionViewer/confirm", "Confirm removal"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { DeleteGroup((ConditionGroup)re); tn.Parent.Nodes.Remove(tn); } } }