public NonterminalActionBar(NonterminalExpanded nontExpandedIn)
        {
            InitializeComponent();

            nontExpanded = nontExpandedIn;

            Init(nontExpandedIn.NonterminalHeadD);
        }
        public void Collapse(NonterminalExpanded control)
        {
            StackPanel parent = (control.Parent as StackPanel);
            if (parent == null)
                throw new Exception("The controls parent is not of type stack panel");

            // draw collapsed control
            GrammarNodeVDrawVisitor visitor = new GrammarNodeVDrawVisitor();
            visitor.visit(control.ReferenceTail);

            // get the index of the nonterminal collapsed that wants to expand
            int index = parent.Children.IndexOf(control);
            if (index < 0)
                throw new Exception("Cant find child in my stack panel, uh oh!");

            parent.Children.RemoveAt(index);
            parent.Children.Insert(index, visitor.DrawnItem);
        }
        private void SelectedNonterminal(NonterminalExpanded control, GrammarEventArgs eventArgs)
        {
            SelectedNonterminal(eventArgs);

            if (ControlSelected != null)
            {
                ControlSelected(control, eventArgs);
            }
        }
        private void collapse(NonterminalExpanded nonterminalExpanded, GrammarEventArgs e)
        {
            lock (new System.Object())
            {
                NonterminalTailV nonterminalTailV = (NonterminalTailV)e.Reference;

                if (nonterminalTailV.IsExpanded)
                {
                    // collapse in the model
                    model.Functions.Collapse(nonterminalTailV);

                    // collapse in the view
                    view.Functions.Collapse(nonterminalExpanded);

                    // re draw the view - we do this to reinitialise the controllers - not needed when expanding
                    ReDraw();
                }
            }
        }
 internal void Listen(NonterminalExpanded nonterminalExpanded)
 {
     nonterminalExpanded.ControlEvent += new NonterminalExpanded.ControlEventHandler(nonterminalExpanded_ControlEvent);
 }