Exemplo n.º 1
0
        public void OpenWPFInSeparateThread(IRibbonControl control)
        {
            if (!CheckWorkbook())
            {
                return;
            }

            if (_refEditWindow2 == null)
            {
                Thread thread = new Thread(() =>
                {
                    try
                    {
                        _refEditWindow2         = new RefEditWindow(_excelThreadId);
                        _refEditWindow2.Closed += delegate { _refEditWindow2 = null; };
                        _refEditWindow2.ShowDialog();
                    }
                    catch (Exception e)
                    {
                        Debug.Print("Error: {0}", e);
                    }
                });

                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            }
            else
            {
                _refEditWindow2.Dispatcher.Invoke(new Action(() => _refEditWindow2.Activate()));
            }
        }
Exemplo n.º 2
0
        public void OpenWPFInExcelThread(IRibbonControl control)
        {
            if (!CheckWorkbook())
            {
                return;
            }

            if (_refEditWindow1 == null)
            {
                try
                {
                    _refEditWindow1         = new RefEditWindow(_excelThreadId);
                    _refEditWindow1.Closed += delegate { _refEditWindow1 = null; };
                    _refEditWindow1.Show();
                }
                catch (Exception e)
                {
                    Debug.Print("Error: {0}", e);
                }
            }
            else
            {
                _refEditWindow1.Activate();
            }
        }