通过SDK更改选项

214
4
12-26-2022晚上11:13
mody_buchbinder
临时贡献者II

我想为许多人自动更改默认情况下在GP工具中使用撤销选项。

您可以在附件的屏幕截图中看到我想更改的选项。

Pro SDK有这个:https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic73588.html但它没有这个选项。

我在注册表或用户配置文件中找不到任何存储此选项的东西,但由于Pro“记住”新值,它必须写在某个地方。

什么好主意吗?

谢谢

0荣誉
4回复
CharlesMacleod
亚博搜索yabovip28点com

Mody,我们可以公开这个属性,以允许api更改 3.23.1

同时,你可以使用这样的东西来改变它,如果你必须,但我真的不建议这样做。在更改用户时需要注意。以编程方式进行配置:

1.应用程序可以缓存属性和它们的值,我不知道这是否是EnableUndo的情况。

2.这段代码保存User。磁盘上的配置,并且此保存不会与“选项”对话框或其他可能保存用户的应用程序代码同步。配置(如果两者同时尝试保存,则可能导致冲突)

内部类ToggleGP_EnableUndo:按钮{私有静态只读string GP_EnableUndo = "EnableUndo";OnClick() {var enable_undo = getgpenableundo ();SetGPEnableUndoSetting (! enable_undo);} private bool GetGPEnableUndoSetting() {var config = System.Configuration.ConfigurationManager.}OpenExeConfiguration (ConfigurationUserLevel.PerUserRoamingAndLocal);Var组= config。SectionGroups[@"userSettings"] as ConfigurationSectionGroup;var gp_Section = group.Sections["ArcGIS.Desktop.Internal.GeoProcessing.Properties. var gp_Section = group.Sections["作为ClientSettingsSection;var enableundo = gp_Section?.Settings.Get(GP_EnableUndo);var rawValue = enableUndoSetting?. value ?. valuexml ?。InnerText ?实现吗?“假”; return Boolean.Parse(rawValue); } private void SetGPEnableUndoSetting(bool enable_undo) { var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); var group = config.SectionGroups[@"userSettings"] as ConfigurationSectionGroup; var gp_Section = group.Sections["ArcGIS.Desktop.Internal.GeoProcessing.Properties.Settings"] as ClientSettingsSection; var enableUndoSetting = gp_Section.Settings.Get(GP_EnableUndo); //null check... if (enableUndoSetting == null) { //create a new value var element = new SettingElement(GP_EnableUndo, SettingsSerializeAs.String); var xElement = new XElement(XName.Get("value")); XmlDocument doc = new XmlDocument(); XmlElement valueXml = doc.ReadNode(xElement.CreateReader()) as XmlElement; valueXml.InnerText = enable_undo.ToString(); element.Value.ValueXml = valueXml; gp_Section.Settings.Add(element); } else { //change the value XmlDocument doc = new XmlDocument(); var sr = new StringReader(enableUndoSetting.Value.ValueXml.OuterXml); XmlElement valueXml = doc.ReadNode(XmlReader.Create(sr)) as XmlElement; valueXml.InnerText = enable_undo.ToString(); enableUndoSetting.Value.ValueXml = valueXml; } config.Save(); } }

0荣誉
GintautasKmieliauskas
定期贡献者II

你好,

它是在ArcGIS Pro 3.1 Beta中公开的,但它不能像预期的那样工作。

QueuedTask.Run() => {ApplicationOptions.GeoprocessingOptions.SetEnableUndoOn(true);});

我试图解读财产的新价值,它仍然有旧的价值。

0荣誉
CharlesMacleod
亚博搜索yabovip28点com

谢谢,Gintautas,这看起来像是Beta版的bug。我们会在期末修正的。

0荣誉
mody_buchbinder
临时贡献者II

你好查理

谢谢你,新年快乐。

如你所说,这是一次过度杀戮。

我想有人会解释它默认保存在哪里,我可以写一些外部代码来从Pro外部更改它

谢谢

0荣誉