[paintcode] add new sample for PaintCode
Use www.paintcodeapp.com to open the .paintcode files included in this sample
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<SampleMetadata>
|
||||
<ID>0c225c9a-a1ed-4e07-954b-e5b45802979e</ID>
|
||||
<IsFullApplication>false</IsFullApplication>
|
||||
<Level>Intermediate</Level>
|
||||
<Tags>User Interface</Tags>
|
||||
</SampleMetadata>
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace PaintCode
|
||||
{
|
||||
public class Application
|
||||
{
|
||||
static void Main (string[] args)
|
||||
{
|
||||
UIApplication.Main (args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
|
||||
[Register ("AppDelegate")]
|
||||
public partial class AppDelegate : UIApplicationDelegate
|
||||
{
|
||||
UIWindow window;
|
||||
UINavigationController navCtrlr;
|
||||
UITabBarController tabBarController;
|
||||
UIViewController news, blue, glossy, lineart;
|
||||
|
||||
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
|
||||
{
|
||||
// create a new window instance based on the screen size
|
||||
window = new UIWindow (UIScreen.MainScreen.Bounds);
|
||||
|
||||
navCtrlr = new UINavigationController ();
|
||||
|
||||
|
||||
blue = new BlueButtonViewController ();
|
||||
glossy = new GlossyButtonViewController ();
|
||||
lineart = new DrawingViewController ();
|
||||
|
||||
news = new NewsDialogViewController ();
|
||||
// news.View.Frame = new System.Drawing.RectangleF (0
|
||||
// , UIApplication.SharedApplication.StatusBarFrame.Height
|
||||
// , UIScreen.MainScreen.ApplicationFrame.Width
|
||||
// , UIScreen.MainScreen.ApplicationFrame.Height);
|
||||
|
||||
navCtrlr.PushViewController (news, false);
|
||||
|
||||
|
||||
navCtrlr.TabBarItem = new UITabBarItem ("Calendar", UIImage.FromBundle ("Images/about.png"), 0);
|
||||
blue.TabBarItem = new UITabBarItem ("Blue Button", UIImage.FromBundle ("Images/about.png"), 0);
|
||||
glossy.TabBarItem = new UITabBarItem ("Glossy Button", UIImage.FromBundle ("Images/about.png"), 0);
|
||||
lineart.TabBarItem = new UITabBarItem ("Line Art", UIImage.FromBundle ("Images/about.png"), 0);
|
||||
|
||||
tabBarController = new UITabBarController ();
|
||||
tabBarController.ViewControllers = new UIViewController [] {
|
||||
navCtrlr,
|
||||
blue,
|
||||
glossy,
|
||||
lineart
|
||||
};
|
||||
|
||||
|
||||
|
||||
window.AddSubview (tabBarController.View);
|
||||
// make the window visible
|
||||
window.MakeKeyAndVisible ();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,271 @@
|
|||
using System;
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.CoreGraphics;
|
||||
using System.Drawing;
|
||||
|
||||
namespace PaintCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Blue button example
|
||||
/// http://paintcodeapp.com/examples.html
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This implementation only deals with Normal and Pressed states.
|
||||
/// There is no handling for the Disabled state.
|
||||
/// </remarks>
|
||||
public class BlueButton : UIButton {
|
||||
|
||||
bool isPressed;
|
||||
|
||||
public UIColor NormalColor;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the user touches
|
||||
/// </summary>
|
||||
public event Action<BlueButton> Tapped;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the GlassButton using the specified dimensions
|
||||
/// </summary>
|
||||
public BlueButton (RectangleF frame) : base (frame)
|
||||
{
|
||||
NormalColor = UIColor.FromRGBA (0.00f, 0.37f, 0.89f, 1.00f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the button is rendered enabled or not.
|
||||
/// </summary>
|
||||
public override bool Enabled {
|
||||
get {
|
||||
return base.Enabled;
|
||||
}
|
||||
set {
|
||||
base.Enabled = value;
|
||||
SetNeedsDisplay ();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool BeginTracking (UITouch uitouch, UIEvent uievent)
|
||||
{
|
||||
SetNeedsDisplay ();
|
||||
isPressed = true;
|
||||
return base.BeginTracking (uitouch, uievent);
|
||||
}
|
||||
|
||||
public override void EndTracking (UITouch uitouch, UIEvent uievent)
|
||||
{
|
||||
if (isPressed && Enabled){
|
||||
if (Tapped != null)
|
||||
Tapped (this);
|
||||
}
|
||||
isPressed = false;
|
||||
SetNeedsDisplay ();
|
||||
base.EndTracking (uitouch, uievent);
|
||||
}
|
||||
|
||||
public override bool ContinueTracking (UITouch uitouch, UIEvent uievent)
|
||||
{
|
||||
var touch = uievent.AllTouches.AnyObject as UITouch;
|
||||
if (Bounds.Contains (touch.LocationInView (this)))
|
||||
isPressed = true;
|
||||
else
|
||||
isPressed = false;
|
||||
return base.ContinueTracking (uitouch, uievent);
|
||||
}
|
||||
|
||||
public override void Draw (RectangleF rect)
|
||||
{
|
||||
var context = UIGraphics.GetCurrentContext ();
|
||||
var bounds = Bounds;
|
||||
|
||||
//UIColor background = Enabled ? isPressed ? HighlightedColor : NormalColor : DisabledColor;
|
||||
|
||||
|
||||
UIColor buttonColor = NormalColor; //UIColor.FromRGBA (0.00f, 0.37f, 0.89f, 1.00f);
|
||||
var buttonColorRGBA = new float[4];
|
||||
buttonColor.GetRGBA (
|
||||
out buttonColorRGBA [0],
|
||||
out buttonColorRGBA [1],
|
||||
out buttonColorRGBA [2],
|
||||
out buttonColorRGBA [3]
|
||||
);
|
||||
if (isPressed) {
|
||||
// Get the Hue Saturation Brightness Alpha copy of the color
|
||||
var buttonColorHSBA = new float[4];
|
||||
buttonColor.GetHSBA (
|
||||
out buttonColorHSBA [0],
|
||||
out buttonColorHSBA [1],
|
||||
out buttonColorHSBA [2],
|
||||
out buttonColorHSBA [3]
|
||||
);
|
||||
// Change the brightness to a fixed value (0.5f)
|
||||
buttonColor = UIColor.FromHSBA (buttonColorHSBA [0], buttonColorHSBA [1], 0.5f, buttonColorHSBA [3]);
|
||||
// Re-set the base buttonColorRGBA because everything else is relative to it
|
||||
buttonColorRGBA = new float[4];
|
||||
buttonColor.GetRGBA (
|
||||
out buttonColorRGBA [0],
|
||||
out buttonColorRGBA [1],
|
||||
out buttonColorRGBA [2],
|
||||
out buttonColorRGBA [3]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
using (var colorSpace = CGColorSpace.CreateDeviceRGB ()) {
|
||||
|
||||
|
||||
|
||||
// ------------- START PAINTCODE -------------
|
||||
|
||||
//// Color Declarations
|
||||
UIColor upColorOut = UIColor.FromRGBA (0.79f, 0.79f, 0.79f, 1.00f);
|
||||
UIColor bottomColorDown = UIColor.FromRGBA (0.21f, 0.21f, 0.21f, 1.00f);
|
||||
UIColor upColorInner = UIColor.FromRGBA (0.17f, 0.18f, 0.20f, 1.00f);
|
||||
UIColor bottomColorInner = UIColor.FromRGBA (0.98f, 0.98f, 0.99f, 1.00f);
|
||||
|
||||
|
||||
UIColor buttonFlareUpColor = UIColor.FromRGBA (
|
||||
(buttonColorRGBA[0] * 0.3f + 0.7f),
|
||||
(buttonColorRGBA[1] * 0.3f + 0.7f),
|
||||
(buttonColorRGBA[2] * 0.3f + 0.7f),
|
||||
(buttonColorRGBA[3] * 0.3f + 0.7f)
|
||||
);
|
||||
UIColor buttonTopColor = UIColor.FromRGBA (
|
||||
(buttonColorRGBA[0] * 0.8f),
|
||||
(buttonColorRGBA[1] * 0.8f),
|
||||
(buttonColorRGBA[2] * 0.8f),
|
||||
(buttonColorRGBA[3] * 0.8f + 0.2f)
|
||||
);
|
||||
UIColor buttonBottomColor = UIColor.FromRGBA (
|
||||
(buttonColorRGBA[0] * 0 + 1),
|
||||
(buttonColorRGBA[1] * 0 + 1),
|
||||
(buttonColorRGBA[2] * 0 + 1),
|
||||
(buttonColorRGBA[3] * 0 + 1)
|
||||
);
|
||||
UIColor buttonFlareBottomColor = UIColor.FromRGBA (
|
||||
(buttonColorRGBA[0] * 0.8f + 0.2f),
|
||||
(buttonColorRGBA[1] * 0.8f + 0.2f),
|
||||
(buttonColorRGBA[2] * 0.8f + 0.2f),
|
||||
(buttonColorRGBA[3] * 0.8f + 0.2f)
|
||||
);
|
||||
UIColor flareWhite = UIColor.FromRGBA (1.00f, 1.00f, 1.00f, 0.83f);
|
||||
|
||||
//// Gradient Declarations
|
||||
var ringGradientColors = new CGColor [] {upColorOut.CGColor, bottomColorDown.CGColor};
|
||||
var ringGradientLocations = new float [] {0, 1};
|
||||
var ringGradient = new CGGradient (colorSpace, ringGradientColors, ringGradientLocations);
|
||||
var ringInnerGradientColors = new CGColor [] {upColorInner.CGColor, bottomColorInner.CGColor};
|
||||
var ringInnerGradientLocations = new float [] {0, 1};
|
||||
var ringInnerGradient = new CGGradient (colorSpace, ringInnerGradientColors, ringInnerGradientLocations);
|
||||
var buttonGradientColors = new CGColor [] {buttonBottomColor.CGColor, buttonTopColor.CGColor};
|
||||
var buttonGradientLocations = new float [] {0, 1};
|
||||
var buttonGradient = new CGGradient (colorSpace, buttonGradientColors, buttonGradientLocations);
|
||||
var overlayGradientColors = new CGColor [] {flareWhite.CGColor, UIColor.Clear.CGColor};
|
||||
var overlayGradientLocations = new float [] {0, 1};
|
||||
var overlayGradient = new CGGradient (colorSpace, overlayGradientColors, overlayGradientLocations);
|
||||
var buttonFlareGradientColors = new CGColor [] {buttonFlareUpColor.CGColor, buttonFlareBottomColor.CGColor};
|
||||
var buttonFlareGradientLocations = new float [] {0, 1};
|
||||
var buttonFlareGradient = new CGGradient (colorSpace, buttonFlareGradientColors, buttonFlareGradientLocations);
|
||||
|
||||
//// Shadow Declarations
|
||||
var buttonInnerShadow = UIColor.Black.CGColor;
|
||||
var buttonInnerShadowOffset = new SizeF (0, -0);
|
||||
var buttonInnerShadowBlurRadius = 5;
|
||||
var buttonOuterShadow = UIColor.Black.CGColor;
|
||||
var buttonOuterShadowOffset = new SizeF (0, 2);
|
||||
|
||||
|
||||
var buttonOuterShadowBlurRadius = isPressed ? 2 : 5; // ADDED this code after PaintCode
|
||||
|
||||
|
||||
//// outerOval Drawing
|
||||
var outerOvalPath = UIBezierPath.FromOval (new RectangleF (5, 5, 63, 63));
|
||||
context.SaveState ();
|
||||
context.SetShadowWithColor (buttonOuterShadowOffset, buttonOuterShadowBlurRadius, buttonOuterShadow);
|
||||
context.BeginTransparencyLayer (null);
|
||||
outerOvalPath.AddClip ();
|
||||
context.DrawLinearGradient (ringGradient, new PointF (36.5f, 5), new PointF (36.5f, 68), 0);
|
||||
context.EndTransparencyLayer ();
|
||||
context.RestoreState ();
|
||||
|
||||
|
||||
|
||||
//// overlayOval Drawing
|
||||
var overlayOvalPath = UIBezierPath.FromOval (new RectangleF (5, 5, 63, 63));
|
||||
context.SaveState ();
|
||||
overlayOvalPath.AddClip ();
|
||||
context.DrawRadialGradient (overlayGradient,
|
||||
new PointF (36.5f, 12.23f), 17.75f,
|
||||
new PointF (36.5f, 36.5f), 44.61f,
|
||||
CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
|
||||
context.RestoreState ();
|
||||
|
||||
|
||||
|
||||
//// innerOval Drawing
|
||||
var innerOvalPath = UIBezierPath.FromOval (new RectangleF (12, 12, 49, 49));
|
||||
context.SaveState ();
|
||||
innerOvalPath.AddClip ();
|
||||
context.DrawLinearGradient (ringInnerGradient, new PointF (36.5f, 12), new PointF (36.5f, 61), 0);
|
||||
context.RestoreState ();
|
||||
|
||||
|
||||
|
||||
//// buttonOval Drawing
|
||||
var buttonOvalPath = UIBezierPath.FromOval (new RectangleF (14, 13, 46, 46));
|
||||
context.SaveState ();
|
||||
buttonOvalPath.AddClip ();
|
||||
context.DrawRadialGradient (buttonGradient,
|
||||
new PointF (37, 63.23f), 2.44f,
|
||||
new PointF (37, 44.48f), 23.14f,
|
||||
CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
|
||||
context.RestoreState ();
|
||||
|
||||
////// buttonOval Inner Shadow
|
||||
var buttonOvalBorderRect = buttonOvalPath.Bounds;
|
||||
buttonOvalBorderRect.Inflate (buttonInnerShadowBlurRadius, buttonInnerShadowBlurRadius);
|
||||
buttonOvalBorderRect.Offset (-buttonInnerShadowOffset.Width, -buttonInnerShadowOffset.Height);
|
||||
buttonOvalBorderRect = RectangleF.Union (buttonOvalBorderRect, buttonOvalPath.Bounds);
|
||||
buttonOvalBorderRect.Inflate (1, 1);
|
||||
|
||||
var buttonOvalNegativePath = UIBezierPath.FromRect (buttonOvalBorderRect);
|
||||
buttonOvalNegativePath.AppendPath (buttonOvalPath);
|
||||
buttonOvalNegativePath.UsesEvenOddFillRule = true;
|
||||
|
||||
context.SaveState ();
|
||||
{
|
||||
var xOffset = buttonInnerShadowOffset.Width + (float)Math.Round (buttonOvalBorderRect.Width);
|
||||
var yOffset = buttonInnerShadowOffset.Height;
|
||||
context.SetShadowWithColor (
|
||||
new SizeF (xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)),
|
||||
buttonInnerShadowBlurRadius,
|
||||
buttonInnerShadow);
|
||||
|
||||
buttonOvalPath.AddClip ();
|
||||
var transform = CGAffineTransform.MakeTranslation (-(float)Math.Round (buttonOvalBorderRect.Width), 0);
|
||||
buttonOvalNegativePath.ApplyTransform (transform);
|
||||
UIColor.Gray.SetFill ();
|
||||
buttonOvalNegativePath.Fill ();
|
||||
}
|
||||
context.RestoreState ();
|
||||
|
||||
|
||||
|
||||
|
||||
//// flareOval Drawing
|
||||
var flareOvalPath = UIBezierPath.FromOval (new RectangleF (22, 14, 29, 15));
|
||||
context.SaveState ();
|
||||
flareOvalPath.AddClip ();
|
||||
context.DrawLinearGradient (buttonFlareGradient, new PointF (36.5f, 14), new PointF (36.5f, 29), 0);
|
||||
context.RestoreState ();
|
||||
|
||||
|
||||
// ------------- END PAINTCODE -------------
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Двоичные данные
PaintCode/PaintCodeDemo/BlueButton/BlueButton.paintcode/QuickLook/Preview.pdf
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using MonoTouch.UIKit;
|
||||
using System.Drawing;
|
||||
|
||||
namespace PaintCode
|
||||
{
|
||||
public class BlueButtonViewController : UIViewController
|
||||
{
|
||||
public BlueButtonViewController ()
|
||||
{
|
||||
}
|
||||
|
||||
BlueButton button;
|
||||
UITextView text;
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
|
||||
View.BackgroundColor = UIColor.White;
|
||||
|
||||
button = new BlueButton (new RectangleF (10, 10, 120, 120));
|
||||
|
||||
button.Tapped += (obj) => {
|
||||
new UIAlertView ("Tapped", "Button tapped", null, "OK", null).Show ();
|
||||
};
|
||||
|
||||
View.AddSubview (button);
|
||||
|
||||
|
||||
text = new UITextView (new Rectangle (10, 100, 300, 300));
|
||||
text.Font = UIFont.SystemFontOfSize (14f);
|
||||
text.Editable = false;
|
||||
text.Text = "PaintCode BlueButton Example\n\n"
|
||||
+ "After the button is drawn in PaintCode then added to a UIButton subclass "
|
||||
+ "Draw() method override, some color/style properties are tweaked in code "
|
||||
+ "to create the TouchDown effect.";
|
||||
View.AddSubview (text);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Двоичные данные
PaintCode/PaintCodeDemo/Calendar/Calendar.paintcode/QuickLook/Preview.pdf
Normal file
|
@ -0,0 +1,105 @@
|
|||
//
|
||||
// ElementBadge.cs: defines the Badge Element.
|
||||
//
|
||||
// Author:
|
||||
// Miguel de Icaza (miguel@gnome.org)
|
||||
//
|
||||
// Copyright 2010, Novell, Inc.
|
||||
//
|
||||
// Code licensed under the MIT X11 license
|
||||
//
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.CoreGraphics;
|
||||
using System.Drawing;
|
||||
using MonoTouch.Foundation;
|
||||
|
||||
namespace PaintCode {
|
||||
/// <summary>
|
||||
/// Lifted this code from MT.D source, so it could be customized
|
||||
/// </summary>
|
||||
public class CustomBadgeElement {
|
||||
public CustomBadgeElement ()
|
||||
{
|
||||
}
|
||||
public static UIImage MakeCalendarBadge (string smallText, string bigText)
|
||||
{
|
||||
UIGraphics.BeginImageContext (new SizeF (42, 42));
|
||||
|
||||
|
||||
// ------------- START PAINTCODE ----------------
|
||||
|
||||
|
||||
//// Abstracted Graphic Attributes
|
||||
var textContent = bigText;
|
||||
var text2Content = smallText;
|
||||
|
||||
//// General Declarations
|
||||
var colorSpace = CGColorSpace.CreateDeviceRGB();
|
||||
var context = UIGraphics.GetCurrentContext();
|
||||
|
||||
//// Color Declarations
|
||||
UIColor dateRed = UIColor.FromRGBA(0.83f, 0.11f, 0.06f, 1.00f);
|
||||
|
||||
//// Gradient Declarations
|
||||
var greyGradientColors = new CGColor [] {UIColor.White.CGColor, UIColor.FromRGBA(0.57f, 0.57f, 0.57f, 1.00f).CGColor, UIColor.Black.CGColor};
|
||||
var greyGradientLocations = new float [] {0.65f, 0.75f, 0.75f};
|
||||
var greyGradient = new CGGradient(colorSpace, greyGradientColors, greyGradientLocations);
|
||||
|
||||
//// Shadow Declarations
|
||||
var dropShadow = UIColor.DarkGray.CGColor;
|
||||
var dropShadowOffset = new SizeF(2, 2);
|
||||
var dropShadowBlurRadius = 1;
|
||||
|
||||
|
||||
//// Rounded Rectangle Drawing
|
||||
var roundedRectanglePath = UIBezierPath.FromRoundedRect(new RectangleF(1.5f, 1.5f, 38, 38), 4);
|
||||
context.SaveState();
|
||||
context.SetShadowWithColor(dropShadowOffset, dropShadowBlurRadius, dropShadow);
|
||||
context.BeginTransparencyLayer(null);
|
||||
roundedRectanglePath.AddClip();
|
||||
context.DrawLinearGradient(greyGradient, new PointF(20.5f, 1.5f), new PointF(20.5f, 39.5f), 0);
|
||||
context.EndTransparencyLayer();
|
||||
context.RestoreState();
|
||||
|
||||
UIColor.Black.SetStroke();
|
||||
roundedRectanglePath.LineWidth = 1;
|
||||
roundedRectanglePath.Stroke();
|
||||
|
||||
|
||||
//// Rounded Rectangle 2 Drawing
|
||||
var roundedRectangle2Path = UIBezierPath.FromRoundedRect(new RectangleF(2, 28, 37, 11), UIRectCorner.BottomLeft | UIRectCorner.BottomRight, new SizeF(4, 4));
|
||||
dateRed.SetFill();
|
||||
roundedRectangle2Path.Fill();
|
||||
|
||||
|
||||
|
||||
//// Text Drawing
|
||||
var textRect = new RectangleF(2, 0, 37, 28);
|
||||
UIColor.Black.SetFill();
|
||||
new NSString(textContent).DrawString(textRect, UIFont.FromName("Helvetica-Bold", 24), UILineBreakMode.WordWrap, UITextAlignment.Center);
|
||||
|
||||
|
||||
//// Text 2 Drawing
|
||||
var text2Rect = new RectangleF(2, 27, 37, 15);
|
||||
UIColor.White.SetFill();
|
||||
new NSString(text2Content).DrawString(text2Rect, UIFont.FromName("HelveticaNeue-Bold", 9), UILineBreakMode.WordWrap, UITextAlignment.Center);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------- END PAINTCODE ----------------
|
||||
|
||||
var converted = UIGraphics.GetImageFromCurrentImageContext ();
|
||||
UIGraphics.EndImageContext ();
|
||||
return converted;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.Dialog;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PaintCode
|
||||
{
|
||||
public class NewsDialogViewController : DialogViewController
|
||||
{
|
||||
List<Tuple<DateTime,string>> newsItems = new List<Tuple<DateTime, string>> {
|
||||
new Tuple<DateTime, string> (new DateTime(2012,07,04), "Fireworks"),
|
||||
new Tuple<DateTime, string> (new DateTime(2012,05,01), "S-O-S"),
|
||||
new Tuple<DateTime, string> (new DateTime(2012,02,29), "Is it a leap year?")
|
||||
};
|
||||
|
||||
public NewsDialogViewController () : base (UITableViewStyle.Plain, null)
|
||||
{
|
||||
View.BackgroundColor = UIColor.White;
|
||||
TableView.BackgroundColor = UIColor.White;
|
||||
|
||||
var section = new Section ();
|
||||
// creates the rows using MT.Dialog
|
||||
|
||||
foreach (var item in newsItems) {
|
||||
var published = item.Item1;
|
||||
var image = CustomBadgeElement.MakeCalendarBadge (
|
||||
published.ToString ("MMM").ToUpper ()
|
||||
, published.ToString ("dd"));
|
||||
var badgeRow = new BadgeElement (image, item.Item2);
|
||||
|
||||
badgeRow.Tapped += () => {
|
||||
var dv = new DrawingViewController ();
|
||||
NavigationController.PushViewController (dv, true);
|
||||
};
|
||||
section.Add (badgeRow);
|
||||
}
|
||||
Root = new RootElement ("PaintCode examples") { section };
|
||||
}
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 141 KiB |
После Ширина: | Высота: | Размер: 638 KiB |
|
@ -0,0 +1,251 @@
|
|||
using System;
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.CoreGraphics;
|
||||
using System.Drawing;
|
||||
using MonoTouch.Foundation;
|
||||
|
||||
namespace PaintCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Blue button example
|
||||
/// http://paintcodeapp.com/examples.html
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This implementation only deals with Normal and Pressed states.
|
||||
/// There is no handling for the Disabled state.
|
||||
/// </remarks>
|
||||
public class GlossyButton : UIButton {
|
||||
|
||||
bool isPressed;
|
||||
|
||||
public UIColor NormalColor;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the user touches
|
||||
/// </summary>
|
||||
public event Action<GlossyButton> Tapped;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the GlassButton using the specified dimensions
|
||||
/// </summary>
|
||||
public GlossyButton (RectangleF frame) : base (frame)
|
||||
{
|
||||
NormalColor = UIColor.FromRGBA (0.82f, 0.11f, 0.14f, 1.00f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the button is rendered enabled or not.
|
||||
/// </summary>
|
||||
public override bool Enabled {
|
||||
get {
|
||||
return base.Enabled;
|
||||
}
|
||||
set {
|
||||
base.Enabled = value;
|
||||
SetNeedsDisplay ();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool BeginTracking (UITouch uitouch, UIEvent uievent)
|
||||
{
|
||||
SetNeedsDisplay ();
|
||||
isPressed = true;
|
||||
return base.BeginTracking (uitouch, uievent);
|
||||
}
|
||||
|
||||
public override void EndTracking (UITouch uitouch, UIEvent uievent)
|
||||
{
|
||||
if (isPressed && Enabled){
|
||||
if (Tapped != null)
|
||||
Tapped (this);
|
||||
}
|
||||
isPressed = false;
|
||||
SetNeedsDisplay ();
|
||||
base.EndTracking (uitouch, uievent);
|
||||
}
|
||||
|
||||
public override bool ContinueTracking (UITouch uitouch, UIEvent uievent)
|
||||
{
|
||||
var touch = uievent.AllTouches.AnyObject as UITouch;
|
||||
if (Bounds.Contains (touch.LocationInView (this)))
|
||||
isPressed = true;
|
||||
else
|
||||
isPressed = false;
|
||||
return base.ContinueTracking (uitouch, uievent);
|
||||
}
|
||||
|
||||
public override void Draw (RectangleF rect)
|
||||
{
|
||||
var context = UIGraphics.GetCurrentContext ();
|
||||
var bounds = Bounds;
|
||||
|
||||
//UIColor background = Enabled ? isPressed ? HighlightedColor : NormalColor : DisabledColor;
|
||||
|
||||
|
||||
UIColor buttonColor = NormalColor; //UIColor.FromRGBA (0.00f, 0.37f, 0.89f, 1.00f);
|
||||
var buttonColorRGBA = new float[4];
|
||||
buttonColor.GetRGBA (
|
||||
out buttonColorRGBA [0],
|
||||
out buttonColorRGBA [1],
|
||||
out buttonColorRGBA [2],
|
||||
out buttonColorRGBA [3]
|
||||
);
|
||||
if (isPressed) {
|
||||
// Get the Hue Saturation Brightness Alpha copy of the color
|
||||
var buttonColorHSBA = new float[4];
|
||||
buttonColor.GetHSBA (
|
||||
out buttonColorHSBA [0],
|
||||
out buttonColorHSBA [1],
|
||||
out buttonColorHSBA [2],
|
||||
out buttonColorHSBA [3]
|
||||
);
|
||||
// Change the brightness to a fixed value (0.5f)
|
||||
buttonColor = UIColor.FromHSBA (buttonColorHSBA [0], buttonColorHSBA [1], 0.5f, buttonColorHSBA [3]);
|
||||
// Re-set the base buttonColorRGBA because everything else is relative to it
|
||||
buttonColorRGBA = new float[4];
|
||||
buttonColor.GetRGBA (
|
||||
out buttonColorRGBA [0],
|
||||
out buttonColorRGBA [1],
|
||||
out buttonColorRGBA [2],
|
||||
out buttonColorRGBA [3]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
using (var colorSpace = CGColorSpace.CreateDeviceRGB ()) {
|
||||
|
||||
|
||||
//// Abstracted Graphic Attributes
|
||||
var textContent = this.Title (UIControlState.Normal); //"STOP";
|
||||
var font = UIFont.SystemFontOfSize (18);
|
||||
// ------------- START PAINTCODE -------------
|
||||
|
||||
|
||||
|
||||
//// Color Declarations
|
||||
UIColor frameColorTop = UIColor.FromRGBA (0.20f, 0.20f, 0.20f, 1.00f);
|
||||
UIColor frameShadowColor = UIColor.FromRGBA (1.00f, 1.00f, 1.00f, 0.40f);
|
||||
|
||||
UIColor glossyColorBottom = UIColor.FromRGBA (
|
||||
(buttonColorRGBA [0] * 0.6f + 0.4f),
|
||||
(buttonColorRGBA [1] * 0.6f + 0.4f),
|
||||
(buttonColorRGBA [2] * 0.6f + 0.4f),
|
||||
(buttonColorRGBA [3] * 0.6f + 0.4f)
|
||||
);
|
||||
UIColor glossyColorUp = UIColor.FromRGBA (
|
||||
(buttonColorRGBA [0] * 0.2f + 0.8f),
|
||||
(buttonColorRGBA [1] * 0.2f + 0.8f),
|
||||
(buttonColorRGBA [2] * 0.2f + 0.8f),
|
||||
(buttonColorRGBA [3] * 0.2f + 0.8f)
|
||||
);
|
||||
|
||||
//// Gradient Declarations
|
||||
var glossyGradientColors = new CGColor [] {glossyColorUp.CGColor, glossyColorBottom.CGColor};
|
||||
var glossyGradientLocations = new float [] {0, 1};
|
||||
var glossyGradient = new CGGradient (colorSpace, glossyGradientColors, glossyGradientLocations);
|
||||
|
||||
//// Shadow Declarations
|
||||
var frameInnerShadow = frameShadowColor.CGColor;
|
||||
var frameInnerShadowOffset = new SizeF (0, -0);
|
||||
var frameInnerShadowBlurRadius = 3;
|
||||
var buttonInnerShadow = UIColor.Black.CGColor;
|
||||
var buttonInnerShadowOffset = new SizeF (0, -0);
|
||||
var buttonInnerShadowBlurRadius = 12;
|
||||
var textShadow = UIColor.Black.CGColor;
|
||||
var textShadowOffset = new SizeF (0, -0);
|
||||
var textShadowBlurRadius = 1;
|
||||
var buttonShadow = UIColor.Black.CGColor;
|
||||
|
||||
var buttonShadowOffset = new SizeF (0, isPressed ? 0 : 2); // ADDED this code after PaintCode
|
||||
var buttonShadowBlurRadius = isPressed ? 2 : 3; // ADDED this code after PaintCode
|
||||
|
||||
|
||||
|
||||
|
||||
//// outerFrame Drawing
|
||||
var outerFramePath = UIBezierPath.FromRoundedRect(new RectangleF(2.5f, 1.5f, 120, 32), 8);
|
||||
context.SaveState();
|
||||
context.SetShadowWithColor(buttonShadowOffset, buttonShadowBlurRadius, buttonShadow);
|
||||
frameColorTop.SetFill();
|
||||
outerFramePath.Fill();
|
||||
context.RestoreState();
|
||||
|
||||
UIColor.Black.SetStroke();
|
||||
outerFramePath.LineWidth = 1;
|
||||
outerFramePath.Stroke();
|
||||
|
||||
|
||||
//// innerFrame Drawing
|
||||
var innerFramePath = UIBezierPath.FromRoundedRect(new RectangleF(5.5f, 4.5f, 114, 26), 5);
|
||||
context.SaveState();
|
||||
context.SetShadowWithColor(frameInnerShadowOffset, frameInnerShadowBlurRadius, frameInnerShadow);
|
||||
buttonColor.SetFill();
|
||||
innerFramePath.Fill();
|
||||
|
||||
////// innerFrame Inner Shadow
|
||||
var innerFrameBorderRect = innerFramePath.Bounds;
|
||||
innerFrameBorderRect.Inflate(buttonInnerShadowBlurRadius, buttonInnerShadowBlurRadius);
|
||||
innerFrameBorderRect.Offset(-buttonInnerShadowOffset.Width, -buttonInnerShadowOffset.Height);
|
||||
innerFrameBorderRect = RectangleF.Union(innerFrameBorderRect, innerFramePath.Bounds);
|
||||
innerFrameBorderRect.Inflate(1, 1);
|
||||
|
||||
var innerFrameNegativePath = UIBezierPath.FromRect(innerFrameBorderRect);
|
||||
innerFrameNegativePath.AppendPath(innerFramePath);
|
||||
innerFrameNegativePath.UsesEvenOddFillRule = true;
|
||||
|
||||
context.SaveState();
|
||||
{
|
||||
var xOffset = buttonInnerShadowOffset.Width + (float)Math.Round(innerFrameBorderRect.Width);
|
||||
var yOffset = buttonInnerShadowOffset.Height;
|
||||
context.SetShadowWithColor(
|
||||
new SizeF(xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)),
|
||||
buttonInnerShadowBlurRadius,
|
||||
buttonInnerShadow);
|
||||
|
||||
innerFramePath.AddClip();
|
||||
var transform = CGAffineTransform.MakeTranslation(-(float)Math.Round(innerFrameBorderRect.Width), 0);
|
||||
innerFrameNegativePath.ApplyTransform(transform);
|
||||
UIColor.Gray.SetFill();
|
||||
innerFrameNegativePath.Fill();
|
||||
}
|
||||
context.RestoreState();
|
||||
|
||||
context.RestoreState();
|
||||
|
||||
UIColor.Black.SetStroke();
|
||||
innerFramePath.LineWidth = 1;
|
||||
innerFramePath.Stroke();
|
||||
|
||||
|
||||
//// Rounded Rectangle Drawing
|
||||
var roundedRectanglePath = UIBezierPath.FromRoundedRect(new RectangleF(8, 6, 109, 9), 4);
|
||||
context.SaveState();
|
||||
roundedRectanglePath.AddClip();
|
||||
context.DrawLinearGradient(glossyGradient, new PointF(62.5f, 6), new PointF(62.5f, 15), 0);
|
||||
context.RestoreState();
|
||||
|
||||
|
||||
|
||||
//// Text Drawing
|
||||
var textRect = new RectangleF(18, 6, 90, 28);
|
||||
context.SaveState();
|
||||
context.SetShadowWithColor(textShadowOffset, textShadowBlurRadius, textShadow);
|
||||
glossyColorUp.SetFill();
|
||||
|
||||
// Use default button-drawn text
|
||||
//new NSString(textContent).DrawString(textRect, font, UILineBreakMode.WordWrap, UITextAlignment.Center);
|
||||
context.RestoreState();
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------- END PAINTCODE -------------
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using MonoTouch.UIKit;
|
||||
using System.Drawing;
|
||||
|
||||
namespace PaintCode
|
||||
{
|
||||
public class GlossyButtonViewController : UIViewController
|
||||
{
|
||||
public GlossyButtonViewController ()
|
||||
{
|
||||
}
|
||||
|
||||
GlossyButton button;
|
||||
UITextView text;
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
|
||||
View.BackgroundColor = UIColor.White;
|
||||
|
||||
button = new GlossyButton (new RectangleF (30, 30, 130, 38));
|
||||
button.SetTitle ("Stop!", UIControlState.Normal);
|
||||
|
||||
button.Tapped += (obj) => {
|
||||
new UIAlertView ("Tapped", "Button tapped", null, "OK", null).Show ();
|
||||
};
|
||||
|
||||
View.AddSubview (button);
|
||||
|
||||
|
||||
text = new UITextView (new Rectangle (10, 100, 300, 300));
|
||||
text.Font = UIFont.SystemFontOfSize (14f);
|
||||
text.Editable = false;
|
||||
text.Text = "PaintCode GlossyButton Example\n\n"
|
||||
+"After the button is drawn in PaintCode then added to a UIButton subclass "
|
||||
+"Draw() method override, some color/style properties are tweaked in code "
|
||||
+"to create the TouchDown effect.\n\n"
|
||||
+"The button is sized exactly so that the 'built-in' UIButton.Title "
|
||||
+"is displayed in the center of the PaintCode-generated design.";
|
||||
View.AddSubview (text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Двоичные данные
PaintCode/PaintCodeDemo/GlossyButton/glossyButton.paintcode/QuickLook/Preview.pdf
Normal file
Двоичные данные
PaintCode/PaintCodeDemo/GlossyButton/glossyButton.paintcode/content.pcode
Normal file
После Ширина: | Высота: | Размер: 20 KiB |
После Ширина: | Высота: | Размер: 2.9 KiB |
После Ширина: | Высота: | Размер: 5.8 KiB |
После Ширина: | Высота: | Размер: 318 KiB |
После Ширина: | Высота: | Размер: 7.1 KiB |
После Ширина: | Высота: | Размер: 7.3 KiB |
После Ширина: | Высота: | Размер: 10 KiB |
После Ширина: | Высота: | Размер: 2.0 KiB |
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>Images/Icons/57_icon.png</string>
|
||||
<string>Images/Icons/114_icon.png</string>
|
||||
<string>Images/Icons/72_icon.png</string>
|
||||
<string>Images/Icons/29_icon.png</string>
|
||||
<string>Images/Icons/58_icon.png</string>
|
||||
<string>Images/Icons/50_icon.png</string>
|
||||
</array>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,338 @@
|
|||
using System;
|
||||
using MonoTouch.UIKit;
|
||||
using System.Drawing;
|
||||
using MonoTouch.CoreGraphics;
|
||||
using MonoTouch.Foundation;
|
||||
|
||||
namespace PaintCode
|
||||
{
|
||||
// http://mikebluestein.wordpress.com/2010/02/21/drawing-with-coregraphics-in-monotouch-2/
|
||||
public class DrawingView : UIView
|
||||
{
|
||||
public DrawingView ()
|
||||
{
|
||||
BackgroundColor = UIColor.White;
|
||||
}
|
||||
|
||||
public DrawingView (IntPtr p) : base(p)
|
||||
{
|
||||
BackgroundColor = UIColor.White;
|
||||
}
|
||||
|
||||
public override void Draw (RectangleF rect)
|
||||
{
|
||||
base.Draw (rect);
|
||||
|
||||
// ------------- START PAINTCODE ----------------
|
||||
|
||||
|
||||
//// General Declarations
|
||||
var colorSpace = CGColorSpace.CreateDeviceRGB ();
|
||||
var context = UIGraphics.GetCurrentContext ();
|
||||
|
||||
//// Color Declarations
|
||||
UIColor gold = UIColor.FromRGBA (1.00f, 0.95f, 0.57f, 1.00f);
|
||||
UIColor brown = UIColor.FromRGBA (0.79f, 0.75f, 0.18f, 1.00f);
|
||||
UIColor lightBrown = UIColor.FromRGBA (0.69f, 0.57f, 0.23f, 1.00f);
|
||||
UIColor darkishBlue = UIColor.FromRGBA (0.20f, 0.39f, 0.98f, 1.00f);
|
||||
UIColor bottomColorDown = UIColor.FromRGBA (0.21f, 0.21f, 0.21f, 1.00f);
|
||||
|
||||
//// Gradient Declarations
|
||||
var newGradientColors = new CGColor [] {UIColor.Black.CGColor, UIColor.White.CGColor};
|
||||
var newGradientLocations = new float [] {0, 1};
|
||||
var newGradient = new CGGradient (colorSpace, newGradientColors, newGradientLocations);
|
||||
var calendarGradientColors = new CGColor [] {
|
||||
UIColor.DarkGray.CGColor,
|
||||
UIColor.FromRGBA (0.72f, 0.72f, 0.72f, 1.00f).CGColor,
|
||||
UIColor.White.CGColor
|
||||
};
|
||||
var calendarGradientLocations = new float [] {0, 0.26f, 0.26f};
|
||||
var calendarGradient = new CGGradient (colorSpace, calendarGradientColors, calendarGradientLocations);
|
||||
|
||||
//// Shadow Declarations
|
||||
var shadow = UIColor.DarkGray.CGColor;
|
||||
var shadowOffset = new SizeF (2, 2);
|
||||
var shadowBlurRadius = 2;
|
||||
|
||||
//// Abstracted Graphic Attributes
|
||||
var monthContent = "MAR";
|
||||
var dayContent = "24";
|
||||
var dayFont = UIFont.FromName ("Helvetica-Bold", 24);
|
||||
var textContent = "News Headline";
|
||||
|
||||
|
||||
//// Oval 11 Drawing
|
||||
var oval11Path = UIBezierPath.FromOval (new RectangleF (256.5f, 46.5f, 13, 14));
|
||||
lightBrown.SetFill ();
|
||||
oval11Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval11Path.LineWidth = 1;
|
||||
oval11Path.Stroke ();
|
||||
|
||||
|
||||
//// Oval 12 Drawing
|
||||
var oval12Path = UIBezierPath.FromOval (new RectangleF (280.5f, 46.5f, 13, 14));
|
||||
lightBrown.SetFill ();
|
||||
oval12Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval12Path.LineWidth = 1;
|
||||
oval12Path.Stroke ();
|
||||
|
||||
|
||||
//// Rounded Rectangle Drawing
|
||||
var roundedRectanglePath = UIBezierPath.FromRoundedRect (new RectangleF (8.5f, 60.5f, 37, 36), 4);
|
||||
context.SaveState ();
|
||||
context.SetShadowWithColor (shadowOffset, shadowBlurRadius, shadow);
|
||||
context.BeginTransparencyLayer (null);
|
||||
roundedRectanglePath.AddClip ();
|
||||
context.DrawLinearGradient (calendarGradient, new PointF (27, 96.5f), new PointF (27, 60.5f), 0);
|
||||
context.EndTransparencyLayer ();
|
||||
context.RestoreState ();
|
||||
|
||||
UIColor.DarkGray.SetStroke ();
|
||||
roundedRectanglePath.LineWidth = 1;
|
||||
roundedRectanglePath.Stroke ();
|
||||
|
||||
|
||||
//// Rounded Rectangle 3 Drawing
|
||||
UIBezierPath roundedRectangle3Path = new UIBezierPath ();
|
||||
roundedRectangle3Path.MoveTo (new PointF (9, 91.2f));
|
||||
roundedRectangle3Path.AddCurveToPoint (new PointF (12.56f, 95), new PointF (9, 93.3f), new PointF (10.32f, 95));
|
||||
roundedRectangle3Path.AddLineTo (new PointF (40.94f, 95));
|
||||
roundedRectangle3Path.AddCurveToPoint (new PointF (45, 91.2f), new PointF (43.18f, 95), new PointF (45, 93.3f));
|
||||
roundedRectangle3Path.AddLineTo (new PointF (45, 87));
|
||||
roundedRectangle3Path.AddCurveToPoint (new PointF (43.42f, 85.5f), new PointF (45, 84.9f), new PointF (45.66f, 85.5f));
|
||||
roundedRectangle3Path.AddLineTo (new PointF (10.94f, 85.5f));
|
||||
roundedRectangle3Path.AddCurveToPoint (new PointF (9, 87), new PointF (8.7f, 85.5f), new PointF (9, 84.9f));
|
||||
roundedRectangle3Path.AddLineTo (new PointF (9, 91.2f));
|
||||
roundedRectangle3Path.ClosePath ();
|
||||
UIColor.Red.SetFill ();
|
||||
roundedRectangle3Path.Fill ();
|
||||
|
||||
|
||||
|
||||
//// Month Drawing
|
||||
var monthRect = new RectangleF (10, 84, 34, 15);
|
||||
UIColor.White.SetFill ();
|
||||
new NSString (monthContent).DrawString (
|
||||
monthRect,
|
||||
UIFont.FromName("Helvetica-Bold", 9),
|
||||
UILineBreakMode.WordWrap,
|
||||
UITextAlignment.Center
|
||||
);
|
||||
|
||||
|
||||
//// Day Drawing
|
||||
var dayRect = new RectangleF (0, 58, 54, 31);
|
||||
UIColor.Black.SetFill ();
|
||||
new NSString (dayContent).DrawString (dayRect, dayFont, UILineBreakMode.WordWrap, UITextAlignment.Center);
|
||||
|
||||
|
||||
//// Text Drawing
|
||||
var textRect = new RectangleF (54, 60, 75, 38);
|
||||
UIColor.Black.SetFill ();
|
||||
new NSString (textContent).DrawString (
|
||||
textRect,
|
||||
UIFont.FromName("Helvetica", 16),
|
||||
UILineBreakMode.WordWrap,
|
||||
UITextAlignment.Left
|
||||
);
|
||||
|
||||
|
||||
//// Star Drawing
|
||||
UIBezierPath starPath = new UIBezierPath ();
|
||||
starPath.MoveTo (new PointF (31, 14.5f));
|
||||
starPath.AddLineTo (new PointF (26.24f, 21.45f));
|
||||
starPath.AddLineTo (new PointF (18.16f, 23.83f));
|
||||
starPath.AddLineTo (new PointF (23.3f, 30.5f));
|
||||
starPath.AddLineTo (new PointF (23.06f, 38.92f));
|
||||
starPath.AddLineTo (new PointF (31, 36.1f));
|
||||
starPath.AddLineTo (new PointF (38.94f, 38.92f));
|
||||
starPath.AddLineTo (new PointF (38.7f, 30.5f));
|
||||
starPath.AddLineTo (new PointF (43.84f, 23.83f));
|
||||
starPath.AddLineTo (new PointF (35.76f, 21.45f));
|
||||
starPath.ClosePath ();
|
||||
gold.SetFill ();
|
||||
starPath.Fill ();
|
||||
|
||||
brown.SetStroke ();
|
||||
starPath.LineWidth = 1;
|
||||
starPath.Stroke ();
|
||||
|
||||
|
||||
//// Blue blob Drawing
|
||||
UIBezierPath blueBlobPath = new UIBezierPath ();
|
||||
blueBlobPath.MoveTo (new PointF (256.5f, 16.5f));
|
||||
blueBlobPath.AddCurveToPoint (new PointF (240.5f, 41.5f), new PointF (235.5f, 37.5f), new PointF (217.53f, 41.55f));
|
||||
blueBlobPath.AddCurveToPoint (new PointF (265.5f, 30.5f), new PointF (263.47f, 41.45f), new PointF (265.5f, 30.5f));
|
||||
blueBlobPath.AddCurveToPoint (new PointF (256.5f, 16.5f), new PointF (265.5f, 30.5f), new PointF (277.5f, -4.5f));
|
||||
blueBlobPath.ClosePath ();
|
||||
blueBlobPath.MiterLimit = 2;
|
||||
blueBlobPath.LineJoinStyle = CGLineJoin.Round;
|
||||
darkishBlue.SetFill ();
|
||||
blueBlobPath.Fill ();
|
||||
|
||||
bottomColorDown.SetStroke ();
|
||||
blueBlobPath.LineWidth = 1;
|
||||
blueBlobPath.Stroke ();
|
||||
|
||||
|
||||
//// Button Drawing
|
||||
var buttonPath = UIBezierPath.FromRoundedRect (new RectangleF (54.5f, 10.5f, 163, 31), 4);
|
||||
context.SaveState ();
|
||||
buttonPath.AddClip ();
|
||||
context.DrawRadialGradient (newGradient,
|
||||
new PointF (100.39f, 55.13f), 7.84f,
|
||||
new PointF (136, 26), 86.67f,
|
||||
CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
|
||||
context.RestoreState ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
buttonPath.LineWidth = 1;
|
||||
buttonPath.Stroke ();
|
||||
|
||||
|
||||
//// Smiley face Drawing
|
||||
var smileyFacePath = UIBezierPath.FromOval (new RectangleF (159.5f, 49.5f, 47, 47));
|
||||
gold.SetFill ();
|
||||
smileyFacePath.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
smileyFacePath.LineWidth = 1;
|
||||
smileyFacePath.Stroke ();
|
||||
|
||||
|
||||
//// Oval 2 Drawing
|
||||
var oval2Path = UIBezierPath.FromOval (new RectangleF (169.5f, 64.5f, 8, 8));
|
||||
UIColor.Black.SetFill ();
|
||||
oval2Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval2Path.LineWidth = 1;
|
||||
oval2Path.Stroke ();
|
||||
|
||||
|
||||
//// Oval 3 Drawing
|
||||
var oval3Path = UIBezierPath.FromOval (new RectangleF (188.5f, 64.5f, 8, 8));
|
||||
UIColor.Black.SetFill ();
|
||||
oval3Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval3Path.LineWidth = 1;
|
||||
oval3Path.Stroke ();
|
||||
|
||||
|
||||
//// Bezier 2 Drawing
|
||||
UIBezierPath bezier2Path = new UIBezierPath ();
|
||||
bezier2Path.MoveTo (new PointF (172.5f, 80.5f));
|
||||
bezier2Path.AddCurveToPoint (new PointF (185.5f, 85.5f), new PointF (177.75f, 85), new PointF (182.04f, 86.03f));
|
||||
bezier2Path.AddCurveToPoint (new PointF (194.5f, 79.5f), new PointF (191.27f, 84.62f), new PointF (194.5f, 79.5f));
|
||||
UIColor.Black.SetStroke ();
|
||||
bezier2Path.LineWidth = 2;
|
||||
bezier2Path.Stroke ();
|
||||
|
||||
|
||||
//// Oval 5 Drawing
|
||||
var oval5Path = UIBezierPath.FromOval (new RectangleF (256.5f, 52.5f, 36, 33));
|
||||
lightBrown.SetFill ();
|
||||
oval5Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval5Path.LineWidth = 1;
|
||||
oval5Path.Stroke ();
|
||||
|
||||
|
||||
//// Oval 6 Drawing
|
||||
var oval6Path = UIBezierPath.FromOval (new RectangleF (262.5f, 59.5f, 10, 19));
|
||||
UIColor.White.SetFill ();
|
||||
oval6Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval6Path.LineWidth = 1;
|
||||
oval6Path.Stroke ();
|
||||
|
||||
|
||||
//// Oval 7 Drawing
|
||||
var oval7Path = UIBezierPath.FromOval (new RectangleF (275.5f, 59.5f, 10, 19));
|
||||
UIColor.White.SetFill ();
|
||||
oval7Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval7Path.LineWidth = 1;
|
||||
oval7Path.Stroke ();
|
||||
|
||||
|
||||
//// Oval 9 Drawing
|
||||
var oval9Path = UIBezierPath.FromOval (new RectangleF (264.5f, 68.5f, 6, 5));
|
||||
UIColor.Black.SetFill ();
|
||||
oval9Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval9Path.LineWidth = 1;
|
||||
oval9Path.Stroke ();
|
||||
|
||||
|
||||
//// Oval 10 Drawing
|
||||
var oval10Path = UIBezierPath.FromOval (new RectangleF (277.5f, 68.5f, 6, 5));
|
||||
UIColor.Black.SetFill ();
|
||||
oval10Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval10Path.LineWidth = 1;
|
||||
oval10Path.Stroke ();
|
||||
|
||||
|
||||
//// Oval 4 Drawing
|
||||
var oval4Path = UIBezierPath.FromOval (new RectangleF (250.5f, 70.5f, 47, 24));
|
||||
lightBrown.SetFill ();
|
||||
oval4Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval4Path.LineWidth = 1;
|
||||
oval4Path.Stroke ();
|
||||
|
||||
|
||||
//// Oval 8 Drawing
|
||||
var oval8Path = UIBezierPath.FromOval (new RectangleF (267.5f, 77.5f, 9, 4));
|
||||
UIColor.Black.SetFill ();
|
||||
oval8Path.Fill ();
|
||||
|
||||
UIColor.Black.SetStroke ();
|
||||
oval8Path.LineWidth = 1;
|
||||
oval8Path.Stroke ();
|
||||
|
||||
|
||||
//// Bezier 5 Drawing
|
||||
UIBezierPath bezier5Path = new UIBezierPath ();
|
||||
bezier5Path.MoveTo (new PointF (270.5f, 81.5f));
|
||||
bezier5Path.AddCurveToPoint (new PointF (267.5f, 88.5f), new PointF (269.5f, 85.5f), new PointF (267.5f, 88.5f));
|
||||
UIColor.Black.SetStroke ();
|
||||
bezier5Path.LineWidth = 1;
|
||||
bezier5Path.Stroke ();
|
||||
|
||||
|
||||
//// Bezier 6 Drawing
|
||||
UIBezierPath bezier6Path = new UIBezierPath ();
|
||||
bezier6Path.MoveTo (new PointF (272.5f, 81.5f));
|
||||
bezier6Path.AddLineTo (new PointF (274.5f, 87.5f));
|
||||
UIColor.Black.SetStroke ();
|
||||
bezier6Path.LineWidth = 1;
|
||||
bezier6Path.Stroke ();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ------------- END PAINTCODE ----------------
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using MonoTouch.UIKit;
|
||||
using System.Drawing;
|
||||
|
||||
namespace PaintCode
|
||||
{
|
||||
public class DrawingViewController : UIViewController
|
||||
{
|
||||
public DrawingViewController ()
|
||||
{
|
||||
}
|
||||
|
||||
UIView drawing;
|
||||
UITextView text;
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
|
||||
drawing = new DrawingView ();
|
||||
drawing.Frame = new System.Drawing.RectangleF (0, 0, 320, 640);
|
||||
|
||||
View.AddSubview (drawing);
|
||||
|
||||
|
||||
text = new UITextView (new Rectangle (10, 150, 300, 300));
|
||||
text.Font = UIFont.SystemFontOfSize (14f);
|
||||
text.Editable = false;
|
||||
text.Text = "Xamarin Shapes Example\n\n"+
|
||||
"These are a few random shapes drawn with PaintCode and rendered in a UIView\n\n"
|
||||
+"http://www.paintcodeapp.com/";
|
||||
View.AddSubview (text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}</ProjectGuid>
|
||||
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>PaintCode</RootNamespace>
|
||||
<AssemblyName>PaintCode</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<MtouchProfiling>true</MtouchProfiling>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchI18n />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<MtouchProfiling>true</MtouchProfiling>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="monotouch" />
|
||||
<Reference Include="MonoTouch.Dialog-1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="Calendar\CustomBadgeElement.cs" />
|
||||
<Compile Include="LineArt\DrawingViewController.cs" />
|
||||
<Compile Include="Calendar\NewsDialogViewController.cs" />
|
||||
<Compile Include="LineArt\DrawingView.cs" />
|
||||
<Compile Include="BlueButton\BlueButton.cs" />
|
||||
<Compile Include="BlueButton\BlueButtonViewController.cs" />
|
||||
<Compile Include="GlossyButton\GlossyButton.cs" />
|
||||
<Compile Include="GlossyButton\GlossyButtonViewController.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<Folder Include="LineArt\" />
|
||||
<Folder Include="Calendar\" />
|
||||
<Folder Include="BlueButton\" />
|
||||
<Folder Include="GlossyButton\" />
|
||||
<Folder Include="Images\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Default.png" />
|
||||
<Content Include="Default%402x.png" />
|
||||
<Content Include="Images\Icons\114_icon.png" />
|
||||
<Content Include="Images\Icons\29_icon.png" />
|
||||
<Content Include="Images\Icons\50_icon.png" />
|
||||
<Content Include="Images\Icons\512_icon.png" />
|
||||
<Content Include="Images\Icons\57_icon.png" />
|
||||
<Content Include="Images\Icons\58_icon.png" />
|
||||
<Content Include="Images\Icons\72_icon.png" />
|
||||
<Content Include="Images\about%402x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ITunesArtwork Include="iTunesArtwork" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaintCode", "PaintCode.csproj", "{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||
Debug|iPhone = Debug|iPhone
|
||||
Release|iPhone = Release|iPhone
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{4A2801EE-58EC-4A5E-84DB-48C46A71ADC8}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = PaintCode.csproj
|
||||
EndGlobalSection
|
||||
EndGlobal
|
После Ширина: | Высота: | Размер: 318 KiB |
|
@ -0,0 +1,25 @@
|
|||
PaintCode Demo
|
||||
==============
|
||||
|
||||
PaintCode (http://www.paintcodeapp.com) now supports C# code generation for Xamarin MonoTouch.
|
||||
|
||||
This sample app shows some PaintCode-generated elements:
|
||||
|
||||
* Calendar badge
|
||||
|
||||
* Blue button
|
||||
|
||||
* Glossy button
|
||||
|
||||
* Random line-art
|
||||
|
||||
See also http://blog.xamarin.com/2012/06/06/meet-our-new-favorite-design-tool-paintcode/
|
||||
|
||||
![screenshot](https://github.com/xamarin/monotouch-samples/raw/master/PaintCode/Screenshots/BlueButton.png "BlueButton Example")
|
||||
![screenshot](https://github.com/xamarin/monotouch-samples/raw/master/PaintCode/Screenshots/GlossyButton.png "GlossyButton Example")
|
||||
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
Craig Dunn
|
После Ширина: | Высота: | Размер: 31 KiB |
После Ширина: | Высота: | Размер: 23 KiB |
После Ширина: | Высота: | Размер: 33 KiB |
После Ширина: | Высота: | Размер: 32 KiB |