Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7628753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:39:17+00:00 2026-05-31T05:39:17+00:00

So I have the following class constructor public class BolaInfo { private double massa;

  • 0

So I have the following class constructor

public class BolaInfo
{
 private double massa;
 private double raio;
 private double corX;
 private double corY;
 private double max_x;
 private double min_x;
 private double max_y;
 private double min_y;
 private double teste;
 private double angulo;
 private double velocidade;
 private double velX;
 private double velY;
 private Random rand;
 private Random rand1;

 public BolaInfo()
 {
   this.rand = new Random();
   this.rand1 = new Random();

   MASSA = massa;
   VELOCIDADE = velocidade;
   RAIO = raio;
   CORX = corX;
   CORY = corY;
   ANGULO = angulo;

   ANGULO = (double)(rand.Next(0, 360));

   this.ellips = new Ellipse();
   ELLIPSE = ellips;
   ELLIPSE.SetResourceReference(Ellipse.FillProperty, "BallGrad");
   ELLIPSE.Width = RAIO * 2;
   ELLIPSE.Height = RAIO * 2;

   CORX = rand.Next((int)(RAIO),(int)(650 - RAIO));
   CORY = rand1.Next((int)(RAIO), (int)(440 - RAIO));

   VELOC_X = velX;
   VELOC_X = Math.Cos(angulo * Math.PI / 180);

   VELOC_Y = velY;
   VELOC_Y = Math.Sin(angulo * Math.PI / 180);
  } 

 public double MASSA { get; set; }
 public double RAIO { get; set; }
 public double CORX { get; set; }
 public double CORY { get; set; }
 public double VELOCIDADE { get; set; }
 public double VELOC_X { get; set; }
 public double VELOC_Y { get; set; }
 public double ANGULO { get; set; }
 public Ellipse ELLIPSE { get; set; }
}

I’m using a datagrid binded to a list of this class and when I add a new row all looks fine except ELLIPSE.Width, ELLIPSE.Height, CORX, CORY, VELOC_X and VELOC_Y.

The problem is those values are generated by the input in RAIO and acording to the breakpoints it sets its initial value to 0 and doesn’t recalculate those values with the new value of it.

I though of calling functions where the datagrid is declared to set those values correctly but I know it wouldn’t be the best practice way (in my head at least).

How can I fix this without resorting to that way?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:39:18+00:00Added an answer on May 31, 2026 at 5:39 am

    it’s hard to tell from your naming conventions, whether you are assigning to attributes or properties.
    You also seem to want to use functions or properties. Showing how you bound RAIO to BolaInfo would be helpful to. maybe you are looking for the INotifyPropertyChanged-Interface:

    public class BolaInfo : INotifyPropertyChanged{
       private double _angulo;
       private double _raio;
       private double? _velocityX;
       public BolaInfo(double initRaio)
       {
          var rand = new Random();
          //just do initialization of class members
          this.angulo = (double)(rand.Next(0, 360));
          this.raio = initRaio;
       }
       public double VelocityX
       {
         get{
            if( _velocityX == null ){
               _velocityX = Math.Cos(this.angulo * Math.PI / 180) + raio;
            }
            return _velocityX.Value;
         }
       }
       //writable property needs a setter
       public double Raio{
         get{ 
           return _raio;
         }
         set{
           if( _raio == value ) return;
           _raio = value;
           _velocityX = null;
           RaisePropertyChanged("Raio");
           RaisePropertyChanged("VelocityX");
         } 
       }
       private void RaisePropertyChanged(String propName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
            }
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Service class constructor: public class Service : IService { private
I have a class which has the following constructor public DelayCompositeDesigner(DelayComposite CompositeObject) { InitializeComponent();
I have following class public class ButtonChange { private int _buttonState; public void SetButtonState(int
suppose I have the following class: class MyInteger { private: int n_; public: MyInteger(int
I have the following class: public class Car implements Comparable<Car>{ private long idCar; private
I have the following class: private class Info{ public String A; public int B;
I have the following class: public class SqlCeEventStore: EventStore { private EventStoreDB db; public
I have the following C++-class: // Header-File class A { public: A(); private: B
I have following situation. In a constructor of a pseudo class I attach a
I have following class (as seen through reflector) public class W : IDisposable {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.