Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rev 12 (22.08.2018) #4

Merged
merged 1 commit into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file modified .vs/Good Teacher/DesignTimeBuild/.dtbcache
Binary file not shown.
Binary file modified .vs/Good Teacher/v15/.suo
Binary file not shown.
Binary file modified .vs/Good Teacher/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file modified .vs/Good Teacher/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file modified .vs/Good Teacher/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
4 changes: 2 additions & 2 deletions Good Teacher Presentation/Good Teacher Presentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\ZstdNet.1.3.3\build\ZstdNet.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\ZstdNet.1.3.3\build\ZstdNet.targets'))" />
<Error Condition="!Exists('..\packages\Fody.3.1.3\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.1.3\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.3.1.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.1.0\build\Costura.Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.3.1.4\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.3.1.4\build\Fody.targets'))" />
</Target>
<Import Project="..\packages\ZstdNet.1.3.3\build\ZstdNet.targets" Condition="Exists('..\packages\ZstdNet.1.3.3\build\ZstdNet.targets')" />
<Import Project="..\packages\Fody.3.1.3\build\Fody.targets" Condition="Exists('..\packages\Fody.3.1.3\build\Fody.targets')" />
<Import Project="..\packages\Costura.Fody.3.1.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.3.1.0\build\Costura.Fody.targets')" />
<Import Project="..\packages\Fody.3.1.4\build\Fody.targets" Condition="Exists('..\packages\Fody.3.1.4\build\Fody.targets')" />
</Project>
238 changes: 160 additions & 78 deletions Good Teacher Presentation/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Good_Teacher.Class.Save.Output;
using Good_Teacher.Class.Save.Output.Temporary;
using Good_Teacher.Class.Serialization;
using Good_Teacher.Class.Special;
using Good_Teacher.Class.Workers;
using Good_Teacher.Controls;
using Good_Teacher.Windows.Special;
Expand Down Expand Up @@ -34,6 +35,9 @@ public partial class MainWindow : Window
DataStore data;
DispatcherTimer dispatcherTimer = new DispatcherTimer();
DispatcherTimer dispatcherTimerTransition = new DispatcherTimer();
DispatcherTimer dispatcherTimer_Timers = new DispatcherTimer();
long Timer_TimersLast = 0;

short t = 0, m = 0;
int currentC = 0;
private int LoadedPage = 0;
Expand Down Expand Up @@ -118,6 +122,13 @@ public MainWindow()
dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
dispatcherTimer.IsEnabled = true;


Timer_TimersLast = DateTime.Now.Ticks;

dispatcherTimer_Timers.Tick -= DispatcherTimer_Timers_Tick;
dispatcherTimer_Timers.Tick += DispatcherTimer_Timers_Tick;
dispatcherTimer_Timers.Interval = new TimeSpan(0, 0, 0, 0, 100);
dispatcherTimer_Timers.IsEnabled = true;

dispatcherTimerTransition.Tick -= DispatcherTimerTransition_Tick;
dispatcherTimerTransition.Tick += DispatcherTimerTransition_Tick;
Expand Down Expand Up @@ -150,6 +161,27 @@ public MainWindow()
}
}

private void DispatcherTimer_Timers_Tick(object sender, EventArgs e)
{
foreach (TimerAction timer in data.pages[currentLoaded].Timers)
{
if (!timer.Stop)
{
timer.ActualTime -= (float)((float)(DateTime.Now.Ticks - Timer_TimersLast) / TimeSpan.TicksPerMillisecond) / 1000;

if (timer.ActualTime <= 0)
{
timer.Stop = true;
foreach (IActions action in timer.Actions)
{
DoAction(action);
}
}
}
}
Timer_TimersLast = DateTime.Now.Ticks;
}

private void DispatcherTimerTransition_Tick(object sender, EventArgs e)
{
if (data.pages[LoadedPage].transitionType == Good_Teacher.Class.Enumerators.TransitionTypeEnum.TransitionType.Automatic)
Expand Down Expand Up @@ -377,6 +409,12 @@ private void LoadCanvas(int pos, bool IgnoreHidden = false)
}
}

foreach (TimerAction timer in data.pages[currentLoaded].Timers)
{
timer.SetActualTime();
timer.Stop = false;
}

DoScript();

dispatcherTimerTransition.Interval = TimeSpan.FromMilliseconds(data.pages[LoadedPage].TransitionMove);
Expand Down Expand Up @@ -455,6 +493,20 @@ public void SaveControlState()
{
output.Pages[currentLoaded].InputList.Add(new RadioButtonInput(((RadioButton)elm).Content?.ToString(), ((RadioButton)elm).IsChecked == true, ((RadioButton)elm).GroupName));
}
else if (elm is ToggleButton_Control)
{
string checkSTR = "";
if (((ToggleButton_Control)elm).IsChecked)
{
checkSTR = ((ToggleButton_Control)elm).contentCreatorChecked.GetText();
}
else
{
checkSTR = ((ToggleButton_Control)elm).contentCreatorUnchecked.GetText();
}

output.Pages[currentLoaded].InputList.Add(new ToggleButtonInput("" + ControlWorker.GetID(((ToggleButton_Control)elm).Name), checkSTR, ((ToggleButton_Control)elm).IsChecked));
}
}
}

Expand Down Expand Up @@ -518,6 +570,9 @@ private void Window_Presentation_Closing(object sender, System.ComponentModel.Ca

mediaplayer.Stop();

dispatcherTimer_Timers.Stop();
dispatcherTimer_Timers.IsEnabled = false;

FontWorker.RemoveTemporaryFolder();
}

Expand Down Expand Up @@ -563,6 +618,10 @@ void ToSpecialPresentation()
{
((CButton)PlayCanvas.Children[i]).Click += Window_Presentation_Click;
}
else if (PlayCanvas.Children[i] is ToggleButton_Control)
{
((ToggleButton_Control)PlayCanvas.Children[i]).Click += Window_Presentation_Click;
}
else if (PlayCanvas.Children[i] is AnswerButton)
{
((AnswerButton)PlayCanvas.Children[i]).Click += Window_Presentation_Answer_Click;
Expand Down Expand Up @@ -627,105 +686,128 @@ private void Window_Presentation_Answer_Click(AnswerButton sender, MouseButtonEv
}


private void Window_Presentation_Click(CButton sender, MouseButtonEventArgs e)
private void Window_Presentation_Click(FrameworkElement sender, MouseButtonEventArgs e)
{
foreach (IActions action in sender.actions)
{
int act = action.DoAction();
List<IActions> actions = new List<IActions>();

switch (act)
if (sender is CButton)
{
actions = new List<IActions>(((CButton)sender).actions);
}
else if (sender is ToggleButton_Control)
{
if (((ToggleButton_Control)sender).IsChecked)
{
case 1:
if (((Action_GoToPage)action).ToSpecific)
{
LoadCanvas(((Action_GoToPage)action).ToPage - 1, true);
UpdateNumberLabel();
}
else if (((Action_GoToPage)action).Next)
{
GoForward();
}
else
{
GoBack();
}
break;
case 2:
Close();
break;
case 3:
if (((Action_Sound)action).Stop)
{
mediaplayer.Stop();
}
else if (((Action_Sound)action).PlayAgain)
{
mediaplayer.Position = TimeSpan.Zero;
mediaplayer.Play();
}
else
{
if (!String.IsNullOrWhiteSpace(((Action_Sound)action).PathToPlay))
SetSoundToBePlayed(((Action_Sound)action).PathToPlay, ((Action_Sound)action).Repeat);
}
break;
case 4:
LoadNewPresentation(((Action_LoadPresentation)action).PresentationPath);
break;
case 5:
{
FrameworkElement felm = ControlWorker.FindChild<FrameworkElement>(PlayCanvas, "ID_" + ((Action_SetVisibility)action).ID);
actions = new List<IActions>(((ToggleButton_Control)sender).CheckedActions);
}
else
{
actions = new List<IActions>(((ToggleButton_Control)sender).UncheckedActions);
}
}

foreach (IActions action in actions)
{
DoAction(action);
}
}


public void DoAction(IActions action)
{
int act = action.DoAction();

switch (act)
{
case 1:
if (((Action_GoToPage)action).ToSpecific)
{
LoadCanvas(((Action_GoToPage)action).ToPage - 1, true);
UpdateNumberLabel();
}
else if (((Action_GoToPage)action).Next)
{
GoForward();
}
else
{
GoBack();
}
break;
case 2:
Close();
break;
case 3:
if (((Action_Sound)action).Stop)
{
mediaplayer.Stop();
}
else if (((Action_Sound)action).PlayAgain)
{
mediaplayer.Position = TimeSpan.Zero;
mediaplayer.Play();
}
else
{
if (!String.IsNullOrWhiteSpace(((Action_Sound)action).PathToPlay))
SetSoundToBePlayed(((Action_Sound)action).PathToPlay, ((Action_Sound)action).Repeat);
}
break;
case 4:
LoadNewPresentation(((Action_LoadPresentation)action).PresentationPath);
break;
case 5:
{
FrameworkElement felm = ControlWorker.FindChild<FrameworkElement>(PlayCanvas, "ID_" + ((Action_SetVisibility)action).ID);

if (felm != null)
if (felm != null)
{
if (((Action_SetVisibility)action).VisibilityValue == SetVisibilityEnum.SetVisibilityValue.SetToVisible)
{
if (((Action_SetVisibility)action).VisibilityValue == SetVisibilityEnum.SetVisibilityValue.SetToVisible)
felm.Visibility = Visibility.Visible;
}
else if (((Action_SetVisibility)action).VisibilityValue == SetVisibilityEnum.SetVisibilityValue.SetToInvisible)
{
felm.Visibility = Visibility.Collapsed;
}
else
{
if (felm.Visibility == Visibility.Collapsed || felm.Visibility == Visibility.Hidden)
{
felm.Visibility = Visibility.Visible;
}
else if (((Action_SetVisibility)action).VisibilityValue == SetVisibilityEnum.SetVisibilityValue.SetToInvisible)
{
felm.Visibility = Visibility.Collapsed;
}
else
{
if (felm.Visibility == Visibility.Collapsed || felm.Visibility == Visibility.Hidden)
{
felm.Visibility = Visibility.Visible;
}
else
{
felm.Visibility = Visibility.Collapsed;
}
felm.Visibility = Visibility.Collapsed;
}
}
break;
}
case 6:
MakeAnimation(currentLoaded, ((Action_DoAnimation)action).AnimationID);
break;
case 7:
{
FrameworkElement felm = ControlWorker.FindChild<FrameworkElement>(PlayCanvas, "ID_" + ((Action_Position)action).ID);
}
case 6:
MakeAnimation(currentLoaded, ((Action_DoAnimation)action).AnimationID);
break;
case 7:
{
FrameworkElement felm = ControlWorker.FindChild<FrameworkElement>(PlayCanvas, "ID_" + ((Action_Position)action).ID);

if (felm != null)
if (felm != null)
{
if (((Action_Position)action).ChangeX)
{
if (((Action_Position)action).ChangeX)
{
MathSignEnum.SetPositionX(((Action_Position)action).CX, ((Action_Position)action).SignX, felm);
}
MathSignEnum.SetPositionX(((Action_Position)action).CX, ((Action_Position)action).SignX, felm);
}

if (((Action_Position)action).ChangeY)
{
MathSignEnum.SetPositionY(((Action_Position)action).CY, ((Action_Position)action).SignY, felm);
}
if (((Action_Position)action).ChangeY)
{
MathSignEnum.SetPositionY(((Action_Position)action).CY, ((Action_Position)action).SignY, felm);
}
break;
}
}
break;
}
}
}


void GoBack()
{
if (currentC > 0)
Expand Down Expand Up @@ -785,7 +867,7 @@ private void TB_CNumber_KeyDown(object sender, KeyEventArgs e)
}
else
{
LoadCanvas(sn - 1);
LoadCanvas(sn - 1,true);
}
}
else
Expand Down
Loading