Пример #1
0
 private void SpustRefreshDohadzovanie(string text)
 {
     _webBrowser2.Refresh();
     _refreshovaciCas     = Convert.ToInt32((text));
     _refreshovacieVlakno = new Thread(WorkThreadFunction);
     _refreshovacieVlakno.Start();
 }
Пример #2
0
 private void LoadComp(object sender, EventArgs e)
 {
     DailyBrowser.Document.Cookie    = LoginCookieString;
     DailyBrowser.DocumentCompleted -= LoadComp;
     DailyBrowser.DocumentCompleted += RefreshComp;
     DailyBrowser.Refresh();
 }
Пример #3
0
        private void HladajHb(string cas, string cenaVstup)
        {
            var cen  = int.Parse(cenaVstup);
            var cass = int.Parse(cas);
            var wb1  = new System.Windows.Forms.WebBrowser();

            wb1.ScriptErrorsSuppressed = true;
            wb1.Navigate(new Uri("http://www.stargate-game.cz/obchod.php?page=4"));
            while (true)
            {
                while (true)
                {
                    Application.DoEvents();
                    if (!string.IsNullOrEmpty(wb1.StatusText) && !wb1.StatusText.Contains("obchod.php?"))
                    {
                        break;
                    }
                }

                if (
                    wb1.Document.Body.InnerText.Contains("nabízena za "))
                {
                    var zac = wb1.Document.Body.InnerText.IndexOf("nabízena za ") + 12;
                    var kon = wb1.Document.Body.InnerText.IndexOf("kg naquadahu", zac);

                    var cena =
                        wb1.Document.Body.InnerText.Substring(zac,
                                                              kon - zac).Replace(" ", "");

                    if (int.Parse(cena) < cen)
                    {
                        MessageBox.Show("Lacne HB", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                    }

                    Random rand = new Random();
                    Thread.Sleep((cass + rand.Next(-5, 10)) * 1000);
                    wb1.Refresh();
                    Thread.Sleep(1000);
                }
            }
        }
Пример #4
0
 private void toolStripButton4_Click(object sender, EventArgs e)
 {
     wb.Refresh();
 }
Пример #5
0
 public void Reload()
 {
     view.Refresh();
 }
Пример #6
0
        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;
                    }
            }
        }
Пример #7
0
 void RefreshButtonClick(object sender, System.EventArgs e)
 {
     webBrowser.Refresh();
 }
Пример #8
0
        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";
        }
Пример #9
0
 private void printToolStripButton_Click(object sender, EventArgs e)
 {
     WebBrowser printer = new WebBrowser();
     printer.DocumentText = mainTextBox.Text;
     printer.Refresh();
     printer.Print();
 }
Пример #10
0
 void TsBtnYenile_Click(object sender, EventArgs e)
 {
     wb.Refresh();
 }
Пример #11
0
 public void refresh()
 {
     b.Refresh();
 }
Пример #12
0
        // 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;
            }
        }
Пример #13
0
        //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());

                    var dividendLine = previsions.FirstOrDefault(l => l[0] == "Dividende");
                    if (dividendLine != null)
                    {
                        float dividend = 0;
                        float.TryParse(dividendLine[1], out dividend);
                        financial.Dividend = dividend;
                    }

                    break;
                }
            }
            //foreach (var div in divs)
            //{
            //    if (div.InnerText != null && div.InnerText.StartsWith("Activité"))
            //    {
            //        Console.WriteLine(div.InnerText);
            //        financial.Activity = div.InnerHtml;
            //        break;
            //    }
            //}
        }
Пример #14
0
        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);
            }
        }
Пример #15
0
        //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;
                    }
                }
            }
        }