Click here to Skip to main content
15,900,724 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to sleep the thread in this example? Pin
daCrazyDude6-Jun-12 15:48
daCrazyDude6-Jun-12 15:48 
Questioncombine edits Pin
dcof2-Jun-12 16:27
dcof2-Jun-12 16:27 
AnswerRe: combine edits Pin
OriginalGriff3-Jun-12 0:27
mveOriginalGriff3-Jun-12 0:27 
GeneralRe: combine edits Pin
dcof3-Jun-12 18:04
dcof3-Jun-12 18:04 
AnswerRe: combine edits Pin
Paul Conrad4-Jun-12 6:38
professionalPaul Conrad4-Jun-12 6:38 
AnswerRe: combine edits Pin
Luc Pattyn3-Jun-12 4:58
sitebuilderLuc Pattyn3-Jun-12 4:58 
Questionbst Pin
negar parham2-Jun-12 7:02
negar parham2-Jun-12 7:02 
AnswerRe: bst Pin
Paul Conrad2-Jun-12 7:07
professionalPaul Conrad2-Jun-12 7:07 
AnswerRe: bst Pin
AmitGajjar4-Jun-12 2:11
professionalAmitGajjar4-Jun-12 2:11 
QuestionC# working with strings Pin
dcof2-Jun-12 6:48
dcof2-Jun-12 6:48 
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 

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.