Exemple #1
0
        public async Task <ConfigurationItemViewModel> GetConfigurationItem(int configurationId)
        {
            _sharedService.WriteLogs("GetConfigurationItem started by:" + _userSettings.UserName, true);

            try
            {
                var configuration = await _configurationRepository.GetByIdAsync(configurationId);

                Guard.Against.NullConfiguration(configurationId, configuration);

                var vm = new ConfigurationItemViewModel()
                {
                    Id           = configuration.Id,
                    FieldName    = configuration.FieldName,
                    FieldValue   = configuration.FieldValue,
                    CreatedDate  = configuration.CreatedDate,
                    CreatedBy    = configuration.CreatedBy,
                    ModifiedDate = configuration.ModifiedDate,
                    ModifiedBy   = configuration.ModifiedBy
                };

                return(vm);
            }
            catch (Exception ex)
            {
                _sharedService.WriteLogs("GetConfigurationItem failed:" + ex.Message, false);

                var vm = new ConfigurationItemViewModel();

                return(vm);
            }
        }
        public ConfigurationWindow(ConfigurationWindowViewModel vm) : base(vm)
        {
            BorderStyleKeyName = "ConfigurationWindowBorderStyle";
            InitializeComponent();
            MinHeight           = ActualHeight;//overide the MiniHeight set by window base
            MinimizeButtonState = YoYoStudio.Controls.CustomWindow.WindowButtonState.Disabled;
            MaximizeButtonState = YoYoStudio.Controls.CustomWindow.WindowButtonState.Disabled;

            screenCapture.ScreenCaputreCancelled += screenCapture_ScreenCaputreCancelled;
            screenCapture.ScreenCaputred         += screenCapture_ScreenCaputred;
            ActiveConfiguration = vm.CurrentConfigurationItemVM;
        }
Exemple #3
0
        public async Task UpdateConfigurationAsync(ConfigurationItemViewModel configuration)
        {
            _sharedService.WriteLogs("UpdateConfigurationAsync started by:" + _userSettings.UserName, true);

            try
            {
                var _configuration = await _configurationRepository.GetByIdAsync(configuration.Id);

                Guard.Against.NullConfiguration(configuration.Id, _configuration);

                _configuration.FieldValue   = configuration.FieldValue;
                _configuration.ModifiedDate = DateTime.Now;
                _configuration.ModifiedBy   = _userSettings.UserName;

                await _configurationRepository.UpdateAsync(_configuration);
            }
            catch (Exception ex)
            {
                _sharedService.WriteLogs("UpdateConfigurationAsync failed:" + ex.Message, false);
            }
        }
Exemple #4
0
        public async Task CreateConfigurationAsync(ConfigurationItemViewModel configuration)
        {
            _sharedService.WriteLogs("CreateConfigurationAsync started by:" + _userSettings.UserName, true);

            try
            {
                var _configuration = new SystemConfigurations();

                _configuration.FieldName    = configuration.FieldName;
                _configuration.FieldValue   = configuration.FieldValue;
                _configuration.CreatedDate  = DateTime.Now;
                _configuration.CreatedBy    = _userSettings.UserName;
                _configuration.ModifiedDate = DateTime.Now;
                _configuration.ModifiedBy   = _userSettings.UserName;

                await _configurationRepository.AddAsync(_configuration);
            }
            catch (Exception ex)
            {
                _sharedService.WriteLogs("CreateConfigurationAsync failed:" + ex.Message, false);
            }
        }
        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;
            }
        }
        protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, RoomWindowAction> message)
        {
            RoomWindowViewModel roomVM = DataContext as RoomWindowViewModel;

            switch (message.Action)
            {
            case RoomWindowAction.ShowConfigWindow:
                ConfigurationItemViewModel configItem = message.Content as ConfigurationItemViewModel;
                roomVM.ApplicationVM.ConfigurationWindowVM = new ConfigurationWindowViewModel(configItem);
                ShowWebWindow(webWindow, false);
                ConfigurationWindow configurationWindow = new ConfigurationWindow(roomVM.ApplicationVM.ConfigurationWindowVM);
                configurationWindow.Owner = this;
                configurationWindow.ShowDialog();
                ShowWebWindow(webWindow, true);
                break;

            case RoomWindowAction.PlayMusic:
                bool canPlay = (bool)message.Content;
                if (canPlay)
                {
                    if (playMusicWindow == null)
                    {
                        InitMusicWindow();
                    }
                    ShowWebWindow(webWindow, false);
                    playMusicWindow.WindowState = System.Windows.WindowState.Normal;
                    playMusicWindow.Show();
                    playMusicWindow.Topmost = true;
                }
                else
                {
                    ShowWebWindow(webWindow, false);
                    if (System.Windows.MessageBox.Show("其它人正在播放音乐,请稍后再试", "提示", MessageBoxButton.OK) == MessageBoxResult.OK)
                    {
                        ShowWebWindow(webWindow, true);
                    }
                }
                break;

            case RoomWindowAction.ManageMusic:
                ShowWebWindow(webWindow, false);
                ManageMusicWindowViewModel manageMusicVM = new ManageMusicWindowViewModel();
                ManageMusicWindow          manageWnd     = new ManageMusicWindow(manageMusicVM);
                manageWnd.Owner   = this;
                manageWnd.Topmost = true;
                ShowWebWindow(webWindow, false);
                manageWnd.ShowDialog();
                ShowWebWindow(webWindow, true);
                break;

            case RoomWindowAction.RecordAudio:
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter = "音频文件 (*.wav)|*.wav";
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    RoomWindowViewModel vm = DataContext as RoomWindowViewModel;
                    vm.StartAudioRecording(dialog.FileName);
                }
                break;

            default:
                break;
            }
        }