Creando GuiasUnion
This commit is contained in:
parent
c4892b1f36
commit
268b66ad76
10
App.xaml
10
App.xaml
|
@ -3,7 +3,17 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:CtrEditor"
|
||||
StartupUri="MainWindow.xaml">
|
||||
|
||||
<Application.Resources>
|
||||
<local:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
<local:LevelToHeightMultiConverter x:Key="LevelToHeightMultiConverter"/>
|
||||
<local:WidthPercentageConverter x:Key="WidthPercentageConverter"/>
|
||||
<local:DistanceToMarginConverter x:Key="DistanceToMarginConverter"/>
|
||||
<local:MarginConverter x:Key="MarginConverter"/>
|
||||
<local:FloatToFormattedStringConverter x:Key="floatFormatter"/>
|
||||
<local:DoubleToFormattedStringConverter x:Key="doubleFormatter"/>
|
||||
<local:BrushToColorNameConverter x:Key="BrushToColorNameConverter"/>
|
||||
<local:VerticalPositionConverter x:Key="VerticalPositionConverter"/>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
||||
|
|
|
@ -6,9 +6,15 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<Optimize>True</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="ObjetosSim\ucBasicExample.xaml.cs" />
|
||||
<Compile Remove="ObjetosSim\ucTransporteCurva.xaml.cs" />
|
||||
<Compile Remove="Simulacion\FPhysics.cs" />
|
||||
<Compile Remove="Simulacion\GeometrySimulator.cs" />
|
||||
|
@ -41,10 +47,13 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Remove="ObjetosSim\ucBasicExample.xaml" />
|
||||
<Page Remove="ObjetosSim\ucTransporteCurva.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="ObjetosSim\ucBasicExample.xaml" />
|
||||
<None Include="ObjetosSim\ucBasicExample.xaml.cs" />
|
||||
<None Include="Simulacion\FPhysics.cs" />
|
||||
<None Include="Simulacion\GeometrySimulator.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -52,7 +61,6 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Aether.Physics2D" Version="2.1.0" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="FarseerPhysics" Version="3.5.0" />
|
||||
<PackageReference Include="LiveChartsCore.SkiaSharpView.WPF" Version="2.0.0-rc2" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
|
@ -88,4 +96,19 @@
|
|||
<Resource Include="imagenes\tank.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Settings.Designer.cs">
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -10,7 +10,6 @@ using CtrEditor.Siemens;
|
|||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using System.Windows;
|
||||
using CtrEditor.Convertidores;
|
||||
using CtrEditor.Simulacion;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Siemens="clr-namespace:CtrEditor.Siemens"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:Siemens="clr-namespace:CtrEditor.Siemens"
|
||||
xmlns:ObjetosSim="clr-namespace:CtrEditor.ObjetosSim" x:Class="CtrEditor.MainWindow"
|
||||
Height="900" Width="1600" WindowState="Maximized"
|
||||
ResizeMode="CanResize" Title="{Binding directorioTrabajo}" Icon="/app2.png">
|
||||
|
@ -14,9 +13,7 @@
|
|||
</Window.DataContext>
|
||||
|
||||
<Window.Resources>
|
||||
<convert:FloatToFormattedStringConverter x:Key="floatFormatter"/>
|
||||
<convert:DoubleToFormattedStringConverter x:Key="doubleFormatter"/>
|
||||
<convert:BrushToColorNameConverter x:Key="BrushToColorNameConverter"/>
|
||||
|
||||
|
||||
<!-- Style for Start/Stop Button -->
|
||||
<Style x:Key="StartStopButtonStyle" TargetType="Button">
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Windows.Media;
|
|||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using Binding = System.Windows.Data.Binding;
|
||||
|
|
|
@ -2,12 +2,8 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
>
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osBotella/>
|
||||
</UserControl.DataContext>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
//using using Microsoft.Xna.Framework;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
<UserControl x:Class="CtrEditor.ObjetosSim.Dinamicos.ucBotellaCuello"
|
||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucBotellaCuello"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osBotella/>
|
||||
<vm:osBotellaCuello/>
|
||||
</UserControl.DataContext>
|
||||
|
||||
<Ellipse Height="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}"
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
//using using Microsoft.Xna.Framework;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace CtrEditor.ObjetosSim.Dinamicos
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ucBotellaCuelloCuello.xaml
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
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:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osFiller/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -3,16 +3,8 @@
|
|||
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:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
<convert:LevelToHeightMultiConverter x:Key="LevelToHeightMultiConverter"/>
|
||||
<convert:WidthPercentageConverter x:Key="WidthPercentageConverter"/>
|
||||
</UserControl.Resources>
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osTanque Alto="1" Ancho="1" Angulo="-4" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
<Storyboard x:Key="PulsingStoryboard" RepeatBehavior="Forever">
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="AnimatedEllipse"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using System.Windows;
|
||||
|
|
|
@ -4,12 +4,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osGuia/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
|
||||
|
|
|
@ -3,13 +3,9 @@
|
|||
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:localuc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:localuc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osTransporteCurva />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
<convert:DistanceToMarginConverter x:Key="DistanceToMarginConverter"/>
|
||||
|
||||
<!-- Define the VisualBrush for the conveyor belt pattern -->
|
||||
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
|
||||
<VisualBrush.Transform>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
<UserControl x:Class="CtrEditor.ObjetosSim.ucTransporteGuiasUnion"
|
||||
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:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:uc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<!-- Define the VisualBrush for the conveyor belt pattern -->
|
||||
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
|
||||
<VisualBrush.Transform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</VisualBrush.Transform>
|
||||
<VisualBrush.Visual>
|
||||
<Canvas>
|
||||
<Rectangle Fill="#FFBFBFBF" Width="10" Height="10"/>
|
||||
<Rectangle Fill="LightGray" Width="10" Height="10" Canvas.Left="10"/>
|
||||
</Canvas>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osTransporteGuiasUnion/>
|
||||
</UserControl.DataContext>
|
||||
|
||||
<Grid>
|
||||
<Canvas x:Name="Canvas" RenderTransformOrigin="0,0">
|
||||
<Canvas.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform/>
|
||||
<RotateTransform Angle="{Binding Angulo}"/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Canvas.RenderTransform>
|
||||
<Rectangle x:Name="TransporteA" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.75}"
|
||||
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}"
|
||||
Fill="{StaticResource BeltBrush}"
|
||||
/>
|
||||
<Rectangle x:Name="TransporteB" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.75}"
|
||||
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}"
|
||||
Fill="{StaticResource BeltBrush}"
|
||||
Canvas.Top="{Binding Alto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1.05}"
|
||||
Canvas.Left="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.25}"
|
||||
/>
|
||||
<Rectangle x:Name="GuiaSuperiorTop"
|
||||
Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.3}"
|
||||
Height="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter}}" Fill="Blue"
|
||||
Canvas.Top="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter},ConverterParameter=-1}"
|
||||
/>
|
||||
<Rectangle x:Name="GuiaInternaA"
|
||||
Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.4}"
|
||||
Height="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter}}" Fill="Blue"
|
||||
Canvas.Left="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.3}"
|
||||
Canvas.Top="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.6}" RenderTransformOrigin="0.5,0.5"
|
||||
>
|
||||
<Rectangle.RenderTransform>
|
||||
<RotateTransform Angle="17"/>
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
<Rectangle x:Name="GuiaInternaB"
|
||||
Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.4}"
|
||||
Height="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter}}" Fill="Blue"
|
||||
Canvas.Left="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.3}"
|
||||
Canvas.Top="{Binding Alto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1.8}" RenderTransformOrigin="0.5,0.5"
|
||||
>
|
||||
<Rectangle.RenderTransform>
|
||||
<RotateTransform Angle="15"/>
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
<Rectangle x:Name="GuiaSuperiorBott"
|
||||
Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.3}"
|
||||
Height="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter}}" Fill="Blue"
|
||||
Canvas.Top="{Binding Alto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
||||
/>
|
||||
<Rectangle x:Name="GuiaInferiorTop" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.3}"
|
||||
Height="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter}}"
|
||||
Canvas.Left="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.7}"
|
||||
Canvas.Top="{Binding Alto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.80}"
|
||||
Fill="Blue"
|
||||
/>
|
||||
<Rectangle x:Name="GuiaInferiorBott" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.3}"
|
||||
Height="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter}}"
|
||||
Canvas.Left="{Binding Ancho, Converter={StaticResource MeterToPixelConverter},ConverterParameter=0.7}"
|
||||
Canvas.Top="{Binding Alto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=2.05}"
|
||||
Fill="Blue"
|
||||
/>
|
||||
<uc:ThreeLinesControl AnchoRecto="50" AnchoCentro="70" Altura="25" AltoGuia="2"/>
|
||||
</Canvas>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -0,0 +1,469 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ucTransporteGuiasUnion.xaml
|
||||
/// </summary>
|
||||
public partial class osTransporteGuiasUnion : osBase, IosBase
|
||||
{
|
||||
private osBase _osMotorA = null;
|
||||
private osBase _osMotorB = null;
|
||||
|
||||
Dictionary<Rectangle, simTransporte> SimGeometriaT;
|
||||
Dictionary<Rectangle, simGuia> SimGeometriaG;
|
||||
Dictionary<Rectangle, Storyboard> Storyboards;
|
||||
Dictionary<Rectangle, BoolReference> TransportsDirection;
|
||||
Dictionary<Rectangle, FloatReference> TransportsVelocidad;
|
||||
|
||||
public static string NombreClase()
|
||||
{
|
||||
return "Transporte Guias Union";
|
||||
}
|
||||
private string nombre = NombreClase();
|
||||
public override string Nombre
|
||||
{
|
||||
get => nombre;
|
||||
set => SetProperty(ref nombre, value);
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public string motorA;
|
||||
|
||||
partial void OnMotorAChanged(string value)
|
||||
{
|
||||
_osMotorA = ObtenerLink(MotorA, typeof(osVMmotorSim));
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public float velocidadActualA;
|
||||
|
||||
partial void OnVelocidadActualAChanged(float value)
|
||||
{
|
||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
||||
{
|
||||
var transporte = uc.TransporteA;
|
||||
SetSpeed(transporte);
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
bool invertirDireccionA;
|
||||
|
||||
partial void OnInvertirDireccionAChanged(bool value)
|
||||
{
|
||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
||||
{
|
||||
var transporte = uc.TransporteA;
|
||||
|
||||
SetSpeed(transporte);
|
||||
ActualizarStoryboards(transporte);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
public string motorB;
|
||||
|
||||
partial void OnMotorBChanged(string value)
|
||||
{
|
||||
_osMotorB = ObtenerLink(MotorB, typeof(osVMmotorSim));
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public float velocidadActualB;
|
||||
|
||||
partial void OnVelocidadActualBChanged(float value)
|
||||
{
|
||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
||||
{
|
||||
var transporte = uc.TransporteB;
|
||||
SetSpeed(transporte);
|
||||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
bool invertirDireccionB;
|
||||
|
||||
partial void OnInvertirDireccionBChanged(bool value)
|
||||
{
|
||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
||||
{
|
||||
var transporte = uc.TransporteB;
|
||||
|
||||
SetSpeed(transporte);
|
||||
ActualizarStoryboards(transporte);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
public float anchoRecto;
|
||||
[ObservableProperty]
|
||||
public float anchoCentral;
|
||||
|
||||
[ObservableProperty]
|
||||
public float alto;
|
||||
|
||||
partial void OnAltoChanged(float value)
|
||||
{
|
||||
ActualizarGeometrias();
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
public float angulo;
|
||||
[ObservableProperty]
|
||||
public float frictionCoefficient;
|
||||
[ObservableProperty]
|
||||
public float velMax50hz;
|
||||
[ObservableProperty]
|
||||
public float tiempoRampa;
|
||||
[ObservableProperty]
|
||||
public bool esMarcha;
|
||||
[ObservableProperty]
|
||||
private float distance;
|
||||
[ObservableProperty]
|
||||
private float altoGuia;
|
||||
|
||||
void ActualizarStoryboards(Rectangle transporte)
|
||||
{
|
||||
if (!Storyboards.Keys.Contains(transporte)) return;
|
||||
|
||||
var direccion = TransportsDirection[transporte].Value;
|
||||
var velocidad = TransportsVelocidad[transporte].Value;
|
||||
|
||||
Storyboards[transporte] = CrearAnimacionMultiStoryBoardTrasnporte(Storyboards[transporte], transporte, direccion);
|
||||
ActualizarAnimacionMultiStoryBoardTransporte(Storyboards[transporte], velocidad);
|
||||
}
|
||||
|
||||
void SetSpeed(Rectangle transporte)
|
||||
{
|
||||
if (!Storyboards.Keys.Contains(transporte)) return;
|
||||
|
||||
var invertirDireccion = TransportsDirection[transporte].Value;
|
||||
var velocidad = TransportsVelocidad[transporte].Value;
|
||||
|
||||
if (invertirDireccion)
|
||||
SimGeometriaT[transporte]?.SetSpeed(-velocidad);
|
||||
else
|
||||
SimGeometriaT[transporte]?.SetSpeed(velocidad);
|
||||
|
||||
ActualizarAnimacionMultiStoryBoardTransporte(Storyboards[transporte], velocidad);
|
||||
}
|
||||
|
||||
private void ActualizarGeometrias()
|
||||
{
|
||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
||||
{
|
||||
foreach (var transporte in SimGeometriaT)
|
||||
{
|
||||
UpdateRectangle(transporte.Value, transporte.Key, Alto, Ancho, Angulo);
|
||||
ActualizarStoryboards(transporte.Key);
|
||||
}
|
||||
foreach (var l in SimGeometriaG)
|
||||
UpdateOrCreateLine(l.Value, l.Key);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public osTransporteGuiasUnion()
|
||||
{
|
||||
Ancho = 1;
|
||||
Alto = 0.10f;
|
||||
AltoGuia = 0.03f;
|
||||
Distance = 0.01f;
|
||||
SimGeometriaT = new Dictionary<Rectangle, simTransporte>();
|
||||
SimGeometriaG = new Dictionary<Rectangle, simGuia>();
|
||||
Storyboards = new Dictionary<Rectangle, Storyboard>();
|
||||
TransportsDirection = new Dictionary<Rectangle, BoolReference>();
|
||||
TransportsVelocidad = new Dictionary<Rectangle, FloatReference>();
|
||||
}
|
||||
|
||||
public override void UpdateGeometryStart()
|
||||
{
|
||||
// Se llama antes de la simulacion
|
||||
ActualizarGeometrias();
|
||||
}
|
||||
|
||||
public override void SimulationStop()
|
||||
{
|
||||
// Se llama al detener la simulacion
|
||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
||||
{
|
||||
SetSpeed(uc.TransporteB);
|
||||
SetSpeed(uc.TransporteA);
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
|
||||
{
|
||||
if (_osMotorA != null)
|
||||
{
|
||||
if (_osMotorA is osVMmotorSim motor)
|
||||
VelocidadActualA = motor.Velocidad;
|
||||
}
|
||||
else if (MotorA.Length > 0)
|
||||
_osMotorA = ObtenerLink(MotorA, typeof(osVMmotorSim));
|
||||
|
||||
if (_osMotorB != null)
|
||||
{
|
||||
if (_osMotorB is osVMmotorSim motor)
|
||||
VelocidadActualB = motor.Velocidad;
|
||||
}
|
||||
else if (MotorB.Length > 0)
|
||||
_osMotorB = ObtenerLink(MotorB, typeof(osVMmotorSim));
|
||||
|
||||
}
|
||||
|
||||
public override void ucLoaded()
|
||||
{
|
||||
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
||||
// crear el objeto de simulacion
|
||||
ActualizarLeftTop();
|
||||
|
||||
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
||||
// crear el objeto de simulacion
|
||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
||||
{
|
||||
var connector = new RectangleConnector(uc.Canvas, MeterToPixels(Alto/2));
|
||||
connector.ConnectRectangles();
|
||||
|
||||
foreach (var child in uc.Canvas.Children)
|
||||
{
|
||||
if (child is Rectangle rect)
|
||||
{
|
||||
if (rect.Name.StartsWith("Transporte"))
|
||||
{
|
||||
SimGeometriaT.Add(rect,AddRectangle(simulationManager, rect, Alto, Ancho, Angulo));
|
||||
Storyboards.Add(rect,CrearAnimacionMultiStoryBoardTrasnporte(rect,false));
|
||||
}
|
||||
if (rect.Name.StartsWith("Guia"))
|
||||
SimGeometriaG.Add(rect,AddLine(simulationManager, rect));
|
||||
}
|
||||
}
|
||||
|
||||
TransportsDirection.Add(uc.TransporteA, new BoolReference(() => InvertirDireccionA, value => InvertirDireccionA = value));
|
||||
TransportsDirection.Add(uc.TransporteB, new BoolReference(() => InvertirDireccionB, value => InvertirDireccionB = value));
|
||||
|
||||
TransportsVelocidad.Add(uc.TransporteA, new FloatReference(() => VelocidadActualA, value => VelocidadActualA = value));
|
||||
TransportsVelocidad.Add(uc.TransporteB, new FloatReference(() => VelocidadActualB, value => VelocidadActualB = value));
|
||||
|
||||
}
|
||||
OnMotorAChanged(MotorA);
|
||||
}
|
||||
|
||||
|
||||
public override void ucUnLoaded()
|
||||
{
|
||||
// El UserControl se esta eliminando
|
||||
// eliminar el objeto de simulacion
|
||||
foreach (var s in SimGeometriaT)
|
||||
simulationManager.Remove(s.Value);
|
||||
foreach (var s in SimGeometriaG)
|
||||
simulationManager.Remove(s.Value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class BoolReference
|
||||
{
|
||||
private Func<bool> getter;
|
||||
private Action<bool> setter;
|
||||
|
||||
public BoolReference(Func<bool> getter, Action<bool> setter)
|
||||
{
|
||||
this.getter = getter;
|
||||
this.setter = setter;
|
||||
}
|
||||
|
||||
public bool Value
|
||||
{
|
||||
get => getter();
|
||||
set => setter(value);
|
||||
}
|
||||
}
|
||||
|
||||
public class FloatReference
|
||||
{
|
||||
private Func<float> getter;
|
||||
private Action<float> setter;
|
||||
|
||||
public FloatReference(Func<float> getter, Action<float> setter)
|
||||
{
|
||||
this.getter = getter;
|
||||
this.setter = setter;
|
||||
}
|
||||
|
||||
public float Value
|
||||
{
|
||||
get => getter();
|
||||
set => setter(value);
|
||||
}
|
||||
}
|
||||
|
||||
public class RectangleConnector
|
||||
{
|
||||
private Canvas canvas;
|
||||
private double maxDistance;
|
||||
|
||||
public RectangleConnector(Canvas canvas, double maxDistance)
|
||||
{
|
||||
this.canvas = canvas;
|
||||
this.maxDistance = maxDistance;
|
||||
}
|
||||
|
||||
public void ConnectRectangles()
|
||||
{
|
||||
var rectangles = canvas.Children.OfType<Rectangle>().Where(rect => rect.Name.StartsWith("Guia")).ToList();
|
||||
|
||||
foreach (var rect in rectangles)
|
||||
{
|
||||
var connections = GetConnectionPoints(rect);
|
||||
foreach (var point in connections)
|
||||
{
|
||||
var closestPoint = GetClosestPoint(point, rectangles, rect);
|
||||
if (closestPoint != null && GetDistance(point, closestPoint.Value) < maxDistance)
|
||||
{
|
||||
AdjustRectanglePosition(rect, point, closestPoint.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Point> GetConnectionPoints(Rectangle rect)
|
||||
{
|
||||
double width = rect.Width;
|
||||
double height = rect.Height;
|
||||
double angle = GetRotationAngle(rect);
|
||||
|
||||
// Puntos de conexión sin rotación
|
||||
var points = new List<Point>
|
||||
{
|
||||
new Point(0, height / 2),
|
||||
new Point(width, height / 2)
|
||||
};
|
||||
|
||||
// Aplicar rotación
|
||||
var rotatedPoints = points.Select(p => RotatePoint(p, angle, new Point(width / 2, height / 2))).ToList();
|
||||
return rotatedPoints;
|
||||
}
|
||||
|
||||
private Point RotatePoint(Point point, double angle, Point center)
|
||||
{
|
||||
double radians = angle * Math.PI / 180;
|
||||
double cos = Math.Cos(radians);
|
||||
double sin = Math.Sin(radians);
|
||||
|
||||
double dx = point.X - center.X;
|
||||
double dy = point.Y - center.Y;
|
||||
|
||||
double x = center.X + (dx * cos - dy * sin);
|
||||
double y = center.Y + (dx * sin + dy * cos);
|
||||
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
private double GetRotationAngle(Rectangle rect)
|
||||
{
|
||||
var transform = rect.RenderTransform as RotateTransform;
|
||||
return transform?.Angle ?? 0;
|
||||
}
|
||||
|
||||
private Point? GetClosestPoint(Point point, List<Rectangle> rectangles, Rectangle excludeRect)
|
||||
{
|
||||
Point? closestPoint = null;
|
||||
double closestDistance = double.MaxValue;
|
||||
|
||||
foreach (var rect in rectangles)
|
||||
{
|
||||
if (rect == excludeRect) continue;
|
||||
|
||||
var points = GetConnectionPoints(rect);
|
||||
foreach (var p in points)
|
||||
{
|
||||
double distance = GetDistance(point, p);
|
||||
if (distance < closestDistance)
|
||||
{
|
||||
closestDistance = distance;
|
||||
closestPoint = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return closestPoint;
|
||||
}
|
||||
|
||||
private double GetDistance(Point p1, Point p2)
|
||||
{
|
||||
return Math.Sqrt(Math.Pow(p2.X - p1.X, 2) + Math.Pow(p2.Y - p1.Y, 2));
|
||||
}
|
||||
|
||||
private void AdjustRectanglePosition(Rectangle rect, Point currentPoint, Point targetPoint)
|
||||
{
|
||||
double offsetX = targetPoint.X - currentPoint.X;
|
||||
double offsetY = targetPoint.Y - currentPoint.Y;
|
||||
|
||||
double newLeft = Canvas.GetLeft(rect) + offsetX;
|
||||
double newTop = Canvas.GetTop(rect) + offsetY;
|
||||
|
||||
Canvas.SetLeft(rect, newLeft);
|
||||
Canvas.SetTop(rect, newTop);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class ucTransporteGuiasUnion : UserControl, IDataContainer
|
||||
{
|
||||
public osBase? Datos { get; set; }
|
||||
|
||||
public ucTransporteGuiasUnion()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Loaded += OnLoaded;
|
||||
this.Unloaded += OnUnloaded;
|
||||
}
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Datos?.ucLoaded();
|
||||
}
|
||||
private void OnUnloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Datos?.ucUnLoaded();
|
||||
}
|
||||
public void Resize(float width, float height)
|
||||
{
|
||||
if (Datos is osTransporteGuiasUnion datos)
|
||||
datos.Ancho = PixelToMeter.Instance.calc.PixelsToMeters(width);
|
||||
}
|
||||
public void Move(float LeftPixels, float TopPixels)
|
||||
{
|
||||
if (Datos != null)
|
||||
{
|
||||
Datos.Left = PixelToMeter.Instance.calc.PixelsToMeters(LeftPixels);
|
||||
Datos.Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels);
|
||||
}
|
||||
}
|
||||
public void Rotate(float Angle)
|
||||
{
|
||||
if (Datos != null)
|
||||
if (Datos is osTransporteGuiasUnion datos)
|
||||
datos.Angulo = Angle;
|
||||
}
|
||||
public void Highlight(bool State) { }
|
||||
public int ZIndex()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -4,13 +4,10 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
|
||||
<!-- Define the VisualBrush for the conveyor belt pattern -->
|
||||
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
|
||||
<VisualBrush.Transform>
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Windows.Controls;
|
|||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using System.Windows.Input;
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osVMmotorSim ImageSource_oculta="/imagenes/motorNegro.png" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osBoton Color="#FFADE6C0" ColorButton_oculto="#FFC72323"/>
|
||||
</UserControl.DataContext>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,13 +4,8 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osGearEncoder Dientes="9"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osPhotocell Color="#FFCA1C1C"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Simulacion;
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
|
@ -46,7 +46,7 @@ namespace CtrEditor.ObjetosSim
|
|||
EscribirBitTag(TagPhotocell_OUT, !LuzCortada);
|
||||
else
|
||||
EscribirBitTag(TagPhotocell_OUT, LuzCortada);
|
||||
if (filter_Frecuency < 1)
|
||||
if (Filter_Frecuency < 1)
|
||||
{
|
||||
Filter_Frecuency = 1;
|
||||
Frecuency = 0;
|
||||
|
|
|
@ -4,13 +4,8 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osSensTemperatura />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osAnalogTag/>
|
||||
</UserControl.DataContext>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osBoolTag/>
|
||||
</UserControl.DataContext>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
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"
|
||||
Background="LightGray"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
Background="LightGray">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osConsensGeneric />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
<UserControl x:Class="CtrEditor.ObjetosSim.Traces.ucTrace3"
|
||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucTrace3"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim.Traces"
|
||||
mc:Ignorable="d" Background="#FFECECEC">
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
Background="#FFECECEC"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osTrace3 Descripcion_Serie_1="Serie 1" Max_Cantidad_Elementos="100"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
@ -7,7 +7,7 @@ using System.Windows.Shapes;
|
|||
using CtrEditor.Siemens;
|
||||
using System.Runtime.Intrinsics;
|
||||
|
||||
namespace CtrEditor.ObjetosSim.Traces
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ucTrace3.xaml
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
<UserControl x:Class="CtrEditor.ObjetosSim.Traces.ucTraceSimple"
|
||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucTraceSimple"
|
||||
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"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim.Traces"
|
||||
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osTraceSimple Alto="3" Ancho="6"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
@ -11,7 +11,7 @@ using LiveChartsCore.SkiaSharpView;
|
|||
using LiveChartsCore.Defaults;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace CtrEditor.ObjetosSim.Traces
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ucTraceSimple.xaml
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Windows.Controls;
|
||||
using CtrEditor.Simulacion;
|
||||
using System.Reflection;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using System.Windows.Data;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<UserControl x:Class="CtrEditor.ObjetosSim.UserControls.ThreeLinesControl"
|
||||
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"
|
||||
Width="Auto" Height="Auto">
|
||||
|
||||
<Grid>
|
||||
<Canvas x:Name="Canvas"/>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -0,0 +1,116 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace CtrEditor.ObjetosSim.UserControls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ThreeLinesControl.xaml
|
||||
/// </summary>
|
||||
public partial class ThreeLinesControl : UserControl
|
||||
{
|
||||
public ThreeLinesControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Loaded += ThreeLinesControl_Loaded;
|
||||
}
|
||||
|
||||
private void ThreeLinesControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CreateRectangles();
|
||||
}
|
||||
|
||||
public double AnchoRecto
|
||||
{
|
||||
get { return (double)GetValue(AnchoRectoProperty); }
|
||||
set { SetValue(AnchoRectoProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AnchoRectoProperty =
|
||||
DependencyProperty.Register("AnchoRecto", typeof(double), typeof(ThreeLinesControl), new PropertyMetadata(100.0, OnDimensionsChanged));
|
||||
|
||||
public double AnchoCentro
|
||||
{
|
||||
get { return (double)GetValue(AnchoCentroProperty); }
|
||||
set { SetValue(AnchoCentroProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AnchoCentroProperty =
|
||||
DependencyProperty.Register("AnchoCentro", typeof(double), typeof(ThreeLinesControl), new PropertyMetadata(100.0, OnDimensionsChanged));
|
||||
|
||||
public double Altura
|
||||
{
|
||||
get { return (double)GetValue(AlturaProperty); }
|
||||
set { SetValue(AlturaProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AlturaProperty =
|
||||
DependencyProperty.Register("Altura", typeof(double), typeof(ThreeLinesControl), new PropertyMetadata(100.0, OnDimensionsChanged));
|
||||
|
||||
public double AltoGuia
|
||||
{
|
||||
get { return (double)GetValue(AltoGuiaProperty); }
|
||||
set { SetValue(AltoGuiaProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AltoGuiaProperty =
|
||||
DependencyProperty.Register("AltoGuia", typeof(double), typeof(ThreeLinesControl), new PropertyMetadata(10.0, OnDimensionsChanged));
|
||||
|
||||
private static void OnDimensionsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var control = d as ThreeLinesControl;
|
||||
control?.CreateRectangles();
|
||||
}
|
||||
|
||||
private void CreateRectangles()
|
||||
{
|
||||
Canvas.Children.Clear();
|
||||
|
||||
// Crear Liz
|
||||
var liz = new Rectangle
|
||||
{
|
||||
Width = AnchoRecto,
|
||||
Height = AltoGuia,
|
||||
Fill = Brushes.Blue
|
||||
};
|
||||
Canvas.SetLeft(liz, 0);
|
||||
Canvas.SetTop(liz, -AltoGuia / 2);
|
||||
Canvas.Children.Add(liz);
|
||||
|
||||
// Calcular la hipotenusa para Lc
|
||||
double lcWidth = Math.Sqrt(Math.Pow(AnchoCentro, 2) + Math.Pow(Altura, 2));
|
||||
|
||||
// Crear Lc
|
||||
var lc = new Rectangle
|
||||
{
|
||||
Width = lcWidth,
|
||||
Height = AltoGuia,
|
||||
Fill = Brushes.Red,
|
||||
RenderTransformOrigin = new Point(0, 0.5)
|
||||
};
|
||||
lc.RenderTransform = new RotateTransform(GetRotationAngle(AnchoCentro, Altura));
|
||||
Canvas.SetLeft(lc, AnchoRecto);
|
||||
Canvas.SetTop(lc, -AltoGuia / 2);
|
||||
Canvas.Children.Add(lc);
|
||||
|
||||
// Crear Lde
|
||||
var lde = new Rectangle
|
||||
{
|
||||
Width = AnchoRecto,
|
||||
Height = AltoGuia,
|
||||
Fill = Brushes.Green
|
||||
};
|
||||
Canvas.SetLeft(lde, AnchoRecto + AnchoCentro);
|
||||
Canvas.SetTop(lde, Altura - AltoGuia / 2);
|
||||
Canvas.Children.Add(lde);
|
||||
}
|
||||
|
||||
|
||||
private double GetRotationAngle(double anchoCentro, double altura)
|
||||
{
|
||||
return Math.Atan2(altura, anchoCentro) * 180 / Math.PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,19 +11,16 @@ using System.Windows;
|
|||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using CtrEditor.Convertidores;
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using System.Windows.Media;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using Siemens.Simatic.Simulation.Runtime;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Diagnostics;
|
||||
using HarfBuzzSharp;
|
||||
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
|
@ -246,19 +243,12 @@ namespace CtrEditor.ObjetosSim
|
|||
return null;
|
||||
}
|
||||
|
||||
protected void CrearAnimacionStoryBoardTrasnporte(System.Windows.Shapes.Rectangle transporte, bool invertirDireccion)
|
||||
protected Storyboard CrearAnimacionMultiStoryBoardTrasnporte(System.Windows.Shapes.Rectangle transporte, bool invertirDireccion)
|
||||
{
|
||||
if (_visualRepresentation == null) return;
|
||||
if (transporte == null) return;
|
||||
if (_visualRepresentation == null) return null;
|
||||
if (transporte == null) return null;
|
||||
|
||||
// Detener y eliminar el storyboard existente si hay uno
|
||||
if (_storyboard != null)
|
||||
{
|
||||
_storyboard.Stop();
|
||||
_storyboard.Children.Clear();
|
||||
}
|
||||
|
||||
_storyboard = new Storyboard();
|
||||
Storyboard storyboard = new Storyboard();
|
||||
var animation = new DoubleAnimation
|
||||
{
|
||||
From = invertirDireccion ? 20 : 0,
|
||||
|
@ -268,20 +258,43 @@ namespace CtrEditor.ObjetosSim
|
|||
};
|
||||
Storyboard.SetTarget(animation, transporte);
|
||||
Storyboard.SetTargetProperty(animation, new PropertyPath("(Rectangle.Fill).(VisualBrush.Transform).(TransformGroup.Children)[0].(TranslateTransform.X)"));
|
||||
_storyboard.Children.Add(animation);
|
||||
_storyboard.Begin();
|
||||
_storyboard.SetSpeedRatio(0);
|
||||
storyboard.Children.Add(animation);
|
||||
storyboard.Begin();
|
||||
storyboard.SetSpeedRatio(0);
|
||||
return storyboard;
|
||||
}
|
||||
|
||||
protected Storyboard CrearAnimacionMultiStoryBoardTrasnporte(Storyboard storyboard, System.Windows.Shapes.Rectangle transporte, bool invertirDireccion)
|
||||
{
|
||||
// Detener y eliminar el storyboard existente si hay uno
|
||||
if (storyboard != null)
|
||||
{
|
||||
storyboard.Stop();
|
||||
storyboard.Children.Clear();
|
||||
}
|
||||
|
||||
return CrearAnimacionMultiStoryBoardTrasnporte(transporte, invertirDireccion);
|
||||
}
|
||||
|
||||
protected void ActualizarAnimacionMultiStoryBoardTransporte(Storyboard storyboard, float velocidadActual)
|
||||
{
|
||||
if (_visualRepresentation == null) return;
|
||||
if (storyboard == null) return;
|
||||
|
||||
if (!_mainViewModel.IsSimulationRunning)
|
||||
storyboard.SetSpeedRatio(0);
|
||||
else
|
||||
storyboard.SetSpeedRatio(Math.Abs(velocidadActual));
|
||||
}
|
||||
|
||||
protected void CrearAnimacionStoryBoardTrasnporte(System.Windows.Shapes.Rectangle transporte, bool invertirDireccion)
|
||||
{
|
||||
_storyboard = CrearAnimacionMultiStoryBoardTrasnporte(_storyboard, transporte, invertirDireccion);
|
||||
}
|
||||
|
||||
protected void ActualizarAnimacionStoryBoardTransporte(float velocidadActual)
|
||||
{
|
||||
if (_visualRepresentation == null) return;
|
||||
if (_storyboard == null) return;
|
||||
|
||||
if (!_mainViewModel.IsSimulationRunning)
|
||||
_storyboard.SetSpeedRatio(0);
|
||||
else
|
||||
_storyboard.SetSpeedRatio(Math.Abs(velocidadActual));
|
||||
ActualizarAnimacionMultiStoryBoardTransporte(_storyboard, velocidadActual);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -387,6 +400,16 @@ namespace CtrEditor.ObjetosSim
|
|||
else return 0f;
|
||||
}
|
||||
|
||||
public float PixelsToMeters(float pixel)
|
||||
{
|
||||
return PixelToMeter.Instance.calc.PixelsToMeters(pixel);
|
||||
}
|
||||
|
||||
public float MeterToPixels(float meter)
|
||||
{
|
||||
return PixelToMeter.Instance.calc.MetersToPixels(meter);
|
||||
}
|
||||
|
||||
public (Vector2 TopLeft, Vector2 BottomRight) GetRectangleCoordinatesInMeter(System.Windows.Shapes.Rectangle rect)
|
||||
{
|
||||
if (rect != null)
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
>
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace CtrEditor.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
</SettingsFile>
|
|
@ -1,23 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using System.Windows;
|
||||
using System.Diagnostics;
|
||||
using CtrEditor.ObjetosSim;
|
||||
using System.Windows.Documents;
|
||||
using nkast.Aether.Physics2D;
|
||||
using nkast.Aether.Physics2D.Dynamics;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
using nkast.Aether.Physics2D.Collision.Shapes;
|
||||
using nkast.Aether.Physics2D.Dynamics.Contacts;
|
||||
using nkast.Aether.Physics2D.Collision;
|
||||
using Transform = nkast.Aether.Physics2D.Common.Transform;
|
||||
using nkast.Aether.Physics2D.Dynamics.Joints;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
|
||||
namespace CtrEditor.Simulacion
|
||||
{
|
||||
|
@ -33,6 +25,14 @@ namespace CtrEditor.Simulacion
|
|||
_world.Remove(Body);
|
||||
}
|
||||
}
|
||||
public static float GradosARadianes(float grados)
|
||||
{
|
||||
return (float)(grados * (Math.PI / 180));
|
||||
}
|
||||
public static float RadianesAGrados(float radianes)
|
||||
{
|
||||
return (float)(radianes * (180 / Math.PI));
|
||||
}
|
||||
public void SetPosition(float x, float y)
|
||||
{
|
||||
Body.SetTransform(new Vector2(x, y), Body.Rotation);
|
||||
|
@ -62,8 +62,8 @@ namespace CtrEditor.Simulacion
|
|||
_deferredActions = deferredActions;
|
||||
_innerRadius = innerRadius;
|
||||
_outerRadius = outerRadius;
|
||||
_startAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(startAngle);
|
||||
_endAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(endAngle);
|
||||
_startAngle = GradosARadianes(startAngle);
|
||||
_endAngle = GradosARadianes(endAngle);
|
||||
Create(position);
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,8 @@ namespace CtrEditor.Simulacion
|
|||
if (_world == null) return;
|
||||
_innerRadius = innerRadius;
|
||||
_outerRadius = outerRadius;
|
||||
_startAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(startAngle);
|
||||
_endAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(endAngle);
|
||||
_startAngle = GradosARadianes(startAngle);
|
||||
_endAngle = GradosARadianes(endAngle);
|
||||
Create(position);
|
||||
}
|
||||
|
||||
|
@ -197,8 +197,8 @@ namespace CtrEditor.Simulacion
|
|||
|
||||
public float Angle
|
||||
{
|
||||
get { return Microsoft.Xna.Framework.MathHelper.ToDegrees(Body.Rotation); }
|
||||
set { Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(value); }
|
||||
get { return RadianesAGrados(Body.Rotation); }
|
||||
set { Body.Rotation = GradosARadianes(value); }
|
||||
}
|
||||
|
||||
public new void SetPosition(float x, float y)
|
||||
|
@ -229,7 +229,7 @@ namespace CtrEditor.Simulacion
|
|||
Body = _world.CreateRectangle( width, height, 1f, position);
|
||||
Body.FixtureList[0].IsSensor = true;
|
||||
Body.BodyType = BodyType.Static;
|
||||
Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(angle);
|
||||
Body.Rotation = GradosARadianes(angle);
|
||||
Body.Tag = this; // Importante para la identificación durante la colisión
|
||||
}
|
||||
}
|
||||
|
@ -257,8 +257,8 @@ namespace CtrEditor.Simulacion
|
|||
|
||||
public float Angle
|
||||
{
|
||||
get { return Microsoft.Xna.Framework.MathHelper.ToDegrees(Body.Rotation); }
|
||||
set { Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(value); }
|
||||
get { return RadianesAGrados(Body.Rotation); }
|
||||
set { Body.Rotation = GradosARadianes(value); }
|
||||
}
|
||||
|
||||
public new void SetPosition(float x, float y)
|
||||
|
@ -282,7 +282,7 @@ namespace CtrEditor.Simulacion
|
|||
Body = _world.CreateRectangle( width, height, 1f, position);
|
||||
Body.FixtureList[0].IsSensor = true;
|
||||
Body.BodyType = BodyType.Static;
|
||||
Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(angle);
|
||||
Body.Rotation = GradosARadianes(angle);
|
||||
Body.Tag = this; // Importante para la identificación durante la colisión
|
||||
LuzCortada = 0;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ using FarseerPhysics.Dynamics;
|
|||
using FarseerPhysics.Factories;
|
||||
using FarseerPhysics.Collision.Shapes;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using FarseerPhysics.Common;
|
||||
using System.Windows;
|
||||
using System.Diagnostics;
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FarseerPhysics.Collision;
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
|
||||
|
|
|
@ -146,13 +146,13 @@ namespace CtrEditor.Simulacion
|
|||
float radius = circleShape.Radius;
|
||||
float halfSide = radius; // El lado del cuadrado inscrito es igual al radio
|
||||
|
||||
Vector2[] squareVertices =
|
||||
[
|
||||
new Vector2(-halfSide, -halfSide),
|
||||
new Vector2(halfSide, -halfSide),
|
||||
new Vector2(halfSide, halfSide),
|
||||
new Vector2(-halfSide, halfSide)
|
||||
];
|
||||
Vector2[] squareVertices = new Vector2[]
|
||||
{
|
||||
new Vector2(-halfSide, -halfSide),
|
||||
new Vector2(halfSide, -halfSide),
|
||||
new Vector2(halfSide, halfSide),
|
||||
new Vector2(-halfSide, halfSide)
|
||||
};
|
||||
|
||||
foreach (var vertex in squareVertices)
|
||||
{
|
||||
|
@ -164,6 +164,7 @@ namespace CtrEditor.Simulacion
|
|||
return vertices;
|
||||
}
|
||||
|
||||
|
||||
private static Vector2 RotatePoint(Vector2 point, Vector2 origin, float rotation)
|
||||
{
|
||||
float cos = (float)Math.Cos(rotation);
|
||||
|
|
|
@ -1,15 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows;
|
||||
|
||||
namespace CtrEditor.Convertidores
|
||||
namespace CtrEditor
|
||||
{
|
||||
public class VerticalPositionConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is double altura && double.TryParse(parameter?.ToString(), out double factor))
|
||||
{
|
||||
return altura * factor;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class HalfWidthConverter : IValueConverter
|
||||
{
|
||||
|
@ -178,6 +189,27 @@ namespace CtrEditor.Convertidores
|
|||
}
|
||||
}
|
||||
|
||||
public class MarginConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values.Length == 4 &&
|
||||
values[0] is double left &&
|
||||
values[1] is double top &&
|
||||
values[2] is double right &&
|
||||
values[3] is double bottom)
|
||||
{
|
||||
return new Thickness(PixelToMeter.Instance.calc.MetersToPixels((float)left), PixelToMeter.Instance.calc.MetersToPixels((float)top), PixelToMeter.Instance.calc.MetersToPixels((float)right), PixelToMeter.Instance.calc.MetersToPixels((float)bottom));
|
||||
}
|
||||
return new Thickness();
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException("ConvertBack is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
public class DistanceToMarginConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
Loading…
Reference in New Issue