/// <summary> /// Returns a default value for the specified property. /// </summary> /// <param name="prop">The property requesting a default value.</param> /// <returns>A default value casted as object.</returns> private static object GetDefaultValueForProperty(NewPropertiesEnum prop) { switch (prop) { case NewPropertiesEnum.CorrectEventsBehavior: return(true); } return(null); }
/// <summary> /// Returns a default value for the specified property. /// </summary> /// <param name="prop">The property requesting a default value.</param> /// <returns>A default value casted as object.</returns> private static object GetDefaultValueForProperty(NewPropertiesEnum prop) { switch (prop) { case NewPropertiesEnum.ExpandedImage: case NewPropertiesEnum.NormalImage: return(new Dictionary <TreeNode, object>()); } return(null); }
/// <summary> /// Returns a default value for the specified property. /// </summary> /// <param name="prop">The property requesting a default value.</param> /// <returns>A default value casted as object.</returns> private static object GetDefaultValueForProperty(NewPropertiesEnum prop) { switch (prop) { case NewPropertiesEnum.ActiveFontStyle: return(ActiveTabFontStyleEnum.Default); case NewPropertiesEnum.UseMnemonic: return(true); } return(null); }
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////// STATIC PROPERTIES DEFINITION //////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Check if the property 'newPropertiesEnum' is already defined for this TreeView. /// </summary> /// <param name="treeView">The TreeView.</param> /// <param name="prop">The newPropertiesEnum to search.</param> /// <returns>true if successful, false otherwise.</returns> private static bool CheckForProperty(TreeView treeView, NewPropertiesEnum prop) { if (treeView == null) { return(false); } CheckNewProperties(treeView); if (!NewProperties[treeView].ContainsKey(prop)) { NewProperties[treeView][prop] = GetDefaultValueForProperty(prop); } return(true); }
///////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////// INSTANCE IMPLEMENTATION FOR EXTRA PROPERTIES ////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////// STATIC IMPLEMENTATION FOR EXTRA PROPERTIES /////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Check if the property 'newPropertiesEnum' is already defined for this button. /// </summary> /// <param name="btn">The button.</param> /// <param name="prop">newPropertiesEnum</param> /// <returns>true if successful, false otherwise.</returns> private static bool CheckForProperty(Button btn, NewPropertiesEnum prop) { if (btn == null) { return(false); } CheckNewProperties(btn); if (!NewProperties[btn].ContainsKey(prop)) { NewProperties[btn][prop] = GetDefaultValueForProperty(prop); } return(true); }
/// <summary> /// Check if the property 'newPropertiesEnum' is already defined for this tabcontrol. /// </summary> /// <param name="tabControl">The tab control to test.</param> /// <param name="prop">The property to check.</param> /// <returns>True if property could be checked.</returns> private static bool CheckForProperty(TabControl tabControl, NewPropertiesEnum prop) { if (tabControl == null) { return(false); } CheckNewProperties(tabControl); if (!_NewProperties[tabControl.GetHashCode()].ContainsKey(prop)) { _NewProperties[tabControl.GetHashCode()][prop] = GetDefaultValueForProperty(prop); } return(true); }
/// <summary> /// Sets the tabControl to use the custom drawing mode, /// if the mode or the eventhandler have already been set then /// they are not set again. /// </summary> /// <param name="tabControl">The tabControl to set its custom value.</param> /// <param name="property">A custom behavior value.</param> /// <param name="value">True if the custom drawing mode has to be set.</param> private static void SetCustomDrawingMode(TabControl tabControl, NewPropertiesEnum property, bool value) { if (tabControl != null) { int key = tabControl.GetHashCode(); if (value) { if (!ControlOfCustomDrawingMode.ContainsKey(key)) { tabControl.DrawMode = TabDrawMode.OwnerDrawFixed; tabControl.DrawItem += TabControl_DrawItem; ControlOfCustomDrawingMode.Add(key, new List <NewPropertiesEnum>()); } if (!ControlOfCustomDrawingMode[key].Contains(property)) { ControlOfCustomDrawingMode[key].Add(property); } } else { if (ControlOfCustomDrawingMode.ContainsKey(key)) { if (ControlOfCustomDrawingMode[key].Contains(property)) { ControlOfCustomDrawingMode[key].Remove(property); } if (ControlOfCustomDrawingMode[key].Count == 0) { tabControl.DrawMode = TabDrawMode.Normal; tabControl.DrawItem -= TabControl_DrawItem; ControlOfCustomDrawingMode.Remove(key); } } } } }