ControlCrossThreadAccessor/ControlDelegate
От: adontz Грузия http://adontz.wordpress.com/
Дата: 08.06.06 23:06
Оценка:
Вот, нагенерировал
A journey of a thousand miles must begin with a single step © Lau Tsu
Re: ControlDelegate
От: adontz Грузия http://adontz.wordpress.com/
Дата: 08.06.06 23:07
Оценка:
/******************************************************************************/
/*                                                                            */
/*    _                ___        _..-._                                      */
/*    \`.|\..----...-'`   `-._.-'' _.-..'                                     */
/*    /  ' `         ,       __.-''                                           */
/*    )/` _/     \   `-_,   /                                                 */
/*    `-'" `"\_  ,_.-;_.-\_ ',  NABU Project                                  */
/*        _.-'_./   {_.'   ; /  Nabu.Forms Library                            */
/*       {_.-``-'         {_/   Copyright © 2005-2006, TrifleSoft             */
/*                                                                            */
/******************************************************************************/
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace Nabu.Forms
{
    public static class ControlDelegate
    {
        #region Types

        public delegate AccessibleObject GetAccessibleObjectHandler();
        
        public delegate AccessibleRole GetAccessibleRoleHandler();
        public delegate void SetAccessibleRoleHandler(AccessibleRole value);
        
        public delegate AnchorStyles GetAnchorStylesHandler();
        public delegate void SetAnchorStylesHandler(AnchorStyles value);
        
        public delegate BindingContext GetBindingContextHandler();
        public delegate void SetBindingContextHandler(BindingContext value);
        
        public delegate bool GetBooleanHandler();
        public delegate void SetBooleanHandler(bool value);

        public delegate ContextMenu GetContextMenuHandler();
        public delegate void SetContextMenuHandler(ContextMenu value);

        public delegate ContextMenuStrip GetContextMenuStripHandler();
        public delegate void SetContextMenuStripHandler(ContextMenuStrip value);
        
        public delegate Control GetControlHandler();
        public delegate void SetControlHandler(Control value);
        
        public delegate Control.ControlCollection GetControlCollectionHandler();

        public delegate ControlBindingsCollection GetControlBindingsCollectionHandler();
        
        public delegate Color GetColorHandler();
        public delegate void SetColorHandler(Color value);

        public delegate Cursor GetCursorHandler();
        public delegate void SetCursorHandler(Cursor value);

        public delegate DockStyle GetDockStyleHandler();
        public delegate void SetDockStyleHandler(DockStyle value);

        public delegate Font GetFontHandler();
        public delegate void SetFontHandler(Font value);
        
        public delegate IContainer GetIContainerHandler();

        public delegate ImeMode GetImeModeHandler();
        public delegate void SetImeModeHandler(ImeMode value);

        public delegate ISite GetISiteHandler();
        public delegate void SetISiteHandler(ISite value);

        public delegate IWindowTarget GetIWindowTargetHandler();
        public delegate void SetIWindowTargetHandler(IWindowTarget value);

        public delegate int GetInt32Handler();
        public delegate void SetInt32Handler(int value);
        
        public delegate Image GetImageHandler();
        public delegate void SetImageHandler(Image value);
        
        public delegate ImageLayout GetImageLayoutHandler();
        public delegate void SetImageLayoutHandler(ImageLayout value);
        
        public delegate IntPtr GetIntPtrHandler();
        
        public delegate object GetObjectHandler();
        public delegate void SetObjectHandler(object value);

        public delegate Padding GetPaddingHandler();
        public delegate void SetPaddingHandler(Padding value);
        
        public delegate Point GetPointHandler();
        public delegate void SetPointHandler(Point value);
        
        public delegate Rectangle GetRectangleHandler();
        public delegate void SetRectangleHandler(Rectangle value);

        public delegate Region GetRegionHandler();
        public delegate void SetRegionHandler(Region value);

        public delegate RightToLeft GetRightToLeftHandler();
        public delegate void SetRightToLeftHandler(RightToLeft value);
        
        public delegate Size GetSizeHandler();
        public delegate void SetSizeHandler(Size value);
        
        public delegate string GetStringHandler();
        public delegate void SetStringHandler(string value);

        #endregion
        
        #region Methods

        #region AccessibilityObject

        public static GetAccessibleObjectHandler GetAccessibilityObject(Control control)
        {
            return (GetAccessibleObjectHandler)Delegate.CreateDelegate(typeof(GetAccessibleObjectHandler), control, "get_AccessibilityObject");
        }

        #endregion

        #region Bottom

        public static GetInt32Handler GetBottom(Control control)
        {
            return (GetInt32Handler)Delegate.CreateDelegate(typeof(GetInt32Handler), control, "get_Bottom");
        }

        #endregion

        #region CanFocus

        public static GetBooleanHandler GetCanFocus(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_CanFocus");
        }

        #endregion

        #region CanSelect

        public static GetBooleanHandler GetCanSelect(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_CanSelect");
        }

        #endregion

        #region ClientRectangle

        public static GetRectangleHandler GetClientRectangle(Control control)
        {
            return (GetRectangleHandler)Delegate.CreateDelegate(typeof(GetRectangleHandler), control, "get_ClientRectangle");
        }

        #endregion

        #region CompanyName

        public static GetStringHandler GetCompanyName(Control control)
        {
            return (GetStringHandler)Delegate.CreateDelegate(typeof(GetStringHandler), control, "get_CompanyName");
        }

        #endregion

        #region Container

        public static GetIContainerHandler GetContainer(Control control)
        {
            return (GetIContainerHandler)Delegate.CreateDelegate(typeof(GetIContainerHandler), control, "get_Container");
        }

        #endregion

        #region ContainsFocus

        public static GetBooleanHandler GetContainsFocus(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_ContainsFocus");
        }

        #endregion

        #region Controls

        public static GetControlCollectionHandler GetControls(Control control)
        {
            return (GetControlCollectionHandler)Delegate.CreateDelegate(typeof(GetControlCollectionHandler), control, "get_Controls");
        }

        #endregion

        #region Created

        public static GetBooleanHandler GetCreated(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_Created");
        }

        #endregion

        #region DataBindings

        public static GetControlBindingsCollectionHandler GetDataBindings(Control control)
        {
            return (GetControlBindingsCollectionHandler)Delegate.CreateDelegate(typeof(GetControlBindingsCollectionHandler), control, "get_DataBindings");
        }

        #endregion

        #region DisplayRectangle

        public static GetRectangleHandler GetDisplayRectangle(Control control)
        {
            return (GetRectangleHandler)Delegate.CreateDelegate(typeof(GetRectangleHandler), control, "get_DisplayRectangle");
        }

        #endregion

        #region Disposing

        public static GetBooleanHandler GetDisposing(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_Disposing");
        }

        #endregion

        #region Focused

        public static GetBooleanHandler GetFocused(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_Focused");
        }

        #endregion

        #region Handle

        public static GetIntPtrHandler GetHandle(Control control)
        {
            return (GetIntPtrHandler)Delegate.CreateDelegate(typeof(GetIntPtrHandler), control, "get_Handle");
        }

        #endregion

        #region HasChildren

        public static GetBooleanHandler GetHasChildren(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_HasChildren");
        }

        #endregion

        #region InvokeRequired

        public static GetBooleanHandler GetInvokeRequired(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_InvokeRequired");
        }

        #endregion

        #region IsDisposed

        public static GetBooleanHandler GetIsDisposed(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_IsDisposed");
        }

        #endregion

        #region IsHandleCreated

        public static GetBooleanHandler GetIsHandleCreated(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_IsHandleCreated");
        }

        #endregion

        #region IsMirrored

        public static GetBooleanHandler GetIsMirrored(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_IsMirrored");
        }

        #endregion

        #region PreferredSize

        public static GetSizeHandler GetPreferredSize(Control control)
        {
            return (GetSizeHandler)Delegate.CreateDelegate(typeof(GetSizeHandler), control, "get_PreferredSize");
        }

        #endregion

        #region ProductName

        public static GetStringHandler GetProductName(Control control)
        {
            return (GetStringHandler)Delegate.CreateDelegate(typeof(GetStringHandler), control, "get_ProductName");
        }

        #endregion

        #region ProductVersion

        public static GetStringHandler GetProductVersion(Control control)
        {
            return (GetStringHandler)Delegate.CreateDelegate(typeof(GetStringHandler), control, "get_ProductVersion");
        }

        #endregion

        #region RecreatingHandle

        public static GetBooleanHandler GetRecreatingHandle(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_RecreatingHandle");
        }

        #endregion

        #region Right

        public static GetInt32Handler GetRight(Control control)
        {
            return (GetInt32Handler)Delegate.CreateDelegate(typeof(GetInt32Handler), control, "get_Right");
        }

        #endregion

        #region TopLevelControl

        public static GetControlHandler GetTopLevelControl(Control control)
        {
            return (GetControlHandler)Delegate.CreateDelegate(typeof(GetControlHandler), control, "get_TopLevelControl");
        }

        #endregion

        #region AccessibleDefaultActionDescription

        public static GetStringHandler GetAccessibleDefaultActionDescription(Control control)
        {
            return (GetStringHandler)Delegate.CreateDelegate(typeof(GetStringHandler), control, "get_AccessibleDefaultActionDescription");
        }

        public static SetStringHandler SetAccessibleDefaultActionDescription(Control control)
        {
            return (SetStringHandler)Delegate.CreateDelegate(typeof(SetStringHandler), control, "set_AccessibleDefaultActionDescription");
        }

        #endregion

        #region AccessibleDescription

        public static GetStringHandler GetAccessibleDescription(Control control)
        {
            return (GetStringHandler)Delegate.CreateDelegate(typeof(GetStringHandler), control, "get_AccessibleDescription");
        }

        public static SetStringHandler SetAccessibleDescription(Control control)
        {
            return (SetStringHandler)Delegate.CreateDelegate(typeof(SetStringHandler), control, "set_AccessibleDescription");
        }

        #endregion

        #region AccessibleName

        public static GetStringHandler GetAccessibleName(Control control)
        {
            return (GetStringHandler)Delegate.CreateDelegate(typeof(GetStringHandler), control, "get_AccessibleName");
        }

        public static SetStringHandler SetAccessibleName(Control control)
        {
            return (SetStringHandler)Delegate.CreateDelegate(typeof(SetStringHandler), control, "set_AccessibleName");
        }

        #endregion

        #region AccessibleRole

        public static GetAccessibleRoleHandler GetAccessibleRole(Control control)
        {
            return (GetAccessibleRoleHandler)Delegate.CreateDelegate(typeof(GetAccessibleRoleHandler), control, "get_AccessibleRole");
        }

        public static SetAccessibleRoleHandler SetAccessibleRole(Control control)
        {
            return (SetAccessibleRoleHandler)Delegate.CreateDelegate(typeof(SetAccessibleRoleHandler), control, "set_AccessibleRole");
        }

        #endregion

        #region AllowDrop

        public static GetBooleanHandler GetAllowDrop(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_AllowDrop");
        }

        public static SetBooleanHandler SetAllowDrop(Control control)
        {
            return (SetBooleanHandler)Delegate.CreateDelegate(typeof(SetBooleanHandler), control, "set_AllowDrop");
        }

        #endregion

        #region Anchor

        public static GetAnchorStylesHandler GetAnchor(Control control)
        {
            return (GetAnchorStylesHandler)Delegate.CreateDelegate(typeof(GetAnchorStylesHandler), control, "get_Anchor");
        }

        public static SetAnchorStylesHandler SetAnchor(Control control)
        {
            return (SetAnchorStylesHandler)Delegate.CreateDelegate(typeof(SetAnchorStylesHandler), control, "set_Anchor");
        }

        #endregion

        #region AutoScrollOffset

        public static GetPointHandler GetAutoScrollOffset(Control control)
        {
            return (GetPointHandler)Delegate.CreateDelegate(typeof(GetPointHandler), control, "get_AutoScrollOffset");
        }

        public static SetPointHandler SetAutoScrollOffset(Control control)
        {
            return (SetPointHandler)Delegate.CreateDelegate(typeof(SetPointHandler), control, "set_AutoScrollOffset");
        }

        #endregion

        #region AutoSize

        public static GetBooleanHandler GetAutoSize(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_AutoSize");
        }

        public static SetBooleanHandler SetAutoSize(Control control)
        {
            return (SetBooleanHandler)Delegate.CreateDelegate(typeof(SetBooleanHandler), control, "set_AutoSize");
        }

        #endregion

        #region BackColor

        public static GetColorHandler GetBackColor(Control control)
        {
            return (GetColorHandler)Delegate.CreateDelegate(typeof(GetColorHandler), control, "get_BackColor");
        }

        public static SetColorHandler SetBackColor(Control control)
        {
            return (SetColorHandler)Delegate.CreateDelegate(typeof(SetColorHandler), control, "set_BackColor");
        }

        #endregion

        #region BackgroundImage

        public static GetImageHandler GetBackgroundImage(Control control)
        {
            return (GetImageHandler)Delegate.CreateDelegate(typeof(GetImageHandler), control, "get_BackgroundImage");
        }

        public static SetImageHandler SetBackgroundImage(Control control)
        {
            return (SetImageHandler)Delegate.CreateDelegate(typeof(SetImageHandler), control, "set_BackgroundImage");
        }

        #endregion

        #region BackgroundImageLayout

        public static GetImageLayoutHandler GetBackgroundImageLayout(Control control)
        {
            return (GetImageLayoutHandler)Delegate.CreateDelegate(typeof(GetImageLayoutHandler), control, "get_BackgroundImageLayout");
        }

        public static SetImageLayoutHandler SetBackgroundImageLayout(Control control)
        {
            return (SetImageLayoutHandler)Delegate.CreateDelegate(typeof(SetImageLayoutHandler), control, "set_BackgroundImageLayout");
        }

        #endregion

        #region BindingContext

        public static GetBindingContextHandler GetBindingContext(Control control)
        {
            return (GetBindingContextHandler)Delegate.CreateDelegate(typeof(GetBindingContextHandler), control, "get_BindingContext");
        }

        public static SetBindingContextHandler SetBindingContext(Control control)
        {
            return (SetBindingContextHandler)Delegate.CreateDelegate(typeof(SetBindingContextHandler), control, "set_BindingContext");
        }

        #endregion

        #region Bounds

        public static GetRectangleHandler GetBounds(Control control)
        {
            return (GetRectangleHandler)Delegate.CreateDelegate(typeof(GetRectangleHandler), control, "get_Bounds");
        }

        public static SetRectangleHandler SetBounds(Control control)
        {
            return (SetRectangleHandler)Delegate.CreateDelegate(typeof(SetRectangleHandler), control, "set_Bounds");
        }

        #endregion

        #region Capture

        public static GetBooleanHandler GetCapture(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_Capture");
        }

        public static SetBooleanHandler SetCapture(Control control)
        {
            return (SetBooleanHandler)Delegate.CreateDelegate(typeof(SetBooleanHandler), control, "set_Capture");
        }

        #endregion

        #region CausesValidation

        public static GetBooleanHandler GetCausesValidation(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_CausesValidation");
        }

        public static SetBooleanHandler SetCausesValidation(Control control)
        {
            return (SetBooleanHandler)Delegate.CreateDelegate(typeof(SetBooleanHandler), control, "set_CausesValidation");
        }

        #endregion

        #region ClientSize

        public static GetSizeHandler GetClientSize(Control control)
        {
            return (GetSizeHandler)Delegate.CreateDelegate(typeof(GetSizeHandler), control, "get_ClientSize");
        }

        public static SetSizeHandler SetClientSize(Control control)
        {
            return (SetSizeHandler)Delegate.CreateDelegate(typeof(SetSizeHandler), control, "set_ClientSize");
        }

        #endregion

        #region ContextMenu

        public static GetContextMenuHandler GetContextMenu(Control control)
        {
            return (GetContextMenuHandler)Delegate.CreateDelegate(typeof(GetContextMenuHandler), control, "get_ContextMenu");
        }

        public static SetContextMenuHandler SetContextMenu(Control control)
        {
            return (SetContextMenuHandler)Delegate.CreateDelegate(typeof(SetContextMenuHandler), control, "set_ContextMenu");
        }

        #endregion

        #region ContextMenuStrip

        public static GetContextMenuStripHandler GetContextMenuStrip(Control control)
        {
            return (GetContextMenuStripHandler)Delegate.CreateDelegate(typeof(GetContextMenuStripHandler), control, "get_ContextMenuStrip");
        }

        public static SetContextMenuStripHandler SetContextMenuStrip(Control control)
        {
            return (SetContextMenuStripHandler)Delegate.CreateDelegate(typeof(SetContextMenuStripHandler), control, "set_ContextMenuStrip");
        }

        #endregion

        #region Cursor

        public static GetCursorHandler GetCursor(Control control)
        {
            return (GetCursorHandler)Delegate.CreateDelegate(typeof(GetCursorHandler), control, "get_Cursor");
        }

        public static SetCursorHandler SetCursor(Control control)
        {
            return (SetCursorHandler)Delegate.CreateDelegate(typeof(SetCursorHandler), control, "set_Cursor");
        }

        #endregion

        #region Dock

        public static GetDockStyleHandler GetDock(Control control)
        {
            return (GetDockStyleHandler)Delegate.CreateDelegate(typeof(GetDockStyleHandler), control, "get_Dock");
        }

        public static SetDockStyleHandler SetDock(Control control)
        {
            return (SetDockStyleHandler)Delegate.CreateDelegate(typeof(SetDockStyleHandler), control, "set_Dock");
        }

        #endregion

        #region Enabled

        public static GetBooleanHandler GetEnabled(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_Enabled");
        }

        public static SetBooleanHandler SetEnabled(Control control)
        {
            return (SetBooleanHandler)Delegate.CreateDelegate(typeof(SetBooleanHandler), control, "set_Enabled");
        }

        #endregion

        #region Font

        public static GetFontHandler GetFont(Control control)
        {
            return (GetFontHandler)Delegate.CreateDelegate(typeof(GetFontHandler), control, "get_Font");
        }

        public static SetFontHandler SetFont(Control control)
        {
            return (SetFontHandler)Delegate.CreateDelegate(typeof(SetFontHandler), control, "set_Font");
        }

        #endregion

        #region ForeColor

        public static GetColorHandler GetForeColor(Control control)
        {
            return (GetColorHandler)Delegate.CreateDelegate(typeof(GetColorHandler), control, "get_ForeColor");
        }

        public static SetColorHandler SetForeColor(Control control)
        {
            return (SetColorHandler)Delegate.CreateDelegate(typeof(SetColorHandler), control, "set_ForeColor");
        }

        #endregion

        #region Height

        public static GetInt32Handler GetHeight(Control control)
        {
            return (GetInt32Handler)Delegate.CreateDelegate(typeof(GetInt32Handler), control, "get_Height");
        }

        public static SetInt32Handler SetHeight(Control control)
        {
            return (SetInt32Handler)Delegate.CreateDelegate(typeof(SetInt32Handler), control, "set_Height");
        }

        #endregion

        #region ImeMode

        public static GetImeModeHandler GetImeMode(Control control)
        {
            return (GetImeModeHandler)Delegate.CreateDelegate(typeof(GetImeModeHandler), control, "get_ImeMode");
        }

        public static SetImeModeHandler SetImeMode(Control control)
        {
            return (SetImeModeHandler)Delegate.CreateDelegate(typeof(SetImeModeHandler), control, "set_ImeMode");
        }

        #endregion

        #region IsAccessible

        public static GetBooleanHandler GetIsAccessible(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_IsAccessible");
        }

        public static SetBooleanHandler SetIsAccessible(Control control)
        {
            return (SetBooleanHandler)Delegate.CreateDelegate(typeof(SetBooleanHandler), control, "set_IsAccessible");
        }

        #endregion

        #region Left

        public static GetInt32Handler GetLeft(Control control)
        {
            return (GetInt32Handler)Delegate.CreateDelegate(typeof(GetInt32Handler), control, "get_Left");
        }

        public static SetInt32Handler SetLeft(Control control)
        {
            return (SetInt32Handler)Delegate.CreateDelegate(typeof(SetInt32Handler), control, "set_Left");
        }

        #endregion

        #region Location

        public static GetPointHandler GetLocation(Control control)
        {
            return (GetPointHandler)Delegate.CreateDelegate(typeof(GetPointHandler), control, "get_Location");
        }

        public static SetPointHandler SetLocation(Control control)
        {
            return (SetPointHandler)Delegate.CreateDelegate(typeof(SetPointHandler), control, "set_Location");
        }

        #endregion

        #region Margin

        public static GetPaddingHandler GetMargin(Control control)
        {
            return (GetPaddingHandler)Delegate.CreateDelegate(typeof(GetPaddingHandler), control, "get_Margin");
        }

        public static SetPaddingHandler SetMargin(Control control)
        {
            return (SetPaddingHandler)Delegate.CreateDelegate(typeof(SetPaddingHandler), control, "set_Margin");
        }

        #endregion

        #region MaximumSize

        public static GetSizeHandler GetMaximumSize(Control control)
        {
            return (GetSizeHandler)Delegate.CreateDelegate(typeof(GetSizeHandler), control, "get_MaximumSize");
        }

        public static SetSizeHandler SetMaximumSize(Control control)
        {
            return (SetSizeHandler)Delegate.CreateDelegate(typeof(SetSizeHandler), control, "set_MaximumSize");
        }

        #endregion

        #region MinimumSize

        public static GetSizeHandler GetMinimumSize(Control control)
        {
            return (GetSizeHandler)Delegate.CreateDelegate(typeof(GetSizeHandler), control, "get_MinimumSize");
        }

        public static SetSizeHandler SetMinimumSize(Control control)
        {
            return (SetSizeHandler)Delegate.CreateDelegate(typeof(SetSizeHandler), control, "set_MinimumSize");
        }

        #endregion

        #region Name

        public static GetStringHandler GetName(Control control)
        {
            return (GetStringHandler)Delegate.CreateDelegate(typeof(GetStringHandler), control, "get_Name");
        }

        public static SetStringHandler SetName(Control control)
        {
            return (SetStringHandler)Delegate.CreateDelegate(typeof(SetStringHandler), control, "set_Name");
        }

        #endregion

        #region Padding

        public static GetPaddingHandler GetPadding(Control control)
        {
            return (GetPaddingHandler)Delegate.CreateDelegate(typeof(GetPaddingHandler), control, "get_Padding");
        }

        public static SetPaddingHandler SetPadding(Control control)
        {
            return (SetPaddingHandler)Delegate.CreateDelegate(typeof(SetPaddingHandler), control, "set_Padding");
        }

        #endregion

        #region Parent

        public static GetControlHandler GetParent(Control control)
        {
            return (GetControlHandler)Delegate.CreateDelegate(typeof(GetControlHandler), control, "get_Parent");
        }

        public static SetControlHandler SetParent(Control control)
        {
            return (SetControlHandler)Delegate.CreateDelegate(typeof(SetControlHandler), control, "set_Parent");
        }

        #endregion

        #region Region

        public static GetRegionHandler GetRegion(Control control)
        {
            return (GetRegionHandler)Delegate.CreateDelegate(typeof(GetRegionHandler), control, "get_Region");
        }

        public static SetRegionHandler SetRegion(Control control)
        {
            return (SetRegionHandler)Delegate.CreateDelegate(typeof(SetRegionHandler), control, "set_Region");
        }

        #endregion

        #region RightToLeft

        public static GetRightToLeftHandler GetRightToLeft(Control control)
        {
            return (GetRightToLeftHandler)Delegate.CreateDelegate(typeof(GetRightToLeftHandler), control, "get_RightToLeft");
        }

        public static SetRightToLeftHandler SetRightToLeft(Control control)
        {
            return (SetRightToLeftHandler)Delegate.CreateDelegate(typeof(SetRightToLeftHandler), control, "set_RightToLeft");
        }

        #endregion

        #region Site

        public static GetISiteHandler GetSite(Control control)
        {
            return (GetISiteHandler)Delegate.CreateDelegate(typeof(GetISiteHandler), control, "get_Site");
        }

        public static SetISiteHandler SetSite(Control control)
        {
            return (SetISiteHandler)Delegate.CreateDelegate(typeof(SetISiteHandler), control, "set_Site");
        }

        #endregion

        #region Size

        public static GetSizeHandler GetSize(Control control)
        {
            return (GetSizeHandler)Delegate.CreateDelegate(typeof(GetSizeHandler), control, "get_Size");
        }

        public static SetSizeHandler SetSize(Control control)
        {
            return (SetSizeHandler)Delegate.CreateDelegate(typeof(SetSizeHandler), control, "set_Size");
        }

        #endregion

        #region TabIndex

        public static GetInt32Handler GetTabIndex(Control control)
        {
            return (GetInt32Handler)Delegate.CreateDelegate(typeof(GetInt32Handler), control, "get_TabIndex");
        }

        public static SetInt32Handler SetTabIndex(Control control)
        {
            return (SetInt32Handler)Delegate.CreateDelegate(typeof(SetInt32Handler), control, "set_TabIndex");
        }

        #endregion

        #region TabStop

        public static GetBooleanHandler GetTabStop(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_TabStop");
        }

        public static SetBooleanHandler SetTabStop(Control control)
        {
            return (SetBooleanHandler)Delegate.CreateDelegate(typeof(SetBooleanHandler), control, "set_TabStop");
        }

        #endregion

        #region Tag

        public static GetObjectHandler GetTag(Control control)
        {
            return (GetObjectHandler)Delegate.CreateDelegate(typeof(GetObjectHandler), control, "get_Tag");
        }

        public static SetObjectHandler SetTag(Control control)
        {
            return (SetObjectHandler)Delegate.CreateDelegate(typeof(SetObjectHandler), control, "set_Tag");
        }

        #endregion

        #region Text

        public static GetStringHandler GetText(Control control)
        {
            return (GetStringHandler)Delegate.CreateDelegate(typeof(GetStringHandler), control, "get_Text");
        }

        public static SetStringHandler SetText(Control control)
        {
            return (SetStringHandler)Delegate.CreateDelegate(typeof(SetStringHandler), control, "set_Text");
        }

        #endregion

        #region Top

        public static GetInt32Handler GetTop(Control control)
        {
            return (GetInt32Handler)Delegate.CreateDelegate(typeof(GetInt32Handler), control, "get_Top");
        }

        public static SetInt32Handler SetTop(Control control)
        {
            return (SetInt32Handler)Delegate.CreateDelegate(typeof(SetInt32Handler), control, "set_Top");
        }

        #endregion

        #region UseWaitCursor

        public static GetBooleanHandler GetUseWaitCursor(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_UseWaitCursor");
        }

        public static SetBooleanHandler SetUseWaitCursor(Control control)
        {
            return (SetBooleanHandler)Delegate.CreateDelegate(typeof(SetBooleanHandler), control, "set_UseWaitCursor");
        }

        #endregion

        #region Visible

        public static GetBooleanHandler GetVisible(Control control)
        {
            return (GetBooleanHandler)Delegate.CreateDelegate(typeof(GetBooleanHandler), control, "get_Visible");
        }

        public static SetBooleanHandler SetVisible(Control control)
        {
            return (SetBooleanHandler)Delegate.CreateDelegate(typeof(SetBooleanHandler), control, "set_Visible");
        }

        #endregion

        #region Width

        public static GetInt32Handler GetWidth(Control control)
        {
            return (GetInt32Handler)Delegate.CreateDelegate(typeof(GetInt32Handler), control, "get_Width");
        }

        public static SetInt32Handler SetWidth(Control control)
        {
            return (SetInt32Handler)Delegate.CreateDelegate(typeof(SetInt32Handler), control, "set_Width");
        }

        #endregion

        #region WindowTarget

        public static GetIWindowTargetHandler GetWindowTarget(Control control)
        {
            return (GetIWindowTargetHandler)Delegate.CreateDelegate(typeof(GetIWindowTargetHandler), control, "get_WindowTarget");
        }

        public static SetIWindowTargetHandler SetWindowTarget(Control control)
        {
            return (SetIWindowTargetHandler)Delegate.CreateDelegate(typeof(SetIWindowTargetHandler), control, "set_WindowTarget");
        }

        #endregion
        
        #endregion
    }
}
/******************************************************************************/
/*                                END OF FILE                                 */
/******************************************************************************/
A journey of a thousand miles must begin with a single step © Lau Tsu
Re: ControlCrossThreadAccessor
От: adontz Грузия http://adontz.wordpress.com/
Дата: 08.06.06 23:07
Оценка:
/******************************************************************************/
/*                                                                            */
/*    _                ___        _..-._                                      */
/*    \`.|\..----...-'`   `-._.-'' _.-..'                                     */
/*    /  ' `         ,       __.-''                                           */
/*    )/` _/     \   `-_,   /                                                 */
/*    `-'" `"\_  ,_.-;_.-\_ ',  NABU Project                                  */
/*        _.-'_./   {_.'   ; /  Nabu.Forms Library                            */
/*       {_.-``-'         {_/   Copyright © 2005-2006, TrifleSoft             */
/*                                                                            */
/******************************************************************************/
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace Nabu.Forms
{
    public static class ControlCrossThreadAccessor
    {
        #region Methods

        #region AccessibilityObject

        public static AccessibleObject GetAccessibilityObject(Control control)
        {
            return (AccessibleObject)control.Invoke(ControlDelegate.GetAccessibilityObject(control));
        }

        #endregion

        #region Bottom

        public static int GetBottom(Control control)
        {
            return (int)control.Invoke(ControlDelegate.GetBottom(control));
        }

        #endregion

        #region CanFocus

        public static bool GetCanFocus(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetCanFocus(control));
        }

        #endregion

        #region CanSelect

        public static bool GetCanSelect(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetCanSelect(control));
        }

        #endregion

        #region ClientRectangle

        public static Rectangle GetClientRectangle(Control control)
        {
            return (Rectangle)control.Invoke(ControlDelegate.GetClientRectangle(control));
        }

        #endregion

        #region CompanyName

        public static string GetCompanyName(Control control)
        {
            return (string)control.Invoke(ControlDelegate.GetCompanyName(control));
        }

        #endregion

        #region Container

        public static IContainer GetContainer(Control control)
        {
            return (IContainer)control.Invoke(ControlDelegate.GetContainer(control));
        }

        #endregion

        #region ContainsFocus

        public static bool GetContainsFocus(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetContainsFocus(control));
        }

        #endregion

        #region Controls

        public static Control.ControlCollection GetControls(Control control)
        {
            return (Control.ControlCollection)control.Invoke(ControlDelegate.GetControls(control));
        }

        #endregion

        #region Created

        public static bool GetCreated(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetCreated(control));
        }

        #endregion

        #region DataBindings

        public static ControlBindingsCollection GetDataBindings(Control control)
        {
            return (ControlBindingsCollection)control.Invoke(ControlDelegate.GetDataBindings(control));
        }

        #endregion

        #region DisplayRectangle

        public static Rectangle GetDisplayRectangle(Control control)
        {
            return (Rectangle)control.Invoke(ControlDelegate.GetDisplayRectangle(control));
        }

        #endregion

        #region Disposing

        public static bool GetDisposing(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetDisposing(control));
        }

        #endregion

        #region Focused

        public static bool GetFocused(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetFocused(control));
        }

        #endregion

        #region Handle

        public static IntPtr GetHandle(Control control)
        {
            return (IntPtr)control.Invoke(ControlDelegate.GetHandle(control));
        }

        #endregion

        #region HasChildren

        public static bool GetHasChildren(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetHasChildren(control));
        }

        #endregion

        #region InvokeRequired

        public static bool GetInvokeRequired(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetInvokeRequired(control));
        }

        #endregion

        #region IsDisposed

        public static bool GetIsDisposed(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetIsDisposed(control));
        }

        #endregion

        #region IsHandleCreated

        public static bool GetIsHandleCreated(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetIsHandleCreated(control));
        }

        #endregion

        #region IsMirrored

        public static bool GetIsMirrored(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetIsMirrored(control));
        }

        #endregion

        #region PreferredSize

        public static Size GetPreferredSize(Control control)
        {
            return (Size)control.Invoke(ControlDelegate.GetPreferredSize(control));
        }

        #endregion

        #region ProductName

        public static string GetProductName(Control control)
        {
            return (string)control.Invoke(ControlDelegate.GetProductName(control));
        }

        #endregion

        #region ProductVersion

        public static string GetProductVersion(Control control)
        {
            return (string)control.Invoke(ControlDelegate.GetProductVersion(control));
        }

        #endregion

        #region RecreatingHandle

        public static bool GetRecreatingHandle(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetRecreatingHandle(control));
        }

        #endregion

        #region Right

        public static int GetRight(Control control)
        {
            return (int)control.Invoke(ControlDelegate.GetRight(control));
        }

        #endregion

        #region TopLevelControl

        public static Control GetTopLevelControl(Control control)
        {
            return (Control)control.Invoke(ControlDelegate.GetTopLevelControl(control));
        }

        #endregion

        #region AccessibleDefaultActionDescription

        public static string GetAccessibleDefaultActionDescription(Control control)
        {
            return (string)control.Invoke(ControlDelegate.GetAccessibleDefaultActionDescription(control));
        }

        public static void SetAccessibleDefaultActionDescription(Control control, string value)
        {
            control.Invoke(ControlDelegate.SetAccessibleDefaultActionDescription(control), value);
        }

        #endregion

        #region AccessibleDescription

        public static string GetAccessibleDescription(Control control)
        {
            return (string)control.Invoke(ControlDelegate.GetAccessibleDescription(control));
        }

        public static void SetAccessibleDescription(Control control, string value)
        {
            control.Invoke(ControlDelegate.SetAccessibleDescription(control), value);
        }

        #endregion

        #region AccessibleName

        public static string GetAccessibleName(Control control)
        {
            return (string)control.Invoke(ControlDelegate.GetAccessibleName(control));
        }

        public static void SetAccessibleName(Control control, string value)
        {
            control.Invoke(ControlDelegate.SetAccessibleName(control), value);
        }

        #endregion

        #region AccessibleRole

        public static AccessibleRole GetAccessibleRole(Control control)
        {
            return (AccessibleRole)control.Invoke(ControlDelegate.GetAccessibleRole(control));
        }

        public static void SetAccessibleRole(Control control, AccessibleRole value)
        {
            control.Invoke(ControlDelegate.SetAccessibleRole(control), value);
        }

        #endregion

        #region AllowDrop

        public static bool GetAllowDrop(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetAllowDrop(control));
        }

        public static void SetAllowDrop(Control control, bool value)
        {
            control.Invoke(ControlDelegate.SetAllowDrop(control), value);
        }

        #endregion

        #region Anchor

        public static AnchorStyles GetAnchor(Control control)
        {
            return (AnchorStyles)control.Invoke(ControlDelegate.GetAnchor(control));
        }

        public static void SetAnchor(Control control, AnchorStyles value)
        {
            control.Invoke(ControlDelegate.SetAnchor(control), value);
        }

        #endregion

        #region AutoScrollOffset

        public static Point GetAutoScrollOffset(Control control)
        {
            return (Point)control.Invoke(ControlDelegate.GetAutoScrollOffset(control));
        }

        public static void SetAutoScrollOffset(Control control, Point value)
        {
            control.Invoke(ControlDelegate.SetAutoScrollOffset(control), value);
        }

        #endregion

        #region AutoSize

        public static bool GetAutoSize(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetAutoSize(control));
        }

        public static void SetAutoSize(Control control, bool value)
        {
            control.Invoke(ControlDelegate.SetAutoSize(control), value);
        }

        #endregion

        #region BackColor

        public static Color GetBackColor(Control control)
        {
            return (Color)control.Invoke(ControlDelegate.GetBackColor(control));
        }

        public static void SetBackColor(Control control, Color value)
        {
            control.Invoke(ControlDelegate.SetBackColor(control), value);
        }

        #endregion

        #region BackgroundImage

        public static Image GetBackgroundImage(Control control)
        {
            return (Image)control.Invoke(ControlDelegate.GetBackgroundImage(control));
        }

        public static void SetBackgroundImage(Control control, Image value)
        {
            control.Invoke(ControlDelegate.SetBackgroundImage(control), value);
        }

        #endregion

        #region BackgroundImageLayout

        public static ImageLayout GetBackgroundImageLayout(Control control)
        {
            return (ImageLayout)control.Invoke(ControlDelegate.GetBackgroundImageLayout(control));
        }

        public static void SetBackgroundImageLayout(Control control, ImageLayout value)
        {
            control.Invoke(ControlDelegate.SetBackgroundImageLayout(control), value);
        }

        #endregion

        #region BindingContext

        public static BindingContext GetBindingContext(Control control)
        {
            return (BindingContext)control.Invoke(ControlDelegate.GetBindingContext(control));
        }

        public static void SetBindingContext(Control control, BindingContext value)
        {
            control.Invoke(ControlDelegate.SetBindingContext(control), value);
        }

        #endregion

        #region Bounds

        public static Rectangle GetBounds(Control control)
        {
            return (Rectangle)control.Invoke(ControlDelegate.GetBounds(control));
        }

        public static void SetBounds(Control control, Rectangle value)
        {
            control.Invoke(ControlDelegate.SetBounds(control), value);
        }

        #endregion

        #region Capture

        public static bool GetCapture(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetCapture(control));
        }

        public static void SetCapture(Control control, bool value)
        {
            control.Invoke(ControlDelegate.SetCapture(control), value);
        }

        #endregion

        #region CausesValidation

        public static bool GetCausesValidation(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetCausesValidation(control));
        }

        public static void SetCausesValidation(Control control, bool value)
        {
            control.Invoke(ControlDelegate.SetCausesValidation(control), value);
        }

        #endregion

        #region ClientSize

        public static Size GetClientSize(Control control)
        {
            return (Size)control.Invoke(ControlDelegate.GetClientSize(control));
        }

        public static void SetClientSize(Control control, Size value)
        {
            control.Invoke(ControlDelegate.SetClientSize(control), value);
        }

        #endregion

        #region ContextMenu

        public static ContextMenu GetContextMenu(Control control)
        {
            return (ContextMenu)control.Invoke(ControlDelegate.GetContextMenu(control));
        }

        public static void SetContextMenu(Control control, ContextMenu value)
        {
            control.Invoke(ControlDelegate.SetContextMenu(control), value);
        }

        #endregion

        #region ContextMenuStrip

        public static ContextMenuStrip GetContextMenuStrip(Control control)
        {
            return (ContextMenuStrip)control.Invoke(ControlDelegate.GetContextMenuStrip(control));
        }

        public static void SetContextMenuStrip(Control control, ContextMenuStrip value)
        {
            control.Invoke(ControlDelegate.SetContextMenuStrip(control), value);
        }

        #endregion

        #region Cursor

        public static Cursor GetCursor(Control control)
        {
            return (Cursor)control.Invoke(ControlDelegate.GetCursor(control));
        }

        public static void SetCursor(Control control, Cursor value)
        {
            control.Invoke(ControlDelegate.SetCursor(control), value);
        }

        #endregion

        #region Dock

        public static DockStyle GetDock(Control control)
        {
            return (DockStyle)control.Invoke(ControlDelegate.GetDock(control));
        }

        public static void SetDock(Control control, DockStyle value)
        {
            control.Invoke(ControlDelegate.SetDock(control), value);
        }

        #endregion

        #region Enabled

        public static bool GetEnabled(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetEnabled(control));
        }

        public static void SetEnabled(Control control, bool value)
        {
            control.Invoke(ControlDelegate.SetEnabled(control), value);
        }

        #endregion

        #region Font

        public static Font GetFont(Control control)
        {
            return (Font)control.Invoke(ControlDelegate.GetFont(control));
        }

        public static void SetFont(Control control, Font value)
        {
            control.Invoke(ControlDelegate.SetFont(control), value);
        }

        #endregion

        #region ForeColor

        public static Color GetForeColor(Control control)
        {
            return (Color)control.Invoke(ControlDelegate.GetForeColor(control));
        }

        public static void SetForeColor(Control control, Color value)
        {
            control.Invoke(ControlDelegate.SetForeColor(control), value);
        }

        #endregion

        #region Height

        public static int GetHeight(Control control)
        {
            return (int)control.Invoke(ControlDelegate.GetHeight(control));
        }

        public static void SetHeight(Control control, int value)
        {
            control.Invoke(ControlDelegate.SetHeight(control), value);
        }

        #endregion

        #region ImeMode

        public static ImeMode GetImeMode(Control control)
        {
            return (ImeMode)control.Invoke(ControlDelegate.GetImeMode(control));
        }

        public static void SetImeMode(Control control, ImeMode value)
        {
            control.Invoke(ControlDelegate.SetImeMode(control), value);
        }

        #endregion

        #region IsAccessible

        public static bool GetIsAccessible(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetIsAccessible(control));
        }

        public static void SetIsAccessible(Control control, bool value)
        {
            control.Invoke(ControlDelegate.SetIsAccessible(control), value);
        }

        #endregion

        #region Left

        public static int GetLeft(Control control)
        {
            return (int)control.Invoke(ControlDelegate.GetLeft(control));
        }

        public static void SetLeft(Control control, int value)
        {
            control.Invoke(ControlDelegate.SetLeft(control), value);
        }

        #endregion

        #region Location

        public static Point GetLocation(Control control)
        {
            return (Point)control.Invoke(ControlDelegate.GetLocation(control));
        }

        public static void SetLocation(Control control, Point value)
        {
            control.Invoke(ControlDelegate.SetLocation(control), value);
        }

        #endregion

        #region Margin

        public static Padding GetMargin(Control control)
        {
            return (Padding)control.Invoke(ControlDelegate.GetMargin(control));
        }

        public static void SetMargin(Control control, Padding value)
        {
            control.Invoke(ControlDelegate.SetMargin(control), value);
        }

        #endregion

        #region MaximumSize

        public static Size GetMaximumSize(Control control)
        {
            return (Size)control.Invoke(ControlDelegate.GetMaximumSize(control));
        }

        public static void SetMaximumSize(Control control, Size value)
        {
            control.Invoke(ControlDelegate.SetMaximumSize(control), value);
        }

        #endregion

        #region MinimumSize

        public static Size GetMinimumSize(Control control)
        {
            return (Size)control.Invoke(ControlDelegate.GetMinimumSize(control));
        }

        public static void SetMinimumSize(Control control, Size value)
        {
            control.Invoke(ControlDelegate.SetMinimumSize(control), value);
        }

        #endregion

        #region Name

        public static string GetName(Control control)
        {
            return (string)control.Invoke(ControlDelegate.GetName(control));
        }

        public static void SetName(Control control, string value)
        {
            control.Invoke(ControlDelegate.SetName(control), value);
        }

        #endregion

        #region Padding

        public static Padding GetPadding(Control control)
        {
            return (Padding)control.Invoke(ControlDelegate.GetPadding(control));
        }

        public static void SetPadding(Control control, Padding value)
        {
            control.Invoke(ControlDelegate.SetPadding(control), value);
        }

        #endregion

        #region Parent

        public static Control GetParent(Control control)
        {
            return (Control)control.Invoke(ControlDelegate.GetParent(control));
        }

        public static void SetParent(Control control, Control value)
        {
            control.Invoke(ControlDelegate.SetParent(control), value);
        }

        #endregion

        #region Region

        public static Region GetRegion(Control control)
        {
            return (Region)control.Invoke(ControlDelegate.GetRegion(control));
        }

        public static void SetRegion(Control control, Region value)
        {
            control.Invoke(ControlDelegate.SetRegion(control), value);
        }

        #endregion

        #region RightToLeft

        public static RightToLeft GetRightToLeft(Control control)
        {
            return (RightToLeft)control.Invoke(ControlDelegate.GetRightToLeft(control));
        }

        public static void SetRightToLeft(Control control, RightToLeft value)
        {
            control.Invoke(ControlDelegate.SetRightToLeft(control), value);
        }

        #endregion

        #region Site

        public static ISite GetSite(Control control)
        {
            return (ISite)control.Invoke(ControlDelegate.GetSite(control));
        }

        public static void SetSite(Control control, ISite value)
        {
            control.Invoke(ControlDelegate.SetSite(control), value);
        }

        #endregion

        #region Size

        public static Size GetSize(Control control)
        {
            return (Size)control.Invoke(ControlDelegate.GetSize(control));
        }

        public static void SetSize(Control control, Size value)
        {
            control.Invoke(ControlDelegate.SetSize(control), value);
        }

        #endregion

        #region TabIndex

        public static int GetTabIndex(Control control)
        {
            return (int)control.Invoke(ControlDelegate.GetTabIndex(control));
        }

        public static void SetTabIndex(Control control, int value)
        {
            control.Invoke(ControlDelegate.SetTabIndex(control), value);
        }

        #endregion

        #region TabStop

        public static bool GetTabStop(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetTabStop(control));
        }

        public static void SetTabStop(Control control, bool value)
        {
            control.Invoke(ControlDelegate.SetTabStop(control), value);
        }

        #endregion

        #region Tag

        public static object GetTag(Control control)
        {
            return (object)control.Invoke(ControlDelegate.GetTag(control));
        }

        public static void SetTag(Control control, object value)
        {
            control.Invoke(ControlDelegate.SetTag(control), value);
        }

        #endregion

        #region Text

        public static string GetText(Control control)
        {
            return (string)control.Invoke(ControlDelegate.GetText(control));
        }

        public static void SetText(Control control, string value)
        {
            control.Invoke(ControlDelegate.SetText(control), value);
        }

        #endregion

        #region Top

        public static int GetTop(Control control)
        {
            return (int)control.Invoke(ControlDelegate.GetTop(control));
        }

        public static void SetTop(Control control, int value)
        {
            control.Invoke(ControlDelegate.SetTop(control), value);
        }

        #endregion

        #region UseWaitCursor

        public static bool GetUseWaitCursor(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetUseWaitCursor(control));
        }

        public static void SetUseWaitCursor(Control control, bool value)
        {
            control.Invoke(ControlDelegate.SetUseWaitCursor(control), value);
        }

        #endregion

        #region Visible

        public static bool GetVisible(Control control)
        {
            return (bool)control.Invoke(ControlDelegate.GetVisible(control));
        }

        public static void SetVisible(Control control, bool value)
        {
            control.Invoke(ControlDelegate.SetVisible(control), value);
        }

        #endregion

        #region Width

        public static int GetWidth(Control control)
        {
            return (int)control.Invoke(ControlDelegate.GetWidth(control));
        }

        public static void SetWidth(Control control, int value)
        {
            control.Invoke(ControlDelegate.SetWidth(control), value);
        }

        #endregion

        #region WindowTarget

        public static IWindowTarget GetWindowTarget(Control control)
        {
            return (IWindowTarget)control.Invoke(ControlDelegate.GetWindowTarget(control));
        }

        public static void SetWindowTarget(Control control, IWindowTarget value)
        {
            control.Invoke(ControlDelegate.SetWindowTarget(control), value);
        }

        #endregion

        #endregion
    }
}
/******************************************************************************/
/*                                END OF FILE                                 */
/******************************************************************************/
A journey of a thousand miles must begin with a single step © Lau Tsu
Re: ControlCrossThreadAccessor/ControlDelegate
От: _FRED_ Черногория
Дата: 13.06.06 08:54
Оценка:
Здравствуйте, adontz, Вы писали:

A>Вот, нагенерировал


То есть, для двух вызовов подряд (например, установки дока и вызова SendToBack) ты предлагаешь делать два вызова Invoke???

ЗЫ. Поддерживаешь ещё первый фреймворк
... << RSDN@Home 1.2.0 alpha rev. 652>>
Now playing: «Тихо в лесу…»
Help will always be given at Hogwarts to those who ask for it.
Re[2]: ControlCrossThreadAccessor/ControlDelegate
От: adontz Грузия http://adontz.wordpress.com/
Дата: 13.06.06 10:24
Оценка:
Здравствуйте, _FRED_, Вы писали:

_FR>То есть, для двух вызовов подряд (например, установки дока и вызова SendToBack) ты предлагаешь делать два вызова Invoke???


ControlCrossThreadAccessor
A journey of a thousand miles must begin with a single step © Lau Tsu
Re[3]: ControlCrossThreadAccessor/ControlDelegate
От: _FRED_ Черногория
Дата: 13.06.06 10:55
Оценка:
Здравствуйте, adontz, Вы писали:

_FR>>То есть, для двух вызовов подряд (например, установки дока и вызова SendToBack) ты предлагаешь делать два вызова Invoke???


A>ControlCrossThreadAccessor


И…? Хоть убей, непонимаю Где, как и почему предполагается использовать этот класс?
... << RSDN@Home 1.2.0 alpha rev. 652>>
Now playing: «Тихо в лесу…»
Help will always be given at Hogwarts to those who ask for it.
Re[4]: ControlCrossThreadAccessor/ControlDelegate
От: adontz Грузия http://adontz.wordpress.com/
Дата: 13.06.06 11:09
Оценка:
Здравствуйте, _FRED_, Вы писали:

A>>ControlCrossThreadAccessor

_FR>И…? Хоть убей, непонимаю Где, как и почему предполагается использовать этот класс?

Как это не понимаешь Нехорошо. Ну вобщем было у меня два потока, которые дёргали один контрол и естественно мне сообщили, что дёргать один контрол из двух потоков нехорошо. Очень грубо сообщили, окошечком с исключением. Для того чтобы дёргать культурно, надо использовать метод Invoke. но он требует передавать делегат. Ну и конечно тип делегата ещё надо объявить — мне стало лень. Кроме того я не нашёл в C# способа (и прочёл, что его нет) объявлять делегаты для геттеров/сеттеров свойств. Лень меня сподвигла на кодогенерацию.

Вместо
delegate int GetInt32Handler();

int bottom = control.Invoke((GetInt32Handler)Delegate.CreateDelegate(typeof(GetInt32Handler), control, "get_Bottom"));

Пишем

int bottom = CrossThreadControlAcccessor.GetBottom(control);


Во-первых, просто напросто короче.
Во-вторых, в одном месте. Делегат придётся объявлять вне метода.
В-третьих, ИМХО более понятно что происходит.
A journey of a thousand miles must begin with a single step © Lau Tsu
Re[5]: ControlCrossThreadAccessor/ControlDelegate
От: _FRED_ Черногория
Дата: 13.06.06 11:44
Оценка:
Здравствуйте, adontz, Вы писали:

A>Ну вобщем было у меня два потока, которые дёргали один контрол и естественно мне сообщили, что дёргать один контрол из двух потоков нехорошо. Очень грубо сообщили, окошечком с исключением.


Значит, фреймворк второй?

A>Для того чтобы дёргать культурно, надо использовать метод Invoke. но он требует передавать делегат. Ну и конечно тип делегата ещё надо объявить — мне стало лень. Кроме того я не нашёл в C# способа (и прочёл, что его нет) объявлять делегаты для геттеров/сеттеров свойств. Лень меня сподвигла на кодогенерацию.

A>Вместо
A>delegate int GetInt32Handler();

A>int bottom = control.Invoke((GetInt32Handler)Delegate.CreateDelegate(typeof(GetInt32Handler), control, "get_Bottom"));

A>Пишем
A>int bottom = CrossThreadControlAcccessor.GetBottom(control);


А так?
  public delegate T Function<T>();
    …
  int bottom = (int)control.Invoke(new Function<int>(delegate { return control.Bottom; }));


A>Во-первых, просто напросто короче.


Признаю

A>Во-вторых, в одном месте. Делегат придётся объявлять вне метода.


У меня — более реюзабельный делегат :о)

A>В-третьих, ИМХО более понятно что происходит.


Возможно, НО! А если надо получит значение десятка свойств, а потом и установить их в другие значения? Так же, по одному брать и по-одному записывать? Вместо того, что бы переключиться в другой поток один раз со всеми параметрами и всё сделать?

Или, например, как ты себе представляешь полезность вот такой вот работы:
  BindingContext bindingContext = CrossThreadControlAcccessor.GetBindingContext(control);
  Control.ControlCollection сщтекщды = CrossThreadControlAcccessor.GetControls(control);

Что дальше вызывающий код может сделать с полученными ссылками? Мне кажется, что ничего хорошего
... << RSDN@Home 1.2.0 alpha rev. 652>>
Now playing: «Тихо в лесу…»
Help will always be given at Hogwarts to those who ask for it.
Re[6]: ControlCrossThreadAccessor/ControlDelegate
От: adontz Грузия http://adontz.wordpress.com/
Дата: 13.06.06 12:06
Оценка:
Здравствуйте, _FRED_, Вы писали:

A>>Во-вторых, в одном месте. Делегат придётся объявлять вне метода.

_FR>У меня — более реюзабельный делегат :о)

Кстати синтаксис инициализации мне не был знаком. Интересно всё как

_FR>Возможно, НО! А если надо получит значение десятка свойств, а потом и установить их в другие значения? Так же, по одному брать и по-одному записывать? Вместо того, что бы переключиться в другой поток один раз со всеми параметрами и всё сделать?


Ты прав, в том-то и суть, что ради десятка надо переключатся, а ради одного городить делегат и страшненький вызов очень лень.
A journey of a thousand miles must begin with a single step © Lau Tsu
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.