Skip to content

Commit

Permalink
ПКМ на глвном окне для списния времени
Browse files Browse the repository at this point in the history
  • Loading branch information
Oshi41 committed Jul 16, 2019
1 parent c226094 commit a5db841
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 8 deletions.
1 change: 1 addition & 0 deletions TFSService/Gui/Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
<Compile Include="ViewModels\SafeExecutor.cs" />
<Compile Include="ViewModels\StatsViewModel.cs" />
<Compile Include="ViewModels\WorkItemVm.cs" />
<Compile Include="View\Controls\BindProxy.cs" />
<Compile Include="View\CreateTaksView.xaml.cs">
<DependentUpon>CreateTaksView.xaml</DependentUpon>
</Compile>
Expand Down
3 changes: 3 additions & 0 deletions TFSService/Gui/Helper/ObservableCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public bool IsExecuting

#region Constructors

public ObservableCommand(Action<object> action, Func<object, bool> predicat = null)
: base(action, predicat ?? (o => true)) { }

/// <summary>
/// Creates a new instance of <see cref="T:Mvvm.Commands.DelegateCommand" /> with the <see cref="T:System.Action" /> to
/// invoke on execution.
Expand Down
4 changes: 2 additions & 2 deletions TFSService/Gui/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,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("1.0.0.2")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyVersion("1.0.0.13")]
[assembly: AssemblyFileVersion("1.0.0.12")]
26 changes: 26 additions & 0 deletions TFSService/Gui/View/Controls/BindProxy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Gui.View.Controls
{
class BindProxy : Freezable
{
public static readonly DependencyProperty DataProperty = DependencyProperty.Register(
"Data", typeof(object), typeof(BindProxy), new PropertyMetadata(default(object)));

public object Data
{
get { return (object) GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}

protected override Freezable CreateInstanceCore()
{
return new BindProxy();
}
}
}
36 changes: 34 additions & 2 deletions TFSService/Gui/View/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
xmlns:p="clr-namespace:Gui.Properties"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:Gui.Behaviors"
xmlns:constants="clr-namespace:TfsAPI.Constants;assembly=TfsAPI"
xmlns:controls="clr-namespace:Gui.View.Controls"
mc:Ignorable="d"
Height="400" Width="600"
Title="{Binding Path=StatsViewModel.Name}">
Expand All @@ -17,6 +19,11 @@
<viewmodels:MainViewModel />
</Window.DataContext>

<Window.Resources>
<controls:BindProxy x:Key="BindProxy"
Data="{Binding}"/>
</Window.Resources>


<materialDesign:DialogHost IsOpen="{Binding Path=IsBusy}">

Expand All @@ -33,6 +40,7 @@
</materialDesign:DialogHost.DialogContent>

<Grid >

<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
Expand Down Expand Up @@ -60,7 +68,7 @@

<MenuItem Header="{x:Static p:Resources.AS_Actions}">
<MenuItem Header="{x:Static p:Resources.AS_WriteOffHours}"
Command="{Binding Path=WriteOffHorsCommand}"/>
Command="{Binding Path=WriteOffHoursCommand}"/>
<Separator/>
<MenuItem Header="{x:Static p:Resources.AS_CloseCompletedReviewes}"
Command="{Binding Path=CodeResponsesViewModel.CloseReviewes}" />
Expand Down Expand Up @@ -91,7 +99,30 @@
ScrollViewer.VerticalScrollBarVisibility="Auto"
HorizontalContentAlignment="Stretch"
HorizontalAlignment="Stretch"
ItemsSource="{Binding Path=StatsViewModel.MyItems}" />
ItemsSource="{Binding Path=StatsViewModel.MyItems}" >
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}"
BasedOn="{StaticResource {x:Type ListViewItem}}">

<Setter Property="ContextMenu" Value="{x:Null}"/>

<Style.Triggers>
<DataTrigger Binding="{Binding Path=Item.Type.Name}"
Value="{x:Static constants:WorkItemTypes.Task}">
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.AS_WriteOffHours}"
Command="{Binding Source={StaticResource BindProxy}, Path=Data.WriteOffHoursCommand}"
CommandParameter="{Binding}"/>
</ContextMenu>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
</ListView>

<materialDesign:Card Grid.Row="3">

Expand Down Expand Up @@ -129,6 +160,7 @@
</materialDesign:Card>

</Grid>

</materialDesign:DialogHost>


Expand Down
17 changes: 14 additions & 3 deletions TFSService/Gui/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MainViewModel()
ShowMonthlyCommand = new ObservableCommand(ShowMonthly);
UpdateCommand = ObservableCommand.FromAsyncHandler(Update);
SettingsCommand = new ObservableCommand(ShowSettings);
WriteOffHorsCommand = new ObservableCommand(OnWriteHours);
WriteOffHoursCommand = new ObservableCommand(OnWriteHours);

Init();
}
Expand Down Expand Up @@ -196,7 +196,7 @@ public bool IsBusy
/// <summary>
/// Принудительно списываю время
/// </summary>
public ICommand WriteOffHorsCommand { get; }
public ICommand WriteOffHoursCommand { get; }

#endregion

Expand Down Expand Up @@ -225,10 +225,21 @@ private void ShowSettings()
WindowManager.ShowDialog(vm, Resources.AS_Settings, 500);
}

private void OnWriteHours()
private void OnWriteHours(object obj)
{
var vm = new WriteOffHoursViewModel(_apiObserve);

if (obj is WorkItemVm toWriteOff)
{
var find = vm.ChooseTaskVm.Searcher.Items.FirstOrDefault(x => x.Item.Id == toWriteOff.Item.Id);

if (find != null)
{
vm.ChooseTaskVm.Searcher.Selected = find;
}
}


if (WindowManager.ShowDialog(vm, Resources.AS_ChooseWriteoffTask, 450, 240) == true)
{
var selected = vm.ChooseTaskVm.Searcher.Selected;
Expand Down
1 change: 0 additions & 1 deletion TFSService/TfsAPI/Interfaces/ITfsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public interface ITfsApi

/// <summary>
/// Возвращает кол-во часов, которое необходимо списать за день
/// TODO переменовать в GetCurrentCapacity либо перегрузить метод с передачей дат
/// </summary>
/// <returns></returns>
int GetCapacity();
Expand Down

0 comments on commit a5db841

Please sign in to comment.