예제 #1
0
        public void tDoubleDoRedo()
        {
            var hc = new HistoryController();

            var o = new DefaultNode(hc);

            o.Name = "testA";
            Assert.AreEqual("testA", o.Name);

            o.Name = "testB";
            Assert.AreEqual("testB", o.Name);

            o.Name = "testC";
            Assert.AreEqual("testC", o.Name);

            hc.Undo();
            Assert.AreEqual("testB", o.Name);

            hc.Undo();
            Assert.AreEqual("testA", o.Name);

            hc.Redo();
            Assert.AreEqual("testB", o.Name);

            hc.Redo();
            Assert.AreEqual("testC", o.Name);
        }
예제 #2
0
파일: Room.cs 프로젝트: MHDante/OrbitVR
        private void MakeItemGroups()
        {
            Node itemDef = DefaultNode.CreateClone(this);

            itemDef.addComponent(typeof(ItemPayload), true);
            itemDef.movement.active = false;

            var infos = Component.compInfos;

            foreach (Type t in infos.Keys)
            {
                Info info = infos[t];
                if ((info.compType & mtypes.item) != mtypes.item)
                {
                    continue;
                }
                if (t == typeof(ItemPayload))
                {
                    continue;
                }
                //if (info.userLevel == UserLevel.Developer || info.userLevel == UserLevel.Advanced) continue;
                Node nodeDef = itemDef.CreateClone(this);
                //nodeDef.addComponent(t, true);
                Component c = Node.MakeComponent(t, true, nodeDef);
                nodeDef.Comp <ItemPayload>().AddComponentItem(c);
                Groups.Items.AddGroup(new Group(this, nodeDef, t.ToString().LastWord('.') + " Item"));
            }
        }
예제 #3
0
        public void tGetHeirarcyDeep()
        {
            var testSlide    = new Slide();
            var testNodeA1   = new DefaultNode();
            var testNodeA2   = new DefaultNode();
            var testNodeA1A1 = new DefaultNode();
            var testNodeA1A2 = new DefaultNode();
            var testNodeA2A1 = new DefaultNode();
            var testNodeA2A2 = new DefaultNode();

            testSlide.AddChild(testNodeA1);
            testSlide.AddChild(testNodeA2);
            testNodeA1.AddChild(testNodeA1A1);
            testNodeA1.AddChild(testNodeA1A2);
            testNodeA2.AddChild(testNodeA2A1);
            testNodeA2.AddChild(testNodeA2A2);

            testNodeA1A2.Description = "test description";

            var testView = ViewFactory.Instance.GetHierarchy(testSlide);

            Assert.AreEqual(typeof(SlideView), testView.GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(0).GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(1).GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(0).GetChildViews().ElementAt(0).GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(1).GetChildViews().ElementAt(1).GetType());

            var testNode = testView.GetChildViews().ElementAt(0).GetChildViews().ElementAt(1);

            var ptestNode          = new PrivateObject(testNode);
            var descriptionControl = (DraggableLabel)ptestNode.GetField("dlDescription");

            // test that the description property of testNodeA1A2 was applied by GetHierarchy
            Assert.AreEqual("test description", descriptionControl.Text);
        }
예제 #4
0
        public void tHasCachedView_true()
        {
            var testNode = new DefaultNode();
            var testView = ViewFactory.Instance.GetView(testNode);

            Assert.IsTrue(ViewFactory.Instance.HasCachedView(testNode));
        }
예제 #5
0
#pragma warning restore 169

        // offer() occurs at the tail of the linked list.
        // poll() occurs at the head of the linked list.
        //
        // Resulting layout is:
        //
        //   head --next--> 1st element --next--> 2nd element --next--> ... tail (last element)
        //
        // where the head is a dummy node whose value is null.
        //
        // offer() appends a new node next to the tail using AtomicReference.getAndSet()
        // poll() removes head from the linked list and promotes the 1st element to the head,
        // setting its value to null if possible.
        //
        // Also note that this class : AtomicReference for the "tail" slot (which is the one that is appended to)
        // since Unsafe does not expose XCHG operation intrinsically.
        public MpscLinkedQueue()
        {
            MpscLinkedQueueNode <T> tombstone = new DefaultNode(default(T));

            this.HeadRef = tombstone;
            this.TailRef = tombstone;
        }
예제 #6
0
        public void tDefaultNodeView()
        {
            var testNode = new DefaultNode();

            var testView = (new ViewFactory()).GetView(testNode);

            Assert.AreEqual(typeof(DefaultNodeView), testView.GetType());
        }
예제 #7
0
 /// <summary>
 /// Ajoute les informations des noeuds à la liste des informations de monitoring des noeuds
 /// </summary>
 /// <param name="monitoringValues">Liste des informations de monitoring des noeuds</param>
 public void AddNodeToList(List <List <string> > monitoringValues)
 {
     foreach (List <string> nodeinfo in monitoringValues)
     {
         Logger.Write($"Ajout d'un node dans la liste ({nodeinfo[0]} - {nodeinfo[1]} - {nodeinfo[2]})");
         DefaultNode n = new DefaultNode(nodeinfo[0], nodeinfo[1], Convert.ToInt32(nodeinfo[2]), false);
         Application.Current.Dispatcher.Invoke(() => ViewModelLocator.VmlMonitorUcStatic.NodeList.Add(n));
     }
 }
예제 #8
0
        public void tGetHierarchy()
        {
            var testSlide = new Slide();
            var testNode  = new DefaultNode();

            testSlide.AddChild(testNode);

            var testView = ViewFactory.Instance.GetHierarchy(testSlide);

            Assert.AreEqual(typeof(SlideView), testView.GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(0).GetType());
        }
예제 #9
0
        public void tRestore()
        {
            var testNode = new DefaultNode {
                Name = "testA"
            };
            var memento = testNode.GetMemento("Name");

            testNode.Name = "testB";
            Assert.AreEqual("testB", testNode.Name);

            memento.Restore();
            Assert.AreEqual("testA", testNode.Name);
        }
예제 #10
0
        public ExtendedPort(string name, PortTypes portType, Type type, VplControl.Core.VplControl hostCanvas, Guid id = new Guid())
            : base(name, portType, type, hostCanvas)
        {
            // DefaultNode for the handling in the mainHostCanvas --> Checking the parentNode which should not be null
            ParentNode = new DefaultNode(hostCanvas);

            // Check (Create a Guid for the Port)
            if (id == Guid.Empty)
            {
                Id = Guid.NewGuid();
            }

            // UI
            PopupGrid = new Grid
            {
                Background          = Brushes.Transparent,
                Opacity             = 1,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(2)
            };

            PopupBorder = new Border
            {
                Background      = Brushes.White,
                CornerRadius    = new CornerRadius(5),
                BorderBrush     = new SolidColorBrush(Colors.DarkGray),
                BorderThickness = new Thickness(2),
                Padding         = new Thickness(10)
            };

            // Then add your border to the grid
            PopupGrid.Children.Add(PopupBorder);

            popup = new Popup
            {
                Child              = PopupGrid,
                PlacementTarget    = this,
                PopupAnimation     = PopupAnimation.Fade,
                AllowsTransparency = true,
                ClipToBounds       = true,
            };

            // Turn off the Toolips
            ToolTip = null;

            MouseDown += OnMouseDown;

            MouseEnter           += PortOnMouseEnter;
            MouseLeave           += PortOnMouseLeave;
            PopupGrid.MouseLeave += PopupGridOnMouseLeave;
        }
예제 #11
0
        private void cmNewDefaultNode_Click(object sender, RoutedEventArgs e)
        {
            var location = Mouse.GetPosition(cvsMain);
            var newNode  = new DefaultNode {
                Location = location,
                Size     = new Size {
                    Width  = 200,
                    Height = 200
                }
            };

            Model.AddChild(newNode);
            AddChildView(ViewFactory.Instance.GetView <DefaultNodeView>(newNode), location);
        }
        public SBUIDesigner()
        {
            InitializeComponent();

            treeView.HideSelection = false;

            nodeManager = new SBUINodeManager();

            //uiAddMenu = new ContextMenuStrip();
            //ToolStripMenuItem addItem = new ToolStripMenuItem("Add");
            //uiAddMenu.Items.Add(addItem);

            //root = new TreeNode("GUI");
            //treeView.Nodes.Add(root);
            //treeView.MouseClick += TreeView_MouseClick;
            //treeView.MouseDoubleClick += TreeView_MouseDoubleClick;

            List <Node> gui      = new List <Node>();
            Node        rootNode = new DefaultNode("GUI");

            gui.Add(rootNode);
            rootNode.Children.Add(new DefaultNode("Some test"));
            Node childNode = new DefaultNode("Another one");

            rootNode.Children.Add(childNode);
            childNode.Children.Add(new DefaultNode("LOLOL"));

            nodeManager.Nodes = gui;

            JsonSerializer serializer = JsonSerializer.CreateDefault();

            serializer.Formatting = Formatting.Indented;
            serializer.MetadataPropertyHandling = MetadataPropertyHandling.Default;
            serializer.TypeNameHandling         = TypeNameHandling.Auto;

            //Code = serializer.Serialize()
            //Code = JsonConvert.SerializeObject(gui);

            UpdateUI();

            nodeChooser.Items.AddRange(new CBI[] {
                new CBI(new Nodes.Label("Label"), NodeToString),
                new CBI(new Nodes.Image("Image"), NodeToString)
            });
            nodeChooser.SelectedIndex = 0;
        }
예제 #13
0
        /// <summary>
        /// Méthode d'écoute par Socket asynchrone
        /// </summary>
        public async void Listen()
        {
            TcpListener listener = new TcpListener(IPAddress.Parse(Address), Port);

            listener.Start();
            Logger.Write($"Serveur en écoute sur le port {Port}");
            while (true)
            {
                Socket sock = await listener.AcceptSocketAsync();

                DefaultNode connectedNode = new DefaultNode("", ((IPEndPoint)sock.RemoteEndPoint).Address + "", ((IPEndPoint)sock.RemoteEndPoint).Port, sock);
                nbNodes++;
                Logger.Write($"Connexion acceptée depuis l'adresse {sock.RemoteEndPoint}");
                GetIdentityOfNode(connectedNode);
                Receive(connectedNode);
            }
        }
예제 #14
0
        /// <summary>
        /// Méthode d'identification de noeud lors d'une connexion entrante
        /// </summary>
        /// <param name="connectedNode"></param>
        private void GetIdentityOfNode(DefaultNode connectedNode)
        {
            int tId = LastTaskId;
            Tuple <int, Node> taskNodeTuple = new Tuple <int, Node>(tId, connectedNode);

            unidentifiedNodes.Add(taskNodeTuple);

            DataInput input = new DataInput()
            {
                Method   = IdentMethod,
                NodeGuid = NodeGuid,
                TaskId   = tId,
                Data     = new Tuple <string, int>(nbNodes.ToString(), connectedNode.Port),
                MsgType  = MessageType.Ident
            };

            SendData(connectedNode, input);
        }
예제 #15
0
        public bool Enqueue(T value)
        {
            MpscLinkedQueueNode <T> newTail;
            var node = value as MpscLinkedQueueNode <T>;

            if (node != null)
            {
                newTail      = node;
                newTail.Next = null;
            }
            else
            {
                newTail = new DefaultNode(value);
            }

            MpscLinkedQueueNode <T> oldTail = this.GetAndSetTailRef(newTail);

            oldTail.Next = newTail;
            return(true);
        }
예제 #16
0
        public void Tick()
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            if (CurrentNode != null)
            {
                var node = CurrentNode.Tick();
                CurrentNode = node;
            }
            else
            {
                CurrentNode = DefaultNode.Tick();
                nodeStack.Clear();
            }

            if (nodeStack.Count < 1 || nodeStack.Peek() != CurrentNode)
            {
                nodeStack.Push(CurrentNode);
            }
        }
예제 #17
0
파일: Room.cs 프로젝트: MHDante/OrbitVR
        private void MakePresetGroups()
        {
            var infos   = Component.compInfos;
            int runenum = 0;

            foreach (Type t in infos.Keys)
            {
                Info info = infos[t];
                if ((info.compType & mtypes.essential) == mtypes.essential)
                {
                    continue;
                }
                if ((info.compType & mtypes.exclusiveLinker) == mtypes.exclusiveLinker)
                {
                    continue;
                }
                if ((info.compType & mtypes.item) == mtypes.item)
                {
                    continue;
                }
                if (info.userLevel == UserLevel.Developer || info.userLevel == UserLevel.Advanced)
                {
                    continue;
                }
                if (t == typeof(Lifetime))
                {
                    continue;
                }
                if (t == typeof(Rune))
                {
                    continue;
                }
                Node nodeDef = DefaultNode.CreateClone(this);
                nodeDef.SetColor(Utils.randomColor());
                nodeDef.addComponent(t, true);
                nodeDef.addComponent(typeof(Rune), true);
                nodeDef.Comp <Rune>().runeTexture = (Textures)runenum++;
                Groups.Preset.AddGroup(new Group(this, nodeDef, t.ToString().LastWord('.') + " Group"));
            }
        }
예제 #18
0
 /// <summary>
 ///     Автонастройка
 /// </summary>
 public override void AutoTune()
 {
     base.AutoTune();
     if (null != DefaultNode)
     {
         DefaultNode.AutoTune();
     }
     if (null != DefaultEdge)
     {
         DefaultEdge.AutoTune();
     }
     foreach (var sg in SubGraphs)
     {
         sg.AutoTune();
     }
     foreach (var n in Nodes)
     {
         n.AutoTune();
     }
     foreach (var e in Edges)
     {
         e.AutoTune();
     }
 }
예제 #19
0
        public void tSerializer_historyController()
        {
            var hc              = new HistoryController();
            var filename        = @"c:\temp\tSerializer_HistoryController.xml";
            var slideCollection = new SlideCollection();
            var slide1          = new Slide {
                Name = "Slide1"
            };
            var slide2 = new Slide {
                Name = "Slide2"
            };
            var child1 = new DefaultNode {
                Name        = "child1",
                Description = "child1_description",
                Comment     = "child1_comment",
                Parent      = null
            };
            var child2 = new VisualNode {
                Name        = "child2",
                Description = "child2_description",
                Comment     = "child2_comment",
                Parent      = null
            };
            var child3 = new VisualNode {
                Name        = "child3",
                Description = "child3_description",
                Comment     = "child3_comment",
                Parent      = null
            };
            var child4 = new VisualNode {
                Name        = "child4",
                Description = "child4_description",
                Comment     = "child4_comment",
                Parent      = null
            };

            slideCollection.AddChild(slide1);
            slideCollection.AddChild(slide2);

            slide1.AddChild(child1);
            slide1.AddChild(child2);

            slide2.AddChild(child3);
            slide2.AddChild(child4);

            Serializer.Serialize(slideCollection, filename);
            var result = Serializer.DeSerialize(filename, hc);

            Assert.AreEqual(typeof(SlideCollection), result.GetType());
            var r = (SlideCollection)result;

            // The Parent properties of both slides in the slide collection should reference the
            // slide collection.
            var firstSlide  = r.Children[0];
            var secondSlide = r.Children[1];

            Assert.AreEqual(r.Guid, firstSlide.Parent.Guid);
            Assert.AreEqual(r.Guid, secondSlide.Parent.Guid);

            // The Parent properties of both children of the first slide should reference the
            // first slide.
            var firstChild  = firstSlide.Children[0];
            var secondChild = firstSlide.Children[1];

            Assert.AreEqual(firstSlide.Guid, firstChild.Parent.Guid);
            Assert.AreEqual(firstSlide.Guid, secondChild.Parent.Guid);

            // The Parent properties of both children of the secode slide should reference the
            // second slide.
            firstChild  = secondSlide.Children[0];
            secondChild = secondSlide.Children[1];
            Assert.AreEqual(secondSlide.Guid, firstChild.Parent.Guid);
            Assert.AreEqual(secondSlide.Guid, secondChild.Parent.Guid);

            firstChild.Name = "testA";
            Assert.AreEqual("testA", firstChild.Name);

            firstChild.Name = "testB";
            Assert.AreEqual("testB", firstChild.Name);

            hc.Undo();
            Assert.AreEqual("testA", firstChild.Name);

            hc.Redo();
            Assert.AreEqual("testB", firstChild.Name);
        }
예제 #20
0
        public void tHasCachedView_false()
        {
            var testNode = new DefaultNode();

            Assert.IsFalse(ViewFactory.Instance.HasCachedView(testNode));
        }
예제 #21
0
        public void tSerializer_DefaultNode()
        {
            var hc              = new HistoryController();
            var filename        = @"c:\temp\tSerializer_DefaultNode.xml";
            var slideCollection = new SlideCollection();
            var slide1          = new Slide {
                Name = "Slide1"
            };
            var child1 = new DefaultNode {
                Name        = "child1",
                Description = "child1_description",
                Comment     = "child1_comment",
                Background  = new System.Windows.Media.Color {
                    A = 1, B = 150, G = 160, R = 170
                },
                BorderType = BorderType.normal,
                Foreground = new System.Windows.Media.Color {
                    A = 1, R = 2, G = 3, B = 4
                },
                Location = new System.Windows.Point {
                    X = 1, Y = 2
                },
                ShapeType = ShapeType.rectangle,
                Size      = new System.Windows.Size {
                    Height = 1, Width = 2
                },
                Parent = null
            };

            slideCollection.AddChild(slide1);

            slide1.AddChild(child1);

            Serializer.Serialize(slideCollection, filename);
            var result = Serializer.DeSerialize(filename, hc);

            Assert.AreEqual(typeof(SlideCollection), result.GetType());
            var r = (SlideCollection)result;

            var Slide = r.Children[0];

            Assert.AreEqual(r.Guid, Slide.Parent.Guid);

            var tNode = (DefaultNode)Slide.Children[0];

            Assert.AreEqual(Slide.Guid, tNode.Parent.Guid);

            Assert.AreEqual("child1", tNode.Name);
            Assert.AreEqual("child1_description", tNode.Description);
            Assert.AreEqual("child1_comment", tNode.Comment);
            Assert.AreEqual(new System.Windows.Media.Color {
                A = 1, B = 150, G = 160, R = 170
            }, tNode.Background);
            Assert.AreEqual(BorderType.normal, tNode.BorderType);
            Assert.AreEqual(new System.Windows.Media.Color {
                A = 1, R = 2, G = 3, B = 4
            }, tNode.Foreground);
            Assert.AreEqual(new System.Windows.Point {
                X = 1, Y = 2
            }, tNode.Location);
            Assert.AreEqual(ShapeType.rectangle, tNode.ShapeType);
            Assert.AreEqual(new System.Windows.Size {
                Height = 1, Width = 2
            }, tNode.Size);
        }
예제 #22
0
 /// <summary>
 /// Set the currently viewed node
 /// </summary>
 /// <param name="node">The node to view</param>
 public void SetCurrentNode(DefaultNode node)
 {
     currentNode = node;
 }
예제 #23
0
        public void TestGenerics()
        {
            // Create the open class<T> which contains a List<T>

            GenericType genericClassArg = new GenericType("T");

            ClassGraph openClass = new ClassGraph();

            openClass.Name      = "OpenClass";
            openClass.Namespace = "Namespace";
            openClass.DeclaredGenericArguments.Add(genericClassArg);

            TypeSpecifier listType = TypeSpecifier.FromType(typeof(List <>));

            Assert.AreEqual(listType.GenericArguments.Count, 1);

            listType.GenericArguments[0] = genericClassArg;

            MethodGraph openMethod = new MethodGraph("OpenMethod");

            // Add open list parameter
            TypeNode listTypeNode = new TypeNode(openMethod, listType);

            openMethod.MainReturnNode.AddReturnType();
            GraphUtil.ConnectTypePins(listTypeNode.OutputTypePins[0], openMethod.MainReturnNode.InputTypePins[0]);

            DefaultNode defaultNode = new DefaultNode(openMethod);

            GraphUtil.ConnectTypePins(listTypeNode.OutputTypePins[0], defaultNode.TypePin);
            GraphUtil.ConnectDataPins(defaultNode.DefaultValuePin, openMethod.MainReturnNode.InputDataPins[0]);

            GraphUtil.ConnectExecPins(openMethod.EntryNode.InitialExecutionPin, openMethod.ReturnNodes.First().ReturnPin);

            openClass.Methods.Add(openMethod);

            // Create the closed class which contains a List<string>

            ClassGraph closedClass = new ClassGraph();

            closedClass.Name      = "ClosedClass";
            closedClass.Namespace = "Namespace";

            TypeSpecifier closedListType = TypeSpecifier.FromType <string>();

            MethodGraph closedMethod = new MethodGraph("ClosedMethod");

            // Add closed list parameter
            TypeNode closedListTypeNode = new TypeNode(closedMethod, closedListType);

            closedMethod.MainReturnNode.AddReturnType();
            GraphUtil.ConnectTypePins(closedListTypeNode.OutputTypePins[0], closedMethod.MainReturnNode.InputTypePins[0]);

            DefaultNode closedDefaultNode = new DefaultNode(closedMethod);

            GraphUtil.ConnectTypePins(closedListTypeNode.OutputTypePins[0], closedDefaultNode.TypePin);
            GraphUtil.ConnectDataPins(closedDefaultNode.DefaultValuePin, closedMethod.MainReturnNode.InputDataPins[0]);

            GraphUtil.ConnectExecPins(closedMethod.EntryNode.InitialExecutionPin, closedMethod.ReturnNodes.First().ReturnPin);

            closedClass.Methods.Add(closedMethod);

            // Translate the classes

            ClassTranslator translator = new ClassTranslator();

            string openClassTranslated = translator.TranslateClass(openClass);

            string closedClassTranslated = translator.TranslateClass(closedClass);
        }