//public void UpdateIconWebsite() //{ // try // { // string url = ""; // string sql = ""; // try // { // DataTable DB = new DataTable(); // sql = string.Format("select distinct origin_url from logins where image_data IS NULL or length(image_data)==0 limit 1 "); // using (SQLiteConnection connect = new SQLiteConnection(ConnectionString)) // { // connect.Open(); // using (SQLiteCommand command = new SQLiteCommand(sql, connect)) // { // SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); // adapter.Fill(DB); // if (DB.Rows.Count == 0) return; // url = (DB.Rows[0][0] == DBNull.Value) ? string.Empty : DB.Rows[0][0].ToString(); // adapter.Dispose(); // connect.Close(); // } // } // } // catch (Exception ex) // { // } // byte[] imageData = GetIconFromUrl(encode.Base64Decode( url)); // sql = string.Format("update \"main\".\"logins\" set image_data=@image_byte_array where origin_url='{0}' ", url); // using (SQLiteConnection connect = new SQLiteConnection(ConnectionString)) // { // connect.Open(); // using (SQLiteCommand command = new SQLiteCommand(sql, connect)) // { // command.Parameters.Add("@image_byte_array", DbType.Binary, imageData.Length); // command.Parameters["@image_byte_array"].Value = imageData; // command.ExecuteNonQuery(); // } // connect.Close(); // } // } // catch (Exception ex) // { // } //} private byte[] GetIconFromUrl(string url) { byte[] imageData = new byte[0]; Converts conv = new Converts(); Image _imageData = null; try { _imageData = Favicon.GetFromUrl(url).Icon; if (_imageData != null) { byte[] tmpImageData = conv.ImageToByteArray(_imageData); Array.Resize(ref imageData, tmpImageData.Length); Array.Copy(tmpImageData, imageData, tmpImageData.Length); } return(imageData); } catch (Exception ex) { return(imageData); } }
/// <summary> /// Used to set the search bar text to the URI of the website. /// </summary> private void browser_AddressChanged(object sender, AddressChangedEventArgs args) { //Invokes on UI thread mainTabPage.InvokeOnUiThreadIfRequired(() => { //Sets the search bar to the address of the web browser. OnDocumentURLChange?.Invoke(browser, new DocumentURLChange { DocumentURL = args.Address }); //Activating the History Command AddHistoryEntry(args.Address, HistoryValueType.URL); }); Image iconIco = Favicon.GetFromUrl(args.Address).Icon; //Gets the tmp Path to store all of the icons. string tmpPath = Path.GetTempPath() + @"MoonByte\" + ResourceInformation.ApplicationName + @"\"; mainTabPage.ChangeTabIcon(iconIco); }