/// <summary> /// Rule implementation. /// </summary> /// <param name="context">Rule context.</param> protected override void Execute(RuleContext context) { var value = (string)context.InputPropertyValues[PrimaryProperty]; if (MaxLinesProperty != null) { MaxLines = (int)context.InputPropertyValues[MaxLinesProperty]; } if (value != null) { string[] valueArray = value.Split(new string[1] { Environment.NewLine }, StringSplitOptions.None); if (!String.IsNullOrEmpty(value) && (valueArray != null) && (valueArray.Length > MaxLines)) { string message = String.Format(ResourcesValidation.StringMaxLines, PrimaryProperty.FriendlyName, MaxLines.ToString()); context.Results.Add(new RuleResult(RuleName, PrimaryProperty, message) { Severity = Severity }); } } }
protected override IEnumerator ProcessPayload(VisualPayload payload) { var label = VisualizerFactory.InstantiateLabelVisualizerPrefab(); label.Initialize(this, payload); var meshRenderer = label.TextComponent.GetComponent <MeshRenderer>(); var targetFont = FontFactory.GetFontPair(FontName.GetFirstValue(payload.Data)); var newMaterial = FontFactory.GenerateNewSpatialMaterial(targetFont.FontTexture); label.TextComponent.font = targetFont.Font; label.TextComponent.fontSize = Mathf.FloorToInt(FontSize.GetFirstValue(payload.Data) * targetFont.FontScale); label.transform.localPosition = new Vector3(0f, label.TextComponent.fontSize * targetFont.VerticalOffset, 0f); label.CharactersPerLine = CharactersPerLine.GetFirstValue(payload.Data); label.MaxLines = MaxLines.GetFirstValue(payload.Data); newMaterial.color = FontColor.GetFirstValue(payload.Data); meshRenderer.material = newMaterial; label.BackgroundPadding = BackgroundPadding.GetFirstValue(payload.Data); label.BackgroundDepth = BackgroundDepth.GetFirstValue(payload.Data); label.LateralJustification = Justification.GetFirstValue(payload.Data); label.VerticalJustification = VerticalJustification.GetFirstValue(payload.Data); label.MinHeight = MinHeight.GetFirstValue(payload.Data); label.MaxHeight = MaxHeight.GetFirstValue(payload.Data); label.Orientation = Orientation.GetFirstValue(payload.Data); label.SetClickState(ClickState); label.RemoveBackground = !ShowBackground.GetFirstValue(payload.Data); label.Text = LabelText.GetFirstValue(payload.Data); var newPayload = new VisualPayload(payload.Data, new VisualDescription(label.Bound)); var iterator = DefaultState.Transmit(newPayload); while (iterator.MoveNext()) { yield return(null); } }
private void MaxLinesMenuItem_Click(object sender, EventArgs e) { var prompt = new InputPrompt { StartLocation = this.ChildPointToScreen(TraceView), TextInputType = InputPrompt.InputType.Unsigned, Message = "Max lines to display in the window", InitialValue = MaxLines.ToString() }; var result = prompt.ShowHawkDialog(); if (result == DialogResult.OK) { var max = int.Parse(prompt.PromptText); if (max > 0) { MaxLines = max; } } }