IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Presentation Foundation Discussion :

System.NullReferenceException pour affichage caméra


Sujet :

Windows Presentation Foundation

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Par défaut System.NullReferenceException pour affichage caméra
    Bonjour,

    Je dois afficher l'image d'une cam via une appli wpf. J'ai trouvé sur http://easywebcam.codeplex.com/ un exemple qui le fait et affiche très bien.

    Quand je veux l'adapter à mon code celà ne fonctionne pas et lorsque je clique sur bouton start ou stop, cela m'engendre une erreur "System.NullReferenceException" Et je ne vois pas d'où cela peut venir. Je vois joins le code correspondant.
    partie xaml :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    <Window
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	xmlns:my="clr-namespace:Placement" 
     
    	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    	xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    	mc:Ignorable="d" xmlns:visualizationToolkit="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    	x:Class="Window1"
    	x:Name="Window"
    	Title="Window1"
    	Width="1440" Height="900" Background="Black">
        <Window.Resources>
            <SolidColorBrush x:Key="StandardBorderBrush" Color="#888" />
            <SolidColorBrush x:Key="StandardBackgroundBrush" Color="#FFF" />
            <SolidColorBrush x:Key="HoverBorderBrush" Color="#DDD" />
            <SolidColorBrush x:Key="SelectedBackgroundBrush" Color="Gray" />
            <SolidColorBrush x:Key="SelectedForegroundBrush" Color="White" />
            <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
            <SolidColorBrush x:Key="NormalBrush" Color="#888" />
            <SolidColorBrush x:Key="NormalBorderBrush" Color="#888" />
            <SolidColorBrush x:Key="HorizontalNormalBrush" Color="#888" />
            <SolidColorBrush x:Key="HorizontalNormalBorderBrush" Color="#888" />
            <LinearGradientBrush x:Key="ListBoxBackgroundBrush"
                StartPoint="0,0" EndPoint="1,0.001">
                <LinearGradientBrush.GradientStops>
                    <GradientStopCollection>
                        <GradientStop Color="White" Offset="0.0" />
                        <GradientStop Color="White" Offset="0.6" />
                        <GradientStop Color="#DDDDDD" Offset="1.2"/>
                    </GradientStopCollection>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
            <LinearGradientBrush x:Key="StandardBrush"
                StartPoint="0,0" EndPoint="0,1">
                <LinearGradientBrush.GradientStops>
                    <GradientStopCollection>
                        <GradientStop Color="#FFF" Offset="0.0"/>
                        <GradientStop Color="#CCC" Offset="1.0"/>
                    </GradientStopCollection>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="GlyphBrush" Color="#444" />
            <LinearGradientBrush x:Key="PressedBrush"
                StartPoint="0,0" EndPoint="0,1">
                <LinearGradientBrush.GradientStops>
                    <GradientStopCollection>
                        <GradientStop Color="#BBB" Offset="0.0"/>
                        <GradientStop Color="#EEE" Offset="0.1"/>
                        <GradientStop Color="#EEE" Offset="0.9"/>
                        <GradientStop Color="#FFF" Offset="1.0"/>
                    </GradientStopCollection>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
     
     
            <Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="OverridesDefaultStyle" Value="true"/>
                <Setter Property="Focusable" Value="false"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type RepeatButton}">
                            <Border
              x:Name="Border"
              Margin="1"
              CornerRadius="2"
              Background="{StaticResource NormalBrush}"
              BorderBrush="{StaticResource NormalBorderBrush}"
              BorderThickness="1">
                                <Path
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Fill="{StaticResource GlyphBrush}"
                Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsPressed" Value="true">
                                    <Setter TargetName="Border" Property="Background"
                                    Value="{StaticResource PressedBrush}" />
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Foreground"
                                    Value="{StaticResource DisabledForegroundBrush}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
     
            <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="OverridesDefaultStyle" Value="true"/>
                <Setter Property="IsTabStop" Value="false"/>
                <Setter Property="Focusable" Value="false"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type RepeatButton}">
                            <Border Background="Transparent" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
     
            <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="OverridesDefaultStyle" Value="true"/>
                <Setter Property="IsTabStop" Value="false"/>
                <Setter Property="Focusable" Value="false"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Thumb}">
                            <Border
              CornerRadius="2"
              Background="{TemplateBinding Background}"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="1" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
     
            <ControlTemplate x:Key="VerticalScrollBar"
                TargetType="{x:Type ScrollBar}">
                <Grid >
                    <Grid.RowDefinitions>
                        <RowDefinition MaxHeight="18"/>
                        <RowDefinition Height="0.00001*"/>
                        <RowDefinition MaxHeight="18"/>
                    </Grid.RowDefinitions>
                    <Border
          Grid.RowSpan="3"
          CornerRadius="2"
          Background="#F0F0F0" />
                    <RepeatButton
          Grid.Row="0"
          Style="{StaticResource ScrollBarLineButton}"
          Height="18"
          Command="ScrollBar.LineUpCommand"
          Content="M 0 4 L 8 4 L 4 0 Z" />
                    <Track
          x:Name="PART_Track"
          Grid.Row="1"
          IsDirectionReversed="true">
                        <Track.DecreaseRepeatButton>
                            <RepeatButton
              Style="{StaticResource ScrollBarPageButton}"
              Command="ScrollBar.PageUpCommand" />
                        </Track.DecreaseRepeatButton>
                        <Track.Thumb>
                            <Thumb
              Style="{StaticResource ScrollBarThumb}"
              Margin="1,0,1,0"
              Background="{StaticResource HorizontalNormalBrush}"
              BorderBrush="{StaticResource HorizontalNormalBorderBrush}" />
                        </Track.Thumb>
                        <Track.IncreaseRepeatButton>
                            <RepeatButton
              Style="{StaticResource ScrollBarPageButton}"
              Command="ScrollBar.PageDownCommand" />
                        </Track.IncreaseRepeatButton>
                    </Track>
                    <RepeatButton
          Grid.Row="3"
          Style="{StaticResource ScrollBarLineButton}"
          Height="18"
          Command="ScrollBar.LineDownCommand"
          Content="M 0 0 L 4 4 L 8 0 Z"/>
                </Grid>
            </ControlTemplate>
     
            <ControlTemplate x:Key="HorizontalScrollBar"
                TargetType="{x:Type ScrollBar}">
                <Grid >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition MaxWidth="18"/>
                        <ColumnDefinition Width="0.00001*"/>
                        <ColumnDefinition MaxWidth="18"/>
                    </Grid.ColumnDefinitions>
                    <Border
          Grid.ColumnSpan="3"
          CornerRadius="2"
          Background="#F0F0F0" />
                    <RepeatButton
          Grid.Column="0"
          Style="{StaticResource ScrollBarLineButton}"
          Width="18"
          Command="ScrollBar.LineLeftCommand"
          Content="M 4 0 L 4 8 L 0 4 Z" />
                    <Track
          x:Name="PART_Track"
          Grid.Column="1"
          IsDirectionReversed="False">
                        <Track.DecreaseRepeatButton>
                            <RepeatButton
              Style="{StaticResource ScrollBarPageButton}"
              Command="ScrollBar.PageLeftCommand" />
                        </Track.DecreaseRepeatButton>
                        <Track.Thumb>
                            <Thumb
              Style="{StaticResource ScrollBarThumb}"
              Margin="0,1,0,1"
              Background="{StaticResource NormalBrush}"
              BorderBrush="{StaticResource NormalBorderBrush}" />
                        </Track.Thumb>
                        <Track.IncreaseRepeatButton>
                            <RepeatButton
              Style="{StaticResource ScrollBarPageButton}"
              Command="ScrollBar.PageRightCommand" />
                        </Track.IncreaseRepeatButton>
                    </Track>
                    <RepeatButton
          Grid.Column="3"
          Style="{StaticResource ScrollBarLineButton}"
          Width="18"
          Command="ScrollBar.LineRightCommand"
          Content="M 0 0 L 4 4 L 0 8 Z"/>
                </Grid>
            </ControlTemplate>
     
            <Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Setter Property="OverridesDefaultStyle" Value="true"/>
                <Style.Triggers>
                    <Trigger Property="Orientation" Value="Horizontal">
                        <Setter Property="Width" Value="Auto"/>
                        <Setter Property="Height" Value="10" />
                        <Setter Property="Template"
                            Value="{StaticResource HorizontalScrollBar}" />
                    </Trigger>
                    <Trigger Property="Orientation" Value="Vertical">
                        <Setter Property="Width" Value="10"/>
                        <Setter Property="Height" Value="Auto" />
                        <Setter Property="Template"
                            Value="{StaticResource VerticalScrollBar}" />
                    </Trigger>
                </Style.Triggers>
            </Style>
     
     
            <Style x:Key="FavsScrollViewer" TargetType="{x:Type ScrollViewer}">
                <Setter Property="OverridesDefaultStyle" Value="True"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollViewer}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
     
                                <ScrollContentPresenter Grid.Column="1"/>
     
                                <ScrollBar x:Name="PART_VerticalScrollBar"
                Value="{TemplateBinding VerticalOffset}"
                Maximum="{TemplateBinding ScrollableHeight}"
                ViewportSize="{TemplateBinding ViewportHeight}"
                Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>
                                <ScrollBar x:Name="PART_HorizontalScrollBar"
                Orientation="Horizontal"
                Grid.Row="1"
                Grid.Column="1"
                Value="{TemplateBinding HorizontalOffset}"
                Maximum="{TemplateBinding ScrollableWidth}"
                ViewportSize="{TemplateBinding ViewportWidth}"
                Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>
     
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
     
     
     
     
     
     
     
     
     
     
     
     
            <LinearGradientBrush x:Key="ToolBarHorizontalBackground" EndPoint="0,1" StartPoint="0,0">
                <GradientStop Color="#FFFFFF" Offset="0"/>
                <GradientStop Color="#FFFBFF" Offset="0.5"/>
                <GradientStop Color="#F7F7F7" Offset="1"/>
            </LinearGradientBrush>
     
            <BitmapImage x:Key="Icon_FolderOpen"   UriSource="Resources/test.jpg"   />
            <BitmapImage x:Key="Icon_FolderClosed" UriSource="Resources/Folder.gif" />
     
            <Style x:Key="IconImageStyleSmall" TargetType="{x:Type Image}">
                <Setter Property="MaxWidth" Value="16"/>
                <Setter Property="MaxHeight" Value="16"/>
                <Setter Property="Margin" Value="1"/>
            </Style>
            <SolidColorBrush x:Key="ToolBarSubMenuBackground" Color="#FDFDFD"/>
            <SolidColorBrush x:Key="ToolBarMenuBorder" Color="#808080"/>
            <SolidColorBrush x:Key="ToolBarGripper" Color="#C6C3C6"/>
            <Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Thumb}">
                            <Border SnapsToDevicePixels="True" Background="Transparent" Padding="{TemplateBinding Padding}">
                                <Rectangle>
                                    <Rectangle.Fill>
                                        <DrawingBrush TileMode="Tile" Viewbox="0,0,4,4" ViewboxUnits="Absolute" Viewport="0,0,4,4" ViewportUnits="Absolute">
                                            <DrawingBrush.Drawing>
                                                <DrawingGroup>
                                                    <GeometryDrawing Brush="White" Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
                                                    <GeometryDrawing Brush="{StaticResource ToolBarGripper}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z"/>
                                                </DrawingGroup>
                                            </DrawingBrush.Drawing>
                                        </DrawingBrush>
                                    </Rectangle.Fill>
                                </Rectangle>
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter Property="Cursor" Value="SizeAll"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="ToolBarStyle1" TargetType="{x:Type ToolBar}">
                <Setter Property="Background" Value="{StaticResource ToolBarHorizontalBackground}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ToolBar}">
     
                            <Grid x:Name="Grid" Margin="3,1,1,1" SnapsToDevicePixels="true">
                                <Grid x:Name="OverflowGrid" HorizontalAlignment="Right">
                                    <Popup x:Name="OverflowPopup" AllowsTransparency="true" IsOpen="{Binding IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" StaysOpen="false" Focusable="false">
                                        <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
                                            <Border Background="{StaticResource ToolBarSubMenuBackground}" BorderBrush="{StaticResource ToolBarMenuBorder}" BorderThickness="1">
                                                <ToolBarOverflowPanel x:Name="PART_ToolBarOverflowPanel" FocusVisualStyle="{x:Null}" Margin="2" Focusable="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle" WrapWidth="200"/>
                                            </Border>
                                        </Microsoft_Windows_Themes:SystemDropShadowChrome>
                                    </Popup>
                                </Grid>
                                <Border x:Name="MainPanelBorder" Margin="0,0,11,0" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3,3,3,3" Padding="{TemplateBinding Padding}">
                                    <DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
                                        <Thumb x:Name="ToolBarThumb" Margin="-3,-1,0,0" Style="{StaticResource ToolBarThumbStyle}" Width="10" Padding="6,5,1,6"/>
                                        <ContentPresenter x:Name="ToolBarHeader" HorizontalAlignment="Center" Margin="4,0,4,0" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header"/>
                                        <ToolBarPanel x:Name="PART_ToolBarPanel" Margin="0,1,2,2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" IsItemsHost="true"/>
                                    </DockPanel>
                                </Border>
                            </Grid>
     
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="ButtonFocusVisual">
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Rectangle Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="2" SnapsToDevicePixels="true"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
     
     
        </Window.Resources>
     
     
        <Grid x:Name="LayoutRoot" Width="1440" Height="890" Background="#BF969696">
            <Menu BorderThickness="0" VerticalAlignment="Top" Height="30" >
                <Menu.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#FFF6F6F6"/>
                        <GradientStop Color="#FF494949" Offset="0.357"/>
                        <GradientStop Color="#FFDCD9D9" Offset="1"/>
                        <GradientStop Color="#FF494949" Offset="0.843"/>
                    </LinearGradientBrush>
                </Menu.Background>
                <MenuItem Header="File" x:Name="MenuItem1" FontSize="14.667" Foreground="White"  >
                    <MenuItem Header="Ouvrir" Foreground="Black"/>
                    <Separator/>
                    <MenuItem Header="Fermer" Foreground="Black"/>
                    <MenuItem Header="Enregistrer" Foreground="Black"/>
                </MenuItem>
                <MenuItem Header="Options" x:Name="MenuItem2" FontSize="14.667" Foreground="White" >
                    <MenuItem Header="Option1" Foreground="Black" />
                    <MenuItem Header="Option2" Foreground="Black"/>
                    <MenuItem Header="Option3" Foreground="Black"/>
                </MenuItem>
                <MenuItem Header="Setting" x:Name="MenuItem4" FontSize="14.667" Foreground="White" >
                    <MenuItem Header="Mot de passe" Foreground="Black"/>
     
                </MenuItem>
                <MenuItem Header="Help" x:Name="MenuItem3" FontSize="14.667" Foreground="White" >
                    <MenuItem Header="Infos" Foreground="Black"/>
                    <MenuItem Header="A propos" Foreground="Black" />
                </MenuItem>
                <Separator/>
            </Menu>
            <Canvas HorizontalAlignment="Left" Margin="0,30,0,44" Width="310" Background="#FF353535">
                <Border CornerRadius="10"
    				BorderBrush="Gray"
    				Background="#FF404040"
    				BorderThickness="1"
    				Padding="0" Height="51" Width="292" Canvas.Left="8" Canvas.Top="10">
     
                    <ToolBar  Background="#FF404040" Margin="19,-1,0,0" RenderTransformOrigin="0.5,0.5" Style="{DynamicResource ToolBarStyle1}" VerticalAlignment="Top" Height="42" HorizontalAlignment="Left" Width="262">
     
     
                        <Button Background="{x:Null}" Width="24" Height="24" RenderTransformOrigin="0.5,0.5" Margin="0,0,0,7" VerticalAlignment="Bottom" >
     
                            <Image Source="C:\Users\Anthony kamax\Downloads\Icones\case-vert-icone-8663-32.png" x:Name="Image1" />
                        </Button>
                        <Button Background="{x:Null}"   SnapsToDevicePixels="True"  >
                            <Image Source="Resources/appbar.camera.png" Height="30" />
                        </Button>
                        <Button Background="{x:Null}" Width="24" Height="24" SnapsToDevicePixels="True" Margin="3,6,4,6" >
                            <Image Source="C:\Users\Anthony kamax\Downloads\Icones\camera.png" />
                        </Button>
                        <Button Background="{x:Null}" Width="24" Height="24" SnapsToDevicePixels="True" Margin="3,6,4,6" >
                            <Image Source="C:\Users\Anthony kamax\Downloads\Icones\loupe-zoom-avant-icone-8627-32.png" />
                        </Button>
                        <Button Background="{x:Null}" Width="24" Height="24" SnapsToDevicePixels="True" Margin="3,6,4,6" >
                            <Image Source="C:\Users\Anthony kamax\Downloads\Icones\loupe-zoom-arriere-icone-9037-32.png" />
                        </Button>
                        <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                            <Image Source="Resources/appbar.save.png" Height="30" />
                        </Button>
     
                        <Image Source="Resources/appbar.edit.box.png" Width="30" />
     
     
                    </ToolBar>
                </Border>
                <Border CornerRadius="10"
    				BorderBrush="Gray"
    				Background="#FF404040"
    				BorderThickness="1"
    				Padding="0" Height="402" Width="294" Canvas.Top="78" Canvas.Left="10">
                    <Canvas Margin="0,0,0,-46">
                        <visualizationToolkit:Title Content="Live Cam" Canvas.Left="120" FontStyle="Italic" FontWeight="Bold"/>
                        <Image Height="320" x:Name="imgVideo" Stretch="Fill"  HorizontalAlignment="Left" Width="240" Canvas.Left="25.5" Canvas.Top="19.96"/>
                    </Canvas>
                </Border>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <Button x:Name="bntStart" Content="Start" Click="bntStart_Click" />
                    <Button x:Name="bntStop" Content="Stop" Margin="10,0,0,0" Click="bntStop_Click" />
                    <Button x:Name="bntContinue" Content="Continue" Margin="10,0,0,0" Click="bntContinue_Click" />
                </StackPanel>
                <Border CornerRadius="10"
    				BorderBrush="Gray"
    				Background="#FF404040"
    				BorderThickness="1"
    				Padding="0" Height="216.8" Width="294.5" Canvas.Left="8" Canvas.Top="537">
     
                    <Canvas Margin="0,0,0,-46">
                        <visualizationToolkit:Title Content="Sample parameters" Canvas.Left="64" FontStyle="Italic" FontWeight="Bold"/>
                        <TextBlock Width="160" Height="20.04" Canvas.Top="31.96" TextWrapping="Wrap"><Run Text="T"/><Run Text="hick of histological section"/><Run Text=" :"/></TextBlock>
                        <TextBlock Width="93" Height="20.04" Canvas.Top="54.96" TextWrapping="Wrap"><Run Text="Sample Number"/><Run Text=" :"/></TextBlock>
                        <TextBlock Width="83" Height="20.04" Canvas.Top="82.96" TextWrapping="Wrap"><Run Text="Observations "/><Run Text=":"/></TextBlock>
                        <TextBox Width="125.5" Height="22" Canvas.Left="159" Canvas.Top="25.96" Text="TextBox" TextWrapping="Wrap"/>
                        <TextBox Width="171.5" Height="23.04" Canvas.Left="113" Canvas.Top="51.96" Text="TextBox" TextWrapping="Wrap"/>
                        <TextBox Width="191.5" Height="119.04" Canvas.Left="93" Canvas.Top="82.96" Text="TextBox" TextWrapping="Wrap"/>
                    </Canvas>
                </Border>
     
                <Image Source="C:\Users\Anthony kamax\Downloads\Icones\Logo KAMAX.gif" Stretch="Fill" HorizontalAlignment="Left" VerticalAlignment="Bottom" Canvas.Left="8" Canvas.Top="772.8" Width="91" Height="31"/>
                <ProgressBar Width="182" Height="13" Canvas.Left="113.76" Canvas.Top="782"/>
     
     
     
            </Canvas>
     
            <Grid Margin="315,35,0,36" Background="#FF404040">
                <Image Width="480" Height="640" Source="Resources/Capture02b.jpg" Stretch="Fill" Margin="568,86,0,94"/>
                <Image Width="480" Height="640" Source="Resources/Capture02NB.jpg" Stretch="Fill" Margin="19,86,0,94" OpacityMask="Black" HorizontalAlignment="Left" d:LayoutOverrides="Width"/>
     
     
     
     
     
     
                <ToolBar  Background="#FF404040" Margin="19,31,0,0" RenderTransformOrigin="0.5,0.5" Style="{DynamicResource ToolBarStyle1}" VerticalAlignment="Top" Height="42" HorizontalAlignment="Left" Width="242">
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
                        <Image Width="30" Height="30" Source="Resources/appbar.folder.open.png" />
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                        <Image Source="C:\Users\Anthony kamax\Downloads\Icones\agt-imprimer-icone-9151-32.png" />
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                        <Image Source="Resources/appbar.save.png" Height="30" />
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                        <Image Source="Resources/appbar.page.copy.png" Height="30"  />
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
                        <Image Source="Resources/appbar.magnify.add.png" Height="30"  />
     
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                        <Image Source="Resources/appbar.magnify.minus.png" Height="30"  />
                    </Button>
                </ToolBar>
                <ToolBar  Background="#FF626262" Margin="412,0,0,201.5" RenderTransformOrigin="0.5,0.5" Style="{DynamicResource ToolBarStyle1}" VerticalAlignment="Bottom" Height="42" HorizontalAlignment="Left" Width="247">
                    <ToolBar.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform Angle="90"/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </ToolBar.RenderTransform>
     
                    <Button Height="30" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Stretch" Margin="0,5.5,0,1.5">
     
                        <Image Source="Resources/appbar.ruler.png" Height="30" />
                    </Button>
                    <Button Height="30" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Stretch" Margin="0,3.5">
     
                        <Image Source="dessiner-modifier-crayon-ecrivez-icone-5630-32.png" />
                    </Button>
                    <Button Height="30" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Stretch">
     
                        <Image Source="Eraser_Icon_256.png"  />
                    </Button>
                    <Button Height="30" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Stretch">
     
                        <Image Source="Resources/appbar.base.select.png" Height="28" />
                    </Button>
                    <Button Height="30" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Stretch">
     
                        <Image Source="couleurs-roue-icone-9716-32.png" />
                    </Button>
                    <Button Height="30" HorizontalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Stretch">
                        <Button.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform />
                                <SkewTransform />
                                <RotateTransform Angle="-90" />
                                <TranslateTransform />
                            </TransformGroup>
                        </Button.RenderTransform>
                        <Image Source="rect5605.png" />
                    </Button>
                </ToolBar>
                <ToolBar  Background="#FF626262" Margin="606,31,249,0" RenderTransformOrigin="0.5,0.5" Style="{DynamicResource ToolBarStyle1}" VerticalAlignment="Top" Height="42">
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
                        <Image Width="30" Height="30" Source="Resources\appbar.folder.open.png" />
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                        <Image Source="agt-imprimer-icone-9151-321.png" />
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                        <Image Source="Resources\appbar.save.png" Height="30" />
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                        <Image Source="Resources\appbar.page.copy.png" Height="30"  />
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                        <Image Source="loupe-zoom-arriere-icone-9037-322.png" />
                    </Button>
                    <Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Height="30" Margin="0,3.5" >
     
                        <Image Source="loupe-zoom-avant-icone-8627-322.png" />
                    </Button>
                </ToolBar>
                <Border CornerRadius="10"
    					BorderBrush="Gray"
    					Background="#FF404040"
    					BorderThickness="1"
    					Padding="0" Width="42.333" HorizontalAlignment="Left" Margin="513.667,162,0,359">
                    <WrapPanel Margin="2,19.5,-1,7" >
                        <Image Width="30" Height="30" Source="Resources\appbar.lightbulb.hue.on.png" Stretch="Fill" Margin="5,3"/>
                        <Slider Width="31" Height="167" Orientation="Vertical" Margin="5,3"/>
                        <Image Width="30" Height="30" Source="Resources\appbar.lightbulb.hue.png" Stretch="Fill" Margin="5,3" RenderTransformOrigin="0.667,8.35"/>
     
                    </WrapPanel>
                </Border>
                <Border CornerRadius="10"
    					BorderBrush="Gray"
    					Background="#FF404040"
    					BorderThickness="1"
    					Padding="0" Height="34" Width="226" HorizontalAlignment="Left" Margin="-315,0,0,352" VerticalAlignment="Bottom">
                    <WrapPanel Margin="2,0,7,-11"    Height="43" >
     
                        <Image Width="30" Height="30" Source="Resources\appbar.lightbulb.hue.png" Stretch="Fill" Margin="0,0,3,0"/>
                        <Slider Width="136" Height="23"/>
                        <Image Width="30" Height="30" Source="Resources\appbar.lightbulb.hue.on.png" Stretch="Fill" Margin="5,0,0,0"/>
     
                    </WrapPanel>
                </Border>
                <Border CornerRadius="10"
    					BorderBrush="Gray"
    					Background="#FF404040"
    					BorderThickness="1"
    					Padding="0" Width="42.333" HorizontalAlignment="Left" Margin="513.667,86,0,0" VerticalAlignment="Top" Height="46.333">
                    <WrapPanel Margin="0,-1,7,7" HorizontalAlignment="Right" >
                        <visualizationToolkit:Title Content="SAT" Canvas.Left="120" FontStyle="Italic" FontWeight="Bold"/>
     
     
                        <Image Source="C:\Users\Anthony kamax\Downloads\Icones\boule-rouge-icone-7914-32.png" Height="24" Width="24" />
                    </WrapPanel>
                </Border>
                <Border CornerRadius="10"
    					BorderBrush="Gray"
    					Background="#FF404040"
    					BorderThickness="1"
    					Padding="0" Width="42" HorizontalAlignment="Left" Margin="-84,0,0,352" VerticalAlignment="Bottom" Height="46">
                    <WrapPanel Margin="0,-1,7,7" HorizontalAlignment="Right" >
                        <visualizationToolkit:Title Content="SAT" Canvas.Left="120" FontStyle="Italic" FontWeight="Bold"/>
     
     
                        <Image Source="boule-rouge-icone-7914-32.png" Height="24" Width="24" />
                    </WrapPanel>
                </Border>
     
            </Grid>
     
        </Grid>
    </Window>
    et le code vb.net :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    Imports System
    Imports System.IO
    Imports System.Linq
    Imports System.Collections.Generic
    Imports System.Collections.ObjectModel
    Imports System.Text
     
    Imports System.Windows.Threading
    Imports System.Windows.Media.Animation
    Imports System.Threading
    Imports System.Windows.Resources
    Imports System.Reflection
    Imports WebCam_Capture
     
     
    Imports System.Windows
    Imports System.Windows.Controls
     
     
     
     
     
    Class Window1
     
        Private webcam As WebCam
        Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            webcam = New WebCam()
            webcam.InitializeWebCam(imgVideo)
        End Sub
     
        Private Sub bntStart_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            webcam.Start()
        End Sub
     
        Private Sub bntStop_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            webcam.Stop()
        End Sub
     
        Private Sub bntContinue_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
            webcam.Continue()
        End Sub
    End Class
    Merci d'avance pour votre aide

  2. #2
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Par défaut
    La méthode Window_Loaded n'est pas associée à l'évènement Loaded de la fenêtre, donc elle n'est jamais appelée, et donc la variable webcam n'est jamais initialisée, ce qui cause l'exception quand tu essaies d'appeler une méthode dessus.

    Il manque ça dans ton XAML sur l'élément Window :

    Code XAML : Sélectionner tout - Visualiser dans une fenêtre à part
    Loaded="Window_Loaded"

  3. #3
    Rédacteur/Modérateur


    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2004
    Messages
    19 875
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2004
    Messages : 19 875
    Par défaut
    Citation Envoyé par SkaknYoshi Voir le message
    je ne vois pas d'où cela peut venir
    Voilà un mini cours de débogage pour que tu ne sois pas bloqué la prochaine fois

    Cette exception (NullReferenceException) a toujours la même cause : tu as essayé d'accéder à un membre (méthode, propriété, champ ou évènement) d'une variable qui vaut Nothing (généralement parce que tu as oublié de l'initialiser)

    Normalement, le débogueur suspend l'exécution et place le curseur sur la ligne qui pose problème, tu peux donc regarder la valeur des variables pour voir celle qui pose problème. Si tu penses avoir initialisé cette variable, mets un point d'arrêt à l'endroit où tu l'initialises, et relance l'exécution. Si le débogueur ne s'arrête pas sur le point d'arrêt, c'est que ce code n'a pas été exécuté... Reste juste à trouver pourquoi

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    66
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 66
    Par défaut
    Ok merci bien,

    J'ai eu peur, ça fonctionnait pas lors de mes premières tentatives, j'ai relancé projet et cela fonctionne désormais.

    Le débogueur m'emmenait directement sur webcam.start et j'avais bien vu que dans webcam il y avait nothing, mais j'ai pas pensé à vérifier le lancement de Window_Loaded

    Il y a un petit moment que je n'avais pas fait de dév et je n'ai pas toujours les "réflexes"

    En tout cas encore merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Mémoire insuffisante pour affichage caméra
    Par SkaknYoshi dans le forum Windows Presentation Foundation
    Réponses: 14
    Dernier message: 29/04/2014, 14h56
  2. recherche solution pour affichage ds une StringGrid....
    Par steph_1 dans le forum Composants VCL
    Réponses: 13
    Dernier message: 13/07/2005, 13h24
  3. Algorithmes génériques pour affichage de primitives 2D.
    Par Selenite dans le forum Algorithmes et structures de données
    Réponses: 3
    Dernier message: 02/01/2005, 20h20
  4. Réponses: 17
    Dernier message: 17/05/2004, 15h24
  5. code html en ram -> TWebBrowser pour affichage
    Par FredericB dans le forum C++Builder
    Réponses: 2
    Dernier message: 22/04/2003, 22h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo