I have a localized app with all strings in Resources.resx file. This is one of the many approaches which is really designed for WinForms, but works with WPF as well.
The problem is when I want to put a non-breaking space in localized text. Entity code is converted to text. Inacceptable. So I tried to paste the Unicode character in the text, but it looks like it's converted to regular space and doesn't really work.
Of course I'm open to change localization of my app, but it's really important it should work automatically - the language should be derived from system display language. This is the main reason I use Resource Designer for it. If I could use resource dictionary and still use automatic detection feature I would switch to resource dictionary.
When I copied non-breaking space character from Word or any website, it didn't work, so I thought it's no way to do this.
Then I finally got the idea of inserting into a XAML TextBox, copy it from there and paste inside resource designer text.
Not a great solution, but it works. It can be sort of automated with keeping non-breaking space sample in any text file within the project. Just to copy it from there if needed. The greatest downside of this is the space totally looks like a normal space, so I won't be able to see what kind of space is in the text until I actually display it in a control.
Related
I need to setup a common code styling pattern which team needs to follow and will give warning or error to the developer while writing/compiling the code or pushing the code on the repository.
I have gone through couple of sites explaining about the EditorConfig file for setting up the styling in Visual Studio.
Also Gone through the link Code Style Option to give the style to the code.
The problem is Code Style Option have predefined styling.
I need to setup some custom styling in code like
A space before and after = operator
A space after comma in function parameter.
A proper indentation will be applied automatically to that file after the build. etc
If the answer lies in the Editorconfig for this Please let me know a guide to data setup in that file
Most of what you asked for is, for the most part, already enabled by default, but you can configure it using an .editorconfig as you mentioned. You won't be able to make it as specific as you requested, however by the sounds of it, I would think you'd want this formatting applied for all cases, and not these specific cases you mention. If that isn't the case, then I don't think there any native way to specify the specific formatting you asked for.
Add an .editorconfig file to your project, and open it. Note that you should be able to create .editorconfigs for each project to specify formatting in each, or you can make a global one.
For adding a space before and after an equal sign, the control for this is "Set spacing for operators". This will apply however to all operators. I don't think you can narrow it down to only equal signs:
For spaces after parameters, the control for this is "Insert space after comma". Again, this will be for all commas used throughout your code, not just for parameters:
Lastly, you can control the indentation settings you wish by looking under the Whitespace → Indentation and spacing section:
For formatting on build you have some options. You can download a format on save extension, but that wouldn't format on "a build" technically. However I think because when a build is performed, a save of all files automatically occurs, and this should also format them.
One other way I've found is using the dotnet format command as a Post-Build event.
I’ve been searching on here and I’m developing a chatbot that has various responses, some of the responses are pretty long strings. Is there any way to make sure that line breaks don’t occur mid-word in the output? Would I have to insert it in my code before every response or define it before the method begins? Or is this just not possible? Thanks.
There is no built-in way to format string to fit console.
You need to decide what is the criteria for your line breaking algorithm and implement that.
Notes
you need to re-calculate it every time you render the text (assuming you have some sort of history shown) as window size can change (you can resize console windows similar to all other windows thus changing character-width).
depending on the language finding boundaries of words could range from trivial to implement ("just use spaces") to multiyear research project for once that don't use spaces (range similar to xkcd:Tasks :)).
If you have options I'd recommend switching to HTML rendering instead of console as word breaking already done there for you (and much more like proper emojis which you will have hard time with
in console app)
I am making an application that will generate and SQL scripts from a template and after taking input for different fields from the user.
There are many templates, so the GUI needs to adjust for the fields that the user will be filling out.
In the interest of keeping this scalable, I'd rather not hardcode the GUIs into the program, but would like have it read from an XML file and change based on the template the user has selected.
This is preferred because if a new template were to arise, then all that the program needs is a XML file that corresponds to the template. And the actual code does not need to be changed.
I have my eyes set on using C# for this, as I have good experiences using it.
I am open to suggestions for other languages though.
Edit: This is a project for work, and I wanted to be sure that this is possible with C# before convincing my employers to expand into using C#.
You could do this sort of thing by subclassing Windows.Forms.Form and adding a constructor to accept your XML file as a parameter. Add a parser for your XML file that will interpret instructions for which labels and fields you want to add to a consistent form design (say, two columns with a label for field name on the left and the actual input field on the right, easily achievable by filling the form with a TableLayoutPanel). You just need to lay out your design constraints from the beginning and stick to them.
This is essentially what visual studio does when you create a form through the designer anyway, so I'd suggest you start by creating an example form manually and just looking at the kind of code it places in the form's designer.cs file
Any language can do that. It's more about design patterns than specific technologies.
If you meant writing a GUI only declaratively and with XML, though, then no. You'd have to write your own parsing and GUI assembling code.
I'm working on a number-crunching app with some fairly (from my POV) complex math. My first thought was,
Gee, it'd be really nice to be able to take a screen shot in
Mathematica and include it as a comment in my C# source.
I see a cdata value when entering /// alongside summary, remarks, and other options. Custom tags appear to also be supported (as there doesn't appear to be any validation happening).
In order of preference, I'd like to:
Link Mathematica code to my C# source, and have said code appear, in all its Greek-laden glory, as a comment above the method that calls it (or from which it was generated). Bonus points for actually embedding the Mathematica editor in VS!
Link to an image file containing a screenshot of the above, manually generated via Paint and the snip tool, and have VS display it.
Embed the image in a CDATA section, and have it automagically render inside of VS when viewing the code, inline with said code. Generating a base-85 (or whatever) encoded version of an image is trivial. The problem at this point is getting it to display.
Ways that this is possible:
Write an app that overlays an image on the screen and, via magic, keeps it aligned with the source view in VS. (This is ridiculous, but, hey, so is a language that requires you to denote variable names with a $, and yet has a full BNF grammar available to anyone who can Google. Oh, what a world...)
I got nothing.
Suggestions? Is it possible to extend VS so that an image, or control (where Mathematica could be hosted), can appear in the source view?
(note: one of my favorite statements is "It's software. Anything is possible. Give me a 9-volt battery, a paper clip, pocket knife and a monkey hopped up on speed, and we'll make it happen." In this case, I mean within the realm of practicality.)
It looks like this Visual Studio plug-in should solve most of your requirements:
http://visualstudiogallery.msdn.microsoft.com/793d16d0-235a-439a-91df-4ce7c721df12
MS Word has this capability in its Hebrew and Arabic versions. I would like to achieve this in a windows desktop application, using .Net (may be with win-api calls).
As explained in the link provided by Otaku here, current rich text edit controls can not handle this (unless you go for the hack OP in that Q did, which did not seem like a very good solution).
You could write code to do this manually yourself, ditching the text edit control completely, but that would probably mean a lot of work. It took Microsoft years to get support for combining diacritics working properly in MSWord. I would search for open source software that has this capability, and look at how other developers have done it. It might be hard to find, though, and you would likely have to step outside .NET-land. Maybe OpenOffice can do this?
This discussion might also be of help.
I am afraid that you will find, though, that you'll have to manually parse the Unicode and assign colors to the correct glyphs. If you want to be complete, that is one heck of a job.