Allowing user selected Global Theme for winform app - user-interface

I am using DevExpress controls in a winform app I am building for internal use. My app has about 30 forms in total and I am trying to figure out a way to allow my user's to select a theme. I have seen this mentioned here at SO multiple times in answers to other posts.
I understand how the StyleController works, I believe, but what I am wondering is how I can use 1 Style controller for the whole app.
Right now I am trying to create 1 StlyeController at the Shell form and then pass a reference to it to each child form. From there I then have to programatically set the StyleController property for each control. I don't mind I just wonder, especially from those who have done this, if there is a simpler way?

It is very simple. This example is assuming that you are using skins.
In the constructor of your main form calls:
DevExpress.Skins.SkinManager.EnableFormSkins();
This will enable your form to use the current skin. It is also important that each of your forms derived from XtraForm.
After that you need to setup the global look and feel object for your application:
//This set the style to use skin technology
DevExpress.LookAndFeel.UserLookAndFeel.Default.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
//Here we specify the skin to use by its name
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Black");
If you want to set the look and feel of your application like Office 2003, the setup is different. You just have to call the following function:
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetOffice2003Style();
So, every control of devexpress will use these settings to paint themselves. It is possible to specify a custom LookAndFeel object for some controls but I never used it because I dont see the point to have a custom display for a control or a form.
Exception:
There is one exception in Devexpress framework. The NavBarControl does not use the skin technology automatically from your global LookAndFeel object, you need to specify a setting to enable that:
//To use the current skin
youNavBarControl.PaintStyleName = "SkinNavigationPane";
//To use the current look and feel without the skin
youNavBarControl.PaintStyleName = "NavigationPane";

With version 11.2 I used the information in this article:
http://www.devexpress.com/Support/Center/p/K18013.aspx
In summary :
* Inherit all your forms from XtraForm
* Leave look and feel settings default so that they use the default skin
* Modify the default skin with the following line of code:
DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "DevExpress Dark Style";

Related

In polotly.js, how may I get call a javascript callback called when a slider is changed, and get its current value as argument?

I want to build a web page in plotly.js for plotting a mathematical function depending on some parameters. I want the user to be able to change it using a slider.
For doing this, I need to call my own javascript function (to recalculate the points of the graph), get the current value of the slider and update the graph.
I've looking at the examples in
https://plotly.com/javascript/sliders/
but none of them does what I need, and the documentation
at
https://plotly.com/javascript/reference/layout/sliders/
is not clear at all. It seems that I need to set the "method" property (also "args"). It says
"Sets the Plotly method to be called when the slider value is changed. If the skip method is used, the API slider will function as normal but will perform no API calls and will not bind automatically to state updates. This may be used to create a component interface and attach to slider events manually via JavaScript."
What does it mean?
I already have an application using plotly dash at
https://github.com/pdenapo/normal_bivariada/blob/main/normal_bivariada_interactiva.py
and it is very easy to do using #app.callback. However,
I want to do the same in javascript (since I want to run it on a web server, where I cannot run a python application).
¡Many thanks for any help!

Xamarin persist theme

Currently I am only testing on an Android emulator. I have installed the Theme Nuget packages.
In my App constructor I have:
// Load the desired theme (default to Light)
if (Current.Properties.TryGetValue("Theme", out object theme))
Resources = theme as ResourceDictionary;
else
Resources = new LightThemeResources();
I then have a method in the App class:
public async Task SwitchTheme()
{
// Switch the current theme from List to Dark to Light
if (Resources?.GetType() == typeof(DarkThemeResources))
Resources = new LightThemeResources();
else
Resources = new DarkThemeResources();
// Persist the Theme
Current.Properties.Add("Theme", Resources);
await Current.SavePropertiesAsync();
}
When I call the method the theme switches from light-dark-light etc. But when I restart the App, it always defaults to Light. As if the "await Current.SavePropertiesAsync();" did not work.
Can anyone suggest what the problem may be?
Xamarin Forms Properties is intended for use with C# value types and objects that can be easily serialized - not complex objects like Resources.
From the docs
Values saved in the properties dictionary must be primitive types,
such as integers or strings. Attempting to save reference types, or
collections in particular, can fail silently.
All you really need to do is store a string value - either 'light' or 'dark' and then load the appropriate theme based on that. You don't actually need to store the theme itself.

Show specific presenter instance to flex panel gwt mvp

I'm still learning GWT, yet already have to face some kind of challenge for a work I have to do. Can't show any specific code so I'll try to explain it well.
Here's the situation: A certain class "Navigator" creates and save the Presenter instances of my architecture to allow reusing them. There is a method show() inside that same class that actually displays the view related but that system only works full screen by calling RootPanel.get().
What i'd like to do is showing that presenter instance's view inside of a flex panel element declared in a class myView (related to a class myPresenter) that basically uses Flex Panel to structure it's content.
To make it maybe more clear:
class myView{
...
flexPanel.setWidget(firstWIdget)
flexPanel.setWidget(secondWidget) //secondWidget to be replaced by a "thirdWidget"
...
}
I'd like the secondWidget to be replaced by another one, let's call it thirdWidget, that consists of a specific presenter instance's view.
To resume, I'd like my presenter instance's view to not go full screen but only occupy a certain area of the screen.
The displaying is managed almost entirely programmatically, means very limited use of css files and no use at all of xml ui files.
How can I manage this ?
Thanks
Use a SimplePanel as a container for your views returned by your Navigation class instead of adding them directly to root panel, and use that instance of SimplePanel where ever you want.

Use OneUI theme depending on the installed version of Domino

Based on this snippet (http://openntf.org/XSnippets.nsf/snippet.xsp?id=oneui-on-the-fly-theme-changer) I tried to calculate the theme depending on the release of Domino. I'd like to use "oneuiv2.1" on Domino<9 and "oneuiv3.0.2" on a 9 release.
EDIT: To be clear: I already can identify the version, the question is about calculating and setting the theme at the right time as my following approaches seem to do the work too late. The page renders and then the theme is set - however this is my impression.
These were my first approaches:
Calculate the theme name in the "extends" property of the theme - didn't work.
Calculate and set the value of the session property "xsp.theme" in a beforeRenderResponse and beforePageLoad event of my Xpage - this also failed
Set up a bean to calculate the value and set the session property when the bean is initialized - same result
Of cause you can calculate (render) all the needed stylesheets and scripts of OneUIv2.1 and OneUIv3 in the theme file but hey, this is quite a hassle with that amount of resources, isn't it?
So my question is: do you have any other ideas how to achieve this? This would be very handy to use if your applications can use both themes with the same layout, independent where the application runs - whether on a 8.5.x or 9 machine.
Looking forward to the discussion :-)
You can change theme on beforePageLoad event:
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
beforePageLoad='#{javascript:
var theme = session.getNotesVersion().startsWith("Release 8") ? "oneuiv2.1" : "oneuiv3.0.2";
if ( ! theme.equals(context.getSessionProperty("xsp.theme"))) {
context.setSessionProperty("xsp.theme", theme);
context.redirectToPage(context.getUrl().toSiteRelativeString(context));
}
}'>
The trick is to set session property "xsp.theme" and to redirect to same page if theme has to be changed.
redirectToPage() will happen only one time per session as Notes version won't change during session.
If you use Extension Library you can do this to look for the version of Domino:
#Left(com.ibm.xsp.extlib.util.ExtLibUtil.getExtLibVersion(), 3) == "8.5")

Joomla: How to change template on a specific article

Is there a way to change the template on a specific article only?
Note that it should work without linking the article to any menu.
If you want the template override not to depend on the menu position than the standard joomla way of assigning a different template to a menu will not work. You will need to get your hands dirty and write some custom code. You will need to use the article_id as a trigger for template switch.
I did something like that at work but don't remember now how exactly this is achieved. I will post my code here as soon as I locate it.
EDIT: Found the code :)
You need to edit the file /includes/application.php, specifically the getTemplate() method. At the end of this method, just before:
// Fallback template
if (!file_exists(JPATH_THEMES.DS.$template.DS.'index.php')) {
$template = 'rhuk_milkyway';
}
you can add your condition for applying a custom template, like so:
//CUSTOM TEMPLATE FOR THE ARTICLE 13
if (JRequest::getVar('id')=='13' && JRequest::getVar('option')=='com_content') {
$template = $custom_template_name;
}
This will apply the custom template which name is inside the $custom_template_name to article with id=13. You can also use it to apply a different template to components, like I did with simplecaddy:
//TEMPLATE FOR SIMPLECADDY
if (JRequest::getVar('option')=='com_caddy'){
$template = 'shop';
}
You should really try to stay away from hard coding anything in to the template if it can be avoided. Not sure why you would specify that the article not be linked from a menu. The easiest way to accomplish this without having to write and code is to create a new menu, then add a menu item that links to the article you want to specify the template for. You don't have to put the menu in a module anywhere so it will never show up on the site, but it will show up in the menu assignment in the template manager.
You can do this with single articles, categories, sections, or even components. As long as you have a menu link to associate the template to. I always create an Admin only menu to put links that are needed to run the site, but do not need to be accessed by users.
As Brent said, avoid the temptation to modify core Joomla code! Doing this will likely stop you from doing Joomla upgrades 'cos you know it's going to break the core changes that you made.
Apart from the "hidden menu item" technique (which is useful but can break SEF URLs in some situations), a useful tool is Chameleon. This allows you to select specific articles/categories/sections (plus things like browser type, user group, component, whatever) and use these to trigger a certain template.
Though this is an old post, I thought I'd share my thoughts: You can easily change template on a single article, by implementing the onAfterInitialize() - function in a system plugin. No need to modify the Joomla core.
This works for Joomla 1.5, but should also work in 2.5:
function onAfterInitialise(){
if(true){ // f.ex. test for article ID or whatever
JRequest::setVar('template', 'beez'); // change template
}
}
In joomla 3.x versions, url-parameters are handled differently. The following was tested in joomla 3.4.8:
public function onAfterInitialise()
{
$app=JFactory::getApplication();
if(true){ // f.ex. test for article ID or whatever
$app->input->set('template', 'beez3');
}
}
More on writing plugins for Joomla here

Resources