Skip to content

Commit

Permalink
host devices can now be edited
Browse files Browse the repository at this point in the history
  • Loading branch information
Venomalia committed Oct 17, 2021
1 parent ffce81f commit aa8e280
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Controls/TexturePicker.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@
</Style>
</Button.Style>
</Button>
<Button HorizontalAlignment="Left" Width="20" Grid.Column="0" Margin="0,0,2,0" Command="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Window},Path=EditHostDevicesCommand}" CommandParameter="{Binding}">
<Button.Style>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource blank}">
<Setter Property="Content" >
<Setter.Value>
<Path Fill="Sienna" Data="{DynamicResource Geometry.HostDevices}" Style="{StaticResource DropShadow}"/>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Content">
<Setter.Value>
<Path Fill="LightGray" Data="{DynamicResource Geometry.HostDevices}" Style="{StaticResource DropShadow}"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</Grid>
<TextBox Grid.Row="1" Padding="2" Margin="1" HorizontalAlignment="Center" MinWidth="50" Text="{Binding TextureHash, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" BorderBrush="{Binding HashProperties.IsValid, Converter={StaticResource BoolToBrushConverter}}"/>
</Grid>
Expand Down
25 changes: 25 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ private DynamicInputPackViewModel InputPack
set
{
value.CheckImagePaths();
_edit_host_devices_window?.Close();
DataContext = value;
((PanZoomViewModel)PanZoom.DataContext).InputPack = value;
UnsavedChanges = false;
Expand All @@ -48,6 +49,7 @@ private DynamicInputPackViewModel InputPack

private Window _edit_emulated_devices_window;
private Window _edit_default_host_devices_window;
private Window _edit_host_devices_window;
private Window _edit_metadata_window;

private void ExportToLocation_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -84,6 +86,29 @@ private void EditDefaultHostDevices_Click(object sender, RoutedEventArgs e)
_edit_default_host_devices_window.Show();
}

public ICommand EditHostDevicesCommand => new ViewModels.Commands.RelayCommand<Data.DynamicInputTexture>(EditHostDevicesS);

private void EditHostDevicesS(Data.DynamicInputTexture texture)
{
_edit_host_devices_window?.Close();

var user_control = new HostDeviceKeyViewModel { HostDevices = new ViewModels.Commands.UICollection<Data.HostDevice>(texture.HostDevices) };
texture.HostDevices = user_control.HostDevices;

_edit_host_devices_window = new Window
{
Title = "Editing Host Devices of " + texture.TextureHash,
ResizeMode = ResizeMode.CanResize,
SizeToContent = SizeToContent.Manual,
Owner = Application.Current.MainWindow,
Top = this.Top + 50, Left = this.Left + 70,
Width = 620, Height = 550, MinWidth = 500, MinHeight = 400,
Content = new Controls.EditHostDevices { DataContext = user_control }
};

_edit_host_devices_window.Show();
}

private void EditEmulatedDevices_Click(object sender, RoutedEventArgs e)
{
_edit_emulated_devices_window?.Close();
Expand Down

0 comments on commit aa8e280

Please sign in to comment.