AntTweakBar.Tw.AddVarCB C# (CSharp) Method

AddVarCB() public static method

This function adds a new variable to a tweak bar by providing CallBack (CB) functions to access it.
public static AddVarCB ( IntPtr bar, String name, VariableType type, SetVarCallback setCallback, GetVarCallback getCallback, IntPtr clientData, 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.
setCallback SetVarCallback The callback function that will be called by AntTweakBar to change the variable’s value.
getCallback GetVarCallback The callback function that will be called by AntTweakBar to get the variable’s value.
clientData System.IntPtr For your convenience, this is a supplementary pointer that will be passed to the callback functions when they are called.
def String An optional definition string used to modify the behavior of this new entry.
return void
        public static void AddVarCB(IntPtr bar, String name, VariableType type, SetVarCallback setCallback, GetVarCallback getCallback, IntPtr clientData, String def)
        {
            if (bar == IntPtr.Zero) {
                throw new ArgumentOutOfRangeException("bar");
            } else if (type == VariableType.Undefined) {
                throw new ArgumentOutOfRangeException("type");
            } else if (name == null) {
                throw new ArgumentNullException("name");
            } else if (getCallback == null) {
                throw new ArgumentNullException("getCallback");
            }

            if (!NativeMethods.TwAddVarCB(bar, name, type, setCallback, getCallback, clientData, def)) {
                throw new AntTweakBarException("TwAddVarCB failed.");
            }
        }