예제 #1
0
        /// <summary>Sets the font set for the component passed.</summary>
        /// <param name="component">The component to set the font set for.</param>
        /// <param name="fontStyle">The name of the font set used.</param>
        public void SetFontStyle(object component, FontStyle fontStyle)
        {
            FontSetInformation information = GetFontInformation(component);

            SetFontInformation(component, new FontSetInformation()
            {
                Set = information.Set, Size = information.Size, Style = fontStyle
            });
        }
예제 #2
0
        /// <summary>Sets the font set for the component passed.</summary>
        /// <param name="component">The component to set the font set for.</param>
        /// <param name="information">The name of the font set used.</param>
        protected void SetFontInformation(object component, FontSetInformation information)
        {
            if (FontSetInformation.Empty.Equals(information))
            {
                if (ComponentToFontInformation.ContainsKey(component))
                {
                    //Reset the font.
                    foreach (PropertyInfo property in component.GetType().GetProperties())
                    {
                        if (property.CanRead && property.CanWrite && property.PropertyType == typeof(Font))
                        {
                            property.SetValue(component, null, null);
                        }
                    }

                    if (DesignMode)
                    {
                        //Remove the font set.
                        ComponentToFontInformation.Remove(component);

                        //Remove the type descriptor provider.
                        TypeDescriptor.RemoveProvider(ComponentToTypeDescriptorProvider[component], component);
                        ComponentToTypeDescriptorProvider.Remove(component);
                    }
                }
            }
            else
            {
                ComponentToFontInformation[component] = information;

                Font fntFont = null;
                if (DesignMode || (Resolver == null))
                {
                    if (!ComponentToTypeDescriptorProvider.ContainsKey(component))
                    {
                        ComponentToTypeDescriptorProvider[component] = new FontProviderTypeDescriptorProvider(component, TypeDescriptor.GetProvider(component));
                        TypeDescriptor.AddProvider(ComponentToTypeDescriptorProvider[component], component);
                    }
                    fntFont = new Font("Microsoft Sans Serif", information.Size, information.Style);
                }
                else
                {
                    if (Resolver == null)
                    {
                        throw new Exception("The font set Resolver hasn't been assigned.");
                    }
                    fntFont = Resolver.RequestFont(information);
                }
                foreach (PropertyInfo property in component.GetType().GetProperties())
                {
                    if (property.CanRead && property.CanWrite && property.PropertyType == typeof(Font))
                    {
                        property.SetValue(component, fntFont, null);
                    }
                }
            }
        }
예제 #3
0
        /// <summary>Sets the font set for the component passed.</summary>
        /// <param name="component">The component to set the font set for.</param>
        /// <param name="fontSet">The name of the font set used.</param>
        public void SetFontSet(object component, string fontSet)
        {
            FontSetInformation information = GetFontInformation(component);

            SetFontInformation(component, new FontSetInformation()
            {
                Set = fontSet, Size = information.Size, Style = information.Style
            });
        }
        /// <summary>
        /// Returns a font that best matches the described font set.
        /// </summary>
        /// <param name="p_fsiFontInfo">The information describing the desired font.</param>
        /// <returns>A font that best matches the described font set.</returns>
        public Font RequestFont(FontSetInformation p_fsiFontInfo)
        {
            Font fntFont = null;

            for (Int32 i = m_lstFontSetGroups.Count - 1; i >= 0; i--)
            {
                FontSetGroup fsgGroup = m_lstFontSetGroups[i];
                if (fsgGroup.HasFontSet(p_fsiFontInfo.Set))
                {
                    fntFont = fsgGroup.GetFontSet(p_fsiFontInfo.Set).CreateFont(p_fsiFontInfo.Style, p_fsiFontInfo.Size);
                }
                if ((fntFont == null) && (fsgGroup.DefaultFontSet != null))
                {
                    fntFont = fsgGroup.DefaultFontSet.CreateFont(p_fsiFontInfo.Style, p_fsiFontInfo.Size);
                }
                if (fntFont != null)
                {
                    return(fntFont);
                }
            }
            return(null);
        }
예제 #5
0
		/// <summary>Sets the font set for the component passed.</summary>
		/// <param name="component">The component to set the font set for.</param>
		/// <param name="information">The name of the font set used.</param>
		protected void SetFontInformation(object component, FontSetInformation information)
		{
			if (FontSetInformation.Empty.Equals(information))
			{
				if (ComponentToFontInformation.ContainsKey(component))
				{
					//Reset the font.
					foreach (PropertyInfo property in component.GetType().GetProperties())
					{
						if (property.CanRead && property.CanWrite && property.PropertyType == typeof(Font))
							property.SetValue(component, null, null);
					}

					if (DesignMode)
					{
						//Remove the font set.
						ComponentToFontInformation.Remove(component);

						//Remove the type descriptor provider.
						TypeDescriptor.RemoveProvider(ComponentToTypeDescriptorProvider[component], component);
						ComponentToTypeDescriptorProvider.Remove(component);
					}
				}
			}
			else
			{
				ComponentToFontInformation[component] = information;

				Font fntFont = null;
				if (DesignMode || (Resolver == null))
				{
					if (!ComponentToTypeDescriptorProvider.ContainsKey(component))
					{
						ComponentToTypeDescriptorProvider[component] = new FontProviderTypeDescriptorProvider(component, TypeDescriptor.GetProvider(component));
						TypeDescriptor.AddProvider(ComponentToTypeDescriptorProvider[component], component);
					}
					fntFont = new Font("Microsoft Sans Serif", information.Size, information.Style);
				}
				else
				{
					if (Resolver == null)
						throw new Exception("The font set Resolver hasn't been assigned.");
					fntFont = Resolver.RequestFont(information);
				}
				foreach (PropertyInfo property in component.GetType().GetProperties())
				{
					if (property.CanRead && property.CanWrite && property.PropertyType == typeof(Font))
						property.SetValue(component, fntFont, null);
				}
			}
		}