AutoCAD.Net/C#.Net QQ群:193522571 AutoCAD中状态栏

AutoCAD中状态栏类:

  public sealed class StatusBar
  {
    protected StatusBar(AcApStatusBar* impObj);

    public PaneCollection Panes { get; }
    public TrayItemCollection TrayItems { get; }
    public Window Window { get; }

    public void CloseBubbleWindows();
    public Pane GetDefaultPane(DefaultPane pane);
    public void RemoveDefaultPane(DefaultPane pane);
    public void Update();
  }

其中Panes中包含默认Pane,默认Pane的枚举如下:

  public enum DefaultPane
  {
    ModeMacro = 0,
    CursorCoordinates = 1,
    Snap = 2,
    Grid = 3,
    Ortho = 4,
    Polar = 5,
    ObjectTrack = 6,
    LineWeight = 7,
    PaperModel = 8,
    Paper = 9,
    Model = 10,
    ObjectSnap = 11,
    Float = 12,
    Table = 13,
    Spacer = 14,
    ViewportMaximizePrevious = 15,
    ViewportMaximize = 16,
    ViewportMaximizeNext = 17,
    DynamicInput = 18,
    DynamicUcs = 19,
    LayoutModelIcons = 20,
    ModelIcon = 21,
    LayoutIcon = 22,
    LayoutMoreIcon = 23,
    All = 24,
  }
View Code

测试后发现移除了默认Pane后,想再加入其中一项就会导致内存出错。

原本打算先移除掉再加上走不通,不过Panes中包含了一个可以让用户自定义值的Pane,即:ModeMacro,其默认visible为false,初始值为“.”,后面发现移除不了默认的pane可以将其隐藏,显示了用户的值后再将其恢复,同样可以达到预计效果。

显示用户文本:

        foreach (Pane p in AcadApplication.StatusBar.Panes)
        {
          if (p.Text != ".")
          {
            p.Visible = false;
          }
          else
          {
            p.Visible = true;
            p.Text = statusBarValue;
          }
        }
        AcadApplication.StatusBar.Update();

恢复默认:

      foreach (Pane p in AcadApplication.StatusBar.Panes)
      {
        if (p.Text == statusBarValue)
        {
          p.Text = ".";
          p.Visible = false;
        }
        else
        {
          p.Visible = true;
        }
      }
      AcadApplication.StatusBar.Update();

 

你可能感兴趣的:(AutoCAD.Net/C#.Net QQ群:193522571 AutoCAD中状态栏)