diff --git a/SmartPanel.xaml b/SmartPanel.xaml index 8773b596311bf80c206fd902cfc809cd51818253..df280808e449e02b10d5949b314125a2abc0df04 100644 --- a/SmartPanel.xaml +++ b/SmartPanel.xaml @@ -379,6 +379,11 @@ Height="80" Width="80" Grid.Column="0" + Stroke="White" + StrokeThickness="3" + PointerEntered="_selectedAccountAvatarContainer__PointerEntered" + PointerExited="_selectedAccountAvatarContainer__PointerExited" + PointerReleased="_selectedAccountAvatarContainer__PointerReleased" Margin="5"> <Ellipse.Fill> <ImageBrush @@ -386,6 +391,24 @@ ImageSource="Assets\TESTS\contactAvatar.png"/> </Ellipse.Fill> </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=""> + </TextBlock> <StackPanel Grid.Column="1" VerticalAlignment="Bottom"> <TextBlock x:Name="_selectedAccountName_" diff --git a/SmartPanel.xaml.cpp b/SmartPanel.xaml.cpp index caf31bd847a5a6b67976f75ec267d45547d4dbe1..a93d42eedf3e2eebfd871c2ccecd412e409dfa85 100644 --- a/SmartPanel.xaml.cpp +++ b/SmartPanel.xaml.cpp @@ -206,17 +206,20 @@ void RingClientUWP::Views::SmartPanel::setMode(RingClientUWP::Views::SmartPanel: if (mode == RingClientUWP::Views::SmartPanel::Mode::Normal) { _rowRingTxtBx_->Height = 40; _selectedAccountAvatarContainer_->Height = 80; + _shaderPhotoboothIcon_->Height = 80; _selectedAccountAvatarColumn_->Width = 90; _selectedAccountRow_->Height = 90; } else { _rowRingTxtBx_->Height = 0; _selectedAccountAvatarContainer_->Height = 50; + _shaderPhotoboothIcon_->Height = 50; _selectedAccountAvatarColumn_->Width = 60; _selectedAccountRow_->Height = 60; } _selectedAccountAvatarContainer_->Width = _selectedAccountAvatarContainer_->Height; + _shaderPhotoboothIcon_->Width = _shaderPhotoboothIcon_->Height; _settingsTBtn_->IsChecked = false; _accountsMenuButton_->IsChecked = false; _shareMenuButton_->IsChecked = false; @@ -858,3 +861,66 @@ Object ^ RingClientUWP::Views::CollapseEmptyString::ConvertBack(Object ^ value, 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; +} diff --git a/SmartPanel.xaml.h b/SmartPanel.xaml.h index 2419ee70ca199b7c286f4e79e1f138f50529ef55..326725500449186f8f34cdd62a2b6fa78285483e 100644 --- a/SmartPanel.xaml.h +++ b/SmartPanel.xaml.h @@ -133,6 +133,9 @@ private: void _passwordBoxAccountCreationCheck__PasswordChanged(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ 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 _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 diff --git a/Styles.xaml b/Styles.xaml index 8dc34756c5ec02c2278802b53b908ae847bd8080..ddcba01c3c9e9defff362779997cfecf9cadf6ae 100644 --- a/Styles.xaml +++ b/Styles.xaml @@ -117,6 +117,19 @@ <Setter Property="Foreground" Value="Black"/> </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" TargetType="Button"> <Setter Property="Width"