Skip to content
Snippets Groups Projects
Commit f3ad2c07 authored by Nicolas Jager's avatar Nicolas Jager
Browse files

profil : allows to take a picture by clicking on the avatar

Change-Id: I8da2ece803a90981a1ccea352df9f6f2ed084535
Tuleap: #1250
parent 0a7b77df
No related branches found
No related tags found
No related merge requests found
...@@ -379,6 +379,11 @@ ...@@ -379,6 +379,11 @@
Height="80" Height="80"
Width="80" Width="80"
Grid.Column="0" Grid.Column="0"
Stroke="White"
StrokeThickness="3"
PointerEntered="_selectedAccountAvatarContainer__PointerEntered"
PointerExited="_selectedAccountAvatarContainer__PointerExited"
PointerReleased="_selectedAccountAvatarContainer__PointerReleased"
Margin="5"> Margin="5">
<Ellipse.Fill> <Ellipse.Fill>
<ImageBrush <ImageBrush
...@@ -386,6 +391,24 @@ ...@@ -386,6 +391,24 @@
ImageSource="Assets\TESTS\contactAvatar.png"/> ImageSource="Assets\TESTS\contactAvatar.png"/>
</Ellipse.Fill> </Ellipse.Fill>
</Ellipse> </Ellipse>
<Ellipse
x:Name="_shaderPhotoboothIcon_"
Visibility="Collapsed"
Height="80"
Width="80"
Grid.Column="0"
IsHitTestVisible="False"
Fill="Black"
Opacity="0.3"
Margin="5">
</Ellipse>
<TextBlock x:Name="_photoboothIcon_"
Grid.Column="0"
Visibility="Collapsed"
IsHitTestVisible="False"
Style="{StaticResource TextSegoeStyle-Centered-40pt-white}"
Text="&#xE722;">
</TextBlock>
<StackPanel Grid.Column="1" <StackPanel Grid.Column="1"
VerticalAlignment="Bottom"> VerticalAlignment="Bottom">
<TextBlock x:Name="_selectedAccountName_" <TextBlock x:Name="_selectedAccountName_"
......
...@@ -206,17 +206,20 @@ void RingClientUWP::Views::SmartPanel::setMode(RingClientUWP::Views::SmartPanel: ...@@ -206,17 +206,20 @@ void RingClientUWP::Views::SmartPanel::setMode(RingClientUWP::Views::SmartPanel:
if (mode == RingClientUWP::Views::SmartPanel::Mode::Normal) { if (mode == RingClientUWP::Views::SmartPanel::Mode::Normal) {
_rowRingTxtBx_->Height = 40; _rowRingTxtBx_->Height = 40;
_selectedAccountAvatarContainer_->Height = 80; _selectedAccountAvatarContainer_->Height = 80;
_shaderPhotoboothIcon_->Height = 80;
_selectedAccountAvatarColumn_->Width = 90; _selectedAccountAvatarColumn_->Width = 90;
_selectedAccountRow_->Height = 90; _selectedAccountRow_->Height = 90;
} }
else { else {
_rowRingTxtBx_->Height = 0; _rowRingTxtBx_->Height = 0;
_selectedAccountAvatarContainer_->Height = 50; _selectedAccountAvatarContainer_->Height = 50;
_shaderPhotoboothIcon_->Height = 50;
_selectedAccountAvatarColumn_->Width = 60; _selectedAccountAvatarColumn_->Width = 60;
_selectedAccountRow_->Height = 60; _selectedAccountRow_->Height = 60;
} }
_selectedAccountAvatarContainer_->Width = _selectedAccountAvatarContainer_->Height; _selectedAccountAvatarContainer_->Width = _selectedAccountAvatarContainer_->Height;
_shaderPhotoboothIcon_->Width = _shaderPhotoboothIcon_->Height;
_settingsTBtn_->IsChecked = false; _settingsTBtn_->IsChecked = false;
_accountsMenuButton_->IsChecked = false; _accountsMenuButton_->IsChecked = false;
_shareMenuButton_->IsChecked = false; _shareMenuButton_->IsChecked = false;
...@@ -858,3 +861,66 @@ Object ^ RingClientUWP::Views::CollapseEmptyString::ConvertBack(Object ^ value, ...@@ -858,3 +861,66 @@ Object ^ RingClientUWP::Views::CollapseEmptyString::ConvertBack(Object ^ value,
RingClientUWP::Views::CollapseEmptyString::CollapseEmptyString() RingClientUWP::Views::CollapseEmptyString::CollapseEmptyString()
{} {}
void RingClientUWP::Views::SmartPanel::_selectedAccountAvatarContainer__PointerEntered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
{
_photoboothIcon_->Visibility = Windows::UI::Xaml::Visibility::Visible;
_shaderPhotoboothIcon_->Visibility = Windows::UI::Xaml::Visibility::Visible;
}
void RingClientUWP::Views::SmartPanel::_selectedAccountAvatarContainer__PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
{
CameraCaptureUI^ cameraCaptureUI = ref new CameraCaptureUI();
cameraCaptureUI->PhotoSettings->Format = CameraCaptureUIPhotoFormat::Png;
cameraCaptureUI->PhotoSettings->CroppedSizeInPixels = Size(100, 100);
create_task(cameraCaptureUI->CaptureFileAsync(CameraCaptureUIMode::Photo))
.then([this](StorageFile^ photoFile)
{
if (photoFile != nullptr) {
// maybe it would be possible to move some logics to the style sheet
auto brush = ref new ImageBrush();
auto circle = ref new Ellipse();
circle->Height = 80; // TODO : use some global constant when ready
circle->Width = 80;
auto path = photoFile->Path;
auto uri = ref new Windows::Foundation::Uri(path);
auto bitmapImage = ref new Windows::UI::Xaml::Media::Imaging::BitmapImage();
bitmapImage->UriSource = uri;
StorageFolder^ localfolder = ApplicationData::Current->LocalFolder;
String^ profilefolder = ".profile";
create_task(localfolder->CreateFolderAsync(profilefolder,
Windows::Storage::CreationCollisionOption::OpenIfExists))
.then([=](StorageFolder^ copytofolder) {
try {
create_task(photoFile->CopyAsync(copytofolder))
.then([=](StorageFile^ copiedfile) {
copiedfile->RenameAsync("profile_image.png",
Windows::Storage::NameCollisionOption::ReplaceExisting);
});
}
catch (Exception^ e) {
RingDebug::instance->print("Exception while saving profile image");
}
});
Configuration::UserPreferences::instance->PREF_PROFILE_PHOTO = true;
Configuration::UserPreferences::instance->save();
brush->ImageSource = bitmapImage;
_selectedAccountAvatar_->ImageSource = bitmapImage;
}
});
}
void RingClientUWP::Views::SmartPanel::_selectedAccountAvatarContainer__PointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
{
_photoboothIcon_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
_shaderPhotoboothIcon_->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
}
...@@ -133,6 +133,9 @@ private: ...@@ -133,6 +133,9 @@ private:
void _passwordBoxAccountCreationCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void _passwordBoxAccountCreationCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
void _accountTypeComboBox__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e); void _accountTypeComboBox__SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
void _ringAliasTextBox__TextChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::TextChangedEventArgs^ e); void _ringAliasTextBox__TextChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::TextChangedEventArgs^ e);
void _selectedAccountAvatarContainer__PointerEntered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void _selectedAccountAvatarContainer__PointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
void _selectedAccountAvatarContainer__PointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
}; };
} }
} }
\ No newline at end of file
...@@ -117,6 +117,19 @@ ...@@ -117,6 +117,19 @@
<Setter Property="Foreground" <Setter Property="Foreground"
Value="Black"/> Value="Black"/>
</Style> </Style>
<Style x:Key="TextSegoeStyle-Centered-40pt-white"
TargetType="TextBlock">
<Setter Property="FontFamily"
Value="Segoe MDL2 Assets"/>
<Setter Property="FontSize"
Value="40"/>
<Setter Property="HorizontalAlignment"
Value="Center"/>
<Setter Property="VerticalAlignment"
Value="Center"/>
<Setter Property="Foreground"
Value="White"/>
</Style>
<Style x:Key="ButtonStyle1" <Style x:Key="ButtonStyle1"
TargetType="Button"> TargetType="Button">
<Setter Property="Width" <Setter Property="Width"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment