C#-如何调用Microstation的消息管理器

❄ 正文

 在进行Bentley二次开发的时候,通常我们需要向用户输出一些信息,比如操作的提示,错误的提示等等。可以采用以下方式:


❄ 1、通知管理器(Notification Manager)

 NotificationManager控制与用户的交互。可以用此类来生成提示、错误消息和警报对话框。

消息位置

dll名称:Bentley.DgnPlatformNET.dll
命名空间:Bentley.DgnPlatformNET
类名:NotificationManager

//打开消息弹窗
public static MessageBoxValue OpenMessageBox(MessageBoxType mbType, string message, MessageBoxIconType icon);
//向MS的底部通知栏写入提示
public static StatusInt OutputMessage(NotifyMessageDetails message);
public static void OutputPrompt(string prompt);
//设置一个标志来分配(value==true时)事件,以便在执行费时算法时,刷新界面,从而不卡顿。
public static void SetDispatchEvents(bool value);

public enum MessageBoxType
{
    YesNo = -121,
    LargeOk = -119,
    YesNoCancel = -113,
    MediumAlert = -112,
    Ok = -97,
    OkCancel = -13,
    None = 0
}
public enum MessageBoxIconType
{
    NoSymbol = 0,
    Information = 1,
    Question = 2,
    Warning = 3,
    Critical = 4
}
public enum MessageBoxValue
{
    None = 0,
    Apply = 1,
    Reset = 2,
    Ok = 3,
    Cancel = 4,
    Default = 5,
    Yes = 6,
    No = 7,
    Retry = 8,
    Stop = 9,
    Help = 10,
    YesToAll = 11,
    NoToAll = 12
}

❄ 2、消息中心(MessageCenter)

Bentley在Bentley.MstnPlatformNET中也存在与消息管理器一样的类以供调用向用户传递消息。
dll名称:ustation.dll
命名空间:Bentley.MstnPlatformNET
类名:MessageCenter

public class MessageCenter
{
    public static MessageCenter Instance { get; }
    public string StatusWarning { set; }
    public string StatusMessage { set; }
    public string StatusPrompt { set; }
    public string StatusCommand { get; set; }

    public static string GetStringFromMessageListResource(int listId, int stringId);
    public void ShowDebugMessage(string briefMessage, string detailedMessage, bool openAlertBox);
    public void ShowDebugMessage(string briefMessage, string detailedMessage, MessageAlert alertType);
    public void ShowErrorMessage(string briefMessage, string detailedMessage, bool openAlertBox);
    public void ShowErrorMessage(string briefMessage, string detailedMessage, MessageAlert alertType);
    public void ShowInfoMessage(string briefMessage, string detailedMessage, bool openAlertBox);
    public void ShowInfoMessage(string briefMessage, string detailedMessage, MessageAlert alertType);
    public void ShowMessage(MessageType messageType, string briefMessage, string detailedMessage, MessageAlert alertType);
}

❄ 3、测试代码

附上Notification Manager测试代码的链接,加载编译之后的ArticleSourceCode.dll,调用Key-in:test message manager。弹出一个操作窗体,通过选择不同选项,即可查看相应方法的效果。


测试操作窗体

>GitHub源代码

❄ 4、使用方法
  • OpenMessageBox方法
private void NotificationManagerOpenMessageBox()
{  
    NotificationManager.OpenMessageBox(NotificationManager.MessageBoxType.MediumAlert, "Medium alert",NotificationManager.MessageBoxIconType.Warning);
}
  • OutputMessage方法
private void NotificationManagerOutputMessage()
{
    OutputMessagePriority outputMessagePriority = OutputMessagePriority.Information;
    string briefMsg = "this is a brief msg";
    string detailMsg = "this is a detail msg";
    NotifyTextAttributes notifyTextAttributes = NotifyTextAttributes.AlwaysBeveled;
    NotifyMessageDetails notifyMessageDetails = new NotifyMessageDetails(outputMessagePriority,briefMsg,detailMsg,notifyTextAttributes,OutputMessageAlert.Balloon);
    NotificationManager.OutputMessage(notifyMessageDetails);    
}
OutputMessage效果
  • OutputPrompt方法
private void NotificationManagerOutputPrompt()
{
    NotificationManager.OutputPrompt("this is ouput prompt");
}
OutputPrompt使用效果

未经授权,禁止转载哦~

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一、Python简介和环境搭建以及pip的安装 4课时实验课主要内容 【Python简介】: Python 是一个...
    _小老虎_阅读 11,322评论 0 10
  • 专业考题类型管理运行工作负责人一般作业考题内容选项A选项B选项C选项D选项E选项F正确答案 变电单选GYSZ本规程...
    小白兔去钓鱼阅读 13,265评论 0 13
  • 鹿旭市的北城初中是一所十分有名的私立学校,2029年他们学校迎来了新一届的新生。在这青春年华刚刚开始的时候,七段最...
    粼粼流Yao阅读 3,379评论 0 1
  • 28班2.0第二组发言稿 熊建权20180306 分享房间:27861331 分享主题:我运动我快乐 一、三个标签...
    一日看人生阅读 1,463评论 0 0

友情链接更多精彩内容