Пример #1
0
        public SolutionExplorer()
        {
            InitializeComponent();

            entity.BeforeNodeOperationEvent += entity_BeforeNodeOperationEvent;
            entity.BeforeDropEvent += entity_BeforeDropEvent;
            entity.TreeViewExItemMouseDoubleClick += (s, e) =>
            {
                //CommandServer.Execute(DefaultCommand.Develop_OnProjectResourceOpen, entity.HitNode);

            };
            entity.TreeViewExMouseRightButtonDown += (s, e) =>
            {
                PopContextMenu(s as SolutionExplorerNode);
            };

            HeadNode = new SolutionExplorerNode();

            Property.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Solution")
                {
                    HeadNode.Nodes.Clear();
                    var orSolution = Property.Get<SolutionExplorerNode>("Solution", default(SolutionExplorerNode));
                    if (orSolution != null)
                        HeadNode.Nodes.Add(orSolution);
                }
            };

            var initSolution = Property.Get<SolutionExplorerNode>("Solution", default(SolutionExplorerNode));
            if (initSolution != null)
                HeadNode.Nodes.Add(initSolution);
        }
Пример #2
0
        public void PopContextMenu(SolutionExplorerNode hitContextMenuNode)
        {
            if (hitContextMenuNode.ContextMenu == null)
            {
                hitContextMenuNode.ContextMenu = new System.Windows.Controls.ContextMenu();

                var k = hitContextMenuNode.ProjectItem;

                if (ProjectItemType.Folders.Contains(k.ItemType))
                {
                    if (k.ItemType.Equals(ProjectItemType.ReferneceFolder))
                    {
                        hitContextMenuNode.ContextMenu.Items.Add(GetAddReferenceMenu());
                    }
                    else
                    {
                        AddAddOperation(hitContextMenuNode.ContextMenu);
                        if (k.ItemType.Equals(ProjectItemType.Folder))
                        {
                            hitContextMenuNode.ContextMenu.Items.Add(new Separator());
                            AddFileOperation(hitContextMenuNode.ContextMenu, true);
                        }
                    }
                }
                else if (ProjectItemType.References.Contains(k.ItemType))
                {
                    hitContextMenuNode.ContextMenu.Items.Add(GetDeleteMenu());
                }
                else if (ProjectItemType.Files.Contains(k.ItemType))
                {
                    AddFileOperation(hitContextMenuNode.ContextMenu, false);
                }

                if (hitContextMenuNode.ContextMenu.HasItems)
                    hitContextMenuNode.ContextMenu.Items.Add(new Separator());

                hitContextMenuNode.ContextMenu.Items.Add(GetPropertyMenu());
            }
        }