コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (Title.Text)
            {
            case "" when content.Text == "":
                titleContentRequired.Visible = true;
                contentRequired.Visible      = false;
                titleRequired.Visible        = false;
                break;

            case "" when content.Text != "":
                titleRequired.Visible        = true;
                contentRequired.Visible      = false;
                titleContentRequired.Visible = false;
                break;

            default:
                if (Title.Text != "" && content.Text == "")
                {
                    contentRequired.Visible      = true;
                    titleRequired.Visible        = false;
                    titleContentRequired.Visible = false;
                }
                else     //quando os dois estão preenchidos
                {
                    var receiverId = (receivercomboBox1.SelectedItem as ComboboxItem)?.Value.ToString();
                    Debug.WriteLine(receiverId);

                    var senderPerson = Person;
                    var message      = new Message
                    {
                        Sender     = senderPerson,
                        LastUpdate = DateTime.Now.ToString(CultureInfo.CurrentCulture),
                        Title      = Title.Text,
                        Content    = content.Text
                    };                                            //cria msg
                    var recDictionary = message.Save(receiverId); //guarda na db
                    if (recDictionary != null)
                    {
                        var receiver = Person.CheckRole(receiverId); //instancia o receiver
                        receiver.Messages.Add(message);              //Adiciona a msg ao receiver
                    }

                    if (ParentForm != null)
                    {
                        var appForms        = (MadeiraMuseum)ParentForm;
                        var messagesControl = appForms.MessagesControl;
                        messagesControl.ResetView();
                        messagesControl.NotificationLabel.Text = @"Message sent with success!";
                        messagesControl.ShowNotification();
                    }
                }

                break;
            }
        }
コード例 #2
0
 private void msgtext_Click(Message msg)
 {
     //MessageBox.Show(""+msg.Id);
     if (ParentForm != null)
     {
         var appForms             = (MadeiraMuseum)ParentForm;
         var singleMessageControl = appForms.SingleMessageControl;
         singleMessageControl.Location = new Point(185, 0);
         singleMessageControl.Message  = msg;
         singleMessageControl.UpdateText();
         singleMessageControl.BringToFront();
     }
 }