/// <summary>
        /// Create a _Win* control based on the type of provided WinControl.
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        public static IEnhancedWinControl Create(WinControl control)
        {
            string Prefix = ".Enhanced";
            string controlTypeName = control.GetType().Name;
            string Namespace = typeof(EnhancedWinControlFactory).Namespace;

            // Get  type based on WinControl type and namespace
            Type Type = Type.GetType(Namespace + Prefix + controlTypeName);

            // The type will be null if it does not exist
            if (Type == null)
            {
                throw new Exception(string.Format("Control Type '{0}' not supported", control.GetType().Name));
            }

            // Create  control
            var enhancedControl = (IEnhancedWinControl)Activator.CreateInstance(Type);

            // Wrap WinControl
            enhancedControl.WrapReady(control);

            return enhancedControl;
        }
示例#2
0
        /// <summary>
        /// Create a _Win* control based on the type of provided WinControl.
        /// </summary>
        /// <param name="control"></param>
        /// <returns></returns>
        public static IEnhancedWinControl Create(WinControl control)
        {
            string Prefix          = ".Enhanced";
            string controlTypeName = control.GetType().Name;
            string Namespace       = typeof(EnhancedWinControlFactory).Namespace;

            // Get  type based on WinControl type and namespace
            Type Type = Type.GetType(Namespace + Prefix + controlTypeName);

            // The type will be null if it does not exist
            if (Type == null)
            {
                throw new Exception(string.Format("Control Type '{0}' not supported", control.GetType().Name));
            }

            // Create  control
            var enhancedControl = (IEnhancedWinControl)Activator.CreateInstance(Type);

            // Wrap WinControl
            enhancedControl.WrapReady(control);

            return(enhancedControl);
        }
        private static IEnhancedWinControl WrapUtil(WinControl control)
        {
            IEnhancedWinControl _con = null;

            if (control.GetType() == typeof(WinButton))
            {
                _con = new EnhancedWinButton();
            }
            else if (control.GetType() == typeof(WinCheckBox))
            {
                _con = new EnhancedWinCheckBox();
            }
            else if (control.GetType() == typeof(WinComboBox))
            {
                _con = new EnhancedWinComboBox();
            }
            else if (control.GetType() == typeof(WinEdit))
            {
                _con = new EnhancedWinEdit();
            }
            else if (control.GetType() == typeof(WinHyperlink))
            {
                _con = new EnhancedWinHyperlink();
            }
            else if (control.GetType() == typeof(WinList))
            {
                _con = new EnhancedWinList();
            }
            else if (control.GetType() == typeof(WinListItem))
            {
                _con = new EnhancedWinListItem();
            }
            else if (control.GetType() == typeof(WinRadioButton))
            {
                _con = new EnhancedWinRadioButton();
            }
            else if (control.GetType() == typeof(WinTable))
            {
                _con = new EnhancedWinTable();
            }
            else if (control.GetType() == typeof(WinCell))
            {
                _con = new EnhancedWinCell();
            }
            else if (control.GetType() == typeof(WinScrollBar))
            {
                _con = new EnhancedWinScrollBar();
            }
            else if (control.GetType() == typeof(WinCustom))
            {
                _con = new EnhancedWinCustom();
            }
            else
            {
                throw new Exception(string.Format("WrapUtil: '{0}' not supported", control.GetType().Name));
            }
            _con.WrapReady(control);
            return(_con);
        }