示例#1
0
        private static void OnStreamChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            CameraStream s = sender as CameraStream;

            //end the stream and prepare it for disposal
            s.stream.NewFrame -= s.Stream_NewFrame;
            s.stream.Stop();
            //restart the stream at the new address
            s.HookStream();
        }
        public CameraViewSelector()
        {
            layout = new Grid();
            BuildRows();
            Content = layout;

            stream = new CameraStream()
            {
                Stretch = Stretch.Uniform
            };
            layout.Children.Add(stream);

            StackPanel chooserArea = new StackPanel()
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            streams = new ComboBox()
            {
                MinWidth = 150,
                Margin   = new Thickness(0, 10, 2.5, 10)
            };
            streams.SelectionChanged += Streams_SelectionChanged;
            chooserArea.Children.Add(streams);
            Button refresh = new Button()
            {
                Margin  = new Thickness(2.5, 10, 0, 10),
                Padding = new Thickness(5),
                Content = "Refresh"
            };

            refresh.Click += Refresh_Click;
            chooserArea.Children.Add(refresh);
            Grid.SetRow(chooserArea, 1);
            layout.Children.Add(chooserArea);

            AddOneConverter extraRows  = new AddOneConverter();
            Binding         rowBinding = new Binding("DisplayPanelHeight")
            {
                Source    = this,
                Converter = extraRows
            };

            BindingOperations.SetBinding(this, TileGrid.RowSpanProperty, rowBinding);

            this.SetBinding(TileGrid.ColumnSpanProperty, this, "DisplayPanelWidth");
        }