/// <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 }); } } }
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; } } }