Ejemplo n.º 1
0
		MessageBarManager ()
		{
			messageBarQueue = new Queue<MessageView> ();
			MessageVisible = false;
			MessageBarOffset = 20;
			styleSheet = new MessageBarStyleSheet ();
		}
Ejemplo n.º 2
0
 MessageBarManager()
 {
     messageBarQueue  = new Queue <MessageView> ();
     MessageVisible   = false;
     MessageBarOffset = 20;
     styleSheet       = new MessageBarStyleSheet();
 }
 /// <summary>
 ///     Prevents a default instance of the <see cref="MessageBarManager" /> class from being created.
 /// </summary>
 /// <remarks>
 ///     <para>An init message is coupled with an alloc (or allocWithZone:) message in the same line of code:</para>
 ///     <para>
 ///         An object isn’t ready to be used until it has been initialized. The init method defined in the NSObject class
 ///         does no initialization; it simply returns self.
 ///     </para>
 ///     <para>
 ///         In a custom implementation of this method, you must invoke super’s designated initializer then initialize and
 ///         return the new object. If the new object can’t be initialized, the method should return nil. For example, a
 ///         hypothetical BuiltInCamera class might return nil from its init method if run on a device that has no camera.
 ///     </para>
 ///     <para>
 ///         In some cases, an init method might return a substitute object. You must therefore always use the object
 ///         returned by init, and not the one returned by alloc or allocWithZone:, in subsequent code.
 ///     </para>
 /// </remarks>
 private MessageBarManager()
 {
     this.messageBarQueue  = new Queue <MessageView>();
     this.MessageVisible   = false;
     this.MessageBarOffset = 20;
     this.styleSheet       = new MessageBarStyleSheet();
 }
 MessageBarManager()
 {
     messageBarQueue  = new Queue <MessageView> ();
     MessageVisible   = false;
     MessageBarOffset = UIApplication.SharedApplication.StatusBarFrame.Size.Height;
     styleSheet       = new MessageBarStyleSheet();
 }
        public override void Draw(RectangleF rect)
        {
            var context = UIGraphics.GetCurrentContext();

            MessageBarStyleSheet styleSheet = StylesheetProvider.StyleSheetForMessageView(this);

            context.SaveState();

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

            context.BeginPath();
            context.MoveTo(0, rect.Size.Height);
            context.SetStrokeColorWithColor(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;

            if (!ShowFromBottom)
            {
                yOffset += GetStatusBarFrame().Height;
            }

            styleSheet.IconImageForMessageType(MessageType).Draw(new RectangleF(xOffset, yOffset, IconSize, IconSize));
            context.SaveState();

            yOffset -= TextOffset;
            xOffset += IconSize + Padding;
            SizeF 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, titleLabelSize.Width, titleLabelSize.Height);

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

            SizeF descriptionLabelSize = DescriptionSize();

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

            Description.DrawString(descriptionRectangle, DescriptionFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
        }
Ejemplo n.º 6
0
		public static void Init()
		{
			_styleSheet = new MessageBarStyleSheet();
		}
Ejemplo n.º 7
0
        public override void Draw(CGRect rect)
        {
            var context = UIGraphics.GetCurrentContext();

            MessageBarStyleSheet styleSheet = StylesheetProvider.StyleSheetForMessageView(this);

            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();


            nfloat xOffset = Padding;
            nfloat yOffset = Padding;

            var icon = styleSheet.IconImageForMessageType(MessageType);

            if (icon != null)
            {
                icon.Draw(new CGRect(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 CGRect(xOffset, yOffset, titleLabelSize.Width, titleLabelSize.Height);

            Title.DrawString(titleRectangle, new UIStringAttributes {
                Font = TitleFont, ForegroundColor = TitleColor
            });
            yOffset += titleLabelSize.Height;

            CGSize descriptionLabelSize = DescriptionSize();

            DescriptionColor.SetColor();
            var descriptionRectangle = new CGRect(xOffset, yOffset, descriptionLabelSize.Width, descriptionLabelSize.Height);

            Description.DrawString(descriptionRectangle, new UIStringAttributes {
                Font = DescriptionFont, ForegroundColor = DescriptionColor
            });
        }
        /// <summary>
        /// Draws the view within the passed-in rectangle.
        /// </summary>
        /// <param name="rect">
        /// The <see cref="T:System.Drawing.RectangleF"/> to draw.
        /// </param>
        public override void Draw(CGRect rect)
        {
            var context = UIGraphics.GetCurrentContext();

            MessageBarStyleSheet styleSheet = this.StylesheetProvider.StyleSheetForMessageView(this);

            context.SaveState();

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

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

            nfloat xOffset = Padding;
            nfloat yOffset = Padding;

            styleSheet.IconImageForMessageType(this.MessageType)
            .Draw(new CGRect(xOffset, yOffset, this.iconSize, this.iconSize));
            context.SaveState();

            yOffset -= TextOffset;
            xOffset += this.iconSize + Padding;

            CGSize titleLabelSize       = this.TitleSize();
            CGSize descriptionLabelSize = this.DescriptionSize();

            if (!this.HasTitle || !this.HasDescription)
            {
                yOffset = (float)(Math.Ceiling(rect.Size.Height * 0.5) - Math.Ceiling(
                                      (this.HasTitle ? titleLabelSize : descriptionLabelSize).Height * 0.5) - TextOffset);
            }

            if (this.HasTitle)
            {
                TitleColor.SetColor();
                var titleRectangle = new CGRect(xOffset, yOffset, titleLabelSize.Width, titleLabelSize.Height);
                this.Title.DrawString(titleRectangle, TitleFont, UILineBreakMode.TailTruncation, UITextAlignment.Left);
                yOffset += titleLabelSize.Height;
            }

            if (this.HasDescription)
            {
                DescriptionColor.SetColor();
                var descriptionRectangle = new CGRect(
                    xOffset,
                    yOffset,
                    descriptionLabelSize.Width,
                    descriptionLabelSize.Height);
                this.Description.DrawString(
                    descriptionRectangle,
                    DescriptionFont,
                    UILineBreakMode.TailTruncation,
                    UITextAlignment.Left);
            }
        }
 /// <summary>
 ///     Prevents a default instance of the <see cref="MessageBarManager" /> class from being created.
 /// </summary>
 /// <remarks>
 ///     <para>An init message is coupled with an alloc (or allocWithZone:) message in the same line of code:</para>
 ///     <para>
 ///         An object isn’t ready to be used until it has been initialized. The init method defined in the NSObject class
 ///         does no initialization; it simply returns self.
 ///     </para>
 ///     <para>
 ///         In a custom implementation of this method, you must invoke super’s designated initializer then initialize and
 ///         return the new object. If the new object can’t be initialized, the method should return nil. For example, a
 ///         hypothetical BuiltInCamera class might return nil from its init method if run on a device that has no camera.
 ///     </para>
 ///     <para>
 ///         In some cases, an init method might return a substitute object. You must therefore always use the object
 ///         returned by init, and not the one returned by alloc or allocWithZone:, in subsequent code.
 ///     </para>
 /// </remarks>
 private MessageBarManager()
 {
     this.messageBarQueue = new Queue<MessageView>();
     this.MessageVisible = false;
     this.MessageBarOffset = 20;
     this.styleSheet = new MessageBarStyleSheet();
 }