public void Start() { if (File.Exists("favicon.png")) { Icon = Favicon.FromBase64String(Convert.ToBase64String(File.ReadAllBytes("favicon.png"))); _logger.LogInformation($"Loaded server favicon from file favicon.png"); } else { _logger.LogWarning($"No favicon found. To enable favicons, save a 64x64 file called \"favicon.png\" into the server's directory."); } _logger.LogInformation($"Default server on port {Configuration.ServerPort}..."); _logger.LogInformation($"Minecraft Version: {MinecraftVersion}"); _logger.LogInformation($"Protocol Version: {ProtocolVersion}"); _listener.Start(); while (!_isStopped) { if (_isDisposed) { throw new ObjectDisposedException(GetType().Name); } var client = _listener.AcceptTcpClient(); _logger.LogDebug($"[{client.Client.RemoteEndPoint}] New client incoming..."); _connection.Handle(client); _logger.LogDebug($"[{client.Client.RemoteEndPoint}] Handled."); } }
public void Initialize(LoginFieldS lf) { Commands.AddCommand("NotNow", NotNow); Commands.AddCommand("Add", Add); DrawingImage tmpDraw = new DrawingImage(); try { Username = lf.userName; Password = lf.password; Title = lf.title; _lf = lf; tmpDraw = HIOStaticValues.PutTextInImage(lf.url.Substring(0, 1)); IconUrl = tmpDraw; Task.Run(() => { Favicon fv = new Favicon(); fv.GetFromUrlAsync("http://" + lf.url); fv.GetFromUrlAsyncCompleted += Fv_GetFromUrlAsyncCompleted; }); } catch (Exception ex) { } }
public UC_mailSearchWeb() { InitializeComponent(); m_identifier = Page.MailSearchWeb; m_next = Page.Gesture; m_previous = Page.Action; lbl_icon.Text = Translation.GetText("C_SearchOpenWeb_lbl_icon"); m_timer = new Timer(); m_timer.Interval = 2000; m_timer.Tick += new EventHandler(m_timer_Tick); m_webIconExtractor = new Favicon(); m_webIconExtractor.IconObatined += new Favicon.DlgIconObtained(IconObtained); m_autoCompleteSearchItems = new AutoCompleteStringCollection(); m_autoCompleteSearchItems.AddRange(new string[] { "http://www.google.com/search?&q=(*)", "http://en.wikipedia.org/w/index.php?&search=(*)", "http://maps.google.com/maps?q=(*)", "http://translate.google.com/#auto|en|(*)", "http://www.last.fm/search?q=(*)", "http://www.imdb.com/find?s=all&q=(*)", "http://search.yahoo.com/search?p=(*)", "http://www.bing.com/search?q=(*)", "http://search.seznam.cz/?q=(*)", "http://www.slovnik.seznam.cz/?q=(*)&lang=en_cz", "http://www.mapy.cz/?query=(*)", "http://www.csfd.cz/hledani-filmu-hercu-reziseru-ve-filmove-databazi/?search=(*)" }); }
//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); } }
public void DisplayData(string fullname, string description, string avatar, string time, string videofile, int likesCount, bool isliked, bool isSaved, int votesCount) { try { Fullname.Text = fullname; TimeTextView.Text = time; GlideImageLoader.LoadImage(Activity, avatar, UserAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); var textSanitizer = new TextSanitizer(Description, Activity); if (!string.IsNullOrEmpty(description)) { ReadMoreOption.AddReadMoreTo(Description, Methods.FunString.DecodeString(description)); textSanitizer.Load(Methods.FunString.DecodeString(description)); } else { Description.Visibility = ViewStates.Gone; } CommentIcon.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#888888") : Color.ParseColor("#444444")); LikeCount.Text = likesCount + " " + Context.GetText(Resource.String.Lbl_Likes); LikeIcon.Tag = "Like"; if (isliked) { LikeIcon.SetTextColor(Color.ParseColor("#ed4856")); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, LikeIcon, IonIconsFonts.IosHeart); LikeIcon.Tag = "Liked"; } if (!isSaved) { Favicon.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#888888") : Color.ParseColor("#444444")); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, Favicon, IonIconsFonts.IosStarOutline); Favicon.Tag = "Add"; } else { Favicon.SetTextColor(Color.ParseColor("#FFCE00")); FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, Favicon, IonIconsFonts.AndroidStar); Favicon.Tag = "Added"; } CommentCount.Text = votesCount + " " + Context.GetText(Resource.String.Lbl_Comments); if (votesCount <= 4) { ViewCommentsButton.Visibility = ViewStates.Gone; } } catch (Exception e) { Console.WriteLine(e); } }
private void LoadFavicon() { var favicon = Favicon.Load(); if (favicon != null) { this.Icon = favicon; } }
public IHtmlString HeadContent() { var builder = new StringBuilder(); builder.Append(Metadata.GetHtml()); builder.Append(Favicon.GetHtml()); builder.Append(Theme.GetHtml()); builder.Append(Script.GetHtml()); return(MvcHtmlString.Create(builder.ToString())); }
private async Task DownloadAssetsAsync() { try { var bytes = await client.TransferBytesAsync("/favicon.ico"); Favicon.Save(bytes); } catch (Exception ex) { ex.Trace(); } }
/// <summary> /// 绑定表单 /// </summary> /// <returns></returns> protected override object OnSubmit() { // 保存设置 var configManager = Application.Ioc.Resolve <GenericConfigManager>(); var settings = configManager.GetData <WebsiteSettings>(); settings.WebsiteName = WebsiteName; settings.DocumentTitleFormat = DocumentTitleFormat; settings.PageKeywords = PageKeywords; settings.PageDescription = PageDescription; settings.CopyrightText = CopyrightText; configManager.PutData(settings); // 保存Logo var logoManager = Application.Ioc.Resolve <LogoManager>(); if (RestoreDefaultFrontPageLogo) { logoManager.RestoreDefaultFrontPageLogo(); } else if (FrontPageLogo != null) { logoManager.SaveFrontPageLogo(FrontPageLogo.OpenReadStream()); } if (RestoreDefaultAdminPanelLogo) { logoManager.RestoreDefaultAdminPageLogo(); } else if (AdminPanelLogo != null) { logoManager.SaveAdminPanelLogo(AdminPanelLogo.OpenReadStream()); } if (RestoreDefaultFavicon) { logoManager.RestoreDefaultFavicon(); } else if (Favicon != null) { logoManager.SaveFavicon(Favicon.OpenReadStream()); } return(new { message = new T("Saved Successfully") }); }
/// <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); }
private void btn_obtainIcon_Click(object sender, EventArgs e) { if (m_tempGesture.Action == null) { return; } switch (m_tempGesture.Action.Name) { case InternetOptions.INTERNET_OPEN_WEBSITE: case InternetOptions.INTERNET_SEARCH_WEB: if (!m_obtainingIcon) { Bitmap favicon = Favicon.Load(tB_address.Text); if (favicon != null) { pB_icon.Image = favicon; } else { tB_address.Enabled = false; //btn_obtainIcon.Enabled = false; btn_obtainIcon.Text = Translation.Btn_cancel; m_cursor = this.Cursor; this.Cursor = Cursors.WaitCursor; m_webIconExtractor.Url = tB_address.Text; m_webIconExtractor.ObtainIcon(); m_obtainingIcon = true; } } else { m_webIconExtractor.StopThread(); m_obtainingIcon = false; tB_address.Enabled = true; btn_obtainIcon.Text = Translation.GetText("C_SearchOpenWeb_btn_getIcon"); //"Get Web Icon"; this.Cursor = m_cursor; } break; } }
private void dgvBookmarks_CellEndEdit(object sender, DataGridViewCellEventArgs e) { Uri url; if (e.ColumnIndex == 2 && Uri.TryCreate(dgvBookmarks[e.ColumnIndex, e.RowIndex].Value as string, UriKind.RelativeOrAbsolute, out url)) { url = new UriBuilder(dgvBookmarks[e.ColumnIndex, e.RowIndex].Value as string).Uri; dgvBookmarks[0, e.RowIndex].Value = Properties.Resources.indicator_small; dgvBookmarks[2, e.RowIndex].Value = url.ToString(); if (url.IsFile) { dgvBookmarks[0, e.RowIndex].Value = Properties.Resources.folder; } else { if (url.Scheme == "http" || url.Scheme == "https") { Favicon favicon = new Favicon(); favicon.GetFromUrlAsyncCompleted += favicon_GetFromUrlAsyncCompleted; favicon.Tag = dgvBookmarks[0, e.RowIndex]; btnSave.Enabled = false; favicon.GetFromUrlAsync(url); } else if (url.Scheme == "ftp") { dgvBookmarks[0, e.RowIndex].Value = Properties.Resources.ftp; } else { dgvBookmarks[0, e.RowIndex].Value = Properties.Resources.world; } } } }
private void favicon_GetFromUrlAsyncCompleted(object sender, AsyncCompletedEventArgs e) { if (!this.IsDisposed) { Favicon favicon = (Favicon)sender; DataGridViewCell cell = (DataGridViewCell)favicon.Tag; if (e.Error == null && favicon.Icon != null) { cell.Value = favicon.Icon.GetThumbnailImage(16, 16, null, IntPtr.Zero); } else { cell.Value = Properties.Resources.world; } btnSave.Invoke((MethodInvoker)(() => { btnSave.Enabled = true; } )); } }
private void HttpListenHandler(IAsyncResult result) { try { var context = Listener.EndGetContext(result); string body = null; if (context.Request.HasEntityBody) { using (System.IO.Stream bodyStream = context.Request.InputStream) { using (System.IO.StreamReader reader = new System.IO.StreamReader(bodyStream, context.Request.ContentEncoding)) { body = reader.ReadToEnd(); } } } byte[] responseBuffer; if (context.Request.RawUrl == "/favicon.ico") { if (Favicon == null) { responseBuffer = new byte[0]; context.Response.StatusCode = 404; } else { using (var stream = new MemoryStream()) { Favicon.Save(stream); responseBuffer = stream.ToArray(); context.Response.ContentType = "image/x-icon"; } } } else { var response = "ok"; string command = "Unknown Command"; try { var urlParams = new List <string>(context.Request.RawUrl.Split(new char[] { '/' })).Select(us => Uri.UnescapeDataString(us)).ToList(); if (!string.IsNullOrWhiteSpace(body)) { urlParams.Add(body); } if (string.IsNullOrWhiteSpace(urlParams.FirstOrDefault())) { urlParams.RemoveAt(0); } if (string.IsNullOrWhiteSpace(urlParams.LastOrDefault()) && urlParams.Any()) { urlParams.RemoveAt(urlParams.Count - 1); } //urlParams = urlParams.Where(p => !string.IsNullOrWhiteSpace(p)).ToList(); if (!urlParams.Any()) { response = Documentation.Function(null, null); } else { string domain = null; if (urlParams.Count > 1 && Commands.ContainsKey(urlParams[1])) { domain = urlParams[0]; urlParams.RemoveAt(0); } command = urlParams[0]; urlParams.RemoveAt(0); if (!Commands.ContainsKey(command)) { throw new ApiError($"Invalid Command"); } command = Commands[command]?.Name; //normalize name for display during errors response = Commands[command].Function(urlParams, domain) ?? response; } } catch (Exception e) { response = $"{command}: {e.Message}"; context.Response.StatusCode = e is ApiError ? 400 : 500; } responseBuffer = Encoding.UTF8.GetBytes(response); context.Response.ContentType = "text/plain"; } // Get a response stream and write the response to it. context.Response.ContentLength64 = responseBuffer.Length; using (System.IO.Stream output = context.Response.OutputStream) { output.Write(responseBuffer, 0, responseBuffer.Length); output.Close(); } } catch { } finally { Listener.BeginGetContext(HttpListenHandler, Listener); } }