/// <summary>
 /// The OnWebBrowser_LoadingStateChanged.
 /// </summary>
 /// <param name="sender">The sender<see cref="object"/>.</param>
 /// <param name="e">The e<see cref="LoadingStateChangedEventArgs"/>.</param>
 private void OnWebBrowser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
 {
     UIThreadHelper.Invoke(() =>
     {
         this.CanBackward = e.CanGoBack;
         this.CanForward  = e.CanGoForward;
         this.CanReload   = e.CanReload;
     });
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TabItem"/> class.
 /// </summary>
 /// <param name="guid">The unique identifier.</param>
 public TabItem(Guid guid)
 {
     this.Guid            = guid;
     this.HeaderViewModel = new WebBrowserTabHeaderViewModel {
         Header = "No Header"
     };
     UIThreadHelper.Invoke(() =>
     {
         this.Header = new WebBrowserTabHeaderView {
             DataContext = this.HeaderViewModel
         };
     });
 }
 /// <summary>
 /// The SaveSettings.
 /// </summary>
 private void SaveSettings()
 {
     this.ChartEditorViewModel.UpdateSettings();
     UIThreadHelper.Invoke(() =>
     {
         var window              = this.GlobalData.MainWindow;
         var settings            = this.GlobalData.SettingsModel;
         settings.WindowPosition = new Point(window.Left, window.Top);
         settings.WindowWidth    = window.ActualWidth;
         settings.WindowHeight   = window.Height;
         settings.WindowState    = window.WindowState;
         SettingsHelper.Save(settings, window);
     });
 }
Exemplo n.º 4
0
        /// <summary>
        /// The OnBeforeDownload.
        /// </summary>
        /// <param name="chromiumWebBrowser">The chromiumWebBrowser<see cref="IWebBrowser"/>.</param>
        /// <param name="browser">The browser<see cref="IBrowser"/>.</param>
        /// <param name="downloadItem">The downloadItem<see cref="DownloadItem"/>.</param>
        /// <param name="callback">The callback<see cref="IBeforeDownloadCallback"/>.</param>
        public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
        {
            lock (this.Lock)
            {
                if (this.DownloadItemDict.ContainsKey(downloadItem.Id) || callback.IsDisposed)
                {
                    return;
                }

                UIThreadHelper.Invoke(() =>
                {
                    using (callback)
                    {
                        var fileName = downloadItem.SuggestedFileName;
                        var filePath = Path.Combine(this.DownloadPath, downloadItem.SuggestedFileName);
                        if (this.IsShowDialog)
                        {
                            var dialog = new VistaSaveFileDialog
                            {
                                FileName         = fileName,
                                CheckPathExists  = true,
                                InitialDirectory = this.DownloadPath,
                                OverwritePrompt  = true,
                                Title            = "Save Link to...",
                            };

                            var element = chromiumWebBrowser as FrameworkElement;

                            var window = Window.GetWindow(element);
                            if (!(bool)dialog.ShowDialog(window))
                            {
                                return;
                            }

                            filePath = dialog.FileName;
                        }

                        this.DownloadPath = Path.GetDirectoryName(filePath);
                        var model         = new DownloadProcessModel(downloadItem);
                        this.DownloadItemDict.Add(downloadItem.Id, model);
                        this.DownloadItemModels.Insert(0, model);
                        callback.Continue(filePath, false);
                    }
                });
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WebBrowserHeaderedItemViewModel"/> class.
        /// </summary>
        /// <param name="globalBrowserData">The globalBrowserData<see cref="GlobalBrowserData"/>.</param>
        /// <param name="cefWindowData">The cefWindowData<see cref="CefWindowData"/>.</param>
        /// <param name="downloadAction">The downloadAction<see cref="Action{Operation}"/>.</param>
        internal WebBrowserHeaderedItemViewModel(GlobalBrowserData globalBrowserData, CefWindowData cefWindowData, Action <Operation> downloadAction)
        {
            this.VideoBrowserViewModel = new VideoBrowserViewModel(globalBrowserData, cefWindowData)
            {
                DownloadAction = downloadAction
            };

            this.VideoBrowserViewModel.PropertyChanged += this.OnVideoBrowserViewModel_PropertyChanged;
            this.Title = this.VideoBrowserViewModel.Header;
            UIThreadHelper.Invoke(() =>
            {
                this.VideoBrowserView = new VideoBrowserView {
                    DataContext = this.VideoBrowserViewModel
                };
                this.Content = this.VideoBrowserView;
            });
        }
        /// <summary>
        /// The Test.
        /// </summary>
        /// <param name="testWindow">The testWindow<see cref="Window"/>.</param>
        protected override void Test(Window testWindow)
        {
            var client = this.GlobalBrowserData.InterTabClient;
            DefaultTabHostWindow window = null;

            UIThreadHelper.Invoke(() =>
            {
                var viewModel       = new DefaultTabHostViewModel(this.GlobalBrowserData);
                var browserTabModel = viewModel.WebBrowserTabControlViewModel;
                var tab             = new WebBrowserHeaderedItemViewModel(this.GlobalBrowserData, browserTabModel.CefWindowData, null);
                //browserTabModel.TabItems.Add(tab);
                window = new DefaultTabHostWindow {
                    DataContext = viewModel
                };
            });

            window.ShowDialog();
        }