/// <summary> /// Function to load an animation from a file. /// </summary> /// <param name="fileName">Path and file name for the animation file.</param> /// <returns>The loaded animation from the file.</returns> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="fileName"/> parameter is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the fileName parameter is an empty string. /// <para>-or-</para> /// <para>Thrown when the stream parameter does not contain a Gorgon animation file.</para> /// <para>-or-</para> /// <para>Thrown when the name of the animation is already present in the controller animation collection.</para> /// <para>-or-</para> /// <para>Thrown when a track type cannot be associated with a property on the object type that the controller was declared with.</para> /// </exception> /// <exception cref="System.InvalidCastException">Thrown when the animation being loaded is for a different type than the controller was declared with.</exception> public GorgonAnimation <T> FromFile(string fileName) { GorgonDebug.AssertParamString(fileName, "fileName"); using (FileStream file = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { return(FromStream(file)); } }
/// <summary> /// Function to add a section to the configuration. /// </summary> /// <param name="section">Section that will contain the new section.</param> /// <param name="name">Name of the section.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="name"/> parameter was NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the applicationName parameter is empty or the <paramref name="section"/> does not exist.</exception> private void AddSection(string section, string name) { GorgonDebug.AssertParamString(name, "name"); XElement currentSection = GetSectionElement(section); currentSection.Add(new XElement("Section", new XAttribute("SectionName", name))); }
/// <summary> /// Function to save the animation to a file. /// </summary> /// <param name="fileName">Path and file name of the file to write.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="fileName"/> parameter is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the fileName parameter is an empty string.</exception> public void Save(string fileName) { GorgonDebug.AssertParamString(fileName, "fileName"); using (FileStream stream = File.Open(fileName, FileMode.Create, FileAccess.Write, FileShare.None)) { Save(stream); } }
/// <summary> /// Initializes a new instance of the <see cref="GorgonAnimatedProperty" /> struct. /// </summary> /// <param name="displayName">The display name used to override the property name.</param> /// <param name="propertyInfo">The property info.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="displayName"/> or <paramref name="propertyInfo"/> parameters are NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the displayName parameter is an empty string.</exception> public GorgonAnimatedProperty(string displayName, PropertyInfo propertyInfo) { GorgonDebug.AssertParamString(displayName, "displayName"); GorgonDebug.AssertNull(propertyInfo, "propertyInfo"); DisplayName = displayName; DataType = propertyInfo.PropertyType; Property = propertyInfo; }
/// <summary> /// Function to enumerate all the plug-in names from an assembly. /// </summary> /// <param name="assemblyFile">File containing the plug-ins.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="assemblyFile"/> parameter is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the assemblyFile parameter is an empty string.</exception> /// <exception cref="System.IO.FileNotFoundException">Thrown when the assembly file could not be found.</exception> /// <remarks>Unlike the overload of this method, this method will check only the file pointed at by <c>assemblyFile</c>.</remarks> public IList <string> EnumeratePlugIns(string assemblyFile) { GorgonDebug.AssertParamString(assemblyFile, assemblyFile); CreateAppDomains(); // Function to load a list of type names from an assembly. return(_verifier.GetPlugInTypes(FindPlugInAssembly(assemblyFile))); }
/// <summary> /// Initializes a new instance of the <see cref="GorgonAnimation{T}" /> class. /// </summary> /// <param name="controller">Animation controller that owns this animation.</param> /// <param name="name">The name.</param> /// <param name="length">The length of the animation, in milliseconds.</param> internal GorgonAnimation(GorgonAnimationController <T> controller, string name, float length) : base(name) { GorgonDebug.AssertParamString(name, "name"); Tracks = new GorgonAnimationTrackCollection <T>(this); Length = length; Speed = 1.0f; AnimationController = controller; }
/// <summary> /// Inserts the specified index. /// </summary> /// <param name="index">The index.</param> /// <param name="item">The item.</param> public void Insert(int index, string item) { GorgonDebug.AssertParamString(item, "item"); if (Contains(ValidatePath(item))) { return; } _paths.Insert(index, item); }
/// <summary> /// Function to remove an animation from the collection. /// </summary> /// <param name="animation">Animation to remove.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="animation"/> parameter is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the animation parameter is an empty string.</exception> /// <exception cref="System.Collections.Generic.KeyNotFoundException">Thrown when the animation was not found in the collection.</exception> public void Remove(string animation) { GorgonDebug.AssertParamString(animation, "animation"); #if DEBUG if (!Contains(animation)) { throw new KeyNotFoundException(string.Format(Resources.GORANM_ANIMATION_DOES_NOT_EXIST, animation)); } #endif RemoveItem(this[animation]); }
/// <summary> /// Function to set an animation playing. /// </summary> /// <param name="animatedObject">The object to apply the animation onto.</param> /// <param name="animation">Name of the animation to start playing.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="animation"/> or <paramref name="animatedObject"/> parameters are NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the animation parameter is an empty string.</exception> /// <exception cref="System.Collections.Generic.KeyNotFoundException">Thrown when the animation could not be found in the collection.</exception> public void Play(T animatedObject, string animation) { GorgonDebug.AssertParamString(animation, animation); #if DEBUG if (!Contains(animation)) { throw new KeyNotFoundException(string.Format(Resources.GORANM_ANIMATION_DOES_NOT_EXIST, animation)); } #endif Play(animatedObject, this[animation]); }
/// <summary> /// Function to add an animation to the collection. /// </summary> /// <param name="name">Name of the animation to add.</param> /// <param name="length">Length of the animation, in seconds.</param> /// <returns>The newly created animation.</returns> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="name"/> parameter is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the name parameter is an empty string. /// <para>-or-</para> /// <para>Thrown when the animation already exists in this collection.</para></exception> public GorgonAnimation <T> Add(string name, float length) { GorgonDebug.AssertParamString(name, "name"); #if DEBUG if (Contains(name)) { throw new ArgumentException(string.Format(Resources.GORANM_ANIMATION_ALREADY_EXISTS, name), "name"); } #endif var result = new GorgonAnimation <T>(this, name, length); AddItem(result); return(result); }
/// <summary> /// Initializes a new instance of the <see cref="GorgonApplicationSettings"/> class. /// </summary> /// <param name="applicationName">Name of the application.</param> /// <param name="settingsVersion">The version of the settings file.</param> /// <remarks>Passing NULL (Nothing in VB.Net) to the <paramref name="settingsVersion"/> parameter will bypass version checking for the settings.</remarks> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="applicationName"/> parameter was NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the applicationName parameter is empty.</exception> protected GorgonApplicationSettings(string applicationName, Version settingsVersion) { GorgonDebug.AssertParamString(applicationName, "applicationName"); _properties = new Dictionary <PropertyInfo, ApplicationSettingAttribute>(); ApplicationName = applicationName; Version = settingsVersion; _path = GorgonComputerInfo.FolderPath(Environment.SpecialFolder.ApplicationData); _path += System.IO.Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture); _path += applicationName.RemoveIllegalFilenameChars() + System.IO.Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture); _path += System.IO.Path.ChangeExtension(GetType().Assembly.GetName().Name.RemoveIllegalFilenameChars(), "config.xml"); Clear(); }
/// <summary> /// Function to save the shader to a file. /// </summary> /// <param name="fileName">File name and path for the shader file.</param> /// <param name="binary">[Optional] TRUE if saving as a binary version of the shader, FALSE if not.</param> /// <param name="saveDebug">[Optional] TRUE to save debug information with the shader, FALSE to exclude it.</param> /// <remarks>The <paramref name="saveDebug"/> parameter is only applicable when the <paramref name="binary"/> parameter is set to TRUE.</remarks> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="fileName"/> parameter is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown is the fileName parameter is an empty string. /// <para>-or-</para> /// <para>Thrown when the shader is being saved as source code and the <see cref="GorgonLibrary.Graphics.GorgonShader.SourceCode">SourceCode</see> parameter is NULL (Nothing in VB.Net) or empty.</para> /// </exception> /// <exception cref="GorgonLibrary.GorgonException">Thrown when the shader fails to compile.</exception> public void Save(string fileName, bool binary = false, bool saveDebug = false) { FileStream stream = null; GorgonDebug.AssertParamString(fileName, "fileName"); try { stream = File.Open(fileName, FileMode.Create, FileAccess.Write, FileShare.None); Save(stream, binary, saveDebug); } finally { if (stream != null) { stream.Dispose(); } } }
/// <summary> /// Function to set a value for a property. /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="value">Value to assign to the property.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="propertyName"/> parameter is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the propertyName parameter is an empty string.</exception> protected void SetData(string propertyName, object value) { GorgonDebug.AssertParamString(propertyName, "propertyName"); GorgonDebug.AssertNull(Data[propertyName], "propertyName"); GorgonCustomHIDProperty property; if (Data.TryGetValue(propertyName, out property)) { property.SetValue(value); } else { Data.Add(new GorgonCustomHIDProperty(propertyName, value)); } if (DataChanged != null) { DataChanged(this, new GorgonCustomHIDDataChangedEventArgs(Data[propertyName])); } }
/// <summary> /// Function to remove a path entry. /// </summary> /// <param name="item">Item to remove</param> public void Remove(string item) { GorgonDebug.AssertParamString(item, "item"); _paths.Remove(item); }
/// <summary> /// Function to remove a plug-in by index. /// </summary> /// <param name="name">Name of the plug-in to remove.</param> /// <exception cref="System.ArgumentNullException">The <paramRef name="name"/> was NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">The name was an empty string..</exception> public void Unload(string name) { GorgonDebug.AssertParamString(name, "name"); RemoveItem(name); }
/// <summary> /// Function to define a new button for the device. /// </summary> /// <param name="name">Name of the button to define.</param> /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="name"/> parameter is NULL (Nothing in VB.Net).</exception> /// <exception cref="System.ArgumentException">Thrown when the name parameter is empty. /// <para>-or-</para> /// <para>Thrown when the name already exists in the list.</para> /// </exception> protected void DefineButton(string name) { GorgonDebug.AssertParamString(name, "name"); AddItem(new JoystickButtonState(name, false)); }