Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 9bb7c9d

Browse files
committed
[SimpleLogin]Adding sample for docs purposes
1 parent d55ee0d commit 9bb7c9d

15 files changed

+356
-0
lines changed

SimpleLogin/CodeOnlyProject.sln

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeOnlyDemo", "CodeOnlyProject\CodeOnlyDemo.csproj", "{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|iPhoneSimulator = Debug|iPhoneSimulator
9+
Release|iPhoneSimulator = Release|iPhoneSimulator
10+
Debug|iPhone = Debug|iPhone
11+
Release|iPhone = Release|iPhone
12+
Ad-Hoc|iPhone = Ad-Hoc|iPhone
13+
AppStore|iPhone = AppStore|iPhone
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
17+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
18+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
19+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.AppStore|iPhone.Build.0 = AppStore|iPhone
20+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Debug|iPhone.ActiveCfg = Debug|iPhone
21+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Debug|iPhone.Build.0 = Debug|iPhone
22+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
23+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
24+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Release|iPhone.ActiveCfg = Release|iPhone
25+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Release|iPhone.Build.0 = Release|iPhone
26+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
27+
{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
28+
EndGlobalSection
29+
GlobalSection(MonoDevelopProperties) = preSolution
30+
StartupItem = CodeOnlyProject\CodeOnlyDemo.csproj
31+
EndGlobalSection
32+
EndGlobal
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Foundation;
2+
using UIKit;
3+
4+
namespace CodeOnlyDemo
5+
{
6+
[Register("AppDelegate")]
7+
public partial class AppDelegate : UIApplicationDelegate
8+
{
9+
// class-level declarations
10+
UIWindow window;
11+
12+
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
13+
{
14+
// create a new window instance based on the screen size
15+
window = new UIWindow(UIScreen.MainScreen.Bounds);
16+
17+
var controller = new CustomViewController();
18+
19+
window.RootViewController = controller;
20+
21+
// make the window visible
22+
window.MakeKeyAndVisible();
23+
24+
return true;
25+
}
26+
}
27+
}
28+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using UIKit;
2+
3+
namespace CodeOnlyDemo
4+
{
5+
class CircleController : UIViewController
6+
{
7+
CircleView view;
8+
9+
public override void LoadView()
10+
{
11+
view = new CircleView();
12+
View = view;
13+
}
14+
}
15+
}
16+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using UIKit;
3+
using CoreGraphics;
4+
5+
namespace CodeOnlyDemo
6+
{
7+
class CircleView : UIView
8+
{
9+
public override void Draw(CGRect rect)
10+
{
11+
base.Draw(rect);
12+
13+
//get graphics context
14+
using (var g = UIGraphics.GetCurrentContext())
15+
{
16+
// set up drawing attributes
17+
g.SetLineWidth(10.0f);
18+
UIColor.Green.SetFill();
19+
UIColor.Blue.SetStroke();
20+
21+
// create geometry
22+
var path = new CGPath();
23+
path.AddArc(Bounds.GetMidX(), Bounds.GetMidY(), 50f, 0, 2.0f * (float)Math.PI, true);
24+
25+
// add geometry to graphics context and draw
26+
g.AddPath(path);
27+
g.DrawPath(CGPathDrawingMode.FillStroke);
28+
}
29+
}
30+
31+
public CircleView()
32+
{
33+
BackgroundColor = UIColor.White;
34+
}
35+
}
36+
}
37+
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
6+
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
7+
<ProjectGuid>{DB8B7EBC-51F2-4581-8F85-A930D67C2A1D}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>CodeOnlyDemo</RootNamespace>
10+
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
11+
<AssemblyName>CodeOnlyProject</AssemblyName>
12+
<TargetFrameworkIdentifier>Xamarin.iOS</TargetFrameworkIdentifier>
13+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
14+
</PropertyGroup>
15+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
16+
<DebugSymbols>true</DebugSymbols>
17+
<DebugType>full</DebugType>
18+
<Optimize>false</Optimize>
19+
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
20+
<DefineConstants>DEBUG;</DefineConstants>
21+
<ErrorReport>prompt</ErrorReport>
22+
<WarningLevel>4</WarningLevel>
23+
<ConsolePause>false</ConsolePause>
24+
<MtouchLink>None</MtouchLink>
25+
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
26+
<MtouchDebug>true</MtouchDebug>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
29+
<DebugType>full</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
<MtouchLink>None</MtouchLink>
35+
<ConsolePause>false</ConsolePause>
36+
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
37+
</PropertyGroup>
38+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
39+
<DebugSymbols>true</DebugSymbols>
40+
<DebugType>full</DebugType>
41+
<Optimize>false</Optimize>
42+
<OutputPath>bin\iPhone\Debug</OutputPath>
43+
<DefineConstants>DEBUG;</DefineConstants>
44+
<ErrorReport>prompt</ErrorReport>
45+
<WarningLevel>4</WarningLevel>
46+
<ConsolePause>false</ConsolePause>
47+
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
48+
<MtouchDebug>true</MtouchDebug>
49+
<CodesignKey>iPhone Developer</CodesignKey>
50+
<MtouchArch>ARMv7</MtouchArch>
51+
</PropertyGroup>
52+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
53+
<DebugType>full</DebugType>
54+
<Optimize>true</Optimize>
55+
<OutputPath>bin\iPhone\Release</OutputPath>
56+
<ErrorReport>prompt</ErrorReport>
57+
<WarningLevel>4</WarningLevel>
58+
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
59+
<ConsolePause>false</ConsolePause>
60+
<CodesignKey>iPhone Developer</CodesignKey>
61+
<MtouchArch>ARMv7, ARM64</MtouchArch>
62+
</PropertyGroup>
63+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
64+
<DebugType>full</DebugType>
65+
<Optimize>true</Optimize>
66+
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
67+
<ErrorReport>prompt</ErrorReport>
68+
<WarningLevel>4</WarningLevel>
69+
<ConsolePause>false</ConsolePause>
70+
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
71+
<BuildIpa>true</BuildIpa>
72+
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
73+
<CodesignKey>iPhone Distribution</CodesignKey>
74+
<MtouchArch>ARMv7, ARM64</MtouchArch>
75+
</PropertyGroup>
76+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
77+
<DebugType>full</DebugType>
78+
<Optimize>true</Optimize>
79+
<OutputPath>bin\iPhone\AppStore</OutputPath>
80+
<ErrorReport>prompt</ErrorReport>
81+
<WarningLevel>4</WarningLevel>
82+
<CodesignKey>iPhone Distribution</CodesignKey>
83+
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
84+
<ConsolePause>false</ConsolePause>
85+
<CodesignProvision>Automatic:AppStore</CodesignProvision>
86+
<MtouchArch>ARMv7, ARM64</MtouchArch>
87+
</PropertyGroup>
88+
<ItemGroup>
89+
<Reference Include="System" />
90+
<Reference Include="System.Xml" />
91+
<Reference Include="System.Core" />
92+
<Reference Include="Xamarin.iOS" />
93+
</ItemGroup>
94+
<ItemGroup>
95+
<None Include="Info.plist" />
96+
<None Include="Entitlements.plist" />
97+
</ItemGroup>
98+
<ItemGroup>
99+
<Compile Include="Main.cs" />
100+
<Compile Include="AppDelegate.cs" />
101+
<Compile Include="CustomViewController.cs" />
102+
<Compile Include="CircleView.cs" />
103+
<Compile Include="CircleController.cs" />
104+
</ItemGroup>
105+
<ItemGroup>
106+
<Folder Include="Resources\" />
107+
</ItemGroup>
108+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
109+
<ItemGroup>
110+
<BundleResource Include="Resources\Default-568h%402x.png" />
111+
</ItemGroup>
112+
</Project>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System;
2+
using UIKit;
3+
using CoreGraphics;
4+
5+
namespace CodeOnlyDemo
6+
{
7+
8+
public class CustomViewController : UIViewController
9+
{
10+
UITextField usernameField, passwordField;
11+
CircleController circleController;
12+
13+
public override void ViewDidLoad()
14+
{
15+
base.ViewDidLoad();
16+
View.BackgroundColor = UIColor.Gray;
17+
18+
nfloat h = 31.0f;
19+
nfloat w = View.Bounds.Width;
20+
21+
usernameField = new UITextField
22+
{
23+
Placeholder = "Enter your username",
24+
BorderStyle = UITextBorderStyle.RoundedRect,
25+
Frame = new CGRect(10, 32, w - 20, h),
26+
AutoresizingMask = UIViewAutoresizing.FlexibleWidth
27+
};
28+
29+
passwordField = new UITextField
30+
{
31+
Placeholder = "Enter your password",
32+
BorderStyle = UITextBorderStyle.RoundedRect,
33+
Frame = new CGRect(10, 64, w - 20, h),
34+
SecureTextEntry = true,
35+
AutoresizingMask = UIViewAutoresizing.FlexibleWidth
36+
};
37+
38+
var submitButton = UIButton.FromType(UIButtonType.RoundedRect);
39+
submitButton.Frame = new CGRect(10, 120, w - 20, 44);
40+
submitButton.SetTitle("Submit", UIControlState.Normal);
41+
submitButton.BackgroundColor = UIColor.White;
42+
submitButton.Layer.CornerRadius = 5f;
43+
submitButton.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
44+
45+
submitButton.TouchUpInside += delegate
46+
{
47+
Console.WriteLine("Submit button pressed");
48+
circleController = new CircleController();
49+
PresentViewController(circleController, true, null);
50+
};
51+
52+
View.AddSubviews(new UIView[]{ usernameField, passwordField, submitButton });
53+
}
54+
}
55+
}
56+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
</dict>
6+
</plist>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDisplayName</key>
6+
<string>CodeOnlyProject</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>com.your-company.CodeOnlyProject</string>
9+
<key>CFBundleShortVersionString</key>
10+
<string>1.0</string>
11+
<key>CFBundleVersion</key>
12+
<string>1.0</string>
13+
<key>LSRequiresIPhoneOS</key>
14+
<true/>
15+
<key>MinimumOSVersion</key>
16+
<string>8.3</string>
17+
<key>UIDeviceFamily</key>
18+
<array>
19+
<integer>1</integer>
20+
</array>
21+
<key>UIRequiredDeviceCapabilities</key>
22+
<array>
23+
<string>armv7</string>
24+
</array>
25+
<key>UISupportedInterfaceOrientations</key>
26+
<array>
27+
<string>UIInterfaceOrientationPortrait</string>
28+
<string>UIInterfaceOrientationLandscapeLeft</string>
29+
<string>UIInterfaceOrientationLandscapeRight</string>
30+
</array>
31+
</dict>
32+
</plist>

SimpleLogin/CodeOnlyProject/Main.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
using Foundation;
6+
using UIKit;
7+
8+
namespace CodeOnlyProject
9+
{
10+
public class Application
11+
{
12+
// This is the main entry point of the application.
13+
static void Main(string[] args)
14+
{
15+
// if you want to use a different Application Delegate class from "AppDelegate"
16+
// you can specify it here.
17+
UIApplication.Main(args, null, "AppDelegate");
18+
}
19+
}
20+
}
Loading

SimpleLogin/Metadata.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<SampleMetadata>
3+
<ID>C8C9307F-8006-4F85-9198-8D3FB1BA19A5</ID>
4+
<IsFullApplication>false</IsFullApplication>
5+
<Level>Beginning</Level>
6+
<Tags>Getting Started, User Interface</Tags>
7+
<Gallery>false</Gallery>
8+
<Brief>This introductory sample looks at setting up a basic iOS application in Visual Studio.</Brief>
9+
</SampleMetadata>

SimpleLogin/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SimpleLogin
2+
==========
3+
4+
This sample is the application that will be built at the end of the [Creating iOS Applications in Code Using Visual Studio](http://developer.xamarin.com/guides/ios/application_fundamentals/ios_code_only/) guide.
5+
6+
7+
8+
Loading
96.2 KB
Loading

SimpleLogin/Screenshots/circles.png

30.7 KB
Loading

0 commit comments

Comments
 (0)