private async Task BrowserLoadAsync() { try { var newsHtmlPanel = new HtmlPanel { Dock = DockStyle.Fill, BaseStylesheet = "" }; newsHtmlPanel.ImageLoad += HtmlPanel_ImageLoad; TabPage_News.Controls.Add(newsHtmlPanel); newsHtmlPanel.Text = await new TimeoutWebClient { Timeout = 3000, Encoding = Encoding.UTF8 }.DownloadStringTaskAsync(NewsUri); //await Task.Run(async () => { newsHtmlPanel.Text = await new TimeoutWebClient { Timeout = 3000, Encoding = Encoding.UTF8 }.DownloadStringTaskAsync(NewsUri); }); var faqHtmlPanel = new HtmlPanel { Dock = DockStyle.Fill, BaseStylesheet = "" }; faqHtmlPanel.ImageLoad += HtmlPanel_ImageLoad; TabPage_FAQ.Controls.Add(faqHtmlPanel); faqHtmlPanel.Text = await new TimeoutWebClient { Timeout = 3000, Encoding = Encoding.UTF8 }.DownloadStringTaskAsync(FAQUri); //await Task.Run(async () => { faqHtmlPanel.Text = await new TimeoutWebClient { Timeout = 3000, Encoding = Encoding.UTF8 }.DownloadStringTaskAsync(FAQUri); }); } catch (WebException) { /* do nothing */ } }
internal void setDiscussionNoteText(Control noteControl, DiscussionNote note) { if (note == null) { // this is possible when noteControl detaches from parent return; } Debug.Assert(noteControl is HtmlPanel); HtmlPanel htmlPanel = noteControl as HtmlPanel; htmlPanel.BaseStylesheet = String.Format( "{0} body div {{ font-size: {1}px; padding-left: 4px; padding-right: {2}px; }}", Properties.Resources.Common_CSS, WinFormsHelpers.GetFontSizeInPixels(noteControl), SystemInformation.VerticalScrollBarWidth * 2); // this is really weird // We need to zero the control size before SetText call to allow HtmlPanel to compute the size int prevWidth = noteControl.Width; noteControl.Width = 0; noteControl.Height = 0; string body = MarkDownUtils.ConvertToHtml(note.Body, _imagePath, _specialDiscussionNoteMarkdownPipeline); noteControl.Text = String.Format(MarkDownUtils.HtmlPageTemplate, addPrefix(body, note, _firstNoteAuthor)); resizeLimitedWidthHtmlPanel(htmlPanel, prevWidth); _htmlDiscussionNoteToolTip.BaseStylesheet = String.Format("{0} body div {{ font-size: {1}px; }}", Properties.Resources.Common_CSS, WinFormsHelpers.GetFontSizeInPixels(noteControl)); _htmlDiscussionNoteToolTip.SetToolTip(noteControl, getNoteTooltipHtml(note)); }
private void setDiffContextText(Control diffContextControl) { double fontSizePx = WinFormsHelpers.GetFontSizeInPixels(diffContextControl); DiscussionNote note = getNoteFromControl(diffContextControl); Debug.Assert(note.Type == "DiffNote"); DiffPosition position = PositionConverter.Convert(note.Position); Debug.Assert(diffContextControl is HtmlPanel); HtmlPanel htmlPanel = diffContextControl as HtmlPanel; // We need to zero the control size before SetText call to allow HtmlPanel to compute the size int prevWidth = htmlPanel.Width; htmlPanel.Width = 0; htmlPanel.Height = 0; string html = getContext(_panelContextMaker, position, _diffContextDepth, fontSizePx, out string css); htmlPanel.BaseStylesheet = css; htmlPanel.Text = html; resizeLimitedWidthHtmlPanel(htmlPanel, prevWidth); string tooltipHtml = getContext(_tooltipContextMaker, position, _tooltipContextDepth, fontSizePx, out string tooltipCSS); _htmlDiffContextToolTip.BaseStylesheet = String.Format("{0} .htmltooltip {{ padding: 1px; }}", tooltipCSS); _htmlDiffContextToolTip.SetToolTip(htmlPanel, tooltipHtml); }
private void setServiceDiscussionNoteText(Control noteControl, DiscussionNote note) { if (note == null) { Debug.Assert(false); return; } // We need to zero the control size before SetText call to allow HtmlPanel to compute the size noteControl.Width = 0; noteControl.Height = 0; Debug.Assert(noteControl is HtmlPanel); HtmlPanel htmlPanel = noteControl as HtmlPanel; htmlPanel.BaseStylesheet = String.Format("{0} body div {{ font-size: {1}px; }}", Properties.Resources.Common_CSS, WinFormsHelpers.GetFontSizeInPixels(noteControl)); string body = MarkDownUtils.ConvertToHtml(note.Body, _imagePath, _specialDiscussionNoteMarkdownPipeline); noteControl.Text = String.Format(MarkDownUtils.HtmlPageTemplate, body); resizeFullSizeHtmlPanel(noteControl as HtmlPanel); }
private void resizeLimitedWidthHtmlPanel(HtmlPanel htmlPanel, int width) { htmlPanel.Width = width; int extraHeight = htmlPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0; htmlPanel.Height = htmlPanel.AutoScrollMinSize.Height + 2 + extraHeight; }
private HtmlPanel createDiffContext(DiscussionNote firstNote) { if (firstNote.Type != "DiffNote") { return(null); } int fontSizePx = 12; int rowsVPaddingPx = 2; int rowHeight = (fontSizePx + rowsVPaddingPx * 2 + 1 /* border of control */ + 2); // we're adding 2 extra pixels for each row because HtmlRenderer does not support CSS line-height property // this value was found experimentally int panelHeight = (_diffContextDepth.Size + 1) * rowHeight; HtmlPanel htmlPanel = new HtmlPanel { BorderStyle = BorderStyle.FixedSingle, Height = panelHeight, MinimumSize = new Size(600, 0), TabStop = false }; DiffPosition position = convertToDiffPosition(firstNote.Position); htmlPanel.Text = getContext(_panelContextMaker, position, _diffContextDepth, fontSizePx, rowsVPaddingPx); _htmlToolTip.SetToolTip(htmlPanel, getContext(_tooltipContextMaker, position, _tooltipContextDepth, fontSizePx, rowsVPaddingPx)); return(htmlPanel); }
/// <summary> /// Constructor; initializes <see cref="_applicationForm"/>. /// </summary> /// <param name="applicationForm">Main application form instance associated with this window.</param> public OptionsWindow(MainForm applicationForm) { _applicationForm = applicationForm; InitializeComponent(); _toolsMenu.Renderer = new EasyConnectToolStripRender(); _iconPictureBox.Image = new Icon(Icon, 16, 16).ToBitmap(); _urlPanel = new HtmlPanel { AutoScroll = false, Width = _urlPanelContainer.Width, Height = _urlPanelContainer.Height, Left = 0, Top = 0, Font = urlTextBox.Font, Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top }; _urlPanelContainer.Controls.Add(_urlPanel); _urlPanel.Text = String.Format( @"<span style=""background-color: #FFFFFF; font-family: {2}; font-size: {1}pt; height: {0}px; color: #9999BF"">easyconnect://<font color=""black"">options</font></span>", _urlPanel.Height, urlTextBox.Font.SizeInPoints, urlTextBox.Font.FontFamily.GetName(0)); #if APPX _updatesMenuItem.Visible = false; _toolsMenuSeparator2.Visible = false; #else _updatesMenuItem.Visible = ConfigurationManager.AppSettings["checkForUpdates"] != "false"; _toolsMenuSeparator2.Visible = ConfigurationManager.AppSettings["checkForUpdates"] != "false"; #endif }
private string getContextHtmlText(DiffPosition position, HtmlPanel htmlPanel, out string stylesheet) { stylesheet = String.Empty; double fontSizePx = WinFormsHelpers.GetFontSizeInPixels(htmlPanel); var getContext = isCurrentNoteNew() ? _getNewDiscussionDiffContext(position) : _getDiffContext(position); return(DiffContextFormatter.GetHtml(getContext, fontSizePx, 2, true)); }
private void updatePreview(HtmlPanel previewPanel, string text) { previewPanel.BaseStylesheet = String.Format("{0} body div {{ font-size: {1}px; }}", Properties.Resources.Common_CSS, WinFormsHelpers.GetFontSizeInPixels(previewPanel)); var pipeline = MarkDownUtils.CreatePipeline(Program.ServiceManager.GetJiraServiceUrl()); string body = MarkDownUtils.ConvertToHtml(text, String.Empty, pipeline); previewPanel.Text = String.Format(MarkDownUtils.HtmlPageTemplate, body); }
public previewForm() { InitializeComponent(); htmlPanel = new TheArtOfDev.HtmlRenderer.WinForms.HtmlPanel(); htmlPanel.Location = new Point(0, labelAttachments.Location.Y + 25); htmlPanel.Width = Width; htmlPanel.Height = Height; htmlPanel.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; Controls.Add(htmlPanel); }
private void SetHTMLPanelText(HtmlPanel ctl, string text) { try { ctl.Text = text; m_htmlText = text; } catch (ArgumentException) { ctl.Text = text; } }
public ConversationForm(string thisUserId, string otherUserId, string hash_pass, VoipClientModule voipClient) { _thisUserId = thisUserId; _otherUserId = otherUserId; _voipClient = voipClient; InitializeComponent(); this.Text = $"Conversation with {otherUserId}"; _htmlPanel = new HtmlPanel(); panel1.Controls.Add(_htmlPanel); _htmlPanel.Dock = DockStyle.Fill; _voipClient.PhoneStateChanged += VoipClientOnPhoneStateChanged; }
public static HtmlString Panel(this HtmlHelper helper, string id, string header, string body, string footer, string dataBind, PanelHeaderStyle headerStyle = PanelHeaderStyle.Default) { var panel = new HtmlPanel(); panel.Id = id; panel.Header = header; panel.HeaderStyle = headerStyle; panel.Footer = footer; panel.Body.AppendLine(body); return(new HtmlString(panel.ToString())); }
public HtmlSurrogate(HtmlPanel htmlPanel, Context?context, ViewGroup viewGroup, IUiProvider uiProvider) : base(context) { _htmlPanel = htmlPanel; _viewGroup = viewGroup; _uiProvider = uiProvider; _htmlPanel.PropertyChanged += OnControlPropertyChanged; _hasPendingContent = htmlPanel.Markup != null || htmlPanel.Uri != null; }
private void showDiscussionContext(DiffPosition position, HtmlPanel htmlPanel) { if (position == null) { htmlPanel.Text = "This discussion is not associated with code"; return; } string html = getContextHtmlText(position, htmlPanel, out string stylesheet); htmlPanel.BaseStylesheet = stylesheet; htmlPanel.Text = html; }
/// <summary> /// Throws ArgumentException. /// Throws GitOperationException and GitObjectException in case of problems with git. /// </summary> private void showDiscussionContext(HtmlPanel htmlPanel, TextBox tbFileName) { ContextDepth depth = new ContextDepth(0, 3); IContextMaker textContextMaker = new EnhancedContextMaker(_gitRepository); DiffContext context = textContextMaker.GetContext(_position, depth); DiffContextFormatter formatter = new DiffContextFormatter(); htmlPanel.Text = formatter.FormatAsHTML(context); tbFileName.Text = "Left: " + (_difftoolInfo.Left?.FileName ?? "N/A") + " Right: " + (_difftoolInfo.Right?.FileName ?? "N/A"); }
/// <summary> /// Default constructor; initializes the UI for the OmniBar. /// </summary> public ConnectionWindow() { InitializeComponent(); // Create the panels that will contain the display text for each auto complete entry when the user is typing in the URL text box for (int i = 0; i < 6; i++) { HtmlPanel autoCompletePanel = new HtmlPanel { AutoScroll = false, Width = _omniBarPanel.Width, Height = 30, Left = 0 }; autoCompletePanel.Top = i * autoCompletePanel.Height; autoCompletePanel.Font = urlTextBox.Font; autoCompletePanel.MouseEnter += autoCompletePanel_MouseEnter; autoCompletePanel.MouseLeave += autoCompletePanel_MouseLeave; autoCompletePanel.Click += autoCompletePanel_Click; autoCompletePanel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; PictureBox autoCompletePictureBox = new PictureBox { Width = 16, Height = 16, Left = 5, Top = autoCompletePanel.Top + 7 }; _omniBarPanel.Controls.Add(autoCompletePictureBox); _omniBarPanel.Controls.Add(autoCompletePanel); } urlTextBox.LostFocus += urlTextBox_LostFocus; _iconPictureBox.Image = new Icon(Resources.EasyConnect, 16, 16).ToBitmap(); _urlPanel = new HtmlPanel { AutoScroll = false, Width = _urlPanelContainer.Width, Height = _urlPanelContainer.Height, Left = 0, Top = 0, Font = urlTextBox.Font, Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top }; _urlPanel.Click += _urlPanel_Click; _urlPanelContainer.Controls.Add(_urlPanel); urlTextBox.Visible = false; }
/// <summary> /// Click the Trade row where we load the details and show in a browser /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Trade_Click(object sender, EventArgs e) { // get the Trade object var panel = sender as Label; var trade = m_trades.Where(t => t.Id == panel.Tag as string).FirstOrDefault(); if (trade == null) { return; } // inject browser HtmlPanel browser; if (m_browserHeight != 0) { tradesContainer.Height -= m_browserHeight; browserContainer.Height = m_browserHeight; m_browserHeight = 0; browser = new HtmlPanel(); browser.Dock = DockStyle.Fill; browser.Location = new Point(0, 0); browser.Size = new Size(browserContainer.Width, browserContainer.Height); browserContainer.Controls.Add(browser); } else { browser = browserContainer.Controls[0] as HtmlPanel; } // pull details segment and merge with normal html var cursor = Cursor.Current; try { Cursor.Current = Cursors.WaitCursor; Application.DoEvents(); browser.Text = AuthenticatorData.GetClient().GetConfirmationDetails(trade); } catch (Exception ex) { browser.Text = "<html><head></head><body><p>" + ex.Message + "</p>" + ex.StackTrace.Replace(Environment.NewLine, "<br>") + "</body></html>"; } finally { Cursor.Current = cursor; } }
public HtmlSurrogate2(Context?context, HtmlPanel htmlPanel, WebView nativeView, IUiProvider uiProvider, ViewGroup viewGroup) : base(context, htmlPanel, nativeView, viewGroup) { _uiProvider = uiProvider; _htmlPanel = htmlPanel; _nativeView = nativeView; htmlPanel.PropertyChanged += OnControlPropertyChanged; _hasPendingContent = htmlPanel.Markup != null || htmlPanel.Uri != null; }
private void LoadDocumentForTab(TabPage page) { if (page != null && page.Controls.Count == 0 && page.Tag != null) { Control documentView; string fullPath; string text; Cursor.Current = Cursors.WaitCursor; Debug.Print("Loading readme: {0}", page.Tag); fullPath = this.GetFullReadmePath(page.Tag.ToString()); text = File.Exists(fullPath) ? File.ReadAllText(fullPath) : string.Format("Cannot find file '{0}'", fullPath); if (text.IndexOf('\n') != -1 && text.IndexOf('\r') == -1) { text = text.Replace("\n", "\r\n"); } switch (Path.GetExtension(fullPath)) { case ".md": documentView = new HtmlPanel { Dock = DockStyle.Fill, BaseStylesheet = Resources.CSS, Text = string.Concat("<html><body>", CommonMarkConverter.Convert(text), "</body></html>") // HACK: HTML panel screws up rendering if a <body> tag isn't present }; break; default: documentView = new TextBox { ReadOnly = true, Multiline = true, WordWrap = true, ScrollBars = ScrollBars.Vertical, Dock = DockStyle.Fill, Text = text, Font = new Font("Courier New", 10) }; break; } page.Controls.Add(documentView); Cursor.Current = Cursors.Default; } }
/// <summary> /// Constructor; loads the history data and gets the icons for each protocol. /// </summary> /// <param name="applicationForm">Main application for for this window.</param> public HistoryWindow(MainForm applicationForm) { _applicationForm = applicationForm; InitializeComponent(); historyContextMenu.Renderer = new EasyConnectToolStripRender(); _historyListView.ListViewItemSorter = new HistoryComparer(_connections); // Get the icon for each protocol foreach (IProtocol protocol in ConnectionFactory.GetProtocols()) { Icon icon = new Icon(protocol.ProtocolIcon, 16, 16); historyImageList.Images.Add(icon); _connectionTypeIcons[protocol.ConnectionType] = historyImageList.Images.Count - 1; } Connections_CollectionModified(History.Instance.Connections, new ListModificationEventArgs(ListModification.RangeAdded, 0, History.Instance.Connections.Count)); History.Instance.Connections.CollectionModified += Connections_CollectionModified; _toolsMenu.Renderer = new EasyConnectToolStripRender(); _iconPictureBox.Image = new Icon(Icon, 16, 16).ToBitmap(); _urlPanel = new HtmlPanel { AutoScroll = false, Width = _urlPanelContainer.Width, Height = _urlPanelContainer.Height, Left = 0, Top = 0, Font = urlTextBox.Font, Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top, BackColor = Color.FromArgb(241, 243, 244) }; _urlPanelContainer.Controls.Add(_urlPanel); _urlPanel.Text = String.Format(CultureInfo.InvariantCulture, @"<span style=""background-color: #F1F3F4; font-family: {2}; font-size: {1}pt; height: {0}px; color: #707172"">easyconnect://<font color=""black"">history</font></span>", _urlPanel.Height, urlTextBox.Font.SizeInPoints, urlTextBox.Font.FontFamily.GetName(0)); #if APPX _updatesMenuItem.Visible = false; _toolsMenuSeparator2.Visible = false; #else _updatesMenuItem.Visible = ConfigurationManager.AppSettings["checkForUpdates"] != "false"; _toolsMenuSeparator2.Visible = ConfigurationManager.AppSettings["checkForUpdates"] != "false"; #endif }
async private void MenuItemToggleResolveNote_Click(object sender, EventArgs e) { MenuItem menuItem = (MenuItem)(sender); HtmlPanel htmlPanel = (HtmlPanel)(menuItem.Tag); if (htmlPanel?.Parent?.Parent == null) { return; } DiscussionNote note = getNoteFromControl(htmlPanel); Debug.Assert(note == null || note.Resolvable); await onToggleResolveNoteAsync(note); }
private void resizeBoxContent(int width) { if (_textboxesNotes != null) { foreach (Control noteControl in _textboxesNotes) { HtmlPanel htmlPanel = noteControl as HtmlPanel; DiscussionNote note = getNoteFromControl(noteControl); if (note != null && !isServiceDiscussionNote(note)) { resizeLimitedWidthHtmlPanel(htmlPanel, width * NotesWidth / 100); } else { resizeFullSizeHtmlPanel(htmlPanel); } } } int realLabelAuthorPercents = Convert.ToInt32( LabelAuthorWidth * ((Parent as CustomFontForm).CurrentFontMultiplier * LabelAuthorWidthMultiplier)); if (_labelAuthor != null) { _labelAuthor.Width = width * realLabelAuthorPercents / 100; } if (_textboxFilename != null) { _textboxFilename.Width = width * LabelFilenameWidth / 100; _textboxFilename.Height = (_textboxFilename as TextBoxEx).FullPreferredHeight; } int remainingPercents = 100 - HorzMarginWidth - realLabelAuthorPercents - HorzMarginWidth - NotesWidth - HorzMarginWidth - HorzMarginWidth - HorzMarginWidth; if (_panelContext != null) { resizeLimitedWidthHtmlPanel(_panelContext as HtmlPanel, width * remainingPercents / 100); _htmlDiffContextToolTip.MaximumSize = new Size(_panelContext.Width, 0 /* auto-height */); } }
public MarbleBrowser(Control control) { _htmlPanel = new HtmlPanel(); control.Controls.Add(_htmlPanel); control.Resize += (sender, args) => { _htmlPanel.Width = control.Width / 2; _htmlPanel.Height = control.Height; _htmlPanel.Location = new Point(control.Width / 2, 0); }; _htmlPanel.BaseStylesheet = null; _htmlPanel.Text = null; _htmlPanel.RenderError += OnRenderError; _htmlPanel.StylesheetLoad += OnStylesheetLoad; }
private void ShowTitle(HtmlPanel panel) { //update title, this might fail when called from Navigated as the document might not be ready yet //but we also call on LoadCompleted. This should catch both situations //of real navigation and also back and forth in history var title = panel.GetTitle(); const string geminiTitle = "GemiNaut, a friendly GUI browser"; try { Application.Current.MainWindow.Title = title == null ? geminiTitle : title + " - " + geminiTitle; } catch (Exception e) { ToastNotify(e.Message, ToastMessageStyles.Error); } }
public AddonDetailsDialog(String addonNameText, String addonTypeText, String addonCreatorText, String addonVersionText, String addonDescriptionText) { Font = new Font(Font.Name, 8.25f * 96f / CreateGraphics().DpiX, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont); InitializeComponent(); detailsAddonNameMaxLabel.Text = String.Format(detailsAddonNameMaxLabel.Text, Addon.addonNameDef[2] - 1); detailsAddonNameTextBox.MaxLength = Addon.addonNameDef[2] - 1; detailsAddonCreatorMaxLabel.Text = String.Format(detailsAddonCreatorMaxLabel.Text, Addon.addonCreatorDef[2] - 1); detailsAddonCreatorTextBox.MaxLength = Addon.addonCreatorDef[2] - 1; detailsAddonVersionMaxLabel.Text = String.Format(detailsAddonVersionMaxLabel.Text, Addon.addonVersionDef[2] - 1); detailsAddonVersionTextBox.MaxLength = Addon.addonVersionDef[2] - 1; detailsAddonDescriptionMaxLabel.Text = String.Format(detailsAddonDescriptionMaxLabel.Text, Addon.addonDescriptionDef[2] - 1); detailsAddonDescriptionEditor.MaxLength = Addon.addonDescriptionDef[2] - 1; detailsAddonNameTextBox.Text = addonNameText; detailsAddonTypeTextBox.Text = addonTypeText; detailsAddonCreatorTextBox.Text = addonCreatorText; detailsAddonDateTextBox.Text = DateTime.Now.ToShortDateString(); detailsAddonVersionTextBox.Text = addonVersionText; detailsAddonOfflineServerVersionTextBox.Text = MainForm.localOfflineServerVersion; if (addonDescriptionText.StartsWith("<font face=\"Microsoft Sans Serif\" size=\"8pt\">") && addonDescriptionText.EndsWith("</font>")) { addonDescriptionText = addonDescriptionText.Remove(addonDescriptionText.Length - 7, 7).Remove(0, 45); addonDescriptionUseDefaultFontCheckBox.Checked = true; } else { if (addonDescriptionText.Length > (Addon.addonDescriptionDef[2] - 53)) { addonDescriptionUseDefaultFontCheckBox.Checked = false; } } detailsAddonDescriptionEditor.Text = addonDescriptionText; htmlPanel = new HtmlPanel(); htmlPanel.AutoSize = false; htmlPanel.BorderStyle = BorderStyle.Fixed3D; htmlPanel.Location = new Point(620, 37); htmlPanel.Size = new Size(210, 299); htmlPanel.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; this.Controls.Add(htmlPanel); }
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); HtmlPanel ctl = DataGridView.EditingControl as HtmlPanel; // initialFormattedValue = "This is an <b>HtmlLabel</b> control"; if (ctl != null) { if (initialFormattedValue == null) { string nullText = "";//"This <b>cell</b> has a <span style=\"color: red\">null</span> value!"; SetHTMLPanelText(ctl, nullText); } else { SetHTMLPanelText(ctl, Convert.ToString(initialFormattedValue)); } } }
public static string GetTitle(this HtmlPanel panel) { return(null); if (string.IsNullOrWhiteSpace(panel.Text)) { return(null); } var doc = XDocument.Parse(panel.Text); var titleTag = doc.Descendants("title").First(); if (titleTag != null) { return(titleTag.Value); } return(null); }
void _LoadHtmlRenderer() { if (_html != null) { return; } _html = new HtmlPanel { AccessibleName = "Info_code", Dock = DockStyle.Fill, //BackColor = Color.LightYellow, BackColor = Color.FromArgb(unchecked ((int)0xfff8fff0)), UseSystemCursors = true, BaseStylesheet = CiHtml.s_CSS }; _html.ImageLoad += CodeInfo.OnHtmlImageLoad; _html.LinkClicked += _html_LinkClicked; this.Controls.Add(_html); _html.Hide(); //workaround for: HtmlPanel flickers (temp hscrollbar) when setting text first time. Now hide, then show after setting text. }
public static void ShowDialog(string title, dynamic attachment, string duedate = "", string description = "", bool quiz = false, string desde = "", string hasta = "", string limit = "") { Form prompt = new Form(); HtmlPanel _lblMessage = new HtmlPanel(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(lxMeets)); prompt.Width = 700; prompt.Height = 300; prompt.BackColor = Color.FromArgb(45, 45, 48); _lblMessage.Left = 16; if (quiz) { _lblMessage.Text = "<p style='color: white'>Habilitado desde: " + desde + "<br>Hasta: " + hasta + "<br>Tiempo Límite: " + limit + " </p>" + "<br>" + description; } else { _lblMessage.Text = "<p style='color: white'>Entrega hasta: " + duedate + " </p>" + "<br>" + description; } foreach (var s in attachment) { try { _lblMessage.Text += "<br> <a href='" + s.fileurltoken.ToString() + "'>" + s.filename.ToString() + " ⤓</a> <p style='color: white'>" + Convert.ToInt32(s.filesize) + " KB </p>"; } catch { } } _lblMessage.Top = 100; _lblMessage.Width = 80; _lblMessage.TabIndex = 1; _lblMessage.TabStop = true; _lblMessage.ForeColor = Color.White; _lblMessage.BackColor = prompt.BackColor; _lblMessage.Font = new Font("Segoe UI", 10); _lblMessage.Dock = DockStyle.Fill; prompt.Name = title; prompt.AutoSize = true; prompt.StartPosition = FormStartPosition.CenterScreen; prompt.Icon = ((Icon)(resources.GetObject("$this.Icon"))); prompt.Text = title; prompt.Controls.Add(_lblMessage); prompt.ShowDialog(); }
private void LoadDocumentForTab(TabPage page) { if (page != null && page.Controls.Count == 0 && page.Tag != null) { Control documentView; string fullPath; string text; Cursor.Current = Cursors.WaitCursor; Debug.Print("Loading readme: {0}", page.Tag); fullPath = this.GetFullReadmePath(page.Tag.ToString()); text = File.Exists(fullPath) ? File.ReadAllText(fullPath) : string.Format("Cannot find file '{0}'", fullPath); if (text.IndexOf('\n') != -1 && text.IndexOf('\r') == -1) { text = text.Replace("\n", "\r\n"); } switch (Path.GetExtension(fullPath)) { case ".md": documentView = new HtmlPanel { Dock = DockStyle.Fill, BaseStylesheet = Properties.Resources.CSS, Text = string.Concat("<html><body>", CommonMarkConverter.Convert(text), "</body></html>") // HACK: HTML panel screws up rendering if a <body> tag isn't present }; break; default: documentView = new TextBox { ReadOnly = true, Multiline = true, WordWrap = true, ScrollBars = ScrollBars.Vertical, Dock = DockStyle.Fill, Text = text }; break; } page.Controls.Add(documentView); Cursor.Current = Cursors.Default; } }
public MainForm(Boolean isFirstRun = false, String installAddonPath = null, Boolean setupIPCTalk = false, Int32 port = -1) { Logger.Setup(); #region Culture Independency Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB"); Properties.Resources.Culture = new CultureInfo("en-GB"); log.Info("Culture independency achieved."); #endregion Font = new Font(Font.Name, 8.25f * 96f / CreateGraphics().DpiX, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont); InitializeComponent(); offlineServerTalk = new OfflineServerTalk(); addonProject = new AddonProject(); htmlPanel = new HtmlPanel(); htmlPanel.AutoSize = false; htmlPanel.BorderStyle = BorderStyle.Fixed3D; htmlPanel.Location = new Point(186, 38); htmlPanel.Size = new Size(210, 299); htmlPanel.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; installAddonGroupBox.Controls.Add(htmlPanel); avalonEditProxyAccent.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); avalonEditProxyTheme.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); avalonEditProxyLanguage.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("XML"); avalonEditProxyMemoryPatch.textEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("C#"); avalonEditProxyAccent.textEditor.Text = AddonProject.Accent.defaultAccentXaml; avalonEditProxyTheme.textEditor.Text = AddonProject.Theme.defaultThemeXaml; avalonEditProxyLanguage.textEditor.Text = AddonProject.Language.defaultLanguageFileText; if (!String.IsNullOrWhiteSpace(installAddonPath)) { log.Info("/installAddon was specified, executing run-once installation."); // handle auto install } else { if (isFirstRun) { if (setupIPCTalk && port != -1) offlineServerTalk.initialize(port); BeginInvoke(new MethodInvoker(delegate { Hide(); FirstRunForm frForm = new FirstRunForm(this); frForm.Show(); })); } } }
private void docsTabControl_Selecting(object sender, TabControlCancelEventArgs e) { TabPage page; page = e.TabPage; if (page.Controls.Count == 0 && page.Tag != null) { Control documentView; string fullPath; string text; Cursor.Current = Cursors.WaitCursor; Debug.Print("Loading readme: {0}", page.Tag); fullPath = this.GetFullReadmePath(page.Tag.ToString()); text = File.Exists(fullPath) ? File.ReadAllText(fullPath) : string.Format("Cannot find file '{0}'", fullPath); if (text.IndexOf('\n') != -1 && text.IndexOf('\r') == -1) { text = text.Replace("\n", "\r\n"); } switch (Path.GetExtension(fullPath)) { case ".md": Markdown parser; parser = new Markdown(); documentView = new HtmlPanel { Dock = DockStyle.Fill, Text = parser.Transform(text) }; break; default: documentView = new TextBox { ReadOnly = true, Multiline = true, WordWrap = true, ScrollBars = ScrollBars.Vertical, Dock = DockStyle.Fill, Text = text }; break; } page.Controls.Add(documentView); Cursor.Current = Cursors.Default; } }