Skip to content

Commit

Permalink
Added feature to open image on single click of mouse in posterPicker …
Browse files Browse the repository at this point in the history
…and professional mode.

Aware of count issue in Professional mode.
  • Loading branch information
DineshSolanki committed Aug 6, 2021
1 parent 9669250 commit 2b940b7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions FoliCon/ViewModels/PosterPickerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,22 @@ public class PosterPickerViewModel : BindableBase, IDialogAware
public ObservableCollection<DArtImageList> ImageUrl { get; set; }
public DelegateCommand StopSearchCommand { get; set; }
public DelegateCommand<object> PickCommand { get; set; }
public DelegateCommand<object> OpenImageCommand { get; set; }
#endregion
public PosterPickerViewModel()
{
ImageUrl = new ObservableCollection<DArtImageList>();
StopSearchCommand = new DelegateCommand(delegate { StopSearch = true; });
PickCommand = new DelegateCommand<object>(PickMethod);
OpenImageCommand = new DelegateCommand<object>(OpenImageMethod);
}

private void OpenImageMethod(object parameter)
{
var link = (string)parameter;
new ImageBrowser(Result.MediaType == MediaTypes.Game
? $"https://{ImageHelper.GetImageUrl(link, ImageSize.HD720)[2..]}"
: link).Show();
}

protected virtual void CloseDialog(string parameter)
Expand Down
10 changes: 10 additions & 0 deletions FoliCon/ViewModels/ProSearchResultViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public bool IsSearchFocused

public DelegateCommand SkipCommand { get; set; }
public DelegateCommand<object> PickCommand { get; set; }
public DelegateCommand<object> OpenImageCommand { get; set; }
public DelegateCommand SearchAgainCommand { get; set; }
public DelegateCommand StopSearchCommand { get; set; }

Expand All @@ -73,10 +74,19 @@ public ProSearchResultViewModel()
ImageUrl = new ObservableCollection<DArtImageList>();
StopSearchCommand = new DelegateCommand(delegate { StopSearch = true; });
PickCommand = new DelegateCommand<object>(PickMethod);
OpenImageCommand = new DelegateCommand<object>(OpenImageMethod);
SkipCommand = new DelegateCommand(SkipMethod);
SearchAgainCommand = new DelegateCommand(PrepareForSearch);
}

private void OpenImageMethod(object parameter)
{
var link = (string)parameter;
var browser = new ImageBrowser(link);
browser.IsFullScreen = true;
browser.Show();
}

private async void PrepareForSearch()
{
StopSearch = false;
Expand Down
4 changes: 4 additions & 0 deletions FoliCon/Views/PosterPicker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
Command="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Window}}, Path=DataContext.(viewModels:PosterPickerViewModel.PickCommand)}"
CommandParameter="{Binding Path=Tag, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Image}}}" />
<MouseBinding MouseAction="LeftClick"
Command="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Window}}, Path=DataContext.(viewModels:PosterPickerViewModel.OpenImageCommand)}"
CommandParameter="{Binding Path=Tag, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Image}}}" />
</Image.InputBindings>
</Image>
</DataTemplate>
Expand Down
4 changes: 4 additions & 0 deletions FoliCon/Views/ProSearchResult.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
Command="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Window}}, Path=DataContext.(viewModels:ProSearchResultViewModel.PickCommand)}"
CommandParameter="{Binding Path=Tag, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Image}}}" />
<MouseBinding MouseAction="LeftClick"
Command="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Window}}, Path=DataContext.(viewModels:ProSearchResultViewModel.OpenImageCommand)}"
CommandParameter="{Binding Path=Tag, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Image}}}" />
</Image.InputBindings>
</Image>
</DataTemplate>
Expand Down

0 comments on commit 2b940b7

Please sign in to comment.