Compare commits

..

3 Commits

Author SHA1 Message Date
jrhodnik f1b647a1c5 Forgot to save csproj. 2019-06-06 19:56:47 -04:00
jrhodnik e3d8fa8094 First commit for sending out to Reddit testers. 2019-06-06 19:46:30 -04:00
jrhodnik a3d464197d Started implementing BrowserOverlay. 2019-06-05 02:38:41 -04:00
19 changed files with 528 additions and 40 deletions

View File

@ -6,6 +6,7 @@
xmlns:local="clr-namespace:VRDash" xmlns:local="clr-namespace:VRDash"
mc:Ignorable="d" mc:Ignorable="d"
KeyDown="Window_KeyDown" KeyDown="Window_KeyDown"
Closing="Window_Closing"
Title="VRDash" Height="700" Width="800"> Title="VRDash" Height="700" Width="800">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>

View File

@ -181,8 +181,20 @@ namespace VRDash
var overlayInfo = attrs.Single(x => x.OverlayType == overlay.GetType()); var overlayInfo = attrs.Single(x => x.OverlayType == overlay.GetType());
UI.IOverlayEditor editor = (UI.IOverlayEditor)Activator.CreateInstance(overlayInfo.Info.EditorType, new object[] { overlay.OverlayConfig }); UI.IOverlayEditor editor = (UI.IOverlayEditor)Activator.CreateInstance(overlayInfo.Info.EditorType, new object[] { overlay.OverlayConfig });
OverlayEditorInfo overlayEditor = new OverlayEditorInfo(new UI.OverlayEditor(editor), overlay); OverlayEditorInfo overlayEditor = new OverlayEditorInfo(new UI.OverlayEditor(editor), overlay);
IOverlayListViewItem lvi = (IOverlayListViewItem)Activator.CreateInstance(overlayInfo.Info.ListViewType, new object[] { overlayEditor }); IOverlayListViewItem lvi = null;
if (overlayInfo.Info.ListViewType != null)
{
lvi = (IOverlayListViewItem)Activator.CreateInstance(overlayInfo.Info.ListViewType, new object[] { overlayEditor });
OverlayManager.Overlays.Add(lvi); OverlayManager.Overlays.Add(lvi);
}
else
{
#if DEBUG
this.GetLogger().Warn($"No list view item for {overlayEditor.Overlay.GetType()}!");
#else
throw new Exception($"No list view item for {overlayEditor.Overlay.GetType()}!");
#endif
}
}; };
w.Content = uc; w.Content = uc;
w.Width = 500; w.Width = 500;
@ -220,15 +232,24 @@ namespace VRDash
private void Window_KeyDown(object sender, KeyEventArgs e) private void Window_KeyDown(object sender, KeyEventArgs e)
{ {
if(e.Key == Key.F1) //if(e.Key == Key.F1)
//{
// var conf = new MonitorOverlayConfig();
// conf.Name = "Test Browser";
// conf.Key = "asdfasdf";
// conf.Location = new Overlay.Config.OverlayLocation.DashboardLocation();
// var overlay = new Overlay.BrowserOverlay(conf);
// overlay.Create();
// overlay.Show();
//}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{ {
var conf = new MonitorOverlayConfig(); foreach(var overlayLVI in OverlayManager.Overlays)
conf.Name = "Test Browser"; {
conf.Key = "asdfasdf"; overlayLVI.Dispose();
conf.Location = new Overlay.Config.OverlayLocation.DashboardLocation(); overlayLVI.OverlayInfo.Overlay.Dispose();
var overlay = new Overlay.BrowserOverlay(conf);
overlay.Create();
overlay.Show();
} }
} }
} }

View File

@ -6,8 +6,15 @@
xmlns:local="clr-namespace:VRDash.Overlay" xmlns:local="clr-namespace:VRDash.Overlay"
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
mc:Ignorable="d" mc:Ignorable="d"
Title="BrowserOverlay" Height="450" Width="800"> Title="BrowserOverlay" Height="450" Width="800"
Closing="Window_Closing">
<Grid> <Grid>
<cefSharp:ChromiumWebBrowser x:Name="cwbBrowser" IsBrowserInitializedChanged="cwbBrowser_IsBrowserInitializedChanged" Paint="cwbBrowser_Paint"/> <Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button x:Name="btnTest" Grid.Row="0" Click="btnTest_Click"> Test</Button>
<cefSharp:ChromiumWebBrowser x:Name="cwbBrowser" Grid.Row="1" IsBrowserInitializedChanged="cwbBrowser_IsBrowserInitializedChanged" Paint="cwbBrowser_Paint"/>
</Grid> </Grid>
</Window> </Window>

View File

@ -4,7 +4,9 @@ using SharpDX.Direct3D11;
using SharpDX.DXGI; using SharpDX.DXGI;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -17,12 +19,15 @@ using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using Valve.VR; using Valve.VR;
using VRDash.Overlay.Config; using VRDash.Overlay.Config;
using VRDash.UI;
using VRDash.Utilities;
namespace VRDash.Overlay namespace VRDash.Overlay
{ {
/// <summary> /// <summary>
/// Interaction logic for BrowserOverlay.xaml /// Interaction logic for BrowserOverlay.xaml
/// </summary> /// </summary>
[OverlayInfo("Browser Overlay", typeof(BrowserOverlayConfig), typeof(BrowserOverlayEditor), typeof(UI.BrowserOverlayListViewItem))]
public partial class BrowserOverlay : Window, IOverlay public partial class BrowserOverlay : Window, IOverlay
{ {
ulong m_OverlayHandle = OpenVR.k_ulOverlayHandleInvalid; ulong m_OverlayHandle = OpenVR.k_ulOverlayHandleInvalid;
@ -32,8 +37,7 @@ namespace VRDash.Overlay
public IOverlayConfig OverlayConfig { get { return Config; } } public IOverlayConfig OverlayConfig { get { return Config; } }
//CHANGEME to the BrowserOverlayCOnfig you make later public BrowserOverlayConfig Config { get; }
public IOverlayConfig Config { get; }
public int CurrentFPS { get; private set; } = 0; public int CurrentFPS { get; private set; } = 0;
@ -45,11 +49,20 @@ namespace VRDash.Overlay
bool m_Created = false; bool m_Created = false;
//CHANGEME to the BrowserOverlayCOnfig you make later public BrowserOverlay(BrowserOverlayConfig config)
public BrowserOverlay(IOverlayConfig config)
{ {
Config = config; Config = config;
InitializeComponent(); InitializeComponent();
this.Show();
Width = Config.Width;
Height = Config.Height;
Config.SizeUpdated += Config_SizeUpdated;
}
private void Config_SizeUpdated(object sender, EventArgs e)
{
Width = Config.Width;
Height = Config.Height;
} }
Factory1 m_Factory = null; Factory1 m_Factory = null;
@ -89,7 +102,23 @@ namespace VRDash.Overlay
public void Destroy() public void Destroy()
{ {
throw new NotImplementedException(); m_ScreenTexture.Dispose();
m_Device.ImmediateContext.ClearState();
m_Device.ImmediateContext.Flush();
m_Device.Dispose();
m_Adapter.Dispose();
m_Factory.Dispose();
CurrentFPS = 0;
var err = OpenVR.Overlay.DestroyOverlay(m_OverlayHandle);
if (err != EVROverlayError.None)
{
throw new Exception($"Error destroying overlay: {err}");
}
m_OverlayHandle = OpenVR.k_ulOverlayHandleInvalid;
m_ThumbnailHandle = OpenVR.k_ulOverlayHandleInvalid;
} }
public void Dispose() public void Dispose()
@ -97,6 +126,7 @@ namespace VRDash.Overlay
if (IsDisposed) { return; } if (IsDisposed) { return; }
Destroy(); Destroy();
IsDisposed = true; IsDisposed = true;
this.Close();
} }
public string GetOverlayName() public string GetOverlayName()
@ -128,7 +158,14 @@ namespace VRDash.Overlay
{ {
if ((bool)e.NewValue) if ((bool)e.NewValue)
{ {
cwbBrowser.LoadHtml("<iframe frameborder=\"0\"\r\n scrolling=\"no\"\r\n id=\"chat_embed\"\r\n src=\"https://www.twitch.tv/embed/meteos/chat\"\r\n height=\"500\"\r\n width=\"350\">\r\n</iframe>"); if (Config.ContentType == BrowserOverlayConfig.BrowserOverlayContentType.Url && !String.IsNullOrWhiteSpace(Config.Content))
{
cwbBrowser.Load(Config.Content);
}
else if(Config.ContentType == BrowserOverlayConfig.BrowserOverlayContentType.Html && !String.IsNullOrWhiteSpace(Config.Content))
{
cwbBrowser.LoadHtml(Config.Content);
}
} }
} }
@ -137,6 +174,13 @@ namespace VRDash.Overlay
private void cwbBrowser_Paint(object sender, CefSharp.Wpf.PaintEventArgs e) private void cwbBrowser_Paint(object sender, CefSharp.Wpf.PaintEventArgs e)
{ {
if (!m_Created) { return; } if (!m_Created) { return; }
if (m_Device.IsDisposed)
{
this.GetLogger().Debug("m_Device is disposed. This should only happen on removal.");
return;
}
Update?.Invoke(this, null); Update?.Invoke(this, null);
if (m_ScreenTexture == null || (m_LastWidth != e.Width || m_LastHeight != e.Height)) if (m_ScreenTexture == null || (m_LastWidth != e.Width || m_LastHeight != e.Height))
@ -187,7 +231,7 @@ namespace VRDash.Overlay
{ {
int count = 4 * e.Width * e.Height; int count = 4 * e.Width * e.Height;
//Stride compensation. Sometimes the BMP and DX texture strides are different. This fixes it. //Stride compensation. Sometimes the browser stride and DX texture strides are different. This fixes it.
if (databox.RowPitch == stride) if (databox.RowPitch == stride)
{ {
m_Stream.Write(e.Buffer, 0, count); m_Stream.Write(e.Buffer, 0, count);
@ -237,5 +281,20 @@ namespace VRDash.Overlay
} }
#endregion #endregion
private void btnTest_Click(object sender, RoutedEventArgs e)
{
//Dispose();
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!IsDisposed)
{
e.Cancel = true;
Hide();
cwbBrowser.GetBrowserHost().WasHidden(false);
}
}
} }
} }

View File

@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VRDash.Overlay.Config.OverlayLocation;
namespace VRDash.Overlay.Config
{
public class BrowserOverlayConfig : IOverlayConfig
{
public string Name { get; set; }
public string Key { get; set; }
public float OverlayWidth { get; set; } = 2.5f;
public IOverlayLocation Location { get; set; }
public string Content { get; set; }
public BrowserOverlayContentType ContentType { get; set; }
public event EventHandler SizeUpdated;
private int m_Width = 600;
public int Width
{
get { return m_Width; }
set
{
m_Width = value;
SizeUpdated?.Invoke(this, null);
}
}
private int m_Height = 600;
public int Height
{
get { return m_Height; }
set
{
m_Height = value;
SizeUpdated?.Invoke(this, null);
}
}
public void Initialize(IOverlay overlay)
{
//Nothing needs to be done here
}
public enum BrowserOverlayContentType
{
Url=0,
Html=1
}
}
}

View File

@ -72,11 +72,7 @@ namespace VRDash.Overlay.Config.OverlayLocation
Location = Matrix3x4.Mult(Matrix3x4.CreateTranslation(PosX, PosY, PosZ), Matrix3x4.Mult(Matrix3x4.CreateFromQuaternion(quat), Matrix3x4.CreateScale(ScaleX, ScaleY, ScaleZ))); Location = Matrix3x4.Mult(Matrix3x4.CreateTranslation(PosX, PosY, PosZ), Matrix3x4.Mult(Matrix3x4.CreateFromQuaternion(quat), Matrix3x4.CreateScale(ScaleX, ScaleY, ScaleZ)));
//Location = Matrix3x4.CreateTranslation(PosX, PosY, PosZ); if (m_Overlay.OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) { return; }
//Location = Matrix3x4.Add(Matrix3x4.CreateFromQuaternion(quat), Location);
//Location = Matrix3x4.Add(Matrix3x4.CreateScale(ScaleX, ScaleY, ScaleZ), Location);
if (m_Overlay.OverlayHandle == OpenVR.k_ulOverlayHandleInvalid || m_ControllerIndex == OpenVR.k_unTrackedDeviceIndexInvalid) { return; }
//Index changed, need to update the overlay //Index changed, need to update the overlay
if (controllerIndex != m_ControllerIndex) if (controllerIndex != m_ControllerIndex)

View File

@ -16,12 +16,18 @@ namespace VRDash.Overlay.Config.OverlayLocation
ulong thumbnailHandle = 0; ulong thumbnailHandle = 0;
//Actually create the overlay //Actually create the overlay
try
{
EVROverlayError err = OpenVR.Overlay.CreateDashboardOverlay(key, name, ref overalyHandle, ref thumbnailHandle); EVROverlayError err = OpenVR.Overlay.CreateDashboardOverlay(key, name, ref overalyHandle, ref thumbnailHandle);
if (err != EVROverlayError.None) if (err != EVROverlayError.None)
{ {
throw new Exception($"Error creating overlay: {err}"); throw new Exception($"Error creating overlay: {err}");
} }
}
catch (Exception ex)
{
this.GetLogger(overlay).Error("Unable to create new OpenVR overlay.", ex);
}
OverlayHandles handles = new OverlayHandles(overalyHandle, thumbnailHandle); OverlayHandles handles = new OverlayHandles(overalyHandle, thumbnailHandle);
return handles; return handles;

View File

@ -0,0 +1,124 @@
//using Newtonsoft.Json;
//using OpenTK;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using Valve.VR;
//using VRDash.UI.LocationEditors;
//using VRDash.Utilities;
//namespace VRDash.Overlay.Config.OverlayLocation
//{
// [OverlayLocationInfo("Playspace", typeof(ControllerLocationEditor))]
// public class PlayspaceLocation : IOverlayLocation
// {
// public ControllerHand Controller { get; set; } = ControllerHand.Left;
// [JsonIgnore]
// public Matrix3x4 Location { get; private set; } = new Matrix3x4(new Vector4(1, 0, 0, 0),
// new Vector4(0, 1, 0, 0),
// new Vector4(0, 0, 1, 0));
// public float PosX { get; set; } = 0;
// public float PosY { get; set; } = 0;
// public float PosZ { get; set; } = 0;
// public float RotP { get; set; } = 0;
// public float RotY { get; set; } = 0;
// public float RotR { get; set; } = 0;
// public float ScaleX { get; set; } = 1;
// public float ScaleY { get; set; } = 1;
// public float ScaleZ { get; set; } = 1;
// DateTime m_LastCheck = DateTime.MinValue;
// IOverlay m_Overlay = null;
// public OverlayHandles CreateOverlay(string key, string name, IOverlay overlay)
// {
// ulong overlayHandle = 0;
// EVROverlayError err = OpenVR.Overlay.CreateOverlay(key, name, ref overlayHandle);
// if (err != EVROverlayError.None){
// throw new Exception($"Error creating overlay: {err}");
// }
// ETrackedDeviceClass type = OpenVR.System.GetTrackedDeviceClass(0);
// overlay.Update += Overlay_Update;
// m_Overlay = overlay;
// return new OverlayHandles(overlayHandle, 0);
// }
// public void SetLocationBasedOnController()
// {
// uint controllerIndex = OpenVR.System.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand);
// TrackedDevicePose_t pose = new TrackedDevicePose_t();
// TrackedDevicePose_t gamePose = new TrackedDevicePose_t();
// var err = OpenVR.Compositor.GetLastPoseForTrackedDeviceIndex(controllerIndex, ref pose, ref gamePose);
// if(err != EVRCompositorError.None)
// {
// this.GetLogger(m_Overlay).Warn($"Unable to set location based on controller: {err}");
// return;
// }
// if(pose.eTrackingResult != ETrackingResult.Running_OK)
// {
// this.GetLogger(m_Overlay).Warn($"Unable to get reliable tracking: {pose.eTrackingResult}");
// }
// var matrix = pose.mDeviceToAbsoluteTracking.ToOpenTKMatrix();
// matrix
// }
// private void Overlay_Update(object sender, EventArgs e)
// {
// if (DateTime.Now.Subtract(m_LastCheck).TotalSeconds >= 1)
// {
// MathHelper.DegreesToRadians(RotP);
// var quat = Quaternion.FromEulerAngles(MathHelper.DegreesToRadians(RotP), MathHelper.DegreesToRadians(RotY), MathHelper.DegreesToRadians(RotR));
// Location = Matrix3x4.Mult(Matrix3x4.CreateTranslation(PosX, PosY, PosZ), Matrix3x4.Mult(Matrix3x4.CreateFromQuaternion(quat), Matrix3x4.CreateScale(ScaleX, ScaleY, ScaleZ)));
// if (m_Overlay.OverlayHandle == OpenVR.k_ulOverlayHandleInvalid) { return; }
// var matrix = Location.ToOpenVRMatrix();
// var err = OpenVR.Overlay.SetOverlayTransformAbsolute(m_Overlay.OverlayHandle, ETrackingUniverseOrigin.TrackingUniverseStanding, ref matrix);
// //var err = OpenVR.Overlay.SetOverlayTransformTrackedDeviceRelative(m_Overlay.OverlayHandle, m_ControllerIndex, ref matrix);
// if (err != EVROverlayError.None)
// {
// this.GetLogger(m_Overlay).Warn($"Error setting tracked device relative to {Controller} hand: {err}");
// }
// else
// {
// this.GetLogger(m_Overlay).Info($"Controller index updated.");
// }
// m_LastCheck = DateTime.Now;
// }
// }
// public void ResetCheckTimer()
// {
// m_LastCheck = DateTime.MinValue;
// }
// public enum ControllerHand
// {
// Left = 0,
// Right = 1
// }
// }
//}

View File

@ -49,8 +49,8 @@ namespace VRDash.Overlay
internal ulong m_OverlayHandle; internal ulong m_OverlayHandle;
public ulong OverlayHandle { get { return m_OverlayHandle; } } public ulong OverlayHandle { get { return m_OverlayHandle; } }
internal ulong m_ThumbnailIcon; internal ulong m_ThumbnailHandle;
public ulong ThumbnailIcon { get { return m_ThumbnailIcon; } } public ulong ThumbnailIcon { get { return m_ThumbnailHandle; } }
public IOverlayConfig OverlayConfig { get { return Config; } } public IOverlayConfig OverlayConfig { get { return Config; } }
public MonitorOverlayConfig Config { get; } public MonitorOverlayConfig Config { get; }
@ -105,7 +105,7 @@ namespace VRDash.Overlay
} }
m_OverlayHandle = OpenVR.k_ulOverlayHandleInvalid; m_OverlayHandle = OpenVR.k_ulOverlayHandleInvalid;
m_ThumbnailIcon = OpenVR.k_ulOverlayHandleInvalid; m_ThumbnailHandle = OpenVR.k_ulOverlayHandleInvalid;
} }
private void EventPump() private void EventPump()
@ -126,7 +126,7 @@ namespace VRDash.Overlay
Config.OverlayLocation.OverlayHandles overlayHandles = Config.Location.CreateOverlay(Config.Key, Config.Name, this); Config.OverlayLocation.OverlayHandles overlayHandles = Config.Location.CreateOverlay(Config.Key, Config.Name, this);
m_OverlayHandle = overlayHandles.OverlayHandle; m_OverlayHandle = overlayHandles.OverlayHandle;
m_ThumbnailIcon = overlayHandles.ThumbnailHandle; m_ThumbnailHandle = overlayHandles.ThumbnailHandle;
overlay.SetOverlayFlag(m_OverlayHandle, VROverlayFlags.SendVRDiscreteScrollEvents, true); overlay.SetOverlayFlag(m_OverlayHandle, VROverlayFlags.SendVRDiscreteScrollEvents, true);

View File

@ -0,0 +1,38 @@
<UserControl x:Class="VRDash.UI.BrowserOverlayEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VRDash.UI"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" >Name:</TextBlock>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Config.Name}" Margin="5,5,5,0"/>
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" >Content Type:</TextBlock>
<ComboBox x:Name="cbContentType" Grid.Row="1" Grid.Column="1" SelectedItem="{Binding Config.ContentType}" Margin="5,5,5,5" SelectionChanged="cbContentType_SelectionChanged"/>
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,0,5">Size:</TextBlock>
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" Margin="5,0,0,5">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,5,0">Width:</TextBlock>
<TextBox x:Name="tbWidth" Width="40" Text="{Binding Config.Width}"/>
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,5,0">Height:</TextBlock>
<TextBox x:Name="tbHeight" Width="40" Text="{Binding Config.Height}"/>
</StackPanel>
<TextBlock x:Name="lblContent" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,5,0">Content:</TextBlock>
<TextBox x:Name="tbContent" Grid.Row="3" Grid.Column="1" Text="{Binding Config.Content}" TextWrapping="Wrap" AcceptsReturn="True" Height="Auto" Margin="5,0,5,0" />
</Grid>
</UserControl>

View File

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VRDash.Overlay.Config;
namespace VRDash.UI
{
/// <summary>
/// Interaction logic for BrowserOverlayConfigEditor.xaml
/// </summary>
public partial class BrowserOverlayEditor : UserControl, IOverlayEditor
{
public BrowserOverlayEditor(BrowserOverlayConfig config)
{
InitializeComponent();
DataContext = this;
OverlayConfig = config;
cbContentType.ItemsSource = Enum.GetValues(typeof(BrowserOverlayConfig.BrowserOverlayContentType));
UpdateGui();
}
public IOverlayConfig Config { get { return OverlayConfig; } }
public BrowserOverlayConfig OverlayConfig { get; private set; }
public string[] ValidateInput()
{
List<string> issues = new List<string>();
if (String.IsNullOrWhiteSpace(Config.Name))
{
issues.Add("Please enter a name.");
}
if(cbContentType.SelectedIndex < 0)
{
issues.Add("Please select a content type.");
}
return issues.ToArray();
}
private void UpdateGui()
{
if (cbContentType.SelectedItem != null)
{
var contentType = (BrowserOverlayConfig.BrowserOverlayContentType)cbContentType.SelectedItem;
tbContent.Text = "";
if (contentType == BrowserOverlayConfig.BrowserOverlayContentType.Html)
{
tbContent.AcceptsReturn = true;
tbContent.MinHeight = 400;
}
else
{
tbContent.AcceptsReturn = false;
tbContent.MinHeight = 0;
}
lblContent.Text = cbContentType.SelectedItem.ToString() + ":";
}
}
private void cbContentType_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
UpdateGui();
}
}
}

View File

@ -0,0 +1,25 @@
<UserControl x:Class="VRDash.UI.BrowserOverlayListViewItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VRDash.UI"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
MouseDoubleClick="UserControl_MouseDoubleClick">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock x:Name="tbName" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold">Name</TextBlock>
<TextBlock x:Name="tbFPS" Grid.Row="1" Grid.Column="1" Margin="0,0,10,0">Loading...</TextBlock>
<TextBlock x:Name="tbURL" Grid.Row="1" Grid.Column="2" FontStyle="Italic">Loading...</TextBlock>
</Grid>
</UserControl>

View File

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using VRDash.Overlay;
namespace VRDash.UI
{
/// <summary>
/// Interaction logic for BrowserOverlayListViewItem.xaml
/// </summary>
public partial class BrowserOverlayListViewItem : UserControl,IDisposable,IOverlayListViewItem
{
public BrowserOverlay Overlay { get { return (BrowserOverlay)OverlayInfo.Overlay; } }
public OverlayEditorInfo OverlayInfo { get; private set; }
DispatcherTimer m_Timer = null;
public BrowserOverlayListViewItem(OverlayEditorInfo overlayInfo)
{
InitializeComponent();
OverlayInfo = overlayInfo;
m_Timer = new DispatcherTimer(new TimeSpan(0, 0, 0, 0, 300), DispatcherPriority.Normal, OnTimerTick, this.Dispatcher);
m_Timer.Start();
}
private void TestShit()
{
}
private void OnTimerTick(object x, object y)
{
tbName.Text = Overlay.OverlayConfig.Name;
tbFPS.Text = $"{Overlay.CurrentFPS} FPS";
tbURL.Text = "Placeholder";
}
public void Dispose()
{
m_Timer?.Stop();
}
private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
Overlay.Show();
}
}
}

View File

@ -32,7 +32,7 @@ namespace VRDash.Utilities
return newmatrix; return newmatrix;
} }
public static Matrix3x4 ToOpenVRMatrix(this HmdMatrix34_t matrix) public static Matrix3x4 ToOpenTKMatrix(this HmdMatrix34_t matrix)
{ {
Matrix3x4 newmatrix = new Matrix3x4(); Matrix3x4 newmatrix = new Matrix3x4();

View File

@ -105,6 +105,8 @@
<Compile Include="Overlay\BrowserOverlay.xaml.cs"> <Compile Include="Overlay\BrowserOverlay.xaml.cs">
<DependentUpon>BrowserOverlay.xaml</DependentUpon> <DependentUpon>BrowserOverlay.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Overlay\Config\BrowserOverlayConfig.cs" />
<Compile Include="Overlay\Config\OverlayLocation\PlayspaceLocation.cs" />
<Compile Include="Overlay\Config\OverlayLocation\ControllerLocation.cs" /> <Compile Include="Overlay\Config\OverlayLocation\ControllerLocation.cs" />
<Compile Include="Overlay\Config\OverlayLocation\DashboardLocation.cs" /> <Compile Include="Overlay\Config\OverlayLocation\DashboardLocation.cs" />
<Compile Include="Overlay\Config\OverlayLocation\IOverlayLocation.cs" /> <Compile Include="Overlay\Config\OverlayLocation\IOverlayLocation.cs" />
@ -127,6 +129,12 @@
<Compile Include="UI\ActionEditors\ResizeWindowActionEditor.xaml.cs"> <Compile Include="UI\ActionEditors\ResizeWindowActionEditor.xaml.cs">
<DependentUpon>ResizeWindowActionEditor.xaml</DependentUpon> <DependentUpon>ResizeWindowActionEditor.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UI\BrowserOverlayEditor.xaml.cs">
<DependentUpon>BrowserOverlayEditor.xaml</DependentUpon>
</Compile>
<Compile Include="UI\BrowserOverlayListViewItem.xaml.cs">
<DependentUpon>BrowserOverlayListViewItem.xaml</DependentUpon>
</Compile>
<Compile Include="UI\CreateNewOverlay.xaml.cs"> <Compile Include="UI\CreateNewOverlay.xaml.cs">
<DependentUpon>CreateNewOverlay.xaml</DependentUpon> <DependentUpon>CreateNewOverlay.xaml</DependentUpon>
</Compile> </Compile>
@ -142,7 +150,7 @@
<Compile Include="UI\OverlayEditor.xaml.cs"> <Compile Include="UI\OverlayEditor.xaml.cs">
<DependentUpon>OverlayEditor.xaml</DependentUpon> <DependentUpon>OverlayEditor.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UI\ProcessSelectorEditor.xaml.cs"> <Compile Include="UI\SelectorEditors\ProcessSelectorEditor.xaml.cs">
<DependentUpon>ProcessSelectorEditor.xaml</DependentUpon> <DependentUpon>ProcessSelectorEditor.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UI\WindowOverlayEditor.xaml.cs"> <Compile Include="UI\WindowOverlayEditor.xaml.cs">
@ -154,7 +162,7 @@
<Compile Include="UI\WindowOverlayListViewItem.xaml.cs"> <Compile Include="UI\WindowOverlayListViewItem.xaml.cs">
<DependentUpon>WindowOverlayListViewItem.xaml</DependentUpon> <DependentUpon>WindowOverlayListViewItem.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UI\WindowSelectorEditor.xaml.cs"> <Compile Include="UI\SelectorEditors\WindowSelectorEditor.xaml.cs">
<DependentUpon>WindowSelectorEditor.xaml</DependentUpon> <DependentUpon>WindowSelectorEditor.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Utilities\OpenTKExtensions.cs" /> <Compile Include="Utilities\OpenTKExtensions.cs" />
@ -183,6 +191,14 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="UI\BrowserOverlayEditor.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\BrowserOverlayListViewItem.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\CreateNewOverlay.xaml"> <Page Include="UI\CreateNewOverlay.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -199,7 +215,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="UI\ProcessSelectorEditor.xaml"> <Page Include="UI\SelectorEditors\ProcessSelectorEditor.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@ -215,7 +231,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="UI\WindowSelectorEditor.xaml"> <Page Include="UI\SelectorEditors\WindowSelectorEditor.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>