/// <summary> /// Get whether a font is bolded for a verbalizer color category /// </summary> /// <param name="verbalizerColor">A designer color used for verbalization</param> /// <returns>Returns true if the color category is bolded.</returns> public bool GetIsBold(ORMDesignerColor verbalizerColor) { Dictionary <ORMDesignerColor, CategoryFontData> dict = myVerbalizationColors; CategoryFontData fontData; return((dict != null && dict.TryGetValue(verbalizerColor, out fontData)) ? fontData.IsBold : CategoryFontData.GetDefault(verbalizerColor).IsBold); }
/// <summary> /// Set custom color information /// </summary> /// <param name="verbalizerColor">The color category to set</param> /// <param name="color">The color to apply. Use <see langword="null"/> /// to revert to the default settings.</param> /// <param name="isBold">Whether or not to bold the font. Use <see langword="null"/> to revert to /// the default setting.</param> public void SetCustomColor(ORMDesignerColor verbalizerColor, Color?color, bool?isBold) { Dictionary <ORMDesignerColor, CategoryFontData> dict = myVerbalizationColors; CategoryFontData defaultData = CategoryFontData.GetDefault(verbalizerColor); bool defaultColor = !color.HasValue || defaultData.Color == color.Value; bool defaultBold = !isBold.HasValue || defaultData.IsBold == isBold.Value; if (defaultColor && defaultBold) { if (dict != null && dict.ContainsKey(verbalizerColor)) { dict.Remove(verbalizerColor); if (dict.Count == 0) { myVerbalizationColors = null; } } } else { if (dict == null) { myVerbalizationColors = dict = new Dictionary <ORMDesignerColor, CategoryFontData>(); } dict[verbalizerColor] = new CategoryFontData(defaultColor ? defaultData.Color : color.Value, defaultBold ? defaultData.IsBold : isBold.Value); } }
/// <summary> /// Implements <see cref="IORMFontAndColorService.GetFontStyle"/> /// </summary> protected FontStyle GetFontStyle(ORMDesignerColor colorIndex) { VerbalizationManager mgr; int index = (int)colorIndex; if (index >= (int)ORMDesignerColor.FirstVerbalizerColor && index <= (int)ORMDesignerColor.LastVerbalizerColor && null != (mgr = myVerbalizationManager)) { return(mgr.GetIsBold(colorIndex) ? FontStyle.Bold : FontStyle.Regular); } return(FontStyle.Bold); }
/// <summary> /// Implements <see cref="IORMFontAndColorService.GetForeColor"/> /// </summary> protected Color GetForeColor(ORMDesignerColor colorIndex) { VerbalizationManager mgr; int index = (int)colorIndex; if (index >= (int)ORMDesignerColor.FirstVerbalizerColor && index <= (int)ORMDesignerColor.LastVerbalizerColor && null != (mgr = myVerbalizationManager)) { return(mgr.GetColor(colorIndex)); } return(Color.Black); }
public static CategoryFontData GetDefault(ORMDesignerColor color) { switch (color) { case ORMDesignerColor.VerbalizerPredicateText: return(new CategoryFontData(Color.DarkGreen, false)); case ORMDesignerColor.VerbalizerObjectName: return(new CategoryFontData(Color.Purple, false)); case ORMDesignerColor.VerbalizerFormalItem: return(new CategoryFontData(Color.MediumBlue, true)); case ORMDesignerColor.VerbalizerNotesItem: return(new CategoryFontData(Color.Black, false)); case ORMDesignerColor.VerbalizerRefMode: return(new CategoryFontData(Color.Brown, false)); case ORMDesignerColor.VerbalizerInstanceValue: return(new CategoryFontData(Color.Brown, false)); } return(new CategoryFontData(Color.Black, true)); }
Color IORMFontAndColorService.GetForeColor(ORMDesignerColor colorIndex) { return(GetForeColor(colorIndex)); }
FontStyle IORMFontAndColorService.GetFontStyle(ORMDesignerColor colorIndex) { return(GetFontStyle(colorIndex)); }
/// <summary> /// Implements <see cref="IORMFontAndColorService.GetBackColor"/> /// </summary> protected static Color GetBackColor(ORMDesignerColor colorIndex) { return(Color.White); }
/// <summary> /// Retrieve font flag information for the specified index. /// Implements IORMFontAndColorService.GetFontStyle /// </summary> /// <param name="colorIndex">Item to retrieve</param> protected FontStyle GetFontFlags(ORMDesignerColor colorIndex) { int index; return CategoryFromDesignerColor(colorIndex, out index).GetColorItem(index).FontStyle; }
FontStyle IORMFontAndColorService.GetFontStyle(ORMDesignerColor colorIndex) { return GetFontFlags(colorIndex); }
Color IORMFontAndColorService.GetBackColor(ORMDesignerColor colorIndex) { return GetBackColor(colorIndex); }
/// <summary> /// Retrieve background color information for the specified index. /// Implements IORMFontAndColorService.GetBackColor /// </summary> /// <param name="colorIndex">Item to retrieve</param> /// <returns>Color</returns> protected Color GetBackColor(ORMDesignerColor colorIndex) { int index; return CategoryFromDesignerColor(colorIndex, out index).GetColorItem(index).BackColor; }
private SettingsCategory CategoryFromDesignerColor(ORMDesignerColor designerColor, out int colorIndex) { SettingsCategory retVal = null; colorIndex = (int)designerColor; if (designerColor >= ORMDesignerColor.FirstEditorColor && designerColor <= ORMDesignerColor.LastEditorColor) { colorIndex -= (int)ORMDesignerColor.FirstEditorColor; retVal = CategoryFromDesignerFont(ORMDesignerColorCategory.Editor); } else if (designerColor >= ORMDesignerColor.FirstVerbalizerColor && designerColor <= ORMDesignerColor.LastVerbalizerColor) { colorIndex -= (int)ORMDesignerColor.FirstVerbalizerColor; retVal = CategoryFromDesignerFont(ORMDesignerColorCategory.Verbalizer); } Debug.Assert(retVal != null); // Value out of range return retVal; }
/// <summary> /// Get the name of an item from its index /// </summary> /// <param name="itemIndex">A valid item index</param> /// <returns>A name. Throws on an invalid index</returns> private static string NameFromItemIndex(ORMDesignerColor itemIndex) { string retVal; switch (itemIndex) { case ORMDesignerColor.VerbalizerPredicateText: retVal = VerbalizerPredicateTextColorName; break; case ORMDesignerColor.VerbalizerObjectName: retVal = VerbalizerObjectNameColorName; break; case ORMDesignerColor.VerbalizerFormalItem: retVal = VerbalizerFormalItemColorName; break; case ORMDesignerColor.VerbalizerNotesItem: retVal = VerbalizerNotesItemColorName; break; case ORMDesignerColor.VerbalizerRefMode: retVal = VerbalizerRefModeColorName; break; case ORMDesignerColor.VerbalizerInstanceValue: retVal = VerbalizerInstanceValueColorName; break; default: Debug.Fail("The cases may not match all of the ORMDesignerColor enums."); throw new ArgumentOutOfRangeException(); } return retVal; }
/// <summary> /// Get the name of an item from its index /// </summary> /// <param name="itemIndex">A valid item index</param> /// <returns>A name. Throws on an invalid index</returns> private static string NameFromItemIndex(ORMDesignerColor itemIndex) { string retVal; switch (itemIndex) { case ORMDesignerColor.Constraint: retVal = ConstraintColorName; break; case ORMDesignerColor.DeonticConstraint: retVal = DeonticConstraintColorName; break; case ORMDesignerColor.ConstraintError: retVal = ConstraintErrorColorName; break; case ORMDesignerColor.RolePicker: retVal = RolePickerColorName; break; case ORMDesignerColor.RoleName: retVal = RoleNameColorName; break; case ORMDesignerColor.ActiveConstraint: retVal = ActiveConstraintColorName; break; default: Debug.Fail("The cases may not match all of the ORMDesignerColor enums."); throw new ArgumentOutOfRangeException(); } return retVal; }