Click here to Skip to main content
15,891,409 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# working with strings Pin
Paul Conrad2-Jun-12 7:02
professionalPaul Conrad2-Jun-12 7:02 
AnswerRe: C# working with strings Pin
OriginalGriff2-Jun-12 9:01
mveOriginalGriff2-Jun-12 9:01 
Questionsend SMS in C# Pin
sina rahimzadeh1-Jun-12 21:48
sina rahimzadeh1-Jun-12 21:48 
AnswerRe: send SMS in C# Pin
Richard MacCutchan1-Jun-12 22:32
mveRichard MacCutchan1-Jun-12 22:32 
AnswerRe: send SMS in C# Pin
Sander Rossel2-Jun-12 0:43
professionalSander Rossel2-Jun-12 0:43 
AnswerRe: send SMS in C# Pin
taha bahraminezhad Jooneghani3-Jun-12 1:56
taha bahraminezhad Jooneghani3-Jun-12 1:56 
QuestionHow to hold dice in yahtzee Pin
Member 83368481-Jun-12 16:05
Member 83368481-Jun-12 16:05 
AnswerRe: How to hold dice in yahtzee Pin
sina rahimzadeh1-Jun-12 21:46
sina rahimzadeh1-Jun-12 21:46 
You can use this code for dice:
C#
public void InitializeRandomRoll( int nSeed )
{
  DateTime aTime = new DateTime(1000);
  aTime = DateTime.Now;
  nSeed += (int)(aTime.Millisecond);
  RandomPick = new Random(nSeed);
}

We need to be able to hold a dice,so that it does not roll when the roll button is pressed.So,we add a variable to hold the state of the dice.and you can use this property.
C#
private bool m_bHoldState = false;
public bool HoldState
{
  get { return m_bHoldState; }
  set { m_bHoldState = value; }
}

Now,we need to make sure that if the dice is held,it does not get rolled.
C#
public void Roll()
{
  // If the dice is not held, roll it
  if( !HoldState )
  {
    RollNumber = RandomPick.Next(1,7);
    this.Invalidate();
  }
}

At the end,the dice is drawn in black if the dice is not held,and in red if it is.
C#
public void DrawDot( Graphics g, Point p )
{
  SolidBrush myBrush;

  if( HoldState )
  {
    myBrush = new SolidBrush( Color.Red );
  }
  else
  {
    myBrush = new SolidBrush( Color.Black );
  }

  g.FillEllipse( myBrush, p.X, p.Y, dotWidth, dotWidth );
  myBrush.Dispose();
}

GeneralRe: How to hold dice in yahtzee Pin
Member 83368481-Jun-12 23:18
Member 83368481-Jun-12 23:18 
QuestionEntity Framework Problem Pin
Kevin Marois1-Jun-12 14:31
professionalKevin Marois1-Jun-12 14:31 
AnswerRe: Entity Framework Problem Pin
Unnikrishnan_S_N9-Jul-12 5:26
Unnikrishnan_S_N9-Jul-12 5:26 
RantVariable Names In Various Projects (Not My Own) Pin
Matt U.1-Jun-12 5:12
Matt U.1-Jun-12 5:12 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
Luc Pattyn1-Jun-12 5:57
sitebuilderLuc Pattyn1-Jun-12 5:57 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
PIEBALDconsult1-Jun-12 6:03
mvePIEBALDconsult1-Jun-12 6:03 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
Matt U.1-Jun-12 7:36
Matt U.1-Jun-12 7:36 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
GenJerDan1-Jun-12 10:30
GenJerDan1-Jun-12 10:30 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
Paul Conrad1-Jun-12 13:55
professionalPaul Conrad1-Jun-12 13:55 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
Matt U.2-Jun-12 7:38
Matt U.2-Jun-12 7:38 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
Ravi Bhavnani1-Jun-12 10:12
professionalRavi Bhavnani1-Jun-12 10:12 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
Matt U.2-Jun-12 7:40
Matt U.2-Jun-12 7:40 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
jschell4-Jun-12 8:15
jschell4-Jun-12 8:15 
GeneralRe: Variable Names In Various Projects (Not My Own) Pin
Matt U.14-Jun-12 2:37
Matt U.14-Jun-12 2:37 
QuestionWCF service as Windows Service Pin
TwilightEva1-Jun-12 2:26
TwilightEva1-Jun-12 2:26 
AnswerRe: WCF service as Windows Service Pin
sina rahimzadeh1-Jun-12 3:15
sina rahimzadeh1-Jun-12 3:15 
GeneralRe: WCF service as Windows Service Pin
jschell1-Jun-12 3:38
jschell1-Jun-12 3:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.