Colors dont load on outlook - outlook

Im creating an email sender that in an email displays a table with data color coded acording to the department it belongs too but several colors dont get shown and it repicks magenta and yellow where light coral and blue should be
//through Console.writeline i made sure that data is picked correctly
private string getColor(string color)
{
string colour="";
if (color.Equals("Red"))
{
colour = "#FFF08080";
}
if (color.Equals("Blue"))
{
colour = "#FFADD8E6";
}
if (color.Equals("Yellow"))
{
colour = "#FFFFFF00";
}
if (color.Equals("Orange"))
{
colour = "#FFFFA500";
}
if (color.Equals("Green"))
{
colour = "#FF90EE90";
}
return colour;
im almost sure it has to do with outlook but i havent been able to get a color te get properly displayed and is actualy visible

Found the problem, there are certain hexadecimals that outlook doesnt catch and it substitute them with others already selected, its just a matter of trying hexadecimals until it works, i would apreciate if someone found/made a list of colors that work on outlook365

Related

AmCharts V4 - What default state does AmCharts use when the hover event is finished?

My goal is to be able to click on a country and fill that polygon background of that country with a specific color.
As soon as I select another country the previous background should revert to the standard color.
How to reproduce the bug: Click on a country on the codepen and then click on another country. Now hover over the first one and it will be still "active".
It does work when I only click on the country, however after hovering over the country it will use the specific color instead of the standard color (just as if it was selected).
Here is the codepen:
https://codepen.io/ms92o/pen/KBXqLO
And here are the specific code snippets which I have created:
I think the problem arises from the state which the country gets after the hover effect is over. I thought that the default state will get used which I have provided a standard fill color.
var selectedPolygon;
polygonTemplate.events.on("hit", function(ev) {
let polygon = ev.target;
if(selectedPolygon) {
selectedPolygon.defaultState.properties.fill = am4core.color("#74B266");
selectedPolygon.setState('default');
}
polygon.setState('active');
selectedPolygon = polygon;
})
/* Create hover state and set alternative fill color */
var hs = polygonTemplate.states.create("hover");
hs.properties.fill = am4core.color("#367B25");
/* Create active state and set fill different fill color */
var as = polygonTemplate.states.create("active");
as.properties.fill = am4core.color("#FF0000");
So my question is: what state does the polygon have after the hover effect?
Generally, on hovering out, the sprite returns back to default state.
In this case, the behaviors were unexpected because that custom state, "active", is actually a reserved name state. It's used when selecting polygons in other charts like you're doing here. Instead of returning to default, it returns to active. To avoid messes between hover, default, and active states, a new state "hoverActive" was introduced in beta.45.
If we change the state name/key to something else, we'll find the behavior is more expected, so refactoring "active" out of your code with some arbitrary key back in we get:
var customActiveState = "selectedCountry";
var selectedPolygon;
polygonTemplate.events.on("hit", function(ev) {
/* NEW: Create an active state and set fill color to red */
let polygon = ev.target;
if(selectedPolygon) {
selectedPolygon.defaultState.properties.fill = am4core.color("#74B266");
selectedPolygon.setState('default');
}
polygon.setState(customActiveState);
selectedPolygon = polygon;
})
/* Create hover state and set alternative fill color */
var hs = polygonTemplate.states.create("hover");
hs.properties.fill = am4core.color("#367B25");
/* Create active state and set fill different fill color */
var as = polygonTemplate.states.create(customActiveState);
as.properties.fill = am4core.color("#FF0000");
Example: https://codepen.io/team/amcharts/pen/477e8a80e09b4bf87128cd72cc082741
But that's not very useful as we lose the red color as soon as we hover out.
So there're some routes we can take, simpler method is how to make use of the reserved active state and get it to work for you, or just manage the defaultState almost just as you've been doing.
Method 1 - Making use of the togglable and isActive properties of Sprite (which MapPolygons extend).
Once a sprite is togglable, clicking it toggles the active state automatically, so we leave that logic out of the hit event, and just ensure a previously toggled country is detoggled for sure:
var selectedPolygon;
polygonTemplate.events.on("hit", function(ev) {
/* NEW: Create an active state and set fill color to red */
let polygon = ev.target;
if(selectedPolygon && selectedPolygon !== polygon) {
selectedPolygon.isActive = false;
}
selectedPolygon = polygon;
})
/* Create hover state and set alternative fill color */
var hs = polygonTemplate.states.create("hover");
hs.properties.fill = am4core.color("#367B25");
/* Create active state and set fill different fill color */
var as = polygonTemplate.states.create("active");
as.properties.fill = am4core.color("#FF0000");
Example: https://codepen.io/notacouch/pen/259c803601ff6f286a294d1477f022ba
Method 2 - Omit the whole custom active state, take the code you already have, and override both the newly-selected polygon's current and its default state's fills (we have to override the current fill, because if you just override the defaultState's fill, you have to wait til you hover out to see it):
var selectedPolygon;
polygonTemplate.events.on("hit", function(ev) {
/* NEW: Create an active state and set fill color to red */
let polygon = ev.target;
if(selectedPolygon) {
selectedPolygon.defaultState.properties.fill = am4core.color("#74B266");
selectedPolygon.setState('default');
}
polygon.defaultState.properties.fill = polygon.fill = am4core.color("#FF0000");
selectedPolygon = polygon;
})
/* Create hover state and set alternative fill color */
var hs = polygonTemplate.states.create("hover");
hs.properties.fill = am4core.color("#367B25");
Example: https://codepen.io/team/amcharts/pen/67121e27c3c1d50d669bca0ed040f746

JavaFX Auto Resizing Group

I have a quite complex scene graph which has led me to some resizing problems. I'd be glad if you could help me solve it.
My root node is a BorderPane that its center is filled with a ListView. Each cell of the ListView is filled with a customized zoomable ScrollPane as below:
public class ZoomableScrollPane extends ScrollPane {
Group zoomGroup;
Scale scaleTransform;
LineChart<Number , Number> content;
double scaleValue = 1.0;
double delta = 0.1;
public ZoomableScrollPane(LineChart<Number , Number> content, double height) {
this.content = content;
this.setPrefHeight(height);
Group contentGroup = new Group();
zoomGroup = new Group();
contentGroup.getChildren().add(zoomGroup);
zoomGroup.getChildren().add(content);
setContent(contentGroup);
scaleTransform = new Scale(scaleValue, scaleValue, 0, 0);
zoomGroup.getTransforms().add(scaleTransform);
}
}
As you can see there is a LineChart inside of each ZoomableScrollPane. I want to do two things with this chart. Firstly, to somehow bind its width with the root layout to get the desired result in case of resizing the window (not zooming, zooming is OK), and secondly to change the chart's width at run time whenever a button is pressed:
public void handleButton(ActionEvent actionEvent) {
MainController.lineChart1.setPrefWidth(MainController.lineChart1.getPrefWidth() + CONSTANT);
}
The problem is that here I face a conflict. Cause the LineChart is the child of a Group (not a pane), I just know one way of resizability and that is to bind its width manually with the root BorderPane's like this:
MainController.lineChart1.prefWidthProperty().bind(fourChannels.widthProperty().subtract(40));
And in that case, I cannot change the LineChart's width at run time and will get A bound value cannot be set Exception.
I guess one solution could be revising the ZoomableScrollPane class to somehow avoid the need of manual binding, but really have no idea how to do it.
Any help on this would be greatly appreciated.
You can detect if a property is bound and then unbind it before manipulating it:
if (content.prefWidthProperty().isBound()) {
content.prefWidthProperty().unbind();
}
...
Presumably when you are zoomed in on a chart and the window is resized the content will already be larger than the viewport, so a forced change in width shouldn't kick in until the window is resized beyond the zoomed in size of the chart?
Given the different conditions you have you might be better off monitoring the size of the BorderPane/ListView and when that changes adjust the size of the charts that need it.

Laying out images on the screens

I'm trying to display image files for the android layout of each screen.
I tried displaying the base menu picture file and image 2 and add them both into the screen. However, I seem to capture the base menu but not the 2nd image.
My function for getting the images, under class name "MyResource'
public function getImage(name:String):Image{
var img:Image = new Image(assetManager.getTexture(name));
return img;
}
My 'main menu' class. It has a bunch of buttons that will redirect it to selected the selected class containing the screens.
switch (btn.name)
{
case "genji":
trace("Genji voice menu was selected.");
app.getScreenManager().getScreen(ScreenManager.SCREEN_GENJI);
break;
}
The screen class that's supposed to display the 2nd image.
public class GenjiScreenClass extends Screens
{
public function GenjiScreenClass(app:StarlingBaseClass)
{
super(app);
}
override public function initialize():void{
trace("I am in GenjiScreenClass initialize() function");
var img:Image = myResource.getImage("basemenu320x480");
var genjiImage:Image = myResource.getImage("GenjiMenuPicture")
this.addChild(genjiImage);
this.addChild(img);
}
}
The image files are all under asset/x1. The base menu image came out but how come the 2nd one didn't?
You add img last:
this.addChild(genjiImage);
this.addChild(img);
This means img is on top of genjiImage covering it up. Depending on the content and size of the images the above one might entirely hide the below one, which can lead to the impression that only the top one is being displayed.
Swap the order of these two statements to solve the problem.

Show different slider for different selections in dat.gui

I have a gui where the use can select different shapes to render with a dropdown. This works well. Now I wanna display a folder with some slider. The count, name and min/max values of the sliders differ in which shape is selected. How can I accomplish this with dat.gui.
Ok found a solution by adding this to the dat.GUI prototype:
dat.GUI.prototype.removeFolder = function(name) {
var folder = this.__folders[name];
if (!folder) {
return;
}
folder.close();
this.__ul.removeChild(folder.domElement.parentNode);
delete this.__folders[name];
this.onResize();
}

SWT: paint on parts of a given composite control like Table-headers or the button of a Combo

The title is pretty self-explanatory, i'm currently adding PaintListeners to all the children, grand-children and so on, of the control i'd like to paint on. I have graphical errors with Tables and Combos at the moment, the PaintListener apparently doesn't apply to the header or the button in the combo.
How can i do this?
This is the code i use to add the listeners:
List<Control> controls = Lists.newArrayList();
controls.add(composite);
while (! controls.isEmpty()) {
Control c = controls.remove(0);
if (c instanceof Composite) {
controls.addAll(Arrays.asList(((Composite) c).getChildren()));
}
c.addPaintListener(new ControlPaintListener());
}

Resources