public static void AddEventHandler(string key, Context.TriggerEvent _event)
 {
     if (eventMap.ContainsKey(key))
     {
         eventMap[key].Enqueue(_event);
     }
     else
     {
         eventMap[key] = new Queue<Context.TriggerEvent>();
         eventMap[key].Enqueue(_event);
     }
 }
示例#2
0
        protected async void ShowMessageDialog(string message, int mode, Context.TriggerEvent triggerEvent = null)
        {
            // Create the message dialog and set its content
            MessageDialog messageDialog = new MessageDialog(message);

            switch (mode)
            { 
                case OK_MODE:
                    // Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
                    messageDialog.Commands.Add(new UICommand(
                        AppResources.OK,
                        new UICommandInvokedHandler((command) => { })));

                    // Set the command to be invoked when escape is pressed
                    messageDialog.CancelCommandIndex = 0;
                    break;

                case OK_CANCEL_MODE:
                    // Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
                    messageDialog.Commands.Add(new UICommand(
                        AppResources.OK,
                        new UICommandInvokedHandler((command) => triggerEvent())));

                    messageDialog.Commands.Add(new UICommand(
                        AppResources.Cancel,
                        new UICommandInvokedHandler((command) => { })));

                    // Set the command to be invoked when escape is pressed
                    messageDialog.CancelCommandIndex = 1;
                    break;
            }

            // Set the command that will be invoked by default
            messageDialog.DefaultCommandIndex = 0;

            // Show the message dialog
            await messageDialog.ShowAsync();
        }
 public static Context GetContext(string currentPage)
 {
     if (Map.ContainsKey(currentPage))
         return Map[currentPage];
     Context con = new Context();
     Map.Add(currentPage, con);
     return con;
 }