Started implementing GUI.
This commit is contained in:
parent
6f3c6fa75e
commit
ac666a5a94
|
|
@ -3,10 +3,29 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using VDash.Overlay.Config;
|
||||||
|
|
||||||
namespace VDash
|
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";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves config to ConfigLocation
|
||||||
|
/// </summary>
|
||||||
|
public void SaveConfig()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Profile
|
||||||
|
{
|
||||||
|
public List<IOverlayConfig> OverlayConfigs { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,14 @@
|
||||||
<Button x:Name="btnDisable">Disable</Button>
|
<Button x:Name="btnDisable">Disable</Button>
|
||||||
<Button x:Name="btnRemove" Click="btnRemove_Click">Remove</Button>
|
<Button x:Name="btnRemove" Click="btnRemove_Click">Remove</Button>
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
<ListView x:Name="lvOverlays" Grid.Row="1">
|
<ListView x:Name="lvOverlays" Grid.Row="1" SelectionChanged="lvOverlays_SelectionChanged">
|
||||||
|
|
||||||
</ListView>
|
</ListView>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Border x:Name="bdrContent" Grid.Column="1" Margin="0,5,5,5"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using Valve.VR;
|
using Valve.VR;
|
||||||
using VDash.Overlay;
|
using VDash.Overlay;
|
||||||
|
using VDash.Overlay.Config;
|
||||||
|
using VDash.UI;
|
||||||
using VDash.Utilities;
|
using VDash.Utilities;
|
||||||
|
|
||||||
namespace VDash
|
namespace VDash
|
||||||
|
|
@ -24,6 +26,13 @@ namespace VDash
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
public static OverlayManager OverlayManager = new OverlayManager();
|
public static OverlayManager OverlayManager = new OverlayManager();
|
||||||
|
public static List<EditorMap> EditorMapping = new List<EditorMap>()
|
||||||
|
{
|
||||||
|
new EditorMap(typeof(MonitorOverlay), typeof(UI.MonitorOverlayEditor)),
|
||||||
|
new EditorMap(typeof(WindowOverlay), typeof(UI.WindowOverlayEditor))
|
||||||
|
};
|
||||||
|
|
||||||
|
List<OverlayEditor> overlayEditors = new List<OverlayEditor>();
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
@ -73,7 +82,12 @@ namespace VDash
|
||||||
{
|
{
|
||||||
Window w = new Window();
|
Window w = new Window();
|
||||||
var uc = new UI.CreateNewOverlay();
|
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.Content = uc;
|
||||||
w.Width = 500;
|
w.Width = 500;
|
||||||
w.Height = 400;
|
w.Height = 400;
|
||||||
|
|
@ -87,6 +101,39 @@ namespace VDash
|
||||||
IOverlay overlay = (IOverlay)lvOverlays.SelectedItem;
|
IOverlay overlay = (IOverlay)lvOverlays.SelectedItem;
|
||||||
overlay.Dispose();
|
overlay.Dispose();
|
||||||
OverlayManager.Overlays.Remove(overlay);
|
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; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,6 @@ namespace VDash.Overlay.Config
|
||||||
{
|
{
|
||||||
string Name { get; set; }
|
string Name { get; set; }
|
||||||
string Key { get; set; }
|
string Key { get; set; }
|
||||||
|
float OverlayWidth { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,19 @@ namespace VDash.Overlay.Config
|
||||||
{
|
{
|
||||||
public class MonitorOverlayConfig : IOverlayConfig
|
public class MonitorOverlayConfig : IOverlayConfig
|
||||||
{
|
{
|
||||||
|
public event EventHandler WidthUpdated;
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
public string MonitorName { 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ namespace VDash.Overlay.Config
|
||||||
{
|
{
|
||||||
public class WindowOverlayConfig : IOverlayConfig
|
public class WindowOverlayConfig : IOverlayConfig
|
||||||
{
|
{
|
||||||
|
public event EventHandler WidthUpdated;
|
||||||
public WindowOverlayConfig(string name, string key, IWindowSelector selector, bool updateDashboardName, bool destroyOnNoWindowFound)
|
public WindowOverlayConfig(string name, string key, IWindowSelector selector, bool updateDashboardName, bool destroyOnNoWindowFound)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
|
|
@ -25,5 +26,15 @@ namespace VDash.Overlay.Config
|
||||||
public IWindowSelector Selector {get; set; }
|
public IWindowSelector Selector {get; set; }
|
||||||
public bool UpdateDashboardName { get; set; } = false;
|
public bool UpdateDashboardName { get; set; } = false;
|
||||||
public bool DestroyOnNoWindowFound { 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,13 +52,14 @@ namespace VDash.Overlay
|
||||||
public List<IOverlayAction> OverlayHiddenActions { get; private set; } = new List<IOverlayAction>();
|
public List<IOverlayAction> OverlayHiddenActions { get; private set; } = new List<IOverlayAction>();
|
||||||
|
|
||||||
public IOverlayConfig OverlayConfig { get { return Config; } }
|
public IOverlayConfig OverlayConfig { get { return Config; } }
|
||||||
public MonitorOverlayConfig Config { get; set; }
|
public MonitorOverlayConfig Config { get; }
|
||||||
|
|
||||||
char[] specialKeys = { '+', '^', '%', '~', '(', ')', '{', '}', '[', ']' };
|
char[] specialKeys = { '+', '^', '%', '~', '(', ')', '{', '}', '[', ']' };
|
||||||
|
|
||||||
public MonitorOverlay(MonitorOverlayConfig config)
|
public MonitorOverlay(MonitorOverlayConfig config)
|
||||||
{
|
{
|
||||||
Config = config;
|
Config = config;
|
||||||
|
Config.WidthUpdated += (x, y) => { SetOverlayWidth(Config.OverlayWidth); };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -421,7 +422,7 @@ namespace VDash.Overlay
|
||||||
screenTexture = new Texture2D(device, textureDesc);
|
screenTexture = new Texture2D(device, textureDesc);
|
||||||
stream = new DataStream(4 * width * height, true, true);
|
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 };
|
HmdVector2_t vecWindowSize = new HmdVector2_t() { v0 = data.Width, v1 = data.Height };
|
||||||
OpenVR.Overlay.SetOverlayMouseScale(m_OverlayHandle, ref vecWindowSize);
|
OpenVR.Overlay.SetOverlayMouseScale(m_OverlayHandle, ref vecWindowSize);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace VDash.Overlay
|
||||||
public ulong ThumbnailIcon { get { return m_ThumbnailIcon; } }
|
public ulong ThumbnailIcon { get { return m_ThumbnailIcon; } }
|
||||||
public IOverlayConfig OverlayConfig { get { return Config; } }
|
public IOverlayConfig OverlayConfig { get { return Config; } }
|
||||||
|
|
||||||
public WindowOverlayConfig Config { get; set; }
|
public WindowOverlayConfig Config { get; }
|
||||||
|
|
||||||
//internal string m_Key;
|
//internal string m_Key;
|
||||||
|
|
||||||
|
|
@ -57,6 +57,7 @@ namespace VDash.Overlay
|
||||||
{
|
{
|
||||||
//Selector = selector;
|
//Selector = selector;
|
||||||
Config = config;
|
Config = config;
|
||||||
|
Config.WidthUpdated += (x, y) => { SetOverlayWidth(Config.OverlayWidth); };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -102,7 +103,7 @@ namespace VDash.Overlay
|
||||||
|
|
||||||
private void destroyInternal()
|
private void destroyInternal()
|
||||||
{
|
{
|
||||||
if (!m_Created) { throw new Exception("This object is not created."); }
|
if (!m_Created) { return; }
|
||||||
m_Created = false;
|
m_Created = false;
|
||||||
|
|
||||||
//Signal render thread to exit
|
//Signal render thread to exit
|
||||||
|
|
@ -201,6 +202,8 @@ namespace VDash.Overlay
|
||||||
|
|
||||||
#region Thumbnail rendering
|
#region Thumbnail rendering
|
||||||
using (var icon = User32.GetAppIcon(windowHandle))
|
using (var icon = User32.GetAppIcon(windowHandle))
|
||||||
|
{
|
||||||
|
if (icon != null)
|
||||||
{
|
{
|
||||||
using (var iconBmp = icon.ToBitmap())
|
using (var iconBmp = icon.ToBitmap())
|
||||||
{
|
{
|
||||||
|
|
@ -211,6 +214,7 @@ namespace VDash.Overlay
|
||||||
iconBmp.UnlockBits(data);
|
iconBmp.UnlockBits(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -497,7 +501,7 @@ namespace VDash.Overlay
|
||||||
screenTexture = new Texture2D(device, textureDesc);
|
screenTexture = new Texture2D(device, textureDesc);
|
||||||
stream = new DataStream(4 * width * height, true, true);
|
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 };
|
HmdVector2_t vecWindowSize = new HmdVector2_t() { v0 = data.Width, v1 = data.Height };
|
||||||
OpenVR.Overlay.SetOverlayMouseScale(m_OverlayHandle, ref vecWindowSize);
|
OpenVR.Overlay.SetOverlayMouseScale(m_OverlayHandle, ref vecWindowSize);
|
||||||
|
|
@ -590,7 +594,7 @@ namespace VDash.Overlay
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clean up after we exit while loop.
|
//Clean up after we exit while loop.
|
||||||
screenTexture.Dispose();
|
screenTexture?.Dispose();
|
||||||
device.ImmediateContext.ClearState();
|
device.ImmediateContext.ClearState();
|
||||||
device.ImmediateContext.Flush();
|
device.ImmediateContext.Flush();
|
||||||
|
|
||||||
|
|
@ -617,7 +621,6 @@ namespace VDash.Overlay
|
||||||
public void SetOverlayName(string newName)
|
public void SetOverlayName(string newName)
|
||||||
{
|
{
|
||||||
OpenVR.Overlay.SetOverlayName(m_OverlayHandle, newName);
|
OpenVR.Overlay.SetOverlayName(m_OverlayHandle, newName);
|
||||||
//Config.Name = newName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetOverlayWidth()
|
public float GetOverlayWidth()
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,12 @@ namespace VDash.UI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class CreateNewOverlay : UserControl
|
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; } = {
|
public OverlayTypeWrapper[] EligibleOverlays { get; private set; } = {
|
||||||
new OverlayTypeWrapper("Window Overlay", typeof(WindowOverlay), new WindowOverlayEditor()),
|
new OverlayTypeWrapper("Window Overlay", typeof(WindowOverlay), new OverlayEditor(new WindowOverlayEditor())),
|
||||||
new OverlayTypeWrapper("Monitor Overlay", typeof(MonitorOverlay), new MonitorOverlayEditor())
|
new OverlayTypeWrapper("Monitor Overlay", typeof(MonitorOverlay), new OverlayEditor(new MonitorOverlayEditor()))
|
||||||
};
|
};
|
||||||
|
|
||||||
public CreateNewOverlay()
|
public CreateNewOverlay()
|
||||||
|
|
@ -53,7 +54,7 @@ namespace VDash.UI
|
||||||
|
|
||||||
MainWindow.OverlayManager.Overlays.Add(overlay);
|
MainWindow.OverlayManager.Overlays.Add(overlay);
|
||||||
|
|
||||||
Created?.Invoke(this, null);
|
Created?.Invoke(this, overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a random string with a given size
|
// Generate a random string with a given size
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Controls;
|
||||||
using VDash.Overlay.Config;
|
using VDash.Overlay.Config;
|
||||||
|
|
||||||
namespace VDash.UI
|
namespace VDash.UI
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,9 @@ namespace VDash.UI
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
OverlayConfig = config;
|
OverlayConfig = config;
|
||||||
DataContext = OverlayConfig;
|
DataContext = OverlayConfig;
|
||||||
cbMontitor.ItemsSource = GetDisplays();
|
var displays = GetDisplays();
|
||||||
|
cbMontitor.ItemsSource = displays;
|
||||||
|
cbMontitor.SelectedItem = displays.Single(x => x.MonitorInfo.DeviceName == OverlayConfig.MonitorName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MonitorOverlayEditor()
|
public MonitorOverlayEditor()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
<UserControl x:Class="VDash.UI.OverlayEditor"
|
||||||
|
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:VDash.UI"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="25" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="85" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="60" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Border x:Name="bdrContent" Grid.Row="0" Grid.ColumnSpan="3"/>
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right" VerticalAlignment="Center">Overlay Width:</TextBlock>
|
||||||
|
<Slider x:Name="slWidth" Maximum="10" Grid.Row="1" Grid.Column="1" Value="{Binding OverlayWidth}" VerticalAlignment="Center" Margin="5,0,5,0"/>
|
||||||
|
<TextBox x:Name="tbWidth" Grid.Row="1" Grid.Column="2" PreviewTextInput="tbWidth_PreviewTextInput" Text="{Binding OverlayWidth}"/>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
|
|
@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for OverlayEditor.xaml
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -40,14 +40,8 @@ namespace VDash.UI
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = OverlayConfig;
|
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;
|
cbSelector.ItemsSource = Selectors;
|
||||||
|
SetupDropDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WindowOverlayEditor(ref WindowOverlayConfig config)
|
public WindowOverlayEditor(ref WindowOverlayConfig config)
|
||||||
|
|
@ -56,6 +50,20 @@ namespace VDash.UI
|
||||||
OverlayConfig = config;
|
OverlayConfig = config;
|
||||||
DataContext = OverlayConfig;
|
DataContext = OverlayConfig;
|
||||||
cbSelector.ItemsSource = Selectors;
|
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
|
public class SelectorWrapper
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ namespace VDash.UI
|
||||||
Selector = selector;
|
Selector = selector;
|
||||||
cbSearchType.ItemsSource = Enum.GetValues(typeof(FromWindowTitle.TitleSearchType));
|
cbSearchType.ItemsSource = Enum.GetValues(typeof(FromWindowTitle.TitleSearchType));
|
||||||
DataContext = selector;
|
DataContext = selector;
|
||||||
|
cbSearchType.SelectedItem = selector.SearchType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cbSearchType_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void cbSearchType_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,9 @@
|
||||||
<Prefer32Bit>true</Prefer32Bit>
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
<Reference Include="SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
|
<HintPath>..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
@ -85,6 +88,7 @@
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="ConfigManager.cs" />
|
||||||
<Compile Include="OverlayManager.cs" />
|
<Compile Include="OverlayManager.cs" />
|
||||||
<Compile Include="Overlay\Actions\BringWindowToFrontAction.cs" />
|
<Compile Include="Overlay\Actions\BringWindowToFrontAction.cs" />
|
||||||
<Compile Include="Overlay\Actions\IOverlayAction.cs" />
|
<Compile Include="Overlay\Actions\IOverlayAction.cs" />
|
||||||
|
|
@ -103,6 +107,9 @@
|
||||||
<Compile Include="UI\MonitorOverlayEditor.xaml.cs">
|
<Compile Include="UI\MonitorOverlayEditor.xaml.cs">
|
||||||
<DependentUpon>MonitorOverlayEditor.xaml</DependentUpon>
|
<DependentUpon>MonitorOverlayEditor.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="UI\OverlayEditor.xaml.cs">
|
||||||
|
<DependentUpon>OverlayEditor.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="UI\ProcessSelectorEditor.xaml.cs">
|
<Compile Include="UI\ProcessSelectorEditor.xaml.cs">
|
||||||
<DependentUpon>ProcessSelectorEditor.xaml</DependentUpon>
|
<DependentUpon>ProcessSelectorEditor.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
@ -137,6 +144,10 @@
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="UI\OverlayEditor.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="UI\ProcessSelectorEditor.xaml">
|
<Page Include="UI\ProcessSelectorEditor.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,21 @@ namespace VDash.WindowSelectors
|
||||||
{
|
{
|
||||||
public class FromProcessName : IWindowSelector
|
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)
|
public FromProcessName(string procName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(procName))
|
if (string.IsNullOrWhiteSpace(procName))
|
||||||
|
|
@ -23,15 +37,15 @@ namespace VDash.WindowSelectors
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Process[] processes = null;
|
Process[] m_Processes = null;
|
||||||
public Process[] GetProcesses()
|
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()
|
public Process GetProcess()
|
||||||
|
|
@ -60,8 +74,15 @@ namespace VDash.WindowSelectors
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool WindowExists()
|
public bool WindowExists()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
return User32.IsWindow(GetWindowHandle());
|
return User32.IsWindow(GetWindowHandle());
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net45" />
|
||||||
<package id="SharpDX" version="4.2.0" targetFramework="net45" />
|
<package id="SharpDX" version="4.2.0" targetFramework="net45" />
|
||||||
<package id="SharpDX.Direct3D11" version="4.2.0" targetFramework="net45" />
|
<package id="SharpDX.Direct3D11" version="4.2.0" targetFramework="net45" />
|
||||||
<package id="SharpDX.DXGI" version="4.2.0" targetFramework="net45" />
|
<package id="SharpDX.DXGI" version="4.2.0" targetFramework="net45" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue