private ContextMenu CreateFilterButtonContextMenu()
        {
            var filterContextMenu = new ContextMenu();

            filterContextMenu.Placement       = PlacementMode.Bottom;
            filterContextMenu.PlacementTarget = _buttonFilter;
            _buttonFilter.ContextMenu         = filterContextMenu;

            var filterContextMenuItemAll = new MenuItem()
            {
                Header = "Show All"
            };

            filterContextMenuItemAll.Click += (sender, eventArgs) =>
            {
                foreach (TreeViewItem projectTreeViewItem in _treeViewProjects.Items)
                {
                    PerformActionOnTreeViewItems(projectTreeViewItem, (treeViewItem) => { treeViewItem.Visibility = Visibility.Visible; });
                }
                filterContextMenu.IsOpen = false;
            };
            filterContextMenu.Items.Add(filterContextMenuItemAll);

            var filterContextMenuItemOnlyExcluded = new MenuItem()
            {
                Header = "Show Only Excluded Files"
            };

            filterContextMenuItemOnlyExcluded.Click += (sender, eventArgs) =>
            {
                foreach (TreeViewItem projectTreeViewItem in _treeViewProjects.Items)
                {
                    ProjectInfo projectInfo = (ProjectInfo)projectTreeViewItem.DataContext;

                    PerformActionOnTreeViewItems(projectTreeViewItem, (treeViewItem) => { treeViewItem.Visibility = Visibility.Visible; });

                    PerformActionOnTreeViewItems(projectTreeViewItem,
                                                 (treeViewItem) =>
                    {
                        SolutionHierarchy.Item item = treeViewItem.DataContext as SolutionHierarchy.Item;
                        if (null != item && item.Type == SolutionHierarchy.Item.ItemType.CppFile)
                        {
                            treeViewItem.Visibility = _solutionSettings.IsExcludedCppFileNameForProject(projectInfo, item.Name) ?
                                                      Visibility.Visible : Visibility.Collapsed;
                        }
                        else
                        {
                            CollapseTreeViewItemIfAllChildrenCollapsed(treeViewItem);
                        }
                    });
                }
                filterContextMenu.IsOpen = false;
            };
            filterContextMenu.Items.Add(filterContextMenuItemOnlyExcluded);

            var filterContextMenuItemOnlyIncluded = new MenuItem()
            {
                Header = "Show Only Included Files"
            };

            filterContextMenuItemOnlyIncluded.Click += (sender, eventArgs) =>
            {
                foreach (TreeViewItem projectTreeViewItem in _treeViewProjects.Items)
                {
                    ProjectInfo projectInfo = (ProjectInfo)projectTreeViewItem.DataContext;

                    PerformActionOnTreeViewItems(projectTreeViewItem, (treeViewItem) => { treeViewItem.Visibility = Visibility.Visible; });

                    PerformActionOnTreeViewItems(projectTreeViewItem,
                                                 (treeViewItem) =>
                    {
                        SolutionHierarchy.Item item = treeViewItem.DataContext as SolutionHierarchy.Item;
                        if (null != item && item.Type == SolutionHierarchy.Item.ItemType.CppFile)
                        {
                            treeViewItem.Visibility = !_solutionSettings.IsExcludedCppFileNameForProject(projectInfo, item.Name) ?
                                                      Visibility.Visible : Visibility.Collapsed;
                        }
                        else
                        {
                            CollapseTreeViewItemIfAllChildrenCollapsed(treeViewItem);
                        }
                    });
                }
                filterContextMenu.IsOpen = false;
            };
            filterContextMenu.Items.Add(filterContextMenuItemOnlyIncluded);

            return(filterContextMenu);
        }
        private void AddCppFileTreeViewItem(ProjectInfo projectInfo, TreeViewItem parentTreeViewItem, SolutionHierarchy.Item item)
        {
            const string kExcludeFromUnityBuild = "Exclude from Unity Build";
            const string kIncludeInUnityBuild   = "Include in Unity Build";

            string cppFileName = item.Name;

            var treeViewItem = new TreeViewItem()
            {
                FontWeight = FontWeights.Normal
            };

            treeViewItem.DataContext = item;
            treeViewItem.ContextMenu = new ContextMenu();

            var checkBox = new CheckBox()
            {
                IsChecked         = !_solutionSettings.IsExcludedCppFileNameForProject(projectInfo, cppFileName),
                VerticalAlignment = VerticalAlignment.Center
            };

            var contextMenuItemExclude = new MenuItem()
            {
                Header = checkBox.IsChecked.Value ? kExcludeFromUnityBuild : kIncludeInUnityBuild,
            };

            contextMenuItemExclude.Click += (sender, eventArgs) =>
            {
                checkBox.IsChecked = !checkBox.IsChecked.Value;
            };
            treeViewItem.ContextMenu.Items.Add(contextMenuItemExclude);

            checkBox.Checked += (sender, eventArgs) =>
            {
                _solutionSettings.RemoveExcludedCppFileNameForProject(projectInfo, cppFileName);
                contextMenuItemExclude.Header = kExcludeFromUnityBuild;
            };
            checkBox.Unchecked += (sender, eventArgs) =>
            {
                _solutionSettings.ExcludeCppFileNameForProject(projectInfo, cppFileName);
                contextMenuItemExclude.Header = kIncludeInUnityBuild;
            };

            var image = new Image()
            {
                Source = _solutionHierarchy.GetIcon(SolutionHierarchy.IconType.CppFile)
            };
            var label = new Label()
            {
                Content = System.IO.Path.GetFileName(cppFileName)
            };

            var stack = new StackPanel()
            {
                Orientation = Orientation.Horizontal, Margin = new Thickness(0, -2, 0, -2)
            };

            stack.Children.Add(checkBox);
            stack.Children.Add(image);
            stack.Children.Add(label);
            treeViewItem.Header = stack;

            parentTreeViewItem.Items.Add(treeViewItem);
        }