コード例 #1
0
		/// <summary>
		/// Invokes the specified button handler.
		/// </summary>
		private void InvokeHandler(MessagePopupButtonHandler handler, object state)
		{
			if (handler != null)
			{
				try
				{
					handler(this, state);
				}
				catch (Exception) { }
			}
		}
コード例 #2
0
		/// <summary>
		/// Called when a button of the message popup is clicked.
		/// </summary>
		private void OnButtonClicked(MessagePopupButtonHandler handler, object state)
		{
			InvokeHandler(handler, state);
			Close();
		}
コード例 #3
0
		public void AddCancelHandler(MessagePopupButtonHandler handler)
		{
			_cancelHandler = handler;
		}
コード例 #4
0
		/// <summary>
		/// Adds a cancel button to the message popup.
		/// </summary>
		/// <remarks>
		/// A <see cref="MessagePopup"/> instance can have at most one cancel button.
		/// If one is present, its handler will be called when the user presses the Back key on the device
		/// while the message popup is open.
		/// If there is no cancel button, the message popup does not intercept Back key presses.
		/// </remarks>
		/// <param name="label">The label of the button.</param>
		/// <param name="handler">The delegate method that will be called when the button is clicked
		/// or when the user presses the Back key.</param>
		/// <param name="state">The state object sent to <paramref name="handler"/> when the button is clicked
		/// or when the user presses the Back key.</param>
		/// <exception cref="InvalidOperationException">If the message popup already has a cancel button.</exception>
		public void AddCancelButton(string label, MessagePopupButtonHandler handler, object state)
		{
			if (_hasCancelButton)
			{
				throw new InvalidOperationException();
			}
			_hasCancelButton = true;
			_cancelHandler = handler;
			_cancelState = state;
			AddButton(label, handler, state);
		}
コード例 #5
0
		/// <summary>
		/// Adds a button to the message popup.
		/// </summary>
		/// <param name="label">The label of the button.</param>
		/// <param name="handler">The delegate method that will be called when the button is clicked (null allowed).</param>
		/// <param name="state">The state object sent to <paramref name="handler"/> when the button is clicked.</param>
		public void AddButton(string label, MessagePopupButtonHandler handler, object state)
		{
			int row = (_content.ButtonsGrid.Children.Count / 2);
			int column = (_content.ButtonsGrid.Children.Count % 2);
			while (_content.ButtonsGrid.RowDefinitions.Count <= row)
			{
				_content.ButtonsGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
			}

			Button button = new Button();
			button.Content = label;
			button.Style = Application.Current.Resources["WSDOTButtonStyle"] as Style;
			button.Click += (sender, e) => OnButtonClicked(handler, state);
			Grid.SetRow(button, row);
			Grid.SetColumn(button, column);
			_content.ButtonsGrid.Children.Add(button);
		}
コード例 #6
0
        /// <summary>
        /// Adds a button to the message popup.
        /// </summary>
        /// <param name="label">The label of the button.</param>
        /// <param name="handler">The delegate method that will be called when the button is clicked (null allowed).</param>
        /// <param name="state">The state object sent to <paramref name="handler"/> when the button is clicked.</param>
        public void AddButton(string label, MessagePopupButtonHandler handler, object state)
        {
            int row = (_content.ButtonsGrid.Children.Count / 2);
            int column = (_content.ButtonsGrid.Children.Count % 2);
            while (_content.ButtonsGrid.RowDefinitions.Count <= row)
            {
                _content.ButtonsGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
            }

            Button button = new Button();
            button.Content = label;
            button.FontSize = _content.MessageTextBlock.FontSize;
            button.Click += (sender, e) => OnButtonClicked(handler, state);
            Grid.SetRow(button, row);
            Grid.SetColumn(button, column);
            _content.ButtonsGrid.Children.Add(button);
        }