123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- /*-------------------------------------------------------------------------
- * 功能描述:ButtonAttribute
- * 作者:xulisong
- * 创建时间: 2019/7/25 11:30:56
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace FWindSoft.Revit.Menu
- {
- [AttributeUsage(AttributeTargets.Class)]
- public class ButtonAttribute:Attribute
- {
- public ButtonAttribute()
- {
- //此处获取到的程序集为mscorlib,不太合适
- //var assemblyName= Assembly.GetCallingAssembly().GetName().Name;
- this.TabName = "自定义";
- this.PanelName = "自定义";
- }
- /// <summary>
- /// 菜单顺序
- /// </summary>
- public int Index { get; set; }
- private string m_TabName;
- private string m_TabText;
- /// <summary>
- /// tab名称
- /// </summary>
- public string TabName
- {
- get { return GetResult(m_TabName, m_TabText); }
- set
- {
- m_TabName = value;
- }
- }
- /// <summary>
- /// tab显示
- /// </summary>
- public string TabText
- {
- get { return GetResult(m_TabText, m_TabName); }
- set
- {
- m_TabText = value;
- }
- }
- private string m_PanelName;
- private string m_PanelText;
- /// <summary>
- /// panel名称
- /// </summary>
- public string PanelName
- {
- get { return GetResult(m_PanelName, m_PanelText); }
- set
- {
- m_PanelName = value;
- }
- }
- /// <summary>
- /// panel显示
- /// </summary>
- public string PanelText
- {
- get { return GetResult(m_PanelText, m_PanelName); }
- set
- {
- m_PanelText = value;
- }
- }
- private string m_ButtonName;
- private string m_ButtonText;
- /// <summary>
- /// button名称
- /// </summary>
- public string ButtonName
- {
- get { return GetResult(m_ButtonName, m_ButtonText); }
- set
- {
- m_ButtonName = value;
- }
- }
- /// <summary>
- /// button显示
- /// </summary>
- public string ButtonText
- {
- get { return GetResult(m_ButtonText, m_ButtonName); }
- set
- {
- m_ButtonText = value;
- }
- }
- public string ImageName { get; set; }
- public string Description { get; set; }
- public string LongDescription { get; set; }
- public RevitButtonStyle ButtonStyle { get; set; }
- public string GroupName { get; set; }
- public bool IsStack { get; set; }
- private T GetResult<T>(T useResult, T spareResult) where T : class
- {
- return useResult ?? spareResult;
- }
- /// <summary>
- /// 生成tab
- /// </summary>
- /// <returns></returns>
- public RevitTab GetTab()
- {
- RevitTab tab = new RevitTab();
- tab.Text = this.TabText;
- tab.Name = this.TabName;
- return tab;
- }
- /// <summary>
- /// 生成Panel
- /// </summary>
- /// <returns></returns>
- public RevitPanel GetPanel()
- {
- RevitPanel panel = new RevitPanel();
- panel.Text = this.PanelText;
- panel.Name = this.PanelName;
- panel.TabName = this.TabName;
- return panel;
- }
- /// <summary>
- /// 生成Button
- /// </summary>
- /// <returns></returns>
- public RevitButton GetButton()
- {
- RevitButton button = new RevitButton();
- button.Text = this.ButtonText;
- button.Name = this.ButtonName;
- button.PanelName = this.PanelName;
- button.IsStack = this.IsStack;
- button.GroupName = this.GroupName;
- button.ButtonStyle = this.ButtonStyle;
- button.Description = this.Description;
- button.LongDescription = this.LongDescription;
- button.ImageName = this.ImageName;
- return button;
- }
-
- }
- }
|