Ejemplo n.º 1
0
        // Returns negative numbers for failure, positive for success
        public int InstallProperty(PropertyConfig config, TreeView treeViewInstalled)
        {
            // Save as propdesc
            var doc          = PropertyConfig.GetPropDesc(new PropertyConfig[] { config });
            var fullFileName = $"{state.DataFolder}{Path.DirectorySeparatorChar}{config.CanonicalName}.propdesc";

            doc.Save(fullFileName);

            // Attempt installation
            var result = state.RegisterCustomProperty(fullFileName, config, out PropertyConfig installedConfig);

            if (result >= 0)
            {
                // Property is new, need to add it in
                state.AddInstalledProperty(installedConfig);
                var treeItem = PropertyTree.AddTreeItem(dictInstalledTree, InstalledPropertyTree,
                                                        installedConfig, addRootTop: true);
                if (treeViewInstalled != null)
                {
                    SelectTreeItemAfterDelay(treeViewInstalled, treeItem);
                }
                ShowIfSavedIsInstalled(installedConfig.CanonicalName);
                RefreshEditorStatus();
            }

            return(result);
        }
Ejemplo n.º 2
0
        public string ExportPropDesc(TreeItem treeItem)
        {
            XmlDocument doc;
            string      configName;

            var items = GetTreeTargets(treeItem, out bool isSubTree);

            if (!isSubTree)
            {
                configName = items.First().CanonicalName;
            }
            else
            {
                configName = treeItem.Path;
            }

            doc = PropertyConfig.GetPropDesc(items);

            var fileName = $"{Extensions.FixFileName(configName)}.propdesc";

            doc.Save(state.DataFolder + $@"\{fileName}");

            return(fileName);
        }