当前位置: 首页>>代码示例>>C#>>正文


C# WebBrowser.Refresh方法代码示例

本文整理汇总了C#中System.Windows.Forms.WebBrowser.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# WebBrowser.Refresh方法的具体用法?C# WebBrowser.Refresh怎么用?C# WebBrowser.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.WebBrowser的用法示例。


在下文中一共展示了WebBrowser.Refresh方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Open

        public void Open(string filename)
        {
            string source = _className + "Open";
            try
            {
                //cleanup existing domain if it exists
                //ReleaseHost();
                Controls.Clear();
                //sending a blank filename just releases the handler
                if (string.IsNullOrEmpty(filename)) return;
                if(PreviewInBrowser(filename))
                {
                    var browser = new WebBrowser {Dock = DockStyle.Fill};
                    if (!Utils.IsFileImage(filename))
                    {
                        browser.Navigate("file://" + filename);
                    }
                    else
                    {
                        var data = Convert.ToBase64String(File.ReadAllBytes(filename));
                        var newValue = string.Format("data:image/{0};base64,{1}", Path.GetExtension(filename), data);

                        browser.DocumentText = "0";
                        browser.Document.OpenNew(true);
                        browser.Document.Write("<img src='" + newValue + "'>");
                        browser.Refresh();
                    }

                    Controls.Add(browser);
                    return;
                }
                AppDomainSetup currentSetup = AppDomain.CurrentDomain.SetupInformation;
                var info = new AppDomainSetup
                {
                    ApplicationBase = currentSetup.ApplicationBase,
                    LoaderOptimization = currentSetup.LoaderOptimization,
                    ApplicationTrust= currentSetup.ApplicationTrust
                };

                _domain = AppDomain.CreateDomain(
                    "Preview Host Domain " + Guid.NewGuid().ToString(), null, info);
                _previewHandlerHost = (PreviewHandlerHost)
                    _domain.CreateInstanceAndUnwrap("OutlookECS", "ChiaraMail.PreviewHandlerHost");
                //start the timer
                _timer.Start();
                string result = _previewHandlerHost.Open(filename, ClientRectangle, Handle);
                _timer.Stop();
                Logger.Verbose(source, string.Format(
                    "preview handler returned {0} for {1}",
                    result, filename));
                switch (result)
                {
                    case "success":
                        break;
                    default:
                        ErrorMessage = result;
                        break;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("PreviewHandlerControl.Open", ex.ToString());
            }
            ErrorMessage = "Unable to preview file";
        }
开发者ID:ProjectECS,项目名称:ECS,代码行数:65,代码来源:PreviewHandler.cs

示例2: AddDocViewer

        private void AddDocViewer(byte[] docStream)
        {
            DocType fileDocType = GetDocumentType(docStream);

            switch (fileDocType)
            {
                case DocType.TIF:
                    {
                        try
                        {
                            TifEditor editor = new TifEditor();
                            editor.Dock = System.Windows.Forms.DockStyle.Fill;
                            editor.Edit = false;
                            editor.ExitDelegate = null;
                            editor.ImageFileName = null;
                            editor.Location = new System.Drawing.Point(0, 0);
                            editor.SaveAsFileName = null;
                            editor.ScaleFactor = 1;
                            editor.Size = new System.Drawing.Size(1148, 422);
                            editor.TabIndex = 0;
                            editor.TransDelegate = null;
                            editor.UserName = null;
                            editor.LoadImage(new MemoryStream(docStream));
                            this.Controls.Add(editor);
                        }
                        catch (Exception ex)
                        {
                            XtraMessageBox.Show("An error occurred while loading file: " + fileName + "." + Environment.NewLine +
                                "Error CNF-547 in " + PROJ_FILE_NAME + ".AddDocViewer(): " + ex.Message,
                                 "Inbound Tab Page", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;
                    }
                case DocType.HTML:
                    {
                        WebBrowser webBrowser = new WebBrowser();
                        webBrowser.Dock = System.Windows.Forms.DockStyle.Fill;
                        webBrowser.TabIndex = 0;
                        this.Controls.Add(webBrowser);
                        StringBuilder contents = new StringBuilder();
                        char[] str = new char[docStream.Length];
                        for (int i = 0; i < docStream.Length; i++)
                        {
                            str[i] = (char)docStream[i];
                        }
                        contents.Append(str);

                        webBrowser.Navigate("about:blank");

                        webBrowser.Document.Write(contents.ToString());
                        webBrowser.Refresh();

                        break;
                    }
                case DocType.RTF:
                    {
                        
                        VaultRTFEditor richTextBox = new VaultRTFEditor();
                        richTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
                        richTextBox.LoadFile(new MemoryStream(docStream), RichTextBoxStreamType.RichText);
                        this.Controls.Add(richTextBox);
                        break;
                    }
            }
        }
开发者ID:Amphora2015,项目名称:DemoTest,代码行数:65,代码来源:XtraAxTabPage.cs

示例3: printToolStripButton_Click

 private void printToolStripButton_Click(object sender, EventArgs e)
 {
     WebBrowser printer = new WebBrowser();
     printer.DocumentText = mainTextBox.Text;
     printer.Refresh();
     printer.Print();
 }
开发者ID:Krypton-Project,项目名称:Fox,代码行数:7,代码来源:office-writer.cs

示例4: ParseFINRAHtml

        // Private methods
        private bool ParseFINRAHtml(string html, DateTime date, out StockAdvDecl investGrade, out StockAdvDecl highYield)
        {
            try
            {
                WebBrowser browser = new WebBrowser();
                browser.ScriptErrorsSuppressed = true;
                browser.DocumentText = html;
                browser.Document.OpenNew(true);
                browser.Document.Write(html);
                browser.Refresh();

                var table = browser.Document.GetElementsByTagName("table").Cast<HtmlElement>().First();
                var data = getTableData(table);

                investGrade = new StockAdvDecl()
                {
                    Date = date,
                    Advances = int.Parse(data[2][2]),
                    Declines = int.Parse(data[3][2]),
                    Unchanged = int.Parse(data[4][2]),
                    Volume = data[7][2] != null ? int.Parse(data[7][2]) : 0
                };
                highYield = new StockAdvDecl()
                {
                    Date = date,
                    Advances = int.Parse(data[2][3]),
                    Declines = int.Parse(data[3][3]),
                    Unchanged = int.Parse(data[4][3]),
                    Volume = data[7][3] != null ? int.Parse(data[7][3]) : 0
                };
                return true;
            }
            catch (Exception)
            {
                investGrade = null;
                highYield = null;
                return false;
            }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:40,代码来源:FINRADataProvider.cs

示例5: DownloadFinancialSummary

        //public static void DownloadFinancial2(StockSerie stockSerie)
        //{
        //    if (stockSerie.StockAnalysis.Financial != null && stockSerie.StockAnalysis.Financial.DownloadDate.AddDays(7) > DateTime.Now) return;
        //    string url = "http://www.abcbourse.com/analyses/chiffres.aspx?s=$ShortNamep".Replace("$ShortName", stockSerie.ShortName);
        //    url = "http://www.boursorama.com/bourse/profil/profil_finance.phtml?symbole=1rP$ShortName".Replace("$ShortName", stockSerie.ShortName);
        //    StockWebHelper swh = new StockWebHelper();
        //    string html = swh.DownloadHtml(url);
        //    WebBrowser browser = new WebBrowser();
        //    browser.ScriptErrorsSuppressed = true;
        //    browser.DocumentText = html;
        //    browser.Document.OpenNew(true);
        //    browser.Document.Write(html);
        //    browser.Refresh();
        //    HtmlDocument doc = browser.Document;
        //    HtmlElementCollection tables = doc.GetElementsByTagName("div");
        //    List<List<string>> data = new List<List<string>>();
        //    StockFinancial financial = new StockFinancial();
        //    HtmlElement tbl = tables.Cast<HtmlElement>().FirstOrDefault(t => t.InnerText.StartsWith("Marché"));
        //    if (tbl != null)
        //    {
        //        //ParseFinancialGeneral(stockSerie, financial, tbl);
        //    }
        //    bool found = false;
        //    int count = 0;
        //    foreach (HtmlElement table in tables)
        //    {
        //        if (found)
        //        {
        //            switch (count)
        //            {
        //                case 0:
        //                    financial.IncomeStatement = getTableData(table);
        //                    count++;
        //                    break;
        //                case 1:
        //                    financial.BalanceSheet = getTableData(table);
        //                    count++;
        //                    break;
        //                case 2:
        //                    financial.Ratios = getTableData(table);
        //                    count++;
        //                    break;
        //                case 3:
        //                    financial.Quaterly = getTableData(table);
        //                    count++;
        //                    break;
        //            }
        //        }
        //        else
        //        {
        //            found = table.InnerText.StartsWith("Compte de");
        //        }
        //    }
        //    if (found)
        //        tbl = tables.Cast<HtmlElement>().FirstOrDefault(t => t.InnerText.StartsWith("Compte"));
        //    if (tbl != null)
        //    {
        //        ParseFinancialDetails(stockSerie, financial, tbl);
        //    }
        //}
        public static void DownloadFinancialSummary(StockFinancial financial, string shortName)
        {
            string url = "http://www.boursorama.com/bourse/profil/resume_societe.phtml?symbole=1r$ShortName".Replace("$ShortName", shortName);
            StockWebHelper swh = new StockWebHelper();
            string html = swh.DownloadHtml(url);

            WebBrowser browser = new WebBrowser();
            browser.ScriptErrorsSuppressed = true;
            browser.DocumentText = html;
            browser.Document.OpenNew(true);
            browser.Document.Write(html);
            browser.Refresh();

            HtmlDocument doc = browser.Document;

            var divs = doc.GetElementsByTagName("div").Cast<HtmlElement>();
            foreach (var div in divs)
            {
                if (div.InnerText != null && div.InnerText.StartsWith("Nombre de titres"))
                {
                    var list = div.InnerText.Replace(Environment.NewLine, "|");
                    var split = list.Split('|');
                    var nbTitres = split[0].Split(':')[1].Replace(" ", "");
                    financial.ShareNumber = long.Parse(nbTitres);
                    financial.Coupon = split.First(l => l.StartsWith("Dern")).Split(':')[1].Trim();
                    financial.Sector = split.First(l => l.StartsWith("Secteur")).Split(':')[1].Trim();
                    financial.PEA = split.First(l => l.Contains("PEA")).Split(':')[1].Trim();
                    financial.SRD = split.First(l => l.Contains("SRD")).Split(':')[1].Trim();
                    financial.Indices = split.First(l => l.StartsWith("Indice")).Split(':')[1].Trim();
                    break;
                }
            }
            foreach (var div in divs)
            {
                if (div.InnerText != null && div.InnerText.StartsWith("Prévisions des analystes"))
                {

                    var tables = div.GetElementsByTagName("table").Cast<HtmlElement>();
                    var previsions = getTableData(tables.First());

//.........这里部分代码省略.........
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:101,代码来源:ABCDataProvider.cs

示例6: DownloadFinancial

        public static void DownloadFinancial(StockSerie stockSerie)
        {
            if (stockSerie.Financial != null && stockSerie.Financial.DownloadDate.AddDays(7) > DateTime.Now) return;

            StockFinancial financial = new StockFinancial();
            try
            {
                string shortName = stockSerie.StockGroup == StockSerie.Groups.ALTERNEXT ? "EP" : "P";
                shortName += stockSerie.ShortName;
                DownloadFinancialSummary(financial, shortName);

                string url = "http://www.boursorama.com/bourse/profil/profil_finance.phtml?symbole=1r$ShortName".Replace("$ShortName", shortName);
                StockWebHelper swh = new StockWebHelper();
                string html = swh.DownloadHtml(url);

                WebBrowser browser = new WebBrowser();
                browser.ScriptErrorsSuppressed = true;
                browser.DocumentText = html;
                browser.Document.OpenNew(true);
                browser.Document.Write(html);
                browser.Refresh();

                HtmlDocument doc = browser.Document;

                var divs = doc.GetElementsByTagName("div").Cast<HtmlElement>();
                foreach (var div in divs)
                {
                    if (div.InnerText != null && div.InnerText.StartsWith("Compte de"))
                    {
                        Console.WriteLine(div.InnerText);
                        var tables = div.GetElementsByTagName("table").Cast<HtmlElement>();
                        financial.IncomeStatement = getTableData(tables.First());
                        break;
                    }
                }
                foreach (var div in divs)
                {
                    if (div.InnerText != null && div.InnerText.StartsWith("Bilan"))
                    {
                        Console.WriteLine(div.InnerText);
                        var tables = div.GetElementsByTagName("table").Cast<HtmlElement>();
                        financial.BalanceSheet = getTableData(tables.First());
                        break;
                    }
                }
                foreach (var div in divs)
                {
                    if (div.InnerText != null && div.InnerText.StartsWith("Chiffres d'affaires"))
                    {
                        Console.WriteLine(div.InnerText);
                        var tables = div.GetElementsByTagName("table").Cast<HtmlElement>();
                        financial.Quaterly = getTableData(tables.First());
                        break;
                    }
                }

                financial.DownloadDate = DateTime.Now;
                stockSerie.Financial = financial;
                stockSerie.SaveFinancial();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:65,代码来源:ABCDataProvider.cs

示例7: DownloadAgenda

        //private static void ParseFinancialGeneral(StockSerie stockSerie, StockFinancial financial, HtmlElement tbl)
        //{
        //    List<List<string>> data = getTableData(tbl);
        //    foreach (var row in data)
        //    {
        //        if (row.Count == 2)
        //        {
        //            switch (row[0].Trim())
        //            {
        //                case "Marché":
        //                    financial.Market = row[1];
        //                    break;
        //                case "Nombre de titres":
        //                    financial.ShareNumber = long.Parse(row[1].Replace(" ", ""));
        //                    break;
        //                case "Place de cotation":
        //                    financial.MarketPlace = row[1];
        //                    break;
        //                case "Secteur d'activité":
        //                    financial.Sector = row[1];
        //                    break;
        //                case "Eligible au SRD":
        //                    financial.SRD = row[1];
        //                    break;
        //                case "Eligible au PEA":
        //                    financial.PEA = row[1];
        //                    break;
        //                case "Indices":
        //                    financial.Indices = row[1];
        //                    break;
        //                case "Capitalisation (milliers d'euros)":
        //                    //financial.MarketCap = int.Parse(row[1].Replace(" ", ""));
        //                    break;
        //                case "Rendement":
        //                    float yield = 0f;
        //                    if (float.TryParse(row[1].Replace(",", ".").Replace("%", ""), out yield))
        //                    {
        //                        financial.Yield = yield / 100f;
        //                    }
        //                    break;
        //                case "Dividende (Date de versement)":
        //                    financial.Dividend = row[1];
        //                    break;
        //                case "Date Assemblée Générale":
        //                    financial.MeetingDate = row[1];
        //                    break;
        //            }
        //        }
        //        financial.DownloadDate = DateTime.Now;
        //        stockSerie.StockAnalysis.Financial = financial;
        //    }
        //}
        public static void DownloadAgenda(StockSerie stockSerie)
        {
            string url = "http://www.abcbourse.com/marches/events.aspx?s=$ShortNamep".Replace("$ShortName",
               stockSerie.ShortName);

            StockWebHelper swh = new StockWebHelper();
            string html = swh.DownloadHtml(url);

            WebBrowser browser = new WebBrowser();
            browser.ScriptErrorsSuppressed = true;
            browser.DocumentText = html;
            browser.Document.OpenNew(true);
            browser.Document.Write(html);
            browser.Refresh();

            HtmlDocument doc = browser.Document;

            HtmlElementCollection tables = doc.GetElementsByTagName("table");
            List<List<string>> data = new List<List<string>>();

            foreach (HtmlElement tbl in tables)
            {
                if (tbl.InnerText.StartsWith("Date"))
                {
                    data = getTableData(tbl).Skip(1).ToList();
                    break;
                }
            }
            //
            foreach (var row in data)
            {
                if (row[0].StartsWith("du")) row[0] = row[0].Substring(row[0].IndexOf("au ") + 3);
                DateTime date = DateTime.Parse(row[0]);

                string comment = row[1];
                if (row[2] != null) comment += Environment.NewLine + row[2];

                if (!stockSerie.StockAnalysis.Comments.ContainsKey(date))
                {
                    stockSerie.StockAnalysis.Comments.Add(date, comment);
                }
                else
                {
                    if (!stockSerie.StockAnalysis.Comments[date].Contains(comment))
                    {
                        stockSerie.StockAnalysis.Comments[date] = stockSerie.StockAnalysis.Comments[date] +
                                                                  Environment.NewLine + comment;
                    }
//.........这里部分代码省略.........
开发者ID:dadelcarbo,项目名称:StockAnalyzer,代码行数:101,代码来源:ABCDataProvider.cs


注:本文中的System.Windows.Forms.WebBrowser.Refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。