port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.Interfaces;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_checkBoxValue), Type = typeof(CheckBox))]
[TemplatePart(Name = nameof(_textBlockValue), Type = typeof(TextBlock))]
public class BooleanExpressionEditorView : EditorViewBase<BooleanExpressionEditorViewModel>
{
private CheckBox _checkBoxValue = null!;
private TextBlock _textBlockValue = null!;
public BooleanExpressionEditorView()
{
DefaultStyleKey = typeof(BooleanExpressionEditorView);
this.WhenActivated(d =>
{
this.OneWayBind(ViewModel, vm => vm.CustomValue, v => v._textBlockValue.Text, b => b.ToString()).DisposeWith(d);
this.Bind(ViewModel, vm => vm.CustomValue, v => v._checkBoxValue.IsChecked).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_checkBoxValue = (CheckBox)GetTemplateChild(nameof(_checkBoxValue))!;
_textBlockValue = (TextBlock)GetTemplateChild(nameof(_textBlockValue))!;
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.Interfaces;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_checkBoxValue), Type = typeof(CheckBox))]
[TemplatePart(Name = nameof(_textBlockValue), Type = typeof(TextBlock))]
public class BooleanValueEditorView : EditorViewBase<BooleanValueEditorViewModel>
{
private CheckBox _checkBoxValue = null!;
private TextBlock _textBlockValue = null!;
public BooleanValueEditorView()
{
DefaultStyleKey = typeof(BooleanValueEditorView);
this.WhenActivated(d =>
{
this.OneWayBind(ViewModel, vm => vm.Value, v => v._textBlockValue.Text, b => b.ToString()).DisposeWith(d);
this.Bind(ViewModel, vm => vm.Value, v => v._checkBoxValue.IsChecked).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_checkBoxValue = (CheckBox)GetTemplateChild(nameof(_checkBoxValue))!;
_textBlockValue = (TextBlock)GetTemplateChild(nameof(_textBlockValue))!;
}
}
}

View File

@@ -0,0 +1,38 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.Interfaces;
using Intromat.Nodes.Code;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_sliderValue), Type = typeof(Slider))]
[TemplatePart(Name = nameof(_textBlockValue), Type = typeof(TextBlock))]
public class DimensionEditorView : EditorViewBase<DimensionEditorViewModel>
{
private Slider _sliderValue = null!;
private TextBlock _textBlockValue = null!;
public DimensionEditorView()
{
DefaultStyleKey = typeof(DimensionEditorView);
this.WhenActivated(d =>
{
this.OneWayBind(ViewModel, vm => vm.Value, v => v._textBlockValue.Text, v => ((IntLiteralValue?)v)?.EvaluateDimension().ToString() ?? "0").DisposeWith(d);
this.Bind(ViewModel, vm => vm.CustomValue, v => v._sliderValue.Value, i => i, v => (int)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MinValue, v => v._sliderValue.Minimum, i => i, v => (int)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MaxValue, v => v._sliderValue.Maximum, i => i, v => (int)v).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_sliderValue = (Slider)GetTemplateChild(nameof(_sliderValue))!;
_textBlockValue = (TextBlock)GetTemplateChild(nameof(_textBlockValue))!;
}
}
}

View File

@@ -0,0 +1,59 @@
<UserControl x:Class="Intromat.Views.Editors.EditorHeader"
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"
mc:Ignorable="d"
d:DesignHeight="30" d:DesignWidth="800">
<Grid Margin="0,0,0,5">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="_textBlockName" Foreground="{DynamicResource ControlDefaultForeground}" HorizontalAlignment="Stretch" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
<ComboBox Grid.Column="1" x:Name="_comboBoxRelativeSource" VerticalAlignment="Center" />
<ToggleButton Grid.Column="2" x:Name="_checkBoxPortVisible" VerticalAlignment="Center">
<Viewbox StretchDirection="Both" Stretch="Uniform" Width="16" Height="16">
<Grid Width="20" Height="20">
<Ellipse x:Name="_ellipse" HorizontalAlignment="Left" VerticalAlignment="Center" Height="15" Width="15">
<Ellipse.Fill>
<SolidColorBrush Color="#505050" />
</Ellipse.Fill>
</Ellipse>
<Path x:Name="_path" Data="M 0 0 L 4 4 L 0 8 Z" HorizontalAlignment="Right" VerticalAlignment="Center" Height="8" Width="4">
<Path.Fill>
<SolidColorBrush Color="#505050" />
</Path.Fill>
</Path>
</Grid>
</Viewbox>
<ToggleButton.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="_ellipse"
Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)"
Duration="0:0:0.2" From="#505050" To="White" />
<ColorAnimation Storyboard.TargetName="_path"
Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
Duration="0:0:0.2" From="#505050" To="White" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="_ellipse"
Storyboard.TargetProperty="(Ellipse.Fill).(SolidColorBrush.Color)"
Duration="0:0:0.2" From="White" To="#505050" />
<ColorAnimation Storyboard.TargetName="_path"
Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)"
Duration="0:0:0.2" From="White" To="#505050" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ToggleButton.Triggers>
</ToggleButton>
</Grid>
</UserControl>

View File

@@ -0,0 +1,16 @@
using System.Windows;
using System.Windows.Controls;
namespace Intromat.Views.Editors
{
/// <summary>
/// Interaction logic for EditorHeader.xaml
/// </summary>
public partial class EditorHeader : UserControl
{
public EditorHeader()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms.VisualStyles;
using Intromat.Interfaces;
using Intromat.Nodes.Code;
using Intromat.ViewModels;
using NodeNetwork.ViewModels;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_header), Type = typeof(EditorHeader))]
[TemplatePart(Name = nameof(_content), Type = typeof(Panel))]
public abstract class EditorViewBase<T> : ContentControl, IViewFor<T> where T : NodeEndpointEditorViewModel
{
protected EditorHeader _header = null!;
protected Panel _content = null!;
public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register(nameof(ViewModel),
typeof(T), typeof(EditorViewBase<T>), new PropertyMetadata(null));
protected EditorViewBase()
{
this.WhenActivated(d =>
{
this.Bind(ViewModel, vm => vm.Parent.Name, v => v._header._textBlockName.Text)
.DisposeWith(d);
if (ViewModel is IExpressionEditor expressionEditor)
{
if (expressionEditor.HasParentSource)
_header._comboBoxRelativeSource.Items.Add(ERelativeSource.Parent);
if (expressionEditor.HasInputSource)
_header._comboBoxRelativeSource.Items.Add(ERelativeSource.Input);
if (_header._comboBoxRelativeSource.Items.Count > 0)
_header._comboBoxRelativeSource.Items.Add(ERelativeSource.Custom);
else
_header._comboBoxRelativeSource.Visibility = Visibility.Collapsed;
this.Bind(expressionEditor, vm => vm.RelativeSource, v => v._header._comboBoxRelativeSource.SelectedItem)
.DisposeWith(d);
if (expressionEditor.CodeGenPort.PortType == EPortType.None)
{
_header._checkBoxPortVisible.Visibility = Visibility.Collapsed;
}
else
{
this.Bind(expressionEditor, vm => vm.CodeGenPort.IsPortVisible, v => v._header._checkBoxPortVisible.IsChecked)
.DisposeWith(d);
this.OneWayBind(expressionEditor, vm => vm.CodeGenPort.IsPortVisible, v => v._content.Visibility, portVisible => portVisible ? Visibility.Collapsed : Visibility.Visible)
.DisposeWith(d);
}
}
else
{
_header._comboBoxRelativeSource.Visibility = Visibility.Collapsed;
}
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_header = (EditorHeader)GetTemplateChild(nameof(_header))!;
_content = (Panel)GetTemplateChild(nameof(_content))!;
}
public T? ViewModel
{
get => (T?)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}
object? IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (T?)value;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_comboBoxValue), Type = typeof(ComboBox))]
public class EnumEditorView : EditorViewBase<EnumEditorViewModel>
{
private ComboBox _comboBoxValue = null!;
public EnumEditorView()
{
DefaultStyleKey = typeof(EnumEditorView);
this.WhenActivated(d =>
{
foreach (var name in Enum.GetNames(ViewModel!.EnumType))
_comboBoxValue.Items.Add(name);
this.OneWayBind(ViewModel, vm => vm.Value, v => v._comboBoxValue.SelectedIndex).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_comboBoxValue = (ComboBox)GetTemplateChild(nameof(_comboBoxValue))!;
}
}
}

View File

@@ -0,0 +1,37 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.Interfaces;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_sliderValue), Type = typeof(Slider))]
[TemplatePart(Name = nameof(_textBoxValue), Type = typeof(TextBox))]
public class FloatExpressionEditorView : EditorViewBase<FloatExpressionEditorViewModel>
{
private Slider _sliderValue = null!;
private TextBox _textBoxValue = null!;
public FloatExpressionEditorView()
{
DefaultStyleKey = typeof(FloatExpressionEditorView);
this.WhenActivated(d =>
{
this.Bind(ViewModel, vm => vm.CustomValue, v => v._textBoxValue.Text).DisposeWith(d);
this.Bind(ViewModel, vm => vm.CustomValue, v => v._sliderValue.Value, i => i, v => (float)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MinValue, v => v._sliderValue.Minimum, i => i, v => (float)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MaxValue, v => v._sliderValue.Maximum, i => i, v => (float)v).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_sliderValue = (Slider)GetTemplateChild(nameof(_sliderValue))!;
_textBoxValue = (TextBox)GetTemplateChild(nameof(_textBoxValue))!;
}
}
}

View File

@@ -0,0 +1,37 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.Interfaces;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_sliderValue), Type = typeof(Slider))]
[TemplatePart(Name = nameof(_textBoxValue), Type = typeof(TextBox))]
public class FloatValueEditorView : EditorViewBase<FloatValueEditorViewModel>
{
private Slider _sliderValue = null!;
private TextBox _textBoxValue = null!;
public FloatValueEditorView()
{
DefaultStyleKey = typeof(FloatValueEditorView);
this.WhenActivated(d =>
{
this.Bind(ViewModel, vm => vm.Value, v => v._textBoxValue.Text).DisposeWith(d);
this.Bind(ViewModel, vm => vm.Value, v => v._sliderValue.Value, i => i, v => (float)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MinValue, v => v._sliderValue.Minimum, i => i, v => (float)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MaxValue, v => v._sliderValue.Maximum, i => i, v => (float)v).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_sliderValue = (Slider)GetTemplateChild(nameof(_sliderValue))!;
_textBoxValue = (TextBox)GetTemplateChild(nameof(_textBoxValue))!;
}
}
}

View File

@@ -0,0 +1,15 @@
<UserControl x:Class="Intromat.Views.Editors.GroupEndpointEditorView"
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"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="800">
<StackPanel Orientation="Horizontal">
<TextBox x:Name="nameTextBox" Width="125" />
<ToggleButton x:Name="editNameButton" Margin="5,0,0,0">Edit name</ToggleButton>
<Button x:Name="upButton" Margin="5,0,0,0">▲</Button>
<Button x:Name="downButton" Margin="5,0,0,0">▼</Button>
<Button x:Name="deleteButton" Margin="5,0,0,0">Delete</Button>
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,45 @@
using System.Diagnostics;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Windows;
using Intromat.ViewModels.Nodes;
using ReactiveUI;
namespace Intromat.Views.Editors
{
public partial class GroupEndpointEditorView : IViewFor<IGroupEndpointEditorViewModel>
{
public static readonly DependencyProperty ViewModelProperty = DependencyProperty.Register(nameof(ViewModel),
typeof(IGroupEndpointEditorViewModel), typeof(GroupEndpointEditorView), new PropertyMetadata(null));
public GroupEndpointEditorView()
{
InitializeComponent();
this.WhenAnyValue(v => v.editNameButton.IsChecked)
.Select(isChecked => isChecked ?? false ? Visibility.Visible : Visibility.Collapsed)
.BindTo(this, v => v.nameTextBox.Visibility);
this.WhenActivated(d =>
{
Debug.Assert(ViewModel != null, nameof(ViewModel) + " != null");
this.Bind(ViewModel, vm => vm.Endpoint.Name, v => v.nameTextBox.Text).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.MoveUp, v => v.upButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.MoveDown, v => v.downButton).DisposeWith(d);
this.BindCommand(ViewModel, vm => vm.Delete, v => v.deleteButton).DisposeWith(d);
});
}
public IGroupEndpointEditorViewModel? ViewModel
{
get => (IGroupEndpointEditorViewModel?)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}
object? IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (IGroupEndpointEditorViewModel?)value;
}
}
}

View File

@@ -0,0 +1,37 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.Interfaces;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_sliderValue), Type = typeof(Slider))]
[TemplatePart(Name = nameof(_textBoxValue), Type = typeof(TextBox))]
public class IntegerExpressionEditorView : EditorViewBase<IntegerExpressionEditorViewModel>
{
private Slider _sliderValue = null!;
private TextBox _textBoxValue = null!;
public IntegerExpressionEditorView()
{
DefaultStyleKey = typeof(IntegerExpressionEditorView);
this.WhenActivated(d =>
{
this.Bind(ViewModel, vm => vm.CustomValue, v => v._textBoxValue.Text).DisposeWith(d);
this.Bind(ViewModel, vm => vm.CustomValue, v => v._sliderValue.Value, i => i, v => (int)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MinValue, v => v._sliderValue.Minimum, i => i, v => (int)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MaxValue, v => v._sliderValue.Maximum, i => i, v => (int)v).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_sliderValue = (Slider)GetTemplateChild(nameof(_sliderValue))!;
_textBoxValue = (TextBox)GetTemplateChild(nameof(_textBoxValue))!;
}
}
}

View File

@@ -0,0 +1,37 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.Interfaces;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_sliderValue), Type = typeof(Slider))]
[TemplatePart(Name = nameof(_textBoxValue), Type = typeof(TextBox))]
public class IntegerValueEditorView : EditorViewBase<IntegerValueEditorViewModel>
{
private Slider _sliderValue = null!;
private TextBox _textBoxValue = null!;
public IntegerValueEditorView()
{
DefaultStyleKey = typeof(IntegerValueEditorView);
this.WhenActivated(d =>
{
this.Bind(ViewModel, vm => vm.Value, v => v._textBoxValue.Text).DisposeWith(d);
this.Bind(ViewModel, vm => vm.Value, v => v._sliderValue.Value, i => i, v => (int)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MinValue, v => v._sliderValue.Minimum, i => i, v => (int)v).DisposeWith(d);
this.Bind(ViewModel, vm => vm.MaxValue, v => v._sliderValue.Maximum, i => i, v => (int)v).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_sliderValue = (Slider)GetTemplateChild(nameof(_sliderValue))!;
_textBoxValue = (TextBox)GetTemplateChild(nameof(_textBoxValue))!;
}
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Linq;
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.Interfaces;
using Intromat.ViewModels.Editors;
using ReactiveUI;
using SharpDX.Direct3D11;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_comboBoxFilter), Type = typeof(ComboBox))]
[TemplatePart(Name = nameof(_comboBoxAddress), Type = typeof(ComboBox))]
public class SamplerEditorView : EditorViewBase<SamplerEditorViewModel>
{
private ComboBox _comboBoxFilter = null!;
private ComboBox _comboBoxAddress = null!;
public SamplerEditorView()
{
DefaultStyleKey = typeof(SamplerEditorView);
this.WhenActivated(d =>
{
var addressNames = Enum.GetValues(typeof(TextureAddressMode)).Cast<TextureAddressMode>().ToArray();
_comboBoxAddress.ItemsSource = addressNames;
var filterNames = Enum.GetValues(typeof(Filter)).Cast<Filter>();
_comboBoxFilter.ItemsSource = filterNames;
this.Bind(ViewModel, vm => vm.Address, v => v._comboBoxAddress.SelectedItem).DisposeWith(d);
this.Bind(ViewModel, vm => vm.Filter, v => v._comboBoxFilter.SelectedItem).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_comboBoxFilter = (ComboBox)GetTemplateChild(nameof(_comboBoxFilter))!;
_comboBoxAddress = (ComboBox)GetTemplateChild(nameof(_comboBoxAddress))!;
}
}
}

View File

@@ -0,0 +1,30 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_textBoxValue), Type = typeof(TextBox))]
public class StringExpressionEditorView : EditorViewBase<StringExpressionEditorViewModel>
{
private TextBox _textBoxValue = null!;
public StringExpressionEditorView()
{
DefaultStyleKey = typeof(StringExpressionEditorView);
this.WhenActivated(d =>
{
this.Bind(ViewModel, vm => vm.CustomValue, v => v._textBoxValue.Text).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_textBoxValue = (TextBox)GetTemplateChild(nameof(_textBoxValue))!;
}
}
}

View File

@@ -0,0 +1,30 @@
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using Intromat.ViewModels.Editors;
using ReactiveUI;
namespace Intromat.Views.Editors
{
[TemplatePart(Name = nameof(_textBoxValue), Type = typeof(TextBox))]
public class StringValueEditorView : EditorViewBase<StringValueEditorViewModel>
{
private TextBox _textBoxValue = null!;
public StringValueEditorView()
{
DefaultStyleKey = typeof(StringValueEditorView);
this.WhenActivated(d =>
{
this.Bind(ViewModel, vm => vm.Value, v => v._textBoxValue.Text).DisposeWith(d);
});
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
_textBoxValue = (TextBox)GetTemplateChild(nameof(_textBoxValue))!;
}
}
}