Esempio n. 1
0
        private async void Button_CheckUpdate_Click(object sender, RoutedEventArgs e)
        {
            var res = ServiceConnection.GetUpdate();

            Button_CheckUpdate.IsEnabled = false;
            Button_CheckUpdate.Content   = "正在检测更新...";
            if (await res == "Error")
            {
                Button_CheckUpdate.IsEnabled = true;
                Button_CheckUpdate.Content   = "加载出错";
            }
            else if (await res == "Latest")
            {
                Button_CheckUpdate.Content = "最新版本";
            }
            else
            {
                if (browser == null)
                {
                    browser = new CefSharp.Wpf.ChromiumWebBrowser();
                    Grid_Web.Children.Add(browser);
                }
                browser.Address = await res;
                Button_CheckUpdate.IsEnabled = true;
                Button_CheckUpdate.Content   = "检测更新";
            }
        }
Esempio n. 2
0
        private void CEFWindow_Loaded(object sender, RoutedEventArgs e)
        {
            IntPtr     hwnd = new WindowInteropHelper(this).Handle;
            HwndSource hs   = HwndSource.FromHwnd(hwnd);

            hs.AddHook(new HwndSourceHook(WndProc));

            chromeMain                      = new CefSharp.Wpf.ChromiumWebBrowser();
            chromeMain.MaxHeight            = 720;
            chromeMain.MaxWidth             = 1200;
            chromeMain.MinHeight            = 720;
            chromeMain.MinWidth             = 1200;
            chromeMain.MouseUp             += ChromeMain_MouseUp;
            this.Content                    = chromeMain;
            chromeMain.FrameLoadEnd        += ChromeMain_FrameLoadEnd;
            chromeMain.LoadingStateChanged += ChromeMain_LoadingStateChanged;
            chromeMain.RequestHandler       = new OxoRequestHandler();
            //chromeMain.Address = "https://www.dmm.com/";
            //chromeMain.Address = "http://pc-play.games.dmm.com/play/bungo/";

            //chromeMain.Address = "http://html5test.com/";
            //chromeMain.Address = "http://www.dmm.com/netgame/social/-/gadgets/=/app_id=854854/";

            chromeMain.Address = "https://apis.baidu.com/store/aladdin/land?cardType=ipSearch";


            chromeMain.Focus();
        }
Esempio n. 3
0
 public GettingStarted(string url)
 {
     InitializeComponent();
     DataContext = this;
     this.url    = url;
     CefSharp.Wpf.ChromiumWebBrowser browser;
     browser = new CefSharp.Wpf.ChromiumWebBrowser(this.url)
     {
         LifeSpanHandler = new BasicLifeSpanHandler()
     };
     content.Child = browser;
 }
 public void PasteElement(CefSharp.Wpf.ChromiumWebBrowser MainWindowBrowser)
 {
     if (copycheck)
     {
         var    clipboarddata = System.Windows.Clipboard.GetText();
         IFrame frame         = MainWindowBrowser.GetMainFrame();
         frame.ExecuteJavaScriptAsync(String.Format("pasteAllElements(`{0}`)", clipboarddata));
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Please select an element to paste", "Element Selection Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // get current window handle;
            {
                _hWnd = new WindowInteropHelper(this).Handle;
            }

            // create chrome browser.
            // need to do this programatically because it's
            // bugging up when directly added in XAML
            {
                _browser = new CefSharp.Wpf.ChromiumWebBrowser();
                this.gridContent.Children.Add(_browser);
                _browser.FrameLoadStart += (s, fl) =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        this.tbYTID.IsEnabled = false;
                    });
                };
                _browser.FrameLoadEnd += (s, fl) =>
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        this.tbYTID.IsEnabled = true;
                    });
                };
            }

            // init events
            {
                gridTitleBar.MouseDown        += GridTitleBar_MouseDown;
                gridTitleBar.MouseUp          += GridTitleBar_MouseUp;
                gridSideDragBar.MouseDown     += GridTitleBar_MouseDown;
                gridSideDragBar.MouseUp       += GridTitleBar_MouseUp;
                gridParentContent.SizeChanged += GridParentContent_SizeChanged;
                btnLoad.Click += BtnLoad_Click;

                // force window on top.
                _timer.Tick += (s, te) =>
                {
                    ForceOnTop();

                    // no, we do not want this.
                    //this.Topmost = true;
                };
            }

            gridSideDragBar.Visibility = Visibility.Collapsed;
        }
        /// <summary>
        /// Executes when the history settings is clicked. Opens a new tab with the history
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void History_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var webBrowser = new CefSharp.Wpf.ChromiumWebBrowser();

            webBrowser.BrowserSettings.FileAccessFromFileUrls = CefSharp.CefState.Enabled;  // Enable loading local files through the browser
            var mainWindow = Application.Current.MainWindow as MainWindow;


            NavigationBarControl navigationBar = new NavigationBarControl();
            var browserTab = new Utils.BrowserTab(navigationBar, webBrowser);

            webBrowser.Address = Utils.OrganicUtility.GetLocalPageActualUrl("organic://history");
            mainWindow.browserTabControl.AddTab(webBrowser, "History", MainWindow.CreateGrid(navigationBar, webBrowser));
        }
Esempio n. 7
0
        public static void GetKanColle2ndHtml5Core(CefSharp.Wpf.ChromiumWebBrowser browser)
        {
            try
            {
                browser.ExecuteScriptAsync("var node = document.createElement('style'); " +
                                           "node.innerHTML = 'html, body, iframe {overflow:hidden;margin:0;}'; " +
                                           "document.body.appendChild(node);");

                browser.ExecuteScriptAsync("var node = document.createElement('style'); " +
                                           "node.innerHTML = 'game_frame {position:fixed; left:50%; top:0px; margin-left:-480px; z-index:1;}'; " +
                                           "document.body.appendChild(node);");

                browser.ExecuteScriptAsync("var node = document.createElement('style'); " +
                                           "node.innerHTML = 'ul.area-menu {display: none;}'; " +
                                           "document.body.appendChild(node);");
                browser.ExecuteScriptAsync("var node = document.createElement('style'); " +
                                           "node.innerHTML = '.dmm-ntgnavi {display: none;}'; " +
                                           "document.body.appendChild(node);");

                var game_frame = browser.GetBrowser().GetFrame("game_frame");
                var source     = game_frame?.GetSourceAsync();
                source?.Wait();


                //Browser.SetZoomLevel(Math.Log(zoomFactor, 1.2));


                //if (StyleSheetApplied)
                //{
                //    Browser.Size = Browser.MinimumSize = new Size(
                //        (int)(KanColleSize.Width * zoomFactor),
                //        (int)(KanColleSize.Height * zoomFactor)
                //        );

                //    CenteringBrowser();
                //}
                //"overlap-contents"
                //var contents_iframe = browser.GetBrowser().GetFrame("contents_iframe");
                //var list2 = game_frame.Browser.GetFrameNames();
                //var list = browser.GetBrowser().GetFrameNames();
                //browser.GetBrowser();

                game_frame?.ExecuteJavaScriptAsync("document.getElementById('spacing_top').style.height = '0px'");
            }
            catch (System.Exception ex)
            {
            }
        }
Esempio n. 8
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Browser = new CefSharp.Wpf.ChromiumWebBrowser();
            //browser.Address = @"http://147zxcv.xiaopangkj.space/player.html";

            //this.WebBrowser.WebBrowser.Do
            // 注意,第二个路径不要加 "/"
            // 错误:@"/Res/index.html"

            IPAddress   iPAddress  = IPAddress.Any;
            IPEndPoint  iPEndPoint = new IPEndPoint(iPAddress, 5893);
            MyWebServer webServer  = new MyWebServer(iPEndPoint);

            webServer.Start();
            this.Browser.Address = @"http://127.0.0.1:5893/player.html";

            this.Content = this.Browser;
        }
Esempio n. 9
0
        public BlocklyEditor()
        {
            InitializeComponent();



            string localPath = System.Environment.CurrentDirectory;


            browser = new CefSharp.Wpf.ChromiumWebBrowser(localPath + @"/BlocklySetting/StartPage.html");
            JsHandler jh = new JsHandler();

            browser.JsDialogHandler = jh;

            BrowserGrid.Child = browser;

            browser.LoadingStateChanged += WebBrowser_LoadingStateChanged;
        }
Esempio n. 10
0
        public SigninWindow(string url, bool forceLogin)
        {
            InitializeComponent();
            this.url              = url;
            this.forceLogin       = forceLogin;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            CefSharp.Wpf.ChromiumWebBrowser browser;
            if (forceLogin)
            {
                browser = new CefSharp.Wpf.ChromiumWebBrowser(this.url + "/PassiveSignout");
            }
            else
            {
                browser = new CefSharp.Wpf.ChromiumWebBrowser(this.url + "/Login");
            }
            browser.LoadingStateChanged += Browser_LoadingStateChanged;
            content.Child = browser;
        }
 public GettingStarted(string url)
 {
     Log.FunctionIndent("GettingStarted", "GettingStarted");
     try
     {
         InitializeComponent();
         DataContext = this;
         this.url    = url;
         CefSharp.Wpf.ChromiumWebBrowser browser;
         browser = new CefSharp.Wpf.ChromiumWebBrowser(this.url)
         {
             LifeSpanHandler = new BasicLifeSpanHandler()
         };
         content.Child = browser;
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     Log.FunctionOutdent("GettingStarted", "GettingStarted");
 }
Esempio n. 12
0
        public MainWindow()
        {
            InitializeComponent();

            CefSharp.CefSettings settings = new CefSharp.CefSettings()
            {
                //PackLoadingDisabled = true,
            };

            CefSharp.Cef.Initialize(settings);

            myBrowser = new CefSharp.Wpf.ChromiumWebBrowser();
            //myBrowser.Width = browserHolder.Width - 300;
            //myBrowser.Height = browserHolder.Height - 30;
            //myBrowser.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            //myBrowser.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;

            // Seems WebBrowser is fine - it's canvas that's a fixed size. Rescale automatically?
            // http://stackoverflow.com/questions/1664785/resize-html5-canvas-to-fit-window
            myBrowser.Background = new SolidColorBrush(System.Windows.Media.Colors.CadetBlue);

            browserHolder.Children.Add(myBrowser);


            myBrowser.LoadHtml(GetResourceString("SharpFabric.JavaScript.CanvBody.html"), "http://junky/");

            // Initialize fabric.js after the DOM is fully loaded. Not sure whether this is the recommended way to ensure this.
            myBrowser.FrameLoadEnd += delegate
            {
                myBrowser.ExecuteScriptAsync(GetResourceString("SharpFabric.JavaScript.fabric.js"));
                myBrowser.ExecuteScriptAsync(GetResourceString("SharpFabric.JavaScript.qFunctions.js"));
            };

            myBrowser.RegisterJsObject("callbackObj", new CallbackObjectForJs()
            {
                win = this
            });
        }
 public ConferenceJsEvent(CefSharp.Wpf.ChromiumWebBrowser browser, IMasterDisplayWindow masterDisplayWindow)
 {
     this._browser             = browser;
     this._masterDisplayWindow = masterDisplayWindow;
 }
Esempio n. 14
0
        private void InitLouPanData(int buildingId)
        {
            bId = buildingId;
            //bId = DAL.DataRepository.Instance.GetBuildingsList(DAL.GlobalDataPool.Instance.Uid, 1, 1, 1, null).data.First().ID;
            var buildingInfo = DAL.DataRepository.Instance.GetBuildingsInfo(DAL.GlobalDataPool.Instance.Uid, buildingId).data;

            if (buildingInfo == null)
            {
                return;
            }
            //var v = buildingInfo.Images.First().ImageUrl;
            //iamge.Source = new BitmapImage(new Uri(buildingInfo.Images.First().ImageUrl));

            FlipView2nd.ItemsSource = from a in buildingInfo.Images.OrderBy(a => a.ImageIndex)
                                      select new Uri(ConfigHelper.GetAppSetting("ApiUrl") + @"Images/" + a.ImageUrl, UriKind.Absolute);
            //FlipView2nd.ItemsSource = new Uri[]
            //                 {
            //                     new Uri("http://www.public-domain-photos.com/free-stock-photos-4/landscapes/mountains/painted-desert.jpg", UriKind.Absolute),
            //                     new Uri("http://www.public-domain-photos.com/free-stock-photos-3/landscapes/forest/breaking-the-clouds-on-winter-day.jpg", UriKind.Absolute),
            //                     new Uri("http://www.public-domain-photos.com/free-stock-photos-4/travel/bodie/bodie-streets.jpg", UriKind.Absolute)
            //                 };

            buildingsName = buildingInfo.Name;
            bName.Text    = (string.IsNullOrWhiteSpace(buildingInfo.QuYu) ? "区域未知" : buildingInfo.QuYu) + "  |  "
                            + (string.IsNullOrWhiteSpace(buildingInfo.Name) ? "楼盘名未知" : buildingInfo.Name);

            prise.Text   = string.IsNullOrWhiteSpace(buildingInfo.Price) ? "?元/平米" : buildingInfo.Price;
            address.Text = string.IsNullOrWhiteSpace(buildingInfo.Address) ? "地址未知" : buildingInfo.Address;

            kehushuliang.Text = "合作经济人:" + buildingInfo.HeZhuoJingJiRenNumber
                                + "  |  " + "意向客户:" + buildingInfo.YiXiangKeHuNumber
                                + "  |  " + "我的客户:" + buildingInfo.WoDeKeHuNumber;

            yongjing.Text = buildingInfo.YongJin;

            daikan.Text = buildingInfo.DaiKanYongJin;

            var user = buildingInfo.Users.Where(p => p.UserType == 1).First();

            zhiyeguwen.Text = "咨询业务员    " + user.UserName + "  " + user.DianHua;
            //buildingInfo.yew

            yongjing2.Text = "佣金:" + buildingInfo.YongJin;


            //buildingInfo.HuXing.First ().Name

            BaoBeiGuiZe.Text = string.IsNullOrWhiteSpace(buildingInfo.KaiFaShangGuiZhe.BaoBeiGuiZhe)
                ? "暂无数据" : buildingInfo.KaiFaShangGuiZhe.BaoBeiGuiZhe;
            DiaKanGuiZe.Text = string.IsNullOrWhiteSpace(buildingInfo.KaiFaShangGuiZhe.DaiKanGuiZhe)
                ? "暂无数据" : buildingInfo.KaiFaShangGuiZhe.BaoBeiGuiZhe;
            ChengJiaoGuiZe.Text = string.IsNullOrWhiteSpace(buildingInfo.KaiFaShangGuiZhe.ChengJiaoGuiZhe)
                ? "暂无数据" : buildingInfo.KaiFaShangGuiZhe.BaoBeiGuiZhe;
            ChengJiaoJiangLi.Text = string.IsNullOrWhiteSpace(buildingInfo.KaiFaShangGuiZhe.JiangLi)
                ? "暂无数据" : buildingInfo.KaiFaShangGuiZhe.BaoBeiGuiZhe;
            JieSuanZhouQi.Text = string.IsNullOrWhiteSpace(buildingInfo.KaiFaShangGuiZhe.JieShuanZhouQi)
                ? "暂无数据" : buildingInfo.KaiFaShangGuiZhe.BaoBeiGuiZhe;

            listView.ItemsSource = buildingInfo.HuXing;


            KaiPanShiJian.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.KaiPanTime)
                ? "暂无数据" : buildingInfo.XiangQing.KaiPanTime;
            JiaoFangShiJian.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.JiaoFangTime)
                ? "暂无数据" : buildingInfo.XiangQing.JiaoFangTime;
            KaiFaShang.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.KaiFaShang)
                ? "暂无数据" : buildingInfo.XiangQing.KaiFaShang;
            KaiFaShangPinPai.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.KaiFaShangPinPai)
                ? "暂无数据" : buildingInfo.XiangQing.KaiFaShangPinPai;

            WuYeGongShi.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.WuYeGongShi)
               ? "暂无数据" : buildingInfo.XiangQing.WuYeGongShi;
            JianZhuMianJi.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.JianZhuMianJi)
                ? "暂无数据" : buildingInfo.XiangQing.JianZhuMianJi;

            ZhongHuShu.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.ZhongHuShu)
             ? "暂无数据" : buildingInfo.XiangQing.ZhongHuShu;
            RongJiLv.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.RongJiLv)
                ? "暂无数据" : buildingInfo.XiangQing.RongJiLv;

            CheWeiBi.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.CheWeiBi)
            ? "暂无数据" : buildingInfo.XiangQing.CheWeiBi;
            WuYeFei.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.WuYeFei)
                ? "暂无数据" : buildingInfo.XiangQing.WuYeFei;

            JianZhuLeiXing.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.JianZhuLeiXing)
           ? "暂无数据" : buildingInfo.XiangQing.JianZhuLeiXing;
            ZhuangXiuZhongKuang.Text = string.IsNullOrWhiteSpace(buildingInfo.XiangQing.ZhuangXiuZhongKuang)
                ? "暂无数据" : buildingInfo.XiangQing.ZhuangXiuZhongKuang;

            //买点
            listViewLouPanMaiDian.ItemsSource = buildingInfo.MaiDian;

            HuXingShuLiang.Text = buildingInfo.HuXing.Count.ToString();



            listViewHuXingTuiJian.ItemsSource = buildingInfo.HuXing;


            //FlipView3nd.ItemsSource = from a in buildingInfo.HuXing.OrderBy(a => a.ImageIndex)
            //                          select new Uri(ConfigHelper.GetAppSetting("ApiUrl") + @"Images/" + a.ImageUrl, UriKind.Absolute);

            //webBrowserDiTu.Source = new Uri("www.map.baidu.com");

            //TODO
            //webBrowserDiTu.Navigate(string.Format(louPanMapUri, bId));
            //webBrowserDiTu.Document=

            //buildingInfo.XiangQing
            browser         = new CefSharp.Wpf.ChromiumWebBrowser();
            browser.Address = string.Format(louPanMapUri, bId);
            mapGrid.Children.Add(browser);
        }
        public void DeleteElement(CefSharp.Wpf.ChromiumWebBrowser MainWindowBrowser)
        {
            IFrame deleteFrame = MainWindowBrowser.GetMainFrame();

            deleteFrame.ExecuteJavaScriptAsync("deleteAllElements()");
        }
        public void SelectAllElements(CefSharp.Wpf.ChromiumWebBrowser MainWindowBrowser)
        {
            IFrame selectFrame = MainWindowBrowser.GetMainFrame();

            selectFrame.ExecuteJavaScriptAsync("selectAllElements()");
        }
Esempio n. 17
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt = Newtonsoft.Json.JsonConvert.DeserializeObject <AasxPluginWebBrowser.WebBrowserOptions>(
                    (args[0] as string));
                if (newOpt != null)
                {
                    this.options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(
                    this.options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense = "The browser functionality is licensed under the cefSharp license (see below).";

                lic.isStandardLicense = true;
                lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                    "LICENSE.txt", Assembly.GetExecutingAssembly());

                return(lic);
            }

            if (action == "get-events" && this.eventStack != null)
            {
                // try access
                return(this.eventStack.PopEvent());
            }

            if (action == "get-browser-grid" && args != null && args.Length >= 1 && args[0] is string)
            {
                // args
                var url = args[0] as string;

                // build visual
                this.browserGrid = new Grid();

                this.browserGrid.RowDefinitions.Add(
                    new RowDefinition()
                {
                    Height = new GridLength(1.0, GridUnitType.Star)
                });
                this.browserGrid.ColumnDefinitions.Add(
                    new ColumnDefinition()
                {
                    Width = new GridLength(1.0, GridUnitType.Star)
                });

                this.theBrowser         = new CefSharp.Wpf.ChromiumWebBrowser();
                this.theBrowser.Address = url;
                this.theBrowser.InvalidateVisual();

                this.browserGrid.Children.Add(this.theBrowser);
                Grid.SetRow(this.theBrowser, 0);
                Grid.SetColumn(this.theBrowser, 0);

                // TODO (MIHO, 2020-08-02): when dragging the divider between elements tree and browser window,
                // distortions can be seen (diagonal shifting of pixels). Interestingly, this problem was not
                // appearant, when the browser was integrated within the main application and is new for the
                // plugin approach. Would be great if somebody would find a solution.

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = this.browserGrid;
                return(res);
            }

            if (action == "go-to-address" && args != null && args.Length >= 1 && args[0] is string)
            {
                // args
                var url = args[0] as string;
                Log.Info("AasxPluginWebBrowser go to {0}", url);

                // check, if possible
                if (this.browserGrid != null && this.theBrowser != null)
                {
                    // try execute
                    this.theBrowser.Address = url;
                    this.theBrowser.InvalidateVisual();
                    this.browserGrid.InvalidateVisual();

                    // indicate OK
                    return(new AasxPluginResultBaseObject("OK", true));
                }
            }

            if (action == "gset-zoom-level" && args != null && args.Length >= 1 && args[0] is double)
            {
                // args
                var zoom = (double)args[0];

                // check, if possible
                if (this.browserGrid != null && this.theBrowser != null)
                {
                    // try execute
                    this.theBrowser.ZoomLevel = zoom;

                    // indicate OK
                    return(new AasxPluginResultBaseObject("OK", true));
                }
            }

            // default
            return(null);
        }
Esempio n. 18
0
 public void TestMethod1()
 {
     Cef.Initialize();
     var web = new CefSharp.Wpf.ChromiumWebBrowser();
 }
Esempio n. 19
0
 public cssPropertyBox(winForms.RichTextBox htmltextBox, winForms.RichTextBox csstextBox, CefSharp.Wpf.ChromiumWebBrowser mainWB)
 {
     this.cssTextBox  = csstextBox;
     this.htmltextBox = htmltextBox;
     this.mwb         = mainWB;
 }
Esempio n. 20
0
        public void OpenProject(winForms.RichTextBox htmlTextBox, winForms.RichTextBox csstextBox, MenuItem SaveProject, CefSharp.Wpf.ChromiumWebBrowser mwb)
        {
            if (SaveProject.IsEnabled == true)
            {
                MessageBoxResult msgBoxRes = MessageBox.Show("Do you want to save content or not?", "Save File", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (msgBoxRes == MessageBoxResult.Yes)
                {
                    Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
                    sfd.DefaultExt = ".html";
                    sfd.Filter     = "HTML File (.html)|*.html";
                    if (sfd.ShowDialog() == true && sfd.FileName.Length > 0)
                    {
                        File.WriteAllText(sfd.FileName, htmlTextBox.Text);
                        savepath = sfd.FileName.ToString();
                        save     = true;
                    }

                    //Open the respective css file
                    sfd.DefaultExt = ".css";
                    sfd.Filter     = "CSS File (.css)|*.css";
                    if (sfd.ShowDialog() == true && sfd.FileName.Length > 0)
                    {
                        File.WriteAllText(sfd.FileName, csstextBox.Text);
                        csssavepath = sfd.FileName.ToString();
                        save        = true;
                    }
                }
            }
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.DefaultExt = ".html";
            ofd.Filter     = "HTML File (.html)|*.html|ALL Files (.)|*.*";
            if (ofd.ShowDialog() == true && ofd.CheckFileExists)
            {
                StreamReader sr1 = new StreamReader(ofd.FileName, Encoding.Default);
                htmlTextBox.Text = sr1.ReadToEnd();
                save             = true;
                savepath         = ofd.FileName.ToString();
            }

            ofd.Title      = "Open CSS file";
            ofd.DefaultExt = ".css";
            ofd.Filter     = "CSS File (.css)|*.css|ALL Files (.)|*.*";
            if (ofd.ShowDialog() == true && ofd.CheckFileExists)
            {
                StreamReader sr1 = new StreamReader(ofd.FileName, Encoding.Default);
                csstextBox.Text = sr1.ReadToEnd();
                save            = true;
                csssavepath     = ofd.FileName.ToString();
            }


            //validation
            //stop single line grammercheck firing
            MainWindow.htmlfire = false;
            MainWindow.fire     = false;
            //creating objects to simulate validation
            htmltextBoxClass htb = new htmltextBoxClass();
            csstextBoxClass  ctb = new csstextBoxClass();


            //Overriding Paste Functionality
            //Showing busy work with mouse
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            try
            {
                htb.ValidateTags(htmlTextBox);
                ctb.clipboardGrammerCheck(csstextBox);

                this.mw.Dispatcher.Invoke(() =>
                {
                    Regex singlelinepattern = new Regex(@"\s*?(\r\n|\n|\r)\s*");
                    String htmlH            = htmlTextBox.Text;
                    String singleLineString = singlelinepattern.Replace(htmlH, "");
                    //winForms.MessageBox.Show(singleLineString);
                    IFrame frame = mwb.GetMainFrame();
                    frame.ExecuteJavaScriptAsync(String.Format("testFunc(`{0}`)", htmlH));
                });
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
            MainWindow.htmlfire = true;
            MainWindow.fire     = true;


            SaveProject.IsEnabled = false;
            save = true;
        }
Esempio n. 21
0
 public DownloadHandler(String path, CefSharp.Wpf.ChromiumWebBrowser browser, bool overwriteFiles)
 {
     _defaultPath    = path;
     webBrowser      = browser;
     _overwriteFiles = overwriteFiles;
 }
 public AppCallbacks(CefSharp.Wpf.ChromiumWebBrowser browser)
 {
     this.browser = browser;
 }
        public void CopyElement(CefSharp.Wpf.ChromiumWebBrowser MainWindowBrowser)
        {
            IFrame copyFrame = MainWindowBrowser.GetMainFrame();

            copyFrame.ExecuteJavaScriptAsync("copyAllElements()");
        }