Skip to content
Snippets Groups Projects
Commit 7a606e6f authored by Sandra Borst's avatar Sandra Borst
Browse files

Merge branch 'sessionScreen' into 'develop'

uses now the values from the settings; frontend with the changing UI of the...

See merge request !22
parents c6907a4a 8d3722b6
Branches
No related tags found
1 merge request!22uses now the values from the settings; frontend with the changing UI of the...
Showing
with 165 additions and 42 deletions
No preview for this file type
No preview for this file type
...@@ -151,7 +151,31 @@ namespace InnoLabProjektDektopApp ...@@ -151,7 +151,31 @@ namespace InnoLabProjektDektopApp
// Ereignis-Handler für den "Start"-Button // Ereignis-Handler für den "Start"-Button
private void StartButton_Click(object sender, RoutedEventArgs e) private void StartButton_Click(object sender, RoutedEventArgs e)
{ {
MessageBox.Show("Focus session started!", "Start", MessageBoxButton.OK, MessageBoxImage.Information); // Werte auslesen
int focusPeriod = int.Parse(((ComboBoxItem)FocusPeriodComboBox.SelectedItem)?.Content.ToString().Split()[0] ?? "50");
int breakPeriod = int.Parse(((ComboBoxItem)BreakPeriodComboBox.SelectedItem)?.Content.ToString().Split()[0] ?? "10");
int cycles = int.Parse(((ComboBoxItem)CyclesComboBox.SelectedItem)?.Content.ToString() ?? "4");
string distractionMode = ((ComboBoxItem)DistractionModeComboBox.SelectedItem)?.Content.ToString() ?? "Full-blocking mode";
string mascotVisible = ((ComboBoxItem)MascotVisibilityComboBox.SelectedItem)?.Content.ToString() ?? "Yes";
bool wordsOfAffirmation = WordsOfAffirmationCheckBox.IsChecked ?? false;
bool insultingWords = InsultingWordsCheckBox.IsChecked ?? false;
// Anzeige der Werte in einer MessageBox
MessageBox.Show($"Focus Period: {focusPeriod} minutes\n" +
$"Break Period: {breakPeriod} minutes\n" +
$"Cycles: {cycles}\n" +
$"Distraction Mode: {distractionMode}\n" +
$"Mascot Visible: {mascotVisible}\n" +
$"Words of Affirmation: {wordsOfAffirmation}\n" +
$"Insulting Words: {insultingWords}",
"Current Settings",
MessageBoxButton.OK,
MessageBoxImage.Information);
var sessionScreen = new Session(focusPeriod, breakPeriod, cycles, distractionMode, mascotVisible, wordsOfAffirmation, insultingWords);
sessionScreen.Show();
this.Close();
} }
} }
} }
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
<Button Content="Distractions" Style="{StaticResource TopMenuButon}" HorizontalAlignment="Right" Margin="0,4,20,0" VerticalAlignment="Top" Height="26" Width="80"/> <Button Content="Distractions" Style="{StaticResource TopMenuButon}" HorizontalAlignment="Right" Margin="0,4,20,0" VerticalAlignment="Top" Height="26" Width="80"/>
<TextBlock Name ="Title" Text="Focus Session 0 of 0" Style="{StaticResource Heading1}" HorizontalAlignment="Center" Height="42" TextWrapping="Wrap" VerticalAlignment="Top" Width="442" Margin="0,133,0,0"/> <TextBlock Name ="Title" Text="Focus Session 0 of 0" Style="{StaticResource Heading1}" HorizontalAlignment="Center" Height="42" TextWrapping="Wrap" VerticalAlignment="Top" Width="442" Margin="0,133,0,0"/>
<TextBlock Name="Clock" Text="00:00" Style="{StaticResource Heading1}" HorizontalAlignment="Center" Height="104" TextWrapping="Wrap" VerticalAlignment="Top" Width="326" Margin="0,180,0,0" FontSize="72" FontWeight="Bold"/> <TextBlock Name="Clock" Text="00:00" Style="{StaticResource Heading1}" HorizontalAlignment="Center" Height="104" TextWrapping="Wrap" VerticalAlignment="Top" Width="326" Margin="0,180,0,0" FontSize="72" FontWeight="Bold"/>
<Rectangle Name="ProgressBar" Style="{StaticResource CircleSmall}" HorizontalAlignment="Center" Margin="0,289,0,0" VerticalAlignment="Top" Width="407"/>
<Button Content="Start" Name="PlayPauseButton" Style="{StaticResource PlayPauseButton}" HorizontalAlignment="Center" Margin="0,346,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Click="Button_Click"/> <StackPanel x:Name="CyclesIndicatorPanel" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,60,0,0">
</StackPanel>
<Button Content="Start" Name="PlayPauseButton" Style="{StaticResource PlayPauseButton}" HorizontalAlignment="Center" Margin="0,320,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Click="Button_Click"/>
</Grid> </Grid>
</Window> </Window>
\ No newline at end of file
...@@ -26,14 +26,15 @@ namespace InnoLabProjektDektopApp ...@@ -26,14 +26,15 @@ namespace InnoLabProjektDektopApp
private bool wordsOfAffirmation; private bool wordsOfAffirmation;
private bool insultingWords; private bool insultingWords;
private bool isBreakPeriod = false; // Speichert, ob wir in einer Pause sind
private Timer timer; private Timer timer;
private const int maxTime = (0 * 60) + 5;// total time for each session in seconds private int maxTime;
private int seconds = maxTime; // Tracks the remaining seconds in the current session private int seconds;
private int step = 0; //Indicates whether the timer is running (-1) or paused (0) private int step = 0; //Indicates whether the timer is running (-1) or paused (0)
private const int sessions = 4; //Total number of focus sessions in one cycle private int sessions;
private int currentSession = 1; //Tracks which session is currently running private int currentSession = 1; //Tracks which session is currently running
public Session(int focusPeriod, public Session(int focusPeriod,
...@@ -54,8 +55,14 @@ namespace InnoLabProjektDektopApp ...@@ -54,8 +55,14 @@ namespace InnoLabProjektDektopApp
this.insultingWords = insultingWords; this.insultingWords = insultingWords;
GlobalSettings.setDefaults(this); GlobalSettings.setDefaults(this);
this.maxTime = focusPeriod/2; //todo: multiply with 60 later
this.seconds = this.maxTime;
this.sessions = cycles;
timer = new Timer(timertick, null,0,1000); //A background timer calls timertick every second timer = new Timer(timertick, null,0,1000); //A background timer calls timertick every second
CreateCycleIndicators(); // Kreise erstellen
updateTexts(); updateTexts();
} }
...@@ -63,29 +70,46 @@ namespace InnoLabProjektDektopApp ...@@ -63,29 +70,46 @@ namespace InnoLabProjektDektopApp
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
seconds += step; // Decrement seconds if running seconds += step; // Reduziere Zeit, wenn der Timer läuft
updateTexts(); // Update UI updateTexts(); // Aktualisiere die UI
ProgressBar.Fill = GradientGenerator.generateTwoColorBrush(
Color.FromRgb(72, 98, 132),
Color.FromRgb(222, 222, 222),
1 - (seconds / (double)maxTime)
);
if (seconds <= 0) // When time runs out // Fortschrittsanzeige nur während der Fokusperiode aktualisieren
if (!isBreakPeriod)
{
CreateCycleIndicators(); // Fortschritt für Fokus-Perioden anzeigen
}
if (seconds <= 0) // Wenn die Zeit abgelaufen ist
{
stopTimer(); // Timer stoppen
if (isBreakPeriod) // Wenn wir in einer Pause sind
{
isBreakPeriod = false; // Zurück zum Fokus
seconds = maxTime; // Zeit für die Fokusperiode
currentSession++; // Gehe zum nächsten Zyklus
}
else // Wenn wir im Fokus sind
{ {
stopTimer(); // Pause the timer isBreakPeriod = true; // Wechsel in den Pausenmodus
currentSession++; seconds = breakPeriod; // Zeit für die Pause
seconds = maxTime; // Reset timer for the next session }
if (currentSession > sessions) if (currentSession > sessions) // Wenn alle Zyklen abgeschlossen sind
{ {
timer.Dispose(); // Stop and clean up the timer after all sessions timer.Dispose(); // Timer stoppen und aufräumen
MessageBox.Show("All sessions completed!", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
return;
} }
startTimer(); // Starte den Timer für die nächste Periode
} }
}); });
} }
public void startTimer() public void startTimer()
{ {
if (seconds <= 0) return; // Prevent starting if time is zero if (seconds <= 0) return; // Prevent starting if time is zero
...@@ -111,8 +135,17 @@ namespace InnoLabProjektDektopApp ...@@ -111,8 +135,17 @@ namespace InnoLabProjektDektopApp
private void updateTexts() private void updateTexts()
{ {
Clock.Text = seconds / 60 + ":" + (seconds % 60 < 10 ? "0" : "") + seconds % 60; Clock.Text = seconds / 60 + ":" + (seconds % 60 < 10 ? "0" : "") + seconds % 60;
Title.Text = "Focus Session " + currentSession + " of " + sessions;
if (isBreakPeriod)
{
Title.Text = $"Break Session {currentSession} of {sessions}";
}
else
{
Title.Text = $"Focus Session {currentSession} of {sessions}";
} }
}
private void Button_Click(object sender, RoutedEventArgs e) private void Button_Click(object sender, RoutedEventArgs e)
{ {
...@@ -122,6 +155,70 @@ namespace InnoLabProjektDektopApp ...@@ -122,6 +155,70 @@ namespace InnoLabProjektDektopApp
startTimer(); startTimer();
} }
} }
private void CreateCycleIndicators()
{
// Clear existing indicators
CyclesIndicatorPanel.Children.Clear();
for (int i = 0; i < cycles; i++)
{
if (i + 1 == currentSession) // Highlight the current session with a ProgressBar
{
Grid cycleGrid = new Grid
{
Width = 50,
Height = 20, // Höhe des erweiterten Kreises
Margin = new Thickness(10),
};
// Background for the current cycle
Rectangle backgroundRectangle = new Rectangle
{
Width = 50,
Height = 20,
Fill = Brushes.LightGray,
RadiusX = 10,
RadiusY = 10,
};
// ProgressBar (uses the existing logic)
Rectangle progressBar = new Rectangle
{
Width = 50, // Gleiche Breite wie der Hintergrund
Height = 20, // Gleiche Höhe wie der Hintergrund
Fill = GradientGenerator.generateTwoColorBrush(
Color.FromRgb(72, 98, 132),
Color.FromRgb(222, 222, 222),
1 - (seconds / (double)maxTime)
),
RadiusX = 10,
RadiusY = 10,
HorizontalAlignment = HorizontalAlignment.Left,
};
cycleGrid.Children.Add(backgroundRectangle);
cycleGrid.Children.Add(progressBar); // ProgressBar überlagert den Hintergrund
CyclesIndicatorPanel.Children.Add(cycleGrid);
}
else
{
// Standardkreis für abgeschlossene oder zukünftige Zyklen
Ellipse cycleIndicator = new Ellipse
{
Width = 20,
Height = 20,
Margin = new Thickness(10),
Fill = i < currentSession ? new SolidColorBrush(Color.FromRgb(72, 98, 132)) : Brushes.LightGray,
};
CyclesIndicatorPanel.Children.Add(cycleIndicator);
}
}
}
} }
} }
......
...@@ -14,7 +14,7 @@ using System.Reflection; ...@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("CoFlow")] [assembly: System.Reflection.AssemblyCompanyAttribute("CoFlow")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e6579ef0d3b607362222ce416775f79a38e2a15b")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+93d144893d8dadca6f285ef4a5529527314cd24b")]
[assembly: System.Reflection.AssemblyProductAttribute("CoFlow")] [assembly: System.Reflection.AssemblyProductAttribute("CoFlow")]
[assembly: System.Reflection.AssemblyTitleAttribute("CoFlow")] [assembly: System.Reflection.AssemblyTitleAttribute("CoFlow")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
......
aada719c9e57b2dfa11e1b6fee01ad786fcaf6337a6a62c39bf8cce0ea37e6c6 81fe44d744b1d9f6bc5c21f59489eb8a1ce8533d6aa9ebb2bad659cbb6cd413b
#pragma checksum "..\..\..\..\..\Screens\Regulaer\02Session.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "9B6D99D6ED8E1A78DB85CB3A5AD191E6830B5E1A" #pragma checksum "..\..\..\..\..\Screens\Regulaer\02Session.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4D171F84F09119FFF5927E5550B6D53DBDAC090D"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
...@@ -59,15 +59,15 @@ namespace InnoLabProjektDektopApp { ...@@ -59,15 +59,15 @@ namespace InnoLabProjektDektopApp {
#line hidden #line hidden
#line 17 "..\..\..\..\..\Screens\Regulaer\02Session.xaml" #line 18 "..\..\..\..\..\Screens\Regulaer\02Session.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Shapes.Rectangle ProgressBar; internal System.Windows.Controls.StackPanel CyclesIndicatorPanel;
#line default #line default
#line hidden #line hidden
#line 18 "..\..\..\..\..\Screens\Regulaer\02Session.xaml" #line 20 "..\..\..\..\..\Screens\Regulaer\02Session.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button PlayPauseButton; internal System.Windows.Controls.Button PlayPauseButton;
...@@ -118,12 +118,12 @@ namespace InnoLabProjektDektopApp { ...@@ -118,12 +118,12 @@ namespace InnoLabProjektDektopApp {
this.Clock = ((System.Windows.Controls.TextBlock)(target)); this.Clock = ((System.Windows.Controls.TextBlock)(target));
return; return;
case 3: case 3:
this.ProgressBar = ((System.Windows.Shapes.Rectangle)(target)); this.CyclesIndicatorPanel = ((System.Windows.Controls.StackPanel)(target));
return; return;
case 4: case 4:
this.PlayPauseButton = ((System.Windows.Controls.Button)(target)); this.PlayPauseButton = ((System.Windows.Controls.Button)(target));
#line 18 "..\..\..\..\..\Screens\Regulaer\02Session.xaml" #line 20 "..\..\..\..\..\Screens\Regulaer\02Session.xaml"
this.PlayPauseButton.Click += new System.Windows.RoutedEventHandler(this.Button_Click); this.PlayPauseButton.Click += new System.Windows.RoutedEventHandler(this.Button_Click);
#line default #line default
......
#pragma checksum "..\..\..\..\..\Screens\Regulaer\02Session.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "9B6D99D6ED8E1A78DB85CB3A5AD191E6830B5E1A" #pragma checksum "..\..\..\..\..\Screens\Regulaer\02Session.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4D171F84F09119FFF5927E5550B6D53DBDAC090D"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
...@@ -59,15 +59,15 @@ namespace InnoLabProjektDektopApp { ...@@ -59,15 +59,15 @@ namespace InnoLabProjektDektopApp {
#line hidden #line hidden
#line 17 "..\..\..\..\..\Screens\Regulaer\02Session.xaml" #line 18 "..\..\..\..\..\Screens\Regulaer\02Session.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Shapes.Rectangle ProgressBar; internal System.Windows.Controls.StackPanel CyclesIndicatorPanel;
#line default #line default
#line hidden #line hidden
#line 18 "..\..\..\..\..\Screens\Regulaer\02Session.xaml" #line 20 "..\..\..\..\..\Screens\Regulaer\02Session.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button PlayPauseButton; internal System.Windows.Controls.Button PlayPauseButton;
...@@ -118,12 +118,12 @@ namespace InnoLabProjektDektopApp { ...@@ -118,12 +118,12 @@ namespace InnoLabProjektDektopApp {
this.Clock = ((System.Windows.Controls.TextBlock)(target)); this.Clock = ((System.Windows.Controls.TextBlock)(target));
return; return;
case 3: case 3:
this.ProgressBar = ((System.Windows.Shapes.Rectangle)(target)); this.CyclesIndicatorPanel = ((System.Windows.Controls.StackPanel)(target));
return; return;
case 4: case 4:
this.PlayPauseButton = ((System.Windows.Controls.Button)(target)); this.PlayPauseButton = ((System.Windows.Controls.Button)(target));
#line 18 "..\..\..\..\..\Screens\Regulaer\02Session.xaml" #line 20 "..\..\..\..\..\Screens\Regulaer\02Session.xaml"
this.PlayPauseButton.Click += new System.Windows.RoutedEventHandler(this.Button_Click); this.PlayPauseButton.Click += new System.Windows.RoutedEventHandler(this.Button_Click);
#line default #line default
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment