diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml index 429a7346ee5e7be3c0ebda1926a3ed52ad415b41..2cd4a7add9d9c6cfab1d1f8d8baa601d4e7ffd31 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml @@ -9,6 +9,36 @@ Unloaded="Page_Unloaded" Height="550" Width="900"> <Grid> + + <ToggleButton x:Name="BurgerMenuButton" Content="☰" Width="50" Height="50" Click="BurgerMenuButton_Click" Margin="10,20,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Style="{StaticResource BurgerMenuButtonStyle}" /> + <StackPanel x:Name="MenuPanel" + Visibility="Collapsed" + VerticalAlignment="Top" + HorizontalAlignment="Left" + Margin="10,80,0,0"> + <Button Content="Distractions" + Style="{StaticResource MenuButtonStyle}" + Click="Button_Click_2"/> + <Button Content="ProgrammsList" + Style="{StaticResource MenuButtonStyle}" + Click="Button_Click_3"/> + <Button Content="Overview" + Style="{StaticResource MenuButtonStyle}" + Click="Button_Click_4"/> + <Button Content="Statistics" + Style="{StaticResource MenuButtonStyle}" + Click="Button_Click_5"/> + <Button Content="Abonnement" + Style="{StaticResource MenuButtonStyle}" + Click="Button_Click_6"/> + <Button Content="Contract" + Style="{StaticResource MenuButtonStyle}" + Click="Button_Click_7"/> + <Button Content="Settings" + Style="{StaticResource MenuButtonStyle}" + Click="Button_Click_8"/> + </StackPanel> + <!-- <header:HeaderTemplate VerticalAlignment="Center" Height="534"/> --> <Button Margin="0,100,150,10" Width="40" Height="40" HorizontalAlignment="Right" VerticalAlignment="Top" Background="Transparent" BorderBrush="Transparent" Click="discardSession_Click"> <Grid > @@ -22,8 +52,11 @@ <StackPanel x:Name="CyclesIndicatorPanel" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,60,0,0"> </StackPanel> <Button Content="Pause" Name="PlayPauseButton" Style="{StaticResource PlayPauseButton}" HorizontalAlignment="Center" Margin="0,320,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Click="PlayPause_Click"></Button> - <Button Content="Mascott Up" Click="Button_Click_1" HorizontalAlignment="Left" Margin="116,375,0,0" VerticalAlignment="Top"/> + + <!-- + <Button Content="Mascott Up" Click="Button_Click_1" HorizontalAlignment="Left" Margin="116,375,0,0" VerticalAlignment="Top"/> <Button Content="Mascott Down" Click="Button_Click" HorizontalAlignment="Left" Margin="116,400,0,0" VerticalAlignment="Top"/> + <TextBlock HorizontalAlignment="Left" Margin="116,350,0,0" Text="0" VerticalAlignment="Top" Name="StageText"/> + --> </Grid> - </Page> \ No newline at end of file diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml.cs index e0142f69e38e74c890cbcbb1237f350ad216769e..1f58cb63bdd8f3a243d54b57acf745acc79a52aa 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml.cs @@ -1,5 +1,8 @@ using InnoLabProjektDektopApp.Screens.Regulaer; +using InnoLabProjektDektopApp.Services; using System.Diagnostics; +using System.Diagnostics.Contracts; +using System.Runtime.CompilerServices; using System.Text; using System.Windows; using System.Windows.Controls; @@ -63,6 +66,8 @@ namespace InnoLabProjektDektopApp timer = new Timer(timertick, null, 0, 1000); //A background timer calls timertick every second + //StageText.Text = ProcessMonitor.tmpStage.ToString(); + mascott = new Mascott(); mascott.Show(); @@ -294,12 +299,60 @@ namespace InnoLabProjektDektopApp private void Button_Click_1(object sender, RoutedEventArgs e) { - mascott.emotionUp(); + //mascott.emotionUp(); + ProcessMonitor.tmpStage++; + //StageText.Text = ProcessMonitor.tmpStage.ToString(); } private void Button_Click(object sender, RoutedEventArgs e) { - mascott.emotionDown(); + //mascott.emotionDown(); + ProcessMonitor.tmpStage--; + //StageText.Text = ProcessMonitor.tmpStage.ToString(); + } + + public void navigateTo(Object page) { + this.NavigationService.Navigate(page); + } + + private void Button_Click_2(object sender, RoutedEventArgs e) + { + this.NavigationService.Navigate(new Distractions()); + } + + private void Button_Click_3(object sender, RoutedEventArgs e) + { + this.NavigationService.Navigate(new ProgramsList()); + } + + private void Button_Click_4(object sender, RoutedEventArgs e) + { + this.NavigationService.Navigate(new Overview()); + } + + private void Button_Click_5(object sender, RoutedEventArgs e) + { + this.NavigationService.Navigate(new Statistics()); + } + + private void Button_Click_6(object sender, RoutedEventArgs e) + { + this.NavigationService.Navigate(new Abonnement()); + } + + private void Button_Click_7(object sender, RoutedEventArgs e) + { + this.NavigationService.Navigate(new Contact()); + } + + private void Button_Click_8(object sender, RoutedEventArgs e) + { + this.NavigationService.Navigate(new Settings()); + } + + private void BurgerMenuButton_Click(object sender, RoutedEventArgs e) + { + MenuPanel.Visibility = MenuPanel.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible; } } } diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml index ca19af6ad5e1348d2b8a762ed48c8387af4245c6..34c264f568af9e040479bd07ca84e54c90fddb91 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml @@ -16,7 +16,7 @@ Closing="Window_Closing" Title="Mascott" Height="250" Width="250"> <Grid> - <Image Name="MascottImage" Source="pack://application:,,,/Assets/MascottAnimation/Down/HAPPIEST/frame0.png" Width="250" Height="250" /> + <Image Name="MascottImage" Source="pack://application:,,,/Assets/MascottAnimation/Up/4/frame0.png" Width="250" Height="250" /> <TextBlock Name="Counterxd" HorizontalAlignment="Left" Height="30" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="55" Foreground="White" FontSize="22" Margin="195,45,0,0"/> <Ellipse Name="ellipse1" HorizontalAlignment="Left" Fill="Lime" Height="28" Margin="208,0,0,0" Stroke="Black" VerticalAlignment="Center" Width="28" RenderTransformOrigin="-0.946,0.07"/> </Grid> diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml.cs index 797147ef90338a1dd07499d622a8948d1a7fc6f5..2df52b358db1bed7cd9e3e6aa7305585e07acd40 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml.cs @@ -30,14 +30,14 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer { private Timer frameTimer; private Timer animationTimer; - private int frameCounter = 1; - private int distractionStage = 1; + private int frameCounter = 0; + private int distractionStage = 4; private string framePath = ""; private int oldDistractionStage = 4; - private string animationDirection = "Down"; + private string animationDirection = "Up"; ProcessMonitor processMonitor; - + public Mascott() { @@ -48,7 +48,7 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer } InitializeComponent(); - emotionUp(); + emotionUp_(); processMonitor = App.GetProcessMonitor(); this.Left = -30; //SystemParameters.PrimaryScreenWidth - this.Width; @@ -60,30 +60,34 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer private void animationTick(object state) { + if (!processMonitor.isMonitoring) processMonitor.StartMonitoring(); + Application.Current.Dispatcher.Invoke(() => { - /* - if (!processMonitor.isMonitoring) processMonitor.StartMonitoring(); DateTime timeLeft = Overview.getSessionInstance().timeLeft(); - int processMonitorStage = processMonitor.CalculateCurrentDistractionStage(timeLeft); + int processMonitorStage = processMonitor.CalculateCurrentDistractionStage(timeLeft); //processMonitor.CalculateCurrentDistractionStage(timeLeft); + /* */ + if (processMonitorStage == oldDistractionStage) { Counterxd.Text = "x: " + processMonitorStage.ToString(); return; } if (processMonitorStage < oldDistractionStage) { - emotionUp(); + emotionDown_(); + Counterxd.Text = "d: " + processMonitorStage.ToString(); } else if(processMonitorStage > oldDistractionStage) { - emotionDown(); + emotionUp_(); + Counterxd.Text = "u: " + processMonitorStage.ToString(); } - oldDistractionStage = processMonitorStage;*/ + oldDistractionStage = processMonitorStage; }); } - public void emotionDown() { + public void emotionUp_() { if (animationDirection == "Down") distractionStage--; if (distractionStage < 1) { distractionStage = 1; @@ -96,7 +100,7 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer frameTimer = new Timer(frameTick, null, 0, 42); } - public void emotionUp() { + public void emotionDown_() { if (animationDirection == "Up") distractionStage++; if (distractionStage > 7) { distractionStage = 7; @@ -134,8 +138,9 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer { try { + //MascottImage.Source = new BitmapImage(new Uri($"pack://application:,,,/Assets/MascottAnimation/Down/{animation}/frame{frame_}.png")); - MascottImage.Source = new BitmapImage(new Uri(framePath)); + MascottImage.Source = new BitmapImage(new Uri(framePath)); } catch (Exception e) { return false; diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Services/ProcessMonitor.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Services/ProcessMonitor.cs index 6d8eee2bb6957d0d824b11605fbc91ff14239120..58939c7260e581f64f920ccd2a22b266438d08e3 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Services/ProcessMonitor.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Services/ProcessMonitor.cs @@ -73,18 +73,20 @@ namespace InnoLabProjektDektopApp.Services ShowDistractionWarning(process.Key); } } + await Task.Run(() => { while (isMonitoring) { // this wait is here to prevent another event from being triggered before the previous one is handled - var task = Task.Run(() => watcher.WaitForNextEvent()); + + var task = Task.Run(() => watcher.WaitForNextEvent());/* if (Task.WaitAny(task, Task.Delay(100)) == 0) { if (!isMonitoring) break; Task.Run(() => HandleNewProcess(task.Result)); - } + }*/ } }); } @@ -191,9 +193,15 @@ namespace InnoLabProjektDektopApp.Services new End(sessionInfoFilePath)); } + public static int tmpStage = 4; + + public static int CalculateCurrentDistractionStageTmp(DateTime endTime) { + return tmpStage; + } + public int CalculateCurrentDistractionStage(DateTime endTime) { - + if (cycleStartTimeList.Count == 0) return 4; TimeSpan totalDistractionTime = CalculateTotalDistractionTime(); TimeSpan totalBreakTime = breakInfoList.Aggregate(TimeSpan.Zero, (sum, interval) => sum + (interval.EndTime - interval.StartTime)); Debug.WriteLine("Total distraction time: {0}", totalDistractionTime); diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Styles/Styles.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Styles/Styles.xaml index 6de17a535b6e9eb773cec183d58380ed24d150b9..a5088e2911b181302c20811217a8480a43ac7d1e 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Styles/Styles.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Styles/Styles.xaml @@ -174,7 +174,7 @@ <Setter Property="Margin" Value="10,20,0,0"/> <Setter Property="VerticalAlignment" Value="Top"/> <Setter Property="HorizontalAlignment" Value="Left"/> - <Setter Property="Background" Value="#FF4CAF50"/> + <Setter Property="Background" Value="DarkGray"/> <!-- Green background --> <Setter Property="Foreground" Value="White"/> <!-- White text --> @@ -188,7 +188,7 @@ <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" - CornerRadius="5"> + > <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> </ControlTemplate> @@ -196,11 +196,11 @@ </Setter> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> - <Setter Property="Background" Value="#FF388E3C"/> + <Setter Property="Background" Value="DarkGray"/> <!-- Darker green on hover --> </Trigger> <Trigger Property="IsChecked" Value="True"> - <Setter Property="Background" Value="#FF2E7D32"/> + <Setter Property="Background" Value="DarkGray"/> <!-- Even darker green when checked --> </Trigger> </Style.Triggers> @@ -210,9 +210,10 @@ <Style TargetType="Button" x:Key="MenuButtonStyle"> <Setter Property="Margin" Value="5"/> <Setter Property="Padding" Value="10"/> - <Setter Property="Background" Value="#FF2196F3"/> + + <Setter Property="Background" Value="DarkGray"/> <!-- Blue background --> - <Setter Property="Foreground" Value="White"/> + <Setter Property="Foreground" Value="DarkGray"/> <!-- White text --> <Setter Property="FontSize" Value="16"/> <Setter Property="BorderBrush" Value="Transparent"/> @@ -220,7 +221,7 @@ <Setter Property="Cursor" Value="Hand"/> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> - <Setter Property="Background" Value="#FF1976D2"/> + <Setter Property="Background" Value="Red"/> <!-- Darker blue on hover --> </Trigger> </Style.Triggers>