///<summary>
 ///this function moves cursor to the selected list item in the FunctionsListView.
 ///this is called both by listFunctionsGoButton and Window_KeyDown on pressing enter.
 ///</summary>
 void MoveCursorToSelectedFunction()
 {
     if (false == isTreeViewActive)
     {
         MenuItemViewModel destinationFunction = (MenuItemViewModel)listView.SelectedItem;
         TalkCodePackage.vsOperations.GoToLocationInActiveDocument(destinationFunction.LineNumber);
     }
     else
     {
         MenuItemViewModel destinationFunction = (MenuItemViewModel)treeView.SelectedItem;
         TalkCodePackage.vsOperations.GoToLocationInActiveDocument(destinationFunction.LineNumber);
     }
 }
        /// <summary>
        /// Builds the tree for MenuItem tree view model
        /// </summary>
        /// <param name="node"></param>
        /// <param name="menuItemViewModel"></param>
        void BuildTreeViewModel(ISyntaxEntity node, MenuItemViewModel menuItemViewModel)
        {
            MenuItemViewModel item = new MenuItemViewModel()
            {
                DisplayText = node.DisplayText(),
                SpokenText  = node.SpokenText(),
                Name        = node.DisplayText(),
                LineNumber  = node.Location.StartLineNumber + Constants.GoToLineOffsite,
                Children    = new ObservableCollection <MenuItemViewModel>(),
                IsExpanded  = (node is Block || node is FunctionDefinition)?false:true,
                ImageSource = UIConstants.GetImageSourceFromKind(node)
            };

            if (null == menuItemViewModel)
            {
                treeRootViewModel = item;
            }
            else
            {
                menuItemViewModel.Children.Add(item);
            }

            menuItemViewModel = item;

            if (null == node.Children)
            {
                return;
            }

            foreach (var child in node.Children)
            {
                if (child.Kind == SyntaxEntityKind.Function)
                {
                    if (((child as FunctionDefinition).TypeOfFunction & functionTypesToDisplay) == 0)
                    {
                        continue;
                    }
                }
                BuildTreeViewModel(child, menuItemViewModel);
            }
        }
 public void AddChild(MenuItemViewModel child)
 {
     Children.Add(child);
 }