コード例 #1
0
        protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, Actions> message)
        {
            switch (message.Action)
            {
            case Actions.SmileManagement:
                if (smileControl == null)
                {
                    smileControl = new SmileManagement();
                }
                mainContent.Content = smileControl;
                break;

            case Actions.StampManagement:
                if (stampControl == null)
                {
                    stampControl = new StampManagement();
                }
                mainContent.Content = stampControl;
                break;

            case Actions.ImportGif:
                ImportGif();
                break;

            default:
                break;
            }
        }
コード例 #2
0
ファイル: WebWindow.xaml.cs プロジェクト: wangws556/duoduogit
        protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, WebWindowAction> message)
        {
            switch (message.Action)
            {
            case WebWindowAction.InitHall:
                PART_Loading.Visibility = System.Windows.Visibility.Collapsed;
                PART_Content.Visibility = System.Windows.Visibility.Visible;
                break;

            default:
                break;
            }
        }
コード例 #3
0
 protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, PlayMusicWindowAction> message)
 {
     //switch (message.Action)
     //{
     //    case PlayMusicWindowAction.PlayMusic:
     //        break;
     //    case PlayMusicWindowAction.LoadMusicComplete:
     //        PART_Loading.Visibility = System.Windows.Visibility.Collapsed;
     //        PART_Content.Visibility = System.Windows.Visibility.Visible;
     //        playBtn.IsEnabled = true;
     //        break;
     //    default:
     //        break;
     //}
 }
コード例 #4
0
        protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, ViewModel.CameraWindowAction> message)
        {
            switch (message.Action)
            {
            case CameraWindowAction.TakePicture:
                videoControl.CallFlash(YoYoStudio.Controls.Winform.FlexCommand.TakePicture);
                break;

            case CameraWindowAction.Save:
                break;

            default:
                break;
            }
        }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
        protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, ViewModel.HallWindowAction> message)
        {
            HallWindowViewModel hallWindowVM = DataContext as HallWindowViewModel;

            switch (message.Action)
            {
            case HallWindowAction.ApplicationShutdown:
                if (webWindow != null)
                {
                    CloseWebWindow(webWindow);
                    webWindow = null;
                }
                if (roomWindow != null)
                {
                    roomWindow.Close();
                }
                if (registerWindow != null)
                {
                    registerWindow.Close();
                }
                Close();
                break;

            case HallWindowAction.CloseRoomWindow:
                if (roomWindow != null)
                {
                    roomWindow.Close();
                }
                break;

            case HallWindowAction.AlreadyInRoom:
                ShowWebWindow(webWindow, false);
                if (MessageBox.Show(Messages.AlreadyInRoom, Text.Warning, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    if (roomWindow != null)
                    {
                        roomWindow.Close();
                        hallVM.Me.RoomWindowVM = null;
                    }
                    int roomId = (int)message.Content;
                    if (roomId != null)
                    {
                        hallVM.EnterRoom(roomId);
                    }
                }
                ShowWebWindow(webWindow, true);
                break;

            case HallWindowAction.EnterRoomSucceeded:
                RoomWindowViewModel roomWindowVM = message.Content as RoomWindowViewModel;
                roomWindow               = new RoomWindow(roomWindowVM, this) as RoomWindow;
                roomWindow.Closed       += roomWindow_Closed;
                roomWindow.StateChanged += roomWindow_StateChanged;
                roomWindow.Show();
                //Hide();
                //ShowWebWindow(webWindow, false);
                break;

            case HallWindowAction.EnterRoomFailed:
                MessageBox.Show(Messages.EnterRoomFailed);
                break;

            case HallWindowAction.Register:
                RegisterWindowViewModel vm = message.Content as RegisterWindowViewModel;
                if (vm != null)
                {
                    registerWindow = new RegisterWindow(vm)
                    {
                        Owner = this
                    };
                    ShowWebWindow(webWindow, false);
                    registerWindow.ShowDialog();
                    ShowWebWindow(webWindow, true);
                }
                break;

            case HallWindowAction.RegisterUserIdNotAvailable:
                ShowWebWindow(webWindow, false);
                MessageBox.Show(Messages.NoRegisterUserIdAvailable);
                ShowWebWindow(webWindow, true);
                break;

            case HallWindowAction.RegisterSuccess:
                if (registerWindow != null)
                {
                    registerWindow.Close();
                }
                User user = message.Content as User;
                if (user != null)
                {
                    webWindow.CallJavaScript("SetLoginUser", user.Id, user.Password);
                }
                ShowWebWindow(webWindow, true);
                break;

            case HallWindowAction.RegisterCancel:
                if (registerWindow != null)
                {
                    registerWindow.Close();
                }
                ShowWebWindow(webWindow, true);
                break;

            case HallWindowAction.OpenConfigurationWindow:
                hallWindowVM.ApplicationVM.ConfigurationWindowVM = new ConfigurationWindowViewModel();
                ShowWebWindow(webWindow, false);
                ConfigurationWindow configurationWindow = new ConfigurationWindow(hallWindowVM.ApplicationVM.ConfigurationWindowVM);
                configurationWindow.Owner = this;
                configurationWindow.ShowDialog();
                ShowWebWindow(webWindow, true);
                break;

            case HallWindowAction.SwitchUser:
                ShowWebWindow(webWindow, false);
                if (MessageBox.Show(Text.SwitchUserConfirm, Text.Prompt, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    hallWindowVM.ApplicationVM.SwitchUser();
                    webWindow.CallJavaScript("SwitchUser");
                }
                ShowWebWindow(webWindow, true);
                break;

            default:
                break;
            }
        }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
        protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, ManageMusicWindowAction> message)
        {
            switch (message.Action)
            {
            case ManageMusicWindowAction.UploadMusic:
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter      = "MP3文件 (*.mp3)|*.mp3|FLV 文件 (*.flv)|*.flv";
                dlg.Multiselect = false;
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (!String.IsNullOrEmpty(dlg.FileName))
                    {
                        try
                        {
                            string path = ConvertToFLV(dlg.FileName);
                            if (!System.IO.File.Exists(path))
                            {
                                System.Windows.MessageBox.Show(this, "请确认歌曲名字和其所在的路径没有空格", Messages.UploadError);
                                return;
                            }

                            ManageMusicWindowViewModel viewModel = DataContext as ManageMusicWindowViewModel;
                            bool result = viewModel.UploadMusic(path);
                            if (result == true)
                            {
                                System.Windows.MessageBox.Show(this, Messages.UploadSucceed);
                            }
                            else
                            {
                                System.Windows.MessageBox.Show(this, Messages.UploadError);
                            }
                        }
                        catch (Exception e)
                        {
                            System.Windows.MessageBox.Show(this, e.Message);
                        }
                    }
                    else
                    {
                        System.Windows.MessageBox.Show(this, "请先选择歌曲。");
                    }
                }
                break;

            case ManageMusicWindowAction.DeleteMusic:
                if (System.Windows.MessageBox.Show("确定要删除选择的歌曲吗?", Text.Warning, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    ManageMusicWindowViewModel mvm = DataContext as ManageMusicWindowViewModel;
                    mvm.DeleteMusic();
                }
                break;

            case ManageMusicWindowAction.LoadMusicComplete:
                ManageMusicWindowViewModel vm = DataContext  as ManageMusicWindowViewModel;
                PART_Loading.Visibility   = System.Windows.Visibility.Collapsed;
                PART_Content.Visibility   = System.Windows.Visibility.Visible;
                MusicDataGrid.ItemsSource = vm.Musics;
                break;

            default:
                break;
            }
        }
コード例 #9
0
 protected override void ProcessMessage(Common.Notification.EnumNotificationMessage <object, RegisterWindowAction> message)
 {
     throw new NotImplementedException();
 }