public static Func <Request, Response, Task> UpdateMeta(SQLiteAsyncConnection db) { return(async(req, res) => { var updatedArticle = await req.ParseBodyAsync <Article>(); if (await db.FindAsync <Article>( arti => arti.Slug == updatedArticle.Slug && arti.Id != updatedArticle.Id) != null) { const string msg = "Another article with the same slug already exists"; await res.SendString(msg, status : HttpStatusCode.BadRequest); return; } var existingArticle = await db.FindAsync <Article>(arti => arti.Id == updatedArticle.Id); if (existingArticle == null) { const string msg = "Could not find an existing article with the specified id"; await res.SendString(msg, status : HttpStatusCode.BadRequest); return; } TextFormatting.CopyMeta(existingArticle, updatedArticle); await db.UpdateAsync(existingArticle); await res.SendStatus(HttpStatusCode.OK); }); }
private float AddQuestion(string question, float height, int i) { Vector3 screenPosition = Camera.main.WorldToScreenPoint(transform.position); var rect = new Rect(screenPosition.x - 2, Screen.height - screenPosition.y + height, dotStyle.fixedWidth, dotStyle.fixedHeight); dotPositions.Add(rect); int scaledWidth = Scale(AnswerWidth); GUIStyle style = new GUIStyle(); style.richText = true; style.wordWrap = true; style.fontSize = scaledNormalFontSize; style.fixedWidth = scaledWidth; style.fontStyle = FontStyle.Bold; var content = new GUIContent(TextFormatting.ProcessTags("<color=" + Initialize.QuestionsFontColor + ">" + question + "</color>", scaledSmallFontSize)); float scaledHeight = style.CalcHeight(content, scaledWidth); rect = new Rect(screenPosition.x - 2 + Scale(25), Screen.height - screenPosition.y + height, scaledWidth, scaledHeight); GUI.Label(rect, content, style); answerPositions.Add(rect); answerContents.Add(content); answerStyles.Add(style); height += rect.height + Scale(9); return(height); }
public FormattedNode(string source, string token, TextFormatting formatting, IReadOnlyList <Node> children) : base(source) { Token = token; Formatting = formatting; Children = children; }
void ISimpleVisualizationActor.StopAndSetOrClearPrimaryTime(TimeSpan?time) { StopTimers(); primaryTimeMillisecondsMeasured = TextFormatting.FormatMilliseconds(time); UpdatePrimaryTime(time, true); }
void IVisualizationActor.SetOrClearNextCompetitor(Competitor?competitor) { nextCompetitorNumberLabel.Text = competitor != null?TextFormatting.FormatCompetitorNumber(competitor.Number) : string.Empty; nextHandlerNameLabel.Text = competitor?.HandlerName ?? string.Empty; nextDogNameLabel.Text = competitor?.DogName ?? string.Empty; }
void IVisualizationActor.SetOrClearPreviousCompetitorRun(CompetitionRunResult?competitorRunResult) { if (competitorRunResult != null) { prevCompetitorNumberLabel.Text = TextFormatting.FormatCompetitorNumber(competitorRunResult.Competitor.Number); prevHandlerNameLabel.Text = competitorRunResult.Competitor.HandlerName; prevDogNameLabel.Text = competitorRunResult.Competitor.DogName; prevTimeLabel.Text = TextFormatting.FormatTime(competitorRunResult.Timings?.FinishTime?.ElapsedSince(competitorRunResult.Timings.StartTime).TimeValue); prevFaultsValueLabel.Text = TextFormatting.FormatNumber(competitorRunResult.FaultCount, 2); prevRefusalsValueLabel.Text = TextFormatting.FormatNumber(competitorRunResult.RefusalCount, 2); Color foreColor = competitorRunResult.IsEliminated ? RunHistoryLine.EliminationColor : SystemColors.ControlText; prevTimeLabel.ForeColor = foreColor; prevPlacementLabel.ForeColor = foreColor; prevPlacementLabel.Text = competitorRunResult.IsEliminated ? "X" : TextFormatting.FormatPlacement(competitorRunResult.Placement); } else { prevCompetitorNumberLabel.Text = string.Empty; prevHandlerNameLabel.Text = string.Empty; prevDogNameLabel.Text = string.Empty; prevTimeLabel.Text = string.Empty; prevFaultsValueLabel.Text = string.Empty; prevRefusalsValueLabel.Text = string.Empty; prevPlacementLabel.Text = string.Empty; } }
public NameInput(Scene scene, string name, string text, Vector2 position, int width, string oldString) { Scene = scene; OldString = oldString; NewString = oldString; Position = position; Width = width; MenuAreaBasic = new MenuAreaBasic(this, () => Position, 10); SpriteReference textbox = SpriteLoader.Instance.AddSprite("content/ui_box"); var formatting = new TextFormatting() { Bold = false, }; var dialogInstant = new DialogFormattingInstant(); UI = new LabelledUI(textbox, textbox, textBuilder => { textBuilder.AppendText(name, formatting, dialogInstant); }, () => new Point(Width, Height)); Text = new TextBuilder(Width - 16 - 16, Height); Text.StartLine(LineAlignment.Left); Text.AppendText(text, formatting, dialogInstant); Text.EndLine(); Text.StartLine(LineAlignment.Left); //TODO: Text Input Text.EndLine(); Text.EndContainer(); Text.Finish(); }
void ISimpleVisualizationActor.SetElimination(bool isEliminated) { bool isSecondaryTimeVisible = secondaryTime is { IsVisible : true }; // @formatter:keep_existing_linebreaks true primaryTimeMillisecondsLabel.Text = isEliminated ? EliminationText : isSecondaryTimeVisible ? TextFormatting.FormatMilliseconds(secondaryTime !.Value.TimeValue) : primaryTimeStartedAt != null ? MillisecDashes : primaryTimeMillisecondsMeasured; // @formatter:keep_existing_linebreaks restore } void ISimpleVisualizationActor.SetOrClearCurrentCompetitorNumber(int?number) { currentCompetitorNumberLabel.Text = TextFormatting.FormatNumber(number, 3); } void ISimpleVisualizationActor.SetOrClearNextCompetitorNumber(int?number) { nextCompetitorNumberLabel.Text = TextFormatting.FormatNumber(number, 3); } void ISimpleVisualizationActor.SetOrClearPreviousCompetitorPlacement(int?placement) { previousCompetitorPlacementLabel.Text = TextFormatting.FormatNumber(placement, 3); }
/// <summary> /// Преобразовать строку в информацию о пользователе /// </summary> public static PersonInformation GetFromFullName(string fullName) => fullName?.Split(). Map(splat => new PersonInformation(TextFormatting.RemoveSpacesAndArtefacts(splat[0]), TextFormatting.RemoveSpacesAndArtefacts(splat.GetStringFromArrayOrEmpty(1)), TextFormatting.RemoveSpacesAndArtefacts(splat.GetStringFromArrayOrEmpty(2)), TextFormatting.RemoveSpacesAndArtefacts(splat.JoinStringArrayFromIndexToEndOrEmpty(3)). Map(ConverterDepartmentType.DepartmentStringToTypeOrUnknown))) ?? new PersonInformation();
private void DisplayRefreshTimer_Tick(object?sender, EventArgs e) { if (startTime != null) { TimeSpan timePassed = SystemContext.UtcNow() - startTime.Value; primaryTimeLabel.Text = TextFormatting.FormatTime(timePassed); } }
private void UpdatePrimaryTime(TimeSpan?primaryTime, bool showMilliseconds) { primaryTimeSecondsLabel.Text = TextFormatting.FormatSeconds(primaryTime); if (!IsEliminated) { primaryTimeMillisecondsLabel.Text = showMilliseconds ? primaryTimeMillisecondsMeasured : MillisecDashes; } }
void IVisualizationActor.SetOrClearSecondaryTime(TimeSpan?time, bool doBlink) { secondaryTimeLabel.Text = time != null?TextFormatting.FormatTime(time) : string.Empty; secondaryTimeHighlighter.IsHighlightEnabled = doBlink && time != null; if (secondaryTimeHighlighter.IsHighlightEnabled) { secondaryTimeHighlightCount = 0; } }
private void DoTooltip() { ItemStack stack = GetSlotContents(); if (stack != null) { controller.SetTooltip(TextFormatting.ParseToUnity(i18n.Translate(stack.item.GetTooltip(stack)))); } else { controller.SetTooltip(""); } }
public static string FormatString(string input, TextFormatting textFormatting) { switch (textFormatting) { case TextFormatting.Bold: return(string.Format("'''{0}'''", input)); case TextFormatting.Italic: return(string.Format("''{0}''", input)); } return(input); }
//------------------------------------------------------------------------------------ protected override TextFormatting GetFormatting(Node node, TreeListColumn column) { CResultAErreur result = CResultAErreur.True; TextFormatting format = new TextFormatting(base.GetFormatting(node, column)); CLocalAlarmeAffichee alarme = node.Tag as CLocalAlarmeAffichee; if (alarme != null) { try { CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(alarme); C2iExpression exp = m_parametreAffichage.FormuleItemBackColor; if (exp != null) { result = exp.Eval(ctx); if (result) { Color couleurFond = (Color)result.Data; if (couleurFond != null) { format.BackColor = couleurFond; } } } exp = m_parametreAffichage.FormuleItemForeColor; if (exp != null) { result = exp.Eval(ctx); if (result) { Color couleurTexte = (Color)result.Data; if (couleurTexte != null) { format.ForeColor = couleurTexte; } } } CActionSur2iLink action = null; if (m_dicIndexColonneAction.TryGetValue(column.Index, out action)) { Font font = new Font(format.Font, FontStyle.Underline); format.Font = font; } } catch { } } return(format); }
public SyntaxFormat() { Undefined = new TextFormatting(Color.Red, true); Root = Text = new TextFormatting(Color.Black); EscapedCharacter = DefinedEscaped = new TextFormatting(Color.Orange); BackspaceEscaped = UnicodeCharacter = OctalCharacter = ControlCharacter = HexCharacter = new TextFormatting(Color.OrangeRed); NamedBackreference = Backreference = NegatedCharacterGroup = CharacterGroup = new TextFormatting(Color.Green); NegateCharacterGroup = new TextFormatting(Color.Pink); ExactQuantifier = AtLeastQuantifier = RangeQuantifier = AtLeastMinimumQuantifier = MinimumRangeQuantifier = new TextFormatting(Color.Purple); NegateCharacterGroup = Operator = new TextFormatting(Color.DodgerBlue); Group = NegativeLookahead = PositiveLookbehind = NegativeLookbehind = Greedy = NamedCapture = PositiveLookahead = NonCapturing = new TextFormatting(); Comment = new TextFormatting(Color.Green); Error = Invalid = InvalidQuantifier = new TextFormatting(Color.Red); }
public Expression(TextFormatting format = TextFormatting.None) { //BackgroundColor = Color.LightGreen; Orientation = StackOrientation.Horizontal; HorizontalOptions = LayoutOptions.Center; VerticalOptions = LayoutOptions.Center; Spacing = 0; TextFormat = format; ChildAdded += (sender, e) => ChildrenChanged?.Invoke(sender, e, true); ChildRemoved += (sender, e) => ChildrenChanged?.Invoke(sender, e, false); //ChildrenChanged += delegate { CheckPadding(); }; //CheckPadding(); }
void ISimpleVisualizationActor.SetOrClearSecondaryTime(TimeSpan?time) { if (time == null) { secondaryTime = null; } else { secondaryTime = new SecondaryTime(time.Value); primaryTimeSecondsLabel.Text = TextFormatting.FormatSeconds(secondaryTime.Value.TimeValue); if (!IsEliminated) { primaryTimeMillisecondsLabel.Text = TextFormatting.FormatMilliseconds(secondaryTime.Value.TimeValue); } } }
public void GenerateQuestions(QuestionData question) { Debug.Log("Image position: " + ImagePosition); scaledSmallFontSize = Scale(SmallFontSize); scaledNormalFontSize = Scale(NormalFontSize); currentQuestion = question; isEnabled = true; answerPositions.Clear(); answerContents.Clear(); answerStyles.Clear(); dotPositions.Clear(); Vector3 screenPosition = Camera.main.WorldToScreenPoint(transform.position); dotContent = new GUIContent(DotTexture); dotStyle = new GUIStyle(); dotStyle.fixedWidth = dotStyle.fixedHeight = Scale(20); questionStyle = new GUIStyle(); questionStyle.richText = true; questionStyle.wordWrap = true; questionStyle.fontSize = scaledNormalFontSize; //questionStyle.fontStyle = FontStyle.Bold; questionStyle.font = DefaultFont; string text = "<color=#503a28>" + question.Question + "</color>"; questionContent = new GUIContent(TextFormatting.ProcessTags(text, scaledSmallFontSize)); int scaledWidth = Scale(QuestionWidth); questionPosition = new Rect(screenPosition.x, Screen.height - screenPosition.y, scaledWidth, Scale(100)); float height = TextFormatting.CalculateHeight(questionContent, questionStyle, scaledWidth) + Scale(16); int i = 0; foreach (var answer in question.Answers) { height = AddQuestion(answer, height, i); ++i; } }
public ControlTag(Action <TextBuilder> text) { TextFormatting format = new TextFormatting() { Bold = false, GetParams = pos => new DialogParams() { Color = Color.Black, Border = Color.Transparent, Scale = Vector2.One, } }; Text = new TextBuilder(160, float.PositiveInfinity, defaultFormat: format); Text.StartLine(LineAlignment.Left); text(Text); Text.EndLine(); Text.EndContainer(); Text.Finish(); }
public StatMenu(Scene scene) { Scene = scene; Width = scene.Viewport.Width / 3; Height = scene.Viewport.Height / 2; Position = new Vector2(scene.Viewport.Width / 2, scene.Viewport.Height / 2); UI = new LabelledUI(SpriteLoader.Instance.AddSprite("content/ui_box"), SpriteLoader.Instance.AddSprite("content/ui_box"), null, () => new Point(Width, Height)); foreach (var file in GetRunScores()) { Tabs.Add(new RunTab(this, file, file.ReloadAsync())); } LeftTab = Tabs.First(); var formatName = new TextFormatting() { Bold = true, }; }
private void UpdateScores(bool showScoreAnimation = true) { CurrentPlayer = game.CurrentPlayer; Score[game.CurrentPlayer] = game.Scores[game.CurrentPlayer]; currentScoreText = TextFormatting.AddSpacingBetweenCharacters(string.Format(scoreFormat, Score[0], 1)); if (PlayersPlaying > 1) { currentScoreText2 = TextFormatting.AddSpacingBetweenCharacters(string.Format(scoreFormat, Score[1], 2)); } if (showScoreAnimation) { var scorePopup = GameObject.Find("Score"); if (scorePopup != null) { scorePopup.SendMessage("ShowScore"); } } }
public InfoBox(Scene scene, Action <TextBuilder> name, Action <TextBuilder> text, Vector2 position, int width, int height) { Scene = scene; Position = position; Width = width; Height = height; MenuAreaBasic = new MenuAreaBasic(this, () => Position, 10); SpriteReference textbox = SpriteLoader.Instance.AddSprite("content/ui_box"); var formatting = new TextFormatting() { Bold = false, }; var dialogInstant = new DialogFormattingInstant(); UI = new LabelledUI(textbox, textbox, name, () => new Point(Width, Height)); Text = new TextBuilder(Width, Height); text(Text); Text.EndContainer(); Text.Finish(); }
protected virtual void Update() { if (!player) { GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player) { this.player = player.transform; } } List <string> tip = new List <string>(); GetTooltip(tip); bool vis = IsTooltipVisible(); if (vis && tooltip) { tooltipText.transform.LookAt(Camera.main.transform); tooltipText.transform.Rotate(0F, 180F, 0F); tooltipText.text = (tip.Count > 0 ? TextFormatting.ParseToUnity(i18n.Translate(tip[0])) : ""); for (int i = 1; i < tip.Count; i++) { tooltipText.text += "\n" + TextFormatting.ParseToUnity(i18n.Translate(tip[i])); } //bgr.size = new Vector2(textRender.bounds.extents.x * 10, textRender.bounds.extents.y * 10); //bgr.transform.position = textRender.bounds.center; } else if (tooltip) { tooltipText.text = ""; //bgr.size = Vector2.zero; } }
private void ShowScore(GameObject obj, Transform offsetX, GUIStyle style, string score) { Vector3 rawPosition = obj.transform.position; rawPosition.x = offsetX.position.x; Vector3 start = Camera.main.WorldToScreenPoint(rawPosition); start.y = Screen.height - start.y; float minWidth, maxWidth; string text = TextFormatting.AddSpacingBetweenCharacters(score); GUIContent content = new GUIContent(text); style.CalcMinMaxWidth(content, out minWidth, out maxWidth); float height = style.CalcHeight(content, maxWidth); height /= 2.0f; float halfWidth = maxWidth / 2.0f; GUI.Label(new Rect(start.x - halfWidth - 3, start.y + 2 - height, maxWidth, 120), FontColorUtils.Shadow(text), style); GUI.Label(new Rect(start.x - halfWidth, start.y - height, maxWidth, 120), FontColorUtils.MainGameScore(text), style); }
/// <summary> /// Converts the evaluated expression value /// </summary> public override string ConvertExpressedValue(string value) { return(TextFormatting.Pluralize(value)); }
public FormattedNode(TextFormatting formatting, IReadOnlyList <Node> children) { Formatting = formatting; Children = children; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); try { bool bShowToolTip = false; Node nodeSurvole = CalcHitNode(e.Location); if (nodeSurvole != null && nodeSurvole != m_lastNodeForToolTip) { bShowToolTip = true; m_lastNodeForToolTip = nodeSurvole; } TreeListColumn colonneSurvolee = CalcColumnHit(e.Location).Column; if (colonneSurvolee != null && colonneSurvolee != m_lastColumnForToolTip) { bShowToolTip = true; m_lastColumnForToolTip = colonneSurvolee; // Gestion curseur souris if (m_dicIndexColonneAction.Keys.Contains(colonneSurvolee.Index)) { Cursor.Current = Cursors.Hand; } else { Cursor.Current = Cursors.Default; } } if (bShowToolTip) { object dataForToolTip = GetData(nodeSurvole, colonneSurvolee); if (dataForToolTip != null) { string texte = dataForToolTip.ToString(); if (texte.Trim() != "") { Graphics g = CreateGraphics(); TextFormatting format = GetFormatting(nodeSurvole, colonneSurvolee); SizeF dim = g.MeasureString(texte, format.Font); Rectangle rc = Util.AdjustRectangle(colonneSurvolee.CalculatedRect, format.Padding); int nOffset = 0; if (colonneSurvolee.Index == 0) { nOffset = GetIndentSize(nodeSurvole) + 16; } if ((int)dim.Width >= (rc.Width - nOffset)) { DelayShowTooltip(e.Location, texte); } else { HideTooltip(); } } else { HideTooltip(); } } else { HideTooltip(); } } } catch { HideTooltip(); } }
public void RemoveDiacriticsTest() { string uuml = "ü"; string u = TextFormatting.RemoveDiacritics(uuml, true); }
private static void Main() { try { var txtFilesPath = ConfigurationManager.AppSettings["txtFilesPath"]; var xmlFilesPath = ConfigurationManager.AppSettings["xmlFilesPath"]; var txtInputFilePath = $"{txtFilesPath}3Lines.txt"; var xmlOutputFilePath = $"{xmlFilesPath}1.xml"; IText text; var textParser = new TextParser(); using (var streamReader = new StreamReader(txtInputFilePath)) { // Replace tabs and spaces with one space during parsing. text = textParser.Parse(streamReader); } var textFormatting = new TextFormatting(); Console.WriteLine("<==================== Initial Text ====================>"); Console.WriteLine(text); // Print all sentences of text in increasing order of number of words in each of them. Console.WriteLine("<======================= Task1 ========================>"); #region Realization var sortedSentences = textFormatting.SortSentencesAscending <IWord>(text); foreach (var sentence in sortedSentences) { Console.WriteLine(sentence); } #endregion // In all interrogative sentences of text, find and print without repeating words of a given length. Console.WriteLine("<======================= Task2 ========================>"); #region Realization var wordLengthForSecondTask = 5; var wordsForSecondTask = textFormatting.GetWordsFromSentences(text, SentenceType.InterrogativeSentence, wordLengthForSecondTask); foreach (var word in wordsForSecondTask) { Console.WriteLine(word); } #endregion // Remove from text all words of a given length beginning with a consonant letter. Console.WriteLine("<======================= Task3 ========================>"); #region Realization var wordLengthForThirdTask = 5; text = textFormatting.DeleteWordsStartingWithConsonant(text, wordLengthForThirdTask); foreach (var sentence in text.Sentences) { Console.WriteLine(sentence); } #endregion // In some sentence of text, word of a given length replace with the specified substring. Console.WriteLine("<======================= Task4 ========================>"); #region Realization var sentenceNumberForFourthTask = 1; var wordLengthForFourthTask = 7; var substringForFourthTask = "peck. beak. peck,"; text = textFormatting.ReplacesWordsInSentenceWithSubstring(text, sentenceNumberForFourthTask, wordLengthForFourthTask, textParser.Parse(substringForFourthTask)); foreach (var sentence in text.Sentences) { Console.WriteLine(sentence); } #endregion //textFormatting.SaveToXmlFile(text, xmlOutputFilePath); //text = TextFormatting.ReadFromXmlFile(xmlOutputFilePath); } catch (ArgumentException argumentException) { Console.WriteLine(argumentException.Message); } catch (IOException ioException) { Console.WriteLine(ioException.Message); } catch (Exception exception) { Console.WriteLine(exception.Message); } finally { Console.ReadKey(); } }
void IVisualizationActor.StopAndSetOrClearPrimaryTime(TimeSpan?time) { StopPrimaryTimer(); primaryTimeLabel.Text = time != null?TextFormatting.FormatTime(time.Value) : string.Empty; }