private void CreateContextAttributeElement( object sender, EventArgs args ) { NoBoldNode node = (NoBoldNode)mainTree.SelectedNode; if( node is ContextTreeNodes.Action ) { ContextTreeNodes.Action actionNode = (ContextTreeNodes.Action)mainTree.SelectedNode; con.ActionElementReadWrite action = actionNode.ActionDefinition; con.AttributeElementReadWrite attribute = new con.AttributeElementReadWrite( string.Empty, string.Empty, string.Empty, string.Empty, "TODO: Add value", XacmlVersion.Version11); Attribute attributeNode = new Attribute( attribute ); action.Attributes.Add( attribute ); actionNode.Nodes.Add( attributeNode ); } else if( node is Resource ) { Resource resourceNode = (Resource)mainTree.SelectedNode; con.ResourceElementReadWrite resource = resourceNode.ResourceDefinition; con.AttributeElementReadWrite attribute = new con.AttributeElementReadWrite( string.Empty, string.Empty, string.Empty, string.Empty, "TODO: Add value", XacmlVersion.Version11); Attribute attributeNode = new Attribute( attribute ); resource.Attributes.Add( attribute ); resourceNode.Nodes.Add( attributeNode ); } else if( node is Subject ) { Subject subjectNode = (Subject)mainTree.SelectedNode; con.SubjectElementReadWrite subject = subjectNode.SubjectDefinition; con.AttributeElementReadWrite attribute = new con.AttributeElementReadWrite( "urn:new_attribute", string.Empty, string.Empty, string.Empty, "TODO: Add value", XacmlVersion.Version11); Attribute attributeNode = new Attribute( attribute ); subject.Attributes.Add( attribute ); subjectNode.Nodes.Add( attributeNode ); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mainTree_BeforeSelect(object sender, TreeViewCancelEventArgs e) { // Check if the control have been modified if( mainPanel.Controls.Count != 0 ) { if( !(mainPanel.Controls[0] is XmlViewer) ) { BaseControl baseControl = mainPanel.Controls[0] as BaseControl; mainTree.SelectedNode.NodeFont = new Font( mainTree.Font, FontStyle.Regular ); NoBoldNode oNode = null; if( baseControl is CustomControls.PolicySet ) { oNode = new PolicySet(((CustomControls.PolicySet)baseControl).PolicySetElement); } else if( baseControl is CustomControls.PolicySet ) { oNode = new Policy(((CustomControls.Policy)baseControl).PolicyElement); } else if( baseControl is CustomControls.Rule ) { oNode = new Rule(((CustomControls.Rule)baseControl).RuleElement); } else if( baseControl is CustomControls.TargetItem ) { pol.TargetItemBaseReadWrite element = ((CustomControls.TargetItem)baseControl).TargetItemBaseElement; oNode = new TargetItem(element); } else if( baseControl is CustomControls.Obligations ) { oNode = new Obligations(((CustomControls.Obligations)baseControl).ObligationsElement); } else if( baseControl is ContextCustomControls.Attribute ) { oNode = new Attribute( ((ContextCustomControls.Attribute)baseControl).AttributeElement ); } else if( baseControl is ContextCustomControls.Resource ) { oNode = new Resource( ((ContextCustomControls.Resource)baseControl).ResourceElement ); } if( oNode != null ) { mainTree.SelectedNode = oNode; mainTree.SelectedNode.Text = oNode.Text; } } } }