I am making a GTK# application and I have some weird behavior with TextView (or perhaps ScrolledWindow, can't really tell):
It's basically copying whatever's behind it and using it as the background, when the background should be a solid color. When I switch tabs, it even displays what was in the previously selected tab.
How do I fix this behavior?
Well, I didn't like that I had to do it this way, but it works:
// Fix the weird display bug
drawnHandler = new DrawnHandler((o, args) =>
{
this.Drawn -= drawnHandler;
var color = ConsoleBox.StyleContext.GetBackgroundColor(StateFlags.Normal);
ConsoleBox.OverrideBackgroundColor(StateFlags.Normal, new Gdk.RGBA()
{
Red = color.Red,
Green = color.Green,
Blue = color.Blue,
Alpha = 1
});
});
this.Drawn += drawnHandler;
This gets the proper background color and sets it without alpha (which I'm not even sure how the alpha was set in the first place since I never changed the background color anywhere in the code).
Related
I am creating an application for a new RPG that I am creating. The application has a specific theme and I want to change the checkboxes and buttons to black and the cyan color I chose. On loading the form I use the following code to change the color of the boxes.
coloredCheckBoxes.Add(checkBox1);
coloredCheckBoxes.Add(checkBox2);
foreach (CheckBox checkBox in coloredCheckBoxes)
{
checkBox.FlatStyle = FlatStyle.Flat;
checkBox.FlatAppearance.BorderSize = 1;
checkBox.FlatAppearance.BorderColor = Color.FromArgb(0, 211, 211);
checkBox.FlatAppearance.CheckedBackColor = Color.Black;
checkBox.FlatAppearance.MouseOverBackColor = Color.Black;
checkBox.FlatAppearance.CheckedBackColor = Color.Black;
checkBox.BackColor = Color.Black;
}
No matter how many colors I change the back color of the check boxes still remain this weird grey color.
The check boxes also become lighter if I move my cursor over the boxes as if checkBox.FlatAppearance.MouseOverBackColor = Color.Black; was not used. Is there a way to fix this issue hopefuly without creating a custom checkbox class?
I understand what you need finally.(I remove any old answer)
Try this,
- MetroFramework UI - Original by Peter.
- MetroFramework UI - Forked, dennismagno(Recommand).
- MetroFramework UI - Forked, thielj.
Also provided source code, so you can modify it.
I don't know much about C# and Unity. I just follow the script in Vuforia's Unity Cloud Recognition tutorial, which creates the GUI Box programmatically. So I guess all the stying solutions using the Unity Inspector are not working for me.
My current GUI.Box style
Texture2D texture = new Texture2D(1, 1);
texture.SetPixel(0,0,Color.white);
texture.Apply();
GUIStyle myBoxStyle2 = new GUIStyle(GUI.skin.box);
myBoxStyle2.fontSize = 40;
myBoxStyle2.normal.background = texture;
myBoxStyle2.normal.textColor = Color.black;
myBoxStyle2.alignment = TextAnchor.MiddleLeft;
GUI.Box (new Rect(Screen.width/4,Screen.height/6,Screen.width/2,Screen.height/8), mTargetMetadata, myBoxStyle2);
And it looks like this (the white box)
I checked the GUI Style Manual, not helped.
The rounded corners are actually the default style for GUI.Box.
Internally afaik by default it simply uses the UISprite as texture. In order to use it as well on your MonoBehaviour component you could have a
public Texture2D boxTexture;
and reference the UISprite in it in order to use it for your style.
However it sounds like actually your question seems to be rather
How to change the color of GUI.Box?
So using GUI you could directly change the color using
// store current values before changing
var color = GUI.color;
var contentColor = GUI.contentColor;
// change GUI colors
GUI.color = Color.white;
GUI.contentColor = Color.black;
{
// draw Box with default style
GUI.Box (new Rect(Screen.width/4,Screen.height/6,Screen.width/2,Screen.height/8), mTargetMetadata);
}
// reset GUI colors to former stored values
GUI.color = color;
GUI.contentColor = contentColor;
either this should already fix it or you could try doing the same but using GUI.backgroundColor instead of GUI.color. And just to make the list complete: The text color you can change doing the same thing with GUI.contentColor.
However in general ... I would say Vuforia gave you a very bad option there. Using GUI was actually the way to go way back until Unity 4.5. (so more or less 2015).
It is still in use but actually alsmost only for Building Custom Inspectors and other editor scripting.
Nowadays as mentioned in the comments you should rather use the "New" UI System introduced in Unity 4.6.
I have searched, and tried answers. I have the code, but I'm unsure why it isn't working. I am trying to change the backcolor of the form from green back to white. I believe I have it correct, but it doesn't show the first color, only the last.
if (PassBox1.Text == PassBox2.Text)
{
this.BackColor = Color.FromArgb(0, 255, 0);
// voice.Speak("Correct ", SpeechVoiceSpeakFlags.SVSFDefault);
this.BackColor = Color.FromArgb(192,192,192);
}
When this code runs and backcolor is set to (0,255,0) which is followed by a blocking operation voice.speak, this does not give chance to the ui to refresh and soon as voice speak is done, the backcolor changes to (192...) before ui gets changes to show the other color.
in this case you would be much happier if you created a subclassed text box which allows you to flash colors. you can use some ideas from this post
https://stackoverflow.com/a/4147406/2903863
I am writing a WP8 app that overrides the color theme on the phone to always be white. Now before people discredit me for this decision, the app itself is supposed to be a messenger like application and the white background simply makes everything easier to read. In the future I do want to allow people to be able to choose between black or white in case battery life is important but I need to get over this hurdle first.
Currently the problem is that even after overriding the theme colors the color BEHIND the application bar still refuses to change. I'm not talking about the background color of the application bar but the rectangle drawn behind the application bar as it is animated to pop upwards from the bottom of the screen. It is very visible and it is quiet annoying even if it only appears for about a second.
I know there must be a way to do this as applications like Office, Google Mail and Skype all override the color theme and implement the white theme instead and they do not have this same problem.
If anyone could help that would be great!
I've found a solution but it's not a very nice one. If anyone finds a better solution please let me know.
I solved this problem by setting the application bar opacity to be near 1 but not 1 (I set it to 0.99). This will tell windows to not rescale the window (which is the cause of the black background).
I then set the bottom margin of that page to be the height of the application bar.
Here's the code for anyone interested:
private void panoramaMain_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Panorama p = (Panorama) sender;
if(p.SelectedIndex == 1) {
messageList.Margin = new Thickness(0, 0, 0, ApplicationBar.DefaultSize);
ApplicationBar.IsVisible = true;
} else {
messageList.Margin = new Thickness(0, 0, 0, 0);
ApplicationBar.IsVisible = false;
}
}
Is it possible to change the background color (white by default) of a zedgraph pane?
I tried changing the background color of the zedgraph element, but it doesn't give any visible result, background is still white:
ZedGraphControl.BackColor = System.Drawing.Color.Black;
And there doesn't seem to exist a Color or BackColor property on ZedGraphControl.GraphPane.
myChart.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black;
You can use
zg.GraphPane.Chart.Fill.Color = SystemColors.ControlText;
to change the background [only] of the chart.
If you want to change the background color the zedgraph except the chart, use
zg.GraphPane.Fill.Color = SystemColors.ControlText;
If you want to change the background color of everything in the zedgraph, use both:
zg.GraphPane.Chart.Fill.Color = SystemColors.ControlText;
zg.GraphPane.Fill.Color = SystemColors.ControlText;
EDIT: I know that you already solved your problem but I made this so if someone searches it, he can solve his problem quickly :)
myChart.GraphPane.Fill.Color = System.Drawing.Color.Black; will create a gradient fill started with black color. If you don't want to use gradient you should use -
myChart.GraphPane.Chart.Fill.Brush = new System.Drawing.SolidBrush(Color.Black);
Hope this will solve your problem.