Exemplo n.º 1
0
        private ParseResult ParseLine(int lineNumber, string line)
        {
            if (line.Length == 0 || line.StartsWith(CommentPrefix))
            {
                return(ParseResult.Success);
            }

            ParseData parseData = GetParseData(lineNumber, line);

            if (parseData == null)
            {
                return(ParseResult.Failure.Derive(lineNumber, line, "Invalid syntax"));
            }

            INodeContainer container = GetContainer(parseData);

            if (container == null)
            {
                return(ParseResult.Failure.Derive(lineNumber, line, String.Format("Unable to get node container for type \"{0}\"", parseData.Type)));
            }

            if (containers.ContainsKey(container.Index))
            {
                return(ParseResult.Failure.Derive(lineNumber, line, String.Format("Duplicate index \"{0}\"", container.Index)));
            }

            containers.Add(container.Index, container);

            return(ParseResult.Success);
        }
Exemplo n.º 2
0
        public INodeContainer Get <T>(T node) where T : INode, new()
        {
            INodeContainer output = PrivateGet(node);

            output.Update(null);

            return(output);
        }
Exemplo n.º 3
0
        private static IVisualNodeComponentContainer GetComponentByIndex(INodeContainer container, int index)
        {
            if (index == -1)
            {
                return(container.Name);
            }

            return(((IList <IVisualNodeComponentContainer>)container.Fields)[index]);
        }
Exemplo n.º 4
0
        private static void CreateModelDesignStub(INodeContainer factory)
        {
            BuildError _err = BuildError.DanglingReferenceTarget;
            IPropertyInstanceFactory _pr = factory.AddNodeFactory <IPropertyInstanceFactory>();

            _pr.SymbolicName = new XmlQualifiedName(string.Format("{0}{1}", _err.Focus.ToString(), m_ErrorNumber++), "http://commsvr.com/OOIUA/SemanticData/UANodeSetValidation");
            _pr.AddDescription("en-en", _err.Descriptor);
            _pr.AddDisplayName("en-en", string.Format("ERROR{0}", m_ErrorNumber));
        }
 public TestWorkspaceVisualNode(INodeContainer container,
                                Guid selectionKind,
                                string nodeMoniker,
                                string selectionMoniker)
     : base(container)
 {
     VSSelectionKind    = selectionKind;
     NodeMoniker        = nodeMoniker;
     VSSelectionMoniker = selectionMoniker;
 }
Exemplo n.º 6
0
        private void RegisterContainer(INodeContainer container, int index)
        {
            INodeField newField = Constructor.NodeField(container.NameLabel.LabelText.Value).WithValue("display", ((InputNodeContainer <InputNode>)container).GetValue(null), true);

            container.NameLabel.LabelText.OnChange += s =>
            {
                newField.Name.Value = s;
            };
            newField.GetValue("display").OnChange += (o) =>
            {
                ((InputNodeContainer <InputNode>)container).SetValue(_scriptInstance, o);
            };
            AllInputs.Insert(index, newField);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Copies the common properties between the <paramref name="sourcePanel"/> and the <paramref name="targetPanel"/>.
        /// </summary>
        /// <remarks>The children are not copied.</remarks>
        /// <param name="nodeContainer">The node container.</param>
        /// <param name="sourcePanel">The source panel.</param>
        /// <param name="targetPanel">The target panel.</param>
        private static void CopyCommonProperties([NotNull] INodeContainer nodeContainer, Panel sourcePanel, Panel targetPanel)
        {
            var sourceNode = nodeContainer.GetOrCreateNode(sourcePanel);
            var targetNode = nodeContainer.GetOrCreateNode(targetPanel);

            foreach (var targetChild in targetNode.Members.Where(x => x.Name != nameof(Panel.Children) && x.Name != nameof(UIElement.Id)))
            {
                var name        = targetChild.Name;
                var sourceChild = sourceNode.TryGetChild(name);
                if (sourceChild != null)
                {
                    targetChild.Update(AssetCloner.Clone(sourceChild.Retrieve()));
                }
            }
        }
Exemplo n.º 8
0
        public T GetNode <T>(int index) where T : INode <string>
        {
            if (!containers.ContainsKey(index))
            {
                return(default(T));
            }

            INodeContainer container = containers[index];
            INode <string> node      = container.Node;

            if (!typeof(T).IsAssignableFrom(node.GetType()))
            {
                return(default(T));
            }

            return((T)node);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Copies the common properties between the <paramref name="sourcePanel"/> and the <paramref name="targetPanel"/>.
        /// </summary>
        /// <remarks>The children are not copied.</remarks>
        /// <param name="nodeContainer">The node container.</param>
        /// <param name="sourcePanel">The source panel.</param>
        /// <param name="targetPanel">The target panel.</param>
        private static void CopyCommonProperties([NotNull] INodeContainer nodeContainer, Panel sourcePanel, Panel targetPanel)
        {
            var sourceNode = nodeContainer.GetOrCreateNode(sourcePanel);
            var targetNode = nodeContainer.GetOrCreateNode(targetPanel);

            foreach (var targetChild in targetNode.Members.Where(x => x.Name != nameof(Panel.Children) && x.Name != nameof(UIElement.Id) && x.Name != nameof(UIElement.DependencyProperties)))
            {
                var name        = targetChild.Name;
                var sourceChild = sourceNode.TryGetChild(name);
                if (sourceChild != null)
                {
                    targetChild.Update(AssetCloner.Clone(sourceChild.Retrieve()));
                }
            }

            // Copy the dependency properties, eg. the source panel may be inside a grid and has set grid row/column
            sourcePanel.DependencyProperties.CopyTo(targetPanel.DependencyProperties);
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Enumerate child nodes "Breadth-First".
        /// </summary>
        /// <param name="root">Parent node.</param>
        /// <returns>Yielded nodes.</returns>
        public static IEnumerable <INodeAsset> EnumerateNodesBreadthFirst(this INodeContainer root)
        {
            if (root == null)
            {
                yield break;
            }
            var containers = new Stack <INodeAsset>(16);

            foreach (var n in root.ChildNodes)
            {
                containers.Push(n);
            }
            while (containers.Count > 0)
            {
                var node = containers.Pop();
                yield return(node);

                foreach (var n in node.ChildNodes)
                {
                    containers.Push(n);
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Enumerate child nodes "Depth-First".
        /// </summary>
        /// <param name="root">Parent node.</param>
        /// <returns>Yielded nodes.</returns>
        public static IEnumerable <INodeAsset> EnumerateNodesDepthFirst(this INodeContainer root)
        {
            if (root == null)
            {
                yield break;
            }
            var containers = new Queue <INodeAsset>(16);

            foreach (var n in root.ChildNodes)
            {
                containers.Enqueue(n);
            }
            while (containers.Count > 0)
            {
                var node = containers.Dequeue();
                yield return(node);

                foreach (var n in node.ChildNodes)
                {
                    containers.Enqueue(n);
                }
            }
        }
Exemplo n.º 12
0
        private static void SetInlineContent(INodeContainer<CommonMark.Inline> owner, Syntax.Inline inl)
        {
            while (inl != null)
            {
                CommonMark.Inline result = null;
                switch (inl.Tag)
                {
                    case Syntax.InlineTag.String:
                        result = new Text(inl.Content.Literal); break;
                    case Syntax.InlineTag.SoftBreak:
                        result = new Softbreak(); break;
                    case Syntax.InlineTag.LineBreak:
                        result = new Linebreak(); break;
                    case Syntax.InlineTag.Code:
                        result = new CodeSpan(inl.Content.Literal); break;
                    case Syntax.InlineTag.RawHtml:
                        result = new RawHtml(inl.Content.Literal); break;
                    case Syntax.InlineTag.Entity:
                        result = new TextEntity(inl.Content.Literal); break;
                    case Syntax.InlineTag.Emphasis:
                        result = new Emphasis(); break;
                    case Syntax.InlineTag.Strong:
                        result = new Strong(); break;
                    case Syntax.InlineTag.Link:
                        result = new Link(); break;
                    case Syntax.InlineTag.Image:
                        result = new Image(); break;
                    default:
                        throw new Exception("Invalid value for InlineTag");
                }
                if (result is Linkable)
                {
                    ((Linkable)result).Title = inl.Content.Linkable.Title;
                    ((Linkable)result).Url = inl.Content.Linkable.Url;
                    SetInlineContent((Linkable)result, inl.Content.Linkable.Label);
                }

                if (result is CommonMark.INodeContainer<CommonMark.Inline>)
                    SetInlineContent((CommonMark.INodeContainer<CommonMark.Inline>)result, inl.Content.Inlines);

                if (result != null)
                    owner.Append(result);

                inl = inl.Next;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Validates <paramref name="nodeContext" /> and exports it using an object of <see cref="IModelFactory" />  type.
        /// </summary>
        /// <param name="nodeContext">The node context to be validated and exported.</param>
        /// <param name="exportFactory">A model export factory.</param>
        /// <param name="parentReference">The reference to parent node.</param>
        /// <exception cref="ApplicationException">In {nameof(ValidateExportNode)}</exception>
        public void ValidateExportNode(IUANodeBase nodeContext, INodeContainer exportFactory, UAReferenceContext parentReference)
        {
            Debug.Assert(nodeContext != null, "Validator.ValidateExportNode the argument nodeContext is null.");
            //TODO Handle HasComponent ReferenceType errors. #42
            if (Object.ReferenceEquals(nodeContext.UANode, null))
            {
                string     _msg = string.Format("The node {0} is undefined", nodeContext.NodeIdContext);
                BuildError _be  = null;
                if (parentReference == null || parentReference.ReferenceKind == ReferenceKindEnum.HasProperty)
                {
                    _be = BuildError.UndefinedHasPropertyTarget;
                }
                else
                {
                    _be = BuildError.UndefinedHasComponentTarget;
                }
                TraceMessage _traceMessage = TraceMessage.BuildErrorTraceMessage(_be, _msg);
                Log.TraceEvent(_traceMessage);
                CreateModelDesignStub(exportFactory);
            }
            else
            {
                switch (nodeContext.UANode.NodeClassEnum)
                {
                case NodeClassEnum.UADataType:
                    CreateNode <IDataTypeFactory, UADataType>(exportFactory.AddNodeFactory <IDataTypeFactory>, nodeContext, (x, y) => Update(x, y), UpdateType);
                    break;

                case NodeClassEnum.UAMethod:
                    CreateNode <IMethodInstanceFactory, UAMethod>(exportFactory.AddNodeFactory <IMethodInstanceFactory>, nodeContext, (x, y) => Update(x, y, parentReference), UpdateInstance);
                    break;

                case NodeClassEnum.UAObject:
                    CreateNode <IObjectInstanceFactory, UAObject>(exportFactory.AddNodeFactory <IObjectInstanceFactory>, nodeContext, (x, y) => Update(x, y), UpdateInstance);
                    break;

                case NodeClassEnum.UAObjectType:
                    CreateNode <IObjectTypeFactory, UAObjectType>(exportFactory.AddNodeFactory <IObjectTypeFactory>, nodeContext, Update, UpdateType);
                    break;

                case NodeClassEnum.UAReferenceType:
                    CreateNode <IReferenceTypeFactory, UAReferenceType>(exportFactory.AddNodeFactory <IReferenceTypeFactory>, nodeContext, (x, y) => Update(x, y), UpdateType);
                    break;

                case NodeClassEnum.UAVariable:
                    if (parentReference.ReferenceKind == ReferenceKindEnum.HasProperty)
                    {
                        CreateNode <IPropertyInstanceFactory, UAVariable>(exportFactory.AddNodeFactory <IPropertyInstanceFactory>, nodeContext, (x, y) => Update(x, y, nodeContext, parentReference), UpdateInstance);
                    }
                    else
                    {
                        CreateNode <IVariableInstanceFactory, UAVariable>(exportFactory.AddNodeFactory <IVariableInstanceFactory>, nodeContext, (x, y) => Update(x, y, nodeContext, parentReference), UpdateInstance);
                    }
                    break;

                case NodeClassEnum.UAVariableType:
                    CreateNode <IVariableTypeFactory, UAVariableType>(exportFactory.AddNodeFactory <IVariableTypeFactory>, nodeContext, (x, y) => Update(x, y), UpdateType);
                    break;

                case NodeClassEnum.UAView:
                    CreateNode <IViewInstanceFactory, UAView>(exportFactory.AddNodeFactory <IViewInstanceFactory>, nodeContext, (x, y) => Update(x, y), UpdateInstance);
                    break;

                case NodeClassEnum.Unknown:
                    throw new ApplicationException($"In {nameof(ValidateExportNode)} unexpected NodeClass value");
                }
            }
        }
Exemplo n.º 14
0
 public void SetSourceContainer(INodeContainer container)
 {
     _nodeList = container.Nodes;
     Title     = container.Title;
 }
Exemplo n.º 15
0
 public LeafNode(TActionItem action, INodeContainer parent)
     : base(action, parent)
 {
 }
Exemplo n.º 16
0
		private void ParseNode(Scene scene, INodeContainer parent, XElement node)
		{
			var n = new Node();
			this.ParseIdAndName(node, n);
			var mat = this.ParseMatrix(node.Element(this.schema.matrixName));
			//TODO: check if transform is in there!
			n.Position = new Float3(mat.M03, mat.M13, mat.M23);
			//n.Rotation = 

			var geo = node.Element(this.schema.instanceGeometryName);
			if (geo != null)
			{
				var url = geo.AttributeValue(this.schema.urlName);
				string id = url.Substring(1);
				n.Mesh = (from g in scene.Geometries where g.Id == id select g).First();
			}
			else
			{
				var ctrl = node.Element(this.schema.instanceControllerName);
				if (ctrl != null)
				{
					var url = ctrl.AttributeValue(this.schema.urlName);
					string id = url.Substring(1);
					var controller = this.collada.Element(this.schema.libraryControllersName).ElementById(id);
					url = controller.Element(this.schema.skinName).AttributeValue(this.schema.sourceAttributeName);
					id = url.Substring(1);
					n.Mesh = (from g in scene.Geometries where g.Id == id select g).First();
				}
			}

			parent.Nodes.Add(n);
		}
Exemplo n.º 17
0
 public GroupNode(TActionItem action, INodeContainer parent)
     : base(action, parent)
 {
     this.Items = new List <Node>();
 }
Exemplo n.º 18
0
 public NodesToOwnerPartVisitor([NotNull] AssetPropertyGraphDefinition propertyGraphDefinition, [NotNull] INodeContainer nodeContainer, object ownerPart)
     : base(propertyGraphDefinition)
 {
     ownerPartNode = (IAssetObjectNode)nodeContainer.GetOrCreateNode(ownerPart);
 }
Exemplo n.º 19
0
 public static IEnumerable <Node> GetLightNodes(this INodeContainer nodeContainer)
 {
     return(nodeContainer.nodes.Where((x) => x.HasLight()));
 }
Exemplo n.º 20
0
        public static Node Find(this INodeContainer node, string nodePath, NodeFindMethod method)
        {
            // early exit check against null for passed reference
            if (node == null)
            {
                return(null);
            }

            nodePath = nodePath.Trim('/');
            int    sepIndex = nodePath.IndexOf('/');
            string curLevel = nodePath;

            if (sepIndex != -1)
            {
                curLevel = nodePath.Substring(0, sepIndex);
                nodePath = nodePath.Substring(sepIndex);
            }
            else
            {
                nodePath = nodePath.Substring(curLevel.Length);
            }


            if (node != null && node.nodes != null)
            {
                if (method == NodeFindMethod.ByName)
                {
                    // check if the path exceeds the current node level
                    foreach (Node child in node.nodes)
                    {
                        if (child.name != null && child.name.Equals(curLevel))
                        {
                            if (nodePath.Length > 1)
                            {
                                Node result = child.Find(nodePath, method);
                                if (result != null)
                                {
                                    return(result);
                                }
                            }
                            return(child);
                        }
                    }
                }
                else
                {
                    // check if the path exceeds the current node level
                    foreach (Node child in node.nodes)
                    {
                        if (child.id != null && child.id.Equals(curLevel))
                        {
                            if (nodePath.Length > 1)
                            {
                                Node result = child.Find(nodePath, method);
                                if (result != null)
                                {
                                    return(result);
                                }
                            }
                            return(child);
                        }
                    }
                }
            }
            return(null);

            /*
             * if (node != null && node.nodes != null)
             *  // check if the path exceeds the current node level
             *  foreach (Node child in node.nodes)
             *  {
             *      //if (child.name.Equals(curLevel))
             *      if (child.id.Equals(curLevel)) // changed check against .name to .id
             *      {
             *          if (nodePath.Length > 1)
             *          {
             *              Node result = child.Find(nodePath);
             *              if (result != null)
             *                  return result;
             *          }
             *          return child;
             *      }
             *  }
             * return null;
             */
        }
Exemplo n.º 21
0
		private void ParseNodes(Scene scene, INodeContainer parent, IEnumerable<XElement> elements)
		{
			foreach (var node in elements)
			{
				this.ParseNode(scene, parent, node);
			}
		}
Exemplo n.º 22
0
        /// <summary>
        /// Validates <paramref name="nodeContext"/> and exports it using an object of <see cref="IModelFactory"/>  type.
        /// </summary>
        /// <param name="nodeContext">The node context to be validated and exported.</param>
        /// <param name="exportFactory">A model export factory.</param>
        /// <param name="parentReference">The reference to parent node.</param>
        /// <param name="traceEvent">The trace event.</param>
        /// <returns>An object of <see cref="INodeFactory"/>.</returns>
        internal static void ValidateExportNode(IUANodeBase nodeContext, INodeContainer exportFactory, UAReferenceContext parentReference, Action <TraceMessage> traceEvent)
        {
            Debug.Assert(nodeContext != null, "Validator.ValidateExportNode the argument nodeContext is null.");
            //TODO Handle HasComponent ReferenceType errors. #42
            if (nodeContext.UANode == null)
            {
                string     _msg = string.Format("The node {0} is undefined", nodeContext.NodeIdContext);
                BuildError _be  = null;
                if (parentReference == null || parentReference.ReferenceKind == ReferenceKindEnum.HasProperty)
                {
                    _be = BuildError.UndefinedHasPropertyTarget;
                }
                else
                {
                    _be = BuildError.UndefinedHasComponentTarget;
                }
                TraceMessage _traceMessage = TraceMessage.BuildErrorTraceMessage(_be, _msg);
                traceEvent(_traceMessage);
                CreateModelDesignStub(exportFactory);
            }
            else
            {
                string nodeType = nodeContext.UANode.GetType().Name;
                switch (nodeType)
                {
                case "UAReferenceType":
                    CreateNode <IReferenceTypeFactory, UAReferenceType>(exportFactory.AddNodeFactory <IReferenceTypeFactory>, nodeContext, (x, y) => Update(x, y, traceEvent), UpdateType, traceEvent);
                    break;

                case "UADataType":
                    CreateNode <IDataTypeFactory, UADataType>(exportFactory.AddNodeFactory <IDataTypeFactory>, nodeContext, (x, y) => Update(x, y, nodeContext.UAModelContext, traceEvent), UpdateType, traceEvent);
                    break;

                case "UAVariableType":
                    CreateNode <IVariableTypeFactory, UAVariableType>(exportFactory.AddNodeFactory <IVariableTypeFactory>, nodeContext, (x, y) => Update(x, y, nodeContext, traceEvent), UpdateType, traceEvent);
                    break;

                case "UAObjectType":
                    CreateNode <IObjectTypeFactory, UAObjectType>(exportFactory.AddNodeFactory <IObjectTypeFactory>, nodeContext, Update, UpdateType, traceEvent);
                    break;

                case "UAView":
                    CreateNode <IViewInstanceFactory, UAView>(exportFactory.AddNodeFactory <IViewInstanceFactory>, nodeContext, (x, y) => Update(x, y, traceEvent), UpdateInstance, traceEvent);
                    break;

                case "UAMethod":
                    CreateNode <IMethodInstanceFactory, UAMethod>(exportFactory.AddNodeFactory <IMethodInstanceFactory>, nodeContext, (x, y) => Update(x, y, nodeContext, parentReference, traceEvent), UpdateInstance, traceEvent);
                    break;

                case "UAVariable":
                    if (parentReference == null || parentReference.ReferenceKind == ReferenceKindEnum.HasProperty)
                    {
                        CreateNode <IPropertyInstanceFactory, UAVariable>(exportFactory.AddNodeFactory <IPropertyInstanceFactory>, nodeContext, (x, y) => Update(x, y, nodeContext, parentReference, traceEvent), UpdateInstance, traceEvent);
                    }
                    else
                    {
                        CreateNode <IVariableInstanceFactory, UAVariable>(exportFactory.AddNodeFactory <IVariableInstanceFactory>, nodeContext, (x, y) => Update(x, y, nodeContext, parentReference, traceEvent), UpdateInstance, traceEvent);
                    }
                    break;

                case "UAObject":
                    CreateNode <IObjectInstanceFactory, UAObject>(exportFactory.AddNodeFactory <IObjectInstanceFactory>, nodeContext, (x, y) => Update(x, y, traceEvent), UpdateInstance, traceEvent);
                    break;

                default:
                    Debug.Assert(false, "Wrong node type");
                    break;
                }
            }
        }
Exemplo n.º 23
0
 public static IEnumerable <Node> GetControllerNodes(this INodeContainer nodeContainer)
 {
     return(nodeContainer.nodes.Where((x) => x.HasController()));
 }
Exemplo n.º 24
0
 protected Node(TActionItem action, INodeContainer parent)
 {
     this.Content = action;
     this.Parent  = parent;
 }
Exemplo n.º 25
0
 /// <summary>
 /// Create a new instanse of CTreeNodeCollection assigned to specified owner.
 /// </summary>
 /// <param name="owner">CTreeNode or CTreeView.</param>
 internal CTreeNodeCollection(INodeContainer owner)
 {
     this.owner = owner;
 }
Exemplo n.º 26
0
 public static IEnumerable <Node> GetGeometryNodes(this INodeContainer nodeContainer)
 {
     return(nodeContainer.nodes.Where((x) => x.HasGeometry()));
 }
Exemplo n.º 27
0
 public static IEnumerable <Node> GetOtherNodes(this INodeContainer nodeContainer)
 {
     return(nodeContainer.nodes.Where((x) => !x.HasCamera() && !x.HasController() && !x.HasGeometry() && !x.HasLight()));
 }
Exemplo n.º 28
0
 public NodeContainerAdapter(INodeContainer <TEntity> nodes)
 {
     _nodes = nodes;
 }