Conditionally change backgroundcolor for captions in an ultragrid - ultrawingrid

I am using ultragrid 9.1. I am displaying the details as cardview. I can change the back color of the card caption by using the following property:
Ultragrid.DisplayLayout.Override.CardCaptionAppearance.BackColor = System.Drawing.Color.Red
However, I want to change the back color of the caption conditionally and not for all rows. I am unable to find the relevant property to set this.

My problem has been solved. There is no in built property that could be used to set the background color of the caption. I had to use the DrawFilter interface.
You can find more information about this interface from this link:
You should create a class that implements IUIElementDrawFilter.
In the GetPhasesToFilter method of the interface check if the element is CardCaptionUIElement and if it is return its BeforeDrawBackColor phase. Then in the DrawElement method you can draw the background using the DrawBackColor method of the drawParams argument.
Then, set the drawfilter for the ultragrid.
UltraGrid1.DrawFilter = New CustomDrawFilter()
Class CustomDrawFilter : Implements IUIElementDrawFilter
Public Function DrawElement(drawPhase As DrawPhase, ByRef drawParams As UIElementDrawParams) As Boolean Implements IUIElementDrawFilter.DrawElement
Dim row = DirectCast(drawParams.Element.GetContext(), UltraGridRow)
If (row.VisibleIndex Mod 2 = 0 And row.Selected = False) Then
drawParams.AppearanceData.BackColor = Color.Red
drawParams.DrawBackColor(drawParams.Element.RectInsideBorders)
Return True
End If
Return False
End Function
Public Function GetPhasesToFilter(ByRef drawParams As UIElementDrawParams) As DrawPhase Implements IUIElementDrawFilter.GetPhasesToFilter
If (TypeOf (drawParams.Element) Is CardCaptionUIElement) Then
Return DrawPhase.BeforeDrawBackColor
Else
Return DrawPhase.None
End If
End Function
End Class

Related

I need help i keep geting this unity error? Assets\ScoreTextScript.cs(10,10): error CS0426: The type name 'Text' does not exist in the type 'Text'

So this is my code. Im trying to make it so the coins collected add to the score in the UI.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScoreTextScript : MonoBehaviour
{
Text.Text
coinAmount;
//Use this for initialization
void Start ()
{
text = GetComponent<Text>();
}
//Update is called once per frame
void Update ()
{
text.Text = coinAmount;
}
}
The Text is the error but I don't know how to fix it.
I need help immediately
I think you don't understand how variables work in unity.
First you are declaring a Text.text called coinAmount
In Unity when you are declaring a variable you first have to set the access modifier.
The 2 main are: private and public.
private means your variable will only be accessible in the class you declared it.
public means you can access it from any other class if you make a reference to that script.
Then you need to put the type of your variable.
Here you used Text.text and that's not a type for a variable.
You can set to int, string, etc... If you want to use a Text component in unity do like this:
private Text coinAmount;
Since it's a private variable you can't drag it in the editor. If you want to be able to place a Text component by hand in the editor you can either do:
public Text coinAmount;
//or
[SerializeField] private Text coinAmount; //I'll let you search about SerializeField
In your Start method you are assigning text variable to the Text component this object hold. But text does not exist. If you declare a variable in a method it will only be accessible in this method.
So, what you want is:
private void Start(){
coinAmount = GetComponent<Text>();
}
And lastly i see you want to assign your text to the variable we created earlier. That's useless. You need to create a new variable of type int and assign it to the text value of coinAmount.
To do so:
We will create a new variable right under coinAmount.
public int coinNumber;
And in update we can use it:
private void Update(){
coinAmount.text = coinNumber.ToString(); //.ToString() is used when you want to convert something to a string (which is a type of variable).
}
And there we go everything should work correctly !
The whole code:
private Text coinAmount;
public int coinNumber;
private void Start(){
coinAmount = GetComponent<Text>();
}
private void Update(){
coinAmount.text = coinNumber.ToString(); //.ToString() is used when you want to convert something to a string (which is a type of variable).
}
Hope it helped ! Have a nice day !

TeeChart in VB.Net : Subclassing SeriesXYZPoint cannot assign X axis

I have a very simple class I'm using to subclass a SeriesXYZPoint in TeeChart vb.net
Imports Steema.TeeChart.Styles
Public Class CustomSeriesXYZPoint
Inherits SeriesXYZPoint
Public Sub New(X As Double, y As Double, z As Double, color As Color, flagged As Boolean)
MyBase.New()
Me.X = X
Me.Y = y
Me.Z = z
Me.Color = color
Me.flagged = flagged
End Sub
Public flagged As Boolean
End Class
When I try to assign to the X value at "Me.X = X" I get a nullReferenceException with no InnerException, even though I can see that "Me" is not null in the constructor (as you would hope...)
What I'm doing here should be really simple, and the error message I get is totally opaque. Any help would be awesome.
Edit: I get the same error when I run
Dim thing As New SeriesXYZPoint
thing.X = someValue
The SeriesXYZPoint class is not a series type designed to be drawn in a chart. It's a class internally used to extend series functionality like Custom3D and derived. It needs a series associated to access that X property:
public class SeriesXYPoint : SeriesPoint
//...
public double X
{
get
{
return series.XValues[index];
}
//...
}
}
Instead, you may want to extend Points3D series.

Xamarin - If exist base class for BindingProperty?

I have question:
If i have button and label - and I want to set style with setter BackgroundColorProperty = Color.Black. I tried to give to button in this way:
new Setter { Property = Label.BackgroundColorProperty, Value = Color.Black }
And Its work.
So question - if exist base class or something which I can to use in the way:
new Setter { Property = BASECLASS.BackgroundColorProperty, Value = Color.Black }
The base class of every visual element is VisualElement.
https://developer.xamarin.com/api/type/Xamarin.Forms.VisualElement/
If you use Resharper, it would tell you that you can use the base class in this case :)

How to retrieve strings from resource files for all the languages VB6

Is there a way to retrieve strings for all the languages available in a resource file? I just got a requirement for showing labels in 2 languages at the same time.
You've got two approaches if you want to use the standard VB6 resource files.
The first is to define each language version of the string by a range in the resource file. So say you had a class to wrap up the string like this:
'In Class clsLocalizedStrings
Public Enum StringIds
UserNameCaption = 1
PasswordCaption
OkayCaption
CancelCaption
End Enum
Public Enum LocaleIds
English = 1000
French = 2000
Spanish = 3000
End Enum
Private mLangId As LocaleIds
Public Property Get CurrentLanguge() As LocaleIds
CurrentLanguge = mLangId
End Property
Public Property Let CurrentLanguge(ByVal newVal As LocaleIds)
mLangId = newVal
End Property
Public Function GetLocalString(ByVal id As StringIds)
Dim lResStrId As Long
lResStrId = mLangId + id
GetLocalString = LoadResString(lResStrId)
End Function
You could then set the CurrentLanguge at will and fetch the string value.
The alternative way, where each language gets its own resource file, is to create an ActiveX dll project for each language. Each of these project would expose just a single class similar to the one above. Ideally, you have a default language to use as a base, and the other reference it to implement the class:
'In Class LocalizedStrings in Project DefaultResources (with its own English resource file)
Public Enum StringIds
UserNameCaption = 1
PasswordCaption
OkayCaption
CancelCaption
End Enum
Public Function GetLocalString(ByVal id As StringIds)
GetLocalString = LoadResString(id)
End Function
'In Class FrenchStrings in Project FrenchResources (with its own French resource file)
Implements DefaultResources
Public Function DefaultResources_GetLocalString(ByVal id As DefaultResources.StringIds)
DefaultResources_GetLocalString= LoadResString(id)
End Function
Then in your main application you reference these dlls and make them available in a class or module:
'In Class clsLocalization in main app project
Public Enum LocaleIds
English = 1
French = 2
Spanish = 3
End Enum
Private mLangId As LocaleIds
Private mResources() as DefaultResources
Private Sub Class_Initialize()
Redim mResources (1 to 3)
Set mResources(1) = DefaultResources.LocalizedStrings 'assumes english is default, easy to change though
Set mResources(2) = FrenchResources.FrechStrings
Set mResources(3) = SpanishResources.SpanishStrings
End Sub
Public Property Get CurrentLanguge() As LocaleIds
CurrentLanguge = mLangId
End Property
Public Property Let CurrentLanguge(ByVal newVal As LocaleIds)
mLangId = newVal
End Property
Public Function GetLocalString(ByVal id As StringIds)
GetLocalString = mResources(mLangId).GetLocalString(id)
End Function
Public Propert Get Langauge(ByVal langId As LocaleIds)
Return mResources(langId)
End Property
And this in a module:
Global Localization As clsLocalization
Thn you use it like this:
'show caption for current languge
MsgBox Localization.GetLocalString(StringIds.UserCaption)
'show caption for explicit languge
MsgBox Localization.Langauge(French).GetLocalString(StringIds.UserCaption)
MsgBox Localization.Langauge(Spanish).GetLocalString(StringIds.UserCaption)
Hope that helps!

Convert String into Class for TitleWindow

I don't know if this is possible, I am pulling the names for TitleWindows from my database as strings.
Then from my main application I have to launch the TitleWindow. So in my function I need to convert the name of the TitleWindow which is a String to a Class, because the PopUpManager accepts a Class. Below is my code.
When launching my application and trying to launch the TitleWindow I am getting the error:
Implicit coercion of a value of type String to an unrelated type Class.
I don't want to hard code the name of my popUp in the PopUpManager, that is why I am doing it like this. Any way to work around this?
public function getScreen(screenName:String):void
{
var screen_Name:Class = new Class();
screen_Name = screenName;
var popUpWindow:TitleWindow = PopUpManager.createPopUp(this, screen_Name, false) as TitleWindow;
PopUpManager.centerPopUp(popUpWindow);
}
I have had to do something very similar recently. Here is the function I wrote to do it:
//You have to provice the package signature
private var viewPackage:String = "org.bishop";
//In my case, event.type is the name of a class
var className: String = viewPackage + "." + event.type;
try{
var classRef:Class = getDefinitionByName(className) as Class;
viewNavigator.pushView(classRef);
}
catch(e:ViewError){
trace(e.message);
logger.debug(e.message);
}
Note: for the class to be created correctly, you will need to include both an import statement:
import org.bishop.Login;
and also declare a variable of the class in the code as follows:
Login;
otherwise the classes will not be available to be created.

Resources