public BrickDimSelector(UIApplication uiApp, EventHandlerWithWpfArg eExternalMethodWpfArg) { _uiDoc = uiApp.ActiveUIDocument; _doc = _uiDoc.Document; //_app = _doc.Application; //_uiApp = _doc.Application; Closed += MainWindow_Closed; MyWindowHeight = 135; this.DataContext = this; InitializeComponent(); _mExternalMethodWpfArg = eExternalMethodWpfArg; }
/// <summary> /// This is the method which launches the WPF window, and injects any methods that are /// wrapped by ExternalEventHandlers. This can be done in a number of different ways, and /// implementation will differ based on how the WPF is set up. /// </summary> /// <param name="uiapp">The Revit UIApplication within the add-in will operate.</param> public void ShowForm(UIApplication uiapp) { // If we do not have a dialog yet, create and show it if (_mMyForm != null && _mMyForm == null) { return; } //EXTERNAL EVENTS WITH ARGUMENTS EventHandlerWithWpfArg evWpf = new EventHandlerWithWpfArg(); _mMyForm = new BrickDimSelector(uiapp, evWpf); HwndSource hwndSource = HwndSource.FromHwnd(uiapp.MainWindowHandle); System.Windows.Window wnd = hwndSource.RootVisual as System.Windows.Window; if (wnd != null) { _mMyForm.Owner = wnd; _mMyForm.ShowInTaskbar = false; _mMyForm.Show(); } }