Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
            }
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
            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));
            }
Ejemplo n.º 6
0
 Color IORMFontAndColorService.GetForeColor(ORMDesignerColor colorIndex)
 {
     return(GetForeColor(colorIndex));
 }
Ejemplo n.º 7
0
 FontStyle IORMFontAndColorService.GetFontStyle(ORMDesignerColor colorIndex)
 {
     return(GetFontStyle(colorIndex));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Implements <see cref="IORMFontAndColorService.GetBackColor"/>
 /// </summary>
 protected static Color GetBackColor(ORMDesignerColor colorIndex)
 {
     return(Color.White);
 }
Ejemplo n.º 9
0
		/// <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;
		}
Ejemplo n.º 10
0
		FontStyle IORMFontAndColorService.GetFontStyle(ORMDesignerColor colorIndex)
		{
			return GetFontFlags(colorIndex);
		}
Ejemplo n.º 11
0
		Color IORMFontAndColorService.GetBackColor(ORMDesignerColor colorIndex)
		{
			return GetBackColor(colorIndex);
		}
Ejemplo n.º 12
0
		/// <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;
		}
Ejemplo n.º 13
0
		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;
		}
Ejemplo n.º 14
0
			/// <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;
			}
Ejemplo n.º 15
0
			/// <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;
			}