Ejemplo n.º 1
0
        private void Stream_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new PropertyChangedEventHandler(Stream_PropertyChanged), new object[] { sender, e });
                return;
            }

            StreamViewerControl sv = sender as StreamViewerControl;

            if (e.PropertyName == "Active")
            {
                if (sv.Active)
                {
                    ActiveStreamViewer = sv;
                }
                else if (sv.FullScreen)
                {
                    Stream_FullScreenClicked(sv, new EventArgs());
                }
                return;
            }
            if (e.PropertyName == "PendingConnection")
            {
                ConnectionChainDescriptor goingTo = sv.PendingConnection;
                if (goingTo != null)
                {
                    StreamViewerControl existingViewer = this.FindViewerMatching(goingTo.Source);
                    if (existingViewer != null)
                    {
                        StringBuilder message = new StringBuilder("You are already watching that camera.");
                        if (existingViewer.State == StreamState.Recording)
                        {
                            message.AppendLine("Also, it's also being recorded.");
                        }
                        message.AppendLine("");
                        message.AppendLine("Moving that camera to this viewer will stop the");
                        message.AppendLine("existing viewer (and recording if applicable)");
                        message.AppendLine("");
                        message.AppendLine("Are you sure you want to move the camera to this viewer?");
                        if (DialogResult.Yes == FCYesNoMsgBox.ShowDialog("Move camera here", message.ToString(), this))
                        {
                            existingViewer.Stop();
                        }
                        else
                        {
                            throw new OperationCanceledException();
                        }
                    }
                }
            }
            if (sv == ActiveStreamViewer)
            {
                switch (e.PropertyName)
                {
                case "State":
                    profileGroupSelector.Visible = false;

                    switch (sv.State)
                    {
                    case StreamState.Connecting:
                    case StreamState.Buffering:
                    case StreamState.Stopping:
                        if (CurrentPalette != null)
                        {
                            CurrentPalette = null;
                        }
                        break;

                    case StreamState.Playing:
//                                if (sv.ProfileGroupSelectorEnabled)
                        if (true)
                        {
                            profileGroupSelector.Enabled = true;
                            profileGroupSelector.Visible = true;
                        }
                        profileGroupSelector.StreamViewer = ActiveStreamViewer;
                        break;
                    }
                    break;
                }
            }
        }