Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions MainCore/UI/ViewModels/Tabs/Villages/BuildViewModel.cs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use "is null"?

Original file line number Diff line number Diff line change
Expand Up @@ -187,35 +187,39 @@ private async Task ResourceNormalHandler()
private async Task UpHandler()
{
if (!IsAccountPaused(AccountId)) return;
if (Jobs.SelectedItem == null) return;
var moveJobCommand = Locator.Current.GetService<MoveJobCommand>();
await moveJobCommand.Execute(AccountId, VillageId, Jobs, MoveEnums.Up);
}

private async Task DownHandler()
{
if (!IsAccountPaused(AccountId)) return;
if (Jobs.SelectedItem == null) return;
var moveJobCommand = Locator.Current.GetService<MoveJobCommand>();
await moveJobCommand.Execute(AccountId, VillageId, Jobs, MoveEnums.Down);
}

private async Task TopHandler()
{
if (!IsAccountPaused(AccountId)) return;
if (Jobs.SelectedItem == null) return;
var moveJobCommand = Locator.Current.GetService<MoveJobCommand>();
await moveJobCommand.Execute(AccountId, VillageId, Jobs, MoveEnums.Top);
}

private async Task BottomHandler()
{
if (!IsAccountPaused(AccountId)) return;
if (Jobs.SelectedItem == null) return;
var moveJobCommand = Locator.Current.GetService<MoveJobCommand>();
await moveJobCommand.Execute(AccountId, VillageId, Jobs, MoveEnums.Bottom);
}

private async Task DeleteHandler()
{
if (!IsAccountPaused(AccountId)) return;
if (!Jobs.IsSelected) return;
if (Jobs.SelectedItem == null) return;
var jobId = Jobs.SelectedItemId;

var deleteJobCommand = Locator.Current.GetService<DeleteJobCommand>();
Expand All @@ -237,7 +241,7 @@ private async Task ImportHandler()
var importCommand = Locator.Current.GetService<ImportCommand>();
await importCommand.Execute(AccountId, VillageId);
}

private async Task ExportHandler()
{
var path = _dialogService.SaveFileDialog();
Expand All @@ -261,4 +265,4 @@ private bool IsAccountPaused(AccountId accountId)
return true;
}
}
}
}
96 changes: 41 additions & 55 deletions WPFUI/Views/Tabs/Villages/BuildTab.xaml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any special reason for place them in bottom instead together with import and export buttons ?

Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,22 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Style="{DynamicResource Box}" Grid.Row="0">
<ListBox x:Name="QueueGrid" SelectionMode="Single" ItemTemplate="{DynamicResource ListBoxItem}" />
</Border>
<Border Style="{DynamicResource Box}" Grid.Row="1">
<ListBox x:Name="BuildingsGrid" SelectionMode="Single" ItemTemplate="{DynamicResource ListBoxBlackColorItem}">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem x:Name="UpgradeOneLevelButton" Header="Upgrade one level">
<MenuItem.Icon>
<materialDesign:PackIcon Width="{DynamicResource IconSize}" Height="{DynamicResource IconSize}" Kind="Hammer" />
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="UpgradeMaxLevelButton" Header="Upgrade max level">
<MenuItem.Icon>
<materialDesign:PackIcon Width="{DynamicResource IconSize}" Height="{DynamicResource IconSize}" Kind="Hammer" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
<ListBox x:Name="BuildingsGrid" SelectionMode="Single" ItemTemplate="{DynamicResource ListBoxBlackColorItem}" />
</Border>
<Grid Grid.Row="2" Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button x:Name="UpgradeOneLevelButton" Grid.Column="0" Content="Upgrade One Level" Margin="2" />
<Button x:Name="UpgradeMaxLevelButton" Grid.Column="1" Content="Upgrade Max Level" Margin="2" />
</Grid>
</Grid>
<Grid Grid.Column="2">
<Grid.RowDefinitions>
Expand Down Expand Up @@ -100,54 +94,46 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<Button x:Name="ImportButton" Grid.Column="0" Content="Import" Margin="5" />
<Button x:Name="ExportButton" Grid.Column="1" Content="Export" Margin="5" />
<Button x:Name="ImportButton" Grid.Column="0" Content="Import" Margin="5" />
<Button x:Name="ExportButton" Grid.Column="1" Content="Export" Margin="5" />
</Grid>
<Border Grid.Row="1" Style="{DynamicResource Box}">
<ListBox x:Name="JobsGrid" SelectionMode="Single" ItemTemplate="{DynamicResource ListBoxColorItem}">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem x:Name="TopButton" Header="Top">
<MenuItem.Icon>
<materialDesign:PackIcon Width="{DynamicResource IconSize}" Height="{DynamicResource IconSize}" Kind="ArrowUpBold" />
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="UpButton" Header="Up">
<MenuItem.Icon>
<materialDesign:PackIcon Width="{DynamicResource IconSize}" Height="{DynamicResource IconSize}" Kind="ArrowUp" />
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="DownButton" Header="Down">
<MenuItem.Icon>
<materialDesign:PackIcon Width="{DynamicResource IconSize}" Height="{DynamicResource IconSize}" Kind="ArrowDown" />
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="BottomButton" Header="Bottom">
<MenuItem.Icon>
<materialDesign:PackIcon Width="{DynamicResource IconSize}" Height="{DynamicResource IconSize}" Kind="ArrowDownBold" />
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="DeleteButton" Header="Delete">
<MenuItem.Icon>
<materialDesign:PackIcon Width="{DynamicResource IconSize}" Height="{DynamicResource IconSize}" Kind="Delete" />
</MenuItem.Icon>
</MenuItem>
<MenuItem x:Name="DeleteAllButton" Header="Delete all">
<MenuItem.Icon>
<materialDesign:PackIcon Width="{DynamicResource IconSize}" Height="{DynamicResource IconSize}" Kind="DeleteForever" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
<ListBox x:Name="JobsGrid" SelectionMode="Single" ItemTemplate="{DynamicResource ListBoxColorItem}" />
</Border>
<Grid Grid.Row="2" Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Button x:Name="TopButton" Grid.Column="0" Grid.Row="0" Margin="2" ToolTip="Top">
<materialDesign:PackIcon Kind="ArrowUpBold" />
</Button>
<Button x:Name="UpButton" Grid.Column="1" Grid.Row="0" Margin="2" ToolTip="Up">
<materialDesign:PackIcon Kind="ArrowUp" />
</Button>
<Button x:Name="DownButton" Grid.Column="2" Grid.Row="0" Margin="2" ToolTip="Down">
<materialDesign:PackIcon Kind="ArrowDown" />
</Button>
<Button x:Name="BottomButton" Grid.Column="3" Grid.Row="0" Margin="2" ToolTip="Bottom">
<materialDesign:PackIcon Kind="ArrowDownBold" />
</Button>
<Button x:Name="DeleteButton" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="2" Content="Delete" />
<Button x:Name="DeleteAllButton" Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="2" Margin="2" Content="Delete All" />
</Grid>
</Grid>
</Grid>
</v:BuildTabBase>
</v:BuildTabBase>
8 changes: 4 additions & 4 deletions WPFUI/Views/Tabs/Villages/BuildTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ public BuildTab()
this.Bind(ViewModel, vm => vm.Jobs.SelectedIndex, v => v.JobsGrid.SelectedIndex).DisposeWith(d);

this.OneWayBind(ViewModel, vm => vm.Queue.Items, v => v.QueueGrid.ItemsSource).DisposeWith(d);
this.Bind(ViewModel, vm => vm.Jobs.SelectedItem, v => v.QueueGrid.SelectedItem).DisposeWith(d);
this.Bind(ViewModel, vm => vm.Jobs.SelectedIndex, v => v.QueueGrid.SelectedIndex).DisposeWith(d);
this.Bind(ViewModel, vm => vm.Queue.SelectedItem, v => v.QueueGrid.SelectedItem).DisposeWith(d);
this.Bind(ViewModel, vm => vm.Queue.SelectedIndex, v => v.QueueGrid.SelectedIndex).DisposeWith(d);

this.BindCommand(ViewModel, vm => vm.UpgradeOneLevel, v => v.UpgradeOneLevelButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.UpgradeMaxLevel, v => v.UpgradeMaxLevelButton).DisposeWith(d);

this.BindCommand(ViewModel, vm => vm.Import, v => v.ImportButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.Export, v => v.ExportButton).DisposeWith(d);

this.BindCommand(ViewModel, vm => vm.Top, v => v.TopButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.Up, v => v.UpButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.Down, v => v.DownButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.Top, v => v.TopButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.Bottom, v => v.BottomButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.Delete, v => v.DeleteButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.DeleteAll, v => v.DeleteAllButton).DisposeWith(d);
Expand All @@ -55,4 +55,4 @@ public BuildTab()
});
}
}
}
}