CtrEditor/ObjetosSim/ucBotella.xaml.cs

165 lines
4.6 KiB
C#
Raw Normal View History

2024-05-02 11:06:45 -03:00
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;
2024-05-06 12:31:45 -03:00
using System.Numerics;
2024-05-02 11:06:45 -03:00
namespace CtrEditor.ObjetosSim
2024-05-02 11:06:45 -03:00
{
/// <summary>
/// Interaction logic for ucBotella.xaml
2024-05-02 11:06:45 -03:00
/// </summary>
///
public class osBotella : osBase
2024-05-02 11:06:45 -03:00
{
2024-05-06 12:31:45 -03:00
private Circle Data = new Circle();
// Otros datos y métodos relevantes para la simulación
private string _nombre = "Botella";
2024-05-06 12:31:45 -03:00
public float Diametro {
get => Data.Diameter;
set
{
Data.Diameter = value;
OnPropertyChanged(nameof(Diametro));
OnPropertyChanged(nameof(DiametroPixels));
2024-05-06 12:31:45 -03:00
}
}
public float DiametroPixels
{
get => PixelToMeter.Instance.calc.MetersToPixels(Data.Diameter);
set
{
Data.Diameter = PixelToMeter.Instance.calc.PixelsToMeters(value);
OnPropertyChanged(nameof(Diametro));
OnPropertyChanged(nameof(DiametroPixels));
}
}
2024-05-06 12:31:45 -03:00
public float Mass {
get => Data.Mass;
set
{
Data.Mass = value;
OnPropertyChanged(nameof(Mass));
}
}
public override float LeftPixels
2024-05-03 05:13:25 -03:00
{
get => PixelToMeter.Instance.calc.MetersToPixels(Data.Left);
2024-05-06 12:31:45 -03:00
set
{
Data.Left = PixelToMeter.Instance.calc.PixelsToMeters(value);
2024-05-06 12:31:45 -03:00
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));
2024-05-06 12:31:45 -03:00
OnPropertyChanged(nameof(Left));
}
2024-05-03 05:13:25 -03:00
}
2024-05-06 12:31:45 -03:00
public override float Top
{
get => Data.Top;
2024-05-06 12:31:45 -03:00
set
{
Data.Top = value;
2024-05-06 12:31:45 -03:00
if (_visualRepresentation != null)
Canvas.SetTop(_visualRepresentation, PixelToMeter.Instance.calc.MetersToPixels(value));
OnPropertyChanged(nameof(TopPixels));
2024-05-06 12:31:45 -03:00
OnPropertyChanged(nameof(Top));
}
}
public override string Nombre
{
get => _nombre;
set
{
if (_nombre != value)
{
_nombre = value;
OnPropertyChanged(nameof(Nombre));
}
}
}
public osBotella()
{
DiametroPixels = 10;
}
2024-05-06 12:31:45 -03:00
public override void ConnectSimManager(SimulationManager simulationManager)
{
simulationManager.circles.Add(Data);
2024-05-06 12:31:45 -03:00
}
public override void UpdateControl()
{
Top = Data.Top;
Left = Data.Left;
2024-05-06 12:31:45 -03:00
}
2024-05-02 11:06:45 -03:00
}
public partial class ucBotella : UserControl, IDataContainer
{
public osBase? Datos { get; set; }
public ucBotella()
{
InitializeComponent();
}
2024-05-06 12:31:45 -03:00
public void Resize(float width, float height) { }
public void Move(float LeftPixels, float TopPixels)
{
if (Datos != null)
{
Datos.LeftPixels = LeftPixels;
Datos.TopPixels = TopPixels;
}
}
2024-05-06 12:31:45 -03:00
public void Rotate(float Angle) { }
2024-05-04 16:27:04 -03:00
public void Highlight(bool State) { }
public int ZIndex()
{
return 10;
}
}
2024-05-02 11:06:45 -03:00
}