Skip to content

Commit

Permalink
opravy
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Apr 4, 2024
1 parent 8f90c00 commit a747b6a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ZZZO/ZZZO.Common/API/BodProgramu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum TypBoduProgramu
[Description("Schvalování programu zasedání")]
SchvaleniProgramu = 1,

[Description("Bod zasedání")]
[Description("Řádný bod zasedání")]
BodZasedani = 2,

[Description("Doplněný bod zasedání")]
Expand Down
37 changes: 20 additions & 17 deletions ZZZO/ZZZO.Common/Generators/GeneratorHtml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Documents;
using System.Xml;
using ZZZO.Common.API;

Expand Down Expand Up @@ -58,6 +57,11 @@ public override string Title

#region Metody

public static string GetStyle(string styleName)
{
return File.ReadAllText(Path.Combine(Constants.PathsAndFiles.AppStylesFolder, styleName));
}

protected override byte[] GenerateDoWork(Zasedani zas, IProgress<int> progress, object param)
{
progress.Report(1);
Expand Down Expand Up @@ -122,13 +126,11 @@ private void GenerateBody(XmlElement html, Zasedani zas, IProgress<int> progress
BodProgramu schvaleniProgramu = zas.Program.BodyProgramu.FirstOrDefault(prog => prog.Typ == BodProgramu.TypBoduProgramu.SchvaleniProgramu);
BodProgramu schvaleniZapisovatele = zas.Program.BodyProgramu.FirstOrDefault(prog => prog.Typ == BodProgramu.TypBoduProgramu.SchvaleniZapisOver);


if (schvaleniProgramu?.Usneseni == null || schvaleniProgramu.Usneseni.Count == 0)
{
throw new Exception("v programu chybí bod a usnesení pro schválení programu jako takového");
}


if (schvaleniZapisovatele?.Usneseni == null || schvaleniZapisovatele.Usneseni.Count == 0)
{
throw new Exception("v programu chybí bod a usnesení pro schválení zapisovatele/ověřovatelů");
Expand Down Expand Up @@ -174,12 +176,16 @@ private void GenerateBody(XmlElement html, Zasedani zas, IProgress<int> progress
body.AppendElem("p").InnerText =
$"Nepřítomní zastupitelé: {(string.IsNullOrWhiteSpace(nepritJmena) ? "-" : nepritJmena + ".")}";

body.AppendElem("p").InnerText = $"Zasedání ZO navštívilo {zas.PocetHostu} " +
$"{Sklonovat("host", "hosté", "hostů", zas.PocetHostu)} z řad veřejnosti.";
body.AppendElem("p").InnerText =
$"Zasedání ZO {Sklonovat("navštívil", "navštívili", "navštívilo", zas.PocetHostu)} {zas.PocetHostu} " +
$"{Sklonovat("host", "hosté", "hostů", zas.PocetHostu)} z řad veřejnosti.";

body.AppendElem("p").InnerText =
$"Zasedání ZO řídil pan {ridici.Jmeno} {ridici.Prijmeni}.";

body.AppendElem("p").InnerText = $"Všechna hlasování na tomto zasedání ZO {zas.NazevObce} " +
"jsou veřejná a zastupitelé hlasují zdvižením ruky.";

progress.Report(30);

///
Expand All @@ -200,7 +206,7 @@ private void GenerateBody(XmlElement html, Zasedani zas, IProgress<int> progress
schvaleniZapisovatele.Usneseni.First(),
lastResolutionNumber,
"Hlasování o navrženém zapisovateli a ověřovatelích zápisu");

progress.Report(40);

///
Expand All @@ -211,9 +217,7 @@ private void GenerateBody(XmlElement html, Zasedani zas, IProgress<int> progress
GenerateProgramEntries(body, bodyProgramu.ToList());

body.AppendElem("p").InnerText = $"Řídící osoba zasedání ZO {zas.NazevObce} navrhla schválit výše " +
$"uvedený návrh programu. " +
$"Všechna hlasování na tomto zasedání ZO {zas.NazevObce} " +
"jsou veřejná a zastupitelé hlasují zdvižením ruky.";
$"uvedený návrh programu.";

GenerateResolution(
body,
Expand Down Expand Up @@ -369,6 +373,7 @@ private string GenerateResolution(
}

int countOfPresentVoters = zas.Zastupitele.Count(vol => vol.JePritomen);

List<HlasovaniZastupitele> choiceFor = resolution.VolbyZastupitelu.Where(vol =>
vol.Zastupitel.JePritomen &&
vol.Volba == HlasovaniZastupitele.VolbaHlasovani.Pro).ToList();
Expand All @@ -381,15 +386,18 @@ private string GenerateResolution(
vol.Zastupitel.JePritomen &&
vol.Volba == HlasovaniZastupitele.VolbaHlasovani.ZdrzujeSe).ToList();

string choiceForStr = choiceFor.Count() + ((choiceFor.Any() && choiceFor.Count < countOfPresentVoters)
string choiceForStr = choiceFor.Count() + (choiceFor.Any() && choiceFor.Count < countOfPresentVoters
? $" ({string.Join(", ", choiceFor.Select(ch => ch.Zastupitel.Jmeno + " " + ch.Zastupitel.Prijmeni))})"
: string.Empty);
string choiceAgainstStr = choiceAgainst.Count() + ((choiceAgainst.Any() && choiceAgainst.Count < countOfPresentVoters)

string choiceAgainstStr = choiceAgainst.Count() + (choiceAgainst.Any() && choiceAgainst.Count < countOfPresentVoters
? $" ({string.Join(", ", choiceAgainst.Select(ch => ch.Zastupitel.Jmeno + " " + ch.Zastupitel.Prijmeni))})"
: string.Empty);
string choiceDontKnowStr = choiceDontKnow.Count() + ((choiceDontKnow.Any() && choiceDontKnow.Count < countOfPresentVoters)

string choiceDontKnowStr = choiceDontKnow.Count() + (choiceDontKnow.Any() && choiceDontKnow.Count < countOfPresentVoters
? $" ({string.Join(", ", choiceDontKnow.Select(ch => ch.Zastupitel.Jmeno + " " + ch.Zastupitel.Prijmeni))})"
: string.Empty);

bool accepted = choiceFor.Count() > countOfPresentVoters / 2;

XmlElement div = root.AppendElem("div").AppendClass("resolution-vote-box").AppendClass(accepted ? "success" : "failure");
Expand All @@ -413,11 +421,6 @@ private string GenerateResolution(
return accepted ? generatedResolutionTitle : null;
}

public static string GetStyle(string styleName)
{
return File.ReadAllText(Path.Combine(Constants.PathsAndFiles.AppStylesFolder, styleName));
}

private string Sklonovat(string jednaPolozka, string dvePolozky, string vicePolozek, int pocet)
{
switch (pocet)
Expand Down
50 changes: 50 additions & 0 deletions ZZZO/ZZZO/Controls/Generator.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows.Controls;
using System.Windows.Input;

namespace ZZZO.Controls
{
Expand All @@ -9,6 +10,55 @@ public partial class Generator : UserControl
public Generator()
{
InitializeComponent();

WebBrowser.PreviewMouseWheel += BrowserPreviewMouseWheel;
WebBrowser.KeyUp += BrowserKeyUp;
}

#endregion

#region Metody

private void BrowserKeyUp(object sender, KeyEventArgs e)
{
if (Keyboard.Modifiers != ModifierKeys.Control)
{
return;
}

if (e.Key == Key.Add)
{
WebBrowser.ZoomInCommand.Execute(null);
}

if (e.Key == Key.Subtract)
{
WebBrowser.ZoomOutCommand.Execute(null);
}

if (e.Key == Key.NumPad0)
{
WebBrowser.ZoomLevel = 0;
}
}

private void BrowserPreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (Keyboard.Modifiers != ModifierKeys.Control)
{
return;
}

if (e.Delta > 0)
{
WebBrowser.ZoomInCommand.Execute(null);
}
else
{
WebBrowser.ZoomOutCommand.Execute(null);
}

e.Handled = true;
}

#endregion
Expand Down
8 changes: 4 additions & 4 deletions ZZZO/ZZZO/Controls/Program.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
<Button
Style="{StaticResource PopupButton}"
Command="{Binding AddProgramEntryCmd}"
CommandParameter="{x:Static api:BodProgramu+TypBoduProgramu.BodZasedani}"
Content="Řádny bod programu" />
CommandParameter="{x:Static api:BodProgramu+TypBoduProgramu.DoplnenyBodZasedani}"
Content="Doplněný bod programu" />
<Button
Style="{StaticResource PopupButton}"
Command="{Binding AddProgramEntryCmd}"
CommandParameter="{x:Static api:BodProgramu+TypBoduProgramu.DoplnenyBodZasedani}"
Content="Doplněný bod programu" />
CommandParameter="{x:Static api:BodProgramu+TypBoduProgramu.BodZasedani}"
Content="Řádny bod programu" />
</StackPanel>
</materialDesign:PopupBox>

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 @@ -35,7 +35,7 @@
TextWrapping="Wrap"
Visibility="{Binding ProgramEntry.JeEditovatelny, Converter={StaticResource BooleanToVisibilityConverter}}"
Text="{Binding ProgramEntry.Nadpis, UpdateSourceTrigger=PropertyChanged}" />
<CheckBox Content="Jedná se o předchozího bodu programu"
<CheckBox Content="Jedná se o podbod předchozího bodu programu"
Visibility="{Binding ProgramEntry.JeEditovatelny, Converter={StaticResource BooleanToVisibilityConverter}}"
IsChecked="{Binding ProgramEntry.JePodbod, UpdateSourceTrigger=PropertyChanged}" />
<GroupBox Header="Text bodu programu"
Expand Down

0 comments on commit a747b6a

Please sign in to comment.