public void Normalize() { this.BillCode = BillCode?.Trim(); this.RangeBegin = RangeBegin?.DateBegin(); this.RangeEnd = RangeEnd?.DateEnd(); this.OrderNumber = OrderNumber?.Trim().ToUpper(); this.ItemNumber = ItemNumber?.Trim().ToUpper(); }
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()); }
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 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)); }
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); }
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 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); }
private void RangeBox_FlowLeave(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(RangeStart.Value) && string.IsNullOrEmpty(RangeEnd.Value)) { if (AssertNotEmpty) { RangeEnd.ToastMessage("范围值必须有值!"); e.Handled = true; } return; } if (string.IsNullOrEmpty(RangeStart.Value) || string.IsNullOrEmpty(RangeEnd.Value)) { RangeEnd.ToastMessage("范围值必须成对出现!"); e.Handled = true; return; } if (RangeEnd.CompareTo(RangeStart) < 0) { RangeEnd.ToastMessage("必须为有效范围!"); e.Handled = true; return; } }
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 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 static void NonlinearRangeSlider(Rect rect, int id, ref FloatRange range, string labelKey = null, ToStringStyle valueStyle = ToStringStyle.FloatTwo) { Rect rect2 = rect; rect2.xMin += 8f; rect2.xMax -= 8f; GUI.color = RangeControlTextColor; string text = $"${range.min.ToStringByStyle(valueStyle)} - " + ( range.max > max ? infinity : $"${range.max.ToStringByStyle(valueStyle)}"); if (labelKey != null) { text = text + " " + labelKey; } GameFont font = Text.Font; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(rect2, text); Text.Anchor = TextAnchor.UpperLeft; Rect position = new Rect(rect2.x, rect2.yMax - 8f - 1f, rect2.width, 2f); GUI.DrawTexture(position, BaseContent.WhiteTex); GUI.color = Color.white; float minSliderPos = rect2.x + (rect2.width * SliderPosForValue(range.min)); float maxSliderPos = rect2.x + (rect2.width * Mathf.Clamp01(SliderPosForValue(range.max))); Rect position2 = new Rect(minSliderPos - 16f, position.center.y - 8f, 16f, 16f); GUI.DrawTexture(position2, FloatRangeSliderTex); Rect position3 = new Rect(maxSliderPos + 16f, position.center.y - 8f, -16f, 16f); GUI.DrawTexture(position3, FloatRangeSliderTex); if (curDragEnd != RangeEnd.None && (Event.current.type == EventType.MouseUp || Event.current.rawType == EventType.MouseDown)) { draggingIdInfo.SetValue(null, 0); curDragEnd = RangeEnd.None; SoundDefOf.DragSlider.PlayOneShotOnCamera(); } bool flag = false; if (Mouse.IsOver(rect) || draggingIdGet() == id) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && id != draggingIdGet()) { draggingIdInfo.SetValue(null, id); float x = Event.current.mousePosition.x; if (x < position2.xMax) { curDragEnd = RangeEnd.Min; } else if (x > position3.xMin) { curDragEnd = RangeEnd.Max; } else { float num3 = Mathf.Abs(x - position2.xMax); float num4 = Mathf.Abs(x - (position3.x - 16f)); curDragEnd = ((num3 >= num4) ? RangeEnd.Max : RangeEnd.Min); } flag = true; Event.current.Use(); SoundDefOf.DragSlider.PlayOneShotOnCamera(); } if (flag || (curDragEnd != RangeEnd.None && Event.current.type == EventType.MouseDrag)) { float sliderValue = ValueForSliderPos((Event.current.mousePosition.x - rect2.x) / rect2.width); sliderValue = RoundToSignificantDigits(sliderValue, 2); sliderValue = Mathf.Clamp(sliderValue, 0f, max); if (curDragEnd == RangeEnd.Min) { if (sliderValue != range.min) { range.min = sliderValue; if (range.max < range.min) { range.max = range.min; } CheckPlayDragSliderSound(); } } else if (curDragEnd == RangeEnd.Max && sliderValue != range.max) { if (sliderValue == max) { sliderValue = float.MaxValue; } range.max = sliderValue; if (range.min > range.max) { range.min = range.max; } CheckPlayDragSliderSound(); } Event.current.Use(); } } Text.Font = font; }
/// <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); }
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); } }
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 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); }