Permalink
Browse files

Added AtmHud sample

  • Loading branch information...
1 parent 2ceb43d commit 73003806af3c4d8b50e7d378c5c677f70a1a214f @migueldeicaza migueldeicaza committed Dec 20, 2011
View
@@ -6,7 +6,7 @@
using MonoTouch.CoreAnimation;
using MonoTouch.UIKit;
-namespace ATMHud {
+namespace MonoTouch.AtmHud {
//@interface ATMHud : UIViewController {
[BaseType (typeof (UIViewController), Name="ATMHud", Delegates=new string [] { "WeakDelegate" }, Events=new Type [] { typeof (AtmHudDelegate)})]
interface AtmHud {
@@ -110,7 +110,7 @@ interface AtmHud {
//- (id)initWithDelegate:(id)hudDelegate;
[Export ("initWithDelegate:")]
- IntPtr Constructor (AtmHudDelegate hudDelegate);
+ IntPtr Constructor ([NullAllowed] AtmHudDelegate hudDelegate);
#region Methods
@@ -124,8 +124,8 @@ interface AtmHud {
//- (void)setImage:(UIImage *)image;
[Export ("setImage:")]
- void SetImage (UIImage image);
-
+ void SetImage ([NullAllowed] UIImage image);
+
//- (void)setActivity:(BOOL)flag;
[Export ("setActivity:")]
void SetActivity (bool activity);
@@ -238,7 +238,7 @@ interface AtmHudQueueItem {
string Caption { get; set; }
//@property (nonatomic, retain) UIImage *image;
- [Export ("image")]
+ [Export ("image"), NullAllowed]
UIImage Image { get; set; }
//@property (nonatomic, assign) BOOL showActivity;
View
@@ -1,6 +1,6 @@
using System;
-namespace ATMHud {
+namespace MonoTouch.AtmHud {
public enum AtmHudAccessoryPosition {
Top,
Right,
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,194 @@
+//
+// This shows the various capabilities of the
+// AtmHud library
+//
+using System;
+using MonoTouch.Foundation;
+using MonoTouch.UIKit;
+using MonoTouch.Dialog;
+using MonoTouch.AtmHud;
+using System.Drawing;
+
+namespace sample
+{
+ [Register ("AppDelegate")]
+ public partial class AppDelegate : UIApplicationDelegate
+ {
+ UIWindow window;
+ DialogViewController dvc;
+ AtmHud hud;
+ BooleanElement fixedSize;
+
+ void ConfigureHud ()
+ {
+ // Configure the hud
+ hud = new AtmHud ((AtmHudDelegate) null);
+ hud.UserDidTapHud += delegate {
+ hud.Hide ();
+ };
+ window.AddSubview (hud.View);
+ }
+
+ void HudShow ()
+ {
+ if (fixedSize.Value)
+ hud.SetFixedSize (new SizeF (200, 100));
+ else
+ hud.SetFixedSize (new SizeF (0, 0));
+ hud.Show ();
+ }
+
+ void UpdateHud ()
+ {
+ hud.SetCaption ("And now it will hide");
+ hud.SetActivity (false);
+ hud.SetImage (UIImage.FromFile ("19-check.png"));
+ hud.Update ();
+ hud.HideAfter (2);
+ }
+
+ void ShowPosition (AtmHudAccessoryPosition position)
+ {
+ hud.SetCaption (position.ToString ());
+ hud.AccessoryPosition = position;
+ switch (position){
+ case AtmHudAccessoryPosition.Bottom:
+ hud.SetProgress (0.45f);
+ break;
+ case AtmHudAccessoryPosition.Top:
+ hud.SetActivity (true);
+ break;
+ case AtmHudAccessoryPosition.Left:
+ hud.SetImage (UIImage.FromFile ("19-check.png"));
+ break;
+ case AtmHudAccessoryPosition.Right:
+ hud.SetActivity (true);
+ break;
+ }
+ HudShow ();
+ }
+
+ void SetupUI ()
+ {
+ var root = new RootElement ("AtmHud Demo"){
+ new Section ("Basic Functions", "Tap to hide") {
+ new StringElement ("Show with Caption only", delegate {
+ hud.SetCaption ("Very simple caption");
+ HudShow ();
+ }),
+ new StringElement ("Show with caption and activity", delegate {
+ hud.SetCaption ("Caption and activity indicator");
+ hud.SetActivity (true);
+ HudShow ();
+ }),
+ new StringElement ("Show with caption and image", delegate {
+ hud.SetCaption ("Caption and Image");
+ hud.SetImage (UIImage.FromFile ("19-check.png"));
+ HudShow ();
+ }),
+ new StringElement ("Show activity Only", delegate {
+ hud.SetActivity (true);
+ hud.SetActivityStyle (UIActivityIndicatorViewStyle.WhiteLarge);
+ HudShow ();
+ }),
+ new StringElement ("Play sound on show", delegate {
+ hud.SetCaption ("Showing the HUD triggers a sound");
+ hud.ShowSound = "pop.wav";
+ HudShow ();
+ }),
+ },
+ new Section ("Advanced Functions", "Tap to hide is disabled") {
+ new StringElement ("Show and auto-hide", delegate {
+ hud.SetCaption ("This hud will auto-hide in 2 seconds");
+ HudShow ();
+ hud.HideAfter (2);
+ }),
+ new StringElement ("Show, update and auto-hide", delegate {
+ hud.SetCaption ("This hud will update in 2 seconds");
+ hud.SetActivity (true);
+ HudShow ();
+ NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (2), delegate {
+ UpdateHud ();
+ });
+ }),
+ new StringElement ("Show progressbar", delegate {
+ hud.SetCaption ("Performing Operation");
+ float progress = 0.08f;
+ hud.SetProgress (progress);
+ HudShow ();
+ NSTimer timer = null;
+ timer = NSTimer.CreateRepeatingScheduledTimer (TimeSpan.FromMilliseconds (200), delegate {
+ Console.WriteLine ("Here {0}", progress);
+ progress += 0.1f;
+ hud.SetProgress (progress);
+ if (progress >= 1){
+ timer.Invalidate ();
+ timer = null;
+ hud.Hide ();
+ hud.SetProgress (0);
+ }
+ });
+ }),
+ new StringElement ("Show queued HUD", delegate {
+ hud.AddToQueue (new AtmHudQueueItem () {
+ Caption = "Display 1",
+ Image = null,
+ AccessoryPosition = AtmHudAccessoryPosition.Bottom,
+ ShowActivity = false,
+ });
+ hud.AddToQueue (new AtmHudQueueItem () {
+ Caption = "Display 2",
+ Image = null,
+ AccessoryPosition = AtmHudAccessoryPosition.Right,
+ ShowActivity = true,
+ });
+ hud.AddToQueue (new AtmHudQueueItem () {
+ Caption = "Display 3",
+ Image = UIImage.FromFile ("19-check.png"),
+ AccessoryPosition = AtmHudAccessoryPosition.Bottom,
+ ShowActivity = false,
+ });
+ hud.StartQueue ();
+ NSTimer timer = null;
+ int current = 0;
+ timer = NSTimer.CreateRepeatingScheduledTimer (TimeSpan.FromSeconds (2), delegate {
+ hud.ShowNextInQueue ();
+ if (++current == 3){
+ timer.Invalidate ();
+ timer = null;
+ hud.ClearQueue ();
+ }
+ });
+ })
+ },
+ new Section ("Accessory Positioning"){
+ new StringElement ("Top", delegate { ShowPosition (AtmHudAccessoryPosition.Top); }),
+ new StringElement ("Bottom", delegate { ShowPosition (AtmHudAccessoryPosition.Bottom); }),
+ new StringElement ("Left", delegate { ShowPosition (AtmHudAccessoryPosition.Left); }),
+ new StringElement ("Right", delegate { ShowPosition (AtmHudAccessoryPosition.Right); }),
+ },
+ new Section () {
+ (fixedSize = new BooleanElement ("Use fixed size", false)),
+ }
+ };
+ dvc = new DialogViewController (root);
+ window = new UIWindow (UIScreen.MainScreen.Bounds);
+ window.MakeKeyAndVisible ();
+ window.RootViewController = dvc;
+ }
+
+ public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
+ {
+ SetupUI ();
+ ConfigureHud ();
+ return true;
+ }
+
+ static void Main (string[] args)
+ {
+ // if you want to use a different Application Delegate class from "AppDelegate"
+ // you can specify it here.
+ UIApplication.Main (args, null, "AppDelegate");
+ }
+ }
+}
View
@@ -0,0 +1,16 @@
+<?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>UIDeviceFamily</key>
+ <array>
+ <integer>1</integer>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
Binary file not shown.
View
Binary file not shown.
@@ -0,0 +1,81 @@
+<?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>{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}</ProjectGuid>
+ <ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>sample</RootNamespace>
+ <AssemblyName>sample</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>
+ </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="ATMHud">
+ <HintPath>..\binding\ATMHud.dll</HintPath>
+ </Reference>
+ <Reference Include="MonoTouch.Dialog">
+ <HintPath>MonoTouch.Dialog.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Info.plist" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AppDelegate.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <Content Include="19-check.png" />
+ <Content Include="pop.wav" />
+ </ItemGroup>
+</Project>
View
@@ -0,0 +1,26 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sample", "sample.csproj", "{01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}"
+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
+ {01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Debug|iPhone.ActiveCfg = Debug|iPhone
+ {01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Debug|iPhone.Build.0 = Debug|iPhone
+ {01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
+ {01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
+ {01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Release|iPhone.ActiveCfg = Release|iPhone
+ {01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Release|iPhone.Build.0 = Release|iPhone
+ {01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
+ {01A89D4F-C7DF-4B7E-BC28-F86F5BC9E30A}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = sample.csproj
+ EndGlobalSection
+EndGlobal

0 comments on commit 7300380

Please sign in to comment.