コード例 #1
0
        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);
        }
コード例 #2
0
        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);           
        }
コード例 #3
0
ファイル: NoteModel.cs プロジェクト: MrWalsh/Dynamo
        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;
        }        
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: BaseTypes.cs プロジェクト: norbertzsiros/Dynamo
        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);
        }
コード例 #6
0
        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));
        }
コード例 #7
0
ファイル: CodeBlockNode.cs プロジェクト: rafatahmed/Dynamo
        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;
        }
コード例 #8
0
ファイル: ModelBase.cs プロジェクト: rafatahmed/Dynamo
 /// <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.
 }
コード例 #9
0
ファイル: ModelBase.cs プロジェクト: rafatahmed/Dynamo
 public bool UpdateValue(UpdateValueParams updateValueParams)
 {
     return UpdateValueCore(updateValueParams);
 }
コード例 #10
0
ファイル: SliderTests.cs プロジェクト: norbertzsiros/Dynamo
        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);
        }
コード例 #11
0
ファイル: SliderTests.cs プロジェクト: norbertzsiros/Dynamo
        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);
        }
コード例 #12
0
ファイル: SliderTests.cs プロジェクト: norbertzsiros/Dynamo
        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);
        }
コード例 #13
0
ファイル: SliderTests.cs プロジェクト: norbertzsiros/Dynamo
        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);
        }
コード例 #14
0
ファイル: WorkspaceModel.cs プロジェクト: mikeyforrest/Dynamo
        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;
        }
コード例 #15
0
ファイル: BaseTypes.cs プロジェクト: norbertzsiros/Dynamo
        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);
        }
コード例 #16
0
ファイル: ModelBase.cs プロジェクト: tylerputnam/Dynamo
 /// <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.
 }
コード例 #17
0
ファイル: ModelBase.cs プロジェクト: tylerputnam/Dynamo
 public bool UpdateValue(UpdateValueParams updateValueParams)
 {
     return(UpdateValueCore(updateValueParams));
 }
コード例 #18
0
        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);
        }
コード例 #19
0
ファイル: NodeModel.cs プロジェクト: w-fish/Dynamo
        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);
        }