Skip to content
Snippets Groups Projects
Commit 58db11bd authored by Your Name's avatar Your Name
Browse files

implemented process monitor to mascott animation

parent d5e68963
No related branches found
No related tags found
1 merge request!45implemented process monitor to mascott animation
...@@ -9,6 +9,36 @@ ...@@ -9,6 +9,36 @@
Unloaded="Page_Unloaded" Unloaded="Page_Unloaded"
Height="550" Width="900"> Height="550" Width="900">
<Grid> <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"/> --> <!-- <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"> <Button Margin="0,100,150,10" Width="40" Height="40" HorizontalAlignment="Right" VerticalAlignment="Top" Background="Transparent" BorderBrush="Transparent" Click="discardSession_Click">
<Grid > <Grid >
...@@ -22,8 +52,11 @@ ...@@ -22,8 +52,11 @@
<StackPanel x:Name="CyclesIndicatorPanel" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,60,0,0"> <StackPanel x:Name="CyclesIndicatorPanel" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,60,0,0">
</StackPanel> </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="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"/> <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> </Grid>
</Page> </Page>
\ No newline at end of file
using InnoLabProjektDektopApp.Screens.Regulaer; using InnoLabProjektDektopApp.Screens.Regulaer;
using InnoLabProjektDektopApp.Services;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
...@@ -63,6 +66,8 @@ namespace InnoLabProjektDektopApp ...@@ -63,6 +66,8 @@ namespace InnoLabProjektDektopApp
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
//StageText.Text = ProcessMonitor.tmpStage.ToString();
mascott = new Mascott(); mascott = new Mascott();
mascott.Show(); mascott.Show();
...@@ -294,12 +299,60 @@ namespace InnoLabProjektDektopApp ...@@ -294,12 +299,60 @@ namespace InnoLabProjektDektopApp
private void Button_Click_1(object sender, RoutedEventArgs e) 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) 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;
} }
} }
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
Closing="Window_Closing" Closing="Window_Closing"
Title="Mascott" Height="250" Width="250"> Title="Mascott" Height="250" Width="250">
<Grid> <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"/> <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"/> <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> </Grid>
......
...@@ -30,11 +30,11 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer ...@@ -30,11 +30,11 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer
{ {
private Timer frameTimer; private Timer frameTimer;
private Timer animationTimer; private Timer animationTimer;
private int frameCounter = 1; private int frameCounter = 0;
private int distractionStage = 1; private int distractionStage = 4;
private string framePath = ""; private string framePath = "";
private int oldDistractionStage = 4; private int oldDistractionStage = 4;
private string animationDirection = "Down"; private string animationDirection = "Up";
ProcessMonitor processMonitor; ProcessMonitor processMonitor;
...@@ -48,7 +48,7 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer ...@@ -48,7 +48,7 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer
} }
InitializeComponent(); InitializeComponent();
emotionUp(); emotionUp_();
processMonitor = App.GetProcessMonitor(); processMonitor = App.GetProcessMonitor();
this.Left = -30; //SystemParameters.PrimaryScreenWidth - this.Width; this.Left = -30; //SystemParameters.PrimaryScreenWidth - this.Width;
...@@ -60,13 +60,15 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer ...@@ -60,13 +60,15 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer
private void animationTick(object state) private void animationTick(object state)
{ {
if (!processMonitor.isMonitoring) processMonitor.StartMonitoring();
Application.Current.Dispatcher.Invoke(() => Application.Current.Dispatcher.Invoke(() =>
{ {
/*
if (!processMonitor.isMonitoring) processMonitor.StartMonitoring();
DateTime timeLeft = Overview.getSessionInstance().timeLeft(); DateTime timeLeft = Overview.getSessionInstance().timeLeft();
int processMonitorStage = processMonitor.CalculateCurrentDistractionStage(timeLeft); int processMonitorStage = processMonitor.CalculateCurrentDistractionStage(timeLeft); //processMonitor.CalculateCurrentDistractionStage(timeLeft);
/* */
if (processMonitorStage == oldDistractionStage) { if (processMonitorStage == oldDistractionStage) {
Counterxd.Text = "x: " + processMonitorStage.ToString(); Counterxd.Text = "x: " + processMonitorStage.ToString();
...@@ -74,16 +76,18 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer ...@@ -74,16 +76,18 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer
} }
if (processMonitorStage < oldDistractionStage) { if (processMonitorStage < oldDistractionStage) {
emotionUp(); emotionDown_();
Counterxd.Text = "d: " + processMonitorStage.ToString();
} else if(processMonitorStage > oldDistractionStage) { } 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 (animationDirection == "Down") distractionStage--;
if (distractionStage < 1) { if (distractionStage < 1) {
distractionStage = 1; distractionStage = 1;
...@@ -96,7 +100,7 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer ...@@ -96,7 +100,7 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer
frameTimer = new Timer(frameTick, null, 0, 42); frameTimer = new Timer(frameTick, null, 0, 42);
} }
public void emotionUp() { public void emotionDown_() {
if (animationDirection == "Up") distractionStage++; if (animationDirection == "Up") distractionStage++;
if (distractionStage > 7) { if (distractionStage > 7) {
distractionStage = 7; distractionStage = 7;
...@@ -134,6 +138,7 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer ...@@ -134,6 +138,7 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer
{ {
try try
{ {
//MascottImage.Source = new BitmapImage(new Uri($"pack://application:,,,/Assets/MascottAnimation/Down/{animation}/frame{frame_}.png")); //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));
} }
......
...@@ -74,17 +74,19 @@ namespace InnoLabProjektDektopApp.Services ...@@ -74,17 +74,19 @@ namespace InnoLabProjektDektopApp.Services
} }
} }
await Task.Run(() => await Task.Run(() =>
{ {
while (isMonitoring) while (isMonitoring)
{ {
// this wait is here to prevent another event from being triggered before the previous one is handled // 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 (Task.WaitAny(task, Task.Delay(100)) == 0)
{ {
if (!isMonitoring) break; if (!isMonitoring) break;
Task.Run(() => HandleNewProcess(task.Result)); Task.Run(() => HandleNewProcess(task.Result));
} }*/
} }
}); });
} }
...@@ -191,9 +193,15 @@ namespace InnoLabProjektDektopApp.Services ...@@ -191,9 +193,15 @@ namespace InnoLabProjektDektopApp.Services
new End(sessionInfoFilePath)); new End(sessionInfoFilePath));
} }
public static int tmpStage = 4;
public static int CalculateCurrentDistractionStageTmp(DateTime endTime) {
return tmpStage;
}
public int CalculateCurrentDistractionStage(DateTime endTime) public int CalculateCurrentDistractionStage(DateTime endTime)
{ {
if (cycleStartTimeList.Count == 0) return 4;
TimeSpan totalDistractionTime = CalculateTotalDistractionTime(); TimeSpan totalDistractionTime = CalculateTotalDistractionTime();
TimeSpan totalBreakTime = breakInfoList.Aggregate(TimeSpan.Zero, (sum, interval) => sum + (interval.EndTime - interval.StartTime)); TimeSpan totalBreakTime = breakInfoList.Aggregate(TimeSpan.Zero, (sum, interval) => sum + (interval.EndTime - interval.StartTime));
Debug.WriteLine("Total distraction time: {0}", totalDistractionTime); Debug.WriteLine("Total distraction time: {0}", totalDistractionTime);
......
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
<Setter Property="Margin" Value="10,20,0,0"/> <Setter Property="Margin" Value="10,20,0,0"/>
<Setter Property="VerticalAlignment" Value="Top"/> <Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="HorizontalAlignment" Value="Left"/> <Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="Background" Value="#FF4CAF50"/> <Setter Property="Background" Value="DarkGray"/>
<!-- Green background --> <!-- Green background -->
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="White"/>
<!-- White text --> <!-- White text -->
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
<Border Background="{TemplateBinding Background}" <Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="5"> >
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border> </Border>
</ControlTemplate> </ControlTemplate>
...@@ -196,11 +196,11 @@ ...@@ -196,11 +196,11 @@
</Setter> </Setter>
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FF388E3C"/> <Setter Property="Background" Value="DarkGray"/>
<!-- Darker green on hover --> <!-- Darker green on hover -->
</Trigger> </Trigger>
<Trigger Property="IsChecked" Value="True"> <Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="#FF2E7D32"/> <Setter Property="Background" Value="DarkGray"/>
<!-- Even darker green when checked --> <!-- Even darker green when checked -->
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
...@@ -210,9 +210,10 @@ ...@@ -210,9 +210,10 @@
<Style TargetType="Button" x:Key="MenuButtonStyle"> <Style TargetType="Button" x:Key="MenuButtonStyle">
<Setter Property="Margin" Value="5"/> <Setter Property="Margin" Value="5"/>
<Setter Property="Padding" Value="10"/> <Setter Property="Padding" Value="10"/>
<Setter Property="Background" Value="#FF2196F3"/>
<Setter Property="Background" Value="DarkGray"/>
<!-- Blue background --> <!-- Blue background -->
<Setter Property="Foreground" Value="White"/> <Setter Property="Foreground" Value="DarkGray"/>
<!-- White text --> <!-- White text -->
<Setter Property="FontSize" Value="16"/> <Setter Property="FontSize" Value="16"/>
<Setter Property="BorderBrush" Value="Transparent"/> <Setter Property="BorderBrush" Value="Transparent"/>
...@@ -220,7 +221,7 @@ ...@@ -220,7 +221,7 @@
<Setter Property="Cursor" Value="Hand"/> <Setter Property="Cursor" Value="Hand"/>
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FF1976D2"/> <Setter Property="Background" Value="Red"/>
<!-- Darker blue on hover --> <!-- Darker blue on hover -->
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment