-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from ChanyaVRC/dev
Release v1.2.0.
- Loading branch information
Showing
30 changed files
with
1,179 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="AvatarParameterSender.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:AvatarParameterSender" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace AvatarParameterSender; | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Windows; | ||
|
||
[assembly: ThemeInfo( | ||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
//(used if a resource is not found in the page, | ||
// or application resource dictionaries) | ||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
//(used if a resource is not found in the page, | ||
// app, or any theme specific resource dictionaries) | ||
)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net6.0-windows</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<UseWPF>true</UseWPF> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\vrcosclib\vrcosclib.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<Window x:Class="AvatarParameterSender.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:AvatarParameterSender" | ||
mc:Ignorable="d" | ||
Title="MainWindow" Height="400" Width="640" | ||
Loaded="Window_Loaded"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="60"/> | ||
<RowDefinition Height="*"/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="40"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<Grid | ||
Grid.Column="0" | ||
Grid.ColumnSpan="2" | ||
Grid.Row="0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="10"/> | ||
<RowDefinition Height="*"/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="10"/> | ||
<ColumnDefinition Width="100"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
<Label Grid.Column="1" Grid.Row="1" HorizontalContentAlignment="Left"> | ||
<TextBlock Text="Current Avatar: "/> | ||
</Label> | ||
<Label Grid.Column="2" Grid.Row="1"> | ||
<TextBlock Text="{Binding CurrentAvatarName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}"/> | ||
</Label> | ||
</Grid> | ||
<ScrollViewer Grid.Column="1" Grid.Row="1"> | ||
<StackPanel x:Name="ParameterPanel"> | ||
<Label Content="The parameter has not been acquired. Try to "Reset Avatar"."/> | ||
<!--<local:ParameterSenderItem ParameterName="abc"></local:ParameterSenderItem>--> | ||
</StackPanel> | ||
</ScrollViewer> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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 BuildSoft.VRChat.Osc.Avatar; | ||
|
||
namespace AvatarParameterSender; | ||
/// <summary> | ||
/// Interaction logic for MainWindow.xaml | ||
/// </summary> | ||
public partial class MainWindow : Window | ||
{ | ||
public static readonly DependencyProperty CurrentAvatarNameProperty = | ||
DependencyProperty.Register(nameof(CurrentAvatarName), typeof(string), typeof(MainWindow), new PropertyMetadata(string.Empty)); | ||
|
||
public string CurrentAvatarName | ||
{ | ||
get { return (string)GetValue(CurrentAvatarNameProperty); } | ||
set { SetValue(CurrentAvatarNameProperty, value); } | ||
} | ||
|
||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void Window_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
OscAvatarUtility.AvatarChanged += (sender, e) => | ||
{ | ||
Dispatcher.Invoke(() => LoadCurrentAvatarConfig()); | ||
}; | ||
} | ||
|
||
private void LoadCurrentAvatarConfig() | ||
{ | ||
var currentConfig = OscAvatarConfig.CreateAtCurrent(); | ||
if (currentConfig == null) | ||
{ | ||
return; | ||
} | ||
CurrentAvatarName = currentConfig.Name; | ||
|
||
var children = ParameterPanel.Children; | ||
children.Clear(); | ||
|
||
var items = currentConfig.Parameters.Items; | ||
for (int i = 0; i < items.Length; i++) | ||
{ | ||
var input = items[i].Input; | ||
if (input == null) | ||
{ | ||
continue; | ||
} | ||
|
||
children.Add(new ParameterSenderItem() { | ||
Address = input.Address, | ||
ParameterName = items[i].Name, | ||
Type = input.OscType, | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<UserControl x:Class="AvatarParameterSender.ParameterSenderItem" | ||
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:AvatarParameterSender" | ||
mc:Ignorable="d" | ||
d:DesignHeight="30" d:DesignWidth="800"> | ||
<Grid> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="280*"/> | ||
<ColumnDefinition Width="520*"/> | ||
<ColumnDefinition Width="60"/> | ||
<ColumnDefinition Width="60"/> | ||
<ColumnDefinition Width="60"/> | ||
</Grid.ColumnDefinitions> | ||
|
||
<Label | ||
Grid.Column="0" | ||
VerticalContentAlignment="Center"> | ||
<TextBlock | ||
Text="{Binding ParameterName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ParameterSenderItem}}}"/> | ||
</Label> | ||
<TextBox | ||
Grid.Column="1" | ||
VerticalContentAlignment="Center" | ||
Text="{Binding Address, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ParameterSenderItem}}}"/> | ||
<Label Grid.Column="2"> | ||
<TextBlock Text="{Binding Type, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ParameterSenderItem}}}"/> | ||
</Label> | ||
<ComboBox x:Name="ValueBox" | ||
Grid.Column="3" | ||
Text="{Binding Value, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ParameterSenderItem}}}" | ||
IsEditable="True" | ||
PreviewTextInput="ValueBox_PreviewTextInput" /> | ||
<Button x:Name="SendButton" Content="Send" Grid.Column="4" Click="SendButton_Click"/> | ||
</Grid> | ||
</UserControl> |
128 changes: 128 additions & 0 deletions
128
Sample/AvatarParameterSender/ParameterSenderItem.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
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 BuildSoft.VRChat.Osc; | ||
|
||
namespace AvatarParameterSender; | ||
/// <summary> | ||
/// Interaction logic for ParameterSenderItem.xaml | ||
/// </summary> | ||
public partial class ParameterSenderItem : UserControl | ||
{ | ||
public static readonly DependencyProperty ParameterNameProperty = | ||
DependencyProperty.Register(nameof(ParameterName), typeof(string), typeof(ParameterSenderItem), new PropertyMetadata(string.Empty)); | ||
|
||
public static readonly DependencyProperty AddressProperty = | ||
DependencyProperty.Register(nameof(Address), typeof(string), typeof(ParameterSenderItem), new PropertyMetadata(string.Empty)); | ||
|
||
public static readonly DependencyProperty TypeProperty = | ||
DependencyProperty.Register("MyProperty", typeof(OscType), typeof(ParameterSenderItem), new PropertyMetadata(OscType.Int, OnTypeChanged)); | ||
|
||
public static readonly DependencyProperty ValueProperty = | ||
DependencyProperty.Register("Value", typeof(string), typeof(ParameterSenderItem), new PropertyMetadata(string.Empty)); | ||
|
||
private static void OnTypeChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) | ||
{ | ||
var senderItem = (ParameterSenderItem)dependencyObject; | ||
|
||
var items = senderItem.ValueBox.Items; | ||
items.Clear(); | ||
|
||
senderItem.ValueBox.IsEditable = true; | ||
|
||
if ((OscType)e.NewValue == OscType.Bool) | ||
{ | ||
senderItem.ValueBox.IsEditable = false; | ||
items.Add(bool.TrueString); | ||
items.Add(bool.FalseString); | ||
} | ||
} | ||
|
||
|
||
public string ParameterName | ||
{ | ||
get { return (string)GetValue(ParameterNameProperty); } | ||
set { SetValue(ParameterNameProperty, value); } | ||
} | ||
|
||
public string Address | ||
{ | ||
get { return (string)GetValue(AddressProperty); } | ||
set { SetValue(AddressProperty, value); } | ||
} | ||
|
||
public OscType Type | ||
{ | ||
get { return (OscType)GetValue(TypeProperty); } | ||
set { SetValue(TypeProperty, value); } | ||
} | ||
|
||
public string Value | ||
{ | ||
get { return (string)GetValue(ValueProperty); } | ||
set { SetValue(ValueProperty, value); } | ||
} | ||
|
||
|
||
public ParameterSenderItem() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
|
||
private void ValueBox_PreviewTextInput(object sender, TextCompositionEventArgs e) | ||
{ | ||
switch (Type) | ||
{ | ||
case OscType.Int: | ||
e.Handled = !int.TryParse(ValueBox.Text + e.Text, out _); | ||
break; | ||
case OscType.Float: | ||
e.Handled = !float.TryParse(ValueBox.Text + e.Text, out _); | ||
break; | ||
} | ||
} | ||
|
||
private void SendButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
var address = Address; | ||
var value = Value; | ||
if (string.IsNullOrEmpty(address) || string.IsNullOrEmpty(value)) | ||
{ | ||
return; | ||
} | ||
|
||
switch (Type) | ||
{ | ||
case OscType.Bool: | ||
if (bool.TryParse(value, out bool boolValue)) | ||
{ | ||
OscParameter.SendValue(address, boolValue); | ||
} | ||
break; | ||
case OscType.Int: | ||
if (int.TryParse(value, out int intValue)) | ||
{ | ||
OscParameter.SendValue(address, intValue); | ||
} | ||
break; | ||
case OscType.Float: | ||
if (float.TryParse(value, out float floatValue)) | ||
{ | ||
OscParameter.SendValue(address, floatValue); | ||
} | ||
break; | ||
} | ||
} | ||
} |
Oops, something went wrong.