Ejemplo n.º 1
0
 public void PhotoSearchServiceCallback(PhotoSearchServiceResult photoSearchServiceResult)
 {
     //this.writeLogLine("status: " + status + " result: " + result);
     if (this.OnServiceCallBack != null)
     {
         PhotoSearchServiceCallBackEventArgs args = new PhotoSearchServiceCallBackEventArgs()
         {
             Result = photoSearchServiceResult
         };
         this.OnServiceCallBack(this, args);
     }
 }
Ejemplo n.º 2
0
        private void Context_OnServiceCallBack(object sender, PhotoSearchServiceCallBackEventArgs e)
        {
            this.IsJobRunning = false;

            PhotoSearchServiceResult serviceResult = e.Result;

            if (serviceResult.Type == PhotoSearchServiceResultType.OK)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() => this.view.webBrowser.NavigateToString(serviceResult.Data.ToString())));
                Application.Current.Dispatcher.BeginInvoke(new Action(() => this.resultHtml = serviceResult.Data.ToString()));
            }
            else if (serviceResult.Type == PhotoSearchServiceResultType.Cancel)
            {
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                                                                      MessageBox.Show(this.view,
                                                                                      "Выполнение задачи прервано",
                                                                                      "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Exclamation)));
            }
            else if (serviceResult.Type == PhotoSearchServiceResultType.Confirmation)
            {
                MessageBoxResult dialogResult = MessageBoxResult.No;
                Application.Current.Dispatcher.Invoke(new Action(() =>
                                                                 dialogResult = MessageBox.Show(serviceResult.Data.ToString() + Environment.NewLine + "Продолжить?",
                                                                                                "Подтверждение", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No)));
                if (dialogResult == MessageBoxResult.Yes)
                {
                    this.startJob(true);
                }
            }
            else
            {
                Application.Current.Dispatcher.Invoke(new Action(() =>
                                                                 MessageBox.Show(this.view, serviceResult.Data.ToString(),
                                                                                 "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error)));
            }
            this.raiseCanExecuteChanged();
        }