Skip to content

Commit

Permalink
release: merge v2.4.3 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rodriada000 committed Nov 23, 2019
2 parents 75d6437 + 4bc2497 commit bc83645
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 38 deletions.
48 changes: 48 additions & 0 deletions SessionMapSwitcherWPF/Classes/DateTimeComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using SessionModManagerCore.ViewModels;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SessionModManagerWPF.Classes
{
/// <summary>
/// Class to compare DateTime for sorting <see cref="AssetViewModel.UpdatedDate"/>
/// </summary>
/// <remarks>
/// reference: https://stackoverflow.com/questions/4734055/c-sharp-icomparer-if-datetime-is-null-then-should-be-sorted-to-the-bottom-no
/// </remarks>
public class DateTimeComparer : IComparer
{
public ListSortDirection SortDirection = ListSortDirection.Ascending;

public int Compare(DateTime? x, DateTime? y)
{
DateTime nx = x ?? DateTime.MinValue;
DateTime ny = y ?? DateTime.MinValue;

return nx.CompareTo(ny);
}

public int Compare(object x, object y)
{
AssetViewModel ax = (x as AssetViewModel);
AssetViewModel ay = (y as AssetViewModel);

DateTime.TryParse(ax?.UpdatedDate, out DateTime dx);
DateTime.TryParse(ay?.UpdatedDate, out DateTime dy);

if (SortDirection == ListSortDirection.Ascending)
{
return Compare(dx, dy);
}
else
{
return Compare(dy, dx);
}
}
}
}
4 changes: 2 additions & 2 deletions SessionMapSwitcherWPF/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.2.0")]
[assembly: AssemblyFileVersion("2.4.2.0")]
[assembly: AssemblyVersion("2.4.3.0")]
[assembly: AssemblyFileVersion("2.4.3.0")]
1 change: 1 addition & 0 deletions SessionMapSwitcherWPF/SessionModManagerWPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Classes\DateTimeComparer.cs" />
<Compile Include="Classes\RegistryHelper.cs" />
<Compile Include="UI\AssetStoreUserControl.xaml.cs">
<DependentUpon>AssetStoreUserControl.xaml</DependentUpon>
Expand Down
20 changes: 17 additions & 3 deletions SessionMapSwitcherWPF/UI/AssetStoreUserControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using SessionMapSwitcherCore.ViewModels;
using SessionModManagerCore.ViewModels;
using SessionModManagerWPF.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -90,9 +91,22 @@ private void Sort(string sortBy, ListSortDirection direction)
}

dataView.SortDescriptions.Clear();
SortDescription sd = new SortDescription(sortBy, direction);
dataView.SortDescriptions.Add(sd);
dataView.Refresh();
(dataView as ListCollectionView).CustomSort = null;

if (sortBy == nameof(AssetViewModel.UpdatedDate))
{
DateTimeComparer sorter = new DateTimeComparer()
{
SortDirection = direction
};
(dataView as ListCollectionView).CustomSort = sorter;
}
else
{
SortDescription sd = new SortDescription(sortBy, direction);
dataView.SortDescriptions.Add(sd);
dataView.Refresh();
}
}

private void lstAssets_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down
81 changes: 48 additions & 33 deletions SessionMapSwitcherWPF/UI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
IsEnabled="{Binding InputControlsEnabled}"
Content="Import Map"
Click="BtnImportMap_Click"
Margin="10,0,0,0"
Margin="5,0,0,0"
Padding="5,1,5,1"
FontSize="11">
<Button.ContextMenu>
Expand All @@ -193,15 +193,15 @@


<ListBox x:Name="lstMaps"
Grid.Row="1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
ToolTip="Righ-click a map for additional options"
MinWidth="300" MaxWidth="350"
ScrollViewer.CanContentScroll="False"
Margin="2,1,2,5"
ItemsSource="{Binding FilteredAvailableMaps}"
ItemContainerStyle="{StaticResource MapListItem}"
ContextMenuOpening="ContextMenu_ContextMenuOpening">
Grid.Row="1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
ToolTip="Righ-click a map for additional options"
MinWidth="300" MaxWidth="350"
ScrollViewer.CanContentScroll="False"
Margin="4,1,2,5"
ItemsSource="{Binding FilteredAvailableMaps}"
ItemContainerStyle="{StaticResource MapListItem}"
ContextMenuOpening="ContextMenu_ContextMenuOpening">
<ListBox.ContextMenu>
<ContextMenu x:Name="mainContextMenu">
<MenuItem x:Name="menuSecondMapToLoad" Header="Set Selected Map To Load Next..." Click="menuSecondMapToLoad_Click" ToolTipService.ShowOnDisabled="True" ToolTipService.ShowDuration="8000"/>
Expand All @@ -219,17 +219,33 @@
</ListBox.ContextMenu>
</ListBox>

<WrapPanel Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0,0,0,3">
<Label Content="Currently Loaded Map:"
Padding="3,0,0,0"
FontSize="12"
FontWeight="SemiBold"/>
<StackPanel Grid.Row="2"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Margin="3,0,0,3">

<WrapPanel>
<Label Content="Currently Loaded Map:"
Padding="3,0,0,0"
FontSize="12"
FontWeight="SemiBold"/>

<TextBlock x:Name="txtLoadedMap"
Padding="5,0,0,0"
FontSize="12"
Text="{Binding CurrentlyLoadedMapName, FallbackValue='GrindCity_Yeah'}"/>
</WrapPanel>

<CheckBox x:Name="chkLoadSecondMap"
Padding="3,0,0,0"
FontSize="11"
VerticalContentAlignment="Center"
Margin="1,5,0,0"
ToolTip="Check this to load a different map after the game starts so you can switch to other maps after leaving the apartment. Right-click a map to set the second map to load."
IsChecked="{Binding LoadSecondMapIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Content="{Binding SecondMapCheckboxText, FallbackValue='Load Second Map After Start (Map Name)'}"/>
</StackPanel>

<TextBlock x:Name="txtLoadedMap"
Padding="5,0,0,0"
FontSize="12"
Text="{Binding CurrentlyLoadedMapName, FallbackValue='GrindCity_Yeah'}"/>
</WrapPanel>
</Grid>

</GroupBox>
Expand Down Expand Up @@ -318,10 +334,9 @@
Grid.Row="2" Grid.ColumnSpan="2"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Margin="10,0,0,50"
Margin="10,0,0,45"
Text="{Binding UserMessage, FallbackValue='Map Loaded!'}"
TextWrapping="Wrap"
MaxWidth="600"
FontSize="14"/>

<TextBlock x:Name="lblHintMessage"
Expand All @@ -336,17 +351,17 @@
FontSize="11"/>

<Button x:Name="btnLoadMap"
Grid.Row="2" Grid.ColumnSpan="2"
Content="{Binding LoadMapButtonText, FallbackValue='Load Map'}"
ToolTip="Load selected map from the list"
Style="{StaticResource MainButtonStyle}"
IsEnabled="{Binding InputControlsEnabled}"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
FontSize="16"
Margin="0,0,125,30"
Padding="5,0,5,0"
Click="BtnLoadMap_Click" Height="33"/>
Grid.Row="2" Grid.ColumnSpan="2"
Content="{Binding LoadMapButtonText, FallbackValue='Load Map'}"
ToolTip="Load selected map from the list"
Style="{StaticResource MainButtonStyle}"
IsEnabled="{Binding InputControlsEnabled}"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
FontSize="16"
Margin="0,0,125,30"
Padding="5,0,5,0"
Click="BtnLoadMap_Click" Height="33"/>

<Button x:Name="btnStartGame"
Grid.Row="2" Grid.ColumnSpan="2"
Expand Down

0 comments on commit bc83645

Please sign in to comment.