public void GetHierachyTest() { Project project = new Project("Projekt1", new User("NotKewin2"), new List <User>() { new User("Karsten") }); Storage.SaveProjectToFile(project); Storage.WriteToFile(project, testDoc); Storage.WriteToFile(project, testDoc1); Storage.WriteToFile(project, testDoc2); Folder root = new Folder("root"); Folder cuteanimals = new Folder("cuteanimalsxoxo"); Folder reptiles = new Folder("reptiles"); DocumentStruct testStruct0 = new DocumentStruct(testDoc.Title, testDoc.Owner, testDoc.Id, testDoc.Path, true, true); DocumentStruct testStruct1 = new DocumentStruct(testDoc1.Title, testDoc1.Owner, testDoc1.Id, testDoc1.Path, true, true); DocumentStruct testStruct2 = new DocumentStruct(testDoc2.Title, testDoc2.Owner, testDoc2.Id, testDoc2.Path, true, true); reptiles.AddChild(testStruct2); cuteanimals.AddChild(testStruct0); root.AddChild(testStruct1); cuteanimals.AddChild(reptiles); root.AddChild(cuteanimals); project.AddChild(root); Project expected = project; Project actual = Storage.GetHierachy(project.Id); Assert.AreEqual(expected, actual); }
private void openGLControl1_OpenGLInitialized(object sender, EventArgs e) { //clear grid and axis openGLControl1.Scene.SceneContainer.Children.Clear(); //set background color GLColor background = new GLColor(11 / 255f, 18 / 255f, 34 / 255f, 1); openGLControl1.Scene.ClearColour = background; // Create some lights. Light light1 = new Light() { Name = "Light 1", On = true, Position = new Vertex(-9, -9, 11), GLCode = OpenGL.GL_LIGHT0 }; Light light2 = new Light() { Name = "Light 2", On = true, Position = new Vertex(9, -9, 11), GLCode = OpenGL.GL_LIGHT1 }; Light light3 = new Light() { Name = "Light 3", On = true, Position = new Vertex(0, 15, 15), GLCode = OpenGL.GL_LIGHT2 }; // Add the lights. var folder = new Folder() { Name = "Lights" }; folder.AddChild(light1); folder.AddChild(light2); folder.AddChild(light3); openGLControl1.Scene.SceneContainer.AddChild(folder); var lookAtCamera = new LookAtCamera() { Position = new Vertex(0f, -20f, 2f), Target = new Vertex(0f, 0f, 0f), UpVector = new Vertex(0f, 0f, 1f) }; // Set the look at camera as the current camera. openGLControl1.Scene.CurrentCamera = lookAtCamera; }
public override System.Object Exec(Computer computer, Shell shell, String[] args) { if (args.Length > 2) { if (args[1] == "/") { return(null); } FileTreeNode file = _GetNode(computer, shell, args[1]); Folder to = (Folder)_GetNode(computer, shell, args[2]); if ((file == null) || (to == null)) { return(null); } if (to is Folder) { if (!to.HasChild(file.name)) { var parent = ((Folder)file.parent); parent.RemoveChild(file.name); to.AddChild(file); } else { shell.PushMsg("无法移动,已有同名文件"); } } } return(null); }
/// <summary> /// Downloads the trailer. /// </summary> /// <param name="trailer">The trailer.</param> /// <param name="trailerFolder">The trailer folder.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> private async Task DownloadTrailer(TrailerInfo trailer, Folder trailerFolder, CancellationToken cancellationToken) { var video = trailer.Video; var existing = trailerFolder .Children .OfType <Trailer>() .FirstOrDefault(i => string.Equals(i.Path, trailer.TrailerUrl, StringComparison.OrdinalIgnoreCase)); if (existing != null) { video = existing; } else { video.Path = trailer.TrailerUrl; await trailerFolder.AddChild(video, cancellationToken).ConfigureAwait(false); } // Figure out which image we're going to download var imageUrl = trailer.HdImageUrl ?? trailer.ImageUrl; if (!video.HasImage(ImageType.Primary) && !string.IsNullOrEmpty(imageUrl)) { await ProviderManager.SaveImage(video, imageUrl, Plugin.Instance.AppleTrailers, ImageType.Primary, null, cancellationToken).ConfigureAwait(false); await LibraryManager.UpdateItem(video, ItemUpdateType.ImageUpdate, cancellationToken).ConfigureAwait(false); } }
private void AddSourceFile(Folder folder, string filePath, string[] parts, int index) { if (index == parts.Length - 1) { var file = new SourceFile() { SourceFilePath = filePath, Name = parts[index] }; foreach (var target in GetTargets(filePath)) { file.Children.Add(new Target() { Name = target, SourceFilePath = filePath }); } folder.AddChild(file); } else { var subfolder = folder.GetOrCreateNodeWithName <Folder>(parts[index]); subfolder.IsExpanded = true; AddSourceFile(subfolder, filePath, parts, index + 1); } }
/// <summary> /// Method for forward execution like do or redo. /// Redo will not generate a new <see cref="folderP"/>. /// </summary> public override void Execute() { TreeNode parent = regionBegin.Parent; bool folderPNotExist = folderP == null; if (folderPNotExist) { folderP = new Folder(parent.parentWorkSpace, regionBegin.attributes[0].AttrInput); } int index = parent.Children.IndexOf(regionBegin); parent.InsertChild(folderP, index); foreach (TreeNode t in toAggregate) { parent.RemoveChild(t); if (folderPNotExist) { folderP.AddChild(t); } } parent.RemoveChild(regionBegin); if (regionEnd != null) { parent.RemoveChild(regionEnd); } }
/// <summary> /// Create an entity, under a folder parent. /// </summary> /// <param name="folderParent"></param> /// <returns></returns> public Entity CreateEntity(Folder folderParent) { // parent folder is null? its the root if (folderParent == null) { folderParent = _reposit.Finder.GetRootFolder(); } // create an entity, attach it under the parent Entity entity = new Entity(); entity.ParentFolderId = folderParent.Id; // set a key to the property root PropertyKeyString key = new PropertyKeyString(); key.Key = CoreDef.DefaultPropertyRootName; entity.PropertyRoot.Key = key; // save it if (!_reposit.Builder.SaveEntity(entity)) { return(null); } folderParent.AddChild(entity); // update the parent foder, has a new child if (!_reposit.Builder.UpdateFolder(folderParent)) { return(null); } return(entity); }
private Folder GetAlbumFolder(TrackInfo track) { string artist = FileSystem.Safe(track.DisplayAlbumArtistName); string album = FileSystem.Safe(track.DisplayAlbumTitle); string key = MakeAlbumKey(track); if (album_cache.ContainsKey(key)) { return(album_cache [key].Item2); } Folder root = mtp_device.MusicFolder; Folder tmp = root.GetChildren().Find(x => FileSystem.EqualsNoCase(artist, x.Name)); Folder target; if (null == tmp) { target = root.AddChild(artist).AddChild(album); } else { target = tmp.GetChildren().Find(x => FileSystem.EqualsNoCase(album, x.Name)); if (null == target) { target = tmp.AddChild(album); } } return(target); }
private void AddStageNode() { TreeNode newSt = new Stage(parent.ActivatedWorkSpaceData); TreeNode newTask = new TaskNode(parent.ActivatedWorkSpaceData); TreeNode newFolder = new Folder(parent.ActivatedWorkSpaceData, "Initialize"); newFolder.AddChild(new Code(parent.ActivatedWorkSpaceData, "LoadMusic(\'spellcard\',\'THlib\\\\music\\\\spellcard.ogg\',75,0xc36e80/44100/4)")); newFolder.AddChild(new StageBG(parent.ActivatedWorkSpaceData, "bamboo_background")); newTask.AddChild(newFolder); newTask.AddChild(new TaskWait(parent.ActivatedWorkSpaceData, "60")); newTask.AddChild(new PlayBGM(parent.ActivatedWorkSpaceData, "\"spellcard\"", "", "false")); newTask.AddChild(new TaskWait(parent.ActivatedWorkSpaceData, "180")); newSt.AddChild(newTask); parent.Insert(newSt); }
public string Export(IEnumerable <IPlantillaCompuestaExportable> plantillas) { logger.Info("export {0}", Utilities.Serializer.Serialize2JSON(plantillas)); // Crear el estilo para el ícono var style = new Style(); style.Id = "plantillaSimpleIcon"; style.Icon = new IconStyle(); //style.Icon.Color = new Color32(255, 0, 255, 0); //style.Icon.ColorMode = ColorMode.Normal; style.Icon.Icon = new IconStyle.IconLink(new Uri("http://www.tatuel.com.ar/assets/img/plantillas/plantilla-simple.png")); style.Icon.Scale = 1.1; // Conjunto de localizaciones Folder carpeta = new Folder(); carpeta.Name = "Localizaciones de referencia"; carpeta.AddStyle(style); // Recorrer cada instancia de plantilla simple y cargar ese punto Point point; foreach (IPlantillaCompuestaExportable pc in plantillas) { point = new Point(); point.AltitudeMode = AltitudeMode.Absolute; point.Id = "Tatuel"; point.TargetId = pc.idTemporal; point.Coordinate = new Vector(pc.latitud, pc.longitud, pc.altitud); Placemark marca = new Placemark(); marca.Name = "" + pc.descripcion; marca.Geometry = point; // descripcion marca.Description = new Description(); marca.Description.Text = pc.descripcion; marca.ExtendedData = new ExtendedData(); marca.ExtendedData.AddData(new Data() { DisplayName = pc.criterioDeAgrupacion, Name = "Nombre", Value = pc.descripcion }); marca.Time = new Timestamp() { When = pc.fechaHora }; marca.StyleUrl = new Uri("#plantillaSimpleIcon", UriKind.Relative); // agregarlo a la carpeta carpeta.AddChild(marca); } // Crear el archivo KML con esa carpeta Kml kml = new Kml(); kml.Feature = carpeta; // Serializar y devolver Serializer serializerKml = new Serializer(); serializerKml.Serialize(kml); return(serializerKml.Xml); }
public void Test() { var root = new Folder("root"); var subFolder = new Folder("sub-folder"); var file1 = new File("file1"); var file2 = new File("file2"); var items = new List <IFolderItem>(); root.AddChild(subFolder); root.AddChild(file1); subFolder.AddChild(file2); items.Add(root); items.Add(subFolder); items.Add(file1); items.Add(file2); items.ForEach(i => Debug.WriteLine(i.Name)); }
private void AddStageNode() { TreeNode newSt = new Stage(parent.ActivatedWorkSpaceData); TreeNode newTask = new TaskNode(parent.ActivatedWorkSpaceData); TreeNode newFolder = new Folder(parent.ActivatedWorkSpaceData, "Initialize"); newFolder.AddChild(new StageBG(parent.ActivatedWorkSpaceData)); newTask.AddChild(newFolder); newTask.AddChild(new TaskWait(parent.ActivatedWorkSpaceData, "240")); newSt.AddChild(newTask); parent.Insert(newSt); }
/// <summary> /// Create a folder, under a folder parent. /// (null for the root folder) /// </summary> /// <param name="folderParent"></param> /// <param name="name"></param> /// <returns></returns> public Folder CreateFolder(Folder folderParent, string name) { if (string.IsNullOrWhiteSpace(name)) { return(null); } // check the syntax // TODO: no special character,... // parent folder is null? its the root if (folderParent == null) { folderParent = _reposit.Finder.GetRootFolder(); } else { // check that the name is not used by a folder in the folder parent scope if (_reposit.Finder.FindFolder(folderParent, name, false) != null) { return(null); } } // create a folder, attach it the parent Folder folder = new Folder(); folder.Name = name; folder.ParentFolderId = folderParent.Id; // save it if (!_reposit.Builder.SaveFolder(folder)) { return(null); } folderParent.AddChild(folder); // update the parent foder, has a new child if (!_reposit.Builder.UpdateFolder(folderParent)) { return(null); } return(folder); }
private IEnumerable BuildFindResults(object resultsObject, bool moreAvailable = false) { if (resultsObject == null) { return(null); } var results = resultsObject as IEnumerable <(string, IEnumerable <(int, string)>)>; var root = new Folder(); // root.Children.Add(new Message { Text = "Elapsed " + Elapsed.ToString() }); if (results != null) { foreach (var file in results) { var folder = new SourceFile() { Name = Path.GetFileName(file.Item1), SourceFilePath = file.Item1, IsExpanded = true }; root.AddChild(folder); foreach (var line in file.Item2) { var sourceFileLine = new SourceFileLine() { LineNumber = line.Item1 + 1, LineText = line.Item2 }; folder.AddChild(sourceFileLine); } } } if (!root.HasChildren && !string.IsNullOrEmpty(findInFilesControl.SearchText)) { root.Children.Add(new Message { Text = "No results found." }); } return(root.Children); }
/// <summary> /// Create an entity template under the root folder parent. /// </summary> /// <param name="name"></param> /// <returns></returns> public EntityTempl CreateEntityTempl(Folder folderParent, string name) { // parent folder is null? its the root if (folderParent == null) { folderParent = _reposit.Finder.GetRootFolder(); } // TODO: if (string.IsNullOrWhiteSpace(name)) { return(null); } // check the syntax // TODO: no special character,... // create an entity, attach it the parent EntityTempl entityTempl = new EntityTempl(); entityTempl.ParentFolderId = folderParent.Id; entityTempl.Name = name; // set a key to the property root PropKeyTemplString key = new PropKeyTemplString(); key.Key = CoreDef.DefaultPropertyRootName; entityTempl.PropertyRoot.Key = key; // save it if (!_reposit.Builder.SaveEntityTempl(entityTempl)) { return(null); } folderParent.AddChild(entityTempl); // update the parent foder, has a new child if (!_reposit.Builder.UpdateFolder(folderParent)) { return(null); } return(entityTempl); }
private void AddSourceFile(Folder folder, string filePath, string[] parts, int index) { if (index == parts.Length - 1) { var file = new SourceFile() { SourceFilePath = filePath, Name = parts[index] }; folder.AddChild(file); } else { var subfolder = folder.GetOrCreateNodeWithName <Folder>(parts[index]); subfolder.IsExpanded = true; AddSourceFile(subfolder, filePath, parts, index + 1); } }
/// <summary> /// Initialises a modeling scene. A modeling scene has: /// - A 'Look At' camera targetting the centre of the scene /// - Three gentle omnidirectional lights /// - A design time grid and axis. /// </summary> /// <param name="scene">The scene.</param> public static void InitialiseModelingScene(ColorCodedPickingScene scene) { // Create the 'Look At' camera var lookAtCamera = new ScientificCamera() { Position = new Vertex(-10f, -10f, 10f), Target = new Vertex(0f, 0f, 0f), UpVector = new Vertex(0f, 0f, 1f) }; // Set the look at camera as the current camera. scene.CurrentCamera = lookAtCamera; // Add some design-time primitives. var folder = new Folder() { Name = "Design Primitives" }; folder.AddChild(new Grid()); folder.AddChild(new Axies()); scene.SceneContainer.AddChild(folder); // Create some lights. Light light1 = new Light() { Name = "Light 1", On = true, Position = new Vertex(-9, -9, 11), GLCode = OpenGL.GL_LIGHT0 }; Light light2 = new Light() { Name = "Light 2", On = true, Position = new Vertex(9, -9, 11), GLCode = OpenGL.GL_LIGHT1 }; Light light3 = new Light() { Name = "Light 3", On = true, Position = new Vertex(0, 15, 15), GLCode = OpenGL.GL_LIGHT2 }; // Add the lights. folder = new Folder() { Name = "Lights" }; folder.AddChild(light1); folder.AddChild(light2); folder.AddChild(light3); scene.SceneContainer.AddChild(folder); // Create a set of scene attributes. OpenGLAttributesEffect sceneAttributes = new OpenGLAttributesEffect() { Name = "Scene Attributes" }; // Specify the scene attributes. sceneAttributes.EnableAttributes.EnableDepthTest = true; sceneAttributes.EnableAttributes.EnableNormalize = true; sceneAttributes.EnableAttributes.EnableLighting = true; sceneAttributes.EnableAttributes.EnableTexture2D = true; sceneAttributes.EnableAttributes.EnableBlend = true; sceneAttributes.ColorBufferAttributes.BlendingSourceFactor = BlendingSourceFactor.SourceAlpha; sceneAttributes.ColorBufferAttributes.BlendingDestinationFactor = BlendingDestinationFactor.OneMinusSourceAlpha; sceneAttributes.LightingAttributes.TwoSided = true; scene.SceneContainer.AddEffect(sceneAttributes); }
private void InitializeModelScene(Scene scene, Rect3D rect3D, OpenGLControl sceneControl, ArcBallEffect arcBallEffect) { float centerX = rect3D.X + rect3D.Size.x / 2.0f; float centerY = rect3D.Y + rect3D.Size.y / 2.0f; float centerZ = rect3D.Z + rect3D.Size.z / 2.0f; //scene.CreateInContext(scenContor); Vertex center = new Vertex(centerX, centerY, centerZ); Vertex position = center + new Vertex(0.0f, 0.0f, 1.0f) * (rect3D.Size.z * 2); Vertex PositionNear = center + new Vertex(0.0f, 0.0f, 1.0f) * (rect3D.Size.z * 0.52f); //arcBallEffect. var lookAtCamera = new LookAtCamera() { Position = position, Target = center, UpVector = new Vertex(0f, 1f, 0f), FieldOfView = 60, AspectRatio = 1.0f, Near = (PositionNear - center).Z, Far = float.MaxValue }; scene.CurrentCamera = lookAtCamera; Vertex lightPosition = center; Light light1 = new Light() { Name = "Light 1", On = true, Position = lightPosition, GLCode = OpenGL.GL_LIGHT0 }; /* * Light light2 = new Light() * { * Name = "Light 2", * On = true, * Position = center + new Vertex(1.0f,0.0f,0.0f)* rect3D.Size.x, * GLCode = OpenGL.GL_LIGHT1 * }; * * Light light3 = new Light() * { * Name = "Light 3", * On = true, * Position = center + new Vertex(0.0f,1.0f,0.0f)*rect3D.Size.y, * GLCode = OpenGL.GL_LIGHT2 * }; */ var folder = new Folder() { Name = "Lights" }; folder.AddChild(light1); //folder.AddChild(light2); //folder.AddChild(light3); scene.SceneContainer.AddChild(folder); // Create a set of scene attributes. OpenGLAttributesEffect sceneAttributes = new OpenGLAttributesEffect() { Name = "Scene Attributes" }; // Specify the scene attributes. sceneAttributes.EnableAttributes.EnableDepthTest = true; sceneAttributes.EnableAttributes.EnableNormalize = true; sceneAttributes.EnableAttributes.EnableLighting = true; sceneAttributes.EnableAttributes.EnableTexture2D = true; sceneAttributes.EnableAttributes.EnableBlend = true; sceneAttributes.ColorBufferAttributes.BlendingSourceFactor = BlendingSourceFactor.SourceAlpha; sceneAttributes.ColorBufferAttributes.BlendingDestinationFactor = BlendingDestinationFactor.OneMinusSourceAlpha; sceneAttributes.LightingAttributes.TwoSided = true; scene.SceneContainer.AddEffect(sceneAttributes); sceneControl.OpenGL.SetDimensions(sceneControl.Width, sceneControl.Height); scene.Resize(sceneControl.Width, sceneControl.Height); }
public string Export(IPlantillaCompuestaExportable plantilla, IEnumerable <IInstanciaPlantillaCompuestaExportable> instancias) { logger.Info("export {0}, {1}", Utilities.Serializer.Serialize2JSON(plantilla), Utilities.Serializer.Serialize2JSON(instancias)); // Crear el estilo para el ícono var style = new Style(); style.Id = "plantillaSimpleIcon"; style.Icon = new IconStyle(); //style.Icon.Color = new Color32(255, 0, 255, 0); //style.Icon.ColorMode = ColorMode.Normal; style.Icon.Icon = new IconStyle.IconLink(new Uri("http://www.tatuel.com.ar/assets/img/plantillas/plantilla-simple.png")); style.Icon.Scale = 1.1; // Conjunto de localizaciones Folder carpeta = new Folder(); carpeta.Name = "Localizaciones de carga de datos"; carpeta.AddStyle(style); // Recorrer cada instancia de plantilla simple y cargar ese punto Point point; foreach (Models.IInstanciaPlantillaCompuestaExportable ipc in instancias) { //if (ipc.posicion != null) //{ point = new Point(); point.AltitudeMode = AltitudeMode.Absolute; point.Id = "Tatuel"; //LatitudLongitud latlon = (LatitudLongitud)ipc.posicion; point.Coordinate = new Vector(ipc.latitud, ipc.longitud, ipc.altitud); Placemark marca = new Placemark(); marca.Name = "" + ipc.descripcion; marca.Geometry = point; // descripcion marca.Description = new Description(); marca.Description.Text = "Punto de carga de datos "; marca.ExtendedData = new ExtendedData(); marca.ExtendedData.AddData(new Data() { DisplayName = "Datos serializados en formato JSON", Name = "Datos serializados en formato JSON", Value = Utilities.Serializer.Serialize2JSON(new { accuracy = ipc.accuracy, altitud = ipc.altitud, altitudAccuracy = ipc.altitudAccuracy, descripcion = ipc.descripcion, fechaHora = ipc.fechaHora, idTemporal = ipc.idTemporal, latitud = ipc.latitud, longitud = ipc.longitud }) }); marca.Time = new Timestamp() { When = ipc.fechaHora }; marca.StyleUrl = new Uri("#plantillaSimpleIcon", UriKind.Relative); // agregarlo a la carpeta carpeta.AddChild(marca); //} } // Crear el archivo KML con esa carpeta Kml kml = new Kml(); kml.Feature = carpeta; // Serializar y devolver Serializer serializerKml = new Serializer(); serializerKml.Serialize(kml); return(serializerKml.Xml); }