private Brother ConvertXmlToTree(XmlNode currentParent) { if( currentParent == null ) return null; if( currentParent.Attributes == null ) return null; var big = new Brother( currentParent.Attributes["Last"].Value, currentParent.Attributes["First"].Value, currentParent.Attributes["IniTerm"].Value, int.Parse( currentParent.Attributes["IniYear"].Value ) ) { Active = Util.ConvertStringToBool( currentParent.Attributes["Active"].Value ), Label = {ContextMenuStrip = cmNodeActions} }; ttTree.SetToolTip(big.Label, Util.GetLocalizedString("LeftClickSelectEdit")); foreach ( XmlNode child in currentParent.ChildNodes ) { big.AddChild( ConvertXmlToTree( child ) ); } return big; }
private void EditBrotherPanel_Apply_onClick(object sender, EventArgs eventArguments) { if( cbSelectedTerm.SelectedIndex != -1 && ((selectedEdits & FieldEdit.IniMonth) != 0) ) { selected.InitiationTerm = Util.StringToInitiationTerm(cbSelectedTerm.SelectedItem.ToString()); } if( (selectedEdits & FieldEdit.IniYear) != 0 ) { selected.InitiationYear = dtpSelectedYear.Value.Year; } if( (selectedEdits & FieldEdit.Active) != 0 ) { selected.Active = chbActive.Checked; } if( tbSelectedFirst.Text != string.Empty && ((selectedEdits & FieldEdit.FirstName) != 0) ) { cbTreeParent.Items.Remove( selected ); selected.FirstName = tbSelectedFirst.Text; cbTreeParent.Items.Add( selected ); cbTreeParent.Sorted = true; } if( tbSelectedLast.Text != string.Empty && ((selectedEdits & FieldEdit.LastName) != 0) ) { cbTreeParent.Items.Remove( selected ); selected.LastName = tbSelectedLast.Text; cbTreeParent.Items.Add( selected ); cbTreeParent.Sorted = true; } if( (selectedEdits & FieldEdit.Big) != 0 ) { if( tbSelectedBig.Text == string.Empty ) { if( selected.HasParent() ) { if( selected != Root ) { Root.AddChild( selected ); } RefreshNoBigListBox( Root ); } } else { var tmp = Root.FindDescendant( tbSelectedBig.Text ); if( tmp == null ) { var space = tbSelectedBig.Text.LastIndexOf( ' ' ); tmp = new Brother( tbSelectedBig.Text.Substring( space + 1 ), tbSelectedBig.Text.Substring( 0, space ), Util.DefaultInitiationTerm, Util.DefaultYear ) { Label = {ContextMenuStrip = cmNodeActions} }; Root.AddChild( tmp ); tmp.AddChild( selected ); RefreshNoBigListBox( Root ); } else { if( selected.HasParent() ) { tmp.AddChild( selected ); } else { tmp.AddChild( selected ); } } } } if( (selectedEdits & FieldEdit.Littles) != 0 ) { if( tbSelectedLittles.Text == string.Empty ) { for ( var i = 0; i < selected.ChildCount; i ++ ) { Root.AddChild( (Brother) selected[i] ); } RefreshNoBigListBox( Root ); } else { for ( var i = 0; i < selected.ChildCount; i++ ) { Root.AddChild( (Brother) selected[i] ); } var littles = tbSelectedLittles.Text.Split( new[] {'\n', '\r'}, StringSplitOptions.RemoveEmptyEntries ); for ( var i = 0; i < littles.Length; i++ ) { var space = littles[0].LastIndexOf( ' ' ); var tmp = Root.FindDescendant(littles[0]); Brother littleBrother; if( tmp != null ) { littleBrother = tmp; if( littleBrother.HasParent() ) { selected.AddChild( littleBrother ); } else { selected.AddChild( littleBrother ); RefreshNoBigListBox( Root ); } } else { littleBrother = new Brother(littles[0].Substring(space + 1), littles[0].Substring(0, space), Util.DefaultInitiationTerm, selected.InitiationYear + 1 ) { Label = {ContextMenuStrip = cmNodeActions} }; selected.AddChild( littleBrother ); } } } } if( (selectedEdits & (FieldEdit.IniMonth | FieldEdit.IniYear)) != 0 ) { if( selected !=null ) { ((Brother)selected.GetParent()).RecalculateChildOrder(); } } if( treeRoot == selected && cbTreeParent.Text == string.Empty) { cbTreeParent.SelectedItem = treeRoot; EditBrotherPanel_Initalize( treeRoot ); } else { EditBrotherPanel_Initalize( selected ); } RefreshNoBigListBox( Root ); cbTreeParent.Sorted = true; DisplayTree( true ); }