示例#1
0
        private void TreeItemContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            if ((sender as TreeViewItem)?.DataContext != tv.SelectedItem)
            {
                return; //because this event bubbles to the parent node
            }
            foreach (var item in ContextItems.OfType <MenuItem>())
            {
                item.Click -= ContextItem_Click;
            }

            var menu = (sender as ContextMenu);
            var node = tv.SelectedItem as TreeItemModel;

            ContextItems.Clear();
            if (node.Tag is IIndexItem)
            {
                ContextItems.Add(OpenContextItem);
                ContextItems.Add(OpenWithContextItem);
                ContextItems.Add(CopyPathContextItem);
            }

            var customItems = Substrate.GetContextItems(GetSelectedArgs());

            if (ContextItems.Any() && customItems.Any())
            {
                ContextItems.Add(ContextSeparator);
            }

            foreach (var item in customItems)
            {
                ContextItems.Add(new MenuItem {
                    Header = item.Path, Tag = item
                });
            }

            foreach (var item in ContextItems.OfType <MenuItem>())
            {
                item.Click += ContextItem_Click;
            }

            if (!ContextItems.Any())
            {
                e.Handled = true;
            }
        }
示例#2
0
        private void TreeItemContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            foreach (MenuItem item in ContextItems.Where(i => i is MenuItem))
            {
                item.Click -= ContextItem_Click;
            }

            var menu = (sender as ContextMenu);
            var node = tv.SelectedItem as TreeItemModel;

            ContextItems.Clear();
            if (node.Tag is IPakItem)
            {
                ContextItems.Add(OpenContextItem);
                ContextItems.Add(OpenWithContextItem);
            }

            var customItems = Substrate.GetContextItems(GetSelectedArgs());

            if (ContextItems.Any() && customItems.Any())
            {
                ContextItems.Add(ContextSeparator);
            }

            foreach (var item in customItems)
            {
                ContextItems.Add(new MenuItem {
                    Header = item.Path, Tag = item
                });
            }

            foreach (MenuItem item in ContextItems.Where(i => i is MenuItem))
            {
                item.Click += ContextItem_Click;
            }

            if (!ContextItems.Any())
            {
                e.Handled = true;
            }
        }
        public void LoadModule(string fileName)
        {
            module         = new Module(fileName);
            rootNode       = new TreeItemModel(module.FileName);
            tv.ItemsSource = rootNode.Items;

            TabModel.Header  = Utils.GetFileName(module.FileName);
            TabModel.ToolTip = $"Module Viewer - {TabModel.Header}";

            foreach (var item in globalMenuButton.MenuItems.OfType <MenuItem>())
            {
                item.Click -= GlobalContextItem_Click;
            }

            globalMenuButton.MenuItems.Clear();

            var globalHandlers = Substrate.GetContextItems(GetFolderArgs(rootNode));

            HasGlobalHandlers = globalHandlers.Any();

            if (HasGlobalHandlers)
            {
                foreach (var item in globalHandlers)
                {
                    globalMenuButton.MenuItems.Add(new MenuItem {
                        Header = item.Path, Tag = item
                    });
                }

                foreach (var item in globalMenuButton.MenuItems.OfType <MenuItem>())
                {
                    item.Click += GlobalContextItem_Click;
                }
            }

            HierarchyView = ModuleViewerPlugin.Settings.HierarchyView;
            BuildTagTree(null);
        }
示例#4
0
        public void LoadPak(string fileName)
        {
            pak            = new Adjutant.Saber3D.Halo1X.PakFile(fileName);
            rootNode       = new TreeItemModel(pak.FileName);
            tv.ItemsSource = rootNode.Items;

            TabModel.Header  = Utils.GetFileName(pak.FileName);
            TabModel.ToolTip = $"Pak Viewer - {TabModel.Header}";

            foreach (var item in globalMenuButton.MenuItems.OfType <MenuItem>())
            {
                item.Click -= GlobalContextItem_Click;
            }

            globalMenuButton.MenuItems.Clear();

            var globalHandlers = Substrate.GetContextItems(GetFolderArgs(rootNode));

            HasGlobalHandlers = globalHandlers.Any();

            if (HasGlobalHandlers)
            {
                foreach (var item in globalHandlers)
                {
                    globalMenuButton.MenuItems.Add(new MenuItem {
                        Header = item.Path, Tag = item
                    });
                }

                foreach (var item in globalMenuButton.MenuItems.OfType <MenuItem>())
                {
                    item.Click += GlobalContextItem_Click;
                }
            }

            BuildItemTree(null);
        }
        private void TreeItemContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            if ((sender as TreeViewItem)?.DataContext != tv.SelectedItem)
            {
                return; //because this event bubbles to the parent node
            }
            foreach (var item in ContextItems.OfType <MenuItem>().Concat(OpenFromContextItem.Items.OfType <MenuItem>()))
            {
                item.Click -= ContextItem_Click;
            }

            var menu = (sender as ContextMenu);
            var node = tv.SelectedItem as TreeItemModel;

            ContextItems.Clear();
            OpenFromContextItem.Items.Clear();

            var moduleItem = node.Tag as ModuleItem;

            if (moduleItem != null)
            {
                ContextItems.Add(OpenContextItem);
                ContextItems.Add(OpenWithContextItem);

                var instances = moduleItem.Module.FindAlternateTagInstances(moduleItem.GlobalTagId).ToList();
                if (instances.Count > 1)
                {
                    foreach (var instance in instances)
                    {
                        var item = new MenuItem {
                            Header = Utils.GetFileNameWithoutExtension(instance.Module.FileName), Tag = instance
                        };
                        OpenFromContextItem.Items.Add(item);
                    }

                    ContextItems.Add(OpenFromContextItem);
                }

                ContextItems.Add(CopyPathContextItem);
            }

            var customItems = Substrate.GetContextItems(GetSelectedArgs());

            if (ContextItems.Any() && customItems.Any())
            {
                ContextItems.Add(ContextSeparator);
            }

            foreach (var item in customItems)
            {
                ContextItems.Add(new MenuItem {
                    Header = item.Path, Tag = item
                });
            }

            foreach (var item in ContextItems.OfType <MenuItem>().Concat(OpenFromContextItem.Items.OfType <MenuItem>()))
            {
                item.Click += ContextItem_Click;
            }

            if (!ContextItems.Any())
            {
                e.Handled = true;
            }
        }