101 lines
3.4 KiB
C#
101 lines
3.4 KiB
C#
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.OverlayLocation;
|
|
|
|
namespace VRDash.UI.LocationEditors
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for ControllerLocationEditor.xaml
|
|
/// </summary>
|
|
public partial class ControllerLocationEditor : UserControl
|
|
{
|
|
public ControllerLocation Location { get; set; } = null;
|
|
public Preset[] Presets = { new Preset() {Description = "Default" }, new Preset() { Description = "Behind Controller", PosY = -0.1f, RotP = -90, RotY = 180 } };
|
|
public ControllerLocationEditor(ControllerLocation loction)
|
|
{
|
|
Location = loction;
|
|
InitializeComponent();
|
|
DataContext = this;
|
|
cbController.ItemsSource = Enum.GetValues(typeof(ControllerLocation.ControllerHand));
|
|
cbPresets.ItemsSource = Presets;
|
|
}
|
|
|
|
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
Location.ResetCheckTimer();
|
|
}
|
|
|
|
public class Preset
|
|
{
|
|
public string Description { get; set; }
|
|
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;
|
|
|
|
public override string ToString()
|
|
{
|
|
return Description;
|
|
}
|
|
}
|
|
|
|
private void cbPresets_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
Preset preset = (Preset)cbPresets.SelectedItem;
|
|
Location.PosX = preset.PosX;
|
|
Location.PosY = preset.PosY;
|
|
Location.PosZ = preset.PosZ;
|
|
|
|
Location.RotP = preset.RotP;
|
|
Location.RotY = preset.RotY;
|
|
Location.RotR = preset.RotR;
|
|
|
|
Location.ScaleX = preset.ScaleX;
|
|
Location.ScaleY = preset.ScaleY;
|
|
Location.ScaleZ = preset.ScaleZ;
|
|
|
|
Panel container = (Panel)this.Content;
|
|
UIElementCollection children = container.Children;
|
|
|
|
List<FrameworkElement> lstElement = children.Cast<FrameworkElement>().ToList();
|
|
|
|
var lstControl = lstElement.OfType<Control>();
|
|
|
|
foreach(var control in children)
|
|
{
|
|
if (control.GetType() == typeof(DockPanel))
|
|
{
|
|
var dockPanel = (DockPanel)control;
|
|
foreach (var dcChild in dockPanel.Children)
|
|
{
|
|
if(dcChild.GetType() == typeof(TextBox))
|
|
{
|
|
var tb = (TextBox)dcChild;
|
|
tb.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|