public Cursor(EntityState es, Town t, XmlParser xp)
            : base(es, "Cursor")
        {
            _town = t;

            //Current data path is GameState->Town->Cursor
            var path = es.Name + "->" + _town.Name + "->" + Name;

            Body = new Body(this, "Body");
            AddComponent(Body);

            Physics = new Physics(this, "Physics");
            AddComponent(Physics);

            ImageRender = new ImageRender(this, "ImageRender");
            AddComponent(ImageRender);

            _aimleftkey = new DoubleInput(this, "AimLeftKey", Keys.A, Buttons.DPadLeft, PlayerIndex.One);
            AddComponent(_aimleftkey);

            _aimrightkey = new DoubleInput(this, "AimRightKeys", Keys.D, Buttons.DPadRight, PlayerIndex.One);
            AddComponent(_aimrightkey);

            _quickaimkey = new DoubleInput(this, "QuickAimKey", Keys.LeftShift, Buttons.RightShoulder, PlayerIndex.One);
            AddComponent(_quickaimkey);

            ParseXml(xp, path);

            ImageRender.Origin = new Vector2(ImageRender.Texture.Width / 2f, ImageRender.Texture.Height / 2f);
            Body.Position = _town.Body.Position +
                            (_town.TileRender.Origin - Vector2.UnitY * 40 - ImageRender.Origin) *
                            ImageRender.Scale;
        }
Beispiel #2
0
        private List <NodeModel> SetupNumberNodesAndPresets()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();

            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();

            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 3);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 2);

            DynamoSelection.Instance.ClearSelection();
            //create the first state with the numbers selected
            DynamoSelection.Instance.Selection.Add(numberNode1);
            DynamoSelection.Instance.Selection.Add(numberNode2);
            var ids = DynamoSelection.Instance.Selection.OfType <NodeModel>().Select(x => x.GUID).ToList();

            //create the preset from 2 nodes
            model.ExecuteCommand(new DynamoModel.AddPresetCommand("state1", "3", ids));

            //change values
            numberNode1.Value = "2";
            numberNode2.Value = "3";

            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(numberNode1);
            DynamoSelection.Instance.Selection.Add(numberNode2);
            ids = DynamoSelection.Instance.Selection.OfType <NodeModel>().Select(x => x.GUID).ToList();

            model.ExecuteCommand(new DynamoModel.AddPresetCommand("state2", "5", ids));

            return(new List <NodeModel>()
            {
                numberNode1, numberNode2, addNode
            });
        }
        public void doubleInputNodeWillNotAcceptIds()
        {
            var number = new DoubleInput();

            Model.AddNodeToCurrentWorkspace(number, true);
            DispatcherUtil.DoEvents();
            var nodeView = NodeViewWithGuid(number.GUID.ToString());

            nodeView.inputGrid.ChildrenOfType <DynamoTextBox>().First().Text = "start..end";
            DispatcherUtil.DoEvents();
            Assert.IsTrue(number.Value != "start..end");
            Assert.IsTrue(number.Value == "0");
            Assert.IsTrue(number.IsInErrorState);
        }
        public void TestNodeToCodeCommandState()
        {
            DynamoSelection.Instance.ClearSelection();
            Assert.IsFalse(ViewModel.CurrentSpaceViewModel.NodeToCodeCommand.CanExecute(null));

            var node = new DoubleInput();

            ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(node, false);
            DynamoSelection.Instance.Selection.Add(node);
            Assert.IsTrue(ViewModel.CurrentSpaceViewModel.NodeToCodeCommand.CanExecute(null));

            DynamoSelection.Instance.ClearSelection();
            Assert.IsFalse(ViewModel.CurrentSpaceViewModel.NodeToCodeCommand.CanExecute(null));
        }
Beispiel #5
0
        public void PeriodicEnabledWithPeriodicNodes()
        {
            var node = new DoubleInput {
                CanUpdatePeriodically = true
            };

            var homeSpace = GetHomeSpace();

            homeSpace.AddAndRegisterNode(node, true);

            var item = View.RunSettingsControl.RunTypesComboBox.Items[2] as RunTypeItem;

            Assert.True(item.Enabled);
        }
Beispiel #6
0
        /// <summary>
        /// Overrides <see cref="CADability.Actions.ConstructAction.OnSetAction ()"/>
        /// </summary>
        public override void OnSetAction()
        {
            base.TitleId = "Construct.ObjectPoint";
            // da oben static private, werden diese Variablen gemerkt. Beim ersten Mal vorbesetzen:
            if (ratio == 0)
            {
                ratio = 0.5;
            }
            if (ratioDist == 0)
            {
                ratioDist = 1;
            }

            gPoint = ActionFeedBack.FeedbackPoint(base.Frame);
            base.FeedBack.Add(gPoint);

            ratioCurveInput                             = new CurveInput("Construct.ObjectPoint.Curve");
            ratioCurveInput.Decomposed                  = true; // nur Einzelelemente, auch bei Polyline und Pfad
            ratioCurveInput.MouseOverCurvesEvent       += new CADability.Actions.ConstructAction.CurveInput.MouseOverCurvesDelegate(ratioCurve);
            ratioCurveInput.CurveSelectionChangedEvent += new CADability.Actions.ConstructAction.CurveInput.CurveSelectionChangedDelegate(ratioCurveChanged);

            ratioInput = new DoubleInput("Construct.ObjectPoint.Ratio");
            ratioInput.SetDoubleEvent     += new CADability.Actions.ConstructAction.DoubleInput.SetDoubleDelegate(OnSetRatio);
            ratioInput.Fixed               = true; // muss nicht eingegeben werden
            ratioInput.GetDoubleEvent     += new CADability.Actions.ConstructAction.DoubleInput.GetDoubleDelegate(OnGetRatio);
            ratioInput.ForwardMouseInputTo = ratioCurveInput;
            //			ratio = 0.5; // immer Standardwert

            ratioLength = new LengthInput("Construct.ObjectPoint.RatioLength");
            ratioLength.SetLengthEvent     += new LengthInput.SetLengthDelegate(OnSetRatioLength);
            ratioLength.GetLengthEvent     += new LengthInput.GetLengthDelegate(OnGetRatioLength);
            ratioLength.Fixed               = true; // muss nicht eingegeben werden
            ratioLength.ForwardMouseInputTo = ratioCurveInput;

            GeoPointInput measureText = new GeoPointInput("MeasurePoint");

            measureText.GetGeoPointEvent += new CADability.Actions.ConstructAction.GeoPointInput.GetGeoPointDelegate(GetMeasureText);
            // geht nur mit readOnly, da sonst die Mausbewegung den angezeigten Wert überschreibt
            measureText.ReadOnly = true;
            if (measure)
            {
                base.SetInput(ratioCurveInput, ratioInput, ratioLength, measureText);
            }
            else
            {
                base.SetInput(ratioCurveInput, ratioInput, ratioLength);
            }
            base.OnSetAction();
        }
            public CameraTestNode(State stateref, string name)
                : base(stateref, name)
            {
                _up          = new DoubleInput(this, "Up", Keys.Up, Buttons.DPadUp, PlayerIndex.One);
                _down        = new DoubleInput(this, "Down", Keys.Down, Buttons.DPadDown, PlayerIndex.One);
                _left        = new DoubleInput(this, "Left", Keys.Left, Buttons.DPadLeft, PlayerIndex.One);
                _right       = new DoubleInput(this, "Right", Keys.Right, Buttons.DPadRight, PlayerIndex.One);
                _zoomIn      = new DoubleInput(this, "ZoomIn", Keys.W, Buttons.LeftShoulder, PlayerIndex.One);
                _zoomOut     = new DoubleInput(this, "ZoomOut", Keys.S, Buttons.LeftTrigger, PlayerIndex.One);
                _rotateLeft  = new DoubleInput(this, "RotateLeft", Keys.A, Buttons.RightShoulder, PlayerIndex.One);
                _rotateRight = new DoubleInput(this, "RotateRight", Keys.D, Buttons.RightTrigger, PlayerIndex.One);

                _camera = new Camera(this, "Camera");
                _camera.View();
            }
Beispiel #8
0
        public void Defect_MAGN_847()
        {
            //Detail steps are here http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-847
            DynamoModel model    = ViewModel.Model;
            string      openPath = Path.Combine(GetTestDirectory(), @"core\DynamoDefects\Defect_MAGN_847.dyn");

            RunModel(openPath);
            AssertPreviewCount("2ea813c4-7729-45b5-b23b-d7a3377f0b31", 4);
            DoubleInput doubleInput = model.CurrentWorkspace.NodeFromWorkspace
                                          ("7eba96c0-4715-47f0-a874-01f1887ac465") as DoubleInput;

            doubleInput.Value = "6..8";
            RunCurrentModel();
            AssertPreviewCount("2ea813c4-7729-45b5-b23b-d7a3377f0b31", 3);
        }
Beispiel #9
0
        public void ParentNode_Enters_TemporaryState_Test()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 3);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 2);

            //Check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //freeze add node
            addNode.IsFrozen = true;
            
            // the add node must be frozen and not executing state
            Assert.AreEqual(addNode.IsFrozen, true);
           
            //freeze number node.
            numberNode1.IsFrozen = true;
           
            //change the value on number node 1
            numberNode1.Value = "3.0";

            // the number node must be frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, true);
            
            // the add node must be frozen and in a temporary state
            Assert.AreEqual(addNode.IsFrozen, true);
            
            //Since the add node is frozen, the value should not change
            AssertPreviewValue(addNode.GUID.ToString(), 3);
        }
        public void Node_InFreeze_ExecuteState_Test()
        {
            var model = ViewModel.Model;
            //create some numbers
            var numberNode1 = new DoubleInput();

            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();

            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output,
                                                                       DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input,
                                                                       DynamoModel.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output,
                                                                       DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input,
                                                                       DynamoModel.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 3);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 2);

            //Now Freeze the NumberNode1.
            numberNode1.IsFrozen = true;

            //Get the ViewModel of the number node and check the Freeze property.
            var numberNodevm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == numberNode1);

            Assert.IsNotNull(numberNodevm);
            Assert.AreEqual(numberNodevm.IsFrozenExplicitly, true);
            Assert.AreEqual(numberNodevm.CanToggleFrozen, true);

            //Get the ViewModel of add node and check the Freeze property. This node is a child node of numbernode1.
            //so this node should be in Frozen and Executing state.
            var addNodeVm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == addNode);

            Assert.IsNotNull(addNodeVm);
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, false);
        }
Beispiel #11
0
        public PlayerShip(Node parent, string name)
            : base(parent, name)
        {
            Body.X = EntityGame.Viewport.Width / 2f;
            Body.Y = EntityGame.Viewport.Height / 2f;

            Physics.Drag        = 0.97f;
            Physics.AngularDrag = 0.9f;

            Render = new ImageRender(this, "Render");
            Render.SetTexture(GetRoot <State>().GetService <AssetCollector>().GetAsset <Texture2D>("ship"));
            Render.Layer = .01f;
            Render.Scale = new Vector2(.128f);
            Render.LinkDependency(ImageRender.DEPENDENCY_BODY, Body);

            Body.Bounds = Render.Bounds;
            Body.Origin = new Vector2(Render.Texture.Width / 2f, Render.Texture.Height / 2f);


            Gun = new SimpleGun(this, "SimpleGun");
            Gun.LinkDependency(SimpleGun.DEPENDENCY_BODY, Body);
            Gun.LinkDependency(SimpleGun.DEPENDENCY_PHYSICS, Physics);
            Shape        = new Circle(this, "Circle", Body.Width * .8f);
            Shape.Offset = new Vector2(Body.Width / 2, Body.Height / 2);
            Shape.Debug  = true;
            Shape.LinkDependency(Circle.DEPENDENCY_BODY, Body);

            Collision.Group.AddMask(0);
            Collision.Pair.AddMask(2);
            Collision.CollideEvent += OnCollide;
            Collision.Immovable     = true;
            Collision.LinkDependency(Collision.DEPENDENCY_SHAPE, Shape);
            Shape.LinkDependency(Circle.DEPENDENCY_COLLISION, Collision);


            //Control
            UpButton      = new DoubleInput(this, "UpButton", Keys.W, Buttons.DPadUp, PlayerIndex.One);
            DownButton    = new DoubleInput(this, "DownButton", Keys.S, Buttons.DPadDown, PlayerIndex.One);
            LeftButton    = new DoubleInput(this, "LeftButton", Keys.A, Buttons.DPadLeft, PlayerIndex.One);
            RightButton   = new DoubleInput(this, "RightButton", Keys.D, Buttons.DPadRight, PlayerIndex.One);
            FireButton    = new DoubleInput(this, "FireButton", Keys.Space, Buttons.A, PlayerIndex.One);
            ThrustTrigger = new GamePadTrigger(this, "ThrustTrigger", Triggers.Right, PlayerIndex.One);
            //GravityTrigger = new GamePadTrigger(this, "GravityTrigger", Triggers.Left, PlayerIndex.One);

            LookAnalog = new GamePadAnalog(this, "LookAnalog", Sticks.Left, PlayerIndex.One);
        }
        public override void Start()
        {
            base.Start();
            var menuparser = new XmlParser(@"States/Menu/menu.xml");

            _bgimage = new Image(this, "BGImage");
            _bgimage.ParseXml(menuparser, "Menu->BGImage");
            AddEntity(_bgimage);

            _starttext = new Text(this, "StartText");
            _starttext.ParseXml(menuparser, "Menu->StartText");
            float x = GameRef.Viewport.Width / 2 - _starttext.TextRender.DrawRect.Width / 2;
            _starttext.Body.Position = new Vector2(x, 500);
            AddEntity(_starttext);

            _startkey = new DoubleInput(null, "StartKey", Keys.Enter, Buttons.Start, PlayerIndex.One);
        }
Beispiel #13
0
        public Town(EntityState es, XmlParser xp)
            : base(es, "Town")
        {
            Body = new Body(this, "Body");
            AddComponent(Body);

            TileRender = new TileRender(this, "TileRender");
            AddComponent(TileRender);

            DeadCityAnim = new Animation(this, "DeadCityAnim");
            AddComponent(DeadCityAnim);

            Collision = new Collision(this, "Collision");
            AddComponent(Collision);

            Health = new Health(this, "Health");
            AddComponent(Health);

            Gun = new Gun(this, "Gun");
            AddComponent(Gun);

            Targets = new Targets(this, "Targets");
            AddComponent(Targets);

            _firebombsound = new Sound(this, "FireBombSound");
            AddComponent(_firebombsound);

            _firekey = new DoubleInput(this, "FireKey", Keys.Enter, Buttons.A, PlayerIndex.One);
            AddComponent(_firekey);

            _debugkey = new DoubleInput(this, "DebugKey", Keys.Tab, Buttons.B, PlayerIndex.One);
            AddComponent(_debugkey);

            ParseXml(xp, "GameState->" + Name);

            //Add our custom data here.
            Body.Position.X = StateRef.GameRef.Viewport.Width / 2 - TileRender.DrawRect.Width / 2;

            //Set our rotation origins
            TileRender.Origin = new Vector2(TileRender.TileSize.X / 2f, TileRender.TileSize.Y / 2f);
            DeadCityAnim.Origin = TileRender.Origin;

            //TODO: Health.Hurtevent changes color
            Cursor = new Cursor(es, this, xp);
            es.AddEntity(Cursor);
        }
Beispiel #14
0
            public FancyNode(Node parent, string name)
                : base(parent, name)
            {
                MouseBody               = new Body(this, "MouseBody");
                AutoBody                = new Body(this, "AutoBody");
                FancySpawnerMouse       = new FancySpawner(this, "FancySpawnerMouse", MouseBody);
                FancySpawnerMouse.Color = Color.Red;

                FancySpawnerAuto       = new FancySpawner(this, "FancySpawnerAuto", AutoBody);
                FancySpawnerAuto.Color = Color.Blue;

                _spawnTimer = new Timer(this, "SpwnTimer");
                _spawnTimer.Milliseconds = 25;
                _spawnTimer.LastEvent   += () => FancySpawnerAuto.Emit(1);
                _spawnTimer.Start();

                _emitkey = new DoubleInput(this, "emitkey", Keys.Space, Buttons.A, PlayerIndex.One);
            }
        public void Node_InFreeze_ExecuteState_Test()
        {
            var model = ViewModel.Model;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output,
                DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input,
                DynamoModel.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output,
                DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input,
                DynamoModel.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 3);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 2);

            //Now Freeze the NumberNode1.
            numberNode1.IsFrozen = true;
           
            //Get the ViewModel of the number node and check the Freeze property.
            var numberNodevm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == numberNode1);
            Assert.IsNotNull(numberNodevm);
            Assert.AreEqual(numberNodevm.IsFrozenExplicitly, true);
            Assert.AreEqual(numberNodevm.CanToggleFrozen, true);

            //Get the ViewModel of add node and check the Freeze property. This node is a child node of numbernode1.
            //so this node should be in Frozen and Executing state.
            var addNodeVm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == addNode);
            Assert.IsNotNull(addNodeVm);
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, false);
        }
Beispiel #16
0
        private void OnClone(object sender, EventArgs e)
        {
            DoubleInput cloneForm = new DoubleInput();

            cloneForm.Text = "Clone remote repository";

            cloneForm.label1.Text = "Remote Url";
            cloneForm.label2.Text = "Local Path";

            cloneForm.input2.Cursor   = Cursors.Hand;
            cloneForm.input2.Text     = "Click me !";
            cloneForm.input2.ReadOnly = true;
            cloneForm.input2.Click   += (ed, eg) =>
            {
                if (cloneForm.input1.Text == "")
                {
                    MessageBox.Show("No remote url found");
                    return;
                }
                FolderBrowserDialog folder = new FolderBrowserDialog();
                DialogResult        res    = folder.ShowDialog();
                if (res == DialogResult.OK || res == DialogResult.Yes)
                {
                    Uri    uri  = new Uri(cloneForm.input1.Text);
                    string name = uri.Segments[uri.Segments.Length - 1].TrimEnd('/').Split('.')[0];
                    cloneForm.input2.Text = Path.Combine(@folder.SelectedPath, name);
                }
            };

            cloneForm.Show();

            cloneForm.ConfirmEvent += async(sd, url, path) =>
            {
                LoadingForm loadingForm = new LoadingForm();
                loadingForm.Show(ActiveCanvas.FindForm());
                await Task.Run(() => CloneRepository(url, path));

                loadingForm.Close();
                cloneForm.Close();
                Uri    uri  = new Uri(url);
                string name = uri.Segments[uri.Segments.Length - 1].TrimEnd('/').Split('.')[0];
                MessageBox.Show(string.Format("{0} is Cloned to {1}", name, path));
            };
        }
Beispiel #17
0
        private void OnDocumentCommit(object sender, EventArgs e)
        {
            if (getSignature() == null)
            {
                MessageBox.Show(string.Format("Please tell git who you are!"));
                DoubleInput conform = new DoubleInput();
                conform.Show(ActiveCanvas.FindForm());
                return;
            }
            if (ActiveCanvas.Document == null)
            {
                return;
            }
            bool isModified = ActiveCanvas.Document.IsModified;

            if (isModified)
            {
                MessageBox.Show(string.Format("Please save this document first!"));
            }
            else
            {
                string     docPath    = ActiveCanvas.Document.FilePath;
                CommitForm commitForm = new CommitForm(docPath);
                try
                {
                    using (var repo = new Repository(getWorkDir(docPath)))
                    {
                        if (!repo.RetrieveStatus().IsDirty)
                        {
                            MessageBox.Show("Nothing To Commit !");
                        }
                        else
                        {
                            commitForm.Show(ActiveCanvas.FindForm());
                        }
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #18
0
        public override void Initialize()
        {
            base.Initialize();

            _currentTest = new CircleTest1(this, "CircleTest1");
            _currentTest.Initialize();

            _beginTest = new DoubleInput(this, "BeginTest", Keys.Space, Buttons.Start, PlayerIndex.One);
            _nextTest  = new DoubleInput(this, "NextTest", Keys.Right, Buttons.RightShoulder, PlayerIndex.One);
            _lastTest  = new DoubleInput(this, "LastTest", Keys.Left, Buttons.LeftShoulder, PlayerIndex.One);
            _resetTest = new DoubleInput(this, "ResetLink", Keys.Q, Buttons.X, PlayerIndex.One);

            Page p = new Page(this, "Page");

            p.Show();

            _titleLabel               = new Label(p, "TitleLabel", new Point(0, 0));
            _titleLabel.Text          = _currentTest.Title;
            _titleLabel.Body.Position = new Vector2(2, 2);

            _descriptionLabel               = new Label(p, "DescriptionLabel", new Point(0, 1));
            _descriptionLabel.Text          = _currentTest.Description;
            _descriptionLabel.Body.Position = new Vector2(2, EntityGame.Viewport.Height - _descriptionLabel.Render.Bounds.Y - 2);

            //Init tests
            _tests.Add(_currentTest);
            _tests.Add(new CircleTest2(this, "CircleTest2"));
            _tests.Add(new CircleTest3(this, "CircleTest3"));
            _tests.Add(new CircleTest4(this, "CircleTest4"));
            _tests.Add(new CircleTest5(this, "CirlceTest5"));
            _tests.Add(new CircleTest6(this, "CirlceTest6"));
            _tests.Add(new CircleTest7(this, "CirlceTest7"));
            _tests.Add(new CircleTest8(this, "CirlceTest8"));
            _tests.Add(new CircleTest9(this, "CirlceTest9"));
            _tests.Add(new CircleTest10(this, "CirlceTest10"));

            _tests.Add(new AABBTest1(this, "AABBTest1"));
            _tests.Add(new AABBTest2(this, "AABBTest2"));
            _tests.Add(new AABBTest3(this, "AABBTest3"));
            _tests.Add(new AABBTest4(this, "AABBTest4"));
        }
        private void spinEdit_WorldSC_EditValueChanged(object sender, EventArgs e)
        {
            ucSingleDrawImageWnd c = DrawHandle as ucSingleDrawImageWnd;

            if (c == null || m_worldSC == null)
            {
                return;
            }

            DoubleInput edit = sender as DoubleInput;

            switch (edit.Tag.ToString())
            {
            case "1X": m_worldSC[0].X = Convert.ToInt32(edit.Value); break;

            case "1Y": m_worldSC[0].Y = Convert.ToInt32(edit.Value); break;

            case "2X": m_worldSC[1].X = Convert.ToInt32(edit.Value); break;

            case "2Y": m_worldSC[1].Y = Convert.ToInt32(edit.Value); break;

            case "3X": m_worldSC[2].X = Convert.ToInt32(edit.Value); break;

            case "3Y": m_worldSC[2].Y = Convert.ToInt32(edit.Value); break;

            case "4X": m_worldSC[3].X = Convert.ToInt32(edit.Value); break;

            case "4Y": m_worldSC[3].Y = Convert.ToInt32(edit.Value); break;

            case "5X": m_worldSC[4].X = Convert.ToInt32(edit.Value); break;

            case "5Y": m_worldSC[4].Y = Convert.ToInt32(edit.Value); break;

            case "6X": m_worldSC[5].X = Convert.ToInt32(edit.Value); break;

            case "6Y": m_worldSC[5].Y = Convert.ToInt32(edit.Value); break;

            default:
                break;
            }
        }
        public void NewCustomNodeSaveAndLoadPt1()
        {
            var funcguid = GuidUtility.Create(GuidUtility.UrlNamespace, "NewCustomNodeSaveAndLoad");
            //first create a new custom node.
            var ws       = this.ViewModel.Model.CustomNodeManager.CreateCustomNode("testnode", "testcategory", "atest", funcguid);
            var outnode1 = new Output();

            outnode1.Symbol = "out1";
            var outnode2 = new Output();

            outnode2.Symbol = "out2";

            var numberNode = new DoubleInput();

            numberNode.Value = "5";


            ws.AddAndRegisterNode(numberNode);
            ws.AddAndRegisterNode(outnode1);
            ws.AddAndRegisterNode(outnode2);

            new ConnectorModel(numberNode.OutPorts.FirstOrDefault(), outnode1.InPorts.FirstOrDefault(), Guid.NewGuid());
            new ConnectorModel(numberNode.OutPorts.FirstOrDefault(), outnode2.InPorts.FirstOrDefault(), Guid.NewGuid());

            var saveDir = Path.Combine(Path.GetTempPath(), "NewCustomNodeSaveAndLoad");

            System.IO.Directory.CreateDirectory(saveDir);

            var savePath = Path.Combine(saveDir, "NewCustomNodeSaveAndLoad.dyf");

            if (File.Exists(savePath))
            {
                File.Delete(savePath);
            }
            //save it to a temp location so that we can safely load it in NewCustomNodeSaveAndLoadPt2
            ws.Save(savePath);

            //assert the filesaved
            Assert.IsTrue(File.Exists(savePath));
            Assert.IsFalse(string.IsNullOrEmpty(File.ReadAllText(savePath)));
        }
Beispiel #21
0
        public void CanRestoreStateInGraphThatIsMissingNodes()
        {
            var         nodes       = SetupNumberNodesAndPresets();
            var         model       = CurrentDynamoModel;
            var         numberNode1 = nodes[0];
            DoubleInput numberNode2 = nodes[1] as DoubleInput;

            model.CurrentWorkspace.RemoveNode(numberNode1);

            //now restore state to state 1
            Assert.DoesNotThrow(() =>
            {
                model.CurrentWorkspace.ApplyPreset(model.CurrentWorkspace.Presets.Where(
                                                       x => x.Name == "state1").First());
            });

            //now check that numbernode2 has been set to correct value in state 1
            Assert.AreEqual(numberNode2.Value, "2");
            //check that node 1 has actually been deleted
            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 2);
        }
Beispiel #22
0
        public override void OnSetAction()
        {
            base.ActiveObject = Face.Construct();
            handed            = true;

            if (axisVector.IsNullVector())
            {
                axisVector = GeoVector.XAxis;
            }
            if (angleRotation == 0.0)
            {
                angleRotation = Math.PI;
            }

            base.TitleId = "Constr.Face.ScrewPath";

            pathInput = new CurveInput("Constr.Face.ScrewPath.Path");
            //curveInput.MouseOverCurvesEvent += new CurveInput.MouseOverCurvesDelegate(curveInputPath);
            //curveInput.CurveSelectionChangedEvent += new CurveInput.CurveSelectionChangedDelegate(curveInputPathChanged);
            if (path != null || shape != null)
            {
                pathInput.Fixed = true;
            }

            rotateLineInput                       = new CurveInput("Constr.Face.ScrewPath.AxisLine");
            rotateLineInput.Decomposed            = true; // nur Einzelelemente, auch bei Polyline und Pfad
            rotateLineInput.MouseOverCurvesEvent += new CurveInput.MouseOverCurvesDelegate(mouseOverAxis);
            //rotateLineInput.CurveSelectionChangedEvent += new CurveInput.CurveSelectionChangedDelegate(RotateLineChanged);

            orientation = new MultipleChoiceInput("Constr.Face.ScrewPath.Orientation", "Constr.Face.ScrewPath.Orientation.Values", 0);
            orientation.SetChoiceEvent += Orientation_SetChoiceEvent;
            orientation.GetChoiceEvent += Orientation_GetChoiceEvent;
            numTurns = new DoubleInput("Constr.Face.ScrewPath.NumTurns", 2.5);
            turns    = 2.5;
            numTurns.GetDoubleEvent += NumTurns_GetDoubleEvent;
            numTurns.SetDoubleEvent += NumTurns_SetDoubleEvent;
            base.SetInput(pathInput, rotateLineInput, orientation, numTurns); // , axisPointInput, axisVectorInput);
            base.ShowAttributes = true;
            base.OnSetAction();
        }
Beispiel #23
0
        public void Freeze_Test_On_WatchNode()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();

            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();

            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            //add  a watch node
            var watchNode = new Watch();

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //check the watch node value
            AssertPreviewValue(watchNode.GUID.ToString(), 3);
        }
Beispiel #24
0
        public void Freeze_Test_On_WatchNode()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));
           
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            //add  a watch node
            var watchNode = new Watch();
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);
        
            //check the watch node value
            AssertPreviewValue(watchNode.GUID.ToString(), 3);
        }
Beispiel #25
0
        public void TestNewNodeFromSelectionCommandState()
        {
            Assert.IsFalse(ViewModel.CurrentSpaceViewModel.NodeFromSelectionCommand.CanExecute(null));

            var node = new DoubleInput();

            ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(node, false);
            ViewModel.Model.AddToSelection(node);
            Assert.IsTrue(ViewModel.CurrentSpaceViewModel.NodeFromSelectionCommand.CanExecute(null));

            var ws = ViewModel.Model.CustomNodeManager.Collapse(
                DynamoSelection.Instance.Selection.OfType <NodeModel>(),
                ViewModel.Model.CurrentWorkspace,
                true,
                new FunctionNamePromptEventArgs
            {
                Category    = "Testing",
                Description = "",
                Name        = "__CollapseTest2__",
                Success     = true
            });

            Assert.IsFalse(ViewModel.CurrentSpaceViewModel.NodeFromSelectionCommand.CanExecute(null));
        }
Beispiel #26
0
        public void TestDoubleInput()
        {
            var numNode = new DoubleInput { Value = "0.0", X = 400 };
            //To check if base Serialization method is being called

            //Assert initial values
            Assert.AreEqual(400, numNode.X);
            Assert.AreEqual("0.0", numNode.Value);

            //Serialize node and then change values
            XmlDocument xmlDoc = new XmlDocument();
            XmlElement serializedEl = numNode.Serialize(xmlDoc, SaveContext.Undo);
            numNode.X = 250;
            numNode.Value = "4";

            //Assert new changes
            Assert.AreEqual(250, numNode.X);
            Assert.AreEqual("4", numNode.Value);

            //Deserialize and aasert old values
            numNode.Deserialize(serializedEl, SaveContext.Undo);
            Assert.AreEqual(400, numNode.X);
            Assert.AreEqual("0.0", numNode.Value);
        }
        public override void Initialize()
        {
            base.Initialize();

            EntityGame.ShowDebugInfo   = true;
            EntityGame.BackgroundColor = Color.Gray;

            //Service init
            new MouseService(this);

            _upkey     = new DoubleInput(this, "UpKey", Keys.Up, Buttons.DPadUp, PlayerIndex.One);
            _downkey   = new DoubleInput(this, "DownKey", Keys.Down, Buttons.DPadDown, PlayerIndex.One);
            _leftkey   = new DoubleInput(this, "LeftKey", Keys.Left, Buttons.DPadLeft, PlayerIndex.One);
            _rightkey  = new DoubleInput(this, "RightKey", Keys.Right, Buttons.DPadRight, PlayerIndex.One);
            _selectkey = new DoubleInput(this, "SelectKey", Keys.Space, Buttons.A, PlayerIndex.One);

            _page = new Page(this, "Page");
            _page.Show();

            AddMenuItem("Game of Life", () => (new GameOfLifeState()).Show());
            AddMenuItem("Color Game of Life", () => (new ColorGameOfLifeState()).Show());
            AddMenuItem("Asteroids Game", () => (new AsteroidsGame()).Show());
            AddMenuItem("Tower Defence", () => (new TowerDefenceMenu()).Show());
            AddMenuItem("Particle Test State", () => (new ParticleTestState()).Show());
            AddMenuItem("Camera Test State", () => (new CameraTestState()).Show());
            AddMenuItem("Control Test State", () => (new ControlTestState()).Show());
            AddMenuItem("Spawn Test State", () => (new SpawnerTestState()).Show());
            AddMenuItem("Fancy Spawn Test State", () => (new FancySpawnerTestState()).Show());
            AddMenuItem("Collision Test State", () => (new CollisionTestState()).Show());
            AddMenuItem("Collision Tester State", () => (new CollisionResolutionTest()).Show());
            AddMenuItem("Resolution Test State", () => (new ResolutionTestState()).Show());
            AddMenuItem("Color Test State", () => (new ColorTestState()).Show());
            AddMenuItem("Render Test State", () => (new RenderTestState()).Show());
            AddMenuItem("Primitives Test State", () => (new PrimitiveTestState()).Show());
            _page.ProcessControls();
        }
Beispiel #28
0
        public void ConnectorModelConnectTest()
        {
            //Arrange
            var outnode1 = new Output();

            outnode1.Symbol = "out1";

            var outnode2 = new Output();

            outnode2.Symbol = "out2";

            var numberNode = new DoubleInput();

            numberNode.Value = "5";

            //Act
            //It passes as parameters the same out port (start and end the same port) to the Connect(PortModel p) method then it won't create the connection to end.
            var connector1 = new ConnectorModel(numberNode.OutPorts.FirstOrDefault(), numberNode.OutPorts.FirstOrDefault(), Guid.NewGuid());

            //It passes the second parameter (End) the output port then the Connect(PortModel p) method will try to connect an End port and it will fail
            var connector2 = new ConnectorModel(outnode2.InPorts.FirstOrDefault(), numberNode.OutPorts.FirstOrDefault(), Guid.NewGuid());

            //The outnode2.InPorts has already nodes connected then when calling the Connect(PortModel p) method will remove the port connected
            var connector3 = new ConnectorModel(numberNode.OutPorts.FirstOrDefault(), outnode2.InPorts.FirstOrDefault(), Guid.NewGuid());

            //Assert
            //The End will be null due that the connection from Start to End was not created (out port was passed to both parameters)
            Assert.IsNull(connector1.End);

            //The End will be null due that the connection from Start to End was not created (in port was passed to both parameters)
            Assert.IsNull(connector2.End);

            //It will create the connector from Start to End (removing the previous connected InPort).
            Assert.IsNotNull(connector3.Start);
            Assert.IsNotNull(connector3.End);
        }
Beispiel #29
0
        public override Empty UpdateDoubleState(DoubleInput input)
        {
            State.Double.Value = input.DoubleValue;

            return(new Empty());
        }
        public void doubleInputNodeWillNotAcceptIds()
        {
            var number = new DoubleInput();
            Model.AddNodeToCurrentWorkspace(number, true);
            DispatcherUtil.DoEvents();
            var nodeView = NodeViewWithGuid(number.GUID.ToString());
            nodeView.inputGrid.ChildrenOfType<DynamoTextBox>().First().Text = "start..end";
            DispatcherUtil.DoEvents();
            Assert.IsTrue(number.Value != "start..end");
            Assert.IsTrue(number.Value == "0");
            Assert.IsTrue(number.IsInErrorState);

        }
Beispiel #31
0
        public void Undo_Freeze_OnParentNode_Test()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));
            
            //add  a watch node
            var watchNode = new Watch() { X = 100, Y = 300 };
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //Record for undo.
            model.ExecuteCommand(
                    new DynCmd.UpdateModelValueCommand(
                        Guid.Empty, numberNode1.GUID, "IsFrozen",
                         numberNode1.IsFrozen.ToString()));

            numberNode1.IsFrozen = true;
           
            //Number nodes in frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, true);
           
            //add node in frozen and can execute state
            Assert.AreEqual(addNode.IsFrozen, true);
            
            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);
            Assert.AreEqual(Convert.ToInt32(watchNode.CachedValue), 3);

            //undo the freeze on numbernode1
            model.CurrentWorkspace.Undo();
          
            //Now change the value on number node1
            numberNode1.Value = "3.0";

            //now the first number node unfreeze mode.
            Assert.AreEqual(numberNode1.IsFrozen, false);
           
            //add node in normal state
            Assert.AreEqual(addNode.IsFrozen, false);
           
            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 5);
            AssertPreviewValue(watchNode.GUID.ToString(), 5);
        }        
Beispiel #32
0
 // Add a number node on workspace
 private void CreateNodeOnCurrentWorkspace()
 {
     // Create number node
     var numNode = new DoubleInput { X = 100, Y = 100 };
     ViewModel.Model.CurrentWorkspace.AddAndRegisterNode(numNode, true);
 }
Beispiel #33
0
        public void Unfreeze_ParentNode_MakesATemporaryStateNode_SwitchBackToPreviousState_Test()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            //add  a watch node
            var watchNode = new Watch() {X = 100, Y = 300};
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));
            
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //freeze add node
            addNode.IsFrozen = true;
           
            // the add node must be frozen and not executing state
            Assert.AreEqual(addNode.IsFrozen, true);
           
            //freeze number node.
            numberNode1.IsFrozen = true;
            
            // the number node must be frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, true);
            
            //change the value on number node 1
            numberNode1.Value = "3.0";

            // the add node must be frozen and in a temporary state
            Assert.AreEqual(addNode.IsFrozen, true);
           
            //check the value on add node.
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //now unfreeze number node.
            numberNode1.IsFrozen = false;
           
            //now number node is not frozen
            Assert.AreEqual(numberNode1.IsFrozen, false);

            //this causes the add node to switch back from temporary state
            //to frozen and not executing state
            Assert.AreEqual(addNode.IsFrozen, true);
            
            //check the value on add node. Add node is not executed in the run,
            // becuase the frozen nodes are removed from AST. So the value of add node
            // should be 0. But the cached value should be 3, which is from the previous execution.
            AssertPreviewValue(addNode.GUID.ToString(), 0);
            Assert.IsNotNull(addNode.CachedValue.Data);
            Assert.AreEqual(Convert.ToInt32(addNode.CachedValue.Data),3);
            Assert.AreEqual(Convert.ToInt32(watchNode.CachedValue), 3);
        }
Beispiel #34
0
        public void Node_AttachedTThatHasParents_ShouldNotUnfreeze_UntilAllParentsUnfreeze_Test()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            //add  a watch node
            var watchNode = new Watch() { X = 100, Y = 300 };
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            //check the value.
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //now freeze both the number nodes.
            numberNode1.IsFrozen = true;
          
            numberNode2.IsFrozen = true;
           
            //Number nodes in frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, true);
            
            Assert.AreEqual(numberNode2.IsFrozen, true);
           
            //change the value of number nodes
            numberNode1.Value = "3.0";
            numberNode2.Value = "3.0";

            //add node in frozen and can execute state
            Assert.AreEqual(addNode.IsFrozen, true);
            
            //addnode should not change the value.
            AssertPreviewValue(addNode.GUID.ToString(), 3);
            Assert.AreEqual(Convert.ToInt32(watchNode.CachedValue),3);

            //unfreeze one of the number node          
            numberNode1.IsFrozen = false;
           
            //Number nodes in frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, false);
            
            Assert.AreEqual(numberNode2.IsFrozen, true);
            
            //add node should still be in frozen and can execute state
            Assert.AreEqual(addNode.IsFrozen, true);
                      
            //now unfreeze the other node.
            numberNode2.IsFrozen = false;
            
            Assert.AreEqual(numberNode2.IsFrozen, false);
           
            //now the add node should not be in frozen state
            Assert.AreEqual(addNode.IsFrozen, false);
            
            //addnode should change the value now.
            AssertPreviewValue(addNode.GUID.ToString(), 6);
            AssertPreviewValue(watchNode.GUID.ToString(), 6);
        }
Beispiel #35
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            switch (criptareToolStripMenuItem.Text)
            {
            case "Greek":
                SimpleInput simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.GREEK, new object[] { simpleInput.txtKey.Text });
                }
                break;

            case "Caesar":
                simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.CAESAR, new object[] { simpleInput.txtKey.Text });
                }
                break;

            case "Playfair":
                simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.PLAYFAIR, new object[] { simpleInput.txtKey.Text });
                }
                break;

            case "ADFGVX":
                DoubleInput doubleInput = new DoubleInput();
                if (doubleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.ADFGVX, new object[] { doubleInput.txtKey1.Text, doubleInput.txtKey2.Text });
                }
                break;

            case "Homophonic":
                txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.HOMOPHONIC, new object[] { });
                break;

            case "Enigma":
                simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.ENIGMA, new object[] { simpleInput.txtKey.Text });
                }
                break;

            // TODO: add message for DES
            case "RSA":
                MessageBox.Show("In the next dialog, select number of bits for the key.");
                simpleInput = new SimpleInput();
                if (simpleInput.ShowDialog() == DialogResult.OK)
                {
                    txtNormal.Text = EncryptionHelper.Decrypt(txtEncrypt.Text, EncryptionHelper.EncryptionMode.RSA, new object[] { simpleInput.txtKey.Text });
                }
                break;

            default:
                MessageBox.Show("Select encryption mode from menu.");
                break;
            }
        }
        public void Node_InTemporaryFreeze_State()
        {
            var model = ViewModel.Model;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output,
                DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input,
                DynamoModel.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output,
                DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input,
                DynamoModel.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 3);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 2);

            //Now Freeze the add node. This node has two input nodes. Note that
            //input nodes are not frozen.
            addNode.IsFrozen = true;
           
            //Get the ViewModel of add node and check the Freeze property.
            //This node should be in Frozen and not Executing state.
            var addNodeVm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == addNode);
            Assert.IsNotNull(addNodeVm);
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, true);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, true);

            //Now freeze NumberNode1.
            numberNode1.IsFrozen = true;
           
            //Get the ViewModel of add node and check the Freeze property.
            //This node should be in Frozen and not Executing state.
            var numberNode1Vm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == numberNode1);
            Assert.IsNotNull(numberNode1Vm);
            Assert.AreEqual(numberNode1Vm.IsFrozenExplicitly, true);
            Assert.AreEqual(numberNode1Vm.CanToggleFrozen, true);

            //Now check the add node. Freeze property will be unchecked and disabled.
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, true);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, false);
        }
Beispiel #37
0
        public void Unfreeze_ParentNode_MakesATemporaryStateNode_SwitchBackToPreviousState_Test()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            //add  a watch node
            var watchNode = new Watch() {X = 100, Y = 300};
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));
            
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //freeze add node
            addNode.IsFrozen = true;
           
            // the add node must be frozen and not executing state
            Assert.AreEqual(addNode.IsFrozen, true);
           
            //freeze number node.
            numberNode1.IsFrozen = true;
            
            // the number node must be frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, true);
            
            //change the value on number node 1
            numberNode1.Value = "3.0";

            // the add node must be frozen and in a temporary state
            Assert.AreEqual(addNode.IsFrozen, true);
           
            //check the value on add node.
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //now unfreeze number node.
            numberNode1.IsFrozen = false;
           
            //now number node is not frozen
            Assert.AreEqual(numberNode1.IsFrozen, false);

            //this causes the add node to switch back from temporary state
            //to frozen and not executing state
            Assert.AreEqual(addNode.IsFrozen, true);
            
            // For the new model, as freezing a node is equivallent to delete
            // a node, the node will be nullified.
            //
            // On the UI, the node may choose to display the same previous
            // value as before, but its real value *should* have been changed.
            AssertPreviewValue(addNode.GUID.ToString(), 0);
            Assert.IsNull(addNode.CachedValue.Data);
        }
        public void loadQueryControl(List <BaseReportField> fieldList)
        {
            this.panelQueryControl.Controls.Clear();
            List <BaseReportField> _fieldList = fieldList.FindAll(x => x.UiType > 0).OrderBy(x => x.SortId).ToList();

            int maxheight = 0;;

            for (int i = 0; i < _fieldList.Count; i++)
            {
                Label lab = new Label();
                lab.Text      = _fieldList[i].Name;
                lab.TextAlign = ContentAlignment.MiddleRight;
                lab.Width     = 100;


                Control txt = null;
                if (_fieldList[i].UiType == 1)
                {
                    txt = new TextBox();
                }
                else if (_fieldList[i].UiType == 2)
                {
                    txt = new DateTimePicker();
                }
                else if (_fieldList[i].UiType == 3)
                {
                    txt = new IntegerInput();
                }
                else if (_fieldList[i].UiType == 4)
                {
                    txt = new DoubleInput();
                }
                else if (_fieldList[i].UiType == 5)
                {
                    txt = new ComboBox();
                    int unitId = 0;
                    if (_fieldList[i].DataUnitId == null || _fieldList[i].DataUnitId == "")
                    {
                        unitId = -1;
                    }
                    else
                    {
                        unitId = Convert.ToInt32(_fieldList[i].DataUnitId);
                    }
                    ((ComboBox)txt).DataSource    = InvokeController("GetComboData", unitId, _fieldList[i].DynamicSQL);
                    ((ComboBox)txt).DisplayMember = "name";
                    ((ComboBox)txt).ValueMember   = "code";
                }
                else if (_fieldList[i].UiType == 6)
                {
                    txt = new CheckBox();
                }
                txt.Width = 200;
                txt.Tag   = _fieldList[i];

                if (i % 2 == 0)
                {
                    lab.Location = new Point(0, 15 * i + 5);
                    txt.Location = new Point(100, 15 * i + 5);
                }
                else
                {
                    lab.Location = new Point(300, 15 * (i - 1) + 5);
                    txt.Location = new Point(400, 15 * (i - 1) + 5);
                }

                maxheight = 15 * i + 30;
                panelQueryControl.Controls.Add(lab);
                panelQueryControl.Controls.Add(txt);
            }
            splitContainer2.SplitterDistance = maxheight;
            panelQueryControl.Refresh();
        }
        private void CreateAndConnectNodes()
        {
            var model = CurrentDynamoModel;
            //create a number
            var numberNode = new DoubleInput();
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode, 0, 0, true, false));

            //add  a watch node
            var watchNode = new Watch();
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 2);

            numberNode.IsFrozen = true;
            Assert.IsTrue(numberNode.isFrozenExplicitly);
            Assert.IsFalse(watchNode.IsFrozen);

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 1);

            // check if watch node freeze state is updated
            var msg = "End node freeze state has not been updated";
            Assert.IsTrue(watchNode.IsFrozen, msg);
            Assert.IsFalse(watchNode.isFrozenExplicitly, msg); 
        }
        public void Undo_Freeze_Test()
        {
            var model = ViewModel.Model;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output,
                DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input,
                DynamoModel.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output,
                DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input,
                DynamoModel.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 3);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 2);

            var addNodeVm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == addNode);
            Assert.IsNotNull(addNodeVm);

            var numberNode1Vm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == numberNode1);
            Assert.IsNotNull(numberNode1Vm);

            var numberNode2Vm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == numberNode2);
            Assert.IsNotNull(numberNode2Vm);

            //freeze number node1.            
            numberNode1Vm.ToggleIsFrozenCommand.Execute(null);

            Assert.AreEqual(numberNode1Vm.IsFrozenExplicitly, true);
            Assert.AreEqual(numberNode1Vm.CanToggleFrozen, true);

            //add node is in frozen executing state
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, false);

            //freeze number node2
            numberNode2Vm.ToggleIsFrozenCommand.Execute(null);

            Assert.AreEqual(numberNode2Vm.IsFrozenExplicitly, true);
            Assert.AreEqual(numberNode2Vm.CanToggleFrozen, true);

            //add node is in frozen executing state
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, false);

            ViewModel.CurrentSpace.Undo();

            //numbernode2 unfreeze
            Assert.AreEqual(numberNode2Vm.IsFrozenExplicitly, false);
            Assert.AreEqual(numberNode2Vm.CanToggleFrozen, true);

            //add node is in frozen executing state
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, false);

            ViewModel.CurrentSpace.Undo();

            //numbernode1 unfreeze
            Assert.AreEqual(numberNode1Vm.IsFrozenExplicitly, false);
            Assert.AreEqual(numberNode1Vm.CanToggleFrozen, true);

            //add node is in normal state
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, true);

        }
Beispiel #41
0
        public void Unfreeze_ParentNode_MakesATemporaryStateNode_SwitchBackToPreviousState_Test()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();

            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();

            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            //add  a watch node
            var watchNode = new Watch()
            {
                X = 100, Y = 300
            };

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //freeze add node
            addNode.IsFrozen = true;

            // the add node must be frozen and not executing state
            Assert.AreEqual(addNode.IsFrozen, true);

            //freeze number node.
            numberNode1.IsFrozen = true;

            // the number node must be frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, true);

            //change the value on number node 1
            numberNode1.Value = "3.0";

            // the add node must be frozen and in a temporary state
            Assert.AreEqual(addNode.IsFrozen, true);

            //check the value on add node.
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //now unfreeze number node.
            numberNode1.IsFrozen = false;

            //now number node is not frozen
            Assert.AreEqual(numberNode1.IsFrozen, false);

            //this causes the add node to switch back from temporary state
            //to frozen and not executing state
            Assert.AreEqual(addNode.IsFrozen, true);

            // For the new model, as freezing a node is equivallent to delete
            // a node, the node will be nullified.
            //
            // On the UI, the node may choose to display the same previous
            // value as before, but its real value *should* have been changed.
            AssertPreviewValue(addNode.GUID.ToString(), 0);
            Assert.IsNull(addNode.CachedValue.Data);
        }
Beispiel #42
0
        public void Node_AttachedTThatHasParents_ShouldNotUnfreeze_UntilAllParentsUnfreeze_Test()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();

            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();

            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            //add  a watch node
            var watchNode = new Watch()
            {
                X = 100, Y = 300
            };

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            //check the value.
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //now freeze both the number nodes.
            numberNode1.IsFrozen = true;

            numberNode2.IsFrozen = true;

            //Number nodes in frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, true);

            Assert.AreEqual(numberNode2.IsFrozen, true);

            //change the value of number nodes
            numberNode1.Value = "3.0";
            numberNode2.Value = "3.0";

            //add node in frozen and can execute state
            Assert.AreEqual(addNode.IsFrozen, true);

            //addnode should not change the value.
            AssertPreviewValue(addNode.GUID.ToString(), 3);
            Assert.AreEqual(Convert.ToInt32(watchNode.CachedValue), 3);

            //unfreeze one of the number node
            numberNode1.IsFrozen = false;

            //Number nodes in frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, false);

            Assert.AreEqual(numberNode2.IsFrozen, true);

            //add node should still be in frozen and can execute state
            Assert.AreEqual(addNode.IsFrozen, true);

            //now unfreeze the other node.
            numberNode2.IsFrozen = false;

            Assert.AreEqual(numberNode2.IsFrozen, false);

            //now the add node should not be in frozen state
            Assert.AreEqual(addNode.IsFrozen, false);

            //addnode should change the value now.
            AssertPreviewValue(addNode.GUID.ToString(), 6);
            AssertPreviewValue(watchNode.GUID.ToString(), 6);
        }
Beispiel #43
0
 private float?GetOptionalFloat(DoubleInput textbox, CheckBoxX checkBox)
 {
     return(checkBox.Checked ? (float?)textbox.Value : null);
 }
        public void Undo_Freeze_Test()
        {
            var model = ViewModel.Model;
            //create some numbers
            var numberNode1 = new DoubleInput();

            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();

            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output,
                                                                       DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input,
                                                                       DynamoModel.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output,
                                                                       DynamoModel.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input,
                                                                       DynamoModel.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 3);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 2);

            var addNodeVm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == addNode);

            Assert.IsNotNull(addNodeVm);

            var numberNode1Vm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == numberNode1);

            Assert.IsNotNull(numberNode1Vm);

            var numberNode2Vm = ViewModel.CurrentSpaceViewModel.Nodes.First(x => x.NodeLogic == numberNode2);

            Assert.IsNotNull(numberNode2Vm);

            //freeze number node1.
            numberNode1Vm.ToggleIsFrozenCommand.Execute(null);

            Assert.AreEqual(numberNode1Vm.IsFrozenExplicitly, true);
            Assert.AreEqual(numberNode1Vm.CanToggleFrozen, true);

            //add node is in frozen executing state
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, false);

            //freeze number node2
            numberNode2Vm.ToggleIsFrozenCommand.Execute(null);

            Assert.AreEqual(numberNode2Vm.IsFrozenExplicitly, true);
            Assert.AreEqual(numberNode2Vm.CanToggleFrozen, true);

            //add node is in frozen executing state
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, false);

            ViewModel.CurrentSpace.Undo();

            //numbernode2 unfreeze
            Assert.AreEqual(numberNode2Vm.IsFrozenExplicitly, false);
            Assert.AreEqual(numberNode2Vm.CanToggleFrozen, true);

            //add node is in frozen executing state
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, false);

            ViewModel.CurrentSpace.Undo();

            //numbernode1 unfreeze
            Assert.AreEqual(numberNode1Vm.IsFrozenExplicitly, false);
            Assert.AreEqual(numberNode1Vm.CanToggleFrozen, true);

            //add node is in normal state
            Assert.AreEqual(addNodeVm.IsFrozenExplicitly, false);
            Assert.AreEqual(addNodeVm.CanToggleFrozen, true);
        }
Beispiel #45
0
        public void UnFreeze_ParentNode_UnfreezesChildNodes_Test()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();
            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();
            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            //add  a watch node
            var watchNode = new Watch();
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            BeginRun();

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //Add the number node to selection and call Freeze state on the workspace.
            //this should freeze the number node.
            numberNode1.IsFrozen = true;
            
            // the number node must be frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, true);
            
            //the add node must be frozen and can execute state
            Assert.AreEqual(addNode.IsFrozen, true);
            
            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //check the watch node value
            AssertPreviewValue(watchNode.GUID.ToString(), 3);

            //now the number node1 is frozen. change the value.
            numberNode1.Value = "3.0";

            //check the value of add node. it should not change.
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //unfreeze the input node
            numberNode1.IsFrozen = false;
            
            Assert.AreEqual(numberNode1.IsFrozen, false);

            //Now the add node should be in unfreeze state
            Assert.AreEqual(addNode.IsFrozen, false);

            //Now the add node should get the value
            AssertPreviewValue(addNode.GUID.ToString(), 5);

            //check the watch node value
            AssertPreviewValue(watchNode.GUID.ToString(), 5);
        }
Beispiel #46
0
        public void AddPresetShouldSetDirtyFlag()

        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();

            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();

            numberNode2.Value = "2";

            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            //Check for Dirty flag
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, false);

            //add the nodes
            model.CurrentWorkspace.AddAndRegisterNode(numberNode1, false);
            model.CurrentWorkspace.AddAndRegisterNode(numberNode2, false);
            model.CurrentWorkspace.AddAndRegisterNode(addNode, false);

            //Check for Dirty flag
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, true);

            //Set the dirty flag to false. Mocking the save.
            model.CurrentWorkspace.HasUnsavedChanges = false;
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, false);

            //connect them up
            ConnectorModel.Make(numberNode1, addNode, 0, 0);
            ConnectorModel.Make(numberNode2, addNode, 0, 1);

            //Check for Dirty flag - After the connection the dirty flag should be set.
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, true);

            //Set the dirty flag to false. Mocking the save.
            model.CurrentWorkspace.HasUnsavedChanges = false;
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, false);

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 3);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 2);

            //create the first state with the numbers selected
            DynamoSelection.Instance.Selection.Add(numberNode1);
            DynamoSelection.Instance.Selection.Add(numberNode2);
            var ids = DynamoSelection.Instance.Selection.OfType <NodeModel>().Select(x => x.GUID).ToList();

            //create the preset from 2 nodes
            model.CurrentWorkspace.AddPreset(
                "state1",
                "3", ids);

            Assert.AreEqual(1, model.CurrentWorkspace.Presets.Count());

            //change values
            numberNode1.Value = "2";
            numberNode2.Value = "3";

            DynamoSelection.Instance.ClearSelection();
            DynamoSelection.Instance.Selection.Add(numberNode1);
            DynamoSelection.Instance.Selection.Add(numberNode2);
            ids = DynamoSelection.Instance.Selection.OfType <NodeModel>().Select(x => x.GUID).ToList();

            model.CurrentWorkspace.AddPreset(
                "state2",
                "5", ids);

            //Check for Dirty flag - After the Preset the dirty flag should be set.
            Assert.AreEqual(model.CurrentWorkspace.HasUnsavedChanges, true);
        }
Beispiel #47
0
        public void Undo_Freeze_OnParentNode_Test()
        {
            var model = CurrentDynamoModel;
            //create some numbers
            var numberNode1 = new DoubleInput();

            numberNode1.Value = "1";
            var numberNode2 = new DoubleInput();

            numberNode2.Value = "2";
            var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+"));

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false));
            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false));

            //connect them up
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            //add  a watch node
            var watchNode = new Watch()
            {
                X = 100, Y = 300
            };

            model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false));

            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin));
            model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End));

            Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4);
            Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3);

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);

            //Record for undo.
            model.ExecuteCommand(
                new DynCmd.UpdateModelValueCommand(
                    Guid.Empty, numberNode1.GUID, "IsFrozen",
                    numberNode1.IsFrozen.ToString()));

            numberNode1.IsFrozen = true;

            //Number nodes in frozen and not executing state
            Assert.AreEqual(numberNode1.IsFrozen, true);

            //add node in frozen and can execute state
            Assert.AreEqual(addNode.IsFrozen, true);

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 3);
            Assert.AreEqual(Convert.ToInt32(watchNode.CachedValue), 3);

            //undo the freeze on numbernode1
            model.CurrentWorkspace.Undo();

            //Now change the value on number node1
            numberNode1.Value = "3.0";

            //now the first number node unfreeze mode.
            Assert.AreEqual(numberNode1.IsFrozen, false);

            //add node in normal state
            Assert.AreEqual(addNode.IsFrozen, false);

            //check the value
            AssertPreviewValue(addNode.GUID.ToString(), 5);
            AssertPreviewValue(watchNode.GUID.ToString(), 5);
        }