Can we set themes in GTK 3 for Windows? - c#

In Ubuntu, installing themes are as easy as copy-pasting GTK theme into the themes folder, then with the tweaks tool we can select the theme.
I couldn't find a working solution or workaround to apply themes.
Steps I have tried:
Installing the runtime
The GTK runtime I am using is
https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases.
Get a theme from https://www.pling.com/p/1246387/
Extract the content to C:\Users\username\AppData\Local\Gtk\3.24.24\share\themes
Edit settings.ini on C:\Users\Seiko Santana\AppData\Local\Gtk\3.24.24\etc\gtk-3.0\settings.ini putting gtk-theme-name=Ultimate-Dark-(Cpt)-Violet
Run any GtkSharp application.
It is still loading Adwaita theme. Did I miss something? I'm developing on .NET 6 and GtkSharp if that matters.
Thanks in advance.

I put the theme file under the themes directory like so:
, and added the following code right after Init (if I put it before that, it causes a null exception).
public static void Main(string[] args)
{
Application.Init();
Gtk.Settings.Default.ThemeName = "Ultimate-Dark-(Flat)-Violet";
and it worked:
Without that line, the default theme is like this, so it definitely worked.

Related

Localizing Xamarin Forms

I am trying to localize a Xamarin Forms app. I followed all the steps included here: https://developer.xamarin.com/guides/xamarin-forms/localization/
However, in the Android Emulator, after changing the default language, the strings do not get displayed, they remain the default language. On the device the app doesn't even launch.
Steps taken so far:
1) tried breakpoint (BP) in the main launcher, it skipped the BP and entered the main page
2) tried BP on the Localize class, it doesn't reach it
3) tried BP on the Device.OS check, skips it.
The resource files in Visual Studio are the following:
AppResources.resx
AppResources.fr.resx
AppResources.es.resx
Anyone ever succeeded localizing a Xamarin Forms app before ? I need some assistance with this as Visual Studio does not raise any exception ...
UPDATE 1 :
The resource files in Visual Studio are the following:
AppResources.resx
AppResources.fr_FR.resx
AppResources.es_ES.resx
UPDATE 2:
After recent suggestions and modifications I have the following exception: Markup extension not found.
This is disturbing as the markup extension class is there.
Doesn't work in DEBUG mode (Android only)
If the translated strings are working in your RELEASE Android builds
but not while debugging, right-click on the Android Project and select
Options > Build > Android Build and ensure that the Fast assembly
deployment is NOT ticked. This option causes problems with loading
resources and should not be used if you are testing localized apps.
SOLVED:
The problem was in the declaration of the extension. In a PCL project, the following took place:
a) the TranslateExtension class is located in a subfolder named Pages
b) initial declaration was
xmlns:languages="clr-namespace:MyApp;assembly=MyApp"
c) the following declaration solved the problem:
xmlns:languages="clr-namespace:MyApp.Pages;assembly=MyApp"
along with language code naming conventions of the .resx files as mentioned above
2021 UPDATE
All the current answers are not valid anymore! You need to add resources. Right click your xamarin forms project (Not xamarin android or ios) => Go to project properties ==> Resources ==> Add Resource.
This will create a "Properties" Folder and a resources.resx file which you can delete if you want to.
Then follow the official microsoft documentation by creating a AppResources.resx and other language files (such as AppResources.ar.resx file for arabic). All these files MUST BE in the properties folder.
Then, in your XAML page, declare the namespace as:
xmlns:res="clr-namespace:YourProject.Properties"
Then simply use:
<Label Text="{x:Static res:AppResources.Address}" >
This will use the corresponding Language files depending on what language the device is using. If the language is not supported it will use the defulat file (AppResources.res)
FIUH!!! Wasted one hour to solve this!!!

WPF: Themes and how they can be used

I've just purchased the Telerik UI components for WPF and after installation it has created a distinct Telerik C# WPF project type in the Visual Studio (2013). After selecting that project template a wizard pops up and after I complete it I see a Themes folder is added to my project where there is many .xaml files like System.Window.xaml.
I know that these files may be reusable themes that can style my windows but the problem is that it is the first time that I'm comming across such files. So I have two questions:
1- What exactly are these files?
2- If they are reusable styles, how can I use them. Like but adding the whole style to an empty window.
for example if I use the Office theme, does my app automatically look like MS Office ?
Please read these documentations from Telerik:
http://docs.telerik.com/devtools/wpf/styling-and-appearance/styling-apperance-implicit-styles-overview.html
http://docs.telerik.com/devtools/wpf/styling-and-appearance/styling-apperance-themes-runtime.html
http://docs.telerik.com/devtools/wpf/styling-and-appearance/stylemanager/common-styling-apperance-setting-theme-wpf.html

Windows 8.1 Bing map control

I have added the bing map reference and name space but when I drag and drop the map control to my designer it give me an error.
A reference to "Bing.Maps.Xaml, Version=1.313.0825.0" has been added to the project.In Order to use types from the new reference,Press ok to restart the XAML Designer. After
the XAML Designer restarts, Re-create the control on the artboard.
I have restarted the xaml designer and tried new project but all in vein.
in vs2013, Select BUILD from the main menu, then Configuration Manager.
Choose x86 its done
Create an app with Bing Maps (for Windows 8.1) read msdn.
I think you can download http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples samples (it contains 200 samples for "Windows 8.1").
And you can have a look what BingMap app sample does thing different than your app (and also maybe you can try to add sample's dll to your application, there could be a version difference.)

VS 2010 designer error 'Could not find type XYZ' in Windows7. Works fine in XP

I'm stuck on a problem in VS 2010 C# .NET. I've had a project on Windows XP that includes forms, classes and a handful of my own custom components. These components are simple extensions of built-in MS components (e.g. DataGridViewEx as an extension of DataGridView). Everything has worked fine in XP. I'm trying to port this project over to VS 2010 on Windows 7 / x64. I've got the solution to compile OK on Windows 7, however in design mode, when I open a form that contains one of the custom controls, I get an error 'Could not find type XYZ.DataGridViewEx. Please make sure that the assembly that contains this type is referenced.' XYZ is the namespace I use for these controls and it is the same namespace as the forms that are using the controls. All are part of the same VS project.
When I open a form in the same project that does not contain one of these custom controls, that form opens OK in the designer, and I see the custom controls along the left side in the toolbox. However if I then try to drag one of these controls into that form, it pops up an error message box 'Failed to load toolbox item 'DataGridViewEx'. It will be removed from the toolbox.' And then it gets removed from the toolbox.
Everything was always working fine in VS solution in XP. This problem only occurs in the VS solution in Windows 7 / x64.
I don't understand why it complains about not being able to find the component, since the component is part of the same project. That's a valid thing to do, isn't it?
I've search the web/forums and found cases of the 'Could not find type' error, but it seemed to be caused by a different issue, and I haven't yet found a way to get rid of the error.
Any help/tips are much appreciated!
If your project is targeted at 64 bit, you need to build for 32 bit and choose the 32-bit solution while doing your GUI editing. This is because studio is 32-bit so cannot load 64-bit controls.
Ive run into this before, be sure that in your Form.Designer.cs code file, that each call to your custom controls are done so as absolute calls. For example:
Namespace.CustomControl control;
Rather than
CustomControl control;
Look at your references and find any that have exclamation point icons. Remove the bad references and add them back to your project.
Have you tried disabling UAC completely (running IDE as Administrator + disabling UAC just in case).
Also - always use Fusion Log for tracing assembly loads! See http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.71).aspx for how to set it up
Did you rebuild your components from scratch?
Are the projects included?
Are they all building?
Are they all building on the same platform (x86 vs x64)?
Set the default built to x86 and that should fix it.
Clean the solution
Build the project containing the Control
Add the control to the toolbox/form
See if this works.
For anyone who with similar issue(s). I just came across this in VS 2013 (VB side) on an x86 PC. As mentioned above, I toggled from 'anyCPU' to 'x86' and the form designer opened right up. Simple, but probably wouldn't have tried it without the above post(s). For what it's worth, I toggled back to 'anyCPU', and as yet have had no recurrences...
I faced the same error, can't able to Build my application.
So searched here, Says to change the solution platform X64 or X32.
But in my case the Solution platform only shows Any CPU and configuration manager option only
But i simply change the solution configuration.
Debug => Release
then
Release => Debug
Finally clean and rebuilt the solution. Its works for me!!:)
While the top answer from #richard-whitehead is correct that the 64bit editor cannot load the 32bit controls which is why you're seeing the error, there is another way to have Visual Studio edit 32bit GUI controls in a 64bit GUI project as described here:
https://stackoverflow.com/a/26539992/2280961

Application.EnableVisualStyles() not working

I cann't make my application to apply Windows visual styles.
Application.EnableVisualStyles() in program.cs not changing RenderWithVisualStyle property to true.
[STAThread]
public static void Main(string[] startArgument)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
.....
}
Interestingly if I'm debugging with "Enable visual studio hosting process", Application.EnableVisualStyles() works as expected, RenderWithVisualStyle goes to true and styles are applied. But no styles without hosting process either Debug or Release mode.
Changing target framework v.2 to v.3.5 makes nothing.
Any ideas please, I'm stuck with this issue and googling for 3 days with no success.
Many thanks
You need to embed a manifest XML file that specifies that the new version of the common controls DLL should be used. See the MSDN article on visual styles for more information on how to do this.

Categories