Esempio n. 1
0
        public Settings(Charge charge)
        {
            InitializeComponent();
            integerUDCharge.Value = charge.ElectricCharge;
            integerUDMass.Value = charge.Mass;
            lblbCName.Content = "Settings - " + charge.Name;

            cmboxType.Items.Add("Positive");
            cmboxType.Items.Add("Negative");

            cmboxType.SelectedIndex = charge.Type == Charge.ChargeType.Positive ? 0 : 1;
        }
Esempio n. 2
0
        public void AddNewCharge(Charge charge)
        {
            if (charge.Type == Charge.ChargeType.Positive)
            {
                var positiveCharge = new PositiveCharge();
                positiveCharge.Margin = new Thickness(0, 0, 0, 0);
                positiveCharge.VerticalAlignment = VerticalAlignment.Top;
                positiveCharge.HorizontalAlignment = HorizontalAlignment.Left;
                positiveCharge.MyCharge = charge;

                gridField.Children.Add(positiveCharge);

                var group = new TransformGroup();

                var transfer = new TranslateTransform
                                   {
                                       X = Helper.RandomNumber(10, (int) gridField.Width - 45),
                                       Y = Helper.Clamp(Helper.RandomNumber(10, ((int) gridField.Height - 35)/2), 0,
                                                        (int) gridField.Height - 65)
                                   };
                group.Children.Add(transfer);
                positiveCharge.RenderTransform = group;

                _charges.Add(positiveCharge.MyCharge);
            }
            else
            {
                var negativeCharge = new NegativeCharge();
                negativeCharge.Margin = new Thickness(0, 0, 0, 0);
                negativeCharge.VerticalAlignment = VerticalAlignment.Top;
                negativeCharge.HorizontalAlignment = HorizontalAlignment.Left;
                negativeCharge.MyCharge = charge;

                gridField.Children.Add(negativeCharge);

                var group = new TransformGroup();

                var transfer = new TranslateTransform
                                   {
                                       X = Helper.RandomNumber(10, (int) gridField.Width - 45),
                                       Y = Helper.RandomNumber(10, ((int) gridField.Height - 35))
                                   };
                group.Children.Add(transfer);
                negativeCharge.RenderTransform = group;

                _charges.Add(negativeCharge.MyCharge);
            }
            CalculatePositions();
            Calculation();
            FieldOutline.Update();
        }
 public NegativeCharge()
 {
     InitializeComponent();
     MyCharge = new Charge {ElectricCharge = 1, Type = Charge.ChargeType.Negative};
 }
Esempio n. 4
0
 public FieldPoint(Charge charge)
 {
     InitializeComponent();
     mcharge = charge;
 }
Esempio n. 5
0
 public FieldPoint()
 {
     InitializeComponent();
     mcharge = new Charge();
 }
Esempio n. 6
0
 public void RemoveExistingCharge(Charge charge, UIElement element)
 {
     _charges.Remove(charge);
     gridField.Children.Remove(element);
     Calculation();
     FieldOutline.Update();
 }
 public PositiveCharge()
 {
     InitializeComponent();
     MyCharge = new Charge();
 }