public void IntegerSliderMaxValue() { var integerSliderNode = new IntegerSlider() { Value = 500 }; var updateValueParams = new UpdateValueParams("Value", "1000"); integerSliderNode.UpdateValue(updateValueParams); Assert.AreEqual( 1000, integerSliderNode.Max); updateValueParams = new UpdateValueParams("Value", "-1"); integerSliderNode.UpdateValue(updateValueParams); Assert.AreEqual( -1, integerSliderNode.Min); updateValueParams = new UpdateValueParams("Value", "2147483648"); integerSliderNode.UpdateValue(updateValueParams); Assert.AreEqual( 2147483647, integerSliderNode.Max); updateValueParams = new UpdateValueParams("Value", "-2147483649"); integerSliderNode.UpdateValue(updateValueParams); Assert.AreEqual( -2147483648, integerSliderNode.Min); }
public void SliderMaxValueWithBigNum() { var sliderNode = new DoubleSlider() { Value = 500 }; var updateValueParams = new UpdateValueParams("Max", "2.14748364712346E+15"); sliderNode.UpdateValue(updateValueParams); Assert.AreEqual( 2.14748364712346E+15, sliderNode.Max); }
protected override bool UpdateValueCore(UpdateValueParams updateValueParams) { string name = updateValueParams.PropertyName; string value = updateValueParams.PropertyValue; if (name != "Text") return base.UpdateValueCore(updateValueParams); Text = value; return true; }
public void SliderMaxValue() { var sliderNode = new DoubleSlider() { Value = 500 }; var updateValueParams = new UpdateValueParams("Value", "1000"); sliderNode.UpdateValue(updateValueParams); Assert.AreEqual( 1000, sliderNode.Max); updateValueParams = new UpdateValueParams("Value", "-1"); sliderNode.UpdateValue(updateValueParams); Assert.AreEqual( -1, sliderNode.Min); }
protected override bool UpdateValueCore(UpdateValueParams updateValueParams) { string name = updateValueParams.PropertyName; string value = updateValueParams.PropertyValue; if (name == "Value") { Value = value; return true; // UpdateValueCore handled. } // There's another 'UpdateValueCore' method in 'String' base class, // since they are both bound to the same property, 'StringInput' // should be given a chance to handle the property value change first // before the base class 'String'. return base.UpdateValueCore(updateValueParams); }
protected override bool UpdateValueCore(UpdateValueParams updateValueParams) { string name = updateValueParams.PropertyName; string value = updateValueParams.PropertyValue; switch (name) { case "FontSize": FontSize = Convert.ToDouble(value); break; case "Background": Background = value; break; case "TextBlockText": AnnotationText = value; break; } return(base.UpdateValueCore(updateValueParams)); }
protected override bool UpdateValueCore(UpdateValueParams updateValueParams) { string name = updateValueParams.PropertyName; string value = updateValueParams.PropertyValue; ElementResolver workspaceElementResolver = updateValueParams.ElementResolver; if (name != "Code") return base.UpdateValueCore(updateValueParams); value = CodeBlockUtils.FormatUserText(value); //Since an empty Code Block Node should not exist, this checks for such instances. // If an empty Code Block Node is found, it is deleted. Since the creation and deletion of // an empty Code Block Node should not be recorded, this method also checks and removes // any unwanted recordings if (value == "") { Code = ""; } else { if (!value.Equals(Code)) SetCodeContent(value, workspaceElementResolver); } return true; }
/// <summary> /// This method is supplied as a generic way for command framework to update /// a given named-value in a ModelBase (which has to work under both user /// and playback scenarios). During playback, the command framework issues /// pre-recorded UpdateModelValueCommand that targets a model. Since there /// is no data-binding at play here, there will not be IValueConverter. This /// method takes only string input (the way they appear in DynamoTextBox), /// which overridden method can use for value conversion. /// </summary> /// <param name="updateValueParams">Please see UpdateValueParams for details.</param> /// <returns>Returns true if the call has been handled, or false otherwise. /// </returns> protected virtual bool UpdateValueCore(UpdateValueParams updateValueParams) { return false; // Base class does not handle this. }
public bool UpdateValue(UpdateValueParams updateValueParams) { return UpdateValueCore(updateValueParams); }
public void SliderCanNotBeSetLessThanMinIntValue() { var slider = new IntegerSlider(); Assert.NotNull(slider); var param = new UpdateValueParams("Value", "-2147483649"); slider.UpdateValue(param); Assert.AreEqual(slider.Value, Int32.MinValue); }
public void SliderCanNotBeSetGreaterThanMaxIntValue() { var slider = new IntegerSlider(); Assert.NotNull(slider); var param = new UpdateValueParams("Value", "2147483648"); slider.UpdateValue(param); Assert.AreEqual(slider.Value, Int32.MaxValue); }
public void SliderMinResetsToIntMin() { var slider = new IntegerSlider(); Assert.NotNull(slider); var param = new UpdateValueParams("Min", "-2147483649"); slider.UpdateValue(param); Assert.AreEqual(slider.Min, Int32.MinValue); }
public void SliderMaxResetsToIntMax() { var slider = new IntegerSlider(); Assert.NotNull(slider); var param = new UpdateValueParams("Max", "2147483648"); slider.UpdateValue(param); Assert.AreEqual(slider.Max, Int32.MaxValue); }
internal void UpdateModelValue(IEnumerable<Guid> modelGuids, string propertyName, string value) { if (modelGuids == null || (!modelGuids.Any())) throw new ArgumentNullException("modelGuids"); var retrievedModels = GetModelsInternal(modelGuids); if (!retrievedModels.Any()) throw new InvalidOperationException("UpdateModelValue: Model not found"); var updateValueParams = new UpdateValueParams(propertyName, value, ElementResolver); using (new UndoRedoRecorder.ModelModificationUndoHelper(undoRecorder, retrievedModels)) { foreach (var retrievedModel in retrievedModels) { retrievedModel.UpdateValue(updateValueParams); } } HasUnsavedChanges = true; }
protected override bool UpdateValueCore(UpdateValueParams updateValueParams) { string name = updateValueParams.PropertyName; string value = updateValueParams.PropertyValue; if (name == "Value") { Value = value; return true; // UpdateValueCore handled. } return base.UpdateValueCore(updateValueParams); }
/// <summary> /// This method is supplied as a generic way for command framework to update /// a given named-value in a ModelBase (which has to work under both user /// and playback scenarios). During playback, the command framework issues /// pre-recorded UpdateModelValueCommand that targets a model. Since there /// is no data-binding at play here, there will not be IValueConverter. This /// method takes only string input (the way they appear in DynamoTextBox), /// which overridden method can use for value conversion. /// </summary> /// <param name="updateValueParams">Please see UpdateValueParams for details.</param> /// <returns>Returns true if the call has been handled, or false otherwise. /// </returns> protected virtual bool UpdateValueCore(UpdateValueParams updateValueParams) { return(false); // Base class does not handle this. }
public bool UpdateValue(UpdateValueParams updateValueParams) { return(UpdateValueCore(updateValueParams)); }
protected override bool UpdateValueCore(UpdateValueParams updateValueParams) { string name = updateValueParams.PropertyName; string value = updateValueParams.PropertyValue; switch (name) { case "FontSize": FontSize = Convert.ToDouble(value); break; case "Background": Background = value; break; case "TextBlockText": AnnotationText = value; break; } return base.UpdateValueCore(updateValueParams); }
protected override bool UpdateValueCore(UpdateValueParams updateValueParams) { string name = updateValueParams.PropertyName; string value = updateValueParams.PropertyValue; switch(name) { case "NickName": NickName = value; return true; case "UsingDefaultValue": if (string.IsNullOrWhiteSpace(value)) return true; // Here we expect a string that represents an array of Boolean values which are separated by ";" var arr = value.Split(';'); for (int i = 0; i < arr.Length; i++) { var useDef = !bool.Parse(arr[i]); // do not set true, if default value is disabled if (!useDef || InPorts[i].DefaultValueEnabled) { InPorts[i].UsingDefaultValue = useDef; } } return true; case "ArgumentLacing": LacingStrategy strategy; if (!Enum.TryParse(value, out strategy)) strategy = LacingStrategy.Disabled; ArgumentLacing = strategy; return true; case "IsVisible": bool newVisibilityValue; if (bool.TryParse(value, out newVisibilityValue)) IsVisible = newVisibilityValue; return true; case "IsUpstreamVisible": bool newUpstreamVisibilityValue; if (bool.TryParse(value, out newUpstreamVisibilityValue)) IsUpstreamVisible = newUpstreamVisibilityValue; return true; } return base.UpdateValueCore(updateValueParams); }