public async void Open() { if (Session.HasSourceOpen(IPCamLink.Text)) { var dlg = new ModernDialog { Title = "IP link already open", Content = "IP link provided is already open. Please provide new ip link.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if (!PingHost(IPCamLink.Text)) { var dlg = new ModernDialog { Title = "IP link error", Content = "IP link provided does not exist. Please select valid ip cam link.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if ((OutputResult.IsChecked ?? false) && !Directory.Exists(Path.GetFullPath(OutputFilename.Text))) { var dlg = new ModernDialog { Title = "File output is empty", Content = "Please input the file output.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else { Datastore.GeneralSetValue("ip_cam_last", IPCamLink.Text); var session = await Session.Start(IPCamLink.Text, Path.GetFileName(IPCamLink.Text.Replace("//", ".")), (OutputResult.IsChecked ?? false)?OutputFilename.Text : null); var window = new InstanceWindow(session); window.Show(); } }
public async void Open() { var selected = (CameraObject)cameraList.SelectedItem; if (selected == null) { var dlg = new ModernDialog { Title = "None selected", Content = "Please select a USB camera", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if (Session.HasSourceOpen(selected.Name)) { var dlg = new ModernDialog { Title = "USB Cam already open", Content = "USB Cam is already open. Please choose new USB Cam to open.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if ((OutputResult.IsChecked ?? false) && !Directory.Exists(Path.GetFullPath(OutputFilename.Text))) { var dlg = new ModernDialog { Title = "File output is empty", Content = "Please input the file output.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else { Datastore.GeneralSetValue("usb_cam_last", selected.Name); var session = await Session.Start(selected, selected.Name, (OutputResult.IsChecked ?? false)?OutputFilename.Text : null); var window = new InstanceWindow(session); window.Show(); } }
public async void Open() { if (Session.HasSourceOpen(Filename.Text)) { var dlg = new ModernDialog { Title = "File already open", Content = "File provided is already open. Please choose new file to open.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if (!File.Exists(Filename.Text)) { var dlg = new ModernDialog { Title = "File error", Content = "File does not exist. Please select valid and existing file.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else if ((OutputResult.IsChecked ?? false) && !Directory.GetParent(OutputFilename.Text).Exists) { var dlg = new ModernDialog { Title = "File output is invalid", Content = "Please input the valid file output.", }; var okButton = dlg.OkButton; okButton.Content = "Ok"; dlg.Buttons = new Button[] { okButton }; dlg.MinWidth = 400; dlg.MinHeight = 0; dlg.SizeChanged += (s, e) => { double screenWidth = SystemParameters.PrimaryScreenWidth; double screenHeight = SystemParameters.PrimaryScreenHeight; double windowWidth = e.NewSize.Width; double windowHeight = e.NewSize.Height; dlg.Left = (screenWidth / 2) - (windowWidth / 2); dlg.Top = (screenHeight / 2) - (windowHeight / 2); }; dlg.ShowDialog(); } else { Datastore.GeneralSetValue("video_file_last", Filename.Text); var session = await Session.Start(Filename.Text, Path.GetFileName(Filename.Text), (OutputResult.IsChecked ?? false)?OutputFilename.Text : null); var window = new InstanceWindow(session); window.Show(); } }