CtrEditor/ObjetosSim/ucBotella.xaml.cs

142 lines
3.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Numerics;
namespace CtrEditor.ObjetosSim
{
/// <summary>
/// Interaction logic for ucBotella.xaml
/// </summary>
///
public class osBotella : osBase
{
private Circle Geometria = new Circle();
// Otros datos y métodos relevantes para la simulación
private string _nombre = "Botella";
public float Diametro {
get => Geometria.Diameter;
set
{
Geometria.Diameter = value;
OnPropertyChanged(nameof(Diametro));
}
}
public float Mass {
get => Geometria.Mass;
set
{
Geometria.Mass = value;
OnPropertyChanged(nameof(Mass));
}
}
public float Overlap
{
get => Geometria.Overlap;
set
{
Geometria.Overlap = value;
OnPropertyChanged(nameof(Overlap));
}
}
public override float Left
{
get => Geometria.Left;
set
{
Geometria.Left = value;
CanvasSetLeftinMeter(value);
OnPropertyChanged(nameof(Left));
}
}
public override float Top
{
get => Geometria.Top;
set
{
Geometria.Top = value;
CanvasSetTopinMeter(value);
OnPropertyChanged(nameof(Top));
}
}
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
}
public osBotella()
{
Diametro = 0.10f;
}
public override void ConnectSimManager(SimulationManager simulationManager)
{
simulationManager.circles.Add(Geometria);
}
public override void UpdateGeometry()
{
// Se llama antes de la simulacion
}
public override void UpdateControl()
{
Top = Geometria.Top;
Left = Geometria.Left;
Overlap = Geometria.Overlap;
}
}
public partial class ucBotella : UserControl, IDataContainer
{
public osBase? Datos { get; set; }
public ucBotella()
{
InitializeComponent();
}
public void Resize(float width, float height) { }
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) { }
public void Highlight(bool State) { }
public int ZIndex()
{
return 10;
}
}
}