Пример #1
0
        protected override bool DoUI()
        {
            var directory = System.Reflection.Assembly.GetExecutingAssembly().Location;

            //string directory = System.AppDomain.CurrentDomain.BaseDirectory;
            //MessageBox.Show(directory);
            System.IO.Directory.SetCurrentDirectory(directory.Substring(0, directory.LastIndexOf("\\")));

            Form = new EarthworkBlockingForm(this.m_app);
            PickObjectsMouseHook mouseHook = new PickObjectsMouseHook();
            DialogResult         result    = DialogResult.Retry;

            while ((result = Form.ShowDialog(new Hook.RevitHandle(Process.GetCurrentProcess().MainWindowHandle))) == DialogResult.Retry)
            {
                if (result == DialogResult.Cancel)
                {
                    return(false);
                }
                if (result == DialogResult.OK)
                {
                    return(true);
                }
                if (Form.ShowDialogType == ShowDialogType.AddElements || Form.ShowDialogType == ShowDialogType.DeleleElements)
                {
                    Hooker.DelegateCompletingAction(() =>
                    {
                        Form.SelectedElementIds = m_uiDoc.Selection.PickObjects(ObjectType.Element, "选择要添加的构件")
                                                  .Select(p => m_doc.GetElement(p.ElementId).Id).ToList();
                    });
                    Form.FinishElementSelection();

                    //Hooker Hooker = new Hooker();
                    //try
                    //{
                    //    Hooker.MouseHookProcedure = new Hooker.HookProc(MouseHookProc);
                    //    Hooker.Start();
                    //    Form.SelectedElementIds = m_uiDoc.Selection.PickObjects(ObjectType.Element, "选择要添加的构件")
                    //        .Select(p => m_doc.GetElement(p.ElementId).Id).ToList();
                    //    Hooker.Stop();
                    //}
                    //catch (Exception ex)
                    //{
                    //    Hooker.Stop();
                    //}

                    //try
                    //{
                    //    mouseHook.InstallHook();
                    //    Form.SelectedElementIds = m_uiDoc.Selection.PickObjects(ObjectType.Element, "选择要添加的构件")
                    //        .Select(p => m_doc.GetElement(p.ElementId).Id).ToList();
                    //    mouseHook.UninstallHook();
                    //}
                    //catch
                    //{
                    //    mouseHook.UninstallHook();
                    //}
                }
                if (Form.ShowDialogType == ShowDialogType.ViewGT6 || Form.ShowDialogType == ShowDialogType.ViewCompletion)
                {
                    Hooker.DelegateCompletingAction(() =>
                    {
                        m_uiDoc.Selection.PickObjects(ObjectType.Element, "");
                    });

                    //try
                    //{
                    //    mouseHook.InstallHook();
                    //    m_uiDoc.Selection.PickObjects(ObjectType.Element, "");
                    //    mouseHook.UninstallHook();
                    //}
                    //catch
                    //{
                    //    mouseHook.UninstallHook();
                    //}
                }
            }
            return(true);

            #region 非模态
            //try
            //{
            //    if (ConfigPathManager.IniProjectDB(this.m_doc))
            //    {
            //        Form = new EarthworkBlockingForm(this.m_app);
            //        Form.ShowDialog();
            //        return true;
            //    }
            //    else
            //        return false;
            //}
            //catch(Exception ex)
            //{
            //    TaskDialog.Show("错误", ex.Message);
            //    return false;
            //}
            #endregion
        }
Пример #2
0
        protected override bool DoUI()
        {
            Form = new EarthworkBlockingForm(this.m_app);
            PickObjectsMouseHook mouseHook = new PickObjectsMouseHook();
            DialogResult         result    = DialogResult.Retry;

            while ((result = Form.ShowDialog(new RevitHandle(Process.GetCurrentProcess().MainWindowHandle))) == DialogResult.Retry)
            {
                if (result == DialogResult.Cancel)
                {
                    return(false);
                }
                if (result == DialogResult.OK)
                {
                    return(true);
                }
                if (Form.ShowDialogType == ShowDialogType.AddElements || Form.ShowDialogType == ShowDialogType.DeleleElements)
                {
                    try
                    {
                        mouseHook.InstallHook();
                        Form.SelectedElementIds = m_uiDoc.Selection.PickObjects(ObjectType.Element, "选择要添加的构件")
                                                  .Select(p => m_doc.GetElement(p.ElementId).Id).ToList();
                        mouseHook.UninstallHook();
                    }
                    catch
                    {
                        mouseHook.UninstallHook();
                    }
                    Form.FinishElementSelection();
                }
                if (Form.ShowDialogType == ShowDialogType.ViewGT6 || Form.ShowDialogType == ShowDialogType.ViewCompletion)
                {
                    try
                    {
                        mouseHook.InstallHook();
                        m_uiDoc.Selection.PickObjects(ObjectType.Element, "");
                        mouseHook.UninstallHook();
                    }
                    catch
                    {
                        mouseHook.UninstallHook();
                    }
                }
            }
            return(true);

            #region 非模态
            //try
            //{
            //    if (ConfigPathManager.IniProjectDB(this.m_doc))
            //    {
            //        Form = new EarthworkBlockingForm(this.m_app);
            //        Form.ShowDialog();
            //        return true;
            //    }
            //    else
            //        return false;
            //}
            //catch(Exception ex)
            //{
            //    TaskDialog.Show("错误", ex.Message);
            //    return false;
            //}
            #endregion
        }