I am not getting stylesSheetmanager in general in tool box i had been added styleSheetmanager.dll as a reference but still i m not enable to get stylesSheetmanager in general in tool box and also in label properties. what to do ??
I don't support anymore this component (because of time) but I can try to give you a start of solution.
I think that your new style isn't apply to the form because I don't reload the file if already loaded. Look at the following method in StyleSheetManager:
/// Load the styles sheet file
public void LoadStylesSheetFile()
// If not changed, we don't reload the styles sheet file
if (stylesSheetFilenameHasChanged || file == null)
throw new StylesSheetException(StylesSheetException.ExceptionType.StylesSheetFileNotFound, StylesSheetFilename);
file = new StylesSheetFile();
XmlSerializer serializer = new XmlSerializer(file.GetType());
TextReader reader = new StreamReader(StylesSheetFilename);
file = (StylesSheetFile)serializer.Deserialize(reader);
I want to change properties defined in the styles1.xml.
What should i do for that
Error is :
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "StylesSheetManager.StylesSheetManager.resources" was correctly embedded or linked into assembly "StylesheetManager" at compile time, or that all the satellite assemblies required are loadable and fully signed.
It will be great if anyone can guide me to resolve the below issue.
i am facing two issues with this
I added stylesheetManager into my mdiform and i have updated the app.config with the stylesheet xml file path under appsettings.
But when i try to build the application i am getting the below two errors
1. The type or namespace name 'Sb' could not be found (are you missing a using directive or an assembly reference?)
2. The 'StylesSheetFilename' key hasn't been found in the app.config file. Please, create this key (in the appSettings section) and set it to the (absolute) path of the styles sheet file to use.
but actually there is key with 'StylesSheetFilename' in app.config under appSettings node.
I am using dotnet 3.5. When i drag and drop stylessheetmanager into my mdiform, the below code is getting created in form.designer.cs
Yes, I will correct this in forcing the culture of the thread to English and change the styles sheet files format to English. So, the list separator will be always "," and the decimal separator will always be "."
Would it be possible to make StylesSheetFileManager a public class.
I have to throw StylesSheetManager class and use StylesSheetFileManager directly. My forms are all dynamically created (and modified), so StylesSheetManager could not work with them. I call StylesSheetFileManager.ApplyStyles() myself - seems to work just fine.
Well, technically you are right, but it won't work.
Controls on the forms are not just dynamically created but dynamically removed as well. So the form appears as a blank window, then it reads it's definition from an XML file and creates the controls. Later on the form can be "redirected" to another XML file. So the form removes all the existing controls and creates new ones.
In this case I need not only SetStyle(), but also RemoveStyle() to unregister deleted control from the StylesSheetManager.
Also, can one StylesSheetManager handle multiple forms?
PS. Great Job! I use your codes as a guide to internal structure of .Net components. Can you help me with one simple (for you) question - how to create a object based on class _name_? I mean I have an variable that keeps a class Name and I want to create an object of specified class:
Dim myClassName as String
Dim myObject as Object
myClassName = "Label"
Object = new <... ??? ...> myClassName ' Creates new label
myClassName = "TextBox"
Object = new <... ??? ...> myClassName ' Creates new TextBox
(Please answer if you know the answer off hand.)
1) Q : Would it be possible to make StylesSheetFileManager a public class.
A : I will add a RemoveStyle method to StylesSheetManager which will permit you to call it for all the controls to be deleted. This metho will only do the following :
publicvoid RemoveStyle(Control c)
2) Q : Can one StylesSheetManager handle multiple forms ?
A : not really. Because StylesSheetManager has been defined as a IExtenderProvider, it must normally be dropped on one (and so only one) form.
3) To create a instance of a control (Label for example), do something like this :
Label lbl = (Label)Activator.CreateInstance(typeof(Label));
lbl.Text = "Dynamic label";
lbl.Visible = true;
// this.controlsPanel.Controls.Add(lbl); // you can also use a TableLayoutPanel (controlsPanel)
RemoveStyle will help, but I have many forms dynamically loaded/unloaded, created dynamically based on XML definitions, designed by different programmers. I feel more confident to have one StylesSheetFileManager object created for the whole application, than bunch of StylesSheetManager objects for each form.
Just make it public, so if somebody (like me) wants to use it - let him use it.
PS. I'll think about inherit all my forms from a single parent, and put the StylesSheetManager in the parent class. Maybe it will be a better solution.
Thank you for the "Activator.CreateInstance()" hint.
Some people believe what the bible says. Literally. At least [with Wikipedia] you have the chance to correct the wiki -- Jörgen Sigvardsson People are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer
U've done a great work, but I have a question: there's a way to modify the project in order to get the style application at design time? (I would like to see the style applied immediatly in the visual studio editor)
Not actually but I'll try to do it in a next version.
About this, is there anyone who know how to display a STATIC property in the property grid of a designer. By default, the static properties are hidden. I suppose there is a little magic attribute to apply to the property but I don't know anymore.
The obvious way of having that done is to add an instance property to the class which would be mapped to the static field. But I suppose you'd prefer to avoid this... I think the real solution lies somewhere around the TypeDescriptor[^] type. As stated in MSDN:
The extensibility provided by TypeDescriptor allows the design-time representation of a component to differ from its actual run-time representation, which makes TypeDescriptor useful for building design-time infrastructure.
This means that by using a custom type descriptor, you can expose a design-time only "property" which maps to the static field (or to anything you want: method, other object, ...).
To be able to provide your custom type descriptor, you must decorate your class with TypeDescriptionProviderAttribute, then build a TypeDescriptionProvider whose method GetTypeDescriptor will in turn give back an instance of your custom type descriptor (which will implement ICustomTypeDescriptor or be derived from CustomTypeDescriptor)...
Hope this helps.
PS: why do you need to show static fields in a property grid? This can be rather disturbing: modifying one object's property will affect all the others...
Thanks to you Olivier but I found another way to do it.
Q : Why do I need to show static fields ?
A : I wanted to have just one filename for all the forms of the application.
=> I found another to do it : store the value of the 'StylesSheetFilename' property in the app.config file (this property becomes read only).
Is this will effect the application performance because it alway takes time to look up the xml, and is this the similar way of globalization/localization (just like the netbeans do) ? Is that possible maintain the label with different language in your xml?:->
In "Using the component", $1, I use the "Text" property only for an example, to demonstrate that you can manage all property of a control but I didn't realize this component to manage labels with different languages (only styles). I don't think this is the same usage. Perhaps, you can use it like this but ...
Concerning the performance, I didn't really test so sorry but I can't answer you.
yancyn, I think about what you tell me on performance and decide to modify the StylesSheetManager like this :
* the StylesSheetFileName property is now static (unique for all the component dropped on the form and so unique for all the forms so the whole application)
=> this property must be explictly defined on the code (not in the designer)
* the ApplyStyles must be expliclty called to apply the styles on the form
=> when calling this method, I watch if the StylesSheetFilename has changed from the previous call.
* If yes, I load the file and put the styles in cache
* If no, I use the styles "in cache"
So, if you set the styles of your application in the load of your mainform, the styles sheet file will be used only once. When a new form will be open, the styles "in cache" will be use.
Tell me if you see another thing I can do else I think I will put this new version in the week end.
In the next version of the component, I will handle the indexed properties. This permits to write something like dgDataGrid.Columns.HeaderText = "Text".
In fact, if the property name is indexed (contains something like this ""), I call the PropertyInfo.GetValue() method with the property name (without "") and then cast the result in IList (only indexed properties which implement IList interface are supported) which permits me to use "[x]" syntax. If you want more, feel free to see the PropertySetter.GetObject() method.
I have been thinking about doing something like this. The company I work for uses the Infragistics Control Suite which now allows skinning of Win controls. However, simple properties such as form backcolor are not supported. Also when deploying the application there are numerous library DLL's that are required. Nice Job.
Last Visit: 31-Dec-99 19:00 Last Update: 17-Dec-14 21:41