Ejemplo n.º 1
0
        public void CanResetLocationWhenCreate()
        {
            var model = ViewModel.Model;
            // Arrange
            string samplePath = Path.Combine(workingDirectory, @".\Viewport\CanResetLocationWhenCreate.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            string expectedViewportName = "Title w Line";

            // Act
            ViewModel.OpenCommand.Execute(testPath);
            RunCurrentModel();

            IntegerSlider slider = model.CurrentWorkspace.NodeFromWorkspace
                                       ("d443e82fd58143f5a30fd35f41ca0426") as IntegerSlider;

            slider.Value = 100;

            RunCurrentModel();

            var viewportName = GetPreviewValue("e01a83242a3d4a2cb02789c3c90bb1a1");

            // Assert
            Assert.AreEqual(expectedViewportName, viewportName);
        }
Ejemplo n.º 2
0
    private void Initialize()
    {
        if (m_HasInitialized)
        {
            return;
        }
        // Create Value Throttles
        angleThrottle          = new ValueThrottle <float>(bendUpdateThrottleMs);
        angleThrottle.onValue += ListenerAngle;
        rulerThrottle          = new ValueThrottle <float>(bendUpdateThrottleMs);
        rulerThrottle.onValue += ListenerRuler;
        intThrottle            = new ValueThrottle <int>(bendUpdateThrottleMs);
        intThrottle.onValue   += ListenerInteger;

        // Create Prefabs
        m_AngleWidget = Instantiate(angleWidgetPrefab);
        m_AngleWidget.SetParent(widgetView, false);
        m_AngleWidget.gameObject.SetActive(false);
        AngleSlider angleSlider = m_AngleWidget.GetComponentsInChildren <AngleSlider>(true)[0];

        angleSlider.onValueChanged.AddListener(angleThrottle.Set);

        m_RulerWidget = Instantiate(rulerWidgetPrefab);
        m_RulerWidget.SetParent(widgetView, false);
        m_RulerWidget.gameObject.SetActive(false);
        MultiRulerSlider rulerSlider = m_RulerWidget.GetComponentsInChildren <MultiRulerSlider>(true)[0];

        rulerSlider.onValueChanged.AddListener(rulerThrottle.Set);
        rulerSlider.rulerDisplayType = Engine.unitType;

        m_IntegerWidget = Instantiate(integerWidgetPrefab);
        m_IntegerWidget.SetParent(widgetView, false);
        m_IntegerWidget.gameObject.SetActive(false);
        IntegerSlider integerSlider = m_IntegerWidget.GetComponentsInChildren <IntegerSlider>(true)[0];

        integerSlider.onValueChanged = intThrottle.Set;

        m_EnumWidget = Instantiate(enumWidgetPrefab);
        m_EnumWidget.SetParent(widgetView, false);
        m_EnumWidget.gameObject.SetActive(false);
        EnumDropdown enumDropdown = m_EnumWidget.GetComponentsInChildren <EnumDropdown>(true)[0];

        enumDropdown.onValueChanged.AddListener(ListenerEnum);

        m_HelpWidget = Instantiate(helpWidgetPrefab);
        m_HelpWidget.SetParent(widgetView, false);
        m_HelpWidget.gameObject.SetActive(false);
        BendHelp bendHelp = m_HelpWidget.GetComponentsInChildren <BendHelp>(true)[0];

        bendHelp.onValueChanged = ListenerHelp;

        m_OutputText = outputView.GetComponentsInChildren <TextColumns>(true)[0];
        m_OutputText.maxCharPerLineTotal = Engine.GetLanguageMaxParameterStringLength() * m_OutputText.columns.Count;


        m_HasInitialized = true;
    }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        public void MAGN_3784()
        {
            // Details are available in defect
            // http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-3784

            var model = ViewModel.Model;

            string samplePath = Path.Combine(_testPath, @".\\Bugs\MAGN_3784.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            ViewModel.OpenCommand.Execute(testPath);

            AssertNoDummyNodes();

            RunCurrentModel();

            // check all the nodes and connectors are loaded
            Assert.AreEqual(5, model.CurrentWorkspace.Nodes.Count);
            Assert.AreEqual(3, model.CurrentWorkspace.Connectors.Count);

            // evaluate graph
            var refPtNodeId = "92774673-e265-4378-b8ba-aef86c1a616e";
            var refPt       = GetPreviewValue(refPtNodeId) as ReferencePoint;

            Assert.IsNotNull(refPt);
            Assert.AreEqual(0, refPt.X);

            // change slider value and re-evaluate graph
            IntegerSlider slider = model.CurrentWorkspace.NodeFromWorkspace
                                       ("55a992c9-8f16-4c07-a049-b0627d78c93c") as IntegerSlider;

            slider.Value = 10;

            RunCurrentModel();

            refPt = GetPreviewValue(refPtNodeId) as ReferencePoint;
            Assert.IsNotNull(refPt);
            (10.0).ShouldBeApproximately(refPt.X);

            RunCurrentModel();

            // Cross check from Revit side.
            var selectElementType = "4a99826a-eb73-4831-857c-909579c7eb12";
            var refPt1            = GetPreviewValueAtIndex(selectElementType, 0) as ReferencePoint;

            AssertPreviewCount(selectElementType, 1);

            Assert.IsNotNull(refPt1);
            (10.0).ShouldBeApproximately(refPt1.X, 1.0e-6);
        }
Ejemplo n.º 9
0
        public IntegerSlider IntegerSlider(MenuDisplayMode displayMode, string id, string name,
                                           Func <int> getter, Action <int> setter, int minimum = 0,
                                           int maximum = 10, int defaultValue = 0, string description = null)
        {
            var integerSlider = new IntegerSlider(displayMode, id, name)
                                .WithGetter(getter)
                                .WithSetter(setter)
                                .LimitedByRange(minimum, maximum)
                                .WithDefaultValue(defaultValue)
                                .WithDescription(description);

            Add(integerSlider);

            return(integerSlider as IntegerSlider);
        }
Ejemplo n.º 10
0
        public void Defect_MAGN_2607()
        {
            //Detail steps are here http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-2607
            DynamoModel model    = ViewModel.Model;
            string      openPath = Path.Combine(GetTestDirectory(), @"core\DynamoDefects\Defect_MAGN_2607.dyn");

            RunModel(openPath);
            AssertPreviewValue("99975a42-f887-4b99-9b0a-e36513d2bd6d", 12);
            IntegerSlider input = model.CurrentWorkspace.NodeFromWorkspace
                                      ("7cbafd1f-cec2-48b2-ac52-c9605acfb644") as IntegerSlider;

            input.Value = 12;
            RunCurrentModel();
            AssertPreviewValue("99975a42-f887-4b99-9b0a-e36513d2bd6d", 24);
        }
Ejemplo n.º 11
0
        public void Revit_Adaptive_Component_Placement()
        {
            var model = ViewModel.Model;

            string samplePath = Path.Combine(workingDirectory, @".\Samples\Revit_Adaptive Component Placement.dyn");
            string testPath   = Path.GetFullPath(samplePath);

            ViewModel.OpenCommand.Execute(testPath);

            AssertNoDummyNodes();

            // check all the nodes and connectors are loaded
            Assert.AreEqual(13, model.CurrentWorkspace.Nodes.Count);
            Assert.AreEqual(12, model.CurrentWorkspace.Connectors.Count);

            RunCurrentModel();


            var refPtNodeId = "357e7a53-361c-4c1e-81ae-83e16213a39a";

            AssertPreviewCount(refPtNodeId, 9);

            // get all AdaptiveComponent.
            for (int i = 0; i <= 8; i++)
            {
                var refPt = GetPreviewValueAtIndex(refPtNodeId, i) as AdaptiveComponent;
                Assert.IsNotNull(refPt);
            }

            // change slider value and re-evaluate graph
            IntegerSlider slider = model.CurrentWorkspace.NodeFromWorkspace
                                       ("cc3ba87a-cc1f-4db6-99f2-769f3020e0df") as IntegerSlider;

            slider.Value = 6;

            RunCurrentModel();

            AssertPreviewCount(refPtNodeId, 6);

            // Now there should be only 6 AdaptiveComponent in Revit.
            for (int i = 0; i <= 5; i++)
            {
                var refPt = GetPreviewValueAtIndex(refPtNodeId, i) as AdaptiveComponent;
                Assert.IsNotNull(refPt);
            }
        }
Ejemplo n.º 12
0
        public void Defect_MAGN_4046()
        {
            //Detail steps are here http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-4046
            DynamoModel model    = ViewModel.Model;
            string      openPath = Path.Combine(GetTestDirectory(), @"core\DynamoDefects\Defect_MAGN_4046.dyn");

            RunModel(openPath);
            AssertPreviewCount("354ec30b-b13f-4399-beb2-a68753c09bfc", 1);
            IntegerSlider integerInput = model.CurrentWorkspace.NodeFromWorkspace
                                             ("65d226ea-cfb5-4c5a-940e-a5c4eab1915d") as IntegerSlider;

            for (int i = 0; i <= 10; i++)
            {
                integerInput.Value = 5 + i;
                RunCurrentModel();
                AssertPreviewCount("354ec30b-b13f-4399-beb2-a68753c09bfc", 1);
            }
        }
Ejemplo n.º 13
0
        public void IntegerSliderMaxValue()
        {
            var integerSliderNode = new IntegerSlider()
            {
                Value = 500
            };

            integerSliderNode.UpdateValue("Value", "1000", null);

            Assert.AreEqual(
                1000,
                integerSliderNode.Max);

            integerSliderNode.UpdateValue("Value", "-1", null);

            Assert.AreEqual(
                -1,
                integerSliderNode.Min);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
 public void CanConstructIntegerSlider()
 {
     var slider = new IntegerSlider();
     Assert.NotNull(slider);
 }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
    private void DisplayWidget(int id)
    {
        // Remove any active Highlighting
        m_Bend.SetHighlight(null);
        m_HelpWidget.GetComponentInChildren <BendHelp>().UnSelect();

        // Don't reselect the same Widget
        if (m_ActiveParameter == id)
        {
            return;
        }
        // Disable current Widget
        if (m_ActiveWidget != null)
        {
            m_ActiveWidget.gameObject.SetActive(false);
        }
        m_ActiveParameter = id;

        BendParameter      param = m_Bend.inputParameters[id];
        EBendParameterType type  = param.type;

        object[] range = BendParameter.GetRange(param.name);

        switch (type)
        {
        case EBendParameterType.FloatAngle:
            m_ActiveWidget = m_AngleWidget;
            m_ActiveWidget.gameObject.SetActive(true);
            AngleSlider ans = m_AngleWidget.GetComponentInChildren <AngleSlider>();
            ans.SetRange((float)range[0], (float)range[1]);
            ans.value = (float)param.value;
            break;

        case EBendParameterType.Float:
            m_ActiveWidget = m_RulerWidget;
            m_ActiveWidget.gameObject.SetActive(true);
            MultiRulerSlider mr = m_RulerWidget.GetComponentInChildren <MultiRulerSlider>();
            mr.SetRange((float)range[1]);
            mr.Set((float)param.value, false);
            break;

        case EBendParameterType.Integer:
            m_ActiveWidget = m_IntegerWidget;
            m_ActiveWidget.gameObject.SetActive(true);
            IntegerSlider ins = m_IntegerWidget.GetComponentInChildren <IntegerSlider>();
            ins.SetRange((int)range[0], (int)range[1]);
            ins.SetName(BendParameter.GetStringValue(param.name));
            ins.value = (int)param.value;
            break;

        case EBendParameterType.StringEnum:
            m_ActiveWidget = m_EnumWidget;
            m_ActiveWidget.gameObject.SetActive(true);

            EnumDropdown ed = m_EnumWidget.GetComponentInChildren <EnumDropdown>();
            List <Dropdown.OptionData> enumList = ed.options;
            StringEnum se        = (StringEnum)param.valueObject;
            int        enumStart = (int)range[0];
            int        enumEnd   = (int)range[1];
            enumList.Clear();
            for (int i = enumStart; i <= enumEnd; ++i)
            {
                enumList.Add(new EnumDropdown.EnumOptionData(se.ToStringValue(i), null, se.ToDescription(i)));
            }
            ed.value = (int)param.value;
            ed.Refresh();
            break;

        default:
            throw new ArgumentException("BendInputScreen: DisplayWidget() Invalid type.");
        }
    }
Ejemplo n.º 19
0
        public void CanConstructIntegerSlider()
        {
            var slider = new IntegerSlider();

            Assert.NotNull(slider);
        }