-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Required Zones Expanded window
- Loading branch information
Showing
7 changed files
with
169 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<Window x:Class="EasyZoneBuilder.GUI.RequiredZonesExpanded" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
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:EasyZoneBuilder.GUI" | ||
mc:Ignorable="d" | ||
Style="{DynamicResource CustomWindowStyle}" | ||
Title="Required Zones" Height="300" Width="450" ResizeMode="CanResizeWithGrip" Icon="/Resources/main.ico" WindowStartupLocation="CenterOwner"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="*"></RowDefinition> | ||
<RowDefinition Height="35"></RowDefinition> | ||
</Grid.RowDefinitions> | ||
<DataGrid x:Name="AssetGrid" | ||
Grid.Row="0" | ||
AutoGenerateColumns="False" | ||
SelectionMode="Extended" | ||
Margin="5"> | ||
<DataGrid.Columns> | ||
<DataGridTextColumn Header="AssetType" | ||
Binding="{Binding Key.Value}" | ||
Width="75" | ||
IsReadOnly="True" /> | ||
<DataGridTextColumn Header="Name" | ||
Binding="{Binding Key.Key}" | ||
Width="*" | ||
IsReadOnly="True" /> | ||
<DataGridTextColumn Header="Zone" | ||
Binding="{Binding Value}" | ||
Width="125" | ||
IsReadOnly="True" /> | ||
|
||
|
||
</DataGrid.Columns> | ||
<DataGrid.ContextMenu> | ||
<ContextMenu> | ||
<MenuItem Header="Delete" | ||
x:Name="DeleteContextMenuItem" | ||
Click="DeleteContextMenuItem_Click"> | ||
<MenuItem.Icon> | ||
<Image> | ||
<Image.Source> | ||
<BitmapImage UriSource="Resources/trash.ico" /> | ||
</Image.Source> | ||
</Image> | ||
</MenuItem.Icon> | ||
</MenuItem> | ||
</ContextMenu> | ||
</DataGrid.ContextMenu> | ||
</DataGrid> | ||
<Button | ||
x:Name="FindRequiredZonesBtn" | ||
Grid.Row="1" | ||
Margin="5" | ||
Content="Find Required Zones" | ||
Click="FindRequiredZonesBtn_Click"> | ||
|
||
</Button> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using EasyZoneBuilder.Core; | ||
using System.Collections.Generic; | ||
using System.Windows; | ||
|
||
namespace EasyZoneBuilder.GUI | ||
{ | ||
/// <summary> | ||
/// Interaction logic for RequiredZonesExpanded.xaml | ||
/// </summary> | ||
public partial class RequiredZonesExpanded : Window | ||
{ | ||
public RequiredZonesExpanded() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private async void FindRequiredZonesBtn_Click( object sender, RoutedEventArgs e ) | ||
{ | ||
if ( Mod.Instance.selectedMod.SelectedItem is Core.Mod sMod ) | ||
{ | ||
FindRequiredZonesBtn.IsEnabled = false; | ||
object oldContent = FindRequiredZonesBtn.Content; | ||
FindRequiredZonesBtn.Content = "Finding..."; | ||
await DependencyGraph.DefaultInstance.Pull(); | ||
RefreshAssetGrid(); | ||
FindRequiredZonesBtn.Content = oldContent; | ||
FindRequiredZonesBtn.IsEnabled = true; | ||
} | ||
} | ||
|
||
private void RefreshAssetGrid() | ||
{ | ||
if ( Mod.Instance.selectedMod.SelectedItem is Core.Mod sMod ) | ||
{ | ||
Dictionary<string, DependencyGraph.RequiredZonesEntryInfo> reqZones = DependencyGraph.DefaultInstance.GetRequiredZones(sMod.CSV); | ||
AssetGrid.ItemsSource = ConvertToNewDictionary(reqZones); | ||
} | ||
} | ||
|
||
private Dictionary<KeyValuePair<string, AssetType>, string> ConvertToNewDictionary( Dictionary<string, DependencyGraph.RequiredZonesEntryInfo> originalDict ) | ||
{ | ||
Dictionary<KeyValuePair<string, AssetType>, string> newDict = new Dictionary<KeyValuePair<string, AssetType>, string>(); | ||
|
||
foreach ( KeyValuePair<string, DependencyGraph.RequiredZonesEntryInfo> kvp in originalDict ) | ||
{ | ||
foreach ( KeyValuePair<string, AssetType> asset in kvp.Value.assets ) | ||
{ | ||
newDict.Add(asset, kvp.Key); | ||
} | ||
} | ||
return newDict; | ||
} | ||
|
||
|
||
private void DeleteContextMenuItem_Click( object sender, RoutedEventArgs e ) | ||
{ | ||
if ( Mod.Instance.selectedMod.SelectedItem is Core.Mod sMod && AssetGrid.SelectedItems.Count > 0 ) | ||
{ | ||
foreach ( object item in AssetGrid.SelectedItems ) | ||
{ | ||
sMod.CSV.Remove(((KeyValuePair<KeyValuePair<string, AssetType>, string>)item).Key.Key); | ||
} | ||
sMod.CSV.Push(); | ||
Mod.Instance.ReadModCsvBtn_Click(sender, e); | ||
RefreshAssetGrid(); | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.