private bool FindDataWindow(Control control)
        {
            if (control.Name == "DictionaryWindowBar")
            {
                var bar = control as Bar;

                if (bar != null)
                {
                    bar.CanHide        = false;
                    bar.CanAutoHide    = false;
                    bar.CanCustomize   = false;
                    bar.CanDockTop     = false;
                    bar.CanDockBottom  = false;
                    bar.CanDockLeft    = true;
                    bar.CanDockRight   = true;
                    bar.CanReorderTabs = false;

                    foreach (DockContainerItem item in bar.Items)
                    {
                        var dataWindow = item as DictionaryWindow;

                        if (dataWindow != null)
                        {
                            _dataPanel = dataWindow;

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        public void LookupWord()
        {
            var ctrlGroup = Svc.SM.UI.ElementWdw.ControlGroup;
            var htmlCtrl  = ctrlGroup?.FocusedControl.AsHtml();
            var htmlDoc   = htmlCtrl?.GetDocument();
            var sel       = htmlDoc?.selection;

            if (!(sel?.createRange() is IHTMLTxtRange textSel))
            {
                return;
            }

            var text = textSel.text?.Trim(' ',
                                          '\t',
                                          '\r',
                                          '\n');

            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            /*
             * int spaceIdx = text.IndexOfAny(new[] { ' ', '\r' });
             *
             * if (spaceIdx > 0)
             * text = text.Substring(0,
             *                      spaceIdx);
             *
             * if (spaceIdx == 0 || string.IsNullOrWhiteSpace(text))
             * return;
             */

            Application.Current.Dispatcher.Invoke(
                () =>
            {
                var wdw = new DictionaryWindow(_dictionaryService, text);
                wdw.ShowAndActivate();
            }
                );
        }