private bool GetEnabled() { if (!InvokeRequired) { return(base.Enabled); } GetBoolDelegate del = GetEnabled; return(Invoke(del) is bool && (bool)Invoke(del)); }
private bool GetEnabled() { if (Parent == null || !Parent.InvokeRequired) { return(base.Enabled); } GetBoolDelegate del = GetEnabled; return(Parent.Invoke(del) is bool && (bool)Parent.Invoke(del)); }
/// <summary> /// 初始化非托管委托指针(函数指针); /// </summary> private void InitializePtr() { //位置委托; SetInt64Delegate setPos = OnSetPos; GetInt64Delegate getPos = OnGetPos; delegates.Add(setPos); delegates.Add(getPos); SetPositionFunc( StreamPtr, getPos, setPos ); //长度委托; GetInt64Delegate getLength = OnGetLength; delegates.Add(getLength); SetGetLengthFunc(StreamPtr, getLength); //可读/写委托; GetBoolDelegate canRead = OnCanRead; GetBoolDelegate canWrite = OnCanWrite; delegates.Add(canRead); delegates.Add(canWrite); SetCanReadFunc(StreamPtr, canRead); SetCanWriteFunc(StreamPtr, canWrite); //写入委托; WriteDelegate write = OnWrite; delegates.Add(write); SetWriteFunc(StreamPtr, write); //读取委托; ReadDelegate read = OnRead; delegates.Add(read); SetReadFunc(StreamPtr, read); }
/// <summary> /// Constructor /// </summary> /// <param name="path">path is "form-name/label-text"</param> /// <param name="getValue">lambda expression to get value</param> /// <param name="setValue">lambda expression to set value</param> public InputBool(string path, GetBoolDelegate getValue, SetBoolDelegate setValue) : base(path, () => getValue().ToString(), (val) => setValue(Convert.ToBoolean(val))) { }
private static extern void SetCanWriteFunc(IntPtr stream, GetBoolDelegate canWriteFunc);
private static extern void SetCanReadFunc(IntPtr stream, [MarshalAs(UnmanagedType.FunctionPtr)] GetBoolDelegate canReadFunc);