Program.cs
namespace SimpleVideoViewer
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
VideoOS.Platform.SDK.Environment.Initialize(); // General initialize. Always required
VideoOS.Platform.SDK.UI.Environment.Initialize(); // Initialize ActiveX references, e.g. usage of ImageViewerActiveX etc
VideoOS.Platform.SDK.Export.Environment.Initialize(); // Initialize export references
DialogLoginForm loginForm = new DialogLoginForm(SetLoginResult);
//loginForm.LoginLogoImage = MyOwnImage; // Set own header image
Application.Run(loginForm); // Show and complete the form and login to server
if (Connected)
{
Application.Run(new MainForm());
}
}
private static bool Connected = false;
private static void SetLoginResult(bool connected)
{
Connected = connected;
}
}
}
mainForm.cs
namespace SimpleVideoViewer
{
public partial class MainForm : Form
{
private ImageViewerControl imageViewerControl;
private Item selectedItem;
public MainForm()
{
InitializeComponent();
}
private void OnClose(object sender, EventArgs e)
{
VideoOS.Platform.SDK.Environment.RemoveAllServers();
Close();
}
private void button1_Click(object sender, EventArgs e)
{
// properly discard the previous camera control, if one is already selected
if (imageViewerControl != null)
{
imageViewerControl.Disconnect();
imageViewerControl.Close();
imageViewerControl.Dispose();
imageViewerControl = null;
}
ItemPickerForm picker = new ItemPickerForm();
picker.KindFilter = Kind.Camera;
picker.Init(Configuration.Instance.GetItems());
if (picker.ShowDialog() == DialogResult.OK)
{
selectedItem = picker.SelectedItem;
label2.Text = selectedItem.Name;
try
{
// image viewer control settings
imageViewerControl = ClientControl.Instance.GenerateImageViewerControl();
imageViewerControl.Dock = DockStyle.Fill;
panel1.Controls.Clear();
panel1.Controls.Add(imageViewerControl);
imageViewerControl.CameraFQID = selectedItem.FQID;
imageViewerControl.EnableDigitalZoom = true;
imageViewerControl.EnableVisibleHeader = false;
imageViewerControl.Initialize();
imageViewerControl.Connect();
// add an overlay after the stream has been established
var fontFamily = new System.Windows.Media.FontFamily("Open Sans Semibold");
var typeface = new System.Windows.Media.Typeface(fontFamily, System.Windows.FontStyles.Normal, System.Windows.FontWeights.Bold, new System.Windows.FontStretch());
var fText = new System.Windows.Media.FormattedText(selectedItem.Name, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, 25, System.Windows.Media.Brushes.White);
var path = new System.Windows.Shapes.Path() { Data = fText.BuildGeometry(new System.Windows.Point(20, 160)), Fill = System.Windows.Media.Brushes.White };
var id = imageViewerControl.ShapesOverlayAdd(new List<System.Windows.Shapes.Shape> { path }, new ShapesOverlayRenderParameters() { ZOrder = 100 });
}
catch (Exception ex)
{
MessageBox.Show("Exception: " + ex);
}
}
}
}
}
Я могу просмотреть список камер, который я установил в XProtect Management Client, но после выбора камеры видеопоток не отображается. В клиенте управления я могу просматривать видеопоток, но в консольном приложении, разработанном с использованием MIP SDK, я не могу просматривать видео с камеры.