GIT: perform LF normalization

This commit is contained in:
Gary Sharp
2013-02-28 17:15:46 +11:00
parent 989f08a24d
commit 7d9be5620d
729 changed files with 300734 additions and 300712 deletions
@@ -1,34 +1,34 @@
<controls:ChildWindow
x:Class="Disco.Silverlight.AttachmentUpload.ErrorWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Title="Error">
<Grid x:Name="LayoutRoot" Width="540">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="IntroductoryText" Grid.Row="0" Margin="0"
Text="An unknown error was encountered. Please contact your administrator for more information."/>
<StackPanel x:Name="ContentStackPanel" Grid.Row="2" Margin="0,6,0,0">
<TextBlock x:Name="LabelText" TextWrapping="Wrap" Margin="0,0,0,2"
Text="Error details"/>
<TextBox x:Name="ErrorTextBox" Height="90" TextWrapping="Wrap" IsReadOnly="True"
VerticalScrollBarVisibility="Auto"/>
</StackPanel>
<Button x:Name="OKButton" Grid.Row="3" Click="OKButton_Click"
HorizontalAlignment="Right" Margin="0,10,0,0"
TabIndex="0" Content="OK"/>
</Grid>
<controls:ChildWindow
x:Class="Disco.Silverlight.AttachmentUpload.ErrorWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Title="Error">
<Grid x:Name="LayoutRoot" Width="540">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="IntroductoryText" Grid.Row="0" Margin="0"
Text="An unknown error was encountered. Please contact your administrator for more information."/>
<StackPanel x:Name="ContentStackPanel" Grid.Row="2" Margin="0,6,0,0">
<TextBlock x:Name="LabelText" TextWrapping="Wrap" Margin="0,0,0,2"
Text="Error details"/>
<TextBox x:Name="ErrorTextBox" Height="90" TextWrapping="Wrap" IsReadOnly="True"
VerticalScrollBarVisibility="Auto"/>
</StackPanel>
<Button x:Name="OKButton" Grid.Row="3" Click="OKButton_Click"
HorizontalAlignment="Right" Margin="0,10,0,0"
TabIndex="0" Content="OK"/>
</Grid>
</controls:ChildWindow>
@@ -1,27 +1,27 @@
Partial Public Class ErrorWindow
Inherits ChildWindow
Public Sub New(ByVal e As Exception)
InitializeComponent()
If e IsNot Nothing Then
ErrorTextBox.Text = e.Message + Environment.NewLine + Environment.NewLine + e.StackTrace
End If
End Sub
Public Sub New(ByVal uri As Uri)
InitializeComponent()
If uri IsNot Nothing Then
ErrorTextBox.Text = "Page not found: """ + uri.ToString() + """"""
End If
End Sub
Public Sub New(ByVal message As String, ByVal details As String)
InitializeComponent()
ErrorTextBox.Text = message + Environment.NewLine + Environment.NewLine + details
End Sub
Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Me.DialogResult = True
End Sub
End Class
Partial Public Class ErrorWindow
Inherits ChildWindow
Public Sub New(ByVal e As Exception)
InitializeComponent()
If e IsNot Nothing Then
ErrorTextBox.Text = e.Message + Environment.NewLine + Environment.NewLine + e.StackTrace
End If
End Sub
Public Sub New(ByVal uri As Uri)
InitializeComponent()
If uri IsNot Nothing Then
ErrorTextBox.Text = "Page not found: """ + uri.ToString() + """"""
End If
End Sub
Public Sub New(ByVal message As String, ByVal details As String)
InitializeComponent()
ErrorTextBox.Text = message + Environment.NewLine + Environment.NewLine + details
End Sub
Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Me.DialogResult = True
End Sub
End Class
@@ -1,24 +1,24 @@
<navigation:Page x:Class="Disco.Silverlight.AttachmentUpload.File"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
Title="File Upload"
Style="{StaticResource PageStyle}">
<Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button x:Name="ButtonBrowseForFile" Content="BROWSE FOR FILES" HorizontalAlignment="Center" VerticalAlignment="Center" />
<StackPanel x:Name="DropTarget" Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" AllowDrop="True">
<Image Source="../Assets/dropTarget.png" Stretch="None" Width="128" Height="128" />
<TextBlock HorizontalAlignment="Center">Drop Files Here</TextBlock>
</StackPanel>
</Grid>
</navigation:Page>
<navigation:Page x:Class="Disco.Silverlight.AttachmentUpload.File"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
Title="File Upload"
Style="{StaticResource PageStyle}">
<Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button x:Name="ButtonBrowseForFile" Content="BROWSE FOR FILES" HorizontalAlignment="Center" VerticalAlignment="Center" />
<StackPanel x:Name="DropTarget" Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" AllowDrop="True">
<Image Source="../Assets/dropTarget.png" Stretch="None" Width="128" Height="128" />
<TextBlock HorizontalAlignment="Center">Drop Files Here</TextBlock>
</StackPanel>
</Grid>
</navigation:Page>
@@ -1,62 +1,62 @@
Partial Public Class File
Inherits Page
Public Sub New()
InitializeComponent()
End Sub
Private _FileWindow As FileWindow
Private _ProcessFile As IO.FileInfo
Private _ProcessFiles As Queue(Of IO.FileInfo)
'Executes when the user navigates to this page.
Protected Overrides Sub OnNavigatedTo(ByVal e As System.Windows.Navigation.NavigationEventArgs)
_ProcessFiles = New Queue(Of IO.FileInfo)
End Sub
Private Sub ButtonBrowseForFile_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonBrowseForFile.Click
Dim ofd As New OpenFileDialog() With {.Multiselect = True}
If ofd.ShowDialog() Then
For Each f In ofd.Files
_ProcessFiles.Enqueue(f)
Next
StartProcessing()
End If
End Sub
Private Sub StartProcessing()
If _ProcessFiles.Count > 0 Then
_ProcessFile = _ProcessFiles.Dequeue
_FileWindow = New FileWindow(_ProcessFile)
AddHandler _FileWindow.Closed, AddressOf FileWindow_Closed
_FileWindow.Show()
End If
End Sub
Private Sub FileWindow_Closed(sender As Object, e As EventArgs)
If _FileWindow.DialogResult Then
Me.IsEnabled = False
Dim fs = _FileWindow.File.OpenRead
App.MainPage.UploadAttachment(fs, _FileWindow.Filename, "unknown/unknown", _FileWindow.Comments)
Me.IsEnabled = True
End If
StartProcessing()
End Sub
Private Sub DropTarget_Drop(sender As Object, e As System.Windows.DragEventArgs) Handles DropTarget.Drop
For Each f As IO.FileInfo In e.Data.GetData(DataFormats.FileDrop)
_ProcessFiles.Enqueue(f)
Next
StartProcessing()
End Sub
End Class
Partial Public Class File
Inherits Page
Public Sub New()
InitializeComponent()
End Sub
Private _FileWindow As FileWindow
Private _ProcessFile As IO.FileInfo
Private _ProcessFiles As Queue(Of IO.FileInfo)
'Executes when the user navigates to this page.
Protected Overrides Sub OnNavigatedTo(ByVal e As System.Windows.Navigation.NavigationEventArgs)
_ProcessFiles = New Queue(Of IO.FileInfo)
End Sub
Private Sub ButtonBrowseForFile_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonBrowseForFile.Click
Dim ofd As New OpenFileDialog() With {.Multiselect = True}
If ofd.ShowDialog() Then
For Each f In ofd.Files
_ProcessFiles.Enqueue(f)
Next
StartProcessing()
End If
End Sub
Private Sub StartProcessing()
If _ProcessFiles.Count > 0 Then
_ProcessFile = _ProcessFiles.Dequeue
_FileWindow = New FileWindow(_ProcessFile)
AddHandler _FileWindow.Closed, AddressOf FileWindow_Closed
_FileWindow.Show()
End If
End Sub
Private Sub FileWindow_Closed(sender As Object, e As EventArgs)
If _FileWindow.DialogResult Then
Me.IsEnabled = False
Dim fs = _FileWindow.File.OpenRead
App.MainPage.UploadAttachment(fs, _FileWindow.Filename, "unknown/unknown", _FileWindow.Comments)
Me.IsEnabled = True
End If
StartProcessing()
End Sub
Private Sub DropTarget_Drop(sender As Object, e As System.Windows.DragEventArgs) Handles DropTarget.Drop
For Each f As IO.FileInfo In e.Data.GetData(DataFormats.FileDrop)
_ProcessFiles.Enqueue(f)
Next
StartProcessing()
End Sub
End Class
@@ -1,50 +1,50 @@
<controls:ChildWindow
x:Class="Disco.Silverlight.AttachmentUpload.FileWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Title="Upload File">
<Grid x:Name="LayoutRoot" Width="540">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="IntroductoryText" Grid.Row="0" Margin="0"
Text="Please provide details for the file."/>
<StackPanel x:Name="ContentStackPanel" Grid.Row="2" Margin="0,6,0,0">
<TextBlock x:Name="LabelText" TextWrapping="Wrap" Margin="0,0,0,2"
Text="Details"/>
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0 0 10 0">Filename:</TextBlock>
<TextBlock Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0 0 10 0">Comments:</TextBlock>
<TextBlock x:Name="textBlockName" Grid.Row="0" Grid.Column="1" Margin="4" Text="{Binding Filename}" />
<TextBox x:Name="textBlockComments" Grid.Row="1" Grid.Column="1" Height="24" Margin="4" Text="{Binding Comments}" />
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Right" Margin="0,10,0,0">
<Button x:Name="ButtonCancel" Click="ButtonCancel_Click" Padding="14 6" VerticalAlignment="Bottom"
Margin="0,0,10,0"
TabIndex="0" Content="CANCEL"/>
<Button x:Name="ButtonOK" Click="ButtonOK_Click" Padding="14 6" VerticalAlignment="Bottom"
TabIndex="0" Content="OK" />
</StackPanel>
</Grid>
<controls:ChildWindow
x:Class="Disco.Silverlight.AttachmentUpload.FileWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Title="Upload File">
<Grid x:Name="LayoutRoot" Width="540">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="IntroductoryText" Grid.Row="0" Margin="0"
Text="Please provide details for the file."/>
<StackPanel x:Name="ContentStackPanel" Grid.Row="2" Margin="0,6,0,0">
<TextBlock x:Name="LabelText" TextWrapping="Wrap" Margin="0,0,0,2"
Text="Details"/>
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0 0 10 0">Filename:</TextBlock>
<TextBlock Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0 0 10 0">Comments:</TextBlock>
<TextBlock x:Name="textBlockName" Grid.Row="0" Grid.Column="1" Margin="4" Text="{Binding Filename}" />
<TextBox x:Name="textBlockComments" Grid.Row="1" Grid.Column="1" Height="24" Margin="4" Text="{Binding Comments}" />
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Right" Margin="0,10,0,0">
<Button x:Name="ButtonCancel" Click="ButtonCancel_Click" Padding="14 6" VerticalAlignment="Bottom"
Margin="0,0,10,0"
TabIndex="0" Content="CANCEL"/>
<Button x:Name="ButtonOK" Click="ButtonOK_Click" Padding="14 6" VerticalAlignment="Bottom"
TabIndex="0" Content="OK" />
</StackPanel>
</Grid>
</controls:ChildWindow>
@@ -1,55 +1,55 @@
Partial Public Class FileWindow
Inherits ChildWindow
Public Property File As IO.FileInfo
Public Property Filename As String
Public Property Comments As String
Private _InitialFocus As Boolean = False
Public Sub New(File As IO.FileInfo)
InitializeComponent()
Me.File = File
Me.Filename = File.Name
Me.Comments = String.Empty
Me.DataContext = Me
End Sub
Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
If String.IsNullOrEmpty(Me.textBlockComments.Text) Then
MessageBox.Show("Please provide a Comment")
Me.textBlockComments.Focus()
Else
Me.Comments = textBlockComments.Text
Me.DialogResult = True
End If
End Sub
Private Sub ButtonCancel_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Me.DialogResult = False
End Sub
Private Sub textBlockComments_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles textBlockComments.KeyDown
If e.Key = Key.Enter Then
ButtonOK_Click(Nothing, Nothing)
Return
End If
If e.Key = Key.Escape Then
ButtonCancel_Click(Nothing, Nothing)
Return
End If
End Sub
Private Sub FileWindow_GotFocus(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.GotFocus
If Not _InitialFocus Then
Me.textBlockComments.Focus()
_InitialFocus = True
End If
End Sub
End Class
Partial Public Class FileWindow
Inherits ChildWindow
Public Property File As IO.FileInfo
Public Property Filename As String
Public Property Comments As String
Private _InitialFocus As Boolean = False
Public Sub New(File As IO.FileInfo)
InitializeComponent()
Me.File = File
Me.Filename = File.Name
Me.Comments = String.Empty
Me.DataContext = Me
End Sub
Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
If String.IsNullOrEmpty(Me.textBlockComments.Text) Then
MessageBox.Show("Please provide a Comment")
Me.textBlockComments.Focus()
Else
Me.Comments = textBlockComments.Text
Me.DialogResult = True
End If
End Sub
Private Sub ButtonCancel_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Me.DialogResult = False
End Sub
Private Sub textBlockComments_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles textBlockComments.KeyDown
If e.Key = Key.Enter Then
ButtonOK_Click(Nothing, Nothing)
Return
End If
If e.Key = Key.Escape Then
ButtonCancel_Click(Nothing, Nothing)
Return
End If
End Sub
Private Sub FileWindow_GotFocus(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.GotFocus
If Not _InitialFocus Then
Me.textBlockComments.Focus()
_InitialFocus = True
End If
End Sub
End Class
@@ -1,14 +1,14 @@
<navigation:Page x:Class="Disco.Silverlight.AttachmentUpload.Hidden"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="640" d:DesignHeight="480"
Title="Hidden Page">
<Grid x:Name="LayoutRoot">
</Grid>
</navigation:Page>
<navigation:Page x:Class="Disco.Silverlight.AttachmentUpload.Hidden"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="640" d:DesignHeight="480"
Title="Hidden Page">
<Grid x:Name="LayoutRoot">
</Grid>
</navigation:Page>
@@ -1,13 +1,13 @@
Partial Public Class Hidden
Inherits Page
Public Sub New()
InitializeComponent()
End Sub
'Executes when the user navigates to this page.
Protected Overrides Sub OnNavigatedTo(ByVal e As System.Windows.Navigation.NavigationEventArgs)
End Sub
End Class
Partial Public Class Hidden
Inherits Page
Public Sub New()
InitializeComponent()
End Sub
'Executes when the user navigates to this page.
Protected Overrides Sub OnNavigatedTo(ByVal e As System.Windows.Navigation.NavigationEventArgs)
End Sub
End Class
@@ -1,37 +1,37 @@
<navigation:Page x:Class="Disco.Silverlight.AttachmentUpload.WebCam"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
Title="WebCam Capture"
Style="{StaticResource PageStyle}">
<Grid x:Name="LayoutRoot">
<Grid x:Name="WebCamAccessHost" Visibility="Collapsed">
<Button x:Name="ButtonStartWebCam" Content="START WEBCAM" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="14, 8" />
</Grid>
<Grid x:Name="WebCamShow" Visibility="Collapsed">
<Rectangle x:Name="WebCamHost" />
<Button x:Name="ButtonCapture" Content="CAPTURE IMAGE" HorizontalAlignment="Center" VerticalAlignment="Bottom" Padding="14, 8" />
</Grid>
<Border x:Name="WebCamCaptured" Visibility="Collapsed" Width="600" Height="450" Background="#BBffe3cb" BorderBrush="#FFDB761D" BorderThickness="4" CornerRadius="4">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Rectangle x:Name="WebCamCapturedImage" Grid.ColumnSpan="4" Margin="14" />
<Button x:Name="ButtonCancel" Grid.Row="1" Grid.Column="0" Content="CANCEL" HorizontalAlignment="Center" VerticalAlignment="Bottom" Padding="14, 8" Margin="6" />
<TextBlock Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="10 0">Comments:</TextBlock>
<TextBox Grid.Row="1" Grid.Column="2" x:Name="TextBoxComments" Height="24" />
<Button x:Name="ButtonPost" Grid.Row="1" Grid.Column="3" Content="UPLOAD IMAGE" HorizontalAlignment="Center" VerticalAlignment="Bottom" Padding="14, 8" Margin="6" />
</Grid>
</Border>
</Grid>
<navigation:Page x:Class="Disco.Silverlight.AttachmentUpload.WebCam"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
Title="WebCam Capture"
Style="{StaticResource PageStyle}">
<Grid x:Name="LayoutRoot">
<Grid x:Name="WebCamAccessHost" Visibility="Collapsed">
<Button x:Name="ButtonStartWebCam" Content="START WEBCAM" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="14, 8" />
</Grid>
<Grid x:Name="WebCamShow" Visibility="Collapsed">
<Rectangle x:Name="WebCamHost" />
<Button x:Name="ButtonCapture" Content="CAPTURE IMAGE" HorizontalAlignment="Center" VerticalAlignment="Bottom" Padding="14, 8" />
</Grid>
<Border x:Name="WebCamCaptured" Visibility="Collapsed" Width="600" Height="450" Background="#BBffe3cb" BorderBrush="#FFDB761D" BorderThickness="4" CornerRadius="4">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Rectangle x:Name="WebCamCapturedImage" Grid.ColumnSpan="4" Margin="14" />
<Button x:Name="ButtonCancel" Grid.Row="1" Grid.Column="0" Content="CANCEL" HorizontalAlignment="Center" VerticalAlignment="Bottom" Padding="14, 8" Margin="6" />
<TextBlock Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="10 0">Comments:</TextBlock>
<TextBox Grid.Row="1" Grid.Column="2" x:Name="TextBoxComments" Height="24" />
<Button x:Name="ButtonPost" Grid.Row="1" Grid.Column="3" Content="UPLOAD IMAGE" HorizontalAlignment="Center" VerticalAlignment="Bottom" Padding="14, 8" Margin="6" />
</Grid>
</Border>
</Grid>
</navigation:Page>
@@ -1,143 +1,143 @@
Imports System.Windows.Media.Effects
Partial Public Class WebCam
Inherits Page
Public Sub New()
InitializeComponent()
End Sub
Private _CaptureSource As CaptureSource
Private _VideoBrush As VideoBrush
Private _CapturedImage As Imaging.WriteableBitmap
'Executes when the user navigates to this page.
Protected Overrides Sub OnNavigatedTo(ByVal e As System.Windows.Navigation.NavigationEventArgs)
If _CaptureSource Is Nothing Then
'' Init WebCam
_CaptureSource = New CaptureSource
_CaptureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice()
'' Get Best Quality Image
_CaptureSource.VideoCaptureDevice.DesiredFormat = (From f In _CaptureSource.VideoCaptureDevice.SupportedFormats Where f.PixelHeight <= 720
Order By (f.FramesPerSecond * f.PixelHeight * f.PixelWidth) Descending).FirstOrDefault()
AddHandler _CaptureSource.CaptureImageCompleted, AddressOf CaptureSource_CaptureImageCompleted
_VideoBrush = New VideoBrush()
_VideoBrush.Stretch = Stretch.Uniform
_VideoBrush.SetSource(_CaptureSource)
WebCamHost.Fill = _VideoBrush
End If
If (CaptureDeviceConfiguration.AllowedDeviceAccess) Then
ButtonStartWebCam_Click(Nothing, Nothing)
Else
WebCamAccessHost.Visibility = Windows.Visibility.Visible
WebCamCaptured.Visibility = Windows.Visibility.Collapsed
WebCamShow.Visibility = Windows.Visibility.Collapsed
End If
End Sub
Protected Overrides Sub OnNavigatedFrom(e As System.Windows.Navigation.NavigationEventArgs)
If _CaptureSource IsNot Nothing Then
If _CaptureSource.State = CaptureState.Started Then
_CaptureSource.Stop()
End If
End If
MyBase.OnNavigatedFrom(e)
End Sub
Private Sub ButtonStartWebCam_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonStartWebCam.Click
If (CaptureDeviceConfiguration.AllowedDeviceAccess OrElse CaptureDeviceConfiguration.RequestDeviceAccess()) Then
_CapturedImage = Nothing
Me.WebCamShow.Effect = Nothing
WebCamAccessHost.Visibility = Windows.Visibility.Collapsed
WebCamShow.Visibility = Windows.Visibility.Visible
WebCamCaptured.Visibility = Windows.Visibility.Collapsed
_CaptureSource.Start()
Me.ButtonCapture.Focus()
Else
WebCamAccessHost.Visibility = Windows.Visibility.Visible
WebCamCaptured.Visibility = Windows.Visibility.Collapsed
WebCamShow.Visibility = Windows.Visibility.Collapsed
End If
Me.IsEnabled = True
End Sub
Private Sub ButtonCapture_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonCapture.Click
_CaptureSource.CaptureImageAsync()
End Sub
Private Sub CaptureSource_CaptureImageCompleted(sender As Object, e As CaptureImageCompletedEventArgs)
Me.Dispatcher.BeginInvoke(Function()
ImageCaptured(e.Result)
Return Nothing
End Function)
End Sub
Private Sub ImageCaptured(image As Imaging.WriteableBitmap)
_CapturedImage = image
_CaptureSource.Stop()
Dim effect As New BlurEffect() With {.Radius = 15}
Me.WebCamShow.Effect = effect
Dim capturedImageBrush = New ImageBrush() With {.ImageSource = _CapturedImage, .Stretch = Stretch.Uniform}
Me.WebCamCapturedImage.Fill = capturedImageBrush
Me.TextBoxComments.Text = String.Empty
Me.WebCamCaptured.Visibility = Windows.Visibility.Visible
Me.TextBoxComments.Focus()
End Sub
Private Sub ButtonCancel_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonCancel.Click
ButtonStartWebCam_Click(Nothing, Nothing)
End Sub
Private Sub ButtonPost_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonPost.Click
Dim comments As String = Me.TextBoxComments.Text
If String.IsNullOrEmpty(comments) Then
MessageBox.Show("Please provide a Comment")
Me.TextBoxComments.Focus()
Else
Me.IsEnabled = False
System.Threading.ThreadPool.QueueUserWorkItem(Function()
App.MainPage.UploadAttachment(_CapturedImage.ToJpgStream, String.Format("CapturedImage-{0}.jpg", Now.ToString("yyyyMMdd-HHmmss")), "image/jpeg", comments)
Me.Dispatcher.BeginInvoke(Function()
ButtonStartWebCam_Click(Nothing, Nothing)
Return Nothing
End Function)
Return Nothing
End Function)
End If
End Sub
Private Sub TextBoxComments_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles TextBoxComments.KeyDown
If e.Key = Key.Enter Then
ButtonPost_Click(Nothing, Nothing)
Return
End If
If e.Key = Key.Escape Then
ButtonCancel_Click(Nothing, Nothing)
Return
End If
End Sub
End Class
Imports System.Windows.Media.Effects
Partial Public Class WebCam
Inherits Page
Public Sub New()
InitializeComponent()
End Sub
Private _CaptureSource As CaptureSource
Private _VideoBrush As VideoBrush
Private _CapturedImage As Imaging.WriteableBitmap
'Executes when the user navigates to this page.
Protected Overrides Sub OnNavigatedTo(ByVal e As System.Windows.Navigation.NavigationEventArgs)
If _CaptureSource Is Nothing Then
'' Init WebCam
_CaptureSource = New CaptureSource
_CaptureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice()
'' Get Best Quality Image
_CaptureSource.VideoCaptureDevice.DesiredFormat = (From f In _CaptureSource.VideoCaptureDevice.SupportedFormats Where f.PixelHeight <= 720
Order By (f.FramesPerSecond * f.PixelHeight * f.PixelWidth) Descending).FirstOrDefault()
AddHandler _CaptureSource.CaptureImageCompleted, AddressOf CaptureSource_CaptureImageCompleted
_VideoBrush = New VideoBrush()
_VideoBrush.Stretch = Stretch.Uniform
_VideoBrush.SetSource(_CaptureSource)
WebCamHost.Fill = _VideoBrush
End If
If (CaptureDeviceConfiguration.AllowedDeviceAccess) Then
ButtonStartWebCam_Click(Nothing, Nothing)
Else
WebCamAccessHost.Visibility = Windows.Visibility.Visible
WebCamCaptured.Visibility = Windows.Visibility.Collapsed
WebCamShow.Visibility = Windows.Visibility.Collapsed
End If
End Sub
Protected Overrides Sub OnNavigatedFrom(e As System.Windows.Navigation.NavigationEventArgs)
If _CaptureSource IsNot Nothing Then
If _CaptureSource.State = CaptureState.Started Then
_CaptureSource.Stop()
End If
End If
MyBase.OnNavigatedFrom(e)
End Sub
Private Sub ButtonStartWebCam_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonStartWebCam.Click
If (CaptureDeviceConfiguration.AllowedDeviceAccess OrElse CaptureDeviceConfiguration.RequestDeviceAccess()) Then
_CapturedImage = Nothing
Me.WebCamShow.Effect = Nothing
WebCamAccessHost.Visibility = Windows.Visibility.Collapsed
WebCamShow.Visibility = Windows.Visibility.Visible
WebCamCaptured.Visibility = Windows.Visibility.Collapsed
_CaptureSource.Start()
Me.ButtonCapture.Focus()
Else
WebCamAccessHost.Visibility = Windows.Visibility.Visible
WebCamCaptured.Visibility = Windows.Visibility.Collapsed
WebCamShow.Visibility = Windows.Visibility.Collapsed
End If
Me.IsEnabled = True
End Sub
Private Sub ButtonCapture_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonCapture.Click
_CaptureSource.CaptureImageAsync()
End Sub
Private Sub CaptureSource_CaptureImageCompleted(sender As Object, e As CaptureImageCompletedEventArgs)
Me.Dispatcher.BeginInvoke(Function()
ImageCaptured(e.Result)
Return Nothing
End Function)
End Sub
Private Sub ImageCaptured(image As Imaging.WriteableBitmap)
_CapturedImage = image
_CaptureSource.Stop()
Dim effect As New BlurEffect() With {.Radius = 15}
Me.WebCamShow.Effect = effect
Dim capturedImageBrush = New ImageBrush() With {.ImageSource = _CapturedImage, .Stretch = Stretch.Uniform}
Me.WebCamCapturedImage.Fill = capturedImageBrush
Me.TextBoxComments.Text = String.Empty
Me.WebCamCaptured.Visibility = Windows.Visibility.Visible
Me.TextBoxComments.Focus()
End Sub
Private Sub ButtonCancel_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonCancel.Click
ButtonStartWebCam_Click(Nothing, Nothing)
End Sub
Private Sub ButtonPost_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles ButtonPost.Click
Dim comments As String = Me.TextBoxComments.Text
If String.IsNullOrEmpty(comments) Then
MessageBox.Show("Please provide a Comment")
Me.TextBoxComments.Focus()
Else
Me.IsEnabled = False
System.Threading.ThreadPool.QueueUserWorkItem(Function()
App.MainPage.UploadAttachment(_CapturedImage.ToJpgStream, String.Format("CapturedImage-{0}.jpg", Now.ToString("yyyyMMdd-HHmmss")), "image/jpeg", comments)
Me.Dispatcher.BeginInvoke(Function()
ButtonStartWebCam_Click(Nothing, Nothing)
Return Nothing
End Function)
Return Nothing
End Function)
End If
End Sub
Private Sub TextBoxComments_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles TextBoxComments.KeyDown
If e.Key = Key.Enter Then
ButtonPost_Click(Nothing, Nothing)
Return
End If
If e.Key = Key.Escape Then
ButtonCancel_Click(Nothing, Nothing)
Return
End If
End Sub
End Class