Exemplo n.º 1
0
        /// <summary>
        /// Create list item with specific conditions.
        /// </summary>
        public EmailListItem(EmailList parent, Email s, Color bgColor)
        {
            // Set height
            MinHeight = EmailList.ROW_HEIGHT;
            HeightRequest = EmailList.ROW_HEIGHT;

            // Set background color
            BackgroundColor = DefaultColor = bgColor;

            // Self expand horizontal and vertical
            ExpandHorizontal = true;
            ExpandVertical = true;

            // No margin at all
            Margin = 0;

            // Set parent & active email
            ListParent = parent;
            ActiveEmail = s;
            EmailText = new TextEntry()
            {
                Text = s.UserEmail,
                MarginLeft = 5,
                HorizontalPlacement = WidgetPlacement.Fill,
                VerticalPlacement = WidgetPlacement.Center,
                MarginTop = 1,
                ExpandHorizontal = true,
                ExpandVertical = false
            };
            EmailText.Changed += delegate
            {
                s.UserEmail = EmailText.Text;
                if (Email.IsValid(EmailText.Text))
                {
                    BackgroundColor = DefaultColor;
                }
                else
                {
                    BackgroundColor = Colors.Red;
                    EmailText.SetFocus();
                }
            };
            PackStart(EmailText, true, true);

            // Error
            Errors = new CheckBox()
            {
                State = (s.Errors) ? CheckBoxState.On : CheckBoxState.Off,
                WidthRequest = EmailList.ERROR_WIDTH,
                MinWidth = EmailList.ERROR_WIDTH,
                HorizontalPlacement = WidgetPlacement.Center,
                VerticalPlacement = WidgetPlacement.Center,
                MarginLeft = 25
            };
            Errors.Toggled += delegate { s.Errors = Errors.State == CheckBoxState.On; };
            PackStart(Errors);

            // Notification
            Notification = new CheckBox()
            {
                State = (s.Notifications) ? CheckBoxState.On : CheckBoxState.Off,
                WidthRequest = EmailList.ERROR_WIDTH,
                MinWidth = EmailList.ERROR_WIDTH,
                HorizontalPlacement = WidgetPlacement.Center,
                VerticalPlacement = WidgetPlacement.Center
            };
            Notification.Toggled += delegate { s.Notifications = Notification.State == CheckBoxState.On; };
            PackStart(Notification);

            // Button
            RemoveEmail = new Button(Image.FromResource(DirectorImages.CROSS_ICON))
            {
                HorizontalPlacement = WidgetPlacement.Center,
                VerticalPlacement = WidgetPlacement.Center,
                MarginRight = 20
            };
            RemoveEmail.Clicked += delegate { parent.RemoveEmail(ActiveEmail); };
            PackStart(RemoveEmail);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Remove active email.
 /// </summary>
 public void RemoveEmail(Email email)
 {
     ActiveServer.Emails.Remove(email);
     SetServer(ActiveServer);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Add new email to email list in server & create email list box.
 /// </summary>
 private void NewEmail_Clicked(object sender, EventArgs e)
 {
     var _new = new Email();
     ActiveServer.Emails.Add(_new);
     int size = ActiveServer.Emails.Count + 1;
     var tmp = new EmailListItem(this, _new, (size%2 == 0) ? Colors.White : Colors.LightGray)
     {
         BackgroundColor = Colors.Red
     };
     EmailItems.Add(tmp);
     EmailListContent.PackStart(tmp);
 }