diff --git a/VDash/ConfigManager.cs b/VDash/ConfigManager.cs
index c75b815..a936f05 100644
--- a/VDash/ConfigManager.cs
+++ b/VDash/ConfigManager.cs
@@ -3,10 +3,29 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using VDash.Overlay.Config;
namespace VDash
{
- class ConfigManager
+ public class ConfigManager
{
+ public string ConfigLocation { get; private set; }
+ public ConfigManager()
+ {
+ ConfigLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments, Environment.SpecialFolderOption.None) + @"\VRDash\DefaultProfile.json";
+ }
+
+ ///
+ /// Saves config to ConfigLocation
+ ///
+ public void SaveConfig()
+ {
+
+ }
+ }
+
+ public class Profile
+ {
+ public List OverlayConfigs { get; private set; }
}
}
diff --git a/VDash/MainWindow.xaml b/VDash/MainWindow.xaml
index f545546..d7a350c 100644
--- a/VDash/MainWindow.xaml
+++ b/VDash/MainWindow.xaml
@@ -25,10 +25,14 @@
-
+
+
+
+
+
diff --git a/VDash/MainWindow.xaml.cs b/VDash/MainWindow.xaml.cs
index bbaa829..7a3095a 100644
--- a/VDash/MainWindow.xaml.cs
+++ b/VDash/MainWindow.xaml.cs
@@ -14,6 +14,8 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using Valve.VR;
using VDash.Overlay;
+using VDash.Overlay.Config;
+using VDash.UI;
using VDash.Utilities;
namespace VDash
@@ -24,6 +26,13 @@ namespace VDash
public partial class MainWindow : Window
{
public static OverlayManager OverlayManager = new OverlayManager();
+ public static List EditorMapping = new List()
+ {
+ new EditorMap(typeof(MonitorOverlay), typeof(UI.MonitorOverlayEditor)),
+ new EditorMap(typeof(WindowOverlay), typeof(UI.WindowOverlayEditor))
+ };
+
+ List overlayEditors = new List();
public MainWindow()
{
InitializeComponent();
@@ -73,7 +82,12 @@ namespace VDash
{
Window w = new Window();
var uc = new UI.CreateNewOverlay();
- uc.Created += (x, y) => { w.Close(); };
+ uc.Created += (snd, overlay) => {
+ w.Close();
+ UI.IOverlayEditor editor = (UI.IOverlayEditor)Activator.CreateInstance(EditorMapping.Single(x => x.OverlayType == overlay.GetType()).EditorType, new object[] { overlay.OverlayConfig });
+ OverlayEditor overlayEditor = new OverlayEditor(new UI.OverlayEditor(editor), overlay);
+ overlayEditors.Add(overlayEditor);
+ };
w.Content = uc;
w.Width = 500;
w.Height = 400;
@@ -87,6 +101,39 @@ namespace VDash
IOverlay overlay = (IOverlay)lvOverlays.SelectedItem;
overlay.Dispose();
OverlayManager.Overlays.Remove(overlay);
+ overlayEditors.Remove(overlayEditors.Single(x => x.Overlay == overlay));
+ }
+
+ private void lvOverlays_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (lvOverlays.SelectedItem == null) { return; }
+ IOverlay overlay = (IOverlay)lvOverlays.SelectedItem;
+
+ bdrContent.Child = (UserControl)overlayEditors.Single(x => x.Overlay == overlay).Editor;
}
}
+
+ public class OverlayEditor
+ {
+ public OverlayEditor(IOverlayEditor editor, IOverlay overlay)
+ {
+ Editor = editor;
+ Overlay = overlay;
+ }
+
+ public UI.IOverlayEditor Editor { get; private set; }
+ public IOverlay Overlay { get; private set; }
+ }
+
+ public class EditorMap
+ {
+ public EditorMap(Type overlayType, Type editorType)
+ {
+ OverlayType = overlayType;
+ EditorType = editorType;
+ }
+
+ public Type OverlayType { get; private set; }
+ public Type EditorType { get; private set; }
+ }
}
diff --git a/VDash/Overlay/Config/IOverlayConfig.cs b/VDash/Overlay/Config/IOverlayConfig.cs
index 0dc7ba2..a3367c8 100644
--- a/VDash/Overlay/Config/IOverlayConfig.cs
+++ b/VDash/Overlay/Config/IOverlayConfig.cs
@@ -10,5 +10,6 @@ namespace VDash.Overlay.Config
{
string Name { get; set; }
string Key { get; set; }
+ float OverlayWidth { get; set; }
}
}
diff --git a/VDash/Overlay/Config/MonitorOverlayConfig.cs b/VDash/Overlay/Config/MonitorOverlayConfig.cs
index 63e1027..55a4097 100644
--- a/VDash/Overlay/Config/MonitorOverlayConfig.cs
+++ b/VDash/Overlay/Config/MonitorOverlayConfig.cs
@@ -8,8 +8,19 @@ namespace VDash.Overlay.Config
{
public class MonitorOverlayConfig : IOverlayConfig
{
+ public event EventHandler WidthUpdated;
public string Name { get; set; }
public string Key { get; set; }
public string MonitorName { get; set; }
+ float m_Width = 2.5f;
+ public float OverlayWidth
+ {
+ get { return m_Width; }
+ set
+ {
+ m_Width = value;
+ WidthUpdated?.Invoke(this, null);
+ }
+ }
}
}
diff --git a/VDash/Overlay/Config/WindowOverlayConfig.cs b/VDash/Overlay/Config/WindowOverlayConfig.cs
index cef802a..f80ca08 100644
--- a/VDash/Overlay/Config/WindowOverlayConfig.cs
+++ b/VDash/Overlay/Config/WindowOverlayConfig.cs
@@ -9,6 +9,7 @@ namespace VDash.Overlay.Config
{
public class WindowOverlayConfig : IOverlayConfig
{
+ public event EventHandler WidthUpdated;
public WindowOverlayConfig(string name, string key, IWindowSelector selector, bool updateDashboardName, bool destroyOnNoWindowFound)
{
Name = name;
@@ -25,5 +26,15 @@ namespace VDash.Overlay.Config
public IWindowSelector Selector {get; set; }
public bool UpdateDashboardName { get; set; } = false;
public bool DestroyOnNoWindowFound { get; set; } = false;
+ float m_Width = 2.5f;
+ public float OverlayWidth
+ {
+ get { return m_Width; }
+ set
+ {
+ m_Width = value;
+ WidthUpdated?.Invoke(this, null);
+ }
+ }
}
}
diff --git a/VDash/Overlay/MonitorOverlay.cs b/VDash/Overlay/MonitorOverlay.cs
index 9d805e6..698e0c7 100644
--- a/VDash/Overlay/MonitorOverlay.cs
+++ b/VDash/Overlay/MonitorOverlay.cs
@@ -52,13 +52,14 @@ namespace VDash.Overlay
public List OverlayHiddenActions { get; private set; } = new List();
public IOverlayConfig OverlayConfig { get { return Config; } }
- public MonitorOverlayConfig Config { get; set; }
+ public MonitorOverlayConfig Config { get; }
char[] specialKeys = { '+', '^', '%', '~', '(', ')', '{', '}', '[', ']' };
public MonitorOverlay(MonitorOverlayConfig config)
{
Config = config;
+ Config.WidthUpdated += (x, y) => { SetOverlayWidth(Config.OverlayWidth); };
}
@@ -421,7 +422,7 @@ namespace VDash.Overlay
screenTexture = new Texture2D(device, textureDesc);
stream = new DataStream(4 * width * height, true, true);
- overlay.SetOverlayWidthInMeters(m_OverlayHandle, 2.5f);
+ overlay.SetOverlayWidthInMeters(m_OverlayHandle, Config.OverlayWidth);
HmdVector2_t vecWindowSize = new HmdVector2_t() { v0 = data.Width, v1 = data.Height };
OpenVR.Overlay.SetOverlayMouseScale(m_OverlayHandle, ref vecWindowSize);
diff --git a/VDash/Overlay/WindowOverlay.cs b/VDash/Overlay/WindowOverlay.cs
index df2b4e7..4e8941c 100644
--- a/VDash/Overlay/WindowOverlay.cs
+++ b/VDash/Overlay/WindowOverlay.cs
@@ -39,7 +39,7 @@ namespace VDash.Overlay
public ulong ThumbnailIcon { get { return m_ThumbnailIcon; } }
public IOverlayConfig OverlayConfig { get { return Config; } }
- public WindowOverlayConfig Config { get; set; }
+ public WindowOverlayConfig Config { get; }
//internal string m_Key;
@@ -57,6 +57,7 @@ namespace VDash.Overlay
{
//Selector = selector;
Config = config;
+ Config.WidthUpdated += (x, y) => { SetOverlayWidth(Config.OverlayWidth); };
}
///
@@ -102,7 +103,7 @@ namespace VDash.Overlay
private void destroyInternal()
{
- if (!m_Created) { throw new Exception("This object is not created."); }
+ if (!m_Created) { return; }
m_Created = false;
//Signal render thread to exit
@@ -202,13 +203,16 @@ namespace VDash.Overlay
#region Thumbnail rendering
using (var icon = User32.GetAppIcon(windowHandle))
{
- using (var iconBmp = icon.ToBitmap())
+ if (icon != null)
{
- var data = iconBmp.LockBits(new Rectangle(0, 0, iconBmp.Width, iconBmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
+ using (var iconBmp = icon.ToBitmap())
+ {
+ var data = iconBmp.LockBits(new Rectangle(0, 0, iconBmp.Width, iconBmp.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
- overlay.SetOverlayRaw(m_ThumbnailIcon, data.Scan0, (uint)data.Width, (uint)data.Height, 4);
+ overlay.SetOverlayRaw(m_ThumbnailIcon, data.Scan0, (uint)data.Width, (uint)data.Height, 4);
- iconBmp.UnlockBits(data);
+ iconBmp.UnlockBits(data);
+ }
}
}
#endregion
@@ -497,7 +501,7 @@ namespace VDash.Overlay
screenTexture = new Texture2D(device, textureDesc);
stream = new DataStream(4 * width * height, true, true);
- overlay.SetOverlayWidthInMeters(m_OverlayHandle, 2.5f);
+ overlay.SetOverlayWidthInMeters(m_OverlayHandle, Config.OverlayWidth);
HmdVector2_t vecWindowSize = new HmdVector2_t() { v0 = data.Width, v1 = data.Height };
OpenVR.Overlay.SetOverlayMouseScale(m_OverlayHandle, ref vecWindowSize);
@@ -590,7 +594,7 @@ namespace VDash.Overlay
}
//Clean up after we exit while loop.
- screenTexture.Dispose();
+ screenTexture?.Dispose();
device.ImmediateContext.ClearState();
device.ImmediateContext.Flush();
@@ -617,7 +621,6 @@ namespace VDash.Overlay
public void SetOverlayName(string newName)
{
OpenVR.Overlay.SetOverlayName(m_OverlayHandle, newName);
- //Config.Name = newName;
}
public float GetOverlayWidth()
diff --git a/VDash/UI/CreateNewOverlay.xaml.cs b/VDash/UI/CreateNewOverlay.xaml.cs
index 0f55d27..362f17b 100644
--- a/VDash/UI/CreateNewOverlay.xaml.cs
+++ b/VDash/UI/CreateNewOverlay.xaml.cs
@@ -21,11 +21,12 @@ namespace VDash.UI
///
public partial class CreateNewOverlay : UserControl
{
- public event EventHandler Created;
+ public delegate void CreatedEventHandler(UserControl sender, IOverlay created);
+ public event CreatedEventHandler Created;
public OverlayTypeWrapper[] EligibleOverlays { get; private set; } = {
- new OverlayTypeWrapper("Window Overlay", typeof(WindowOverlay), new WindowOverlayEditor()),
- new OverlayTypeWrapper("Monitor Overlay", typeof(MonitorOverlay), new MonitorOverlayEditor())
+ new OverlayTypeWrapper("Window Overlay", typeof(WindowOverlay), new OverlayEditor(new WindowOverlayEditor())),
+ new OverlayTypeWrapper("Monitor Overlay", typeof(MonitorOverlay), new OverlayEditor(new MonitorOverlayEditor()))
};
public CreateNewOverlay()
@@ -53,7 +54,7 @@ namespace VDash.UI
MainWindow.OverlayManager.Overlays.Add(overlay);
- Created?.Invoke(this, null);
+ Created?.Invoke(this, overlay);
}
// Generate a random string with a given size
diff --git a/VDash/UI/IOverlayEditor.cs b/VDash/UI/IOverlayEditor.cs
index bc87bff..2a7ec5b 100644
--- a/VDash/UI/IOverlayEditor.cs
+++ b/VDash/UI/IOverlayEditor.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows.Controls;
using VDash.Overlay.Config;
namespace VDash.UI
diff --git a/VDash/UI/MonitorOverlayEditor.xaml.cs b/VDash/UI/MonitorOverlayEditor.xaml.cs
index e9ea159..61174b0 100644
--- a/VDash/UI/MonitorOverlayEditor.xaml.cs
+++ b/VDash/UI/MonitorOverlayEditor.xaml.cs
@@ -30,7 +30,9 @@ namespace VDash.UI
InitializeComponent();
OverlayConfig = config;
DataContext = OverlayConfig;
- cbMontitor.ItemsSource = GetDisplays();
+ var displays = GetDisplays();
+ cbMontitor.ItemsSource = displays;
+ cbMontitor.SelectedItem = displays.Single(x => x.MonitorInfo.DeviceName == OverlayConfig.MonitorName);
}
public MonitorOverlayEditor()
diff --git a/VDash/UI/OverlayEditor.xaml b/VDash/UI/OverlayEditor.xaml
new file mode 100644
index 0000000..327a661
--- /dev/null
+++ b/VDash/UI/OverlayEditor.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Overlay Width:
+
+
+
+
diff --git a/VDash/UI/OverlayEditor.xaml.cs b/VDash/UI/OverlayEditor.xaml.cs
new file mode 100644
index 0000000..d9d60a1
--- /dev/null
+++ b/VDash/UI/OverlayEditor.xaml.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+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 VDash.Overlay.Config;
+
+namespace VDash.UI
+{
+ ///
+ /// Interaction logic for OverlayEditor.xaml
+ ///
+ public partial class OverlayEditor : UserControl,IOverlayEditor
+ {
+ public IOverlayEditor Editor { get { return (IOverlayEditor)bdrContent.Child; } set { bdrContent.Child = (UserControl)value; } }
+
+ public IOverlayConfig Config { get { return Editor.Config; } }
+
+ public OverlayEditor(IOverlayEditor editor)
+ {
+ InitializeComponent();
+ Editor = editor;
+ DataContext = Config;
+ }
+
+ private void tbWidth_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ Regex regex = new Regex(@"^[1-9]\d*(\.\d+)?$");
+ e.Handled = regex.IsMatch(e.Text);
+ }
+ }
+}
diff --git a/VDash/UI/WindowOverlayEditor.xaml.cs b/VDash/UI/WindowOverlayEditor.xaml.cs
index ae65b4b..27b14a3 100644
--- a/VDash/UI/WindowOverlayEditor.xaml.cs
+++ b/VDash/UI/WindowOverlayEditor.xaml.cs
@@ -40,14 +40,8 @@ namespace VDash.UI
InitializeComponent();
DataContext = OverlayConfig;
- if (OverlayConfig.Selector != null)
- {
- SelectorWrapper wrapper = Selectors.Single(x => x.SelectorType == OverlayConfig.Selector.GetType());
- IWindowSelector selector = OverlayConfig.Selector;
- UserControl editor = (UserControl)Activator.CreateInstance(wrapper.EditorType, OverlayConfig);
- wrapper.Editor = editor;
- }
cbSelector.ItemsSource = Selectors;
+ SetupDropDown();
}
public WindowOverlayEditor(ref WindowOverlayConfig config)
@@ -56,6 +50,20 @@ namespace VDash.UI
OverlayConfig = config;
DataContext = OverlayConfig;
cbSelector.ItemsSource = Selectors;
+ SetupDropDown();
+ }
+
+ private void SetupDropDown()
+ {
+ if (OverlayConfig.Selector != null)
+ {
+ SelectorWrapper wrapper = Selectors.Single(x => x.SelectorType == OverlayConfig.Selector.GetType());
+ IWindowSelector selector = OverlayConfig.Selector;
+ UserControl editor = (UserControl)Activator.CreateInstance(wrapper.EditorType, new object[] { selector });
+ wrapper.Editor = editor;
+ wrapper.Selector = selector;
+ cbSelector.SelectedItem = wrapper;
+ }
}
public class SelectorWrapper
diff --git a/VDash/UI/WindowSelectorEditor.xaml.cs b/VDash/UI/WindowSelectorEditor.xaml.cs
index 8f1ae5f..875f3db 100644
--- a/VDash/UI/WindowSelectorEditor.xaml.cs
+++ b/VDash/UI/WindowSelectorEditor.xaml.cs
@@ -29,6 +29,7 @@ namespace VDash.UI
Selector = selector;
cbSearchType.ItemsSource = Enum.GetValues(typeof(FromWindowTitle.TitleSearchType));
DataContext = selector;
+ cbSearchType.SelectedItem = selector.SearchType;
}
private void cbSearchType_SelectionChanged(object sender, SelectionChangedEventArgs e)
diff --git a/VDash/VDash.csproj b/VDash/VDash.csproj
index 81d20df..5aadc35 100644
--- a/VDash/VDash.csproj
+++ b/VDash/VDash.csproj
@@ -54,6 +54,9 @@
true
+
+ ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll
+
..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll
@@ -85,6 +88,7 @@
MSBuild:Compile
Designer
+
@@ -103,6 +107,9 @@
MonitorOverlayEditor.xaml
+
+ OverlayEditor.xaml
+
ProcessSelectorEditor.xaml
@@ -137,6 +144,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/VDash/WindowSelectors/FromProcessName.cs b/VDash/WindowSelectors/FromProcessName.cs
index 241a511..405b021 100644
--- a/VDash/WindowSelectors/FromProcessName.cs
+++ b/VDash/WindowSelectors/FromProcessName.cs
@@ -7,7 +7,21 @@ namespace VDash.WindowSelectors
{
public class FromProcessName : IWindowSelector
{
- public string ProcessName { get; set; } = "";
+
+ internal string m_ProcName = "";
+ public string ProcessName
+ {
+ get
+ {
+ return m_ProcName;
+ }
+ set
+ {
+ m_ProcName = value;
+ m_Processes = null;
+ }
+ }
+
public FromProcessName(string procName)
{
if (string.IsNullOrWhiteSpace(procName))
@@ -23,15 +37,15 @@ namespace VDash.WindowSelectors
}
- Process[] processes = null;
+ Process[] m_Processes = null;
public Process[] GetProcesses()
{
- if(processes == null)
+ if(m_Processes == null)
{
- processes = Process.GetProcessesByName(ProcessName);
+ m_Processes = Process.GetProcessesByName(ProcessName);
}
- return processes;
+ return m_Processes;
}
public Process GetProcess()
@@ -61,7 +75,14 @@ namespace VDash.WindowSelectors
public bool WindowExists()
{
- return User32.IsWindow(GetWindowHandle());
+ try
+ {
+ return User32.IsWindow(GetWindowHandle());
+ }
+ catch
+ {
+ return false;
+ }
}
}
}
diff --git a/VDash/packages.config b/VDash/packages.config
index def3dbe..7baa7bb 100644
--- a/VDash/packages.config
+++ b/VDash/packages.config
@@ -1,5 +1,6 @@
+