AntTweakBar.Tw.AddVarRW C# (CSharp) Method

AddVarRW() public static method

This function adds a new variable to a tweak bar by specifying the variable’s pointer. The variable is declared Read-Write (RW), so it could be modified interactively by the user.
public static AddVarRW ( IntPtr bar, String name, VariableType type, IntPtr var, String def ) : void
bar System.IntPtr The tweak bar to which adding a new variable.
name String The name of the variable. It will be displayed in the tweak bar if no label is specified for this variable. It will also be used to refer to this variable in other functions.
type VariableType Type of the variable. It must be one of the constants or a user defined type.
var System.IntPtr Pointer to the variable linked to this entry.
def String An optional definition string used to modify the behavior of this new entry.
return void
        public static void AddVarRW(IntPtr bar, String name, VariableType type, IntPtr var, String def)
        {
            if (bar == IntPtr.Zero) {
                throw new ArgumentOutOfRangeException("bar");
            } else if (type == VariableType.Undefined) {
                throw new ArgumentOutOfRangeException("type");
            } else if (var == IntPtr.Zero) {
                throw new ArgumentOutOfRangeException("var");
            } else if (name == null) {
                throw new ArgumentNullException("name");
            }

            if (!NativeMethods.TwAddVarRW(bar, name, type, var, def)) {
                throw new AntTweakBarException("TwAddVarRW failed.");
            }
        }