like below that we get color , I Want set the Cursor property of Button
Color red = Color.FromName("Red");
button1.BackColor = red;
may be something like this:
String x = "Hand"
button1.Cursor = Cursor.FromName(x);
Here is simple example:
https://stackoverflow.com/a/37101840/6306993
CursorConverter cConverter = new CursorConverter();
Cursor c = (Cursor) cConverter.ConvertFromString("Hand");
this.button1.Cursor = c;
as my understanding, you are looking for how to set Cursor for button depend in existing variable. Please see the example below:
Cursor x = Cursors.Hand;
button1.Cursor = x;
if you still get error please check again "Cursors" not "Cursor" in the first line.
Looks like you are looking for CursorConverter.
Here is simple example:
CursorConverter cConverter = new CursorConverter();
Cursor c = (Cursor) cConverter.ConvertFromString("Hand");
this.button1.Cursor = c;
More information:
https://msdn.microsoft.com/en-us/library/system.windows.forms.cursorconverter(v=vs.110).aspx
Related
I have a syncfusion chart in my winform application.
I add a series of data.
I want to highlight a specific point of the series (let's say the 25th data point of the first series) with a red circle and the "Focus" text.
ChartCustomPoint cp = new ChartCustomPoint();
cp.CustomType = ChartCustomPointType.PointFollow;
cp.PointIndex=25;
cp.SeriesIndex=1;
cp.Symbol.Shape = ChartSymbolShape.Circle;
cp.Symbol.Color = Color.Red;
cp.Symbol.Marker.LineInfo.Width = 4;
cp.Alignment = ChartTextOrientation.Up;
cp.Text = "Focus";
chartControl1.CustomPoints.Add(cp);
but, the displayed text is stuck to the symbol. I would like to add space between the label and the symbol.
Is there a property I missed ?
Thank you
Thanks for using Syncfusion Products.
We have analyzed your query. While using the Custom Points the space between the text and the symbol can be provided by using the Alignment property of the Custom points.
The alignment property is used to align the text in the center, top, topleft , topright ,left ,right ,bottom ,bottomleft ,bottomright and when the symbol is present the RegionUp, RegionDown, RegionCenter will consider the symbol and the align the text accordingly.
When the RegionUp is set to the alignment the space is provided between the symbol and the text
ChartCustomPoint cp1 = new ChartCustomPoint();
// Point that follows a series point:
cp1.PointIndex = 2;
cp1.SeriesIndex = 0;
cp1.CustomType = ChartCustomPointType.PointFollow;
cp1.Symbol.Shape = ChartSymbolShape.Circle;
cp1.Offset = 20;
cp1.Font.Facename = "Times New Roman";
cp1.Font.Bold = true;
cp1.Font.Size = 11f;
cp1.Symbol.Color = Color.FromArgb(0Xc1, 0X39, 0x2b);
// Provide space between the symbol and the text
cp1.Alignment = ChartTextOrientation.RegionUp;
cp1.Text = "Circle";
cp1.Symbol.Marker.LineInfo.Width = 4;
chart.CustomPoints.Add(cp1);
We have attached the sample for your reference.
Sample link:http://www.syncfusion.com/downloads/support/directtrac/general/ze/Custom_points-2112217385
Please let us know if you have any concerns.
Regards,
Deepaa.
im trying implement health to my player using unity new UI Image system.but its not working.can anyone help me.Thank you.
using UnityEngine.UI;
if (health_value == 3) {
GameObject.Find("health").GetComponent<Image>().color.a = 1;
GameObject.Find("health1").GetComponent<Image>().color.a = 1;
GameObject.Find("health2").GetComponent<Image>().color.a = 1;
}
im getting this error.
error CS1612: Cannot modify a value type return value of `UnityEngine.UI.Graphic.color'. Consider storing the value in a temporary variable
Because the Color is a struct of Image (I think that's the correct terminology? please correct me if I'm wrong), you can't edit its color directly, you have to create a new Color var, change its vars, and then assign it to Image.
Image healthImage = GameObject.Find("health").GetComponent<Image>();
Color newColor = healthImage.color;
newColor.a = 1;
healthImage.color = newColor;
I had the same issue, but because of different reason. So this might help for someone else if the accepted answer was not their issue.
Please note that Unity expects color values in 0-1 range in script.
So if you are applying red color, make sure you are using it like
gameObject.GetComponent<Image>().color = new Color(1f, 0f, 0f);
instead of
gameObject.GetComponent<Image>().color = new Color(255, 0, 0); // this won't change the image color
Or,
Image healthImage = GameObject.Find("health").GetComponent<Image>();
healthImage.color = Color.red;
if (health_value == 3)
{
GameObject playerHealthImage = GameObject.Find("health").GetComponent<Image>();
Color healthColor = playerHealthImage.color;
healthColor.a=1;
//Or red,Green,Blue,Alpha
healthColor = new Color(1,1,1,1);
playerHealthImage.color = healthColor;
}
You cannot modify Colors RGBA values independently because it's a structure.how ever you can directly assign Color based on above.
GameObject imageGameObject;
// 1.0 - 0.0
float r;
float g;
float b;
float a;
imageGameObject.GetComponent<Image>().color = new Color(r, g, b, a);
// 255-0
int r32;
int g32;
int b32;
int a32;
imageGameObject.GetComponent<Image>().color = new Color32(r32, g32, b32, a32);
This is an incredibly localized problem but I've spent a while on it now and just can't get the formatting to work. Basically what I want to do is show a column chart for a value but no bells and whistles (i.e. no labeling, no title, no legend, nothing!) And I want it to look like this:
But instead it looks like this:
The axis extends out and to the right and I can't figure out how to make it go away. Here is my code:
charts[i].Series.Clear();
charts[i].Series.Add("Block " + i + 1);
charts[i].Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
charts[i].Series[0].Points.Add(liveData[i]);
charts[i].ChartAreas[0].AxisY.Maximum = 4;
charts[i].ChartAreas[0].AxisY.Minimum = 0;
charts[i].ChartAreas[0].AxisX.Maximum = 1;
charts[i].ChartAreas[0].AxisX.Minimum = 1;
charts[i].ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
charts[i].ChartAreas[0].AxisY.MajorGrid.LineWidth = 0;
charts[i].ChartAreas[0].AxisX.LabelStyle.Enabled = false;
charts[i].ChartAreas[0].AxisY.LabelStyle.Enabled = false;
charts[i].ChartAreas[0].AxisY.LineWidth = 0;
charts[i].ChartAreas[0].AxisY.MajorTickMark.Enabled = false;
charts[i].ChartAreas[0].AxisX.MajorTickMark.Enabled = false;
charts[i].Series[0].IsVisibleInLegend = false;
Now I am guessing this is a min/max thing but for the life of me I just can't get it to work. Can someone see my mistake? Or suggest another method besides charts?
Also note the 'Block 1 (V)' label you see underneath is not generated by the chart, it is a textbox label that just happened to get cut into the screenshot.
Thanks!
Your data has the x-value of 1. By default the bar is centered on the 1 mark. by shifting the limits you are actually only seeing half of it. Two things to do: Tell the bar exactly how wide it shall be and limit the x-axes accordingly.
charts[i].Series[0].CustomProperties = "PointWidth = 1"; // One bar takes a width of 1 unit on the x-axis
charts[i].ChartAreas[0].AxisX.Minimum = 0.5; // change!
charts[i].ChartAreas[0].AxisX.Maximum = 1.5; // change!
i have this Enum
public enum Icon
{
Question = 1,
Hand = 2,
Exclamation = 3,
None = 4
}
i have 4 PictureBox on my Form named
P1 , P2 , P3 and P4
if i have Icon G
how i can show any PictureBox like this:
Instead of P2.visible = true i'll write G.Hand = True
thanks in advance
I think there's no need for four PictureBox controls, you just need to have one and select an image base on your enum like the following:
// Assuming you have a dictionary of icons pathes
Dictionary<Icon,string> icons = new Dictionary<Icon,string>();
icons[Icon.Question] = "..\imgQuestion.png" \\ path of question image";
icons[Icon.Hand] =
icons[Icon.Exclamation] =
pictureBoxControl.Image = icons[G.Hand];
Good luck!
Hy my example code:
Bold b = new Bold(new Run("TODO"));
b.FontSize = 50;
My Question is:
How to center the bold element?
I assume this is in reference to classes in System.Windows.Documents. You need to set the TextAlignment property on the thing (a Paragraph usually) that b is contained in.
The paragraph around the Run should define the alignment.
Bold b = new Bold(new Run("TODO"));
b.FontSize = 50;
var p = new Paragraph(b) {TextAlignment = TextAlignment.Center};