Hello!
I am currently updating some old Windows Forms code to WPF, since the deprication of Forms in the 2024 R1 release.
In my ViewItemPlugin class i am using the GenerateViewItemManager to generate a ViewItemManager
Then, using the ViewItemManager, I am generating a ViewItemWpfUserControl using the GenerateViewItemWpfUserControl, and then doing my logic in the Control class.
class PrimaryCameraViewItemPlugin : ViewItemPlugin
{
// ...
public override ViewItemManager GenerateViewItemManager()
{
return new PrimaryCameraViewItemWpfManager(aLog);
}
}
public class PrimaryCameraViewItemWpfManager : ViewItemManager
{
// ...
public override ViewItemWpfUserControl GenerateViewItemWpfUserControl()
{
return new PrimaryCameraViewItemWpfUserControl(aLog);
}
}
In my control class, I wish to control the video of a camera/stream.
From what I understand from the documentation, I “just” need to set the controller stream and camera id, which i do by the following
public partial class PrimaryCameraViewItemWpfUserControl : ViewItemWpfUserControl
{
// ...
private ImageViewerWpfControlInternal aController;
// ...
public override void Init()
{
aController = ClientControl.Instance.CreateImageViewerWpfControlInternal(WindowInformation);
aController.CameraFQID = new FQID();
aController.Initialize();
aController.Connect();
// ...
}
public override void Close()
{
// ...
aController.Disconnect();
aController.Close();
}
// ...
private void UpdateCamera(Message message, FQID newCam)
{
aLog.Debug("New FQID received! Updating view camera and stream...");
aController.Disconnect();
aController.CameraFQID = newCam;
aController.StreamId = new BackgroundPluginUtils(aLog).GetCameraStream(aController.CameraFQID?.ObjectId.ToString());
aController.UpdateLayout();
aLog.Debug("Controller updated");
// ...
try
{
aLog.Debug("Initializing new camera...");
aController.Initialize();
aController.Connect();
aLog.Debug("New camera connected!");
}
catch (Exception e)
{
aLog.Error("Error initializing and connecting: " + e.Message);
aLog.Error(e.StackTrace);
}
}
// ...
}
When debugging the code, I am getting the correct IDs from the Milestone server, and the IDs are set correctly in the control class.
I feel like there might be some event I need to fire, to tell the view to “recompile” or something, but I am having a hard time finding anything in the documentation on it…
For the sake of company security, I cannot show the full code, but the relevant code should be given in this post.
I am getting the view generated on start, but I am unable to display anything in it.
Any help is appreciated!