Hello,
I'm coming here because i need your help.
So here the structure of my program :
Read joystick with DirectX on one computer.
Affect thoses values to my own object (implement INotifyPropertyChanged) on an static classe (objects in this static class are used everywhere on project)
Refresh the GUI with my object values, using databinding - datacontext (Works great)
Send this object via UDP to another computer (who reference my *.dll with my own object, same line 2 of this list) - using JsonSerializer.Serialize.
Receive my object on another computer, affect thoses values to my object on a static class again.
[TRY] Refresh my GUI on this computer with my received values. [DO NOT WORK]
how i receive values and affect to my object in my static class :
private static void ReceiveUDP()
{
try
{
UdpClient listener = new UdpClient(50002);
IPEndPoint groupEP = new IPEndPoint(VariablesGlobales.IpClient, 50002);
Task.Run(() =>
{
while(true)
{
byte[] byteArray = listener.Receive(ref groupEP);
VariablesGlobales.objClient = JsonSerializer.Deserialize<DataObjects.PelleDeminage.Client>(byteArray);
}
});
}
catch(Exception ex)
{
// TODO
}
}
How i use it as datacontext :
this.DataContext = new
{
client = VariablesGlobales.objClient,
};
And how i use databinding in xaml (DevExpress component support value databing, same control used in sender computer GUI):
<dxga:LinearScaleMarker x:Name="mrk_Godet" Value="{Binding client.Godet}" />
My object in my *.dll :
[Serializable]
public class Client : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public int Godet
{
get { return this.GodetValue; }
set
{
if (value != this.GodetValue)
{
this.GodetValue = value;
NotifyPropertyChanged();
}
}
}
/*rest of code*/
If i put an Debug.WriteLine with my value "client.Godet" the value is good, change verytime i move my joystick but my control are not refreshed.
Did you know how can use this object in my *.dll as datacontext in my receiver computer? I use extacly the same code for my sender and receiver computers, sender work great but receiver did not, it seems my PropertyChanged event are never called.
Thank you in advance.
Ludo.