I am using Netbeans. I don't know what I'm doing wrong and I'll detail what I've done in sections within the attached image:
Rename theme.res to theme_legacy.res
Delete indicated file and folders.
In the designer create the constant "theme" and save file.
Rename resource file in main class and save file.
Activate CSS file and save.
In section 6 it shows the incomplete CSS file. After executing the project another "theme" is created as shown in section 7.
I appreciate your comments.
To do a "slow migration" just do the following:
Remove the includeNativeBool constant from the CSS - this means we inherit the native theme instead of the old theme (which I assume already inherits the native theme). You can only inherit one theme...
In the code load the legacy theme just like you do right now
Layer the CSS on top by adding the following line:
theme = UIManager.initNamedTheme("/theme", "Theme");
Once you do that the theme will include both the legacy code and the new stuff. This is from the developer guide "Theme Layering" section.
Related
I'm hoping to create a WPF User Control Library with reusable controls for my many projects to save time recreating them every time (something I've found myself doing).
So I:
Created a WPF User Control Library, and created a ThemeDark.xaml file to contain common colour keys and styles.
Created a separate regular WPF project in the same solution so that I can test the controls in an actual window.
Added a project reference to the User Control Library.
Added a ResourceDictionary.MergedDictionaries into the App.xaml which references the theme file from the other project.
The problem: I can access and use the SolidColorBrush keys from the theme file just fine in the testing project, but for some reason IntelliSense can't see the Styles (which all have keys).
I also can't seem to use the pack://application:,,,/ method of referencing the ResourceDictionary in App.xaml; it only accepts the filename. This was originally set through the Properties panel -> Source -> Browse, however I have tried a few different formats, all to no avail. It also doesn't seem to notice that ThemeDark.xaml is in a Themes/ directory within the User Control Library project.
So - How does one properly reference a ResourceDictionary from a WPF User Control Library project and be able to use all resources (including Styles)?
DarkTheme.xaml (inside user control library project):
App.xaml (inside testing project):
Resulting behaviour (very strange - SolidColorBrushes available but Styles aren't):
I found the problem. I had removed the spaces from the project's namespace, but not from the assembly name.
Once that was fixed I was able to use Source="pack://application:,,,/MyControlLibrary;component/Themes/ThemeDark.xaml"
MyControlLibrary isn't the actual name! ;)
My theme.css is 58K, but the generated theme.res (which does not contain any images or fonts, only the theme generated from css) is 349K.
Since theme.res is a binary format, and probably more compact than a css text file, this seems strange - has anything changed in the format or could something be wrong in my css file?
If on the other it is normal that the theme.res size can be so much bigger than the theme.css, wouldn't it make sense to add an option to just include the css in the distribution and then generate the theme.res on the device on first run of the application?
58k is huge for a CSS theme so this makes sense. Notice that some CSS styles can't be implemented in Codename Ones styling so the CSS tool launches a browser and grabs a screenshot from the browser then generates an image based on that.
To see if this is what happened just open the resource file using the designer tool and go to the images section to see what images were generated. You can then reverse the styles that triggered image generation and see if you can tune the CSS a bit to avoid image creation.
Two questions:
What are the steps to add a data file to theme.res in a css activated project? When I open the generated theme.res with the resourceEditor, I can see the data file but the code Resources.getGlobalResources().getData("datafile") returns null.
I keep having some multi-image files "SideCommand*.png" from Resources.getGlobalResources() that I have no idea where they are from since they do not appear in the generated theme.res loaded in resourceEditor.
It could sound like the process is broken somewhere or I do not check out the right theme.res but adding an image to the css area works just fine. I can see it in the resource Editor and I can load it using Resources.getGlobalResources().getData("imagefile"). I'm really lost here, any chance you can guide me?
Cheers.
Emmanuel
If you define a border that can't be satisfied by the existing borders in Codename One the CSS plugin generates a 9-piece border for you by using the JavaFX HTML engine to render the CSS and grab a screenshot. That means the css for SideCommand uses a fancy border.
The CSS processor supports images but not data files at this time. You can add an image using this approach: https://www.codenameone.com/blog/using-css-to-import-images.html
Notice you can add additional res files for data.
How to embed an application icon into application.exe using WPF and F#? I did not find it anywhere.
I think the approach is the same for WPF and WinForms, which in F# means manually!
Please see this answer.
You could also looks at FsEye's source for reference (it's done in WinForms), see line 39 of http://code.google.com/p/fseye/source/browse/tags/1.0.0-final/FsEye/FsEye.fsproj, the file http://code.google.com/p/fseye/source/browse/tags/1.0.0-final/FsEye/IconResource.fs, and line 23 of http://code.google.com/p/fseye/source/browse/tags/1.0.0-final/FsEye/Forms/WatchForm.fs
(Update: link is no longer alive -- removed)
Quote:
"Make a .rc file with the following line:
1 ICON "icon.ico"
Then compile it with rc.exe and include the .res file in your project's properties page.
You may also include .resources files in your project but the system will not pull the application icon from those."
I need to display an image, which I've done without problems before, but today I decided to be tricky and use "add as link" instead. Well, now I get:
The file Images/hello.png is not part of the project or its 'Build Action' property is not set to 'Resource'.
Wait... its Build Action is set to Resource. I've seen a Silverlight solution that involves the usage of Merged Dictionaries to share files between Silverlight and WPF projects, but it's not clear to me that this would even apply to my WPF + Image issue.
Has anyone solved this problem before? I could make copies of all of the images, but that seems a little silly if I have a shared repository with clip art and the like.
Dave,
I've just tried to add image as a link to plain WPF application. Build action is "Resource" (don't confuse with "Embedded Resource"). I've added it to the root, and refer to it as <Image Source="/file_name.jpg"/> - all works fine.
The message you have is it compile or runtime? If it's a runtime, how do you refer to the image? Do you see it in Reflector, when you open your assembly (it should be under Resources folder)?
I have images in one assembly which I want to share into another. I've used Add as Link in my second assembly. In the project where the actual image files are located they are in a Resources\Images folder. In the project which links to those files the links are also in a Resources\Images folder. At runtime a XamlParseException claiming "cannot locate resource" is thrown.
My xaml which is referencing the image is in a UserControls folder.
In the project which actually contains the images the path ..\Resources\Images\Blah.png works fine as expected.
Opening the DLLs in Reflector makes it obvious that in the assembly with the linked images holds the images at the root level - the compiler is not respecting the folder location. So in the project with the linked files I have to use ..\Blah.png to find the resource.
Surely a bug in the compiler?