private static IEnhancedWpfControl WrapUtil(WpfControl control) { IEnhancedWpfControl _con = null; if (control.GetType() == typeof(WpfButton)) { _con = new EnhancedWpfButton(); } else if (control.GetType() == typeof(WpfCheckBox)) { _con = new EnhancedWpfCheckBox(); } else if (control.GetType() == typeof(WpfComboBox)) { _con = new EnhancedWpfComboBox(); } else if (control.GetType() == typeof(WpfEdit)) { _con = new EnhancedWpfEdit(); } else if (control.GetType() == typeof(WpfHyperlink)) { _con = new EnhancedWpfHyperlink(); } else if (control.GetType() == typeof(WpfList)) { _con = new EnhancedWpfList(); } else if (control.GetType() == typeof(WpfListItem)) { _con = new EnhancedWpfListItem(); } else if (control.GetType() == typeof(WpfRadioButton)) { _con = new EnhancedWpfRadioButton(); } else if (control.GetType() == typeof(WpfTable)) { _con = new EnhancedWpfTable(); } else if (control.GetType() == typeof(WpfCell)) { _con = new EnhancedWpfCell(); } else if (control.GetType() == typeof(WpfScrollBar)) { _con = new EnhancedWpfScrollBar(); } else if (control.GetType() == typeof(WpfCustom)) { _con = new EnhancedWpfCustom(); } else { throw new Exception(string.Format("WrapUtil: '{0}' not supported", control.GetType().Name)); } _con.WrapReady(control); return(_con); }
/// <summary> /// Create a _Wpf* control based on the type of provided WpfControl. /// </summary> /// <param name="control"></param> /// <returns></returns> public static IEnhancedWpfControl Create(WpfControl control) { string Prefix = ".Enhanced"; string controlTypeName = control.GetType().Name; string Namespace = typeof(EnhancedWpfControlFactory).Namespace; // Get type based on WpfControl 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 IEnhancedWpfControl enhancedControl = (IEnhancedWpfControl)Activator.CreateInstance(Type); // Wrap WinControl enhancedControl.WrapReady(control); return(enhancedControl); }