protected FormattedString CreateFormatted(FormatParameters parameters) { var formattedString = new FormattedString(); foreach (var inline in parameters.ContainerInline) { var spans = CreateSpans(inline, parameters.Family, parameters.Attributes, parameters.ForegroundColor, parameters.BackgroundColor, parameters.Size, parameters.Theme); if (spans == null) { continue; } foreach (var span in spans) { formattedString.Spans.Add(span); } } return(formattedString); }
//event on button transfer parameters, transfer format parameters to the KUKA #region BackgroundWorker FormatParameters Transfer public void FormatParameterTransfer_Click() { try { // Nothing thats is related to the UI (WPF) thread should be given to the background worker thread without preparation // basically nothing that is part of the controls shouldn't be given to the background worker thread (otherwise Dispatcher is needed, and then UI thread is frozen) // Use a Dispatcher just for the fast communication between threads, because that way the UI(WPF) thread will not be frozen //Prepare String array out of UI objects, this is needed since the UI objects do not belong to the worker thread and cannot be accessed _formatValues_StringArray = new String[_formatVariables_ObservableCollection.Count]; for (int i = 0; i < _formatValues_StringArray.Length; i++) { _formatValues_StringArray[i] = _formatValues_ObservableCollection[i].Name.ToString(); } //Prepare Structure out of UI objects, this is needed since the UI objects do not belong to the worker thread _transferFormatParameters_struc = new FormatParameters(_formatVariables_ObservableCollection.Count, _transferReq_ObservableCollection[0].Name.ToString(), _pointer_ObservableCollection[0].Name.ToString(), _parValid_ObservableCollection[0].Name.ToString(), _parameterToSend_ObservableCollection[0].Name.ToString(), _formatValues_StringArray); //Start the worker if it is not already running if (!_transferParameters_Worker.IsBusy) { _transferParameters_Worker.RunWorkerAsync(); Status_FormatParameters_Tab = "Format parameters transfer started"; } } catch (Exception exc) { Exception_FormatParameters_Tab = exc.ToString(); } }
public override string Transform(string text) { var p = FormatParameters.Split(','); int off = int.Parse(p[0]); if (off < 0 || off > text.Length) { throw new ArgumentOutOfRangeException($"Out of range offset: {off} (0 - {text.Length})!"); } int len = -1; if (p.Length > 1) { len = int.Parse(p[1]); } if (len < 0) { len = text.Length - off; } if (off + len > text.Length) { throw new ArgumentOutOfRangeException($"Out of range length: {len} (0 - {text.Length - off})!"); } return(text.Substring(off, len)); }
public static void AddFormatParam(IRequestContext context, FormatParameters format) { if (format == null || string.IsNullOrWhiteSpace(format.Format)) { throw new ArgumentNullException(nameof(format)); } context.AddParametr("format", format.Format); if (format.SampleRateHertz.HasValue) { context.AddParametr("sampleRateHertz", format.SampleRateHertz.ToString()); } }
public View Render(HeadingBlock block, MarkdownTheme theme) { var style = GetHeadingStyle(block, theme); var formatParameters = new FormatParameters() { ContainerInline = block.Inline, Family = style.FontFamily, Attributes = style.Attributes, ForegroundColor = style.ForegroundColor, BackgroundColor = style.BackgroundColor, Size = style.FontSize, Theme = theme }; var label = new Label { FormattedText = CreateFormatted(formatParameters) }; if (style.BorderSize <= 0) { return(label); } AttachLinks(label); var headingStack = new StackLayout(); headingStack.Children.Add(label); headingStack.Children.Add(new BoxView { HeightRequest = style.BorderSize, BackgroundColor = style.BorderColor, }); return(headingStack); }
public View Render(ParagraphBlock block, MarkdownTheme theme) { var style = theme.Paragraph; var formatParameters = new FormatParameters() { ContainerInline = block.Inline, Family = style.FontFamily, Attributes = style.Attributes, ForegroundColor = style.ForegroundColor, BackgroundColor = style.BackgroundColor, Size = style.FontSize, Theme = theme }; var label = new Label { FormattedText = CreateFormatted(formatParameters) }; AttachLinks(label); return(label); }
public async Task <YandexTtsResponse> InvokeAsync(string text, bool ssml, VoiceParameters voice, FormatParameters format, CancellationToken cancellationToken = default) { if (string.IsNullOrWhiteSpace(text)) { throw new ArgumentNullException(nameof(text)); } if (voice == null) { throw new ArgumentNullException(nameof(voice)); } if (format == null) { throw new ArgumentNullException(nameof(format)); } var options = new InvokeOptions() { AudioFormat = format, Voice = voice, SSML = ssml, Text = text }; return(await InvokeAsync(options, cancellationToken)); }
public async Task <YandexTtsResponse> MarkupToSpeechAsync(string text, VoiceParameters voice, FormatParameters format, CancellationToken cancellationToken = default) => await InvokeAsync(text, true, voice, format, cancellationToken);
Request ModifyCsrfTokenInRequest(Request Req) { if (Req.Query.Has(TokenName)) { if (RemoveParameter) { Req.Query.Remove(TokenName); } else { Req.Query.Set(TokenName, TokenReplacementValue); } } if (Req.HasBody) { if (Req.IsNormal) { if (Req.Body.Has(TokenName)) { if (RemoveParameter) { Req.Body.Remove(TokenName); } else { Req.Body.Set(TokenName, TokenReplacementValue); } } } else { FormatParameters Params = null; if (Req.IsXml) { Params = FormatPlugin.GetXmlParameters(Req); } else if (Req.IsSoap) { Params = FormatPlugin.GetSoapParameters(Req); } else if (Req.IsJson) { Params = FormatPlugin.GetJsonParameters(Req); } else if (Req.IsMultiPart) { Params = FormatPlugin.GetMultipartParameters(Req); } if (Params != null) { for (int i = 0; i < Params.Count; i++) { if (Params.GetName(i).Contains(TokenName)) { string[] Parts = Params.GetName(i).Split(new char[] { '>' }, StringSplitOptions.RemoveEmptyEntries); if (Parts.Length > 0) { if (Parts[Parts.Length - 1].Trim().Equals(TokenName)) { if (RemoveParameter) { TokenReplacementValue = ""; } if (Req.IsXml || Req.IsSoap || Req.IsJson || Req.IsMultiPart) { FormatPlugin.Get(Req.BodyType).InjectInRequest(Req, i, TokenReplacementValue); } } } break; } } } } } return(Req); }
void FindCandidatesFromDB(object FilterDictObj) { try { Dictionary <string, List <string> > FilterInfo = (Dictionary <string, List <string> >)FilterDictObj; string CsrfParameterName = FilterInfo["TokenName"][0]; List <LogRow> MatchingRecords = IronDB.GetRecordsFromProxyLogMatchingFilters(FilterInfo["Hosts"], FilterInfo["File"], CsrfParameterName); List <LogRow> RecordsWithToken = new List <LogRow>(); foreach (LogRow LR in MatchingRecords) { Request Req = Request.FromProxyLog(LR.ID); if (Req.Query.Has(CsrfParameterName)) { RecordsWithToken.Add(LR); } else if (Req.HasBody) { if (Req.IsNormal) { if (Req.Body.Has(CsrfParameterName)) { RecordsWithToken.Add(LR); } } else { FormatParameters Params = null; if (Req.IsXml) { Params = FormatPlugin.GetXmlParameters(Req); } else if (Req.IsSoap) { Params = FormatPlugin.GetSoapParameters(Req); } else if (Req.IsJson) { Params = FormatPlugin.GetJsonParameters(Req); } else if (Req.IsMultiPart) { Params = FormatPlugin.GetMultipartParameters(Req); } if (Params != null) { for (int i = 0; i < Params.Count; i++) { if (Params.GetName(i).Contains(CsrfParameterName)) { string[] Parts = Params.GetName(i).Split(new char[] { '>' }, StringSplitOptions.RemoveEmptyEntries); if (Parts.Length > 0) { if (Parts[Parts.Length - 1].Trim().Equals(TokenName)) { RecordsWithToken.Add(LR); break; } } } } } } } } //Show these records on the page ShowMatchingRecordValues(RecordsWithToken); } catch (ThreadAbortException) { } catch (Exception Exp) { MessageBox.Show(string.Format("Error finding candidates - {0}", Exp.Message)); } }
public IWorkshopTree Parse(ActionSet actionSet) => _shouldParse?StringParseInfo.Parse(actionSet, FormatParameters.Select(fp => fp.Parse(actionSet)).ToArray()) : null;