Skip to content

Commit

Permalink
různé opravy
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Mar 26, 2024
1 parent bc9eab3 commit e14df3d
Show file tree
Hide file tree
Showing 10 changed files with 260 additions and 89 deletions.
49 changes: 37 additions & 12 deletions ZZZO/ZZZO.Common/API/HlasovaniZastupitele.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

namespace ZZZO.Common.API;

public class HlasovaniZastupitele
public class HlasovaniZastupitele : ObservableObject
{
private VolbaHlasovani _volba = VolbaHlasovani.ZdrzujeSe;
private Zastupitel _zastupitel;

#region Enumy

public enum VolbaHlasovani
Expand Down Expand Up @@ -47,26 +50,48 @@ public string Poznamka

public VolbaHlasovani Volba
{
get;
set;
} = VolbaHlasovani.ZdrzujeSe;
get => _volba;
set
{
if (value == _volba)
{
return;
}

_volba = value;
OnPropertyChanged();
}
}

[JsonIgnore]
public List<VolbaHlasovani> Volby
{
get => new List<VolbaHlasovani>
{
VolbaHlasovani.Pro,
VolbaHlasovani.Proti,
VolbaHlasovani.ZdrzujeSe
};
get => Enum.GetValues<VolbaHlasovani>().ToList();
}

[JsonProperty("Zastupitel", IsReference = true)]
public Zastupitel Zastupitel
{
get;
set;
get => _zastupitel;
set
{
if (Equals(value, _zastupitel))
{
return;
}

_zastupitel = value;

_zastupitel.PropertyChanged += (sender, args) =>
{
OnPropertyChanged(nameof(JmenoPrijmeniZastupitele));
OnPropertyChanged(nameof(Poznamka));
};

OnPropertyChanged();
OnPropertyChanged(nameof(JmenoPrijmeniZastupitele));
OnPropertyChanged(nameof(Poznamka));
}
}

#endregion
Expand Down
8 changes: 7 additions & 1 deletion ZZZO/ZZZO.Common/API/Usneseni.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ public class Usneseni : ObservableObject
[JsonIgnore]
public bool JeSchvaleno
{
get => VolbyZastupitelu.Count(vol => vol.Volba == HlasovaniZastupitele.VolbaHlasovani.Pro) > VolbyZastupitelu.Count / 2;
get
{
var pritomni = VolbyZastupitelu.Where(zas => zas.Zastupitel.JePritomen);

return pritomni.Count(zas => zas.Volba == HlasovaniZastupitele.VolbaHlasovani.Pro) >
pritomni.Count() / 2;
}
}

public string Text
Expand Down
5 changes: 4 additions & 1 deletion ZZZO/ZZZO/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ protected override void OnStartup(StartupEventArgs e)
base.OnStartup(e);

// CefSharp.
Cef.Initialize(new CefSettings());
Cef.Initialize(new CefSettings
{
Locale = CultureInfo.CurrentCulture.IetfLanguageTag
});

Core.PropertyChanged += (sender, args) =>
{
Expand Down
2 changes: 1 addition & 1 deletion ZZZO/ZZZO/Controls/BasicInfo.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<materialDesign:PackIcon VerticalAlignment="Center" Kind="Badge" />
<TextBlock Margin="5,0,0,0">Vybrat znak</TextBlock>
</WrapPanel>
</Button>
</Button>
<Button VerticalAlignment="Center"
CommandParameter="{Binding Core.Zasedani.NazevObce}"
Command="{Binding ShowCityLogosCmd}">
Expand Down
2 changes: 1 addition & 1 deletion ZZZO/ZZZO/Controls/ProgramEntry.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</ComboBox.ItemTemplate>
</ComboBox>

<local:Resolution DataContext="{Binding ElementName=CmbUsneseni, Path=SelectedValue}"
<local:Resolution DataContext="{Binding ResolutionViewModel}"
IsEnabled="{Binding ElementName=CmbUsneseni, Path=SelectedValue, Converter={StaticResource NotNullConverter}}" />
</StackPanel>
</GroupBox>
Expand Down
143 changes: 72 additions & 71 deletions ZZZO/ZZZO/Controls/Resolution.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
xmlns:converters="clr-namespace:ZZZO.Converters"
xmlns:extensions="clr-namespace:ZZZO.Extensions"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:viewModels="clr-namespace:ZZZO.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:ResolutionViewModel}"
d:DesignHeight="450"
d:DesignWidth="800">
<UserControl.Resources>
Expand All @@ -22,87 +24,86 @@
<StackPanel Orientation="Vertical">
<CheckBox Name="CbBereNaVedomi"
Content="ZO bere na vědomí"
IsChecked="{Binding ZoBereNaVedomi, UpdateSourceTrigger=PropertyChanged}" />
IsChecked="{Binding Usneseni.ZoBereNaVedomi, UpdateSourceTrigger=PropertyChanged}" />
<TextBox materialDesign:HintAssist.Hint="Text usnesení"
MinLines="4"
TextWrapping="Wrap"
AcceptsReturn="True"
IsEnabled="{Binding ElementName=CbBereNaVedomi, Path=IsChecked, Converter={StaticResource CollapseOnTrueConverter}}"
Text="{Binding Text, UpdateSourceTrigger=PropertyChanged}" />
Text="{Binding Usneseni.Text, UpdateSourceTrigger=PropertyChanged}" />
<GroupBox Header="Hlasování">
<StackPanel Orientation="Vertical">
<DataGrid materialDesign:DataGridAssist.CellPadding="4 2 2 2"
materialDesign:DataGridAssist.ColumnHeaderPadding="4 2 2 2"
Height="250"
CanUserDeleteRows="False"
IsSynchronizedWithCurrentItem="True"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserSortColumns="False"
CanUserResizeRows="false"
CanUserAddRows="False"
AutoGenerateColumns="False"
ItemsSource="{Binding VolbyZastupitelu}"
extensions:DataGridExtensions.DefaultSorting="A:JmenoPrijmeniZastupitele">
<DataGrid.RowStyle>
<Style BasedOn="{StaticResource MaterialDesignDataGridRow}"
TargetType="{x:Type DataGridRow}">
<Setter Property="IsEnabled"
Value="{Binding Zastupitel.JePritomen}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Zastupitel.JePritomen}"
Value="False">
<Setter Property="Foreground"
Value="{DynamicResource SecondaryHueLightBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<WrapPanel Orientation="Vertical">
<DataGrid materialDesign:DataGridAssist.CellPadding="4 2 2 2"
materialDesign:DataGridAssist.ColumnHeaderPadding="4 2 2 2"
CanUserDeleteRows="False"
IsSynchronizedWithCurrentItem="True"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserSortColumns="False"
CanUserResizeRows="false"
CanUserAddRows="False"
AutoGenerateColumns="False"
ItemsSource="{Binding Usneseni.VolbyZastupitelu}"
extensions:DataGridExtensions.DefaultSorting="A:JmenoPrijmeniZastupitele">
<DataGrid.RowStyle>
<Style BasedOn="{StaticResource MaterialDesignDataGridRow}"
TargetType="{x:Type DataGridRow}">
<Setter Property="IsEnabled"
Value="{Binding Zastupitel.JePritomen}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Zastupitel.JePritomen}"
Value="False">
<Setter Property="Foreground"
Value="{DynamicResource SecondaryHueLightBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>

<DataGrid.Columns>
<DataGridTextColumn ElementStyle="{StaticResource StyleGridTextCenterVertical}" IsReadOnly="True"
Width="Auto"
Header="Zastupitel"
Binding="{Binding JmenoPrijmeniZastupitele}" />
<DataGridTemplateColumn Header="Volba"
Width="Auto">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Padding="2 1 1 2"
Margin="0"
IsEnabled="{Binding Path=Zastupitel.JePritomen}"
ItemsSource="{Binding Volby}"
SelectedValue="{Binding Volba, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource EnumConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn ElementStyle="{StaticResource StyleGridTextCenterVertical}"
IsReadOnly="True"
Width="Auto"
Header="Poznámka"
Binding="{Binding Poznamka}" />
</DataGrid.Columns>
</DataGrid>
<DataGrid.Columns>
<DataGridTextColumn ElementStyle="{StaticResource StyleGridTextCenterVertical}" IsReadOnly="True"
Width="Auto"
Header="Zastupitel"
Binding="{Binding JmenoPrijmeniZastupitele}" />
<DataGridTemplateColumn Header="Volba"
Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Padding="2 1 1 2"
Margin="0"
IsEnabled="{Binding Path=Zastupitel.JePritomen}"
ItemsSource="{Binding Volby}"
SelectedValue="{Binding Volba, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource EnumConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn ElementStyle="{StaticResource StyleGridTextCenterVertical}"
IsReadOnly="True"
Width="*"
Header="Poznámka"
Binding="{Binding Poznamka, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" />
</DataGrid.Columns>
</DataGrid>

<WrapPanel Grid.Row="1"
Orientation="Horizontal">
<Button Command="{Binding AddProgramEntryCmd}"
ToolTip="Všichni jsou PRO">
<materialDesign:PackIcon Kind="CheckAll" />
</Button>
<WrapPanel Grid.Row="1"
Orientation="Horizontal">
<Button Command="{Binding AllAgreeCmd}"
ToolTip="Všichni jsou PRO">
<materialDesign:PackIcon Kind="CheckAll" />
</Button>

<Button Command="{Binding RemoveProgramEntryCmd}"
ToolTip="Všichni jsou PROTI">
<materialDesign:PackIcon Kind="CloseBoxMultiple" />
</Button>
<Button Command="{Binding AllDisagreeCmd}"
ToolTip="Všichni jsou PROTI">
<materialDesign:PackIcon Kind="CloseBoxMultiple" />
</Button>
</WrapPanel>
</WrapPanel>
</StackPanel>
</GroupBox>
</StackPanel>
</UserControl>
20 changes: 20 additions & 0 deletions ZZZO/ZZZO/ViewModels/ProgramEntryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class ProgramEntryViewModel : ViewModelBase
private Usneseni _chosenUsneseni;
private ZzzoCore _core;
private BodProgramu _programEntry;
private ResolutionViewModel _resolutionViewModel;

#endregion

Expand All @@ -21,6 +22,21 @@ public ICommand AddUsneseniCmd
get;
}

public ResolutionViewModel ResolutionViewModel
{
get => _resolutionViewModel;
set
{
if (Equals(value, _resolutionViewModel))
{
return;
}

_resolutionViewModel = value;
OnPropertyChanged();
}
}

public Usneseni ChosenUsneseni
{
get => _chosenUsneseni;
Expand All @@ -32,6 +48,9 @@ public Usneseni ChosenUsneseni
}

_chosenUsneseni = value;

ResolutionViewModel.Usneseni = _chosenUsneseni;

OnPropertyChanged();
}
}
Expand Down Expand Up @@ -78,6 +97,7 @@ public ICommand RemoveUsneseniCmd
public ProgramEntryViewModel(ZzzoCore core)
{
Core = core;
ResolutionViewModel = new ResolutionViewModel(core);

AddUsneseniCmd = new RelayCommand(obj => AddUsneseni(), obj => true);
RemoveUsneseniCmd = new RelayCommand(obj => RemoveUsneseni(), obj => ChosenUsneseni != null);
Expand Down
1 change: 0 additions & 1 deletion ZZZO/ZZZO/ViewModels/ProgramViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public bool ChosenLastProgramEntry
}

public BodProgramu ChosenProgramEntry

{
get => _chosenProgramEntry;
set
Expand Down
Loading

0 comments on commit e14df3d

Please sign in to comment.