30/08/2020
Как скрыть командную строку без запроса к пользователю?
Как скрыть командную строку без запроса к пользователю?
Вопрос: Я использую для скрытия командной строки метод Autodesk.AutoCAD.Internal.Utils.CloseCommandLine(); При этом возникает запрос:
Можно ли как-то избавится от этого запроса, как будто в этом окне мы ответили Да?
Ответ: Это возможно при использовании HideableDialogSettings:
Вот как будет выглядеть этот код:
Код - C#: [Выделить]
- using Autodesk.AutoCAD.Runtime;
- using Autodesk.Internal.Windows;
- // This line is not mandatory, but improves loading performances
- [assembly: CommandClass(typeof(CloseCommanLine.MyCommands))]
- namespace CloseCommanLine
- {
- public class MyCommands
- {
- [CommandMethod("CC")]
- public void CC()
- {
- EnableCloseCommandLineWindow();
- Autodesk.AutoCAD.Internal.Utils.CloseCommandLine();
- DisableCloseCommandLineWindow();
- }
- static void EnableCloseCommandLineWindow()
- {
- Autodesk.AutoCAD.Internal.Windows.ProfileManager.LoadHideableDialogSettingsDictionary();
- HideableDialogSettingsDictionary dict =
- Autodesk.Windows.TaskDialog.HideableDialogSettingsDictionary;
- if (!dict.ContainsKey("MainFrame.CommandLineHideWindow"))
- {
- HideableDialogSettings sets = new HideableDialogSettings();
- sets.Application = "";
- sets.Id = "MainFrame.CommandLineHideWindow";
- //sets.Title = "Command Line – Close Window";
- //sets.Category = "Command Line";
- sets.Result = 6;
- dict.Add(sets);
- }
- try
- {
- dict.SetResult("MainFrame.CommandLineHideWindow", 6);
- Autodesk.AutoCAD.Internal.Windows.ProfileManager.SaveHideableDialogSettingsDictionary();
- }
- catch { }
- }
- static void DisableCloseCommandLineWindow()
- {
- try
- {
- Autodesk.AutoCAD.Internal.Windows.ProfileManager.LoadHideableDialogSettingsDictionary();
- HideableDialogSettingsDictionary dict =
- Autodesk.Windows.TaskDialog.HideableDialogSettingsDictionary;
- if (dict.ContainsKey("MainFrame.CommandLineHideWindow"))
- {
- dict.Remove("MainFrame.CommandLineHideWindow");
- }
- Autodesk.AutoCAD.Internal.Windows.ProfileManager.SaveHideableDialogSettingsDictionary();
- }
- catch { }
- }
- }
- }
Автор: Александр Ривилис
Опубликовано 30.08.2020
Опубликовано 30.08.2020