Beispiel #1
0
        private void listBox_DrawItem(object sender, Tenor.Mobile.UI.DrawItemEventArgs e)
        {
            Badge badge = (Badge)e.Item.Value;

            Size factor = Tenor.Mobile.UI.Skin.Current.ScaleFactor;

            if (!string.IsNullOrEmpty(badge.Name))
            {
                int padding   = 5 * factor.Width;
                int imageSize = listBox.DefaultItemHeight - padding;

                RectangleF rect = new RectangleF
                                      (e.Bounds.X + imageSize + (padding * 2),
                                      e.Bounds.Y,
                                      e.Bounds.Width - (imageSize) - (padding * 2),
                                      e.Bounds.Height);


                if (imageList != null && imageList.ContainsKey(badge.ImageUrl.ToString()))
                {
                    if (!imageListA.ContainsKey(badge.ImageUrl.ToString()))
                    {
                        imageListA.Add(badge.ImageUrl.ToString(), new AlphaImage(new Bitmap(new MemoryStream(imageList[badge.ImageUrl.ToString()]))));
                        imageList[badge.ImageUrl.ToString()] = null;
                    }
                    AlphaImage image = imageListA[badge.ImageUrl.ToString()];

                    Rectangle imgRect =
                        new Rectangle(0 + Convert.ToInt32(padding),
                                      Convert.ToInt32(rect.Y + (rect.Height / 2) - (imageSize / 2)), imageSize, imageSize);
                    try
                    {
                        image.Draw(e.Graphics, imgRect);
                    }
                    catch (Exception ex) { Log.RegisterLog(ex); }
                }

                rect.Y += 2 * factor.Height;
                SizeF size = e.Graphics.MeasureString(badge.Name, fontBold);
                e.Graphics.DrawString(
                    badge.Name, fontBold, brush, rect);

                string text = badge.Description ?? badge.Hint;

                rect.Y += size.Height + (3 * factor.Height);
                e.Graphics.DrawString(
                    text, font, brush, rect, format);



                Rectangle rect2 = new Rectangle(
                    e.Bounds.X, e.Bounds.Bottom - 2, e.Bounds.Width / 3, 1);
                Tenor.Mobile.Drawing.GradientFill.Fill(e.Graphics, rect2, this.BackColor, Color.Gray, Tenor.Mobile.Drawing.GradientFill.FillDirection.LeftToRight);
                rect2.X += rect2.Width;
                Tenor.Mobile.Drawing.GradientFill.Fill(e.Graphics, rect2, Color.Gray, Color.Gray, Tenor.Mobile.Drawing.GradientFill.FillDirection.LeftToRight);
                rect2.X += rect2.Width;
                Tenor.Mobile.Drawing.GradientFill.Fill(e.Graphics, rect2, Color.Gray, this.BackColor, Tenor.Mobile.Drawing.GradientFill.FillDirection.LeftToRight);
            }
        }
Beispiel #2
0
        private void picMap_Paint(object sender, PaintEventArgs e)
        {
            if (picMap.Tag != null && picMap.Tag is byte[])
            {
                try
                {
                    picMap.Tag = new AlphaImage(Main.CreateRoundedAvatar((byte[])picMap.Tag, picMap.Size, factor));
                }
                catch
                {
                    GC.Collect();
                }
            }

            Rectangle picMapRect = new Rectangle(0, 0, picMap.Width, picMap.Height);

            if (picMap.Tag != null && picMap.Tag is AlphaImage)
            {
                string text = string.Format("{0}\r\n{1}", fixType, helpText);
                try
                {
                    ((AlphaImage)picMap.Tag).Draw(e.Graphics,
                                                  picMapRect);

                    e.Graphics.DrawString(
                        text,
                        font, brush1, 4 * factor.Width, 4 * factor.Height);

                    e.Graphics.DrawString(
                        text,
                        font, brush2, 3 * factor.Width, 3 * factor.Height);

                    if (!selectedPoint.IsEmpty)
                    {
                        Pen p    = new Pen(Color.Black);
                        int size = Convert.ToInt32(10 * factor.Width);
                        if (pin == null)
                        {
                            pin = new AlphaImage(Resources.Pin);
                        }
                        Rectangle rect = new Rectangle(selectedPoint.X - Convert.ToInt32(2 * factor.Width), selectedPoint.Y - size, size, size);
                        pin.Draw(e.Graphics, rect);
                    }
                }
                catch (Exception ex) { MySquare.Service.Log.RegisterLog("gdi", ex); }
            }
            else if (!ellipse.IsEmpty)
            {
                TextureBrush brush = new TextureBrush(Resources.MapBg);
                Tenor.Mobile.Drawing.RoundedRectangle.Fill(e.Graphics, new Pen(Color.Gray), brush, picMapRect, ellipse);
            }
        }
Beispiel #3
0
 private void picAvatar_Paint(object sender, PaintEventArgs e)
 {
     try
     {
         if (img == null)
         {
             img = new AlphaImage(Resources.Shout);
         }
         img.Draw(e.Graphics, new Rectangle(0, 0, picAvatar.Width, picAvatar.Height));
     }
     catch (Exception ex)
     {
         Log.RegisterLog("gdi", ex);
     }
 }
Beispiel #4
0
 private void picAvatar_Paint(object sender, PaintEventArgs e)
 {
     try
     {
         if (avatar != null)
         {
             AlphaImage alpha = new AlphaImage(avatar);
             alpha.Draw(e.Graphics,
                        new Rectangle(
                            0,
                            0,
                            picAvatar.Width,
                            picAvatar.Height), Tenor.Mobile.UI.Skin.Current.SelectedBackColor);
         }
     }
     catch (Exception ex) { Log.RegisterLog("gdi", ex); }
 }
Beispiel #5
0
        private void UserInfo_Paint(object sender, PaintEventArgs e)
        {
            if (imgEmail == null)
            {
                imgEmail = new AlphaImage(Resources.Email);
            }
            if (imgFacebook == null)
            {
                imgFacebook = new AlphaImage(Resources.Facebook);
            }
            if (imgTwitter == null)
            {
                imgTwitter = new AlphaImage(Resources.Twitter);
            }
            if (imgFoursquare == null)
            {
                imgFoursquare = new AlphaImage(Resources.Foursquare);
            }

            int padd = (3 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Width);

            imgFoursquare.Draw(e.Graphics,
                               new Rectangle(
                                   lnkFoursquare.Left - lnkFoursquare.Height,
                                   lnkFoursquare.Top,
                                   lnkFoursquare.Height - padd, lnkFoursquare.Height - padd));
            imgEmail.Draw(e.Graphics,
                          new Rectangle(
                              lblEmail.Left - lblEmail.Height,
                              lblEmail.Top,
                              lblEmail.Height - padd, lblEmail.Height - padd));
            imgFacebook.Draw(e.Graphics,
                             new Rectangle(
                                 lblFacebook.Left - lblFacebook.Height,
                                 lblFacebook.Top,
                                 lblFacebook.Height - padd, lblFacebook.Height - padd));
            imgTwitter.Draw(e.Graphics,
                            new Rectangle(
                                lblTwitter.Left - lblTwitter.Height,
                                lblTwitter.Top,
                                lblTwitter.Height - padd, lblTwitter.Height - padd));
        }
Beispiel #6
0
        private void Img_Paint(object sender, PaintEventArgs e)
        {
            Control control = ((Control)sender);

            if (control.Tag != null)
            {
                try
                {
                    if (control.Tag is byte[])
                    {
                        control.Tag = new AlphaImage
                                          (Main.CreateRoundedAvatar((byte[])control.Tag, control.Width, factor));
                    }

                    AlphaImage image = (AlphaImage)control.Tag;
                    Rectangle  rect  = new Rectangle(0, 0, control.Width, control.Height);
                    image.Draw(e.Graphics, rect);
                }
                catch { control.Tag = null; }
            }
        }
Beispiel #7
0
 private void picMap_Paint(object sender, PaintEventArgs e)
 {
     if (picMap.Tag != null && picMap.Tag is byte[])
     {
         try
         {
             picMap.Tag = new AlphaImage(Main.CreateRoundedAvatar((byte[])picMap.Tag, picMap.Size, factor));
         }
         catch (Exception ex)
         {
             Log.RegisterLog("gdi", ex);
             GC.Collect();
         }
     }
     if (picMap.Tag != null && picMap.Tag is AlphaImage)
     {
         AlphaImage image      = (AlphaImage)picMap.Tag;
         Rectangle  picMapRect = new Rectangle(0, 0, image.Width, image.Height);
         try
         {
             image.Draw(e.Graphics, picMapRect);
         }
         catch (Exception ex) { Log.RegisterLog("gdi", ex); picMap.Tag = null; }
     }
     else if (!ellipse.IsEmpty)
     {
         try
         {
             Rectangle    picMapRect = new Rectangle(0, 0, picMap.Width, picMap.Height);
             TextureBrush brush      = new TextureBrush(Resources.MapBg);
             Tenor.Mobile.Drawing.RoundedRectangle.Fill(e.Graphics, new Pen(Color.Gray), brush, picMapRect, ellipse);
         }
         catch
         {
         }
     }
 }
Beispiel #8
0
        private void listBox_DrawItem(object sender, Tenor.Mobile.UI.DrawItemEventArgs e)
        {
            object obj = e.Item.Value;

            Venue venue = e.Item.Value as Venue;
            Tip   tip   = e.Item.Value as Tip;

            if (tip != null)
            {
                venue = tip.Venue;
            }


            Brush textBrush = (e.Item.Selected ? brushS : brush);

            if (obj == null)
            {
                if (smallFont == null)
                {
                    smallFont = new Font(this.Font.Name, this.Font.Size - 1, this.Font.Style);
                }

                Font  thisFont;
                float thisLeft;


                if (e.Item.YIndex < listBox.Count - 1)
                {
                    thisLeft = itemPadding;
                    thisFont = smallFont;
                }
                else
                {
                    thisLeft = e.Bounds.Height;
                    thisFont = Font;
                }

                string text = e.Item.Text;
                if (text.EndsWith("Nearby") && Address != null)
                {
                    StringBuilder geo = new StringBuilder();
                    if (!string.IsNullOrEmpty(Address.Neighborhood))
                    {
                        geo.Append(", ");
                        geo.Append(Address.Neighborhood);
                    }
                    if (!string.IsNullOrEmpty(Address.City))
                    {
                        geo.Append(", ");
                        geo.Append(Address.City);
                    }
                    if (string.IsNullOrEmpty(Address.Neighborhood) && string.IsNullOrEmpty(Address.City))
                    {
                        if (!string.IsNullOrEmpty(Address.Province))
                        {
                            geo.Append(", ");
                            geo.Append(Address.Province);
                        }
                        if (!string.IsNullOrEmpty(Address.Country))
                        {
                            geo.Append(", ");
                            geo.Append(Address.Country);
                        }
                    }

                    if (geo.Length > 0)
                    {
                        geo   = geo.Remove(0, 2);
                        text += " " + geo.ToString();
                    }
                }


                string secondText = null;

                if (text.IndexOf("\r\n") > -1)
                {
                    string[] textS = text.Split('\r', '\n');
                    text       = textS[0];
                    secondText = textS[2];
                }

                SizeF      measuring = e.Graphics.MeasureString(text, thisFont);
                RectangleF rect      = new RectangleF(thisLeft, e.Bounds.Y + itemPadding, measuring.Width, measuring.Height);

                Color color = Tenor.Mobile.UI.Skin.Current.ControlBackColor;
                if (e.Item.YIndex % 2 == 0)
                {
                    color = Tenor.Mobile.UI.Skin.Current.AlternateBackColor;
                }
                if (e.Item.YIndex < listBox.Count - 1)
                {
                    e.Graphics.FillRectangle(new SolidBrush(color), e.Bounds);
                }
                if (e.Item.YIndex > 0)
                {
                    e.Graphics.DrawSeparator(e.Bounds, color);
                }

                e.Graphics.DrawString(text, thisFont, textBrush, rect, format);
                if (secondText != null)
                {
                    if (secondFont == null)
                    {
                        secondFont = new Font(Font.Name, Font.Size - 1, Font.Style);
                    }
                    measuring = e.Graphics.MeasureString(secondText, secondFont);
                    rect      = new RectangleF(rect.X, rect.Bottom + itemPadding, measuring.Width, measuring.Height);
                    e.Graphics.DrawString(secondText, secondFont, secondBrush, rect, format);
                }
            }
            else
            {
                string title = null;
                if (tip != null)
                {
                    title = tip.User.ToString() + " @ " + venue.Name;
                }
                else
                {
                    title = venue.Name;
                }

                SizeF measuring = e.Graphics.MeasureString(title, Font);

                RectangleF rect = new RectangleF(listBox.DefaultItemHeight, e.Bounds.Y + itemPadding, measuring.Width, measuring.Height);
                if (tip != null)
                {
                    rect.X = e.Bounds.X + itemPadding;
                }
                e.Graphics.DrawString(title, this.Font, textBrush, rect, format);

                string secondText = null;
                if (tip != null && !string.IsNullOrEmpty(tip.Text))
                {
                    secondText = tip.Text;
                }
                else if (venue.Location != null)
                {
                    if (!string.IsNullOrEmpty(venue.Location.Address))
                    {
                        secondText = venue.Location.Address;
                    }
                    else if (!string.IsNullOrEmpty(venue.Location.City))
                    {
                        secondText = venue.Location.City;
                    }
                    else if (!string.IsNullOrEmpty(venue.Location.State))
                    {
                        secondText = venue.Location.State;
                    }
                }
                if (secondText != null)
                {
                    if (secondFont == null)
                    {
                        secondFont = new Font(Font.Name, Font.Size - 1, Font.Style);
                    }
                    measuring = e.Graphics.MeasureString(secondText, secondFont);
                    rect      = new RectangleF(rect.X, rect.Bottom + itemPadding, e.Bounds.Width - rect.X, e.Bounds.Height);
                    e.Graphics.DrawString(secondText, secondFont, secondBrush, rect, formatWrap);
                }
                if (
                    (
                        (venue.PrimaryCategory == null && imageList.ContainsKey(string.Empty)) ||
                        (venue.PrimaryCategory != null && imageList.ContainsKey(venue.PrimaryCategory.IconUrl.ToString()))
                    ) &&
                    tip == null
                    )
                {
                    string iconUrl = string.Empty;
                    if (venue.PrimaryCategory != null)
                    {
                        iconUrl = venue.PrimaryCategory.IconUrl.ToString();
                    }

                    int imageSize = listBox.DefaultItemHeight - Convert.ToInt32(itemPadding * 2);

                    if (!imageListBuffer.ContainsKey(iconUrl))
                    {
                        imageListBuffer.Add(iconUrl, new AlphaImage(Main.CreateRoundedAvatar(imageList[iconUrl], imageSize, factor)));
                    }
                    AlphaImage alpha = imageListBuffer[iconUrl];
                    try
                    {
                        alpha.Draw(e.Graphics,
                                   new Rectangle(
                                       e.Bounds.X + Convert.ToInt32(itemPadding),
                                       e.Bounds.Y + Convert.ToInt32(itemPadding),
                                       imageSize,
                                       imageSize), Tenor.Mobile.UI.Skin.Current.SelectedBackColor);
                    }
                    catch (Exception ex)
                    {
                        imageListBuffer.Remove(iconUrl);
                        Log.RegisterLog("gdi", ex);
                    }
                }

                if (venue.Specials != null)
                {
                    foreach (Special special in venue.Specials)
                    {
                        if (special.Kind != SpecialKind.here)
                        {
                            continue;
                        }
                        try
                        {
                            int padd = 10 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Height;

                            AlphaImage alpha = new AlphaImage(Resources.SpecialHere);
                            Rectangle  rectS = new Rectangle(e.Bounds.Right - listBox.DefaultItemHeight - padd, e.Bounds.Y, listBox.DefaultItemHeight + padd, listBox.DefaultItemHeight + padd);
                            rectS.Y = rectS.Y - (padd / 2);

                            alpha.Draw(e.Graphics, rectS);
                        }
                        catch (Exception ex)
                        {
                            Log.RegisterLog("gdi", ex);
                        }
                    }
                }
            }
        }
Beispiel #9
0
        private void pnlCheckInResult_Paint(object sender, PaintEventArgs e)
        {
            if (backBuffer == null)
            {
                ResetBackBuffer();
            }


            e.Graphics.DrawImage(backBuffer, 0, 0);

            Graphics graphics = backBufferG;

            graphics.Clear(pnlCheckInResult.BackColor);

            int        padding = 4 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Width;
            RectangleF rectF   =
                new RectangleF(
                    padding,
                    padding,
                    pnlCheckInResult.Width - (padding * 2),
                    pnlCheckInResult.Height - (padding * 2)
                    );

            Rectangle rect = Rectangle.Round(rectF);

            int leftWithPadding  = rect.X + padding;
            int widthWithPadding = Convert.ToInt32(rect.Width - (padding * 2.5));

            RoundedRectangle.Fill(graphics, new Pen(Color.Gray), new SolidBrush(Color.White),
                                  rect, new Size(8 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Width, 8 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Height));

            Rectangle lastRectangle;

            // -- message
            lastRectangle = new Rectangle(
                leftWithPadding, rect.Y + padding, widthWithPadding, this.Height);

            Size measure = Tenor.Mobile.Drawing.Strings.Measure(graphics, message ?? "", Font, lastRectangle);

            graphics.DrawString(message ?? "", Font, textBrush, new RectangleF(lastRectangle.X, lastRectangle.Y, lastRectangle.Width, lastRectangle.Height), format);

            lastRectangle.Height = measure.Height + padding;
            // --

            if (specials != null)
            {
                foreach (var special in specials)
                {
                    if (special.Kind == SpecialKind.nearby)
                    {
                        continue; //TODO: Show specials nearby on check ins.
                    }
                    int stampSize = 31 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Width;

                    DrawSeparator(graphics, padding, ref rectF, ref lastRectangle);

                    AlphaImage image;
                    if (special.Kind == SpecialKind.here)
                    {
                        image = new AlphaImage(Resources.SpecialHere);
                    }
                    else if (special.Kind == SpecialKind.nearby)
                    {
                        image = new AlphaImage(Resources.SpecialNearby);
                    }
                    else
                    {
                        image = new AlphaImage(Resources.SpecialUnlocked);
                    }


                    Rectangle textRectangle =
                        new Rectangle(
                            lastRectangle.Left,
                            lastRectangle.Top,
                            lastRectangle.Width - stampSize - (padding * 2), this.Height);

                    measure = Tenor.Mobile.Drawing.Strings.Measure(graphics, special.Message ?? "", Font, textRectangle);
                    graphics.DrawString(special.Message ?? "", Font, textBrush, new RectangleF(textRectangle.X, textRectangle.Y, textRectangle.Width, textRectangle.Height), format);


                    if (measure.Height < stampSize)
                    {
                        measure.Height = stampSize;
                    }
                    try
                    {
                        image.Draw(graphics, new Rectangle(
                                       lastRectangle.Right - stampSize - padding,
                                       lastRectangle.Top + ((measure.Height / 2) - (stampSize / 2)), stampSize, stampSize));
                    }
                    catch (Exception ex)
                    {
                        Log.RegisterLog("gdi", ex);
                    }

                    lastRectangle.Height = measure.Height + padding;
                }
            }



            if (!string.IsNullOrEmpty(mayorship))
            {
                int crownSize = 0;
                if (showCrown)
                {
                    crownSize = 31 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Width;
                }

                DrawSeparator(graphics, padding, ref rectF, ref lastRectangle);


                Rectangle textRectangle = new Rectangle(
                    lastRectangle.Left, lastRectangle.Top, lastRectangle.Width - crownSize - (padding * 2), this.Height);

                measure = Tenor.Mobile.Drawing.Strings.Measure(graphics, mayorship ?? "", Font, textRectangle);
                graphics.DrawString(mayorship ?? "", Font, textBrush, new RectangleF(textRectangle.X, textRectangle.Y, textRectangle.Width, textRectangle.Height), format);

                if (measure.Height < crownSize)
                {
                    measure.Height = crownSize;
                }

                if (showCrown)
                {
                    try
                    {
                        AlphaImage image = new AlphaImage(Resources.Crown);
                        image.Draw(graphics, new Rectangle(
                                       lastRectangle.Right - crownSize - padding,
                                       lastRectangle.Top + ((measure.Height / 2) - (crownSize / 2)), crownSize, crownSize));
                    }
                    catch (Exception ex)
                    {
                        Log.RegisterLog("gdi", ex);
                    }
                }
                lastRectangle.Height = measure.Height + padding;
            }


            if (badges != null)
            {
                foreach (var badge in badges)
                {
                    int stampSize = 31 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Width;

                    DrawSeparator(graphics, padding, ref rectF, ref lastRectangle);


                    Rectangle textRectangle =
                        new Rectangle(
                            lastRectangle.Left,
                            lastRectangle.Top,
                            lastRectangle.Width - stampSize - (padding * 2), this.Height);

                    measure = Tenor.Mobile.Drawing.Strings.Measure(graphics, badge.ToString(), Font, textRectangle);
                    graphics.DrawString(badge.ToString(), Font, textBrush, new RectangleF(textRectangle.X, textRectangle.Y, textRectangle.Width, textRectangle.Height), format);

                    if (measure.Height < stampSize)
                    {
                        measure.Height = stampSize;
                    }

                    if (badgeImageList != null && badgeImageList.ContainsKey(badge.ImageUrl.ToString()))
                    {
                        try
                        {
                            AlphaImage image = new AlphaImage(badgeImageList[badge.ImageUrl.ToString()]);
                            image.Draw(graphics, new Rectangle(
                                           lastRectangle.Right - stampSize - padding,
                                           lastRectangle.Top + ((measure.Height / 2) - (stampSize / 2)), stampSize, stampSize));
                        }
                        catch (Exception ex)
                        {
                            Log.RegisterLog("gdi", ex);
                        }
                    }

                    lastRectangle.Height = measure.Height + padding;
                }
            }



            if (scoring != null)
            {
                foreach (var score in scoring)
                {
                    int stampSize = 16 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Width;

                    DrawSeparator(graphics, padding, ref rectF, ref lastRectangle);

                    Rectangle textRectangle =
                        new Rectangle(
                            lastRectangle.Left,
                            lastRectangle.Top,
                            lastRectangle.Width - stampSize - (padding * 2), this.Height);

                    measure = Tenor.Mobile.Drawing.Strings.Measure(graphics, score.ToString(), Font, textRectangle);
                    graphics.DrawString(score.ToString(), Font, textBrush, new RectangleF(textRectangle.X, textRectangle.Y, textRectangle.Width, textRectangle.Height), format);

                    if (measure.Height < stampSize)
                    {
                        measure.Height = stampSize;
                    }

                    if (scoreImageList != null && scoreImageList.ContainsKey(score.ImageUrl))
                    {
                        try
                        {
                            AlphaImage image = new AlphaImage(scoreImageList[score.ImageUrl]);
                            image.Draw(graphics, new Rectangle(
                                           lastRectangle.Right - stampSize - padding,
                                           lastRectangle.Top + ((measure.Height / 2) - (stampSize / 2)), stampSize, stampSize));
                        }
                        catch (Exception ex)
                        {
                            Log.RegisterLog("gdi", ex);
                        }
                    }

                    lastRectangle.Height = measure.Height + padding;
                }
            }

            e.Graphics.DrawImage(backBuffer, 0, 0);

            if (pnlCheckInResult.Height != lastRectangle.Bottom + padding)
            {
                pnlCheckInResult.Height = lastRectangle.Bottom + padding;
                pnlCheckInResult.Invalidate();
            }
        }
Beispiel #10
0
        internal override void DrawTabs(HeaderStrip control, PaintEventArgs e)
        {
            if (control.Tabs.Count == 0)
            {
                return;
            }
            Size size = control.Size;

            size.Height -= HeaderSelectedTabStrip * ScaleFactor.Height;

            IList <HeaderTab> tabs = control.Tabs;
            int bottomHeight       = 15 * ScaleFactor.Height;

            Point offset       = new Point(2 * ScaleFactor.Width, 2 * ScaleFactor.Width);
            int   defaultWidth = 42 * ScaleFactor.Width;
            Size  corner       = new Size(8 * ScaleFactor.Width, 8 * ScaleFactor.Height);

            Pen penBorder = new Pen(Strings.ToColor(BorderLineColor));

            try
            {
                HeaderTab selected = null;
                foreach (HeaderTab tab in tabs)
                {
                    tab.area = new Rectangle(offset.X + tab.TabIndex * defaultWidth, offset.Y, defaultWidth, size.Height - offset.Y + corner.Height);
                    if (tab.Selected)
                    {
                        selected = tab;
                        using (SolidBrush backColor = new SolidBrush(Color.Black))
                            RoundedRectangle.Fill(e.Graphics, penBorder, backColor, tab.area, corner);
                    }

                    if (tab.Image != null)
                    {
                        //draw icon
                        Rectangle destImg = new Rectangle(0, 0, tab.Image.Width, tab.Image.Height);
                        if (tab.Image.Size.Height > tab.area.Height || tab.Image.Size.Width > tab.area.Width)
                        {
                            int oX = 8 * ScaleFactor.Width;
                            int oY = 8 * ScaleFactor.Height;

                            int imageSize = tab.area.Height - ((tab.area.Y + oY) * 2);
                            destImg = new Rectangle(tab.area.X + oX, tab.area.Y + oY, imageSize, imageSize);
                        }

                        destImg = new Rectangle(tab.area.X + (tab.area.Width / 2) - (destImg.Width / 2), (tab.area.Height / 2) - (destImg.Height / 2), destImg.Width, destImg.Height);

                        using (AlphaImage image = new AlphaImage(tab.Image))
                        {
                            image.Draw(e.Graphics, destImg);
                        }
                    }

                    if (!tab.Selected && (tab.TabIndex == tabs.Count - 1 || !tabs[tab.TabIndex + 1].Selected))
                    {
                        Point sep = new Point(tab.area.Right, offset.Y);
                        DrawSeparator(e, sep, size.Height - (sep.Y * 2), Orientation.Vertical);
                    }
                }

                Font       font   = new Font(FontFamily.GenericSansSerif, HeaderSelectedTabStripFontSize, FontStyle.Regular);
                SolidBrush brush  = new SolidBrush(ControlBackColor);
                SolidBrush fBrush = new SolidBrush(Strings.ToColor(HeaderSelectedTabStripFontColor));
                Rectangle  rect   = new Rectangle(0, size.Height, control.Width, control.Height - size.Height);
                e.Graphics.FillRectangle(brush, rect);
                SizeF textSize = e.Graphics.MeasureString(selected.Text, font);

                Rectangle stringRect = rect;
                stringRect.X = Convert.ToInt32(selected.area.X + ((selected.area.Width / 2) - (textSize.Width / 2)));
                if (stringRect.X < 0)
                {
                    stringRect.X = 2 * ScaleFactor.Width;
                }

                e.Graphics.DrawString(selected.Text, font, fBrush, stringRect);
                e.Graphics.DrawLine(new Pen(Strings.ToColor(HeaderSelectedTabStripBorderColor)), rect.Left, rect.Bottom - 1, rect.Right, rect.Bottom - 1);
                brush.Dispose(); fBrush.Dispose(); font.Dispose();
            }
            finally
            {
                penBorder.Dispose();
            }
        }
Beispiel #11
0
        private void listBox_DrawItem(object sender, Tenor.Mobile.UI.DrawItemEventArgs e)
        {
            User user = (User)e.Item.Value;



            Size factor = Tenor.Mobile.UI.Skin.Current.ScaleFactor;

            if (!string.IsNullOrEmpty(user.ToString()))
            {
                int padding   = 5 * factor.Width;
                int imageSize = listBox.DefaultItemHeight - padding;

                RectangleF rect = new RectangleF
                                      (e.Bounds.X + imageSize + (padding * 2),
                                      e.Bounds.Y,
                                      e.Bounds.Width - (imageSize) - (padding * 2),
                                      e.Bounds.Height);

                if (e.Item.Selected)
                {
                    Tenor.Mobile.Drawing.RoundedRectangle.Fill(e.Graphics,
                                                               borderPen, selectedBrush, e.Bounds, new Size(8 * factor.Width, 8 * factor.Height));
                }

                if (imageList != null && imageList.ContainsKey(user.ImageUrl))
                {
                    if (!imageListBuffer.ContainsKey(user.ImageUrl))
                    {
                        imageListBuffer.Add(user.ImageUrl, new AlphaImage(Main.CreateRoundedAvatar(imageList[user.ImageUrl], imageSize, factorF)));
                    }
                    AlphaImage image = imageListBuffer[user.ImageUrl];

                    Rectangle imgRect =
                        new Rectangle(0 + Convert.ToInt32(padding),
                                      Convert.ToInt32(rect.Y + (rect.Height / 2) - (imageSize / 2)), imageSize, imageSize);
                    try
                    {
                        //e.Graphics.DrawImage(image, imgRect, new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
                        image.Draw(e.Graphics, imgRect);
                    }
                    catch (Exception ex) { Log.RegisterLog("gdi", ex); }
                }

                rect.Y += 2 * factor.Height;
                SizeF size = e.Graphics.MeasureString(user.ToString(), fontBold);
                e.Graphics.DrawString(
                    user.ToString(), fontBold, brush, rect);

                if (user.CheckIn != null)
                {
                    string text = string.Empty;

                    if (user.CheckIn.Venue != null)
                    {
                        text = "@ " + user.CheckIn.Venue.Name;
                    }
                    else if (!string.IsNullOrEmpty(user.CheckIn.Shout))
                    {
                        text = user.CheckIn.Shout;
                    }
                    else if (user.CheckIn.Created > DateTime.MinValue)
                    {
                        text = user.CheckIn.Created.ToHumanTime();
                    }


                    rect.Y += size.Height + (3 * factor.Height);
                    e.Graphics.DrawString(
                        text, font, brush, rect, format);
                }


                if (!e.Item.Selected)
                {
                    Rectangle rect2 = new Rectangle(
                        e.Bounds.X, e.Bounds.Bottom - 2, e.Bounds.Width / 3, 1);
                    Tenor.Mobile.Drawing.GradientFill.Fill(e.Graphics, rect2, this.BackColor, Color.Gray, Tenor.Mobile.Drawing.GradientFill.FillDirection.LeftToRight);
                    rect2.X += rect2.Width;
                    Tenor.Mobile.Drawing.GradientFill.Fill(e.Graphics, rect2, Color.Gray, Color.Gray, Tenor.Mobile.Drawing.GradientFill.FillDirection.LeftToRight);
                    rect2.X += rect2.Width;
                    Tenor.Mobile.Drawing.GradientFill.Fill(e.Graphics, rect2, Color.Gray, this.BackColor, Tenor.Mobile.Drawing.GradientFill.FillDirection.LeftToRight);
                }
            }
        }
Beispiel #12
0
        private void listBox_DrawItem(object sender, Tenor.Mobile.UI.DrawItemEventArgs e)
        {
            string text       = null;
            string secondText = null;
            string userUrl    = null;

            Font  font     = this.Font;
            float thisLeft = e.Bounds.Height;

            if (e.Item.Value == null)
            {
                if (smallFont == null)
                {
                    smallFont = new Font(this.Font.Name, this.Font.Size - 1, this.Font.Style);
                }
                font = smallFont;
                text = e.Item.Text;
                Color color = Tenor.Mobile.UI.Skin.Current.ControlBackColor;
                if (e.Item.YIndex % 2 == 0)
                {
                    color = Tenor.Mobile.UI.Skin.Current.AlternateBackColor;
                }
                e.Graphics.FillRectangle(new SolidBrush(color), e.Bounds);
                thisLeft = itemPadding;
                if (e.Item.YIndex > 0)
                {
                    e.Graphics.DrawSeparator(e.Bounds, color);
                }
            }
            else if (e.Item.Value != null && e.Item.Value is CheckIn)
            {
                CheckIn checkIn = (CheckIn)e.Item.Value;

                text = checkIn.ToString();

                if (checkIn.User != null)
                {
                    userUrl = checkIn.User.ImageUrl;
                }


                secondText = checkIn.Created.ToHumanTime();
            }
            else if (e.Item.Value != null && e.Item.Value is User)
            {
                User user = (User)e.Item.Value;
                text = string.Format("{0} {1}", user.FirstName, user.LastName);
                if (user.Contact != null)
                {
                    secondText = user.Contact.Email;
                }
                userUrl = user.ImageUrl;
            }


            Brush textBrush = (e.Item.Selected ? brushS : brush);
            SizeF measuring = e.Graphics.MeasureString(text, Font);

            RectangleF rect = new RectangleF(thisLeft, e.Bounds.Y + itemPadding, measuring.Width, measuring.Height);

            e.Graphics.DrawString(text, font, textBrush, rect, format);

            if (!string.IsNullOrEmpty(secondText))
            {
                measuring = e.Graphics.MeasureString(secondText, Font);
                rect      = new RectangleF(rect.X, rect.Bottom + itemPadding, measuring.Width, measuring.Height);
                if (secondFont == null)
                {
                    secondFont = new Font(Font.Name, Font.Size - 1, Font.Style);
                }
                e.Graphics.DrawString(secondText, secondFont, secondBrush, rect, format);
            }

            if (userUrl != null && imageList.ContainsKey(userUrl) && imageList[userUrl] != null)
            {
                int imageSize = e.Bounds.Height - Convert.ToInt32(itemPadding * 2);

                if (!imageListBuffer.ContainsKey(userUrl))
                {
                    imageListBuffer.Add(userUrl,
                                        new AlphaImage(Main.CreateRoundedAvatar(imageList[userUrl], imageSize, factor)));
                }
                AlphaImage alpha = imageListBuffer[userUrl];

                try
                {
                    alpha.Draw(e.Graphics,
                               new Rectangle(
                                   e.Bounds.X + Convert.ToInt32(itemPadding),
                                   e.Bounds.Y + Convert.ToInt32(itemPadding),
                                   imageSize,
                                   imageSize), Tenor.Mobile.UI.Skin.Current.SelectedBackColor);
                }
                catch (Exception ex)
                {
                    imageListBuffer.Remove(userUrl);
                    Log.RegisterLog("gdi", ex);
                }
            }
        }
Beispiel #13
0
        private void listBox_DrawItem(object sender, Tenor.Mobile.UI.DrawItemEventArgs e)
        {
            if (smallFont == null)
            {
                smallFont = new Font(this.Font.Name, this.Font.Size - 1, this.Font.Style);
            }
            if (format == null)
            {
                format = new StringFormat();
            }
            if (textBrush == null)
            {
                textBrush = new SolidBrush(Color.White);
            }
            if (secondBrush == null)
            {
                secondBrush = new SolidBrush(Color.LightGray);
            }



            Font  thisFont = listBox.Font;
            float thisLeft = e.Bounds.Height;


            string text       = e.Item.Text;
            string secondText = null;

            if (text.IndexOf("\r\n") > -1)
            {
                string[] textS = text.Split('\r', '\n');
                text       = textS[0];
                secondText = textS[2];
            }

            SizeF      measuring = e.Graphics.MeasureString(text, thisFont);
            RectangleF rect      = new RectangleF(thisLeft, e.Bounds.Y + itemPadding, measuring.Width, measuring.Height);

            Color color = Tenor.Mobile.UI.Skin.Current.ControlBackColor;

            if (e.Item.YIndex % 2 == 0)
            {
                color = Tenor.Mobile.UI.Skin.Current.AlternateBackColor;
            }
            //if (!e.Item.Selected)
            //    e.Graphics.FillRectangle(new SolidBrush(color), e.Bounds);
            if (e.Item.YIndex > 0)
            {
                e.Graphics.DrawSeparator(e.Bounds, color);
            }

            e.Graphics.DrawString(text, thisFont, textBrush, rect, format);
            if (secondText != null)
            {
                measuring = e.Graphics.MeasureString(secondText, smallFont);
                rect      = new RectangleF(rect.X, rect.Bottom + itemPadding, measuring.Width, measuring.Height);
                e.Graphics.DrawString(secondText, smallFont, secondBrush, rect, format);
            }

            AlphaImage alpha = e.Item.Value as AlphaImage;

            if (alpha != null)
            {
                try
                {
                    int imageSize = e.Bounds.Height - Convert.ToInt32(itemPadding * 2);
                    alpha.Draw(e.Graphics,
                               new Rectangle(
                                   e.Bounds.X + Convert.ToInt32(itemPadding),
                                   e.Bounds.Y + Convert.ToInt32(itemPadding),
                                   imageSize,
                                   imageSize));
                }
                catch (Exception ex)
                {
                    Log.RegisterLog("gdi", ex);
                }
            }
        }
Beispiel #14
0
        void lstAll_DrawItem(object sender, Tenor.Mobile.UI.DrawItemEventArgs e)
        {
            var             listBox = (Tenor.Mobile.UI.KListControl)sender;
            LeaderboardUser lboard  = (LeaderboardUser)e.Item.Value;

            User user = lboard.User;

            string     rankText = "#" + lboard.Rank.ToString();
            SizeF      rankSize = e.Graphics.MeasureString(rankText, medFont);
            RectangleF rankRect = new RectangleF(
                3 * factorF.Width,
                e.Bounds.Y + (e.Bounds.Height / 2 - rankSize.Height / 2),
                rankSize.Width,
                rankSize.Height
                );

            Size factor = Tenor.Mobile.UI.Skin.Current.ScaleFactor;

            if (!string.IsNullOrEmpty(user.ToString()))
            {
                int padding   = 5 * factor.Width;
                int imageSize = listBox.DefaultItemHeight - padding;

                RectangleF rect = new RectangleF
                                      (imageSize + (padding * 2) + rankRect.Right,
                                      e.Bounds.Y,
                                      e.Bounds.Width - (imageSize) - (padding * 2),
                                      e.Bounds.Height);

                if (user.FriendStatus != null && user.FriendStatus.Value == FriendStatus.self)
                {
                    Tenor.Mobile.Drawing.RoundedRectangle.Fill(e.Graphics,
                                                               borderPen, selectedBrush, e.Bounds, new Size(8 * factor.Width, 8 * factor.Height));
                }
                e.Graphics.DrawString(rankText, medFont, brush, rankRect);

                if (imageList != null && imageList.ContainsKey(user.ImageUrl))
                {
                    if (!imageListBuffer.ContainsKey(user.ImageUrl))
                    {
                        imageListBuffer.Add(user.ImageUrl, new AlphaImage(Main.CreateRoundedAvatar(imageList[user.ImageUrl], imageSize, factorF)));
                    }
                    AlphaImage image = imageListBuffer[user.ImageUrl];

                    Rectangle imgRect =
                        new Rectangle(Convert.ToInt32(rankRect.Right + padding),
                                      Convert.ToInt32(rect.Y + (rect.Height / 2) - (imageSize / 2)), imageSize, imageSize);
                    try
                    {
                        //e.Graphics.DrawImage(image, imgRect, new Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
                        image.Draw(e.Graphics, imgRect);
                    }
                    catch (Exception ex) { Log.RegisterLog("gdi", ex); }
                }

                rect.Y += 2 * factor.Height;
                SizeF size = e.Graphics.MeasureString(user.ToString(), fontBold);
                e.Graphics.DrawString(
                    user.ToString(), fontBold, brush, rect);

                if (lboard.Scores != null)
                {
                    string text = "7-day high score: ";
                    text += lboard.Scores.Max.ToString();


                    rect.Y += size.Height + (3 * factor.Height);
                    e.Graphics.DrawString(
                        text, font, brush, rect, format);


                    var   scoreText = lboard.Scores.Recent.ToString();
                    SizeF sizeScore = e.Graphics.MeasureString(scoreText, bigFont);
                    rect = new RectangleF(
                        e.Bounds.Width - sizeScore.Width - (10 * factorF.Width),
                        e.Bounds.Y + (e.Bounds.Height / 2 - sizeScore.Height / 2),
                        sizeScore.Width, sizeScore.Height
                        );

                    e.Graphics.DrawString(
                        scoreText, bigFont, brush, rect, format);
                }


                if (user.FriendStatus != null && user.FriendStatus.Value != FriendStatus.self)
                {
                    Rectangle rect2 = new Rectangle(
                        e.Bounds.X, e.Bounds.Bottom - 2, e.Bounds.Width / 3, 1);
                    Tenor.Mobile.Drawing.GradientFill.Fill(e.Graphics, rect2, this.BackColor, Color.Gray, Tenor.Mobile.Drawing.GradientFill.FillDirection.LeftToRight);
                    rect2.X += rect2.Width;
                    Tenor.Mobile.Drawing.GradientFill.Fill(e.Graphics, rect2, Color.Gray, Color.Gray, Tenor.Mobile.Drawing.GradientFill.FillDirection.LeftToRight);
                    rect2.X += rect2.Width;
                    Tenor.Mobile.Drawing.GradientFill.Fill(e.Graphics, rect2, Color.Gray, this.BackColor, Tenor.Mobile.Drawing.GradientFill.FillDirection.LeftToRight);
                }
            }
        }
Beispiel #15
0
        private void picGps_Paint(object sender, PaintEventArgs e)
        {
            try
            {
                if (backBufferG == null)
                {
                    return;
                }
                e.Graphics.DrawImage(backBuffer, 0, 0);
                backBufferG.Clear(Color.Black);
                Rectangle size;

                size = new Rectangle(0, 0, picGps.Height, picGps.Height);

                if (showGps)
                {
                    if (gps == null)
                    {
                        gps = new AlphaImage(Resources.Gps);
                    }

                    gps.Draw(backBufferG, size);
                }

                size = new Rectangle(
                    size.Width, 0,
                    14 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Width,
                    11 * Tenor.Mobile.UI.Skin.Current.ScaleFactor.Height);
                if (Program.Location.IsGpsOpen)
                {
                    Debug.Write(Program.Location.Sattelites.ToString());
                    int strength = 0;
                    if (Program.Location.Sattelites.Total > 0)
                    {
                        float active = Program.Location.Sattelites.Active;
                        float total  = Program.Location.Sattelites.Total;
                        if (active > 0 && active <= 2)
                        {
                            active = 1;
                        }
                        else
                        {
                            active -= 2;
                        }
                        if (total > 4)
                        {
                            total = 4;
                        }

                        float strengthPercent =
                            (active / total) * 100F;

                        strength = Convert.ToInt32(Math.Floor(4F * strengthPercent / 100F));
                        if (strength > 4)
                        {
                            strength = 4;
                        }

                        Debug.WriteLine(": " + strengthPercent.ToString() + ": " + strength.ToString());
                    }
                    Image image = null;
                    switch (strength)
                    {
                    case 1:
                        image = Resources.Gps_1;
                        break;

                    case 2:
                        image = Resources.Gps_2;
                        break;

                    case 3:
                        image = Resources.Gps_3;
                        break;

                    case 4:
                        image = Resources.Gps_4;
                        break;

                    default:
                        image = Resources.Gps_0;
                        break;
                    }

                    backBufferG.DrawImage(image,
                                          size,
                                          new Rectangle(0, 0, image.Width, image.Height),
                                          GraphicsUnit.Pixel);
                }

                e.Graphics.DrawImage(backBuffer, 0, 0);
            }
            catch (Exception ex)
            {
                Log.RegisterLog("gdi", ex);
            }
        }