Hi,
I would like to control the font used by all of the controls in our application. Using a style file I have been able to set the base style role's fontName, this seems to work ok. I would rather not hard code the font name in the file and instead determine it at runtime and set this value accordingly. I could modify the style file prior to loading it if I have to but I was hoping for a better way. Should I muck with the StyleManager api to do this? I have found any examples of this.
Thanks for your help,
Bill
Hi Mike,
I have a follow up question. I used the code you posted to set the default font name. I also updated it to set the font size as well which is causing some problems. This works great. We attach a zoom control to our grids and trees that allow the user to zoom in and out. To accomplish this we just change the font size. This no longer works because of the hardcoded font size in the style library. What is the best way to allow the changing of the font size during zoom, but still use the same font? I was thinking I could create 2 style sets one that is the base and another that is the zoom which is the base without a hard coded font size. During the zoom I would just switch over to the Zoom style set. Is there a better way to do this?
Thanks,
Thanks mike, that worked great...
Hi Bill,
Well, this is kinda quick and crude, but the code would look something like this.
private void ultraFontNameEditor1_ValueChanged(object sender, EventArgs e) { ApplicationStyleLibrary styleLibrary = new ApplicationStyleLibrary(); styleLibrary.LoadFromStyleManager(); StyleSetSettings styleSet = null; if (styleLibrary.StyleSets.Count > 0 && styleLibrary.DefaultStyleSet != null) styleSet = styleLibrary.StyleSets[styleLibrary.DefaultStyleSet]; if (styleSet == null) { styleSet = styleLibrary.StyleSets.Add("Default"); styleLibrary.DefaultStyleSet = styleSet.Key; } StyleSettings baseRole = styleSet.RoleStyles.GetStyle("Base", true); StateSettings normalState = (baseRole.States.Exists(RoleState.Normal)) ? baseRole.States[RoleState.Normal] : baseRole.States.Add(RoleState.Normal); normalState.Appearance.FontData.Name = this.ultraFontNameEditor1.Text; styleLibrary.UpdateStyleManager(); }
I would like to be able to do it all in code. Is it possible or do I need to load an isl file? Either way, can you show my how to modify the base UI in code?
Thanks again,
I think what you would have to load is load your StyleLibrary into memory and then modify the base UI Role in code.
But how you would do this depends on whether you want to load a library from a file first, or just create a new library. And do you want to save the changed setting to a file or just do all of this in code?