public override void Return <TReturnException>(object key, string messageFormat, object context = null) { if ((RangeStart.IsLowerOrEqualThan(Validatable) && Validatable.IsLowerOrEqualThan(RangeEnd)) == false) { ReturnResult <TReturnException>(key, messageFormat, context, new object[] { key, RangeStart, RangeEnd }); } }
private ILineReader WriteSql(ILineReader reader, RangeStart info) { if (info.Searcher.IsComment && _context.StripComments) { return(WriteSql(reader, info.Index, info.Searcher.StartCodeLength)); } return(WriteSql(reader, info.Index + info.Searcher.StartCodeLength)); }
public void Save(XmlTextWriter writer) { writer.WriteElementString("firstRoundSeconds", FirstRoundSeconds.ToString()); writer.WriteElementString("roundSeconds", RoundSeconds.ToString()); writer.WriteElementString("showNumericFeedback", ShowNumericFeedback.ToString()); writer.WriteElementString("usePreviousRoundInput", UsePreviousRoundInput.ToString()); writer.WriteElementString("rangeStart", RangeStart.ToString()); writer.WriteElementString("rangeEnd", RangeEnd.ToString()); }
/// <summary> /// Handle the case where a new range start sequence was found /// </summary> /// <param name="reader">The reader where the sequence was found</param> /// <param name="info">Information about the start sequence</param> /// <returns>A new search status</returns> private SearchStatus UseNewRange(ILineReader reader, RangeStart info) { var nextReader = WriteSql(reader, info); if (nextReader == null) { throw new InvalidOperationException($"Missing end of range ({info.Searcher.GetType().Name})"); } _activeRanges.Push(info.Searcher); return(new SearchStatus(_context, nextReader, _activeRanges, null)); }
protected override void SaveFields(XmlTextWriter output) { base.SaveFields(output); output.WriteAttributeString("required", Required ? "true" : "false"); output.WriteAttributeString("datatype", DataType.ToString()); output.WriteAttributeString("stringlength", StringLength.ToString(CultureInfo.CurrentCulture)); output.WriteAttributeString("regularexpression", RegularExpression); output.WriteAttributeString("rangestart", RangeStart.ToString(CultureInfo.CurrentCulture)); output.WriteAttributeString("rangeend", RangeEnd.ToString(CultureInfo.CurrentCulture)); }
public override int GetHashCode() { unchecked { int hashCode = (VariableName != null ? VariableName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (IterableExpression != null ? IterableExpression.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RangeStart != null ? RangeStart.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RangeEnd != null ? RangeEnd.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Body != null ? Body.GetHashCode() : 0); return(hashCode); } }
public RangeBox() { InitializeComponent(); this.Loaded += (sender, e) => { if (RangeStart == null || RangeEnd == null || RangeStart.GetType() != RangeEnd.GetType()) { throw new ArgumentException("设定的RangeStart/RangeEnd参数不正确!"); } SetStyle(RangeStart); SetStyle(RangeEnd); }; this.FlowLeave += RangeBox_FlowLeave; }
public void TestDouble(double minValue, double maxValue, double rangeStart, double rangeEnd) { var calculator = _host.Services.GetRequiredService <IRangeCalculator>(); calculator.Evaluate(minValue, maxValue); calculator.Alternatives.Should().NotBeEmpty(); var bestFit = calculator.Alternatives.BestByInactiveRegions(); bestFit.Should().NotBeNull(); bestFit !.RangeStart.Should().Be(rangeStart); bestFit !.RangeEnd.Should().Be(rangeEnd); }
/// <summary> /// Search for the start of a range /// </summary> /// <param name="reader">The reader where the range start token should be searched in</param> /// <param name="searchers">The collection of searchers to test</param> /// <returns><c>null</c> when no range could be found</returns> private static RangeStart FindRangeStart(ILineReader reader, IEnumerable <IRangeSearcher> searchers) { RangeStart result = null; foreach (var searcher in searchers) { var index = searcher.FindStartCode(reader); if (index != -1 && (result == null || result.Index > index)) { result = new RangeStart(searcher, index); } } return(result); }
public void TestMonth(string minValue, string maxValue, string rangeStart, string rangeEnd) { var calculator = _host.Services.GetRequiredService <IRangeCalculator>(); calculator.Evaluate(DateTime.Parse(minValue), DateTime.Parse(maxValue)); calculator.Alternatives.Should().NotBeEmpty(); var bestFit = calculator.Alternatives.BestByInactiveRegions(); bestFit.Should().NotBeNull(); bestFit !.RangeStart.Should().Be(MonthNumber.GetMonthNumber(rangeStart)); bestFit !.RangeEnd.Should().Be(MonthNumber.GetMonthNumber(rangeEnd)); }
private void UpdateHistogramDisplay() { if (_histogramRawCache != null && _histogramDisplayCache != null) { var graphics2D = _histogramDisplayCache.NewGraphics2D(); graphics2D.Clear(Color.Transparent); _histogramDisplayCache.CopyFrom(_histogramRawCache); var rangeStart = RangeStart.Value(this); var rangeEnd = RangeEnd.Value(this); graphics2D.FillRectangle(0, 0, rangeStart * _histogramDisplayCache.Width, _histogramDisplayCache.Height, new Color(Color.Red, 100)); graphics2D.FillRectangle(rangeEnd * _histogramDisplayCache.Width, 0, 255, _histogramDisplayCache.Height, new Color(Color.Red, 100)); graphics2D.Line(rangeStart * _histogramDisplayCache.Width, 0, rangeStart * _histogramDisplayCache.Width, _histogramDisplayCache.Height, new Color(Color.LightGray, 200)); graphics2D.Line(rangeEnd * _histogramDisplayCache.Width, 0, rangeEnd * _histogramDisplayCache.Width, _histogramDisplayCache.Height, new Color(Color.LightGray, 200)); } }
/// <summary> /// Calculates the variable type of a numeric range iteration. /// </summary> private void detectRangeType(Context ctx) { var t1 = RangeStart.Resolve(ctx); var t2 = RangeEnd.Resolve(ctx); if (t1 != t2) { error(CompilerMessages.ForeachRangeTypeMismatch, t1, t2); } if (!t1.IsIntegerType()) { error(CompilerMessages.ForeachRangeNotInteger, t1); } _VariableType = t1; }
public void DateTimeRangeOfTickSizes(RangeOfDates info) { _rangers.GetRange <DateTime, MonthRange>(info.ControlSize, info.Minimum, info.Maximum, out var result, info) .Should() .BeTrue(); result.Should().NotBeNull(); result !.RangeStart.Should().Be(info.RangeStart); result.RangeEnd.Should().Be(info.RangeEnd); result.MinorValue.Should().Be(info.MinorTick); result.MajorValue.Should().Be(info.MajorTick); }
public IDictionary <string, string> GetArguments() { var arguments = new Dictionary <string, string>(); arguments["first-round-seconds"] = FirstRoundSeconds.ToString(); arguments["round-seconds"] = RoundSeconds.ToString(); arguments["range-start"] = RangeStart.ToString(); arguments["range-end"] = RangeEnd.ToString(); if (ShowNumericFeedback) { arguments["numeric-feedback"] = string.Empty; } if (UsePreviousRoundInput) { arguments["previous-input"] = string.Empty; } return(arguments); }
public void RangeOfTickSizes(RangeOfDates info) { var ranger = new MonthlyTickRange(); ranger.Configure(info); ranger.GetRange(info.ControlSize, info.Minimum, info.Maximum, out var result) .Should() .BeTrue(); result.Should().NotBeNull(); result !.RangeStart.Should().Be(info.RangeStart); result.RangeEnd.Should().Be(info.RangeEnd); result.MinorValue.Should().Be(info.MinorTick); result.MajorValue.Should().Be(info.MajorTick); }
public void RectifyRange() { string startSub = RangeStart.Replace(BaseValue, ""); string endSub = RangeEnd.Replace(BaseValue, ""); if (startSub == "" || endSub == "") //In the cases where one end IS the base value (eg 5.10-5.11) { return; } else if (startSub == "-" && endSub == "+") { return; } else if (endSub == "-" && startSub == "+") { RangeStart = BaseValue + "-"; RangeEnd = BaseValue + "+"; } else if (endSub[0] < startSub[0]) //Compare letters by char value { RangeStart = BaseValue + endSub; RangeEnd = BaseValue + startSub; } }
public override Task Rebuild() { this.DebugDepth("Rebuild"); UpdateHistogramDisplay(); bool propertyUpdated = false; var minSeparation = .01; var rangeStart = RangeStart.Value(this); var rangeEnd = RangeEnd.Value(this); if (rangeStart < 0 || rangeStart > 1 || rangeEnd < 0 || rangeEnd > 1 || rangeStart > rangeEnd - minSeparation) { rangeStart = Math.Max(0, Math.Min(1 - minSeparation, rangeStart)); rangeEnd = Math.Max(0, Math.Min(1, rangeEnd)); if (rangeStart > rangeEnd - minSeparation) { // values are overlapped or too close together if (rangeEnd < 1 - minSeparation) { // move the end up whenever possible rangeEnd = rangeStart + minSeparation; } else { // move the end to the end and the start up rangeEnd = 1; RangeStart = 1 - minSeparation; } } propertyUpdated = true; } var rebuildLock = RebuildLock(); // now create a long running task to process the image return(ApplicationController.Instance.Tasks.Execute( "Calculate Path".Localize(), null, (reporter, cancellationToken) => { var progressStatus = new ProgressStatus(); this.GenerateMarchingSquaresAndLines( (progress0to1, status) => { progressStatus.Progress0To1 = progress0to1; progressStatus.Status = status; reporter.Report(progressStatus); }, Image, ThresholdFunction); if (propertyUpdated) { UpdateHistogramDisplay(); this.Invalidate(InvalidateType.Properties); } UiThread.RunOnIdle(() => { rebuildLock.Dispose(); Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path)); }); return Task.CompletedTask; })); }
public int CompareTo(IntervalPoint <TRange, TIntervalScore> other) { return(RangeStart.CompareTo(other.RangeStart)); }
private void Update(EvaluationContext context) { if (!Values.IsConnected) { return; } var values = Values.GetValue(context); if (values == null || values.Count == 0) { return; } int rangeStart = RangeStart.GetValue(context).Clamp(0, values.Count - 1); int rangeEnd = RangeEnd.GetValue(context).Clamp(0, values.Count - 1); float gain = Gain.GetValue(context); float pow = Pow.GetValue(context); if (Math.Abs(pow) < 0.001f) { return; } if (rangeEnd < rangeStart) { var tmp = rangeEnd; rangeEnd = rangeStart; rangeStart = tmp; } int sampleCount = (rangeEnd - rangeStart) + 1; int entrySizeInBytes = sizeof(float); int listSizeInBytes = sampleCount * entrySizeInBytes; int bufferSizeInBytes = 1 * listSizeInBytes; using (var dataStream = new DataStream(bufferSizeInBytes, true, true)) { var texDesc = new Texture2DDescription() { Width = sampleCount, Height = 1, ArraySize = 1, BindFlags = BindFlags.ShaderResource, Usage = ResourceUsage.Default, MipLevels = 1, CpuAccessFlags = CpuAccessFlags.None, Format = Format.R32_Float, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), }; //foreach (var curveInput in Curves.CollectedInputs) //{ // var curve = curveInput.GetValue(context); // if (curve == null) // { // dataStream.Seek(curveSizeInBytes, SeekOrigin.Current); // continue; // } for (var sampleIndex = rangeStart; sampleIndex <= rangeEnd; sampleIndex++) { //dataStream.Write((float)curve.GetSampledValue((float)sampleIndex / sampleCount)); float v = (float)Math.Pow(values[sampleIndex] * gain, pow); dataStream.Write(v); } //} //Curves.DirtyFlag.Clear(); dataStream.Position = 0; var dataRectangles = new DataRectangle[] { new DataRectangle(dataStream.DataPointer, listSizeInBytes) }; Utilities.Dispose(ref CurveTexture.Value); CurveTexture.Value = new Texture2D(ResourceManager.Instance().Device, texDesc, dataRectangles); } }
/// <summary> /// Determines whether the specified Object is equal to the current Object. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj == null) { return(false); } if (Object.ReferenceEquals(this, obj)) { return(true); } if (this.GetType() != obj.GetType()) { return(false); } var other = (VLLibraryQuestion)obj; //reference types if (!Object.Equals(ValidationField1, other.ValidationField1)) { return(false); } if (!Object.Equals(ValidationField2, other.ValidationField2)) { return(false); } if (!Object.Equals(ValidationField3, other.ValidationField3)) { return(false); } if (!Object.Equals(RegularExpression, other.RegularExpression)) { return(false); } if (!Object.Equals(QuestionText, other.QuestionText)) { return(false); } if (!Object.Equals(Description, other.Description)) { return(false); } if (!Object.Equals(HelpText, other.HelpText)) { return(false); } if (!Object.Equals(FrontLabelText, other.FrontLabelText)) { return(false); } if (!Object.Equals(AfterLabelText, other.AfterLabelText)) { return(false); } if (!Object.Equals(InsideText, other.InsideText)) { return(false); } if (!Object.Equals(RequiredMessage, other.RequiredMessage)) { return(false); } if (!Object.Equals(ValidationMessage, other.ValidationMessage)) { return(false); } if (!Object.Equals(OtherFieldLabel, other.OtherFieldLabel)) { return(false); } //value types if (!QuestionId.Equals(other.QuestionId)) { return(false); } if (!m_category.Equals(other.m_category)) { return(false); } if (!QuestionType.Equals(other.QuestionType)) { return(false); } if (!IsRequired.Equals(other.IsRequired)) { return(false); } if (!RequiredBehavior.Equals(other.RequiredBehavior)) { return(false); } if (!RequiredMinLimit.Equals(other.RequiredMinLimit)) { return(false); } if (!RequiredMaxLimit.Equals(other.RequiredMaxLimit)) { return(false); } if (!AttributeFlags.Equals(other.AttributeFlags)) { return(false); } if (!ValidationBehavior.Equals(other.ValidationBehavior)) { return(false); } if (!RandomBehavior.Equals(other.RandomBehavior)) { return(false); } if (!OtherFieldType.Equals(other.OtherFieldType)) { return(false); } if (!OtherFieldRows.Equals(other.OtherFieldRows)) { return(false); } if (!OtherFieldChars.Equals(other.OtherFieldChars)) { return(false); } if (!OptionsSequence.Equals(other.OptionsSequence)) { return(false); } if (!ColumnsSequence.Equals(other.ColumnsSequence)) { return(false); } if (!RangeStart.Equals(other.RangeStart)) { return(false); } if (!RangeEnd.Equals(other.RangeEnd)) { return(false); } return(true); }
public List <string> GetRangeValues() { if (!IsRange) { return new List <string> { Value } } ; else { List <string> result = new List <string>(); string startSub = RangeStart.Replace(BaseValue, ""); string endSub = RangeEnd.Replace(BaseValue, ""); int rangeStart = Convert.ToInt32(Regex.Match(RangeStart, @"\d+").Value); int rangeEnd = Convert.ToInt32(Regex.Match(RangeEnd, @"\d+").Value); for (int i = rangeStart; i <= rangeEnd; i++) { if (startSub == "" || endSub == "") { if (System == GradeSystem.Hueco) { result.Add($"V{i}"); } else if (System == GradeSystem.YDS) { result.Add($"5.{i}"); } } else if (startSub == "-") { if (System == GradeSystem.Hueco) { result.Add($"V{i}-"); result.Add($"V{i}"); result.Add($"V{i}+"); } else if (System == GradeSystem.YDS) { result.Add($"5.{i}-"); result.Add($"5.{i}"); result.Add($"5.{i}+"); } } else { char startChar = i == rangeStart ? startSub[0] : 'a'; char endChar = i == rangeEnd ? endSub[0] : 'd'; for (char c = startChar; c <= endChar; c++) { if (System == GradeSystem.Hueco) { result.Add($"V{i}{c}"); } else if (System == GradeSystem.YDS) { result.Add($"5.{i}{c}"); } } } } return(result); } }
private bool IsInputValid() { if (RangeStart.IsBlank()) { IsRangeStartFocussed = true; IsRangeEndFocussed = false; return(false); } if (RangeEnd.IsBlank()) { IsRangeStartFocussed = false; IsRangeEndFocussed = true; return(false); } if (RangeStart == RangeEnd) { ShowDialog("Information!", "Start and End range values are the same."); return(false); } // Input must be the correct length if (RangeStart.Length < DocumentIdLength) { ShowDialog("Information!", $"Start of range must be a minimum of {DocumentIdLength} characters"); return(false); } if (RangeEnd.Length < DocumentIdLength) { ShowDialog("Information!", $"End of range must be a minimum of {DocumentIdLength} characters"); return(false); } // Extra check for pasted-in values if (RangeStart.IsNotNumeric()) { ShowDialog("Information!", $"Start of range contains non-numeric characters"); return(false); } if (RangeEnd.IsNotNumeric()) { ShowDialog("Information!", $"End of range contains non-numeric characters"); return(false); } // Workflow ID's must match String rangeStartWorkflowId = RangeStart.Substring(0, workflowIdLength); String rangeEndWorkflowId = RangeEnd.Substring(0, workflowIdLength); if (!rangeStartWorkflowId.Equals(rangeEndWorkflowId)) { ShowDialog("Information!", $"Workflow IDs {rangeStartWorkflowId} and {rangeEndWorkflowId} do not match"); return(false); } // ID's must be ordered correctly if (RangeStart.CompareTo(RangeEnd) > 0) { ShowDialog("Information!", "Start and End range values have been entered in the wrong order"); return(false); } return(true); }