Head material was added
This commit is contained in:
33
Infrastructure/UI/Converters/Common/InvertBoolConverter.cs
Normal file
33
Infrastructure/UI/Converters/Common/InvertBoolConverter.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.Converters.Common
|
||||
{
|
||||
[ValueConversion(typeof(bool), typeof(bool))]
|
||||
public class InvertBoolConverter : IValueConverter
|
||||
{
|
||||
public InvertBoolConverter()
|
||||
{
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value != null && value is bool)
|
||||
{
|
||||
return !((bool)value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return Convert(value, targetType, parameter, culture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
@@ -25,6 +27,9 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
private double maxElementSize;
|
||||
private bool captured, parameterCaptured, elementLock, paramsPanelVisibilty, popupCanBeClosed = true, borderCaptured;
|
||||
private Brush brush;
|
||||
private bool setMaterialColor;
|
||||
private Color color;
|
||||
private IHeadMaterial headMaterial;
|
||||
private MaterialDefinitionBase material;
|
||||
private double prestrain_kx, prestrain_ky, prestrain_epsz;
|
||||
private double opacity = 1, showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight, showedX, showedY;
|
||||
@@ -91,6 +96,30 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
OnPropertyChanged(value, ref centerY);
|
||||
}
|
||||
}
|
||||
|
||||
public IHeadMaterial HeadMaterial
|
||||
{
|
||||
get => headMaterial;
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(value, ref headMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetMaterialColor
|
||||
{
|
||||
get => setMaterialColor;
|
||||
set { OnPropertyChanged(value, ref setMaterialColor);}
|
||||
}
|
||||
public Color Color
|
||||
{
|
||||
get => setMaterialColor? headMaterial.Color :color;
|
||||
set
|
||||
{
|
||||
SetMaterialColor = false;
|
||||
OnPropertyChanged(value, ref color);
|
||||
}
|
||||
}
|
||||
public int MinElementDivision
|
||||
{
|
||||
get => minElementDivision;
|
||||
@@ -119,8 +148,8 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
}
|
||||
public Brush Brush
|
||||
{
|
||||
get => brush;
|
||||
set => OnPropertyChanged(value, ref brush);
|
||||
get => new SolidColorBrush(Color);
|
||||
set { }
|
||||
}
|
||||
public MaterialDefinitionBase Material
|
||||
{
|
||||
@@ -259,8 +288,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
var randomR = new Random(new Random((int)DateTime.Now.Ticks % 1000).Next(50)).Next(0, 255);
|
||||
var randomG = new Random(new Random((int)DateTime.Now.Ticks % 200).Next(100, 200)).Next(0, 255);
|
||||
var randomB = new Random(new Random((int)DateTime.Now.Ticks % 50).Next(500, 1000)).Next(0, 255);
|
||||
var color = Color.FromRgb((byte)randomR, (byte)randomG, (byte)randomB);
|
||||
Brush = new SolidColorBrush(color);
|
||||
color = Color.FromRgb((byte)randomR, (byte)randomG, (byte)randomB);
|
||||
PrimitiveLeftButtonUp = new RelayCommand(o => Captured = false);
|
||||
PrimitiveLeftButtonDown = new RelayCommand(o => Captured = true);
|
||||
|
||||
@@ -273,6 +301,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
|
||||
});
|
||||
OwnerVm = ownerVM;
|
||||
SetMaterialColor = true;
|
||||
}
|
||||
|
||||
protected readonly MainViewModel OwnerVm;
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
</mouseEventTriggers:DoubleClickEventTrigger>-->
|
||||
</i:Interaction.Triggers>
|
||||
</Rectangle>
|
||||
<Rectangle Cursor="SizeNWSE" Fill="{Binding Brush}" VerticalAlignment="Bottom" HorizontalAlignment="Right">
|
||||
<Rectangle Cursor="SizeNWSE" VerticalAlignment="Bottom" HorizontalAlignment="Right">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="PreviewMouseDown">
|
||||
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.LeftButtonDown}" CommandParameter="{Binding}"/>
|
||||
@@ -41,6 +41,9 @@
|
||||
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PreviewMouseMove}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<!--<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Color}"/>
|
||||
</Rectangle.Fill>-->
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
<userControls:PrimitivePopup IsOpen="{Binding ParamsPanelVisibilty}"/>
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
<converters:Area x:Key="AreaConverter"/>
|
||||
|
||||
<Style TargetType="Shape" x:Key="ShapeStyle">
|
||||
<Setter Property="Fill" Value="{Binding Brush, Mode=TwoWay}"/>
|
||||
<Setter Property="Fill">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{Binding Color}"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Opacity" Value="{Binding Opacity, Mode=TwoWay}"/>
|
||||
<!--<Setter Property="ToolTip">
|
||||
<Setter.Value>
|
||||
|
||||
Reference in New Issue
Block a user