Skip to content

Commit

Permalink
Merge pull request #75 from nooperation/develop
Browse files Browse the repository at this point in the history
Develop to master
  • Loading branch information
nooperation authored Mar 4, 2018
2 parents ea3545f + 6d94d6d commit d1ced45
Show file tree
Hide file tree
Showing 33 changed files with 183 additions and 156 deletions.
1 change: 0 additions & 1 deletion AtlasView/App.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Application x:Class="AtlasView.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:AtlasView"
StartupUri="Views/MainWindow.xaml">
<Application.Resources>

Expand Down
8 changes: 1 addition & 7 deletions AtlasView/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;

namespace AtlasView
{
Expand Down
2 changes: 1 addition & 1 deletion AtlasView/Commands/CommandChangePage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ event EventHandler ICommand.CanExecuteChanged

public CommandChangePage(AtlasViewModel viewModel)
{
this._viewModel = viewModel;
_viewModel = viewModel;
}

bool ICommand.CanExecute(object parameter)
Expand Down
2 changes: 1 addition & 1 deletion AtlasView/Commands/CommandNextPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ event EventHandler ICommand.CanExecuteChanged

public CommandNextPage(AtlasViewModel viewModel)
{
this._viewModel = viewModel;
_viewModel = viewModel;
}

bool ICommand.CanExecute(object parameter)
Expand Down
2 changes: 1 addition & 1 deletion AtlasView/Commands/CommandPreviousPAge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ event EventHandler ICommand.CanExecuteChanged

public CommandPreviousPage(AtlasViewModel viewModel)
{
this._viewModel = viewModel;
_viewModel = viewModel;
}

bool ICommand.CanExecute(object parameter)
Expand Down
6 changes: 1 addition & 5 deletions AtlasView/Commands/CommandSearch.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using AtlasView.ViewModels;

Expand All @@ -20,7 +16,7 @@ event EventHandler ICommand.CanExecuteChanged

public CommandSearch(AtlasViewModel viewModel)
{
this._viewModel = viewModel;
_viewModel = viewModel;
}

bool ICommand.CanExecute(object parameter)
Expand Down
2 changes: 0 additions & 2 deletions AtlasView/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

Expand Down
14 changes: 6 additions & 8 deletions AtlasView/ViewModels/AtlasViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
using System.Linq;
using System.Net;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using LibSanBag;
using LibSanBag.FileResources;
using Newtonsoft.Json;
using AtlasView.Commands;
using AtlasView.Models;
Expand Down Expand Up @@ -145,8 +143,7 @@ public ExperienceView SelectedItem

private async void OnSelectedItemChanged()
{
var experienceViewModel = SelectedItem?.DataContext as ExperienceViewModel;
if (experienceViewModel == null)
if (!(SelectedItem?.DataContext is ExperienceViewModel experienceViewModel))
{
return;
}
Expand All @@ -167,8 +164,9 @@ private async void OnSelectedItemChanged()

using (var manifestStream = new MemoryStream(downloadManifestResult.Bytes))
{
CurrentAtlasView = new ManifestResourceView();
CurrentAtlasView.DataContext = viewModel;
CurrentAtlasView = new ManifestResourceView {
DataContext = viewModel
};
viewModel.InitFromStream(manifestStream);
}
}
Expand Down Expand Up @@ -206,7 +204,7 @@ public void Search(string query, int page=1)
var request = WebRequest.Create($"https://atlas.sansar.com/api/experiences?perPage={perPage}&q={query}&page={page}");
var response = request.GetResponse();

var responseJson = "";
string responseJson;
using (var sr = new StreamReader(response.GetResponseStream()))
{
responseJson = sr.ReadToEnd();
Expand All @@ -216,7 +214,7 @@ public void Search(string query, int page=1)
var tempSearchResults = new List<ExperienceView>();
foreach (var experienceData in results.Data)
{
tempSearchResults.Add(new Views.ExperienceView()
tempSearchResults.Add(new ExperienceView
{
DataContext = new ExperienceViewModel(experienceData)
});
Expand Down
7 changes: 1 addition & 6 deletions AtlasView/ViewModels/ExperienceViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using AtlasView.Models;

namespace AtlasView.ViewModels
Expand Down
12 changes: 4 additions & 8 deletions AtlasView/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using AtlasView.Views;

namespace AtlasView.ViewModels
{
Expand All @@ -31,8 +25,10 @@ public MainWindowViewModel()

try
{
CurrentView = new Views.AtlasView();
CurrentView.DataContext = new AtlasViewModel();
CurrentView = new Views.AtlasView
{
DataContext = new AtlasViewModel()
};
}
catch (Exception ex)
{
Expand Down
7 changes: 3 additions & 4 deletions AtlasView/Views/AtlasView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AtlasView.Views"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="711.458">
<Grid>
Expand All @@ -17,9 +16,9 @@
<ColumnDefinition Width="128px"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0">Search</Label>
<TextBox Grid.Column="1" Text="{Binding Path=SearchQuery, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Button Grid.Column="2" Command="{Binding Path=CommandSearch}" CommandParameter="{Binding Path=SearchQuery}" IsDefault="True">Search</Button>
<Grid Grid.Row="1" Grid.ColumnSpan="3">
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=SearchQuery, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalContentAlignment="Center" />
<Button Grid.Row="0" Grid.Column="2" Command="{Binding Path=CommandSearch}" CommandParameter="{Binding Path=SearchQuery}" IsDefault="True">Search</Button>
<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
Expand Down
15 changes: 1 addition & 14 deletions AtlasView/Views/AtlasView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace AtlasView.Views
{
Expand Down
1 change: 0 additions & 1 deletion AtlasView/Views/ExperienceView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AtlasView.Views"
mc:Ignorable="d"
d:DesignHeight="220" d:DesignWidth="220">
<Grid>
Expand Down
15 changes: 1 addition & 14 deletions AtlasView/Views/ExperienceView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace AtlasView.Views
{
Expand Down
1 change: 0 additions & 1 deletion AtlasView/Views/LoadingView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AtlasView.Views"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
Expand Down
15 changes: 1 addition & 14 deletions AtlasView/Views/LoadingView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace AtlasView.Views
{
Expand Down
1 change: 0 additions & 1 deletion AtlasView/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
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:local="clr-namespace:AtlasView.Views"
mc:Ignorable="d"
Title="AtlasView" Height="625" Width="1342.172">
<Grid>
Expand Down
22 changes: 2 additions & 20 deletions AtlasView/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
using LibSanBag;
using Microsoft.Win32;
using AtlasView.ViewModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using AtlasView.ViewModels;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;

namespace AtlasView.Views
{
Expand All @@ -29,7 +11,7 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
this.DataContext = new MainWindowViewModel();
DataContext = new MainWindowViewModel();
}
}
}
2 changes: 1 addition & 1 deletion CommonUI/Commands/CommandCancelExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ event EventHandler ICommand.CanExecuteChanged

public CommandCancelExport(ExportViewModel viewModel)
{
this._viewModel = viewModel;
_viewModel = viewModel;
}

bool ICommand.CanExecute(object parameter)
Expand Down
14 changes: 8 additions & 6 deletions CommonUI/Commands/CommandManifestExportSelected.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Linq;
using System.Windows.Input;
using static LibSanBag.FileResources.ManifestResource;
Expand All @@ -18,20 +19,21 @@ event EventHandler ICommand.CanExecuteChanged

public CommandManifestExportSelected(ManifestResourceViewModel viewModel)
{
this._viewModel = viewModel;
_viewModel = viewModel;
}

bool ICommand.CanExecute(object parameter)
{
return true;
return parameter is IList;
}

void ICommand.Execute(object parameter)
{
var items = parameter as System.Collections.IList;
var manifestEntries = items.Cast<ManifestEntry>().ToList();

_viewModel.ExportRecords(manifestEntries);
if (parameter is IList items)
{
var manifestEntries = items.Cast<ManifestEntry>().ToList();
_viewModel.ExportRecords(manifestEntries);
}
}
}
}
8 changes: 2 additions & 6 deletions CommonUI/Commands/CommandPauseSound.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using CommonUI.ViewModels.ResourceViewModels;

namespace CommonUI.Commands
{
public class CommandPauseSound : ICommand
{
private SoundResourceViewModel _viewModel;
private readonly SoundResourceViewModel _viewModel;

event EventHandler ICommand.CanExecuteChanged
{
Expand All @@ -20,7 +16,7 @@ event EventHandler ICommand.CanExecuteChanged

public CommandPauseSound(SoundResourceViewModel viewModel)
{
this._viewModel = viewModel;
_viewModel = viewModel;
}

bool ICommand.CanExecute(object parameter)
Expand Down
8 changes: 2 additions & 6 deletions CommonUI/Commands/CommandPlaySound.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using CommonUI.ViewModels.ResourceViewModels;

namespace CommonUI.Commands
{
public class CommandPlaySound : ICommand
{
private SoundResourceViewModel _viewModel;
private readonly SoundResourceViewModel _viewModel;

event EventHandler ICommand.CanExecuteChanged
{
Expand All @@ -20,7 +16,7 @@ event EventHandler ICommand.CanExecuteChanged

public CommandPlaySound(SoundResourceViewModel viewModel)
{
this._viewModel = viewModel;
_viewModel = viewModel;
}

bool ICommand.CanExecute(object parameter)
Expand Down
Loading

0 comments on commit d1ced45

Please sign in to comment.