Esempio n. 1
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

            var rsrcListNode = Utils.GetResourceListTreeNode(nodes);

            var module = ILSpyTreeNode.GetModule(nodes[0]);
            Debug.Assert(module != null);
            if (module == null)
                throw new InvalidOperationException();

            var options = new ResourceOptions {
                ResourceType = ResourceType.Embedded,
                Name = "my.resources",
                Attributes = ManifestResourceAttributes.Public,
            };
            var data = new ResourceVM(options, module);
            var win = new ResourceDlg();
            win.Title = CMD_NAME;
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            var node = new ResourceElementSetTreeNode(module, data.Name, data.Attributes);
            UndoCommandManager.Instance.Add(new CreateMultiFileResourceCommand(rsrcListNode, node));
        }
Esempio n. 2
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

            var rsrcNode = (ResourceTreeNode)nodes[0];

            var module = ILSpyTreeNode.GetModule(nodes[0]);
            Debug.Assert(module != null);
            if (module == null)
                throw new InvalidOperationException();

            var data = new ResourceVM(new ResourceOptions(rsrcNode.Resource), module);
            var win = new ResourceDlg();
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            UndoCommandManager.Instance.Add(new ResourceSettingsCommand(rsrcNode, data.CreateResourceOptions()));
        }
Esempio n. 3
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

            var rsrcListNode = Utils.GetResourceListTreeNode(nodes);

            var module = ILSpyTreeNode.GetModule(nodes[0]);
            Debug.Assert(module != null);
            if (module == null)
                throw new InvalidOperationException();

            var options = new ResourceOptions {
                ResourceType = ResourceType.Linked,
                Name = "filelinked",
                Attributes = ManifestResourceAttributes.Public,
                File = new FileDefUser("somefile", dnlib.DotNet.FileAttributes.ContainsNoMetaData, new byte[0]),
            };
            var data = new ResourceVM(options, module);
            var win = new ResourceDlg();
            win.Title = CMD_NAME;
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            var opts = data.CreateResourceOptions();
            var node = ResourceFactory.Create(module, new LinkedResource(opts.Name, opts.File, opts.Attributes));
            UndoCommandManager.Instance.Add(new CreateFileLinkedResourceCommand(rsrcListNode, node));
        }
Esempio n. 4
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

            var rsrcListNode = Utils.GetResourceListTreeNode(nodes);

            var module = ILSpyTreeNode.GetModule(nodes[0]);
            Debug.Assert(module != null);
            if (module == null)
                throw new InvalidOperationException();

            var options = new ResourceOptions {
                ResourceType = ResourceType.AssemblyLinked,
                Name = "asmlinked",
                Attributes = ManifestResourceAttributes.Public,
                Assembly = module.CorLibTypes.AssemblyRef,
            };
            var data = new ResourceVM(options, module);
            var win = new ResourceDlg();
            win.Title = CMD_NAME;
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            var node = ResourceFactory.Create(module, new AssemblyLinkedResource(data.Name, data.Assembly, data.Attributes));
            UndoCommandManager.Instance.Add(new CreateAssemblyLinkedResourceCommand(rsrcListNode, node));
        }
Esempio n. 5
0
		static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IResourceNodeFactory resourceNodeFactory, IFileTreeNodeData[] nodes) {
			if (!CanExecute(nodes))
				return;

			var rsrcListNode = ResUtils.GetResourceListTreeNode(nodes);

			var module = nodes[0].GetModule();
			Debug.Assert(module != null);
			if (module == null)
				throw new InvalidOperationException();

			var options = new ResourceOptions {
				ResourceType = ResourceType.Embedded,
				Name = "my.resources",
				Attributes = ManifestResourceAttributes.Public,
			};
			var data = new ResourceVM(options, module);
			var win = new ResourceDlg();
			win.Title = dnSpy_AsmEditor_Resources.CreateMultiFileResourceCommand2;
			win.DataContext = data;
			win.Owner = appWindow.MainWindow;
			if (win.ShowDialog() != true)
				return;

			var outStream = new MemoryStream();
			ResourceWriter.Write(module, outStream, new ResourceElementSet());
			var er = new EmbeddedResource(data.Name, outStream.ToArray(), data.Attributes);
			var treeView = appWindow.FileTreeView.TreeView;
			var treeNodeGroup = appWindow.FileTreeView.FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.ResourceTreeNodeGroup);
			var node = (IResourceNode)treeView.Create(resourceNodeFactory.Create(module, er, treeNodeGroup)).Data;

			undoCommandManager.Value.Add(new CreateMultiFileResourceCommand(rsrcListNode, node));
			appWindow.FileTabManager.FollowReference(node);
		}
Esempio n. 6
0
		static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IFileTreeNodeData[] nodes) {
			if (!CanExecute(nodes))
				return;

			var rsrcNode = (IResourceNode)nodes[0];

			var module = nodes[0].GetModule();
			Debug.Assert(module != null);
			if (module == null)
				throw new InvalidOperationException();

			var data = new ResourceVM(new ResourceOptions(rsrcNode.Resource), module);
			var win = new ResourceDlg();
			win.DataContext = data;
			win.Owner = appWindow.MainWindow;
			if (win.ShowDialog() != true)
				return;

			undoCommandManager.Value.Add(new ResourceSettingsCommand(rsrcNode, data.CreateResourceOptions()));
		}
Esempio n. 7
0
		static void Execute(Lazy<IUndoCommandManager> undoCommandManager, IAppWindow appWindow, IResourceNodeFactory resourceNodeFactory, IFileTreeNodeData[] nodes) {
			if (!CanExecute(nodes))
				return;

			var rsrcListNode = ResUtils.GetResourceListTreeNode(nodes);

			var module = nodes[0].GetModule();
			Debug.Assert(module != null);
			if (module == null)
				throw new InvalidOperationException();

			var options = new ResourceOptions {
				ResourceType = ResourceType.Linked,
				Name = "filelinked",
				Attributes = ManifestResourceAttributes.Public,
				File = new FileDefUser("somefile", dnlib.DotNet.FileAttributes.ContainsNoMetaData, new byte[0]),
			};
			var data = new ResourceVM(options, module);
			var win = new ResourceDlg();
			win.Title = dnSpy_AsmEditor_Resources.CreateFileLinkedResourceCommand2;
			win.DataContext = data;
			win.Owner = appWindow.MainWindow;
			if (win.ShowDialog() != true)
				return;

			var opts = data.CreateResourceOptions();
			var treeView = appWindow.FileTreeView.TreeView;
			var treeNodeGroup = appWindow.FileTreeView.FileTreeNodeGroups.GetGroup(FileTreeNodeGroupType.ResourceTreeNodeGroup);
			var node = (IResourceNode)treeView.Create(resourceNodeFactory.Create(module, new LinkedResource(opts.Name, opts.File, opts.Attributes), treeNodeGroup)).Data;
			undoCommandManager.Value.Add(new CreateFileLinkedResourceCommand(rsrcListNode, node));
			appWindow.FileTabManager.FollowReference(node);
		}
Esempio n. 8
0
		static void Execute(Lazy<IUndoCommandService> undoCommandService, IAppService appService, IResourceNodeFactory resourceNodeFactory, DocumentTreeNodeData[] nodes) {
			if (!CanExecute(nodes))
				return;

			var rsrcListNode = ResUtils.GetResourceListTreeNode(nodes);

			var module = nodes[0].GetModule();
			Debug.Assert(module != null);
			if (module == null)
				throw new InvalidOperationException();

			var options = new ResourceOptions {
				ResourceType = ResourceType.AssemblyLinked,
				Name = "asmlinked",
				Attributes = ManifestResourceAttributes.Public,
				Assembly = module.CorLibTypes.AssemblyRef,
			};
			var data = new ResourceVM(options, module);
			var win = new ResourceDlg();
			win.Title = dnSpy_AsmEditor_Resources.CreateAssemblyLinkedResourceCommand2;
			win.DataContext = data;
			win.Owner = appService.MainWindow;
			if (win.ShowDialog() != true)
				return;

			var treeView = appService.DocumentTreeView.TreeView;
			var treeNodeGroup = appService.DocumentTreeView.DocumentTreeNodeGroups.GetGroup(DocumentTreeNodeGroupType.ResourceTreeNodeGroup);
			var node = (ResourceNode)treeView.Create(resourceNodeFactory.Create(module, new AssemblyLinkedResource(data.Name, data.Assembly, data.Attributes), treeNodeGroup)).Data;
			undoCommandService.Value.Add(new CreateAssemblyLinkedResourceCommand(rsrcListNode, node));
			appService.DocumentTabService.FollowReference(node);
		}