예제 #1
0
        private void RtmpConnectSuccessful()
        {
            UserViewModel uvm = DataContext as UserViewModel;

            if (uvm != null)
            {
                int idx    = 0;
                int micIdx = 0;
                if (uvm.IsMe())
                {
                    idx = uvm.ApplicationVM.ProfileVM.VideoConfigurationVM.CameraIndex;
                }
                bool pv = (uvm.MicStatus & MicStatusMessage.MicStatus_Video) != MicStatusMessage.MicStatus_Off;
                bool pa = (uvm.MicStatus & MicStatusMessage.MicStatus_Audio) != MicStatusMessage.MicStatus_Off;

                CallFlash(FlexCommand.Connect,
                          uvm.StreamGuid,
                          uvm.IsMe() ? "1" : "0",
                          idx.ToString(),
                          micIdx.ToString(),
                          pv ? "1" : "0",
                          pa ? "1" : "0",
                          IsZoom ? "1" : "0",
                          uvm.ApplicationVM.LocalCache.VideoFps.ToString(),
                          uvm.ApplicationVM.LocalCache.VideoQuality.ToString());
                RoomWindowViewModel roomWindowVM = uvm.RoomWindowVM;
                roomWindowVM.RoomCallback.VideoStateChangedEvent += VideoStateChangedEventHandler;
                roomWindowVM.RoomCallback.AudioStateChangedEvent += AudioStateChangedEventHandler;
            }
        }
예제 #2
0
 public void Dispose()
 {
     Dispatcher.BeginInvoke((Action)(() =>
     {
         UserViewModel uvm = DataContext as UserViewModel;
         if (uvm != null)
         {
             RoomWindowViewModel roomWindowVM = uvm.RoomWindowVM;
             roomWindowVM.RoomCallback.VideoStateChangedEvent -= VideoStateChangedEventHandler;
             roomWindowVM.RoomCallback.AudioStateChangedEvent -= AudioStateChangedEventHandler;
         }
         flex.Dispose();
     }));
 }
예제 #3
0
 public RoomWindow(RoomWindowViewModel roomWindowVM, HallWindow hwnd)
     : base(roomWindowVM)
 {
     roomWindowVM.Load(AllWebPages.RoomPage);
     roomWindowVM.Initialize();
     this.roomWindowVM = roomWindowVM;
     InitializeComponent();
     Loaded    += RoomWindow_Loaded;
     hallWindow = hwnd;
     if (hallWindow != null)
     {
         hallWindow.StateChanged += hallWindow_StateChanged;
     }
 }
예제 #4
0
        public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            RoomWindowViewModel rvm = values[0] as RoomWindowViewModel;

            if (rvm != null)
            {
                if (rvm.Me.MicStatus > 0)
                {
                    return(rvm.DownMicLabel);
                }
                else
                {
                    return(rvm.OnMicLabel);
                }
            }
            return(string.Empty);
        }
예제 #5
0
 void webPage_LoadCompleted()
 {
     webPage.InvokeJavaScript("Init", new object[] {
         "<script type='text/javascript' >" + windowVM.WebPageVM.JavaScript + "</script>",
         "<style type='text/css' >" + windowVM.WebPageVM.Css + "</style>", windowVM.WebPageVM.Body
     });
     if (windowVM is HallWindowViewModel)
     {
         HallWindowViewModel hallVM = windowVM as HallWindowViewModel;
         if (hallVM.ApplicationVM.ProfileVM.LastLoginVM != null)
         {
             if (hallVM.ApplicationVM.ProfileVM.LastLoginVM.Remember)
             {
                 webPage.InvokeJavaScript(WebWindowAction.InitHallWithLogin.ToString(), hallVM.RoomGroupsJson, hallVM.ApplicationVM.ProfileVM.LastLoginVM.UserId,
                                          hallVM.ApplicationVM.ProfileVM.LastLoginVM.Password,
                                          hallVM.ApplicationVM.ProfileVM.LastLoginVM.Remember,
                                          hallVM.ApplicationVM.ProfileVM.AutoLogin);
             }
             else
             {
                 webPage.InvokeJavaScript(WebWindowAction.InitHallWithLogin.ToString(), hallVM.RoomGroupsJson, hallVM.ApplicationVM.ProfileVM.LastLoginVM.UserId,
                                          string.Empty,
                                          hallVM.ApplicationVM.ProfileVM.LastLoginVM.Remember,
                                          hallVM.ApplicationVM.ProfileVM.AutoLogin);
             }
         }
         else
         {
             webPage.InvokeJavaScript(WebWindowAction.InitHall.ToString(), hallVM.RoomGroupsJson);
         }
     }
     else if (windowVM is RoomWindowViewModel)
     {
         RoomWindowViewModel roomVM = windowVM as RoomWindowViewModel;
         webPage.InvokeJavaScript(WebWindowAction.InitRoom.ToString(), roomVM.GiftGroupsJson, roomVM.Me.GetJson(true),
                                  webPage.ActualWidth, webPage.ActualHeight, roomVM.ApplicationVM.LocalCache.PublicChatMessageCount,
                                  roomVM.ApplicationVM.LocalCache.PrivateChatMessageCount, roomVM.ApplicationVM.LocalCache.MessagePerSecond);
     }
     windowVM.LoadAsync();
 }
예제 #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
 public RoomWindow(RoomWindowViewModel roomWindowVM) : this(roomWindowVM, null)
 {
 }
예제 #8
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;
            }
        }
예제 #9
0
 public RoomWindowCommand(RoomWindowViewModel roomWindowViewModel)
 {
     _roomWindowViewModel = roomWindowViewModel;
 }