Exemplo n.º 1
0
        /// <summary>
        /// Prompt for the Amazon Keys
        /// </summary>
        /// <param name="callback">A callback if we got keys</param>
        /// <param name="cancel">A callback if the user didn't provide keys</param>
        public void AskForKeys(TurKit.startTaskDelegate callback, TurKit.noKeysDelegate cancel)
        {
            Amazon amazon       = new Amazon();
            Window amazonWindow = new Window
            {
                Title         = "Amazon Keys",
                Content       = amazon,
                SizeToContent = SizeToContent.WidthAndHeight,
                ResizeMode    = ResizeMode.NoResize
            };

            amazon.okButton.Click += (sender, e) => {
                AmazonKeys keys = new AmazonKeys();
                keys.amazonID  = amazon.accessKey.Text;
                keys.secretKey = amazon.secretKey.Text;

                if (callback != null)
                {
                    callback(keys);
                }
                amazonWindow.Close();
            };

            amazon.cancelButton.Click += (sender, e) =>
            {
                if (cancel != null)
                {
                    cancel();
                }
            };

            amazonWindow.ShowDialog();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads in the AMT secret and key from the amazon.xml file so that HITs can be submitted.
        /// </summary>
        public static void AskForAmazonKeys(TurKit.startTaskDelegate success, TurKit.noKeysDelegate cancel)
        {
            AmazonKeys keys = LoadAmazonKeys();

            if (keys == null)
            {
                Globals.Ribbons.Ribbon.AskForKeys(success, cancel);
            }
            else
            {
                success(keys);
            }
        }