Exemplo n.º 1
0
        public void CreateCameraWindow(Camera camera)
        {
            var viewModel = new CameraWindowViewModel();
            var presenter = new CameraWindowPresenter(viewModel, camera);

            var view = new CameraWindow();

            view.DataContext = viewModel;
            view.Show();
        }
Exemplo n.º 2
0
 void videoControl_FlashCallback(YoYoStudio.Controls.Winform.FlexCallbackCommand cmd, List <string> args)
 {
     switch (cmd)
     {
     case YoYoStudio.Controls.Winform.FlexCallbackCommand.LoadComplete:
         var cameras = videoControl.CallFlash(YoYoStudio.Controls.Winform.FlexCommand.GetCameras).ToList();
         CameraWindowViewModel cvm = videoControl.DataContext as CameraWindowViewModel;
         if (cvm != null)
         {
             cvm.Cameras = new System.Collections.ObjectModel.ObservableCollection <string>(cameras);
         }
         break;
     }
 }
        public JsonResult PostPicture(CameraWindowViewModel formModel)
        {
            try
            {
                var postedData = this.Request["image"];
                if (string.IsNullOrEmpty(postedData))
                {
                    throw new Exception("Could not find the uploaded image");
                }

                var data        = postedData.Substring(22);
                var bytes       = Convert.FromBase64String(data);
                var bytesStream = new MemoryStream(bytes);
                bytesStream.Seek(0, SeekOrigin.Begin);

                var tempFileName = Guid.NewGuid().ToString().ToLower();

                var storageManager = new WindowsAzureBlobStorageManager();
                storageManager.UploadFileToStorage(bytesStream, Constants.AZURE_STORAGE_TEMP_FILES_CONTAINER_NAME, tempFileName);

                return(this.Json(
                           new
                {
                    success = true,
                    fileName = tempFileName,
                    containerName = Constants.AZURE_STORAGE_TEMP_FILES_CONTAINER_NAME
                }));
            }
            catch (Exception ex)
            {
                return(this.Json(
                           new
                {
                    success = false,
                    message = ex.Message
                }));
            }
        }
        public JsonResult PostPicture(CameraWindowViewModel formModel)
        {
            try
            {
                var postedData = this.Request["image"];
                if (string.IsNullOrEmpty(postedData))
                    throw new Exception("Could not find the uploaded image");

                var data = postedData.Substring(22);
                var bytes = Convert.FromBase64String(data);
                var bytesStream = new MemoryStream(bytes);
                bytesStream.Seek(0, SeekOrigin.Begin);

                var tempFileName = Guid.NewGuid().ToString().ToLower();

                var storageManager = new WindowsAzureBlobStorageManager();
                storageManager.UploadFileToStorage(bytesStream, Constants.AZURE_STORAGE_TEMP_FILES_CONTAINER_NAME, tempFileName);

                return this.Json(
                    new
                        {
                            success = true,
                            fileName = tempFileName,
                            containerName = Constants.AZURE_STORAGE_TEMP_FILES_CONTAINER_NAME
                        });
            }
            catch (Exception ex)
            {
                return this.Json(
                    new
                        {
                            success = false,
                            message = ex.Message
                        });
            }
        }
        protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, ViewModel.ConfigurationWindowAction> message)
        {
            switch (message.Action)
            {
            case ConfigurationWindowAction.ConfigurationStateChanged:
                ConfigurationItemViewModel vm = message.Content as ConfigurationItemViewModel;
                if (vm != null)
                {
                    var cvm = DataContext as ConfigurationWindowViewModel;
                    cvm.CurrentConfigurationItemVM = vm;
                    VisualStateManager.GoToState(Configurations, vm.ConfigurationVM.Name, false);
                    if (vm.ConfigurationVM.Name == vm.ApplicationVM.ProfileVM.VideoConfigurationVM.Name)
                    {
                        if (videoControl == null)
                        {
                            var pv = Configurations.Template.FindName("PART_Video", Configurations) as ContentControl;
                            if (pv != null)
                            {
                                pv.ApplyTemplate();
                                videoControl = pv.Template.FindName("videoControl", pv) as VideoControl;
                                if (videoControl != null)
                                {
                                    videoControl.FlashCallback += videoControl_FlashCallback;
                                }
                            }
                        }
                    }
                }
                break;

            case ConfigurationWindowAction.CameraIndexChanged:
                if (videoControl != null)
                {
                    int index = (int)message.Content;
                    if (index > 0)
                    {
                        videoControl.CallFlash(YoYoStudio.Controls.Winform.FlexCommand.StartCamera, new string[] { (index - 1).ToString() });
                        videoControl.IsEnabled = true;
                    }
                    else
                    {
                        videoControl.CallFlash(YoYoStudio.Controls.Winform.FlexCommand.CloseCamera);
                        videoControl.IsEnabled = false;
                    }
                }
                break;

            case ConfigurationWindowAction.LocalPhotoSelect:
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = Text.PhotoType;
                if (dialog.ShowDialog() == true)
                {
                    var currentVm = ((ConfigurationWindowViewModel)DataContext).CurrentConfigurationItemVM.ConfigurationVM as PhotoSelectorViewModel;
                    if (currentVm != null)
                    {
                        currentVm.PhotoSource = Utility.CreateBitmapSourceFromFile(dialog.FileName);
                    }
                }
                break;

            case ConfigurationWindowAction.CameraPhotoSelect:
                CameraWindowViewModel cameraVM = new CameraWindowViewModel();
                cameraVM.Initialize();
                CameraWindow cameraWindow = new CameraWindow(cameraVM);
                cameraWindow.Show();
                break;

            case ConfigurationWindowAction.StartScreenCapture:
                screenCapture.StartCaputre(30, new Size(Owner.ActualWidth, Owner.ActualHeight));
                break;

            case ConfigurationWindowAction.PasswordInvalid:
                MessageBox.Show(Text.PasswordInvalid, Text.Error, MessageBoxButton.OK);
                break;

            case ConfigurationWindowAction.VideoRefresh:
                string[] cams = videoControl.CallFlash(YoYoStudio.Controls.Winform.FlexCommand.GetCameras);
                if (cams != null && cams.Length > 0)
                {
                    VideoConfigurationViewModel cvm = videoControl.DataContext as VideoConfigurationViewModel;
                    if (cvm != null)
                    {
                        cvm.Cameras.Clear();
                        cams.Foreach(c => cvm.Cameras.Add(c));
                    }
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 6
0
 public CameraWindow(CameraWindowViewModel vm) : base(vm)
 {
     InitializeComponent();
     MinimizeButtonState = YoYoStudio.Controls.CustomWindow.WindowButtonState.Disabled;
     MaximizeButtonState = YoYoStudio.Controls.CustomWindow.WindowButtonState.Disabled;
 }