1 回答

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超3個(gè)贊
我終于找到了答案,只需使用 UrrentProfileChangingEventHandler 顯示彈出窗口,并在 CurrentProfileChangedEventHandler 事件上激活您想要的配置文件。這是代碼。
放上初始化方法
UserConfigurationManager bnb = Autodesk.AutoCAD.ApplicationServices.Core.Application.UserConfigurationManager;
bnb.CurrentProfileChanging += UserConfigManagerEvent_CurrentProfileChanging_Handler;
bnb.CurrentProfileChanged += UserConfigManagerEvent_CurrentProfileChanged_Handler;
添加調(diào)用配置文件更改事件的方法
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;
}
}
配置文件更改事件后調(diào)用
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 關(guān)注
- 102 瀏覽
添加回答
舉報(bào)