Click here to Skip to main content
15,905,877 members
Home / Discussions / C#
   

C#

 
QuestionRe: Encrypt - Decrypt Pin
Midnight Ahri12-Jul-12 0:51
Midnight Ahri12-Jul-12 0:51 
AnswerRe: Encrypt - Decrypt Pin
Eddy Vluggen12-Jul-12 2:24
professionalEddy Vluggen12-Jul-12 2:24 
AnswerRe: Encrypt - Decrypt Pin
Midnight Ahri12-Jul-12 15:28
Midnight Ahri12-Jul-12 15:28 
GeneralRe: Encrypt - Decrypt Pin
BobJanova12-Jul-12 23:39
BobJanova12-Jul-12 23:39 
Questionhow to use use transparent proxy(local host) in middle of browser and destination server?? Pin
modipavan12-Jul-12 0:03
modipavan12-Jul-12 0:03 
AnswerRe: how to use use transparent proxy(local host) in middle of browser and destination server?? Pin
Eddy Vluggen12-Jul-12 0:40
professionalEddy Vluggen12-Jul-12 0:40 
QuestionCookie based authentication - calling a get cookie script - cookiecollection empty Pin
psycik11-Jul-12 23:20
psycik11-Jul-12 23:20 
AnswerRe: Cookie based authentication - calling a get cookie script - cookiecollection empty Pin
BobJanova11-Jul-12 23:45
BobJanova11-Jul-12 23:45 
GeneralRe: Cookie based authentication - calling a get cookie script - cookiecollection empty Pin
psycik11-Jul-12 23:51
psycik11-Jul-12 23:51 
GeneralRe: Cookie based authentication - calling a get cookie script - cookiecollection empty Pin
BobJanova13-Jul-12 4:14
BobJanova13-Jul-12 4:14 
QuestionQuery on Delegate Pin
ashish711-Jul-12 21:23
ashish711-Jul-12 21:23 
AnswerRe: Query on Delegate Pin
OriginalGriff11-Jul-12 21:37
mveOriginalGriff11-Jul-12 21:37 
GeneralRe: Query on Delegate Pin
Simon_Whale11-Jul-12 22:27
Simon_Whale11-Jul-12 22:27 
GeneralRe: Query on Delegate Pin
ashish711-Jul-12 22:29
ashish711-Jul-12 22:29 
GeneralRe: Query on Delegate Pin
DaveyM6911-Jul-12 22:48
professionalDaveyM6911-Jul-12 22:48 
GeneralRe: Query on Delegate Pin
OriginalGriff11-Jul-12 22:55
mveOriginalGriff11-Jul-12 22:55 
GeneralRe: Query on Delegate Pin
ashish711-Jul-12 23:13
ashish711-Jul-12 23:13 
GeneralRe: Query on Delegate Pin
Pete O'Hanlon11-Jul-12 23:23
mvePete O'Hanlon11-Jul-12 23:23 
GeneralRe: Query on Delegate Pin
BobJanova11-Jul-12 23:41
BobJanova11-Jul-12 23:41 
GeneralRe: Query on Delegate Pin
Pete O'Hanlon11-Jul-12 22:50
mvePete O'Hanlon11-Jul-12 22:50 
GeneralRe: Query on Delegate Pin
OriginalGriff11-Jul-12 22:56
mveOriginalGriff11-Jul-12 22:56 
GeneralRe: Query on Delegate Pin
DaveyM6911-Jul-12 22:57
professionalDaveyM6911-Jul-12 22:57 
GeneralRe: Query on Delegate Pin
Wayne Gaylard11-Jul-12 23:02
professionalWayne Gaylard11-Jul-12 23:02 
GeneralRe: Query on Delegate Pin
ashish712-Jul-12 2:15
ashish712-Jul-12 2:15 
I have gone through all the replies but I am not able to convert the code in the simple understandable format.

I am pasting the the two .cs file below, if someone can help putting it in the simple fashion for all the 3 eventhandler delegates.

1) PuzzleGame.cs

C#
using Mosaic;

namespace WindowsPhonePuzzle
{
    public class PieceUpdatedEventArgs : EventArgs
    {
        public int PieceId { get; set; }
        public Point NewPosition { get; set; }
    }

    public class GameOverEventArgs : EventArgs
    {
        public int TotalMoves { get; set; }
    }

    public class PuzzleGame
    {        
                
        public EventHandler GameStarted;        
        public EventHandler<PieceUpdatedEventArgs> PieceUpdated;
        public EventHandler<GameOverEventArgs> GameOver;

        ////// More code below

                 if (this.GameStarted != null)
            {
                this.GameStarted(this, null);
            }
        }


        ////// More code below

                if (this.GameOver != null)
                {
                    this.GameOver(this, new GameOverEventArgs { TotalMoves = this.totalMoves });
                }
            }
        }

        ////// More code below


            if (this.PieceUpdated != null)
            {
                this.PieceUpdated(this, new PieceUpdatedEventArgs {PieceId = pieceId, NewPosition = newPosition});
            }
        }
    }
}



2) PuzzlePage.xaml.cs
<pre lang="c#">
using WindowsPhonePuzzle;

 

namespace Mosaic
{
    public partial class PuzzlePage  : PhoneApplicationPage
    {

      
        public PuzzlePage()
        {
            InitializeComponent();
            SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;

            // Puzzle Game
            this.game = new PuzzleGame(3);


            this.game.GameStarted += delegate
            {
                this.ResetWinTransition.Begin();
                this.StatusPanel.Visibility = Visibility.Visible;
                this.TapToContinueTextBlock.Opacity = 0;
                this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString();
            };       

            this.game.GameOver += delegate
            {
                this.WinTransition.Begin();
                this.TapToContinueTextBlock.Opacity = 1;
                this.StatusPanel.Visibility = Visibility.Visible;
                this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString();
            };

            this.game.PieceUpdated +=  delegate(object sender, PieceUpdatedEventArgs args)
            {
                int pieceSize = ImageSize / this.game.ColsAndRows;
                this.AnimatePiece(this.puzzlePieces[args.PieceId], Canvas.LeftProperty, (int)args.NewPosition.X * pieceSize);
                this.AnimatePiece(this.puzzlePieces[args.PieceId], Canvas.TopProperty, (int)args.NewPosition.Y * pieceSize);
                this.TotalMovesTextBlock.Text = this.game.TotalMoves.ToString();
            };

            this.InitBoard();
        }


modified 12-Jul-12 8:40am.

GeneralRe: Query on Delegate Pin
OriginalGriff12-Jul-12 2:23
mveOriginalGriff12-Jul-12 2:23 

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.