1 回答

TA贡献1895条经验 获得超3个赞
我终于找到了答案,只需使用 UrrentProfileChangingEventHandler 显示弹出窗口,并在 CurrentProfileChangedEventHandler 事件上激活您想要的配置文件。这是代码。
放上初始化方法
UserConfigurationManager bnb = Autodesk.AutoCAD.ApplicationServices.Core.Application.UserConfigurationManager;
bnb.CurrentProfileChanging += UserConfigManagerEvent_CurrentProfileChanging_Handler;
bnb.CurrentProfileChanged += UserConfigManagerEvent_CurrentProfileChanged_Handler;
添加调用配置文件更改事件的方法
private void UserConfigManagerEvent_CurrentProfileChanging_Handler(object sender,ProfileEventArgs e)
{
string profileName = acApp.GetSystemVariable("CPROFILE").ToString();
curProfile = e.ProfileName;
if (profileName != curProfile && !IsMessageDisplayed)
{
IsMessageDisplayed = true;
MessageBox.Show("The selected profile is not associated with Project");
}
if (string.IsNullOrEmpty(prevProfile))
{
prevProfile = profileName;
}
}
配置文件更改事件后调用
private void UserConfigManagerEvent_CurrentProfileChanged_Handler(object sender, ProfileEventArgs e)
{
AcadApplication app = (AcadApplication)Application.AcadApplication;
AcadPreferences pref = app.Preferences;
string cur = curProfile;
if (curProfile.Equals(prevProfile))
{
IsMessageDisplayed = false;
return;
}
else
{
pref.Profiles.ActiveProfile = prevProfile;
}
}
- 1 回答
- 0 关注
- 103 浏览
添加回答
举报