Ejemplo n.º 1
0
        public DummyNode(int inputCount, int outputCount, string legacyName, XmlElement originalElement, string legacyAssembly, Nature nodeNature)
        {
            InputCount = inputCount;
            OutputCount = outputCount;
            LegacyNodeName = legacyName;
            NickName = legacyName;
            OriginalNodeContent = originalElement;
            LegacyAssembly = legacyAssembly;
            NodeNature = nodeNature;

            Description = GetDescription();
            ShouldDisplayPreviewCore = false;

            UpdatePorts();

            // Take the position from the old node (because a dummy node
            // should always be created at the location of the old node).
            var helper = new XmlElementHelper(originalElement);
            X = helper.ReadDouble("x", 0.0);
            Y = helper.ReadDouble("y", 0.0);

            //Take the GUID from the old node (dummy nodes should have their
            //GUID's. This will allow the Groups to work as expected. MAGN-7568)
            GUID = helper.ReadGuid("guid", this.GUID);
        }
Ejemplo n.º 2
0
        public DummyNode(int inputCount, int outputCount, string legacyName, XmlElement originalElement, string legacyAssembly, Nature nodeNature)
        {
            InputCount          = inputCount;
            OutputCount         = outputCount;
            LegacyNodeName      = legacyName;
            NickName            = legacyName;
            OriginalNodeContent = originalElement;
            LegacyAssembly      = legacyAssembly;
            NodeNature          = nodeNature;

            Description = GetDescription();
            ShouldDisplayPreviewCore = false;

            UpdatePorts();

            // Take the position from the old node (because a dummy node
            // should always be created at the location of the old node).
            var helper = new XmlElementHelper(originalElement);

            X = helper.ReadDouble("x", 0.0);
            Y = helper.ReadDouble("y", 0.0);

            //Take the GUID from the old node (dummy nodes should have their
            //GUID's. This will allow the Groups to work as expected. MAGN-7568)
            GUID = helper.ReadGuid("guid", this.GUID);
        }
Ejemplo n.º 3
0
 protected override void DeserializeCore(XmlElement element, SaveContext context)
 {
     XmlElementHelper helper = new XmlElementHelper(element);
     this.GUID = helper.ReadGuid("guid", this.GUID);
     this.Text = helper.ReadString("text", "New Note");
     this.X = helper.ReadDouble("x", 0.0);
     this.Y = helper.ReadDouble("y", 0.0);
 }
Ejemplo n.º 4
0
 protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
 {
     var helper = new XmlElementHelper(nodeElement);
     GUID = helper.ReadGuid("guid", GUID);
     Text = helper.ReadString("text", "New Note");
     X = helper.ReadDouble("x", 0.0);
     Y = helper.ReadDouble("y", 0.0);
 }
Ejemplo n.º 5
0
        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {
            XmlElementHelper helper = new XmlElementHelper(element);

            this.GUID = helper.ReadGuid("guid", this.GUID);
            this.Text = helper.ReadString("text", "New Note");
            this.X    = helper.ReadDouble("x", 0.0);
            this.Y    = helper.ReadDouble("y", 0.0);
        }
Ejemplo n.º 6
0
            internal static DragSelectionCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper = new XmlElementHelper(element);
                double           x      = helper.ReadDouble("X");
                double           y      = helper.ReadDouble("Y");
                int op = helper.ReadInteger("DragOperation");

                return(new DragSelectionCommand(new Point(x, y), ((Operation)op)));
            }
Ejemplo n.º 7
0
        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            var helper = new XmlElementHelper(nodeElement);

            GUID = helper.ReadGuid("guid", GUID);
            Text = helper.ReadString("text", "New Note");
            X    = helper.ReadDouble("x", 0.0);
            Y    = helper.ReadDouble("y", 0.0);
        }
Ejemplo n.º 8
0
            internal static CreateNoteCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper   = new XmlElementHelper(element);
                Guid             nodeId   = helper.ReadGuid("NodeId");
                string           noteText = helper.ReadString("NoteText");
                double           x        = helper.ReadDouble("X");
                double           y        = helper.ReadDouble("Y");

                return(new CreateNoteCommand(nodeId, noteText, x, y,
                                             helper.ReadBoolean("DefaultPosition")));
            }
Ejemplo n.º 9
0
        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            var helper = new XmlElementHelper(nodeElement);
            GUID = helper.ReadGuid("guid", GUID);
            Text = helper.ReadString("text", "New Note");
            X = helper.ReadDouble("x", 0.0);
            Y = helper.ReadDouble("y", 0.0);

            // Notify listeners that the position of the note has changed, 
            // then parent group will also redraw itself.
            ReportPosition();
        }
Ejemplo n.º 10
0
        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            var helper = new XmlElementHelper(nodeElement);

            GUID = helper.ReadGuid("guid", GUID);
            Text = helper.ReadString("text", "New Note");
            X    = helper.ReadDouble("x", 0.0);
            Y    = helper.ReadDouble("y", 0.0);

            // Notify listeners that the position of the note has changed,
            // then parent group will also redraw itself.
            ReportPosition();
        }
Ejemplo n.º 11
0
            internal static CreateNodeCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper = new XmlElementHelper(element);

                System.Guid nodeId   = helper.ReadGuid("NodeId");
                string      nodeName = helper.ReadString("NodeName");
                double      x        = helper.ReadDouble("X");
                double      y        = helper.ReadDouble("Y");

                return(new CreateNodeCommand(nodeId, nodeName, x, y,
                                             helper.ReadBoolean("DefaultPosition"),
                                             helper.ReadBoolean("TransformCoordinates")));
            }
Ejemplo n.º 12
0
            internal static SelectInRegionCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper = new XmlElementHelper(element);

                double x      = helper.ReadDouble("X");
                double y      = helper.ReadDouble("Y");
                double width  = helper.ReadDouble("Width");
                double height = helper.ReadDouble("Height");

                Rect region           = new Rect(x, y, width, height);
                bool isCrossSelection = helper.ReadBoolean("IsCrossSelection");

                return(new SelectInRegionCommand(region, isCrossSelection));
            }
Ejemplo n.º 13
0
            internal static CreateNodeCommand DeserializeCore(XmlElement element)
            {
                var    helper          = new XmlElementHelper(element);
                double x               = helper.ReadDouble("X");
                double y               = helper.ReadDouble("Y");
                bool   defaultPos      = helper.ReadBoolean("DefaultPosition");
                bool   transformCoords = helper.ReadBoolean("TransformCoordinates");

                var nodeElement = element.ChildNodes.OfType <XmlElement>().FirstOrDefault();

                if (nodeElement == null)
                {
                    // Get the old NodeId and NodeName attributes
                    Guid   nodeId = helper.ReadGuid("NodeId");
                    string name   = helper.ReadString("NodeName");

                    return(new CreateNodeCommand(nodeId, name, x, y, defaultPos, transformCoords));
                }

                return(new CreateNodeCommand(nodeElement, x, y, defaultPos, transformCoords));
            }
Ejemplo n.º 14
0
        public void TestDoubleAttributes()
        {
            XmlElement element = xmlDocument.CreateElement("element");

            // Test attribute writing.
            XmlElementHelper writer = new XmlElementHelper(element);
            writer.SetAttribute("ValidName", -12.34);

            // Test reading of existing attribute.
            XmlElementHelper reader = new XmlElementHelper(element);
            Assert.AreEqual(-12.34, reader.ReadDouble("ValidName"));

            // Test reading of non-existence attribute with default value.
            Assert.AreEqual(56.78, reader.ReadDouble("InvalidName", 56.78));

            // Test reading of non-existence attribute without default value.
            Assert.Throws<InvalidOperationException>(() =>
            {
                reader.ReadDouble("InvalidName");
            });
        }
Ejemplo n.º 15
0
        public DummyNode(int inputCount, int outputCount, string legacyName, XmlElement originalElement, string legacyAssembly, Nature nodeNature)
        {
            InputCount          = inputCount;
            OutputCount         = outputCount;
            LegacyNodeName      = legacyName;
            NickName            = legacyName;
            OriginalNodeContent = originalElement;
            LegacyAssembly      = legacyAssembly;
            NodeNature          = nodeNature;

            Description = GetDescription();
            ShouldDisplayPreviewCore = false;

            UpdatePorts();

            // Take the position from the old node (because a dummy node
            // should always be created at the location of the old node).
            var helper = new XmlElementHelper(originalElement);

            X = helper.ReadDouble("x", 0.0);
            Y = helper.ReadDouble("y", 0.0);
        }
Ejemplo n.º 16
0
        public void TestDoubleAttributes()
        {
            XmlElement element = xmlDocument.CreateElement("element");

            // Test attribute writing.
            XmlElementHelper writer = new XmlElementHelper(element);

            writer.SetAttribute("ValidName", -12.34);

            // Test reading of existing attribute.
            XmlElementHelper reader = new XmlElementHelper(element);

            Assert.AreEqual(-12.34, reader.ReadDouble("ValidName"));

            // Test reading of non-existence attribute with default value.
            Assert.AreEqual(56.78, reader.ReadDouble("InvalidName", 56.78));

            // Test reading of non-existence attribute without default value.
            Assert.Throws <InvalidOperationException>(() =>
            {
                reader.ReadDouble("InvalidName");
            });
        }
Ejemplo n.º 17
0
        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {
            XmlElementHelper helper = new XmlElementHelper(element);

            this.GUID           = helper.ReadGuid("guid", this.GUID);
            this.annotationText = helper.ReadString("annotationText", Resources.GroupDefaultText);
            this.X               = helper.ReadDouble("left", DoubleValue);
            this.Y               = helper.ReadDouble("top", DoubleValue);
            this.width           = helper.ReadDouble("width", DoubleValue);
            this.height          = helper.ReadDouble("height", DoubleValue);
            this.background      = helper.ReadString("backgrouund", "");
            this.fontSize        = helper.ReadDouble("fontSize", fontSize);
            this.textBlockHeight = helper.ReadDouble("TextblockHeight", DoubleValue);
            this.InitialTop      = helper.ReadDouble("InitialTop", DoubleValue);
            this.InitialHeight   = helper.ReadDouble("InitialHeight", DoubleValue);
            //Deserialize Selected models
            if (element.HasChildNodes)
            {
                var listOfModels = new List <ModelBase>();
                if (Nodes != null)
                {
                    foreach (var childnode in element.ChildNodes)
                    {
                        var mhelper = new XmlElementHelper(childnode as XmlElement);
                        var result  = mhelper.ReadGuid("ModelGuid", new Guid());
                        var model   = ModelBaseRequested != null
                            ? ModelBaseRequested(result)
                            : Nodes.FirstOrDefault(x => x.GUID == result);

                        if (model != null)
                        {
                            listOfModels.Add(model);
                        }
                    }
                }

                Nodes = listOfModels;
            }

            //On any Undo Operation, current values are restored to previous values.
            //These properties should be Raised, so that they get the correct value on Undo.
            RaisePropertyChanged("Background");
            RaisePropertyChanged("FontSize");
            RaisePropertyChanged("AnnotationText");
            RaisePropertyChanged("Nodes");
        }
Ejemplo n.º 18
0
        protected override void DeserializeCore(XmlElement nodeElement, SaveContext context)
        {
            var helper = new XmlElementHelper(nodeElement); 
            
            if (context != SaveContext.Copy)
                GUID = helper.ReadGuid("guid", GUID);

            // Resolve node nick name.
            string name = helper.ReadString("nickname", string.Empty);
            if (!string.IsNullOrEmpty(name))
                nickName = name;
            else
            {
                Type type = GetType();
                object[] attribs = type.GetCustomAttributes(typeof(NodeNameAttribute), true);
                var attrib = attribs[0] as NodeNameAttribute;
                if (null != attrib)
                    nickName = attrib.Name;
            }

            X = helper.ReadDouble("x", 0.0);
            Y = helper.ReadDouble("y", 0.0);
            isVisible = helper.ReadBoolean("isVisible", true);
            isUpstreamVisible = helper.ReadBoolean("isUpstreamVisible", true);
            argumentLacing = helper.ReadEnum("lacing", LacingStrategy.Disabled);

            var portInfoProcessed = new HashSet<int>();

            //read port information
            foreach (XmlNode subNode in nodeElement.ChildNodes)
            {
                if (subNode.Name == "PortInfo")
                {
                    int index = int.Parse(subNode.Attributes["index"].Value);
                    if (index < InPorts.Count)
                    {
                        portInfoProcessed.Add(index);
                        bool def = bool.Parse(subNode.Attributes["default"].Value);
                        inPorts[index].UsingDefaultValue = def;
                    }
                }
            }

            //set defaults
            foreach (
                var port in
                    inPorts.Select((x, i) => new { x, i }).Where(x => !portInfoProcessed.Contains(x.i)))
                port.x.UsingDefaultValue = false;

            if (context == SaveContext.Undo)
            {
                // Fix: MAGN-159 (nodes are not editable after undo/redo).
                //interactionEnabled = helper.ReadBoolean("interactionEnabled", true);
                state = helper.ReadEnum("nodeState", ElementState.Active);

                // We only notify property changes in an undo/redo operation. Normal
                // operations like file loading or copy-paste have the models created
                // in different ways and their views will always be up-to-date with 
                // respect to their models.
                RaisePropertyChanged("InteractionEnabled");
                RaisePropertyChanged("State");
                RaisePropertyChanged("NickName");
                RaisePropertyChanged("ArgumentLacing");
                RaisePropertyChanged("IsVisible");
                RaisePropertyChanged("IsUpstreamVisible");

                // Notify listeners that the position of the node has changed,
                // then all connected connectors will also redraw themselves.
                ReportPosition();
            }
        }
Ejemplo n.º 19
0
 internal static DragSelectionCommand DeserializeCore(XmlElement element)
 {
     XmlElementHelper helper = new XmlElementHelper(element);
     double x = helper.ReadDouble("X");
     double y = helper.ReadDouble("Y");
     int op = helper.ReadInteger("DragOperation");
     return new DragSelectionCommand(new Point(x, y), ((Operation)op));
 }
Ejemplo n.º 20
0
        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {         
            XmlElementHelper helper = new XmlElementHelper(element);
            this.GUID = helper.ReadGuid("guid", this.GUID);
            this.annotationText = helper.ReadString("annotationText", Resources.GroupDefaultText);
            this.X = helper.ReadDouble("left", DoubleValue);
            this.Y = helper.ReadDouble("top", DoubleValue);
            this.width = helper.ReadDouble("width", DoubleValue);
            this.height = helper.ReadDouble("height", DoubleValue);
            this.background = helper.ReadString("backgrouund", "");
            this.fontSize = helper.ReadDouble("fontSize", fontSize);
            this.textBlockHeight = helper.ReadDouble("TextblockHeight", DoubleValue);
            this.InitialTop = helper.ReadDouble("InitialTop", DoubleValue);
            this.InitialHeight = helper.ReadDouble("InitialHeight", DoubleValue);
            //Deserialize Selected models
            if (element.HasChildNodes) 
            {
                var listOfModels = new List<ModelBase>();
                foreach (var childnode in element.ChildNodes)
                {
                    XmlElementHelper mhelper = new XmlElementHelper(childnode as XmlElement);
                     if (SelectedModels != null)
                     {
                         var result = mhelper.ReadGuid("ModelGuid", new Guid());
                         ModelBase model = null;
                         model = ModelBaseRequested != null ? ModelBaseRequested(result) : 
                             SelectedModels.FirstOrDefault(x => x.GUID == result);

                        listOfModels.Add(model);
                    }                  
                }
                SelectedModels = listOfModels;        
            }

            //On any Undo Operation, current values are restored to previous values.
            //These properties should be Raised, so that they get the correct value on Undo.
            RaisePropertyChanged("Background");
            RaisePropertyChanged("FontSize");
            RaisePropertyChanged("AnnotationText");
            RaisePropertyChanged("SelectedModels");
        }
Ejemplo n.º 21
0
            internal static CreateNoteCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper = new XmlElementHelper(element);
                Guid nodeId = helper.ReadGuid("NodeId");
                string noteText = helper.ReadString("NoteText");
                double x = helper.ReadDouble("X");
                double y = helper.ReadDouble("Y");

                return new CreateNoteCommand(nodeId, noteText, x, y,
                    helper.ReadBoolean("DefaultPosition"));
            }
Ejemplo n.º 22
0
            internal static SelectInRegionCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper = new XmlElementHelper(element);

                double x = helper.ReadDouble("X");
                double y = helper.ReadDouble("Y");
                double width = helper.ReadDouble("Width");
                double height = helper.ReadDouble("Height");

                Rect region = new Rect(x, y, width, height);
                bool isCrossSelection = helper.ReadBoolean("IsCrossSelection");
                return new SelectInRegionCommand(region, isCrossSelection);
            }
Ejemplo n.º 23
0
            internal static CreateNodeCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper = new XmlElementHelper(element);
                Guid nodeId = helper.ReadGuid("NodeId");
                string nodeName = helper.ReadString("NodeName");
                double x = helper.ReadDouble("X");
                double y = helper.ReadDouble("Y");

                return new CreateNodeCommand(nodeId, nodeName, x, y,
                    helper.ReadBoolean("DefaultPosition"),
                    helper.ReadBoolean("TransformCoordinates"));
            }
Ejemplo n.º 24
0
        protected override void DeserializeCore(XmlElement element, SaveContext context)
        {
            XmlElementHelper helper = new XmlElementHelper(element);
            this.GUID = helper.ReadGuid("guid", Guid.NewGuid());

            // Resolve node nick name.
            string nickName = helper.ReadString("nickname", string.Empty);
            if (!string.IsNullOrEmpty(nickName))
                this.nickName = nickName;
            else
            {
                System.Type type = this.GetType();
                var attribs = type.GetCustomAttributes(typeof(NodeNameAttribute), true);
                NodeNameAttribute attrib = attribs[0] as NodeNameAttribute;
                if (null != attrib)
                    this.nickName = attrib.Name;
            }

            this.X = helper.ReadDouble("x", 0.0);
            this.Y = helper.ReadDouble("y", 0.0);
            this.isVisible = helper.ReadBoolean("isVisible", true);
            this.isUpstreamVisible = helper.ReadBoolean("isUpstreamVisible", true);
            this.argumentLacing = helper.ReadEnum("lacing", LacingStrategy.Disabled);

            if (context == SaveContext.Undo)
            {
                // Fix: MAGN-159 (nodes are not editable after undo/redo).
                interactionEnabled = helper.ReadBoolean("interactionEnabled", true);
                this.state = helper.ReadEnum("nodeState", ElementState.ACTIVE);

                // We only notify property changes in an undo/redo operation. Normal
                // operations like file loading or copy-paste have the models created
                // in different ways and their views will always be up-to-date with
                // respect to their models.
                RaisePropertyChanged("InteractionEnabled");
                RaisePropertyChanged("State");
                RaisePropertyChanged("NickName");
                RaisePropertyChanged("ArgumentLacing");
                RaisePropertyChanged("IsVisible");
                RaisePropertyChanged("IsUpstreamVisible");

                // Notify listeners that the position of the node has changed,
                // then all connected connectors will also redraw themselves.
                this.ReportPosition();
            }
        }
Ejemplo n.º 25
0
            internal static CreateAnnotationCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper = new XmlElementHelper(element);
                var modelGuids = DeserializeGuid(element, helper);
                string annotationText = helper.ReadString("AnnotationText");
                double x = helper.ReadDouble("X");
                double y = helper.ReadDouble("Y");

                return new CreateAnnotationCommand(modelGuids, annotationText, x, y,
                    helper.ReadBoolean("DefaultPosition"));
            }
Ejemplo n.º 26
0
            internal static CreateNodeCommand DeserializeCore(XmlElement element)
            {
                var helper = new XmlElementHelper(element);
                double x = helper.ReadDouble("X");
                double y = helper.ReadDouble("Y");
                bool defaultPos = helper.ReadBoolean("DefaultPosition");
                bool transformCoords = helper.ReadBoolean("TransformCoordinates");

                var nodeElement = element.ChildNodes.OfType<XmlElement>().FirstOrDefault(el => el.Name != "ModelGuid");

                if (nodeElement == null)
                {
                    // Get the old NodeId and NodeName attributes
                    var nodeId = DeserializeGuid(element, helper);
                    string name = helper.ReadString("NodeName");

                    return new CreateNodeCommand(nodeId, name, x, y, defaultPos, transformCoords);
                }

                return new CreateNodeCommand(nodeElement, x, y, defaultPos, transformCoords);
            }
Ejemplo n.º 27
0
            internal static CreateAndConnectNodeCommand DeserializeCore(XmlElement element)
            {
                var helper = new XmlElementHelper(element);
                string newNodeName = helper.ReadString("NewNodeName");
                double x = helper.ReadDouble("X");
                double y = helper.ReadDouble("Y");
                bool createAsDownstreamNode = helper.ReadBoolean("CreateAsDownstreamNode");
                bool addNewNodeToSelection = helper.ReadBoolean("AddNewNodeToSelection");

                var guids = DeserializeGuid(element, helper).ToList();
                var newNodeGuid = guids.ElementAt(0);
                var existingNodeGuid = guids.ElementAt(1);

                int outPortIndex = helper.ReadInteger("OutPortIndex");
                int inPortIndex = helper.ReadInteger("InPortIndex");

                return new CreateAndConnectNodeCommand(newNodeGuid, existingNodeGuid, newNodeName, outPortIndex, inPortIndex,
                    x, y, createAsDownstreamNode, addNewNodeToSelection);
            }