示例#1
0
 public static ElementInfoPanel GetInstance()
 {
     if (s_instance == null)
     {
         s_instance = new ElementInfoPanel();
     }
     return(s_instance);
 }
示例#2
0
 private void OnViewActivated(object sender, ViewActivatedEventArgs e)
 {
     try
     {
         //重新打开视图则隐藏Panel
         DockablePane panel = m_uiApp.GetDockablePane(new DockablePaneId(ElementInfoPanel.GetInstance().Id));
         if (panel != null)
         {
             ElementInfoPanel.GetInstance().Update(new InfoEntityData());
             panel.Hide();
         }
         DockablePane imageControl = m_uiApp.GetDockablePane(new DockablePaneId(ImageControl.Instance().Id));
         if (imageControl != null)
         {
             imageControl.Hide();
         }
     }
     catch (System.Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
示例#3
0
        public override Result RunIt(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            if (!File.Exists(Path.Combine(App.Instance.settings.SqliteFilePath, App.Instance.settings.SqliteFileName)))
            {
                MessageBox.Show("本地数据文件不存在,请先更新");
                return(Result.Succeeded);
            }
            DockablePane panel = commandData.Application.GetDockablePane(new DockablePaneId(ElementInfoPanel.GetInstance().Id));

            panel.Show();
            commandData.Application.Idling += App.Instance.IdlingHandler;
            return(Result.Succeeded);
        }
示例#4
0
        /// <summary>
        /// Idling event handler.
        /// </summary>
        /// <remarks>
        /// We keep the handler very simple. First check
        /// if we still have the form. If not, unsubscribe
        /// from Idling, for we no longer need it and it
        /// makes Revit speedier. If the form is around,
        /// check if it has a request ready and process
        /// it accordingly.
        /// </remarks>
        public void IdlingHandler(
            object sender,
            IdlingEventArgs args)
        {
            UIApplication uiapp = sender as UIApplication;
            UIDocument    uidoc = uiapp.ActiveUIDocument;

            // UI document is null if the project is closed.

            if (null != uidoc)
            {
                //存放实体
                string entity   = string.Empty;
                bool   isSurvey = false;
                // ElementInfoPanel
#if (Since2016)
                Element selectElement = uidoc.Document.GetElement(uidoc.Selection.GetElementIds().FirstOrDefault());
#else
                Element selectElement = uidoc.Selection.Elements.Cast <Element>().FirstOrDefault <Element>();
#endif
                if (selectElement != null)
                {
                    entity = Utils.GetParameterValueAsString(selectElement, Res.String_ParameterName);
                    if (!string.IsNullOrEmpty(entity))
                    {
                        isSurvey = Res.String_ParameterSurveyType.Equals(selectElement.Name);

                        if (m_selectedElementId != selectElement.Id.IntegerValue)
                        {
                            m_selectedElementId = selectElement.Id.IntegerValue;
                            // isSurvey = true;
                            if (!isSurvey)
                            {//不是测量数据
                             //sqlite
                                InfoEntityData infoEntityData = Sqlite.SelectInfoData(entity);
                                ElementInfoPanel.GetInstance().Update(infoEntityData);
                            }
                            else
                            {//测量数据绘制折线图
                                DrawEntityData drawEntityData      = App.Instance.Sqlite.SelectDrawEntityData(entity, null, null);
                                NewImageForm.Instance().EntityData = drawEntityData;
                                ExcelTable excel             = App.Instance.Sqlite.SelectADrawType(entity);
                                NewImageForm.Instance().Text = excel == null ? "测点" + entity + "的测量数据" : excel.CurrentFile + ": 测点" + entity + "的测量数据";
                                NewImageForm.Instance().Show();
                            }
                        }
                    }
                }
                else
                {
                    if (m_selectedElementId != -1)
                    {//清空数据
                        m_selectedElementId = -1;
                        ElementInfoPanel.GetInstance().Update(null);
                        if (NewImageForm.Instance().Visible)
                        {
                            NewImageForm.Instance().EntityData = new DrawEntityData();
                        }
                    }
                }
            }
        }
示例#5
0
        public Result OnStartup(UIControlledApplication app)
        {
            //UI对象
            m_uiApp = app;
            //APP的引用
            _app = this;
            //事件绑定:打开了一个文档的视图
            app.ViewActivated += OnViewActivated;
            //事件绑定:闲置事件
            //app.Idling += IdlingHandler;
            app.ControlledApplication.DocumentClosing += DocumentClosingAction;
            app.ControlledApplication.DocumentOpened  += DocumentOpenedAction;


            //加载格式文件
            string file = Path.Combine(Path.GetDirectoryName(typeof(App).Assembly.Location), "MahApps.Metro.dll");

            if (File.Exists(file))
            {
                System.Reflection.Assembly.LoadFrom(file);
            }
            //属性面板
            m_elementInfoPanel = ElementInfoPanel.GetInstance();
            m_ImageControl     = ImageControl.Instance();
            //注册Dockable面板
            app.RegisterDockablePane(new DockablePaneId(m_elementInfoPanel.Id), "构件信息", m_elementInfoPanel);
            app.RegisterDockablePane(new DockablePaneId(m_ImageControl.Id), "测点信息", m_ImageControl);
            //
            //
            string tabName       = Res.String_AppTabName;
            string addinAssembly = this.GetType().Assembly.Location;
            string addinDir      = Path.GetDirectoryName(addinAssembly);
            string userManual    = Path.Combine(addinDir, "help.pdf");
            //
            // 创建帮助选项
            ContextualHelp cHelp = new ContextualHelp(ContextualHelpType.Url, userManual);

            app.CreateRibbonTab(tabName);
            RibbonPanel ribbonPanel = app.CreateRibbonPanel(tabName, Res.String_AppPanelName);

            // 设置按钮
            PushButton cmdButton = (PushButton)ribbonPanel.AddItem(
                new PushButtonData("Tooltip_Settings", Res.CommandName_Settings,
                                   addinAssembly, "Revit.Addin.RevitTooltip.CmdSettings"));
            BitmapSource image = Utils.ConvertFromBitmap(Res.settings.ToBitmap());

            cmdButton.Image   = cmdButton.LargeImage = image;
            cmdButton.ToolTip = Res.CommandDescription_Settings;
            cmdButton.SetContextualHelp(cHelp);
            //添加分割
            ribbonPanel.AddSeparator();
            //点击显示属性面板
            ElementInfoButton = (PushButton)ribbonPanel.AddItem(
                new PushButtonData("ElementInfo", Res.Command_ElementInfo,
                                   addinAssembly, "Revit.Addin.RevitTooltip.CmdElementInfo"));
            image = Utils.ConvertFromBitmap(Res.tooltip_on.ToBitmap());
            ElementInfoButton.Image   = ElementInfoButton.LargeImage = image;
            ElementInfoButton.ToolTip = Res.CommandDescription_TooltipOn;
            ElementInfoButton.SetContextualHelp(cHelp);
            //添加分割
            ribbonPanel.AddSeparator();
            //打开绘图面板
            SurveyImageInfoButton = (PushButton)ribbonPanel.AddItem(
                new PushButtonData("SurveyImageInfo", Res.Command_SurveyImageInfo,
                                   addinAssembly, "Revit.Addin.RevitTooltip.CmdImageControl"));
            image = Utils.ConvertFromBitmap(Res.tooltip_on.ToBitmap());
            SurveyImageInfoButton.Image   = SurveyImageInfoButton.LargeImage = image;
            SurveyImageInfoButton.ToolTip = Res.CommandDescription_SurveyImage;
            SurveyImageInfoButton.SetContextualHelp(cHelp);
            //添加分割
            ribbonPanel.AddSeparator();
            //从Mysql导入数据到Sqlite
            LoadDataToSqliteButton = (PushButton)ribbonPanel.AddItem(
                new PushButtonData("CommandReloadSQLiteData", Res.Command_ReloadExcelData,
                                   addinAssembly, "Revit.Addin.RevitTooltip.CmdLoadSQLiteData"));
            image = Utils.ConvertFromBitmap(Res.refresh);
            LoadDataToSqliteButton.Image   = LoadDataToSqliteButton.LargeImage = image;
            LoadDataToSqliteButton.ToolTip = Res.CommandDescription_ReloadExcelData;
            LoadDataToSqliteButton.SetContextualHelp(cHelp);
            // 分割
            ribbonPanel.AddSeparator();

            // About\Help
            PushButtonData aboutButtonData = new PushButtonData("AboutButton",
                                                                Res.CommandName_About, addinAssembly, "Revit.Addin.RevitTooltip.CommandAbout");

            aboutButtonData.Image   = Utils.ConvertFromBitmap(Res.about_16.ToBitmap());
            aboutButtonData.ToolTip = Properties.Resources.CommandDescription_About;
            aboutButtonData.SetContextualHelp(cHelp);
            PushButtonData helpButtonData = new PushButtonData("HelpButton",
                                                               Res.CommandName_Help, addinAssembly, "Revit.Addin.RevitTooltip.CommandHelp");

            helpButtonData.Image   = Utils.ConvertFromBitmap(Res.help_16.ToBitmap());
            helpButtonData.ToolTip = Properties.Resources.CommandDescription_Help;
            helpButtonData.SetContextualHelp(cHelp);
            ribbonPanel.AddStackedItems(aboutButtonData, helpButtonData);
            //设置成隐藏
            // this.SetPanelEnabled(false);

            return(Result.Succeeded);
        }