Ejemplo n.º 1
0
        protected override async Task OnParametersSetAsync()
        {
            string css = "";

            if (Source == null || HttpClient == null)
            {
                return;
            }
            using var response = await HttpClient.GetAsync(Source + ".md" + "?" + Guid.NewGuid ().ToString());

            if (CSS)
            {
                using var cssResponse =
                          await HttpClient.GetAsync(Source + ".razor.md" + "?" + Guid.NewGuid ().ToString());

                if (cssResponse.StatusCode != HttpStatusCode.OK)
                {
                    return;
                }
                css = await cssResponse.Content.ReadAsStringAsync();
            }

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return;
            }

            var markdown = await response.Content.ReadAsStringAsync();

            markdown = Regex.Replace(markdown, @"<!--\\\\-->(.*?)<!--//-->", "", RegexOptions.Singleline);
            string html;

            var code = "";

            if (markdown.IndexOf("@code", StringComparison.Ordinal) != -1)
            {
                html = markdown.Substring(0, markdown.IndexOf("@code", StringComparison.Ordinal));;
                html = html.TrimEnd('\n', '\r');
                code = markdown.Substring(markdown.IndexOf("@code", StringComparison.Ordinal));
            }
            else
            {
                html = markdown;
                html = html.TrimEnd('\n', '\r');
            }
            html = "```html\n" + html + "\n```";
            if (CSS)
            {
                css = "```css\n" + css + "\n```";
            }
            if (!string.IsNullOrEmpty(code))
            {
                code = "```C#\n" + code + "\n```";
            }
            _markup = new MarkupString(Markdown.ToHtml(html, Pipeline));
            _code   = new MarkupString(Markdown.ToHtml(code, Pipeline));
            _css    = new MarkupString(Markdown.ToHtml(css, Pipeline));

            await base.OnParametersSetAsync();
        }
        protected override void OnParametersSet()
        {
            _componentType = Column.ComponentType;
            _cell = default;
            _cellRender = default;
            if (_componentType != null)
                _cellRender = CreateComponent(GridComponent, _componentType, Column, Item, 
                    RowId, false, new VariableReference(ChildComponent));
            else
                _cell = (MarkupString)Column.GetCell(Item).ToString();
            if (Column.Hidden)
                _cssStyles = ((GridStyledColumn)Column).GetCssStylesString() + " " + TdStyle;
            else
                _cssStyles = ((GridStyledColumn)Column).GetCssStylesString();
            _cssClass = ((GridStyledColumn)Column).GetCssClassesString() + " " + TdClass;

            if (GridComponent.Grid.Direction == GridDirection.RTL)
                _cssStyles = string.Concat(_cssStyles, " text-align:right;direction:rtl;").Trim();

            if (!string.IsNullOrWhiteSpace(Column.Width))
                _cssStyles = string.Concat(_cssStyles, " width:", Column.Width, ";").Trim();

            string columnCssClasses = Column.GetCellCssClasses(Item);
            if(!string.IsNullOrWhiteSpace(columnCssClasses))
                _cssClass += " " + columnCssClasses;
        }
Ejemplo n.º 3
0
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            var(resp, httpResp) = await Backend.VideoList(new VideoListRequest()
            {
                Ids = new[] { VideoId }
            });

            if (httpResp.IsSuccessStatusCode)
            {
                video = resp.Data.Videos.FirstOrDefault();
                if (video == null)
                {
                    errorMessage = "An error occurred while getting video details.";
                }

                string plainDesc = video?.Description ?? "";
                FormattedDescription = new MarkupString(plainDesc.FormatAsHtml());
            }
            else
            {
                errorMessage = "An error occurred while getting video details: " + resp.Message;
            }

            videoStreamUri = await Backend.VideoViewUrl(VideoId);
        }
Ejemplo n.º 4
0
        private void PrintarArray(ushort[] estado, int numeroIteracoes)
        {
            string resultado = "";

            resultado += $"<div class='row'>";
            resultado += $"<div class='col-md-2'>";
            resultado += "<label> Número de iterações feitas</label>";
            resultado += @$ "<input type='number' disabled class='form-control text-center' value='{numeroIteracoes}'/>";
            resultado += "</div>";
            resultado += "</div>";
            resultado += $"<div class='row mt-3'>";
            resultado += $"<div class='col-md-2'>";
            resultado += "<label>Resultado final encontrado</label>";
            resultado += $"<div class='grid-resultado w-h-180'>";



            for (int i = 0; i < estado.Length; i++)
            {
                resultado += @$ "<input type='number' disabled class='input-w-h-60 text-center' value='{estado[i]}'/>";
            }

            resultado += "</div>";
            resultado += "</div>";
            resultado += "</div>";

            MarkupString resultString = (MarkupString)resultado;

            NosMarkupStr.Add(resultString);

            resultado = "";
        }
Ejemplo n.º 5
0
        public MessagePreviewData(string bitmapUri, string message)
        {
            BitmapUri = bitmapUri;

            message = message
                      .Replace(";", "<br>")
                      .Replace(".", "<br>")
                      .Replace(":", "");
            message = sizeReg.Replace(message, (m) =>
            {
                // デフォルトサイズは12
                var size = int.Parse(m.Groups[1].Value);
                var mes  = m.Groups[2].Value;
                var em   = size / 12f;
                return($"<span style=\"font-size: {em}em;\">{mes}</span>");
            });
            message = colorReg.Replace(message, (m) =>
            {
                // RGB関数も含めて生のままでCSS指定できそう
                var color = m.Groups[1].Value.ToLower();
                var mes   = m.Groups[2].Value;
                return($"<span style=\"color: {color};\">{mes}</span>");
            });
            // フォローできなかったノイズを消す
            message = removeTagReg.Replace(message, "");

            Message = new MarkupString(Markdown.ToHtml(message));
        }
Ejemplo n.º 6
0
        /// <inheritdoc/>
        protected override void OnParametersSet()
        {
            base.OnParametersSet();
            var markdown = File.ReadAllText(FilePath);

            _markupString = new MarkupString(Markdig.Markdown.ToHtml(markdown, Pipeline));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Convert string into a HTML markup to show correctly in the page
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public static MarkupString ToHtml(this string content)
        {
            string       addBr  = content.Replace(Environment.NewLine, "<br/>").Replace("\n\r", "<br/>");
            MarkupString result = new MarkupString(addBr);

            return(result);
        }
Ejemplo n.º 8
0
        protected override void OnParametersSet()
        {
            _componentType = Column.ComponentType;
            if (_componentType != null)
            {
                _cellRender = CreateComponent(_sequence, GridComponent, _componentType, Column, Item, RowId);
            }
            else
            {
                _cell = (MarkupString)Column.GetCell(Item).ToString();
            }
            if (Column.Hidden)
            {
                _cssStyles = ((GridStyledColumn)Column).GetCssStylesString() + " " + TdStyle;
            }
            else
            {
                _cssStyles = ((GridStyledColumn)Column).GetCssStylesString();
            }
            _cssClass = ((GridStyledColumn)Column).GetCssClassesString() + " " + TdClass;

            if (!string.IsNullOrWhiteSpace(Column.Width))
            {
                _cssStyles = string.Concat(_cssStyles, " width:", Column.Width, ";").Trim();
            }

            string columnCssClasses = Column.GetCellCssClasses(Item);

            if (!string.IsNullOrWhiteSpace(columnCssClasses))
            {
                _cssClass += " " + columnCssClasses;
            }
        }
Ejemplo n.º 9
0
        async Task HandleFileSelected(InputFileChangeEventArgs e)
        {
            using var content = new MultipartFormDataContent();
            foreach (var file in e.GetMultipleFiles(e.FileCount))
            {
                content.Add(new StreamContent(file.OpenReadStream()), "files", file.Name);
            }

            var httpClient = _httpClientFactory.CreateClient("oidc");

            using var response = await httpClient.PostAsync($"{httpClient.BaseAddress}/import", content).ConfigureAwait(false);

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (!response.IsSuccessStatusCode)
            {
                _error = new MarkupString($"{response.StatusCode}<br/>{responseContent.Replace("\n","<br/>")}");
            }
            else
            {
                _result = JsonSerializer.Deserialize <ImportResult>(responseContent, new JsonSerializerOptions
                {
                    PropertyNamingPolicy = JsonNamingPolicy.CamelCase
                });
            }

            await InvokeAsync(StateHasChanged).ConfigureAwait(false);
        }
        protected async override Task OnInitializedAsync()
        {
            var use = (await _authenticationStateProvider.GetAuthenticationStateAsync());

            StringBuilder sb = new StringBuilder();

            sb.AppendLine(use.User.Identity.Name);
            sb.Append("<br />");

            sb.AppendLine(" <ul> ");
            foreach (var item in use.User.Claims)
            {
                sb.Append(" <li> ");
                sb.Append(" <ol> ");
                sb.Append(" <li> ");
                sb.AppendLine(item.Type);
                sb.Append(" </li> ");
                sb.Append(" <li> ");
                sb.AppendLine(item.Value);
                sb.Append(" </li> ");
                sb.Append(" </ol> ");
                sb.Append(" </li> ");
            }
            sb.AppendLine(" </ul> ");
            sb.Append("<br /> Jest Adminiem");
            sb.AppendLine(use.User.IsInRole("Admin").ToString());
            sb.Append("<br /> Ma MyValue");
            sb.AppendLine(use.User.Claims.Any(p => p.Value == "MyValue").ToString());
            sb.Append("<br /> Ma Cos");
            sb.AppendLine(use.User.Claims.Any(p => p.Type == "MyCos").ToString());


            Data = new MarkupString(sb.ToString());
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a new BlogPostEntity.
 /// </summary>
 /// <param name="author">The author of the post, saved in RowKey (REVERSETICKS_AUTHOROID_TITLE).</param>
 /// <param name="title">The title of the post, saved in the RowKey (REVERSETICKS_AUTHOROID_TITLE).</param>
 /// <param name="text">The text of the post.</param>
 public BlogPostEntity(ClaimsPrincipal author, string title, MarkupString content)
 {
     PartitionKey = $"{9999 - DateTime.UtcNow.Year}{99 - DateTime.UtcNow.Month}";
     SetRowKey(author.FindFirst("oid").Value, title);
     Author = author.Identity.Name;
     Text   = content.Value;
 }
Ejemplo n.º 12
0
 protected override async Task OnInitializedAsync()
 {
     if (!string.IsNullOrWhiteSpace(Source))
     {
         Markup = AddClass(await SvgLoader.LoadSvg(Source));
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// A default <see cref="NotificationEventArgs"/> constructor.
 /// </summary>
 /// <param name="notificationType">Type of the notification to show.</param>
 /// <param name="message">Notification content.</param>
 /// <param name="title">Title of the notification.</param>
 /// <param name="options">Additional options to override default notification settings.</param>
 public NotificationEventArgs(NotificationType notificationType, MarkupString message, string title, NotificationOptions options)
 {
     NotificationType = notificationType;
     Message          = message;
     Title            = title;
     Options          = options;
 }
Ejemplo n.º 14
0
        public void LoadCards()
        {
            //var test = LoadFile("BackRed");
            //test = LoadFile("BackBlack");

            BackRed   = (MarkupString)$"<object class='playing-card' type='image/svg+xml' data='images/cards/BackRed.svg'></object>";
            BackBlack = (MarkupString)$"<object class='playing-card' type='image/svg+xml' data='images/cards/BackBlack.svg'></object>";

            var deck = new StandardDeck();
            int i    = 0;

            Faces        = new MarkupString[deck.Suits * deck.Ranks];
            FacesAsImage = new MarkupString[deck.Suits * deck.Ranks];
            foreach (var suit in deck.SuitDescriptions)
            {
                foreach (var rank in deck.RankDescriptions)
                {
                    //test = LoadFile($"{rank}{suit}");

                    // Embeded SVG too large, sends cards too often
                    //Faces[i++] = LoadFile($"{rank}{suit}");

                    // Send the SVG as an object so it can be cached
                    Faces[i] = (MarkupString)$"<object class='playing-card' type='image/svg+xml' data='images/cards/{rank}{suit}.svg'></object>";

                    // Send the SVG as an image so it can be cached (Note: sending as an image works, but does not rotate and scale like an SVG should
                    FacesAsImage[i] = (MarkupString)$"<img class='playing-card' src='images/cards/{rank}{suit}.svg'>";
                    i++;
                }
            }
        }
Ejemplo n.º 15
0
        protected override void OnParametersSet()
        {
            _componentType = ((GridColumnBase <T>)Column).ComponentType;
            if (_componentType != null)
            {
                _cellRender = CreateCellComponent();
            }
            else
            {
                _cell = (MarkupString)Column.GetCell(Item).ToString();
            }
            if (((GridColumnBase <T>)Column).Hidden)
            {
                _cssStyles = ((GridStyledColumn)Column).GetCssStylesString() + " " + TdStyle;
            }
            else
            {
                _cssStyles = ((GridStyledColumn)Column).GetCssStylesString();
            }
            _cssClass = ((GridStyledColumn)Column).GetCssClassesString() + " " + TdClass;
            string columnCssClasses = Column.GetCellCssClasses(Item);

            if (!string.IsNullOrWhiteSpace(columnCssClasses))
            {
                _cssClass += " " + columnCssClasses;
            }
        }
Ejemplo n.º 16
0
        public IActionResult OnGet([FromRoute] string blogName)
        {
            var url = $"/post/{blogName}";

            var blogExcerptModel = _blogContext.BlogExcerptModel.FirstOrDefault(temp => temp.Url == url);


            if (blogExcerptModel is null)
            {
                ViewData["title"] = _configuration["Title"];
                // lang=html
                HtmlContent = new MarkupString(@"<h3>找不到这篇博客</h3>");
            }
            else
            {
                ViewData["title"]     = blogExcerptModel.Title;
                ViewData["BlogTitle"] = blogExcerptModel.Title;

                var file = _blogManager.GetBlog(blogExcerptModel.FileName);

                var str = System.IO.File.ReadAllText(file);

                str = ParseBlog(str);

                var html = Markdig.Markdown.ToHtml(str);

                HtmlContent = new MarkupString(html);
            }


            return(Page());
        }
Ejemplo n.º 17
0
        private async void GetData()
        {
            var text = await JsRuntime.InvokeAsync <string>("getInnerHtml");

            ConvertedText = new MarkupString(text);
            StateHasChanged();
        }
Ejemplo n.º 18
0
 public SnackbarInfo(MarkupString message,
                     string title,
                     SnackbarColor color,
                     string key,
                     RenderFragment messageTemplate,
                     bool showCloseButton,
                     string closeButtonText,
                     object closeButtonIcon,
                     bool showActionButton,
                     string actionButtonText,
                     object actionButtonIcon,
                     double?intervalBeforeClose)
 {
     Message             = message;
     Title               = title;
     Color               = color;
     Key                 = key ?? Guid.NewGuid().ToString();
     MessageTemplate     = messageTemplate;
     ShowCloseButton     = showCloseButton;
     CloseButtonText     = closeButtonText;
     CloseButtonIcon     = closeButtonIcon;
     ShowActionButton    = showActionButton;
     ActionButtonText    = actionButtonText;
     ActionButtonIcon    = actionButtonIcon;
     IntervalBeforeClose = intervalBeforeClose;
 }
        /// <summary>
        /// Adds a tooltip to the anchor.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="content"></param>
        private void AddTooltipMarkupString(Guid id, MarkupString content)
        {
            InvokeAsync(async() =>
            {
                await semaphore.WaitAsync();

                try
                {
                    var instance = new TooltipInstance
                    {
                        Id                  = id,
                        TimeStamp           = DateTime.Now,
                        MarkupStringContent = content,
                        Initiated           = false
                    };

                    Tooltips.TryAdd(id, instance);
                }
                finally
                {
                    semaphore.Release();
                }

                StateHasChanged();
            });
        }
Ejemplo n.º 20
0
        private Content(MarkupString s)
        {
            Fragment = builder => builder.AddContent(0, s);

            #if DEBUG
            SourceValue = s;
            #endif
        }
Ejemplo n.º 21
0
        public async Task <string> FileToMarkdownAsync(string path)
        {
            string text = await DownloadTextFileAsync(path);

            var markup = new MarkupString(text);

            return(markup.Value);
        }
Ejemplo n.º 22
0
 public async Task ShowDialogAsync(string message)
 {
     ConfirmationMessage = new(message);
     CancelRequired      = false;
     NeedsConfirmation   = true;
     RaiseChange();
     await WaitForFinish();
 }
Ejemplo n.º 23
0
        async Task IEventHandler <PwaUpdateable> .HandleAsync(PwaUpdateable payload)
        {
            IsUpdateable = true;

            ReleaseNotes = new MarkupString(await http.GetStringAsync("/release-notes.html"));

            StateHasChanged();
        }
Ejemplo n.º 24
0
        private void ToggleSnackbar(SnackbarColor color, string message)
        {
            this.color   = color;
            this.message = (MarkupString)message;

            snackbar.Show();
            StateHasChanged();
        }
Ejemplo n.º 25
0
 /// <summary>
 /// A default <see cref="MessageEventArgs"/> constructor.
 /// </summary>
 /// <param name="messageType">Type of the message to show.</param>
 /// <param name="message">Message content.</param>
 /// <param name="title">Title of the message.</param>
 /// <param name="options">Additional options to override default message settings.</param>
 /// <param name="callback">Callback that will execute once the user responds with an action.</param>
 public MessageEventArgs(MessageType messageType, MarkupString message, string title, MessageOptions options, TaskCompletionSource <bool> callback)
 {
     MessageType = messageType;
     Message     = message;
     Title       = title;
     Options     = options;
     Callback    = callback;
 }
Ejemplo n.º 26
0
        public Task RaiseMessage(MessageType messageType, MarkupString message, string title = null, Action <MessageOptions> options = null)
        {
            var messageOptions = MessageOptions.Default;

            options?.Invoke(messageOptions);

            MessageReceived?.Invoke(this, new(messageType, message, title, messageOptions) );

            return(Task.CompletedTask);
        }
Ejemplo n.º 27
0
        protected override async Task OnInitAsync()
        {
            var downloader     = new FileDownloader();
            var pathToBlogPost = string.Format(BlogPostRelativeLinkTemplate, PostUrl);
            var response       = await downloader.DownloadFileFromSiteContentAsync(HttpClient, Config, pathToBlogPost, "text/x-markdown");

            BlogPostHtml = new MarkupString(response);

            await base.OnInitAsync();
        }
Ejemplo n.º 28
0
        public async Task <bool> ShowConfirmAsync(string message)
        {
            ConfirmationMessage = new(message);
            CancelRequired      = true;
            NeedsConfirmation   = true;
            RaiseChange();
            await WaitForFinish();

            return(DialogResponse);
        }
Ejemplo n.º 29
0
        public Task RaiseMessage(NotificationType notificationType, MarkupString message, string title = null, Action <NotificationOptions> options = null)
        {
            var notificationOptions = NotificationOptions.Default;

            options?.Invoke(notificationOptions);

            NotificationReceived?.Invoke(this, new(notificationType, message, title, notificationOptions) );

            return(Task.CompletedTask);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// OnInitialized 方法
        /// </summary>
        protected override void OnInitialized()
        {
            base.OnInitialized();

            Title ??= Localizer[nameof(Title)];
            SubTitle ??= Localizer[nameof(SubTitle)];
            BaseUsageText ??= Localizer[nameof(BaseUsageText)];
            IntroText1 ??= Localizer[nameof(IntroText1)];
            IntroText2   = new MarkupString(Localizer[nameof(IntroText2)] ?? "");
            ContentText1 = new MarkupString(Localizer[nameof(ContentText1)] ?? "");
        }