Each new Windows 8 C# Metro project contains StandardStyles.xaml file with lot of styles and templates for various controls. Mostly I use only like 10% of them and I define lot of my own styles.
Hot to easily and safely find and/or remove all unused styles? As far as I know parsing long XAML files increases the startup time of my Windows 8 app and that's something I'd like to avoid. Or do you think I should not care about those 1800 lines of code?
The comment in the header gives you a pretty good idea:
This file contains XAML styles that simplify application development.
These are not merely convenient, but are required by most Visual Studio project and item templates.
Removing, renaming, or otherwise modifying the content of these files may result in a project that
does not build, or that will not build once additional pages are added. If variations on these
styles are desired it is recommended that you copy the content under a new name and modify your
private copy.
If you modify the file then add another view later on, you might be stuck with a view that is not working and you will have to then figure out which styles you need to re-add.
The overhead of this file is small and I would not worry about how it affects your startup time as almost every other XAML app will have the same overhead.
Related
I currently try to change the visual style of my pivot control in UWP.
I would like to change the plain default style of "just text" to something like this:
This is just an example I quickly found on the web. But it is a good representation of what I want to achieve.
I would like to make the pivot items to look like they are tabs.
They should be visibly seperated from another and when one of the items is selected I want to make it visually stand out from the others.
I'm really new to styling controls. I actually just started to read about it yesterday. But it really helps to make an app visually interesting instead of just the plain default styles.
I would really appreciate some help or guidance here :)
Greetings :)
We can modify the PivotHeaderItem default style to implement the effect. Here is also a similar thread that describes how to achieve it : Pivot Header style
Please note that: the PivotHeaderItem default style is based on the Windows Software Development Kit (SDK) for Windows 10, Version 1511 (Windows SDK version 10.0.10586.0). If your app target on other version, the styles and resources may be have different values. But the approach to implement the effect is similar. You can find the corresponding source in the path of your Windows SDK installation such as:
C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.16299.0\Generic.
In webstorm, is there a way to exclude a folder (hence avoid indexing), but at the same time make it visible in the project structure tree? If I do exclude, it would become invisible. I read about custom scope, but it looks like it is for code inspection,... Also, the folder in question is not a library, but some generated one.
For an example use case, I wanted to see my .tmp folder always, but not to index it as the content may keep changing. THis triggers reindexing and bit resource hungry.
Thanks.
IDEA 14 and WebStorm 9 which just have been released display excluded folders in Project View, but don't index them.
I've made a little Towers of Hanoi game, but nothing what was set on my PC looks the same on a different computer, not even the fonts. Everything is so messed up, I couldn't do it better even if I wanted this to happen. To say it short the backgrounds used for controls and forms are out of place, the initial values used for size and position of both forms and controls are bloody changed, and my project just looks like a huge mess. It's true I've worked in absolute values, because usually a programming language respects the programmer's point of view, and doesn't scales and moves everything the way it wants. If I wanted my project to rescale according to screen resolution I would had used relative coordinates, and made all my forms and controls dimensions be a certain amount of the screen's width and height.
Is there a way to preserve the project just as it was initially designed, so it would look the same on any computer?
I'm using Visual Studio 2010, and Windows 7 as OS.
You don't tell us specifically which properties you've modified from the defaults, or show us a screenshot of the before and after views from which we might be able to infer which modifications you've made. But you did mention something about changing the font, so we'll go with that.
In fact, it does try to preserve your specified properties to the extent possible. But sometimes it is just not possible. For example, if you specify a font for your controls that isn't available on the other computer, then it has no choice but to fall back to a font that is available. If you have any experience with web page design, it is a very similar problem. You have to use a small subset of web-safe fonts to ensure that they will be available on all of your users' computers. That's also why web designers are so keen now on embedding fonts into pages.
Anyway, it goes without saying that if the font has to change, the layout is going to be messed up. Different fonts are different sizes, so different amounts of text are going to fit, causing some to get cut off. That is why, in general, you should avoid changing properties like Font. If you use the defaults, things are a lot more compatible. But neither web pages nor desktop applications are WYSIWYG. You need images or PDF files for that.
Then there are system settings like DPI that can really mess things up, too. Keeping the default font isn't going to help you there. You have to design your application in a smart way. You mention something about relative layouts—these are the ticket. Unfortunately, WinForms doesn't make it easy to do this. It all but forces you into specifying absolute sizes and positions based on the pixel grid, which is mostly a waste of time, as you've seen. I describe in detail how to accomplish this in WinForms in this answer. The AutoSize property will be very useful to you. Of course, you'll also need the dynamically-growing TableLayoutPanel and/or FlowLayoutPanel controls, otherwise you'll end up with automatically sized controls that overlap one another.
Pre-emptive snarky comment: you should totally drop WinForms and use WPF instead. It is new, and cool, and sexy, and all but forces you the other way into pixel-independent layouts. Of course, it also makes it really easy to create butt-ugly, downright unusable applications that look like some of the stuff Microsoft has been churning out over the past couple of years.
#Cody Gray thanks for your insights.
com/qMBJS.png
The first image is how the main menu looks. It's kinda self-explanatory how it should had looked, without the big white margins while the text should had been inside the labels backgrounds
The second one is some in-game footage. And this is just one of the levels. It's so messed up I'm almost sorry I've lost a night doing some heavy work on the image editing side of the matter. I'm not at my own PC right now, so I've tried to rearrange all the stuff directly in Visual Studio's design window, to show how the level should had closely looked. Just imagine it without the white and black margins surrounding some controls.
Also I've tried to set the controls and forms parameters through code, when the form loads, trying to force it to look as it should but the result wasn't any better.
In a Silverlight 4 app, our user base needs to define for us what content they want on buttons, labels, various screen text, etc. I understand the methods of resource files, but what i'm wondering is when wanting to give that kind of control to the users to define the text in the resource file, what is the best way to let them do that in a way that they can view their changes to the XAML pages? Do they need to have Blend installed?
I vaguely remember when doing a WinForms app, at one point I handed off to the users the actual winform, and they used some sort of visual designer to edit button text, labels, etc., and those changes were then saved to the resource file.
Our app is MVVM, so each item in the XAML would bind to a property in its view model, and that property would then load the entry from the resource file.
If there is a way to let the user update the contents of the resx file while visually reviewing their changes please let me know.
Thanks very much in advance for any assistance.
What I have done in the past is to have a dedicated assembly for Resources (resx) files. By default, they are "embedded" into the assembly. The trick is to change the property on the resx file to NOT be embedded (False). This way, the files are separate resx xml files that must go with the assembly (and live in the same /bin directory of the running application). This is what you see in some /bin directories with the /en-US/ and other resources. In the past, I have created a simply GUI for users to be able to edit these resx files that gets written back to disk. I am not familiar with Silverlight's inner workings for this type of permissions needed, but I would guess at worse case the edited resx files just get uploaded to a server where a new copy is downloaded on next app restart or alike.
Now, when I said "in the past", that was back in 2003 days. Recently I had to do this manually using the ResXResourceReader because of an existing assembly I could not modify.
Some example code (writing it from memory, completely untested):
using (var reader = new ResXResourceReader("[path-to-bin]/MyResources.resx"))
{
var value = reader["My_key_in_the_resx_file"].ToString;
}
Do note that by going this route, you do have access to other types of resources such as binary and files embedded int he resx files.
Lastly, watch your encoding formats. Some over-seas editors use UTF16. So going with a common Unicode converter may be needed.
Also note there is a ResXResourceWriter class, should you want to roll your own writers for updating the resx files through code.
I need about 100 icons inside my application. Would it be logical to have one large image file with all the icons and then somehow split it up into individual NSImage objects? Is there a way to run some code at build time to regenerate the individual icons?
Assuming you are indeed using the icons separately, I think it would be more logical to keep them separated, for a couple of reasons:
It might seem more organized to reduce the total number of files, but having one big file with all your icons isn't a terribly organized method of storing them, either. Xcode can deal fine with a large number of icon files.
If you're using version control, it complicates the management of the history a bit. As it stands now, if you need to change an icon, you just change that icon, and you can keep a history of changes to that icon. If the icons are in one big file, then any time you change any icon, that file will show up in the history, so it'll be hard to isolate what changes to what icons you made.
It's probably easier to edit a single icon than a bunch of icons smashed together into one file.
Why write a build script or runtime code to slice up the icons if you don't have to?
100 icons? Woot? Okay,
No it would not be logical. It is possible to split them at runtime, not at build time. I would simply use the easy way and add all icons as different files.