Пример #1
0
        /// <summary>
        /// Creates and attaches a button to the shared control panel.
        /// </summary>
        /// <param name="buttonName">The name of the button.</param>
        /// <param name="onChange">
        /// The callback method that will be called every time the button changes state.
        /// </param>
        /// <param name="buttonType">The type of button to create.</param>
        /// <param name="initialButtonState">The initial state of the button.</param>
        /// <returns>
        /// <b>true</b> if the button was created successfully; otherwise, <b>false</b>.
        /// </returns>
        public static bool CreateButton(
            string buttonName       = null,
            ButtonCallback onChange = null,
            ButtonType buttonType   = ButtonType.PushButton,
            bool initialButtonState = false)
        {
            _CvButtonCallback callback = onChange != null ? (state, userdata) => onChange(state > 0 ? true : false) : (_CvButtonCallback)null;

            return(NativeMethods.cvCreateButton(buttonName, callback, IntPtr.Zero, buttonType, initialButtonState ? 1 : 0) > 0);
        }
Пример #2
0
 internal static extern int cvCreateButton(
     string button_name,
     _CvButtonCallback on_change,
     IntPtr userdata,
     ButtonType button_type,
     int initial_button_state);