示例#1
0
        public void GetInfo(object item, ItemInfo info)
        {
            DomNode node = item as DomNode;

            if (node != null)
            {
                if (node.Type == DotaObjectsSchema.FolderType.Type)
                {
                    ProjectFolder folder = node.As <ProjectFolder>();
                    info.Label      = folder.Name;
                    info.IsLeaf     = false;
                    info.ImageIndex = info.GetImageList().Images.IndexOfKey(Resources.FolderIcon);
                }
                else
                {
                    //Lets figure out what it is
                    ProjectFile file = node.As <ProjectFile>();
                    info.Label  = file.Name;
                    info.IsLeaf = true;

                    string ext = Path.GetExtension(file.Path);
                    if (ProjectLoader.FileTypes.ContainsKey(ext))
                    {
                        info.ImageIndex = info.GetImageList().Images.IndexOfKey(ProjectLoader.FileTypes[ext].DisplayImageKey);
                    }
                    else
                    {
                        info.ImageIndex = info.GetImageList().Images.IndexOfKey(Resources.DataImage);
                    }
                }
            }
        }
示例#2
0
        public void TestBeginning()
        {
            DomNode           root      = CreateTree();
            Validator         validator = root.As <Validator>();
            ValidationContext context   = root.As <ValidationContext>();

            context.RaiseBeginning();
            Assert.True(validator.IsValidating);
            Assert.AreSame(validator.Sender, context);
            Assert.AreSame(validator.E, EventArgs.Empty);
        }
示例#3
0
        /// <summary>
        /// Opens or creates a document at the given URI</summary>
        /// <param name="uri">Document URI</param>
        /// <returns>Document, or null if the document couldn't be opened or created</returns>
        public IDocument Open(Uri uri)
        {
            DomNode node     = null;
            string  filePath = uri.LocalPath;
            string  fileName = Path.GetFileName(filePath);

            if (File.Exists(filePath))
            {
                // read existing document using standard XML reader
                using (FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    DomXmlReader reader = new DomXmlReader(m_schemaLoader);
                    node = reader.Read(stream, uri);
                }
            }
            else
            {
                // create new document by creating a Dom node of the root type defined by the schema
                node = SceneEditingContext._CreateSceneRoot("Scene");
            }



            SceneDocument document = null;

            if (node != null)
            {
                // Initialize Dom extensions now that the data is complete; after this, all Dom node
                //  adapters will have been bound to their underlying Dom node.
                node.InitializeExtensions();

                SceneEditingContext context = node.As <SceneEditingContext>();

                ControlInfo controlInfo = new ControlInfo(fileName, filePath, StandardControlGroup.Center);
                controlInfo.IsDocument = true;
                context.ControlInfo    = controlInfo;

                document     = node.As <SceneDocument>();
                document.Uri = uri;

                context.PropertyEditor  = m_propertyEditor;
                context.ContextRegistry = m_contextRegistry;
                context.Initialize(m_commandService);
                context.TreeEditor.TreeControl.Tag = document;

                context.Root = node;
                m_controlHostService.RegisterControl(context.TreeEditor.TreeControl, context.ControlInfo, this);
            }
            return(document);
        }
示例#4
0
        /// <summary>
        /// Adds new object using a transaction so the history context can be verified.
        /// Called by automated scripts during testing.</summary>
        /// <typeparam name="T">Type of object added</typeparam>
        /// <param name="objectToInsert">Object to add</param>
        /// <param name="objectToInsertTo">Parent object to add to</param>
        /// <returns>Object added as type T</returns>
        public T Insert <T>(DomNode objectToInsert, DomNode objectToInsertTo) where T : class
        {
            ITimelineObject source      = objectToInsert.As <ITimelineObject>();
            ITimelineObject destination = objectToInsertTo.As <ITimelineObject>();

            ITransactionContext transactionContext = this.As <ITransactionContext>();

            transactionContext.DoTransaction(
                delegate
            {
                Insert(source, destination);
            }, "Scripted Insert Object");

            return(objectToInsert.As <T>());
        }
示例#5
0
        protected override void OnNodeSet()
        {
            base.OnNodeSet();

            m_transformable           = DomNode.As <ITransformable>();
            DomNode.AttributeChanged += OnAttributeChanged;
        }
        public static GameObjectReference Create(DomNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (!node.Is <IGameObject>())
            {
                throw new ArgumentException(node.Type.Name + " is not derived from " +
                                            Schema.gameObjectType.Type.Name);
            }
            DomNode      rootNode = node.GetRoot();
            GameDocument gameDoc  = rootNode.As <GameDocument>();

            if (gameDoc == null)
            {
                throw new ArgumentException("nod must belong to a document.");
            }


            // create game object reference.
            DomNode             refNode = new DomNode(Schema.gameObjectReferenceType.Type);
            GameObjectReference gobRef  = refNode.As <GameObjectReference>();

            // Create Uri
            Uri ur = new Uri(gameDoc.Uri + "#" + node.GetId());

            refNode.SetAttribute(Schema.gameObjectReferenceType.refAttribute, ur);
            gobRef.m_target = node;
            return(gobRef);
        }
示例#7
0
        /// <summary>
        /// Inserts the data object into the context</summary>
        /// <param name="insertingObject">Data to insert; e.g., System.Windows.Forms.IDataObject</param>
        public void Insert(object insertingObject)
        {
            IDataObject dataObject = (IDataObject)insertingObject;

            object[] items = dataObject.GetData(typeof(object[])) as object[];
            if (items == null)
            {
                return;
            }

            object[] itemCopies = DomNode.Copy(Adapters.AsIEnumerable <DomNode>(items));

            // create a new prototype
            DomNode   node      = new DomNode(PrototypeType);
            Prototype prototype = node.As <Prototype>();

            prototype.Name = "Prototype".Localize("Circuit prototype");
            foreach (Element module in Adapters.AsIEnumerable <Element>(itemCopies))
            {
                prototype.Modules.Add(module);
            }
            foreach (Wire connection in Adapters.AsIEnumerable <Wire>(itemCopies))
            {
                prototype.Connections.Add(connection);
            }

            PrototypeFolder folder = Adapters.As <PrototypeFolder>(m_activeItem);

            if (folder == null)
            {
                folder = PrototypeFolder;
            }

            folder.Prototypes.Add(prototype);
        }
示例#8
0
        /// <summary>
        /// Find first item in a hierarchy using a predicate
        /// </summary>
        /// <typeparam name="T">Type to convert to</typeparam>
        /// <param name="domRootNode">Root item to look in</param>
        /// <param name="predicate">Predicate to use</param>
        /// <returns>Found item or null if not found</returns>
        public static T FindFirstInWhere <T>(DomNode domRootNode, Predicate <T> predicate) where T : class
        {
            if (domRootNode == null)
            {
                return(null);
            }

            if (predicate == null)
            {
                return(null);
            }

            if (domRootNode.Is <T>())
            {
                var converted = domRootNode.As <T>();
                if (predicate(converted))
                {
                    return(converted);
                }
            }

            foreach (var domNode in domRootNode.Children)
            {
                var result = FindFirstInWhere(domNode, predicate);
                if (result != null)
                {
                    return(result);
                }
            }

            return(null);
        }
示例#9
0
        unsafe internal void UpdateSecondaryNativeProperties(
            IList <PropertyInitializer> properties,
            System.IO.UnmanagedMemoryStream stream)
        {
            if (_localToWorldAttribute != null)
            {
                // we have to build a "local to world" transform, and push that through.
                var trans = DomNode.As <ITransformable>();
                if (trans != null)
                {
                    var localToWorld = trans.LocalToWorld;
                    properties.Add(
                        GameEngine.CreateInitializer(
                            _localToWorldAttribute.PropertyId, stream.PositionPointer,
                            typeof(float), 16, false));
                    for (int c = 0; c < 16; ++c)
                    {
                        ((float *)stream.PositionPointer)[c] = localToWorld[c];
                    }
                    stream.Position += sizeof(float) * 16;
                }
            }

            if (_visibleHierarchyAttribute != null)
            {
                var visible = DomNode.As <IVisible>();
                if (visible != null)
                {
                    uint d = Convert.ToUInt32(visible.Visible);
                    SetBasicProperty(_visibleHierarchyAttribute.PropertyId, d, properties, stream);
                    *(uint *)stream.PositionPointer = d;
                    stream.Position += sizeof(uint);
                }
            }
        }
示例#10
0
        /// <summary>
        /// Creates game using DOM adapters</summary>
        private static DomNode CreateGameUsingDomNodeAdapter()
        {
            // Create game
            DomNode root = new DomNode(GameSchema.gameType.Type, GameSchema.gameRootElement);
            Game    game = root.As <Game>();

            game.Name = "Ogre Adventure II";

            // Add an ogre
            DomNode ogreNode = new DomNode(GameSchema.ogreType.Type);
            Ogre    orge     = ogreNode.As <Ogre>();

            orge.Name     = "Bill";
            orge.Size     = 12;
            orge.Strength = 100;
            game.GameObjects.Add(orge);

            // Add a dwarf
            DomNode dwarfNode = new DomNode(GameSchema.dwarfType.Type);
            Dwarf   dwarf     = dwarfNode.As <Dwarf>();

            dwarf.Name       = "Sally";
            dwarf.Age        = 32;
            dwarf.Experience = 55;
            game.GameObjects.Add(dwarf);

            // Add a tree
            DomNode    treeNode = new DomNode(GameSchema.treeType.Type);
            GameObject tree     = treeNode.As <GameObject>();

            tree.Name = "Mr. Oak";
            game.GameObjects.Add(tree);

            return(game.DomNode);
        }
示例#11
0
        public IEnumerable <object> GetChildren(object parent)
        {
            DomNode domNode = parent.As <DomNode>();

            if (domNode != null)
            {
                GameReference gameRef = domNode.As <GameReference>();
                if (gameRef != null && gameRef.Target != null)
                {
                    domNode = gameRef.Target.As <DomNode>();
                }

                foreach (ChildInfo childInfo in domNode.Type.Children)
                {
                    // todo use schema annotatoin to mark types that need to have ref slot.
                    bool isReference = Schema.gameObjectReferenceType.Type.IsAssignableFrom(childInfo.Type) ||
                                       Schema.resourceReferenceType.Type.IsAssignableFrom(childInfo.Type);

                    bool hasChild = false;
                    foreach (DomNode child in domNode.GetChildren(childInfo))
                    {
                        hasChild = true;
                        if (child.Is <IListable>())
                        {
                            yield return(child);
                        }
                    }
                    if ((hasChild == false || childInfo.IsList) && isReference)
                    {
                        yield return(new Slot(domNode, childInfo));
                    }
                }
            }
        }
示例#12
0
文件: Shader.cs 项目: zparr/ATF
        private void ParseBindingsForTexture(RenderState rs)
        {
            foreach (IBinding binding in Bindings)
            {
                if (binding.BindingType == "texture")
                {
                    DomNode  textureObject = (DomNode)binding.Source;
                    ITexture texture       = textureObject.As <ITexture>();

                    string texUri = texture.PathName;

                    int texName = Global <TextureManager> .Instance.GetTextureName(texUri);

                    if (texName != -1)
                    {
                        rs.RenderMode |= RenderMode.Textured;
                        rs.TextureName = texName;

                        TextureInfo info = Global <TextureManager> .Instance.GetTextureInfo(texName);

                        if (info.Components == 4)
                        {
                            rs.RenderMode |= RenderMode.Alpha;
                        }
                    }

                    return;
                }
            }
        }
示例#13
0
        public static DomNode CreateStarter()
        {
            var result  = new DomNode(FolderST.Type);
            var adapter = result.As <PlacementsFolder>();

            if (adapter != null)
            {
                // initialize to the default settings
                var cfg = adapter.GetCfg();
                cfg.UnnamedPlacementDocuments = true;
                adapter.Reconfigure(cfg);

                // add a simple placement with a default object

                var defResource = Globals.ResourceService.Load(
                    new Uri(Utils.CurrentDirectoryAsUri(), "Game/Model/materialsphere.dae"));
                if (defResource != null)
                {
                    var plcmnt = XLEPlacementObject.Create(defResource);
                    if (plcmnt != null)
                    {
                        plcmnt.DomNode.InitializeExtensions();
                        adapter.AddChild(plcmnt);
                    }
                }
                return(result);
            }
            return(null);
        }
        private void LuaCallStackServiceLevelAdding(object sender, SledLuaCallStackServiceEventArgs e)
        {
            if ((e.NewLevel + 1) > Collection.Count)
            {
                var root =
                    new DomNode(
                        SledLuaSchema.SledLuaVarEnvListType.Type,
                        SledLuaSchema.SledLuaVarEnvListRootElement);

                var envVars = root.As <SledLuaVarEnvListType>();
                envVars.Name =
                    string.Format(
                        "{0}{1}{2}{3}",
                        ProjectService.ProjectName,
                        Resource.Space,
                        Resource.LuaEnvironmentVariables,
                        e.NewLevel);

                envVars.DomNode.AttributeChanged += DomNodeAttributeChanged;
                Collection.Add(envVars);
            }

            if ((e.NewLevel == 0) && (Collection.Count > 0))
            {
                m_editor.View = Collection[0];
            }
        }
示例#15
0
        protected ITransformable GetManipulatorNode(TransformationTypes xformType)
        {
            ITransformable manipNode         = null;
            var            selectionCntx     = DesignView.Context.As <ISelectionContext>();
            var            visibilityContext = DesignView.Context.As <IVisibilityContext>();

            if (selectionCntx.LastSelected != null)
            {
                Path <object> path = selectionCntx.LastSelected.As <Path <object> >();
                foreach (object obj in path)
                {
                    DomNode pathnode = obj.As <DomNode>();
                    if (pathnode == null)
                    {
                        break;
                    }
                    object item = Util.AdaptDomPath(pathnode);
                    if (selectionCntx.SelectionContains(item))
                    {
                        var xformable = pathnode.As <ITransformable>();
                        if (xformable != null &&
                            (xformable.TransformationType & xformType) != 0 &&
                            visibilityContext.IsVisible(pathnode))
                        {
                            manipNode = xformable;
                        }
                        break;
                    }
                }
            }
            return(manipNode);
        }
示例#16
0
        public static AddonProject OpenProjectFromFolder(string folder)
        {
            DomNode      domRoot = new DomNode(DotaObjectsSchema.ProjectType.Type);
            AddonProject project = domRoot.As <AddonProject>();

            project.Name = "adsf";

            ProjectFolder root = (new DomNode(DotaObjectsSchema.FolderType.Type)).As <ProjectFolder>();

            root.Path = folder;
            root.Name = folder.Substring(folder.LastIndexOf(Path.DirectorySeparatorChar) + 1);


            ProjectLoader.BuildProjectFromDirectoriesRecursive(folder, ref root);


            project.ProjectFiles.Add(root);

            GlobalSettings.CurrentProjectDirectory = folder;

            if (OnProjectLoad != null)
            {
                OnProjectLoad.Invoke(project);
            }



            return(project);
        }
示例#17
0
        /// <summary>
        /// Inserts the data object into the context</summary>
        /// <param name="insertingObject">Data to insert; e.g., System.Windows.Forms.IDataObject</param>
        public void Insert(object insertingObject)
        {
            IDataObject dataObject = (IDataObject)insertingObject;

            object[] items = dataObject.GetData(typeof(object[])) as object[];
            if (items == null)
            {
                return;
            }

            object[] itemCopies = DomNode.Copy(items.AsIEnumerable <DomNode>());

            // create a new prototype
            DomNode   node      = new DomNode(Schema.prototypeType.Type);
            Prototype prototype = node.As <Prototype>();

            prototype.Name = "Prototype".Localize("Statechart prototype");
            foreach (StateBase state in itemCopies.AsIEnumerable <StateBase>())
            {
                prototype.States.Add(state);
            }
            foreach (Transition transition in itemCopies.AsIEnumerable <Transition>())
            {
                prototype.Transitions.Add(transition);
            }

            PrototypeFolder folder = m_activeItem.As <PrototypeFolder>();

            if (folder == null)
            {
                folder = PrototypeFolder;
            }

            folder.Prototypes.Add(prototype);
        }
示例#18
0
文件: UIRef.cs 项目: Joxx0r/ATF
 /// <summary>
 /// Creates a new UIRef adapter and underlying DomNode</summary>
 /// <param name="uiObj">UIObject being referenced</param>
 /// <returns>New UIRef adapter</returns>
 public static UIRef New(UIObject uiObj)
 {
     DomNode node = new DomNode(UISchema.UIRefType.Type);
     UIRef uiRef = node.As<UIRef>();
     uiRef.UIObject = uiObj;
     return uiRef;
 }
示例#19
0
        /// <summary>
        /// Gets the underlying DOM node's parent adapted the given type, or null if there is
        /// no parent or it can't be adapted to the type</summary>
        /// <typeparam name="T">Desired type</typeparam>
        /// <returns>The underlying DOM node's parent adapted the given type, or null</returns>
        protected T GetParentAs <T>()
            where T : class
        {
            DomNode parent = DomNode.Parent;

            return(parent != null?parent.As <T>() : null);
        }
示例#20
0
        /// <summary>
        /// Inserts new object of given type using a transaction. Called by automated scripts during testing.</summary>
        /// <typeparam name="T">Type of object to insert</typeparam>
        /// <param name="insertingObject">DomNode that contains inserted object</param>
        /// <param name="insertionParent">Parent where object is inserted</param>
        /// <returns>Inserted object</returns>
        public T Insert <T>(DomNode insertingObject, DomNode insertionParent) where T : class
        {
            SetInsertionParent(insertionParent);
            insertingObject.SetAttribute(UISchema.UIType.nameAttribute, typeof(T).Name);
            DataObject dataObject = new DataObject(new object[] { insertingObject });

            ITransactionContext transactionContext = this.As <ITransactionContext>();

            transactionContext.DoTransaction(
                delegate
            {
                Insert(dataObject);
            }, "Scripted Insert Object");

            T         newItem   = null;
            ChildInfo childInfo = GetChildInfo(insertionParent, insertingObject.Type);

            if (childInfo != null)
            {
                if (childInfo.IsList)
                {
                    IList <DomNode> list = insertionParent.GetChildList(childInfo);
                    //This assumes the new object is always appended at the end of the list
                    DomNode newNode = list[list.Count - 1];
                    newItem = newNode.As <T>();
                }
                else
                {
                    DomNode newNode = insertionParent.GetChild(childInfo);
                    newItem = newNode.As <T>();
                }
            }

            return(newItem);
        }
        private void CreateGlobalsCollection()
        {
            if (Collection.Count <= 0)
            {
                var root =
                    new DomNode(
                        SledLuaSchema.SledLuaVarGlobalListType.Type,
                        SledLuaSchema.SledLuaVarGlobalsRootElement);

                var collection = root.As <SledLuaVarGlobalListType>();
                collection.Name =
                    string.Format(
                        "{0}{1}{2}",
                        ProjectService.ProjectName,
                        Resource.Space,
                        Resource.LuaGlobals);

                collection.DomNode.AttributeChanged += DomNodeAttributeChanged;
                Collection.Add(collection);
            }

            if (Collection.Count > 0)
            {
                m_editor.View = Collection[0];
            }
        }
示例#22
0
        public static GameObjectReference Create(DomNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (!node.Is <IGameObject>())
            {
                throw new ArgumentException(node.Type.Name + " is not derived from " +
                                            Schema.gameObjectType.Type.Name);
            }

            GameDocument gameDoc = node.GetRoot().As <GameDocument>();

            if (gameDoc == null)
            {
                throw new ArgumentException("node must belong to a document.");
            }

            // create game object reference.
            DomNode             refNode = new DomNode(Schema.gameObjectReferenceType.Type);
            GameObjectReference gobRef  = refNode.As <GameObjectReference>();

            gobRef.SetTarget(node);
            gobRef.UpdateUri();
            return(gobRef);
        }
示例#23
0
        private void SetupCompileAttribute(SledProjectFilesFileType file)
        {
            if (file == null)
            {
                return;
            }

            // Look for a SledLuaCompileAttributeType attribute in file.Attributes
            var iface = SledDomUtil.GetFirstAs <SledLuaCompileAttributeType, SledAttributeBaseType>(file.Attributes);

            // Files' attribute is already set up
            if (iface != null)
            {
                return;
            }

            var domNode = new DomNode(SledLuaSchema.SledLuaCompileAttributeType.Type);

            // Create new attribute
            var attr = domNode.As <SledLuaCompileAttributeType>();

            // Default values
            attr.Name    = m_luaLanguagePlugin.LanguageName;
            attr.Compile = true;

            // Add new attribute to file
            file.Attributes.Add(attr);
        }
示例#24
0
        /// <summary>
        /// Attempts to resolve (e.g., load from a file) the resource associated with the given URI</summary>
        /// <param name="uri">Resource URI</param>
        /// <returns>The resolved resource or null if there was a failure of some kind</returns>
        public IResource Resolve(Uri uri)
        {
            string fileName = PathUtil.GetCanonicalPath(uri);

            if (!fileName.EndsWith(".dae"))
            {
                return(null);
            }

            DomNode domNode = null;

            try
            {
                using (Stream stream = File.OpenRead(fileName))
                {
                    var persister = new ColladaXmlPersister(m_loader);
                    domNode = persister.Read(stream, uri);
                }
            }
            catch (IOException e)
            {
                Outputs.WriteLine(OutputMessageType.Warning, "Could not load resource: " + e.Message);
            }

            IResource resource = domNode.As <IResource>();

            if (resource != null)
            {
                resource.Uri = uri;
            }

            return(resource);
        }
示例#25
0
        /// <summary>
        /// Creates a new UIRef adapter and underlying DomNode</summary>
        /// <param name="uiObj">UIObject being referenced</param>
        /// <returns>New UIRef adapter</returns>
        public static UIRef New(UIObject uiObj)
        {
            DomNode node  = new DomNode(UISchema.UIRefType.Type);
            UIRef   uiRef = node.As <UIRef>();

            uiRef.UIObject = uiObj;
            return(uiRef);
        }
示例#26
0
        /// <summary>
        /// Create a SLED style breakpoint from a SyntaxEditorControl style breakpoint
        /// </summary>
        /// <param name="ibp">SyntaxEditorControl style breakpoint</param>
        /// <returns>SLED breakpoint</returns>
        public static SledProjectFilesBreakpointType Create(IBreakpoint ibp)
        {
            var node = new DomNode(SledSchema.SledProjectFilesBreakpointType.Type);
            var bp   = node.As <SledProjectFilesBreakpointType>();

            bp.Setup(ibp);
            return(bp);
        }
示例#27
0
        public static ObjectOverride Create(string name)
        {
            DomNode        node           = new DomNode(Schema.objectOverrideType.Type);
            ObjectOverride objectOverride = node.As <ObjectOverride>();

            objectOverride.ObjectName = name;
            return(objectOverride);
        }
示例#28
0
        // Filter out sub-circuits that are not actually needed
        protected override void WriteElement(DomNode node, XmlWriter writer)
        {
            var subCircuit = node.As<SubCircuit>();
            if (subCircuit != null && !m_usedSubCircuits.Contains(subCircuit))
                return;

            base.WriteElement(node, writer);
        }
示例#29
0
            public IGameObject CreateInstance()
            {
                DomNode[] org  = { m_node.GetChild(Schema.prototypeType.gameObjectChild) };
                DomNode   copy = DomNode.Copy(org)[0];

                copy.InitializeExtensions();
                return(copy.As <IGameObject>());
            }
示例#30
0
        protected override void OnNodeSet()
        {
            if (LocalTypes == null)
            {
                var domNode =
                    new DomNode(SledLuaSchema.SledLuaVarFilterTypesType.Type);

                var localTypes =
                    domNode.As <SledLuaVarFilterTypesType>();

                SetChild(SledLuaSchema.SledLuaVarFilterType.LocalTypesChild, localTypes);

                if (LocalTypes != null)
                {
                    LocalTypes.SetAll(false);
                }
            }

            if (LocalNames == null)
            {
                var domNode =
                    new DomNode(SledLuaSchema.SledLuaVarFilterNamesType.Type);

                var localNames =
                    domNode.As <SledLuaVarFilterNamesType>();

                SetChild(SledLuaSchema.SledLuaVarFilterType.LocalNamesChild, localNames);
            }

            if (TargetTypes == null)
            {
                var domNode =
                    new DomNode(SledLuaSchema.SledLuaVarFilterTypesType.Type);

                var targetTypes =
                    domNode.As <SledLuaVarFilterTypesType>();

                SetChild(SledLuaSchema.SledLuaVarFilterType.TargetTypesChild, targetTypes);

                if (TargetTypes != null)
                {
                    TargetTypes.SetAll(false);
                }
            }

            if (TargetNames == null)
            {
                var domNode =
                    new DomNode(SledLuaSchema.SledLuaVarFilterNamesType.Type);

                var targetNames =
                    domNode.As <SledLuaVarFilterNamesType>();

                SetChild(SledLuaSchema.SledLuaVarFilterType.TargetNamesChild, targetNames);
            }

            base.OnNodeSet();
        }
示例#31
0
文件: Patches.cs 项目: ldh9451/XLE
 public static DomNode GetReferenceTarget(DomNode node)
 {
     var placementsCellRef = node.As<Placements.PlacementsCellRef>();
     if (placementsCellRef != null && placementsCellRef.Target != null)
     {
         node = placementsCellRef.Target.As<DomNode>();
     }
     return node;
 }
示例#32
0
 public static PrefabInstance Create(IPrefab prefab)
 {
     DomNode instNode = new DomNode(Schema.prefabInstanceType.Type);
     PrefabInstance inst = instNode.As<PrefabInstance>();
     inst.m_prefab = prefab;
     instNode.InitializeExtensions();
     inst.Resolve(null);
     return inst;
 }
示例#33
0
        public void Insert(object parent, object insertingObject)
        {
            if (parent == null)
            {
                parent = m_activeItem ?? this;
            }

            IEnumerable <DomNode> childNodes = GetNodes(insertingObject);

            if (childNodes == null)
            {
                return;
            }

            // If the parent is the LayeringContext itself:
            // create a new layer for the objects about to be inserted
            ILayer layer = Adapters.As <ILayer>(parent);

            if (layer == null)
            {
                DomNode node     = new DomNode(Schema.layerType.Type);
                ILayer  subLayer = node.As <ILayer>();
                subLayer.Name = "New Layer".Localize();
                Layers.Add(subLayer);
                layer = subLayer;
            }


            foreach (DomNode node in childNodes)
            {
                // Insert GameObjects
                IGameObject gameObject = node.As <IGameObject>();
                if (gameObject != null && !layer.Contains(gameObject))
                {
                    GameObjectReference newRef = GameObjectReference.Create(node);
                    layer.GameObjectReferences.Add(newRef);
                }

                // Insert References
                IReference <IGameObject> reference = node.As <IReference <IGameObject> >();
                if (reference != null)
                {
                    if (reference.Target != null && !layer.Contains(reference.Target))
                    {
                        layer.GameObjectReferences.Add(reference);
                    }
                }

                // Insert Sub-Layers
                ILayer otherLayer = node.As <ILayer>();
                if (otherLayer != null)
                {
                    layer.Layers.Add(otherLayer);
                }
            }
        }
示例#34
0
        #pragma warning restore 618

        // Filter out sub-circuits that are not actually needed
        protected override void WriteElement(DomNode node, XmlWriter writer)
        {
            #pragma warning disable 618 //mastered sub-circuits are obsolete
            var subCircuit = node.As<SubCircuit>();
            if (subCircuit != null && !m_usedSubCircuits.Contains(subCircuit))
                return;
            #pragma warning restore 618

            base.WriteElement(node, writer);
        }
示例#35
0
 public void TestOnChildInserted()
 {
     DomNode root = new DomNode(RootType);
     Validator validator = root.As<Validator>();
     DomNode child = new DomNode(ChildType);
     root.SetChild(ChildInfo, child);
     Assert.AreSame(validator.Sender, root);
     ChildEventArgs e = (ChildEventArgs)validator.E;
     Assert.NotNull(e);
     Assert.AreSame(e.Parent, root);
 }
示例#36
0
        public static AttributeOverride Create(string name, string value)
        {
            if (string.IsNullOrWhiteSpace(name))
                throw new InvalidOperationException("name cannot be null or empty");

            DomNode node = new DomNode(Schema.attributeOverrideType.Type);
            AttributeOverride attrOverride = node.As<AttributeOverride>();
            attrOverride.Name = name;
            attrOverride.AttribValue = value;
            return attrOverride;
        }
示例#37
0
        public SledLuaVarGlobalType GetScmpBlobAsLuaGlobalVar()
        {
            var var = m_debugService.GetScmpBlob<Scmp.LuaVarGlobal>();
            var node = new DomNode(SledLuaSchema.SledLuaVarGlobalType.Type);

            var global = node.As<SledLuaVarGlobalType>();
            global.DisplayName = var.Name;
            global.Name = SledLuaVarBaseType.CreateFlattenedHierarchyName(var.Name, var.Hierarchy, HierarchySeparatorString);
            global.What = SledLuaUtil.LuaTypeIntToString(var.What);
            global.Value = var.Value;
            global.KeyType = var.KeyType;
            SledLuaVarBaseType.SetupTargetHierarchyFromRuntimeData(global, var.Hierarchy);
            global.GenerateUniqueName();

            return global;
        }
示例#38
0
        public static TerrainGob Create(string name, string hmPath, float cellSize)
        {            
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentNullException(name);

            if (!File.Exists(hmPath))
                throw new ArgumentException(hmPath + " does not exist");
            
            Uri ur = new Uri(hmPath);
            DomNode terrainNode = new DomNode(Schema.terrainGobType.Type);            
            terrainNode.SetAttribute(Schema.terrainGobType.cellSizeAttribute, cellSize);
            terrainNode.SetAttribute(Schema.terrainGobType.heightMapAttribute, ur);
            terrainNode.InitializeExtensions();
            TerrainGob terrain = terrainNode.As<TerrainGob>();
            terrain.Name = name;
            return terrain;
        }
示例#39
0
        private void DebugServiceDataReady(object sender, SledDebugServiceEventArgs e)
        {
            var typeCode = (Scmp.LuaTypeCodes)e.Scmp.TypeCode;

            switch (typeCode)
            {
                case Scmp.LuaTypeCodes.LuaStateBegin:
                    m_luaStatesCollection.ValidationBeginning();
                    break;

                case Scmp.LuaTypeCodes.LuaStateAdd:
                {
                    var scmp = m_debugService.GetScmpBlob<Scmp.LuaStateAdd>();

                    var domNode = new DomNode(SledLuaSchema.SledLuaStateType.Type);

                    var luaState = domNode.As<SledLuaStateType>();
                    luaState.Address = scmp.Address;
                    luaState.Name = scmp.Name;
                    luaState.Checked = scmp.Debugging == 1;

                    m_luaStatesCollection.LuaStates.Add(luaState);
                }
                break;

                case Scmp.LuaTypeCodes.LuaStateRemove:
                {
                    var scmp = m_debugService.GetScmpBlob<Scmp.LuaStateRemove>();

                    var sentinel =
                        m_luaStatesCollection.LuaStates.FirstOrDefault(
                            luaState => string.Compare(luaState.Address, scmp.Address, StringComparison.Ordinal) == 0);

                    if (sentinel != null)
                        m_luaStatesCollection.LuaStates.Remove(sentinel);
                }
                break;

                case Scmp.LuaTypeCodes.LuaStateEnd:
                    m_luaStatesCollection.ValidationEnding();
                    break;
            }
        }
        public void Remove(DomNode parent, DomNode child, ChildInfo chInfo)
        {
            NativeObjectAdapter childObject = child.As<NativeObjectAdapter>();
            NativeObjectAdapter parentObject = parent.As<NativeObjectAdapter>();

            object listIdObj = chInfo.GetTag(NativeAnnotations.NativeElement);

            if (childObject == null || parentObject == null || listIdObj == null)
                return;

            uint listId = (uint)listIdObj;
            uint typeId = (uint)chInfo.DefiningType.GetTag(NativeAnnotations.NativeType);
            ulong parentId = parentObject.InstanceId;
            ulong childId = childObject.InstanceId;
            GameEngine.ObjectRemoveChild(typeId, listId, parentId, childId);
            if (ManageNativeObjectLifeTime)
            {                
                GameEngine.DestroyObject(childObject);
            }
        }
        public void AddLocations(ISledLuaVarBaseType luaVar)
        {
            if (luaVar == null)
                return;

            Dictionary<string, List<SledLuaVariableParserService.VariableResult>> parsedVars;

            {
                var nodeType = luaVar.DomNode.Type;
                if (nodeType == SledLuaSchema.SledLuaVarLocalType.Type)
                    parsedVars = m_luaVariableParserService.ParsedLocals;
                else if (nodeType == SledLuaSchema.SledLuaVarUpvalueType.Type)
                    parsedVars = m_luaVariableParserService.ParsedUpvalues;
                else
                    parsedVars = m_luaVariableParserService.ParsedGlobals;
            }

            if (parsedVars == null)
                return;

            // No locations for variable
            List<SledLuaVariableParserService.VariableResult> items;
            if (!parsedVars.TryGetValue(luaVar.Name, out items))
                return;

            // Iterate through all values belonging to this key
            foreach (var result in items)
            {
                var domNode = new DomNode(SledSchema.SledVarLocationType.Type);

                // Generate location data
                var loc = domNode.As<SledVarLocationType>();

                loc.File = result.File.AbsolutePath;
                loc.Line = result.Line;
                loc.Occurence = result.Occurence;

                // Add to list
                luaVar.Locations.Add(loc);
            }
        }
示例#42
0
文件: Patches.cs 项目: ldh9451/XLE
        public static void CreateDefaultNodes(DomNode gameRoot)
        {
            var ext = gameRoot.As<Game.GameExtensions>();
            if (ext != null)
            {
                    // Add default environment settings
                var envFolder = ext.EnvSettingsFolder;
                if (envFolder.Settings.Count == 0)
                    envFolder.AddChild(Environment.XLEEnvSettings.Create(envFolder.GetNameForNewChild()));

                    // Add placements folder with an unnamed default placement document
                if (ext.PlacementsFolder == null)
                {
                    var newNode = Placements.PlacementsFolder.CreateStarter();
                    if (newNode != null)
                    {
                        ext.PlacementsFolder = newNode.As<Placements.PlacementsFolder>();
                    }
                }
            }
        }
示例#43
0
        public TestDataValidator()
        {
            m_childType = new DomNodeType("child");
            m_parentType = new DomNodeType("parent");
            m_parentType.Define(new ExtensionInfo<ValidationContext>());
            m_parentType.Define(new ExtensionInfo<DataValidator>());

            m_childCountRule = new ChildCountRule(2, 3);
            m_childInfo = new ChildInfo("child", m_childType, true);
            m_parentType.Define(m_childInfo);
            m_childInfo.AddRule(m_childCountRule);

            m_parent = new DomNode(m_parentType);
            m_parent.InitializeExtensions();

            m_validationContext = m_parent.As<ValidationContext>();

            m_child1 = new DomNode(m_childType);
            m_child2 = new DomNode(m_childType);
            m_child3 = new DomNode(m_childType);
            m_child4 = new DomNode(m_childType);
        }
示例#44
0
        public SledLuaVarUpvalueType GetScmpBlobAsLuaUpvalueVar()
        {
            var var = m_debugService.GetScmpBlob<Scmp.LuaVarUpvalue>();
            var node = new DomNode(SledLuaSchema.SledLuaVarUpvalueType.Type);

            var upvalue = node.As<SledLuaVarUpvalueType>();
            upvalue.DisplayName = var.Name;
            upvalue.Name = SledLuaVarBaseType.CreateFlattenedHierarchyName(var.Name, var.Hierarchy, HierarchySeparatorString);
            upvalue.What = SledLuaUtil.LuaTypeIntToString(var.What);
            upvalue.Value = var.Value;
            upvalue.Level = var.StackLevel;
            upvalue.Index = var.Index;
            upvalue.KeyType = var.KeyType;

            upvalue.FunctionName = m_luaCallStackService.Get[upvalue.Level].Function;
            upvalue.FunctionLineDefined = m_luaCallStackService.Get[upvalue.Level].LineDefined;

            SledLuaVarBaseType.SetupTargetHierarchyFromRuntimeData(upvalue, var.Hierarchy);
            upvalue.GenerateUniqueName();

            return upvalue;
        }
        public void Insert(DomNode parent, DomNode child, ChildInfo chInfo, int index)
        {
            NativeObjectAdapter childObject = child.As<NativeObjectAdapter>();
            NativeObjectAdapter parentObject = parent.As<NativeObjectAdapter>();

            object listIdObj = chInfo.GetTag(NativeAnnotations.NativeElement);

            if (childObject == null || parentObject == null || listIdObj == null)
                return;

            if (chInfo.IsList && index >= (parent.GetChildList(chInfo).Count - 1))
                index = -1;

            if (ManageNativeObjectLifeTime)
            {
                GameEngine.CreateObject(childObject);
                childObject.UpdateNativeOjbect();
            }
            System.Diagnostics.Debug.Assert(childObject.InstanceId != 0);

            uint listId = (uint)listIdObj;
            uint typeId = (uint)chInfo.DefiningType.GetTag(NativeAnnotations.NativeType);
            ulong parentId = parentObject.InstanceId;
            ulong childId = childObject.InstanceId;

            if (index >= 0)
            {
                GameEngine.ObjectInsertChild(typeId, listId, parentId, childId, index);
            }
            else
            {
                GameEngine.ObjectAddChild(typeId, listId, parentId, childId);
            }

            foreach (var node in child.Children)
            {
                Insert(child, node, node.ChildInfo, -1); // use -1 for index to indicate an append operation.
            }
        }    
示例#46
0
        /// <summary>
        /// Inserts the data object into the context</summary>
        /// <param name="insertingObject">Data to insert; e.g., System.Windows.Forms.IDataObject</param>
        public void Insert(object insertingObject)
        {
            IDataObject dataObject = (IDataObject)insertingObject;
            object[] items = dataObject.GetData(typeof(object[])) as object[];
            if (items == null)
                return;

            object[] itemCopies = DomNode.Copy(Adapters.AsIEnumerable<DomNode>(items));

            // create a new prototype
            DomNode node = new DomNode(Schema.prototypeType.Type);
            Prototype prototype = node.As<Prototype>();
            prototype.Name = Localizer.Localize("Prototype", "Statechart prototype");
            foreach (StateBase state in Adapters.AsIEnumerable<StateBase>(itemCopies))
                prototype.States.Add(state);
            foreach (Transition transition in Adapters.AsIEnumerable<Transition>(itemCopies))
                prototype.Transitions.Add(transition);

            PrototypeFolder folder = Adapters.As<PrototypeFolder>(m_activeItem);
            if (folder == null)
                folder = PrototypeFolder;

            folder.Prototypes.Add(prototype);
        }
示例#47
0
            // Persists relative references instead of absolute references
            protected override void WriteElement(DomNode node, System.Xml.XmlWriter writer)
            {
                TimelineReference reference = node.As<TimelineReference>();
                Uri originalUri = null;
                if (reference != null && reference.Uri != null && reference.Uri.IsAbsoluteUri)
                {
                    originalUri = reference.Uri;
                    reference.Uri = Uri.MakeRelativeUri(reference.Uri);
                }

                base.WriteElement(node, writer);

                if (originalUri != null)
                {
                    reference.Uri = originalUri;
                }
            }
示例#48
0
        public SledLuaVarEnvType GetScmpBlobAsLuaEnvironmentVar()
        {
            var var = m_debugService.GetScmpBlob<Scmp.LuaVarEnvVar>();
            var node = new DomNode(SledLuaSchema.SledLuaVarEnvType.Type);

            // Uses similar formatting as Globals
            var envVar = node.As<SledLuaVarEnvType>();
            envVar.DisplayName = var.Name;
            envVar.Name = SledLuaVarBaseType.CreateFlattenedHierarchyName(var.Name, var.Hierarchy, HierarchySeparatorString);
            envVar.What = SledLuaUtil.LuaTypeIntToString(var.What);
            envVar.Value = var.Value;
            envVar.Level = var.StackLevel; // Extra non-global param
            envVar.KeyType = var.KeyType;
            SledLuaVarBaseType.SetupTargetHierarchyFromRuntimeData(envVar, var.Hierarchy);
            envVar.GenerateUniqueName();

            return envVar;
        }
示例#49
0
        private void CreateLuaStatesCollection()
        {
            var root =
                new DomNode(
                    SledLuaSchema.SledLuaStateListType.Type,
                    SledLuaSchema.SledLuaStatesListRootElement);

            m_luaStatesCollection = root.As<SledLuaStateListType>();

            m_luaStatesCollection.Name =
                string.Format(
                    "{0}{1}{2}",
                    m_projectService.ProjectName,
                    Resources.Resource.Space,
                    Resources.Resource.LuaStateList);

            m_luaStatesEditor.View = m_luaStatesCollection;
        }
示例#50
0
        public void Insert(object parent, object insertingObject)
        {
            if (parent == null)
                parent = m_activeItem ?? this;

            IEnumerable<DomNode> childNodes = GetNodes(insertingObject);
            if (childNodes == null) return;

            // If the parent is the LayeringContext itself:
            // create a new layer for the objects about to be inserted
            ILayer layer = Adapters.As<ILayer>(parent);
            if (layer == null)
            {
                DomNode node = new DomNode(Schema.layerType.Type);
                ILayer subLayer = node.As<ILayer>();
                subLayer.Name = "New Layer".Localize();
                Layers.Add(subLayer);
                layer = subLayer;
            }


            foreach (DomNode node in childNodes)
            {
                // Insert GameObjects
                IGameObject gameObject = node.As<IGameObject>();
                if (gameObject != null && !layer.Contains(gameObject))
                {
                    GameObjectReference newRef = GameObjectReference.Create(node);                    
                    layer.GameObjectReferences.Add(newRef);
                }

                // Insert References
                IReference<IGameObject> reference = node.As<IReference<IGameObject>>();
                if (reference != null)
                {
                    if (reference.Target != null && !layer.Contains(reference.Target))
                        layer.GameObjectReferences.Add(reference);
                }

                // Insert Sub-Layers
                ILayer otherLayer = node.As<ILayer>();
                if (otherLayer != null)
                    layer.Layers.Add(otherLayer);
            }
        }
示例#51
0
        private void CreateSyntaxErrorsCollection()
        {
            var root =
                new DomNode(
                    SledSchema.SledSyntaxErrorListType.Type,
                    SledSchema.SledSyntaxErrorsRootElement);

            m_syntaxErrorsCollection =
                root.As<SledSyntaxErrorListType>();

            m_syntaxErrorsCollection.Name =
                string.Format(
                    "{0}{1}{2}",
                    m_projectService.ProjectName,
                    Resource.Space,
                    Resource.SyntaxErrorsTitle);
        }
 /// <summary>
 /// Unregisters the Control from the IContextRegistry and IControlHostService and disposes
 /// it and sets the circuitNode's ViewingContext's Control property to null.</summary>
 private void UnregisterControl(DomNode circuitNode, Control control)
 {
     //it's OK if the CircuitEditingContext was already removed or wasn't added to IContextRegistry.
     m_contextRegistry.RemoveContext(circuitNode.As<CircuitEditingContext>());
     m_controlHostService.UnregisterControl(control);
     control.Visible = false;
     control.Dispose();
     m_circuitNodeControls.Remove(circuitNode);
     circuitNode.Cast<ViewingContext>().Control = null;
 }
示例#53
0
        public void TestMoveDomNode()
        {
            var root = new DomNode(RootType.Type, RootElement);

            root.InitializeExtensions();

            var folderChild1 = new DomNode(FolderType.Type);
            var folderChild2 = new DomNode(FolderType.Type);
            var itemChild1 = new DomNode(ItemType.Type);
            var itemChild2 = new DomNode(ItemType.Type);

            var validationContext = root.As<ValidationContext>();
            
            // Set up the tree:
            // root
            //     folder
            //         item
            //     folder1
            //         item

            validationContext.RaiseBeginning();

            root.SetAttribute(RootType.NameAttribute, "root");
            itemChild1.SetAttribute(ItemType.NameAttribute, "item");
            itemChild2.SetAttribute(ItemType.NameAttribute, "item");
            folderChild1.SetAttribute(FolderType.NameAttribute, "folder");
            folderChild2.SetAttribute(FolderType.NameAttribute, "folder");

            folderChild1.GetChildList(FolderType.ItemChild).Add(itemChild1);
            folderChild2.GetChildList(FolderType.ItemChild).Add(itemChild2);

            root.GetChildList(RootType.FolderChild).Add(folderChild1);
            root.GetChildList(RootType.FolderChild).Add(folderChild2);

            // renames all folders and items with unique paths
            validationContext.RaiseEnding();
            validationContext.RaiseEnded(); 

            // Move item from first folder to second folder
            // root
            //     folder
            //     folder1
            //         item
            //         item1

            validationContext.RaiseBeginning();

            itemChild1.RemoveFromParent();
            folderChild2.GetChildList(FolderType.ItemChild).Add(itemChild1);

            validationContext.RaiseEnding();
            validationContext.RaiseEnded();
            Assert.DoesNotThrow(() => ValidateSubtree(folderChild2));
            // Make sure that the existing child wasn't renamed. Only the moved child should be renamed.
            Assert.True((string)itemChild2.GetAttribute(ItemType.NameAttribute) == "item");

            // Rename 'item_1' to 'item'.
            validationContext.RaiseBeginning();

            itemChild1.SetAttribute(ItemType.NameAttribute, "item");

            validationContext.RaiseEnding();
            validationContext.RaiseEnded();
            Assert.DoesNotThrow(() => ValidateSubtree(folderChild2));

            // Make sure that the existing child wasn't renamed. Only the moved child should be renamed.
            Assert.True((string)itemChild2.GetAttribute(ItemType.NameAttribute) == "item");

            // Rename the root.
            validationContext.RaiseBeginning();

            root.SetAttribute(RootType.NameAttribute, "new_root");

            validationContext.RaiseEnding();
            validationContext.RaiseEnded();
            Assert.DoesNotThrow(() => ValidateSubtree(root));
            Assert.True((string)root.GetAttribute(RootType.NameAttribute) == "new_root");
        }
示例#54
0
        private void ShowBreakpointConditionForm(DomNode domNode)
        {
            if (domNode == null)
                return;

            if (!domNode.Is<SledProjectFilesBreakpointType>())
                return;

            var bp =
                domNode.As<SledProjectFilesBreakpointType>();

            if (bp == null)
                return;

            ShowBreakpointConditionFormInternal(bp);
        }
示例#55
0
        private static void ConditionEnableOrDisable(DomNode domNode, bool bEnable)
        {
            var bp =
                domNode.As<SledProjectFilesBreakpointType>();

            // Make change (will cause events to fire in DomCollection_AttributeChanging/DomCollection_AttributeChanged)
            bp.ConditionEnabled = bEnable;
        }
示例#56
0
        private static void RemoveBreakpoint(DomNode domNode)
        {
            var bp = domNode.As<SledProjectFilesBreakpointType>();

            // Remove from project and breakpoint window (event gets fired through DomCollection_ChildRemoving)
            bp.File.Breakpoints.Remove(bp);
        }
示例#57
0
            private static void GatherNodeTypes(DomNode domNode, ICollection<SledProjectFilesFolderType> lstFolders)
            {
                if (domNode.Is<SledProjectFilesFolderType>())
                    lstFolders.Add(domNode.As<SledProjectFilesFolderType>());

                foreach (var child in domNode.Children)
                {
                    GatherNodeTypes(child, lstFolders);
                }
            }
示例#58
0
 public static Prefab Create(DomNode node, Uri ur)
 {
     if (node.Type != Schema.prefabType.Type)
         throw new InvalidOperationException("Invalid node type");
     Prefab prefab = node.As<Prefab>();
     prefab.m_uri = ur;
     prefab.Name = Path.GetFileNameWithoutExtension(ur.LocalPath);
     return prefab;
 }
        /// <summary>
        /// Projects the ghost</summary>
        private void ProjectGhost(DomNode ghost, 
            Ray3F rayw,
            HitRecord? hit)
        {

            ITransformable xformnode = ghost.Cast<ITransformable>();
            IBoundable bnode  = ghost.As<IBoundable>();
            AABB box = bnode.BoundingBox;
            
            Vec3F pt;
            if (hit.HasValue && hit.Value.hasNormal)
            {
                Vec3F rad = box.Radius;
                Vec3F norm = hit.Value.normal;
                Vec3F absNorm = Vec3F.Abs(norm);
                Vec3F offset = Vec3F.ZeroVector;
                
                if (absNorm.X > absNorm.Y)
                {
                    if (absNorm.X > absNorm.Z)
                        offset.X = norm.X > 0 ? rad.X : -rad.X;
                    else
                        offset.Z = norm.Z > 0 ? rad.Z : -rad.Z;                        
                }
                else
                {
                    if (absNorm.Y > absNorm.Z)
                        offset.Y = norm.Y > 0 ? rad.Y : -rad.Y;
                    else
                        offset.Z = norm.Z > 0 ? rad.Z : -rad.Z;                        
                        
                }                
                Vec3F localCenter = box.Center - xformnode.Translation;
                pt = hit.Value.hitPt + (offset - localCenter);
            }
            else
            {
                float offset = 6.0f * box.Radius.Length;
                pt = rayw.Origin + offset * rayw.Direction;
            }
                                          
            if (ViewType == ViewTypes.Front)
                pt.Z = 0.0f;
            else if (ViewType == ViewTypes.Top)
                pt.Y = 0.0f;
            else if (ViewType == ViewTypes.Left)
                pt.X = 0.0f;           
            xformnode.Translation = pt;

        }