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 { /// /// Interaction logic for ucBotella.xaml /// /// public class osBotella : osBase { private Circle Data = new Circle(); // Otros datos y métodos relevantes para la simulación private string _nombre = "Botella"; public float Diametro { get => Data.Diameter; set { Data.Diameter = value; OnPropertyChanged(nameof(Diametro)); OnPropertyChanged(nameof(DiametroPixels)); } } public float DiametroPixels { get => PixelToMeter.Instance.calc.MetersToPixels(Data.Diameter); set { Data.Diameter = PixelToMeter.Instance.calc.PixelsToMeters(value); OnPropertyChanged(nameof(Diametro)); OnPropertyChanged(nameof(DiametroPixels)); } } public float Mass { get => Data.Mass; set { Data.Mass = value; OnPropertyChanged(nameof(Mass)); } } public float Overlap { get => Data.Overlap; set { Data.Overlap = value; OnPropertyChanged(nameof(Overlap)); } } public override float LeftPixels { get => PixelToMeter.Instance.calc.MetersToPixels(Data.Left); set { Data.Left = PixelToMeter.Instance.calc.PixelsToMeters(value); if (_visualRepresentation != null) Canvas.SetLeft(_visualRepresentation, value); OnPropertyChanged(nameof(LeftPixels)); OnPropertyChanged(nameof(Left)); } } public override float TopPixels { get => PixelToMeter.Instance.calc.MetersToPixels(Data.Top); set { Data.Top = PixelToMeter.Instance.calc.PixelsToMeters(value); if (_visualRepresentation != null) Canvas.SetTop(_visualRepresentation,value); OnPropertyChanged(nameof(TopPixels)); OnPropertyChanged(nameof(Top)); } } public override float Left { get => Data.Left; set { Data.Left = value; if (_visualRepresentation != null) Canvas.SetLeft(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(value)); OnPropertyChanged(nameof(LeftPixels)); OnPropertyChanged(nameof(Left)); } } public override float Top { get => Data.Top; set { Data.Top = value; if (_visualRepresentation != null) Canvas.SetTop(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(value)); OnPropertyChanged(nameof(TopPixels)); OnPropertyChanged(nameof(Top)); } } public override string Nombre { get => _nombre; set { if (_nombre != value) { _nombre = value; OnPropertyChanged(nameof(Nombre)); } } } public osBotella() { DiametroPixels = 10; } public override void ConnectSimManager(SimulationManager simulationManager) { simulationManager.circles.Add(Data); } public override void UpdateControl() { Top = Data.Top; Left = Data.Left; Overlap = Data.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.LeftPixels = LeftPixels; Datos.TopPixels = TopPixels; } } public void Rotate(float Angle) { } public void Highlight(bool State) { } public int ZIndex() { return 10; } } }