コード例 #1
0
        public override void Draw(CGRect rect)
        {
            var context = UIGraphics.GetCurrentContext();

            MessageBarStyleSheet styleSheet = StylesheetProvider;

            context.SaveState();

            styleSheet.BackgroundColorForMessageType(MessageType).SetColor();
            context.FillRect(rect);
            context.RestoreState();
            context.SaveState();

            context.BeginPath();
            context.MoveTo(0, rect.Size.Height);
            context.SetStrokeColor(styleSheet.StrokeColorForMessageType(MessageType).CGColor);
            context.SetLineWidth(1);
            context.AddLineToPoint(rect.Size.Width, rect.Size.Height);
            context.StrokePath();
            context.RestoreState();
            context.SaveState();

            float xOffset = Padding;
            float yOffset = Padding;
            var   icon    = styleSheet.IconImageForMessageType(MessageType);

            if (icon != null)
            {
                icon.Draw(new RectangleF(xOffset, yOffset, IconSize, IconSize));
            }
            context.SaveState();

            yOffset -= TextOffset;
            xOffset += (icon == null ? 0 : IconSize) + Padding;
            CGSize titleLabelSize = TitleSize();

            if (string.IsNullOrEmpty(Title) && !string.IsNullOrEmpty(Description))
            {
                yOffset = (float)(Math.Ceiling((double)rect.Size.Height * 0.5) - Math.Ceiling((double)titleLabelSize.Height * 0.5) - TextOffset);
            }

            TitleColor.SetColor();

            var titleRectangle = new RectangleF(xOffset, yOffset, (float)titleLabelSize.Width + 5, (float)titleLabelSize.Height + 5);

            Title.DrawString(titleRectangle, TitleFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
            yOffset += (float)titleLabelSize.Height;

            CGSize descriptionLabelSize = DescriptionSize();

            DescriptionColor.SetColor();
            var descriptionRectangle = new RectangleF(xOffset, yOffset, (float)descriptionLabelSize.Width + Padding, (float)descriptionLabelSize.Height);

            Description.DrawString(descriptionRectangle, DescriptionFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
        }
コード例 #2
0
        /// <summary>
        /// Shows the message
        /// </summary>
        /// <param name="title">Messagebar title</param>
        /// <param name="description">Messagebar description</param>
        /// <param name="type">Message type</param>
        /// <param name = "onDismiss">OnDismiss callback</param>
        /// <param name="duration"></param>
        /// <param name="styleSheet"></param>
        public void ShowMessage(string title, string description, ToastNotificationType type, Action <bool> onDismiss, TimeSpan duration, MessageBarStyleSheet styleSheet = null)
        {
            var messageView = new MessageView(title, description, type, onDismiss, duration);

            messageView.StylesheetProvider = styleSheet;
            messageView.Hidden             = true;

            MessageWindowView.AddSubview(messageView);
            MessageWindowView.BringSubviewToFront(messageView);

            _messageBarQueue.Enqueue(messageView);

            if (!_messageVisible)
            {
                ShowNextMessage();
            }
        }
コード例 #3
0
 public static void Init(MessageBarStyleSheet customStyle = null)
 {
     _customStyle = customStyle ?? new MessageBarStyleSheet();
 }