Пример #1
0
        //--------------------------------------------------------------------------
        public void LocationDoubleClicked(LocationDetail location)
        {
            string queryMessageResult = "";

            _currentLoadingScreen = new LoadingScreenDialog(
                "Retreiving Contents from Document ...", false);

            Task.Run(() => {
                System.Threading.Thread.Sleep(200);

                _businessLogic.Queries.GetContents(
                    location,
                    (contents, wordOffsetBegin, wordOffsetEnd, status, message) => {
                    queryMessageResult = message;

                    if (String.IsNullOrEmpty(queryMessageResult))
                    {
                        _parentForm.Invoke((MethodInvoker) delegate {
                            UIUtils.SetRichTextContents(_parentForm.richTextBoxContents,
                                                        contents,
                                                        wordOffsetBegin,
                                                        wordOffsetEnd);
                        });
                    }

                    _currentLoadingScreen.Invoke((MethodInvoker) delegate {
                        _currentLoadingScreen.CloseScreen();
                    });
                }); // GetContents
            });

            // this line waits until _currentLoadingScreen.CloseScreen() is called
            _currentLoadingScreen.ShowDialog();
            _currentLoadingScreen = null;

            // check results
            if (!String.IsNullOrEmpty(queryMessageResult))
            {
                System.Windows.Forms.MessageBox.Show(queryMessageResult, "Error");
                return;
            }
        }