Exemplo n.º 1
0
        /// <summary>
        /// Does a sanity check and then sends the message
        /// </summary>
        private void SendMessage()
        {
            if (null != _mask) // already sending
                return;

            _controlToFocus = null;

            if (string.IsNullOrEmpty(_txtTo.Text))
            {
                Alert.Show("Error", @"No recipients. Please add some...", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtTo;
                return;
            }
                
            if (!CheckRecipients(_txtTo.Text))
            {
                Alert.Show("Error", @"Error with ""To:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtTo;
                return;
            }

            if (_btnCc.Selected && !string.IsNullOrEmpty(_txtCc.Text) && !CheckRecipients(_txtCc.Text))
            {
                Alert.Show("Error", @"Error with ""Cc:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtCc;
                return;
            }

            if (_btnBcc.Selected && !string.IsNullOrEmpty(_txtBcc.Text) && !CheckRecipients(_txtBcc.Text))
            {
                Alert.Show("Error", @"Error with ""Bcc:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtBcc;
                return;
            }

            if (string.IsNullOrEmpty(_txtMessage.Text))
            {
                Alert.Show("Error", @"No message. Please add some text.", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtMessage;
                return;
            }

            if (SendMode == SendMode.SimulateSending) // just simulate sending
            {
                _mask = new LoadingMask(this, "Sending message...");
                _timer.AddEventListener(Timer.COMPLETE, MessageSentHandler); // simulating sent result after 3 seconds
                _timer.Start();
            }
            else // notify the world
            {
                var e = new ExampleEvent(ExampleEvent.SEND_MESSAGE)
                {
                    Bubbles = true, // bubble event
                    To = _txtTo.Text,
                    Cc = _txtCc.Text,
                    Bcc = _txtBcc.Text,
                    Message = _txtMessage.Text
                };
                Debug.Log("Dispatching an event, catch it from outside: " + e);
                DispatchEvent(e);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Does a sanity check and then sends the message
        /// </summary>
        private void SendMessage()
        {
            if (null != _mask) // already sending
            {
                return;
            }

            _controlToFocus = null;

            if (string.IsNullOrEmpty(_txtTo.Text))
            {
                Alert.Show("Error", @"No recipients. Please add some...", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtTo;
                return;
            }

            if (!CheckRecipients(_txtTo.Text))
            {
                Alert.Show("Error", @"Error with ""To:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtTo;
                return;
            }

            if (_btnCc.Selected && !string.IsNullOrEmpty(_txtCc.Text) && !CheckRecipients(_txtCc.Text))
            {
                Alert.Show("Error", @"Error with ""Cc:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtCc;
                return;
            }

            if (_btnBcc.Selected && !string.IsNullOrEmpty(_txtBcc.Text) && !CheckRecipients(_txtBcc.Text))
            {
                Alert.Show("Error", @"Error with ""Bcc:"" recipients. " + HelpMsg, AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtBcc;
                return;
            }

            if (string.IsNullOrEmpty(_txtMessage.Text))
            {
                Alert.Show("Error", @"No message. Please add some text.", AlertButtonFlag.Ok, FocusBack);
                _controlToFocus = _txtMessage;
                return;
            }

            if (SendMode == SendMode.SimulateSending) // just simulate sending
            {
                _mask = new LoadingMask(this, "Sending message...");
                _timer.AddEventListener(Timer.COMPLETE, MessageSentHandler); // simulating sent result after 3 seconds
                _timer.Start();
            }
            else // notify the world
            {
                var e = new ExampleEvent(ExampleEvent.SEND_MESSAGE)
                {
                    Bubbles = true, // bubble event
                    To      = _txtTo.Text,
                    Cc      = _txtCc.Text,
                    Bcc     = _txtBcc.Text,
                    Message = _txtMessage.Text
                };
                Debug.Log("Dispatching an event, catch it from outside: " + e);
                DispatchEvent(e);
            }
        }