Skip to content

Commit

Permalink
Better Timers & Exit Link Function
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisIsBackAU committed May 25, 2022
1 parent f6b8525 commit f04d460
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 106 deletions.
5 changes: 5 additions & 0 deletions Oculus VR Dash Manager/Dashes/Dash Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,10 @@ private static Boolean Running(ServiceControllerStatus Status)
return false;
}
}

public static bool Oculus_Offical_Dash_Installed()
{
return Oculus_Dash.Installed;
}
}
}
1 change: 1 addition & 0 deletions Oculus VR Dash Manager/Dashes/Types.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public enum Dash_Type
{
Exit = -1,
Unknown = 0,
Normal = 1,
OculusKiller = 2
Expand Down
87 changes: 45 additions & 42 deletions Oculus VR Dash Manager/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
using System.Security.Principal;
using System.Text;
using System.Text.RegularExpressions;
using System.Timers;
using System.Windows;
using System.Windows.Threading;

namespace OVR_Dash_Manager
{
public static class Functions
{
public static void ShowFileInDirectory(String FullPath)
{
Process.Start("explorer.exe", $@"/select,""{FullPath}""");
}
public static String GetPageHTML(String pURL, String Method = "GET", CookieContainer Cookies = null, String FormParams = "", String ContentType = "")
{
if (pURL.Contains("&"))
Expand Down Expand Up @@ -155,24 +161,39 @@ public static void MoveCursor(int X, int Y)
SetCursorPos(X, Y);
}
}

public static class Dispatcher_Timer_Functions
public static class Timer_Functions
{
private static Dictionary<String, DispatcherTimer> gTimers = null;
private static Dictionary<String, Boolean> gAutoRepeat = null;
private static Dictionary<String, Timer> gTimers = null;
private static Boolean BeenSetup = false;

private static void Setup()
{
if (gTimers == null)
{
gTimers = new Dictionary<string, DispatcherTimer>();
gAutoRepeat = new Dictionary<string, bool>();
gTimers = new Dictionary<string, Timer>();
BeenSetup = true;
}
}

public static Boolean CreateTimer(String pTimerID, TimeSpan pInterval, EventHandler pTickHandler, Boolean pRepeat = true)
public static Boolean SetNewInterval(String pTimerID, TimeSpan pInterval)
{
if (!BeenSetup)
return false;


Boolean pReturn = false;

if (gTimers.ContainsKey(pTimerID))
{
Timer vTimer = gTimers[pTimerID];
vTimer.Interval = pInterval.TotalMilliseconds;
pReturn = true;
}

return pReturn;
}

public static Boolean CreateTimer(String pTimerID, TimeSpan pInterval, ElapsedEventHandler pTickHandler, Boolean pRepeat = true)
{
if (!BeenSetup)
Setup();
Expand All @@ -181,50 +202,36 @@ public static Boolean CreateTimer(String pTimerID, TimeSpan pInterval, EventHand

if (!gTimers.ContainsKey(pTimerID))
{
DispatcherTimer vTimer = new DispatcherTimer
Timer vTimer = new Timer
{
Interval = pInterval,
IsEnabled = true,
Tag = pTimerID
Interval = pInterval.TotalMilliseconds,
AutoReset = pRepeat,
Enabled = false
};

vTimer.Tick += ElpasedAutoRetrigger;
vTimer.Tick += pTickHandler;

vTimer.Stop();
vTimer.Elapsed += pTickHandler;
vTimer.Start();

gTimers.Add(pTimerID, vTimer);
gAutoRepeat.Add(pTimerID, pReturn);

pReturn = true;
}

return pReturn;
}

private static void ElpasedAutoRetrigger(object sender, EventArgs args)
{
DispatcherTimer pTimer = (DispatcherTimer)sender;
Boolean Repeat = false;
gAutoRepeat.TryGetValue(pTimer.Tag.ToString(), out Repeat);
if (Repeat)
{
pTimer.Stop();
pTimer.Start();
}
}

public static Boolean StartTimer(String pTimerID)
{
if (!BeenSetup)
return false;


Boolean pReturn = false;

if (gTimers.ContainsKey(pTimerID))
{
DispatcherTimer vTimer = gTimers[pTimerID];
vTimer.Start();
Timer vTimer = gTimers[pTimerID];
vTimer.Enabled = true;
pReturn = true;
}

Expand All @@ -236,12 +243,13 @@ public static Boolean StopTimer(String pTimerID)
if (!BeenSetup)
return false;


Boolean pReturn = false;

if (gTimers.ContainsKey(pTimerID))
{
DispatcherTimer vTimer = gTimers[pTimerID];
vTimer.Stop();
Timer vTimer = gTimers[pTimerID];
vTimer.Enabled = false;
pReturn = true;
}

Expand All @@ -263,30 +271,25 @@ public static Boolean TimerExists(String pTimerID)

public static void DisposeTimer(String pTimerID)
{
if (!BeenSetup)
return;

if (gTimers.ContainsKey(pTimerID))
{
DispatcherTimer vTimer = gTimers[pTimerID];
Timer vTimer = gTimers[pTimerID];
gTimers.Remove(pTimerID);
gAutoRepeat.Remove(pTimerID);

vTimer.Stop();
}
}

public static void DisposeAllTimers()
{
if (!BeenSetup)
return;

foreach (KeyValuePair<String, DispatcherTimer> oTimer in gTimers)
foreach (KeyValuePair<String, Timer> oTimer in gTimers)
{
oTimer.Value.Stop();
oTimer.Value.Dispose();
}

gTimers.Clear();
gAutoRepeat.Clear();
}
}

}
23 changes: 13 additions & 10 deletions Oculus VR Dash Manager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:OVR_Dash_Manager"
mc:Ignorable="d"
Title="Oculus VR Dash Manager" Height="284" Width="608" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" Loaded="Window_Loaded" Closing="Window_Closing">
Title="Oculus VR Dash Manager" Height="374" Width="626" WindowStartupLocation="CenterScreen" ResizeMode="CanMinimize" Loaded="Window_Loaded" Closing="Window_Closing">

<Grid Background="{StaticResource WindowBackgroundBrush}">
<Label x:Name="lbl_Title" Content="Oculus VR Dash Manager - KrisIsBack (AU)" Margin="10,5,10,0" VerticalAlignment="Top" Height="41" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" FontWeight="Bold" Cursor="Hand" PreviewMouseDown="lbl_Title_PreviewMouseDown" />
<Label Content="Current Dash" Margin="10,0,10,36" VerticalAlignment="Bottom" Height="41" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" FontWeight="Bold" />
<Label x:Name="lbl_CurrentSetting" Content="Unknown" Margin="10,0,10,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" Height="36" VerticalAlignment="Bottom" />
<GroupBox Header="Dashes" Margin="10,51,10,82">
<Label Content="Current Dash" Margin="10,222,10,0" VerticalAlignment="Top" Height="41" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" FontWeight="Bold" />
<Label x:Name="lbl_CurrentSetting" Content="Unknown" Margin="10,263,10,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" Height="36" VerticalAlignment="Top" />
<GroupBox Header="Dashes" Margin="10,51,10,0" Height="171" VerticalAlignment="Top">
<Grid x:Name="gd_DashButtons">
<Button x:Name="btn_Normal" Content="Offical Dash (SteamVR Hover for 5 Seconds)" HorizontalAlignment="Left" Width="270" Margin="0,0,0,23" Click="btn_ActivateDash_Click" MouseEnter="btn_Normal_MouseEnter" MouseLeave="btn_Normal_MouseLeave" />
<ProgressBar x:Name="pb_Normal" HorizontalAlignment="Left" Width="270" Maximum="5000" SmallChange="10" Height="23" VerticalAlignment="Bottom" />
<Label x:Name="lbl_ItsKaitlyn03" Content="Visit ItsKaitlyn03 (Github)" HorizontalAlignment="Right" Width="270" Height="32" VerticalAlignment="Bottom" FontSize="12" HorizontalContentAlignment="Right" Cursor="Hand" PreviewMouseDown="lbl_ItsKaitlyn03_PreviewMouseDown" VerticalContentAlignment="Bottom" />
<Button x:Name="btn_SteamVR" Content=" ItsKaitlyn03 / OculusKiller - SteamVR Only" HorizontalAlignment="Right" Width="270" Click="btn_ActivateDash_Click" Margin="0,0,0,23" />
<Button x:Name="btn_Normal" Content="Offical Dash&#10;&#10;(SteamVR)&#10;Hover for 5 Seconds" HorizontalAlignment="Left" Width="200" Margin="0,0,0,23" Click="btn_ActivateDash_Click" MouseEnter="btn_Normal_MouseEnter" MouseLeave="btn_Normal_MouseLeave" />
<ProgressBar x:Name="pb_Normal" HorizontalAlignment="Left" Width="200" Maximum="5000" SmallChange="10" Height="23" VerticalAlignment="Bottom" />
<Label x:Name="lbl_ItsKaitlyn03" Content="Visit ItsKaitlyn03 (Github)" HorizontalAlignment="Left" Width="200" Height="32" VerticalAlignment="Bottom" FontSize="12" HorizontalContentAlignment="Right" Cursor="Hand" PreviewMouseDown="lbl_ItsKaitlyn03_PreviewMouseDown" VerticalContentAlignment="Bottom" Margin="217,0,0,0" />
<Button x:Name="btn_SteamVR" Content="ItsKaitlyn03 / OculusKiller&#10;&#10;(SteamVR Mode Only)" HorizontalAlignment="Left" Width="200" Click="btn_ActivateDash_Click" Margin="217,0,0,23" />
<Button x:Name="btn_ExitOculusLink" HorizontalAlignment="Right" Width="143" Click="btn_ActivateDash_Click" Margin="0,0,0,23" Content="Exit Link&#10;&#10;(SteamVR)&#10;Hover 5 Seconds" MouseEnter="btn_ExitOculusLink_MouseEnter" MouseLeave="btn_ExitOculusLink_MouseLeave" />
<ProgressBar x:Name="pb_Exit" HorizontalAlignment="Right" Width="143" Maximum="5000" SmallChange="10" Height="23" VerticalAlignment="Bottom" />
</Grid>
</GroupBox>
<CheckBox x:Name="chkbx_CheckForUpdates" Content="Check for Updates on Launch" HorizontalAlignment="Right" Margin="0,0,10,66" VerticalAlignment="Bottom" Width="180" Checked="chkbx_CheckForUpdates_Checked" Unchecked="chkbx_CheckForUpdates_Unchecked" />
<CheckBox x:Name="chkbx_AlwaysOnTop" Content="Always On Top" HorizontalAlignment="Left" Margin="10,0,0,63" VerticalAlignment="Bottom" Width="180" Checked="chkbx_AlwaysOnTop_Checked" Unchecked="chkbx_AlwaysOnTop_Unchecked"/>
<CheckBox x:Name="chkbx_CheckForUpdates" Content="Check for Updates on Launch" HorizontalAlignment="Left" Margin="160,0,0,13" Width="180" Checked="chkbx_CheckForUpdates_Checked" Unchecked="chkbx_CheckForUpdates_Unchecked" Height="16" VerticalAlignment="Bottom" />
<CheckBox x:Name="chkbx_AlwaysOnTop" Content="Always On Top" HorizontalAlignment="Left" Margin="373,0,0,13" Width="130" Checked="chkbx_AlwaysOnTop_Checked" Unchecked="chkbx_AlwaysOnTop_Unchecked" Height="16" VerticalAlignment="Bottom"/>
<Button x:Name="btn_OpenDashLocation" Content="Open Dash Location" HorizontalAlignment="Left" Margin="10,0,0,10" VerticalAlignment="Bottom" Click="btn_OpenDashLocation_Click" Height="22" Width="114"/>
</Grid>
</Window>
Loading

0 comments on commit f04d460

Please sign in to comment.