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;
        }
        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};
 }
 public FieldPoint(Charge charge)
 {
     InitializeComponent();
     mcharge = charge;
 }
 public FieldPoint()
 {
     InitializeComponent();
     mcharge = new Charge();
 }
 public void RemoveExistingCharge(Charge charge, UIElement element)
 {
     _charges.Remove(charge);
     gridField.Children.Remove(element);
     Calculation();
     FieldOutline.Update();
 }
 public PositiveCharge()
 {
     InitializeComponent();
     MyCharge = new Charge();
 }