/// <summary> /// получение из XML /// </summary> /// <param name="arg"></param> /// <returns></returns> public static DbStructureStatus Get(StructureStatus arg) { return(new DbStructureStatus() { StrstatId = arg.StrstatId, Name = arg.Name, ShortName = arg.ShortName }); }
/// <summary>Gets the handle to the object associated to this structure.</summary> /// <param name="encoding">The fallback encoding for loading objects.</param> /// <param name="obj">Receives the handle to the object associated to this structure.</param> /// <returns>The success of this operation. The operation fails if the object cannot be loaded or registered.</returns> internal bool Get(Encoding encoding, out OpenBveApi.Geometry.ObjectHandle handle) { if (this.Status == StructureStatus.Pending) { OpenBveApi.Path.FileReference file = new OpenBveApi.Path.FileReference(this.File); OpenBveApi.General.Origin origin = new OpenBveApi.General.Origin(file, null, encoding); OpenBveApi.General.Result result = Interfaces.Host.LoadObject(origin, out this.Object); if (result == OpenBveApi.General.Result.Successful) { if (this.Mirrored) { this.Object.Scale(new OpenBveApi.Math.Vector3(-1.0, 1.0, 1.0)); } result = Interfaces.Host.RegisterObject(this.Object, out this.Handle); if (result == OpenBveApi.General.Result.Successful) { this.Status = StructureStatus.LoadedAndRegistered; handle = this.Handle; return true; } else { this.Status = StructureStatus.LoadedCannotRegister; handle = null; return false; } } else { this.Status = StructureStatus.CannotLoad; handle = null; return false; } } else if (this.Status == StructureStatus.LoadedPendingRegistration) { OpenBveApi.General.Result result = Interfaces.Host.RegisterObject(this.Object, out this.Handle); if (result == OpenBveApi.General.Result.Successful) { this.Status = StructureStatus.LoadedAndRegistered; handle = this.Handle; return true; } else { this.Status = StructureStatus.LoadedCannotRegister; handle = null; return false; } } else if (this.Status == StructureStatus.LoadedAndRegistered) { handle = this.Handle; return true; } else { handle = null; return false; } }
// constructors /// <summary>Creates a new instance of this class.</summary> /// <param name="index1">The first index associated to this structure.</param> /// <param name="index2">The second index associated to this structure.</param> /// <param name="file">The file that stores the object.</param> /// <param name="mirrored">Whether to mirror the structure on its x-axis.</param> /// <remarks>The Status of the created structure is set to StructureStatus.Pending.</remarks> internal Structure(int index1, int index2, string file, bool mirrored) { this.Index1 = index1; this.Index2 = index2; this.File = file; this.Mirrored = mirrored; this.Status = StructureStatus.Pending; this.Object = null; this.Handle = null; }