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

            var rsrcSetNode = nodes[0] as ResourceElementSetTreeNode;
            if (rsrcSetNode == null)
                rsrcSetNode = nodes[0].Parent as ResourceElementSetTreeNode;
            Debug.Assert(rsrcSetNode != null);

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

            var options = new ResourceElementOptions(new ResourceElement {
                Name = string.Empty,
                ResourceData = new BuiltInResourceData(ResourceTypeCode.String, string.Empty),
            });
            var data = new ResourceElementVM(options, module, Options.OtherSettings.Instance.DeserializeResources);
            var win = new ResourceElementDlg();
            win.Title = CMD_NAME;
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            var opts = data.CreateResourceElementOptions();
            var node = ResourceFactory.Create(module, opts.Create());
            UndoCommandManager.Instance.Add(new CreateResourceElementCommand(rsrcSetNode, node));
        }
Esempio n. 2
0
        static void Execute(ILSpyTreeNode[] nodes)
        {
            if (!CanExecute(nodes))
                return;

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

            var options = new ResourceElementOptions(rsrcElNode.ResourceElement);
            var data = new ResourceElementVM(options, module, Options.OtherSettings.Instance.DeserializeResources);
            data.CanChangeType = false;
            var win = new ResourceElementDlg();
            win.Title = CMD_NAME;
            win.DataContext = data;
            win.Owner = MainWindow.Instance;
            if (win.ShowDialog() != true)
                return;

            var opts = data.CreateResourceElementOptions();
            string error;
            try {
                error = rsrcElNode.CheckCanUpdateData(opts.Create());
            }
            catch (Exception ex) {
                error = string.Format("Can't use this data: {0}", ex.Message);
            }
            if (!string.IsNullOrEmpty(error)) {
                MainWindow.Instance.ShowMessageBox(error);
                return;
            }

            UndoCommandManager.Instance.Add(new ResourceElementSettingsCommand(rsrcElNode, opts));
        }