├── .gitignore
├── AMQPNetLite
├── AMQPNetLite.sln
├── AMQPNetLiteIoT_Server
│ ├── AMQPServerIoTExample.csproj
│ └── Program.cs
└── AMQPNetLite_Client
│ ├── AMQClientMac.sln
│ ├── AMQPClientMacExample.csproj
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── packages.config
├── AzureSqlDatabase
└── IoTAzureSqlDatabaseExample
│ ├── IoTAzureSqlDatabaseExample.sln
│ ├── IoTAzureSqlDatabase_EntityFramework_Example
│ ├── App.config
│ ├── IoTAzureSqlDatabase.EntityFrameworkExample.csproj
│ ├── Program.cs
│ ├── User.cs
│ └── UsersContext.cs
│ └── IoTAzureSqlDatabase_SqlClient_Example
│ ├── Extensions.cs
│ ├── IoTAzureSqlDatabase.SQLClientExample.csproj
│ ├── Program.cs
│ └── User.cs
├── Forms.Gtk
├── Metadata.xml
├── Screenshots
│ ├── GTK.png
│ ├── WeatherApp-All-sml.png
│ └── WeatherApp-All.png
├── WeatherApp.sln
├── WeatherApp
│ ├── WeatherApp.Droid
│ │ ├── Assets
│ │ │ └── AboutAssets.txt
│ │ ├── MainActivity.cs
│ │ ├── Properties
│ │ │ ├── AndroidManifest.xml
│ │ │ └── AssemblyInfo.cs
│ │ ├── Resources
│ │ │ ├── AboutResources.txt
│ │ │ ├── Resource.Designer.cs
│ │ │ ├── drawable-hdpi
│ │ │ │ └── icon.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── icon.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── icon.png
│ │ │ └── drawable
│ │ │ │ └── icon.png
│ │ ├── WeatherApp.Droid.csproj
│ │ └── packages.config
│ ├── WeatherApp.GTK.Raspberry
│ │ ├── HumiditySensor.cs
│ │ ├── Program.cs
│ │ ├── WeatherApp.Gtk.Raspberry.csproj
│ │ └── app.config
│ ├── WeatherApp.GTK
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── WeatherApp.GTK.csproj
│ │ ├── app.config
│ │ └── packages.config
│ └── WeatherApp
│ │ ├── App.cs
│ │ ├── Core.cs
│ │ ├── DataService.cs
│ │ ├── Properties
│ │ └── AssemblyInfo.cs
│ │ ├── Sensor
│ │ ├── BaseHumiditySensor.cs
│ │ ├── FakeHumiditySensor.cs
│ │ └── IHumiditySensor.cs
│ │ ├── Weather.cs
│ │ ├── WeatherApp.csproj
│ │ ├── WeatherPage.xaml
│ │ ├── WeatherPage.xaml.cs
│ │ └── packages.config
└── readme.md
├── Hermes.Mqtt
├── IoTMqttTest.Server
│ ├── IoTMqttTest.Server.csproj
│ └── Program.cs
├── MqttHermesExample.sln
└── MqttTest.Client
│ ├── App.config
│ ├── MqttTest.Client.csproj
│ ├── MqttTest.Client.csproj.user
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── packages.config
├── IoTSharp.Components
├── HubExamples
│ ├── BlindHubTest.cs
│ ├── ButtonHubTest.cs
│ ├── RelayHubTest.cs
│ └── SensorHubTest.cs
├── IoTSharpComponents.Example.csproj
├── IoTSharpComponents.Example.sln
├── Program.cs
└── README.md
├── LICENSE
├── Microsoft.AspNet.WebApi
├── HomeAutomation.Blind.IOS
│ ├── AppDelegate.cs
│ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Entitlements.plist
│ ├── HomeAutomation.Blind.IOS.csproj
│ ├── Info.plist
│ ├── LaunchScreen.storyboard
│ ├── Main.cs
│ ├── Main.storyboard
│ ├── Remote.png
│ ├── Settings.bundle
│ │ └── Root.plist
│ ├── ViewController.cs
│ └── ViewController.designer.cs
├── HomeAutomation.Blind.Server
│ ├── HomeAutomation.Blind.Server.csproj
│ ├── IoTFactory.cs
│ ├── IoTServiceController.cs
│ └── Program.cs
├── HomeAutomation.sln
├── LicenseAndCredit.txt
├── README.md
└── ReleaseNotesv0.1.md
├── README.md
└── Speech.Recognition
├── Audio
├── Long Audio 2.wav
└── Long Audio.wav
├── Models
├── cmudict-en-us.dict
├── digits.dict
├── en-us.lm.dmp
├── feat.params
├── hello.gram
├── mdef
├── means
├── mixture_weights
├── noisedict
├── sendump
├── transition_matrices
└── variances
├── Program.cs
├── Speech.Recognition.Example.csproj
└── Speech.Recognition.Example.sln
/.gitignore:
--------------------------------------------------------------------------------
1 | *.userprefs
2 | *.mpack
3 | *.md5
4 | packages
5 | bin
6 | debug
7 | obj
8 | nuget.exe
9 |
--------------------------------------------------------------------------------
/AMQPNetLite/AMQPNetLite.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AMQPClientMacExample", "AMQPNetLite_Client\AMQPClientMacExample.csproj", "{6425E720-237D-46EF-A07B-EE30D9823F6E}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AMQPServerIoTExample", "AMQPNetLiteIoT_Server\AMQPServerIoTExample.csproj", "{009EFCA5-730C-4DBA-B68D-12B1C88B93E8}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {6425E720-237D-46EF-A07B-EE30D9823F6E}.Debug|x86.ActiveCfg = Debug|x86
15 | {6425E720-237D-46EF-A07B-EE30D9823F6E}.Debug|x86.Build.0 = Debug|x86
16 | {6425E720-237D-46EF-A07B-EE30D9823F6E}.Release|x86.ActiveCfg = Release|x86
17 | {6425E720-237D-46EF-A07B-EE30D9823F6E}.Release|x86.Build.0 = Release|x86
18 | {009EFCA5-730C-4DBA-B68D-12B1C88B93E8}.Debug|x86.ActiveCfg = Debug|Any CPU
19 | {009EFCA5-730C-4DBA-B68D-12B1C88B93E8}.Debug|x86.Build.0 = Debug|Any CPU
20 | {009EFCA5-730C-4DBA-B68D-12B1C88B93E8}.Release|x86.ActiveCfg = Release|Any CPU
21 | {009EFCA5-730C-4DBA-B68D-12B1C88B93E8}.Release|x86.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | EndGlobal
24 |
--------------------------------------------------------------------------------
/AMQPNetLite/AMQPNetLiteIoT_Server/AMQPServerIoTExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AMQPNetLite/AMQPNetLiteIoT_Server/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Collections.Generic;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 | using Amqp;
7 | using Amqp.Framing;
8 | using Amqp.Listener;
9 | using Amqp.Types;
10 |
11 | namespace AMQPServerIoTExample
12 | {
13 | class MainClass
14 | {
15 | static void Main (string [] args)
16 | {
17 | string address = "amqp://guest:guest@10.67.1.82:5672";
18 | if (args.Length > 0) {
19 | address = args [0];
20 | }
21 |
22 | Uri addressUri = new Uri (address);
23 | ContainerHost host = new ContainerHost (new Uri [] { addressUri }, null, addressUri.UserInfo);
24 | host.Open ();
25 | Console.WriteLine ("Raspberry Pi host is listening on {0}:{1}", addressUri.Host, addressUri.Port);
26 |
27 | string requestProcessor = "request_processor";
28 | host.RegisterRequestProcessor (requestProcessor, new RequestProcessor ());
29 | Console.WriteLine ("Request processor is registered on {0}", requestProcessor);
30 |
31 | Console.WriteLine ("Press enter key to exit...");
32 | Console.ReadLine ();
33 |
34 | host.Close ();
35 | }
36 |
37 | class RequestProcessor : IRequestProcessor
38 | {
39 | int offset;
40 |
41 | void IRequestProcessor.Process (RequestContext requestContext)
42 | {
43 | Console.WriteLine ("Received a request: " + requestContext.Message.Body);
44 | var task = this.ReplyAsync (requestContext);
45 | }
46 |
47 | async Task ReplyAsync (RequestContext requestContext)
48 | {
49 | if (this.offset == 0) {
50 | this.offset = (int)requestContext.Message.ApplicationProperties ["offset"];
51 | }
52 |
53 | var board = Raspberry.Board.Current;
54 | var subject = $"Model: {board.Model.ToString ()};ProcessorName:{board.ProcessorName};SerialNumber:{board.SerialNumber}";
55 |
56 | while (this.offset < 1000) {
57 | try {
58 | Message response = new Message ("Yes I am listening you!!!! " + this.offset);
59 | response.ApplicationProperties = new ApplicationProperties ();
60 | response.ApplicationProperties ["offset"] = this.offset;
61 | response.Properties = new Properties () {
62 | Subject = subject
63 | };
64 | requestContext.ResponseLink.SendMessage (response);
65 | this.offset++;
66 | } catch (Exception exception) {
67 | Console.WriteLine ("Exception: " + exception.Message);
68 | if (requestContext.State == ContextState.Aborted) {
69 | Console.WriteLine ("Request is aborted. Last offset: " + this.offset);
70 | return;
71 | }
72 | }
73 |
74 | await Task.Delay (1000);
75 | }
76 |
77 | requestContext.Complete (new Message ("done"));
78 | }
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/AMQPNetLite/AMQPNetLite_Client/AMQClientMac.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AMQClientMac", "AMQClientMac.csproj", "{6425E720-237D-46EF-A07B-EE30D9823F6E}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {6425E720-237D-46EF-A07B-EE30D9823F6E}.Debug|x86.ActiveCfg = Debug|x86
13 | {6425E720-237D-46EF-A07B-EE30D9823F6E}.Debug|x86.Build.0 = Debug|x86
14 | {6425E720-237D-46EF-A07B-EE30D9823F6E}.Release|x86.ActiveCfg = Release|x86
15 | {6425E720-237D-46EF-A07B-EE30D9823F6E}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | EndGlobal
18 |
--------------------------------------------------------------------------------
/AMQPNetLite/AMQPNetLite_Client/AMQPClientMacExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | {6425E720-237D-46EF-A07B-EE30D9823F6E}
7 | Exe
8 | AMQPClientMacExample
9 | AMQPClientMacExample
10 | v4.6
11 |
12 |
13 | true
14 | full
15 | false
16 | bin\Debug
17 | DEBUG;
18 | prompt
19 | 4
20 | true
21 | x86
22 |
23 |
24 | true
25 | bin\Release
26 | prompt
27 | 4
28 | true
29 | x86
30 |
31 |
32 |
33 |
34 | ..\..\..\packages\AMQPNetLite.1.2.3\lib\net45\Amqp.Net.dll
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/AMQPNetLite/AMQPNetLite_Client/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using Amqp;
4 | using Amqp.Framing;
5 | using Amqp.Types;
6 |
7 | namespace AMQ
8 | {
9 | class MainClass
10 | {
11 | static void Main (string[] args)
12 | {
13 | string address = "amqp://guest:guest@10.67.1.69:5672";
14 | if (args.Length > 0) {
15 | address = args[0];
16 | }
17 | Console.WriteLine ("Running request client...");
18 | new Client (address).Run ();
19 | }
20 |
21 | class Client
22 | {
23 | readonly string address;
24 | string replyTo;
25 | Connection connection;
26 | Session session;
27 | ReceiverLink receiver;
28 | SenderLink sender;
29 | int offset;
30 |
31 | public Client (string address)
32 | {
33 | this.address = address;
34 | this.replyTo = "client-" + Guid.NewGuid ().ToString ();
35 | }
36 |
37 | public void Run ()
38 | {
39 | while (true) {
40 | try {
41 | this.Cleanup ();
42 | this.Setup ();
43 |
44 | this.RunOnce ();
45 |
46 | this.Cleanup ();
47 | break;
48 | }
49 | catch (Exception exception) {
50 | Console.WriteLine ("Reconnect on exception: " + exception.Message);
51 |
52 | Thread.Sleep (5000);
53 | }
54 | }
55 | }
56 |
57 | void Setup ()
58 | {
59 | this.connection = new Connection (new Address (address));
60 | this.session = new Session (connection);
61 |
62 | Attach recvAttach = new Attach () {
63 | Source = new Source () { Address = "request_processor" },
64 | Target = new Target () { Address = this.replyTo }
65 | };
66 |
67 | this.receiver = new ReceiverLink (session, "request-client-receiver", recvAttach, null);
68 | this.receiver.Start (300);
69 | this.sender = new SenderLink (session, "request-client-sender", "request_processor");
70 | }
71 |
72 | void Cleanup ()
73 | {
74 | var temp = Interlocked.Exchange (ref this.connection, null);
75 | if (temp != null) {
76 | temp.Close ();
77 | }
78 | }
79 |
80 | void RunOnce ()
81 | {
82 | Message request = new Message ("Raspberry are you listen me? " + this.offset);
83 | request.Properties = new Properties () { MessageId = "command-request", ReplyTo = this.replyTo };
84 | request.ApplicationProperties = new ApplicationProperties ();
85 | request.ApplicationProperties["offset"] = this.offset;
86 | sender.Send (request, null, null);
87 |
88 | Console.WriteLine ($"Sending request to Raspberry...{Environment.NewLine}{Environment.NewLine}Properties:{Environment.NewLine}{request.Properties}{Environment.NewLine}{Environment.NewLine}Body Message:{Environment.NewLine}{request.Body}{Environment.NewLine}{Environment.NewLine}");
89 |
90 | while (true) {
91 | Message response = receiver.Receive ();
92 | receiver.Accept (response);
93 | Console.WriteLine ("Received response: {0} body {1}", response.Properties, response.Body);
94 |
95 | if (string.Equals ("done", response.Body)) {
96 | break;
97 | }
98 |
99 | this.offset = (int)response.ApplicationProperties["offset"];
100 | }
101 | }
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/AMQPNetLite/AMQPNetLite_Client/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle ("AMQ")]
8 | [assembly: AssemblyDescription ("")]
9 | [assembly: AssemblyConfiguration ("")]
10 | [assembly: AssemblyCompany ("Microsoft")]
11 | [assembly: AssemblyProduct ("")]
12 | [assembly: AssemblyCopyright ("Microsoft Corp.")]
13 | [assembly: AssemblyTrademark ("")]
14 | [assembly: AssemblyCulture ("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion ("1.0.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
--------------------------------------------------------------------------------
/AMQPNetLite/AMQPNetLite_Client/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabaseExample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTAzureSqlDatabase.SQLClientExample", "IoTAzureSqlDatabase_SqlClient_Example\IoTAzureSqlDatabase.SQLClientExample.csproj", "{DE5129E3-625B-43B3-90EA-D1BEE06C6338}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTAzureSqlDatabase.EntityFrameworkExample", "IoTAzureSqlDatabase_EntityFramework_Example\IoTAzureSqlDatabase.EntityFrameworkExample.csproj", "{4EBA50EF-808F-4CDE-A882-EB7B5FE68000}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {DE5129E3-625B-43B3-90EA-D1BEE06C6338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {DE5129E3-625B-43B3-90EA-D1BEE06C6338}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {DE5129E3-625B-43B3-90EA-D1BEE06C6338}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {DE5129E3-625B-43B3-90EA-D1BEE06C6338}.Release|Any CPU.Build.0 = Release|Any CPU
18 | {4EBA50EF-808F-4CDE-A882-EB7B5FE68000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {4EBA50EF-808F-4CDE-A882-EB7B5FE68000}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {4EBA50EF-808F-4CDE-A882-EB7B5FE68000}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {4EBA50EF-808F-4CDE-A882-EB7B5FE68000}.Release|Any CPU.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | EndGlobal
24 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabase_EntityFramework_Example/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabase_EntityFramework_Example/IoTAzureSqlDatabase.EntityFrameworkExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabase_EntityFramework_Example/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.SqlClient;
4 |
5 | namespace IoTAzureSqlDatabase.EntityFrameworkExample
6 | {
7 | class Program
8 | {
9 | static void Main()
10 | {
11 | var context = new UsersContext();
12 |
13 | Console.WriteLine("Creating table if not created...");
14 | context.Database.CreateIfNotExists();
15 |
16 | Console.WriteLine("Removing posible users...");
17 | context.Database.ExecuteSqlCommand("TRUNCATE TABLE XamarinDB.dbo.Users");
18 | context.SaveChanges();
19 |
20 | Console.WriteLine($"Database has {context.Users.Local.Count} users.");
21 |
22 | Console.WriteLine("Adding users...");
23 | context.Users.Add(new User { Id = 1, Name = "Miguel" });
24 | context.Users.Add(new User { Id = 2, Name = "Nat" });
25 | context.Users.Add(new User { Id = 3, Name = "Mikayla" });
26 | context.SaveChanges();
27 |
28 | Console.WriteLine($"Database has {context.Users.Local.Count} users:");
29 | foreach (var employee in context.Users)
30 | Console.WriteLine($"{employee.Id} = {employee.Name}" );
31 |
32 | Console.WriteLine("Finished.");
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabase_EntityFramework_Example/User.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace IoTAzureSqlDatabase.EntityFrameworkExample
5 | {
6 | public class User
7 | {
8 | [Key]
9 | public int Id {
10 | get;
11 | set;
12 | }
13 | public string Name {
14 | get;
15 | set;
16 | }
17 |
18 | public override string ToString ()
19 | {
20 | return string.Format ("[User: Id={0}, Name={1}]", Id, Name);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabase_EntityFramework_Example/UsersContext.cs:
--------------------------------------------------------------------------------
1 | using System.Data.Entity;
2 |
3 | namespace IoTAzureSqlDatabase.EntityFrameworkExample
4 | {
5 | public class UsersContext : DbContext
6 | {
7 | public UsersContext() : base("name=XamarinDBConnectionString")
8 | {
9 | }
10 | public DbSet Users { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabase_SqlClient_Example/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.SqlClient;
4 |
5 | namespace IoTAzureSqlDatabase.EntityFrameworkExample
6 | {
7 | static class Extensions
8 | {
9 | public static List GetUsers (this SqlDataReader sender)
10 | {
11 | var users = new List ();
12 | while (sender.Read ()) {
13 | users.Add (new User () { Id = sender.GetInt32 (0), Name = sender.GetString (1) });
14 | }
15 | return users;
16 | }
17 |
18 | public static int ExecuteNonQuery (this SqlCommand command, string query)
19 | {
20 | command.CommandText = query;
21 | return command.ExecuteNonQuery ();
22 | }
23 |
24 | public static void ExecuteNonQuery (this SqlCommand command, string[] queries)
25 | {
26 | foreach (var query in queries) {
27 | ExecuteNonQuery (command, query);
28 | }
29 | }
30 |
31 | public static List GetUsers (this SqlCommand command)
32 | {
33 | command.CommandText = "SELECT * FROM dbo.Xamarin";
34 | using (var reader = command.ExecuteReader ()) {
35 | return reader.GetUsers ();
36 | }
37 | }
38 |
39 | public static void ConsoleOutput (this List users)
40 | {
41 | foreach (var user in users) {
42 | Console.WriteLine (user);
43 | }
44 | Console.WriteLine ($"Total {users.Count} users.");
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabase_SqlClient_Example/IoTAzureSqlDatabase.SQLClientExample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 |
7 |
8 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabase_SqlClient_Example/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.SqlClient;
4 |
5 | namespace IoTAzureSqlDatabase.EntityFrameworkExample
6 | {
7 | class Program
8 | {
9 | static void Main ()
10 | {
11 | var builder = new SqlConnectionStringBuilder {
12 | ["Server"] = "yourserverhere.database.windows.net",
13 | ["User ID"] = "youruserhere",
14 | ["Password"] = "yourpasswordhere",
15 | ["Database"] = "yourdatabasehere"
16 | };
17 |
18 | try {
19 | //Create a SqlConnection from the provided connection string
20 | using (var connection = new SqlConnection (builder.ToString ())) {
21 | //Begin to formulate the command
22 | var command = new SqlCommand () {
23 | Connection = connection,
24 | CommandTimeout = 10,
25 | CommandType = System.Data.CommandType.Text
26 | };
27 |
28 | //Open connection to database
29 | connection.Open ();
30 |
31 | command.GetUsers ().ConsoleOutput ();
32 |
33 | var queries = new string [] {
34 | "DELETE FROM dbo.Xamarin",
35 | "INSERT INTO dbo.Xamarin (Id, Name) VALUES (1, 'Miguel')",
36 | "INSERT INTO dbo.Xamarin (Id, Name) VALUES (2, 'Nat')",
37 | "INSERT INTO dbo.Xamarin (Id, Name) VALUES (3, 'Mikayla')"
38 | };
39 | command.ExecuteNonQuery (queries);
40 | command.GetUsers ().ConsoleOutput ();
41 |
42 | command.ExecuteNonQuery ("DELETE FROM dbo.Xamarin");
43 |
44 | Console.WriteLine ("\nPress any key to continue");
45 | Console.ReadLine ();
46 | }
47 | } catch (Exception ex) {
48 | Console.WriteLine ("An error occured: " + ex.Message);
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/AzureSqlDatabase/IoTAzureSqlDatabaseExample/IoTAzureSqlDatabase_SqlClient_Example/User.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | namespace IoTAzureSqlDatabase.EntityFrameworkExample
3 | {
4 | class User
5 | {
6 | public int Id {
7 | get;
8 | set;
9 | }
10 | public string Name {
11 | get;
12 | set;
13 | }
14 |
15 | public override string ToString ()
16 | {
17 | return string.Format ("[User: Id={0}, Name={1}]", Id, Name);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Forms.Gtk/Metadata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 71D70AA5-FE69-4934-8FDB-3486D33155FC
4 | true
5 | Beginner
6 | User Interface, Getting Started
7 | Android, iOS, Windows
8 | Starter
9 | Demonstrates a cross-platform app using Xamarin.Forms that retrieves data from a weather service.
10 | true
11 | false
12 |
13 |
--------------------------------------------------------------------------------
/Forms.Gtk/Screenshots/GTK.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/xamarin-iot-samples/f17750a1f4a3207eecbecfa40a71360df3fb9972/Forms.Gtk/Screenshots/GTK.png
--------------------------------------------------------------------------------
/Forms.Gtk/Screenshots/WeatherApp-All-sml.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/xamarin-iot-samples/f17750a1f4a3207eecbecfa40a71360df3fb9972/Forms.Gtk/Screenshots/WeatherApp-All-sml.png
--------------------------------------------------------------------------------
/Forms.Gtk/Screenshots/WeatherApp-All.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/xamarin-iot-samples/f17750a1f4a3207eecbecfa40a71360df3fb9972/Forms.Gtk/Screenshots/WeatherApp-All.png
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherApp.Droid", "WeatherApp\WeatherApp.Droid\WeatherApp.Droid.csproj", "{B425ECD7-AFA3-43F2-93D0-05055A9867C2}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherApp", "WeatherApp\WeatherApp\WeatherApp.csproj", "{6C871F12-A23B-4974-A3AB-5CBB9D642E41}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherApp.GTK", "WeatherApp\WeatherApp.GTK\WeatherApp.GTK.csproj", "{15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeatherApp.Gtk.Raspberry", "WeatherApp\WeatherApp.Gtk.Raspberry\WeatherApp.Gtk.Raspberry.csproj", "{C2181E5F-865A-4B95-9F0D-D688F9EBBC36}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
19 | Release|iPhone = Release|iPhone
20 | Release|iPhoneSimulator = Release|iPhoneSimulator
21 | Debug|iPhone = Debug|iPhone
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Debug|iPhone.ActiveCfg = Debug|Any CPU
27 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Debug|iPhone.Build.0 = Debug|Any CPU
28 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
29 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
30 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Release|iPhone.ActiveCfg = Release|Any CPU
33 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Release|iPhone.Build.0 = Release|Any CPU
34 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
35 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
36 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Debug|iPhone.ActiveCfg = Debug|Any CPU
39 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Debug|iPhone.Build.0 = Debug|Any CPU
40 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
41 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
42 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Release|iPhone.ActiveCfg = Release|Any CPU
45 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Release|iPhone.Build.0 = Release|Any CPU
46 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
47 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
48 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
49 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Debug|Any CPU.Build.0 = Debug|Any CPU
50 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Debug|iPhone.ActiveCfg = Debug|Any CPU
51 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Debug|iPhone.Build.0 = Debug|Any CPU
52 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
53 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
54 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Release|iPhone.ActiveCfg = Release|Any CPU
57 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Release|iPhone.Build.0 = Release|Any CPU
58 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
59 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
60 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Debug|Any CPU.Build.0 = Debug|Any CPU
62 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Debug|iPhone.ActiveCfg = Debug|Any CPU
63 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Debug|iPhone.Build.0 = Debug|Any CPU
64 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
65 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
66 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Release|Any CPU.ActiveCfg = Release|Any CPU
67 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Release|Any CPU.Build.0 = Release|Any CPU
68 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Release|iPhone.ActiveCfg = Release|Any CPU
69 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Release|iPhone.Build.0 = Release|Any CPU
70 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
71 | {C2181E5F-865A-4B95-9F0D-D688F9EBBC36}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
72 | EndGlobalSection
73 | GlobalSection(SolutionProperties) = preSolution
74 | HideSolutionNode = FALSE
75 | EndGlobalSection
76 | EndGlobal
77 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with you package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Android.App;
4 | using Android.Content.PM;
5 | using Android.Runtime;
6 | using Android.Views;
7 | using Android.Widget;
8 | using Android.OS;
9 | using WeatherApp;
10 |
11 | namespace WeatherApp.Droid
12 | {
13 | [Activity(Label = "WeatherApp", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
14 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
15 | {
16 | protected override void OnCreate(Bundle bundle)
17 | {
18 | base.OnCreate(bundle);
19 |
20 | global::Xamarin.Forms.Forms.Init(this, bundle);
21 |
22 | var sensor = new FakeHumiditySensor ();
23 | LoadApplication(new App(sensor));
24 | }
25 | }
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using Android.App;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("WeatherApp.Droid")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("WeatherApp.Droid")]
14 | [assembly: AssemblyCopyright("Copyright © 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: ComVisible(false)]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | //
26 | // You can specify all the values or you can default the Build and Revision Numbers
27 | // by using the '*' as shown below:
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("1.0.0.0")]
30 | [assembly: AssemblyFileVersion("1.0.0.0")]
31 |
32 | // Add some common permissions, these can be removed if not needed
33 | [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
34 | [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
35 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.xml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable-hdpi/
12 | icon.png
13 |
14 | drawable-ldpi/
15 | icon.png
16 |
17 | drawable-mdpi/
18 | icon.png
19 |
20 | layout/
21 | main.xml
22 |
23 | values/
24 | strings.xml
25 |
26 | In order to get the build system to recognize Android resources, set the build action to
27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
28 | instead operate on resource IDs. When you compile an Android application that uses resources,
29 | the build system will package the resources for distribution and generate a class called
30 | "Resource" that contains the tokens for each one of the resources included. For example,
31 | for the above Resources layout, this is what the Resource class would expose:
32 |
33 | public class Resource {
34 | public class drawable {
35 | public const int icon = 0x123;
36 | }
37 |
38 | public class layout {
39 | public const int main = 0x456;
40 | }
41 |
42 | public class strings {
43 | public const int first_string = 0xabc;
44 | public const int second_string = 0xbcd;
45 | }
46 | }
47 |
48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
50 | string in the dictionary file values/strings.xml.
51 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/Resources/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/xamarin-iot-samples/f17750a1f4a3207eecbecfa40a71360df3fb9972/Forms.Gtk/WeatherApp/WeatherApp.Droid/Resources/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/Resources/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/xamarin-iot-samples/f17750a1f4a3207eecbecfa40a71360df3fb9972/Forms.Gtk/WeatherApp/WeatherApp.Droid/Resources/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/Resources/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/xamarin-iot-samples/f17750a1f4a3207eecbecfa40a71360df3fb9972/Forms.Gtk/WeatherApp/WeatherApp.Droid/Resources/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/Resources/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/xamarin-iot-samples/f17750a1f4a3207eecbecfa40a71360df3fb9972/Forms.Gtk/WeatherApp/WeatherApp.Droid/Resources/drawable/icon.png
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/WeatherApp.Droid.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {B425ECD7-AFA3-43F2-93D0-05055A9867C2}
9 | {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10 | Library
11 | Properties
12 | WeatherApp.Droid
13 | WeatherApp.Droid
14 | 512
15 | true
16 | Resources\Resource.Designer.cs
17 | Off
18 | Properties\AndroidManifest.xml
19 | true
20 | v7.0
21 | armeabi,armeabi-v7a,x86
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | true
31 | full
32 | false
33 | bin\Debug\
34 | DEBUG;TRACE
35 | prompt
36 | 4
37 | True
38 | None
39 |
40 |
41 | pdbonly
42 | true
43 | bin\Release\
44 | TRACE
45 | prompt
46 | 4
47 | False
48 | SdkOnly
49 |
50 |
51 |
52 | ..\..\packages\Xamarin.Forms.3.0.0\lib\MonoAndroid10\FormsViewGroup.dll
53 | True
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | ..\..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Animated.Vector.Drawable.dll
63 | True
64 |
65 |
66 | ..\..\packages\Xamarin.Android.Support.Design.23.3.0\lib\MonoAndroid43\Xamarin.Android.Support.Design.dll
67 | True
68 |
69 |
70 | ..\..\packages\Xamarin.Android.Support.v4.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll
71 | True
72 |
73 |
74 | ..\..\packages\Xamarin.Android.Support.v7.AppCompat.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.AppCompat.dll
75 | True
76 |
77 |
78 | ..\..\packages\Xamarin.Android.Support.v7.CardView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.CardView.dll
79 | True
80 |
81 |
82 | ..\..\packages\Xamarin.Android.Support.v7.MediaRouter.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.MediaRouter.dll
83 | True
84 |
85 |
86 | ..\..\packages\Xamarin.Android.Support.v7.RecyclerView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.RecyclerView.dll
87 | True
88 |
89 |
90 | ..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Vector.Drawable.dll
91 | True
92 |
93 |
94 | ..\..\packages\Xamarin.Forms.3.0.0\lib\MonoAndroid10\Xamarin.Forms.Core.dll
95 | True
96 |
97 |
98 | ..\..\packages\Xamarin.Forms.3.0.0\lib\MonoAndroid10\Xamarin.Forms.Platform.dll
99 | True
100 |
101 |
102 | ..\..\packages\Xamarin.Forms.3.0.0\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll
103 | True
104 |
105 |
106 | ..\..\packages\Xamarin.Forms.3.0.0\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll
107 | True
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}
132 | WeatherApp
133 |
134 |
135 |
136 |
137 |
138 |
139 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
140 |
141 |
142 |
143 |
144 |
145 |
152 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.Droid/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.GTK.Raspberry/HumiditySensor.cs:
--------------------------------------------------------------------------------
1 | // This sensor gets the current values of a python script from Adafruit for a
2 | // Humidy Sensor model DHT22, the model can be changed
3 | // ScriptFile: AdafruitDHT.py
4 | // /home/pi/Adafruit_Python_DHT/examples/AdafruitDHT.py
5 |
6 | using System;
7 | using System.Diagnostics;
8 |
9 | namespace WeatherApp
10 | {
11 | public class HumiditySensorDHT22 : BaseHumiditySensor
12 | {
13 | readonly public static string DHT22 = "22";
14 |
15 | readonly int pin;
16 | string adafruitDhtExecutablePath;
17 |
18 | public HumiditySensorDHT22 (int pin, string adafruitDhtExecutablePath)
19 | {
20 | this.pin = pin;
21 | this.adafruitDhtExecutablePath = adafruitDhtExecutablePath;
22 | }
23 |
24 | string ReadActualValue ()
25 | {
26 | string dev = "";
27 |
28 | var order = $"{adafruitDhtExecutablePath} {DHT22} {pin}";
29 | var arguments = string.Format ("-c \"sudo {0}\"", order);
30 |
31 | using (var proc = new Process {
32 | StartInfo = new ProcessStartInfo {
33 | FileName = "/bin/bash",
34 | Arguments = arguments,
35 | UseShellExecute = false,
36 | RedirectStandardOutput = true,
37 | CreateNoWindow = true
38 | }
39 | }) {
40 | proc.Start ();
41 | proc.WaitForExit ();
42 | dev = proc.StandardOutput.ReadToEnd ().Trim ();
43 | };
44 | return dev;
45 | }
46 |
47 | public override void OnRefresh ()
48 | {
49 | var value = ReadActualValue ();
50 | var elements = value.Split (new string[] { " " }, System.StringSplitOptions.RemoveEmptyEntries);
51 | if (elements.Length == 2) {
52 | foreach (var element in elements) {
53 | var elementValues = element.Split ('=');
54 | if (elementValues[0] == "Temp") {
55 | Temperature = elementValues[1];
56 | }
57 | else if (elementValues[0] == "Humidity") {
58 | Humidity = elementValues[1];
59 | }
60 | }
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.GTK.Raspberry/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 | using Xamarin.Forms.Platform.GTK;
4 |
5 | namespace WeatherApp.GTK.Raspberry
6 | {
7 | class Program
8 | {
9 | static void Main (string[] args)
10 | {
11 | //TODO: This is an example of reading a sensor using the output of a python script
12 | //the python code is available from https://github.com/adafruit/Adafruit_Python_DHT/blob/master/examples/AdafruitDHT.py
13 | //you need to copy to the raspberry
14 | var script = "/home/pi/Adafruit_Python_DHT/examples/AdafruitDHT.py";
15 | var sensor = new HumiditySensorDHT22 (18, script);
16 |
17 | Gtk.Application.Init ();
18 | Forms.Init ();
19 |
20 | var app = new App (sensor);
21 | var window = new FormsWindow ();
22 | window.LoadApplication (app);
23 | window.SetApplicationTitle ("WeatherApp");
24 | window.Show ();
25 | Gtk.Application.Run ();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.GTK.Raspberry/WeatherApp.Gtk.Raspberry.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 | WeatherApp.GTK.Raspberry
7 | WeatherApp.GTK.Raspberry
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.GTK.Raspberry/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.GTK/Program.cs:
--------------------------------------------------------------------------------
1 | using Xamarin.Forms;
2 | using Xamarin.Forms.Platform.GTK;
3 | using WeatherApp;
4 |
5 | namespace WeatherApp.GTK
6 | {
7 | class Program
8 | {
9 | static void Main(string[] args)
10 | {
11 | Gtk.Application.Init();
12 | Forms.Init();
13 |
14 | var sensor = new FakeHumiditySensor ();
15 | var app = new App(sensor);
16 | var window = new FormsWindow();
17 | window.LoadApplication(app);
18 | window.SetApplicationTitle("WeatherApp");
19 | window.Show();
20 | Gtk.Application.Run();
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.GTK/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // La información general de un ensamblado se controla mediante el siguiente
6 | // conjunto de atributos. Cambie estos valores de atributo para modificar la información
7 | // asociada con un ensamblado.
8 | [assembly: AssemblyTitle("WeatherApp.GTK")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WeatherApp.GTK")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Si establece ComVisible en false, los tipos de este ensamblado no estarán visibles
18 | // para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde
19 | // COM, establezca el atributo ComVisible en true en este tipo.
20 | [assembly: ComVisible(false)]
21 |
22 | // El siguiente GUID sirve como id. de typelib si este proyecto se expone a COM.
23 | [assembly: Guid("15caae9a-5b32-4fc9-b9f0-d44c006a0679")]
24 |
25 | // La información de versión de un ensamblado consta de los cuatro valores siguientes:
26 | //
27 | // Versión principal
28 | // Versión secundaria
29 | // Número de compilación
30 | // Revisión
31 | //
32 | // Puede especificar todos los valores o usar los valores predeterminados de número de compilación y de revisión
33 | // mediante el carácter '*', como se muestra a continuación:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.GTK/WeatherApp.GTK.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {15CAAE9A-5B32-4FC9-B9F0-D44C006A0679}
8 | WinExe
9 | Properties
10 | WeatherApp.GTK
11 | WeatherApp.GTK
12 | v4.5.2
13 | 512
14 |
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | ..\..\packages\Xamarin.Forms.3.0.0\lib\net45\Xamarin.Forms.Core.dll
48 |
49 |
50 | ..\..\packages\Xamarin.Forms.3.0.0\lib\net45\Xamarin.Forms.Platform.dll
51 |
52 |
53 | ..\..\packages\Xamarin.Forms.3.0.0\lib\net45\Xamarin.Forms.Platform.GTK.dll
54 |
55 |
56 | ..\..\packages\Xamarin.Forms.3.0.0\lib\net45\Xamarin.Forms.Xaml.dll
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}
79 | WeatherApp
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.GTK/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp.GTK/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/App.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using Xamarin.Forms;
7 |
8 | namespace WeatherApp
9 | {
10 | public class App : Application
11 | {
12 | public App (IHumiditySensor humidity)
13 | {
14 | var weader = new WeatherPage (humidity);
15 | MainPage = new NavigationPage(weader);
16 | }
17 |
18 | protected override void OnStart()
19 | {
20 | // Handle when your app starts
21 | }
22 |
23 | protected override void OnSleep()
24 | {
25 | // Handle when your app sleeps
26 | }
27 |
28 | protected override void OnResume()
29 | {
30 | // Handle when your app resumes
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/Core.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 |
4 | namespace WeatherApp
5 | {
6 | public class Core
7 | {
8 |
9 | public static async Task GetWeather(string zipCode)
10 | {
11 | //Sign up for a free API key at http://openweathermap.org/appid
12 | string key = "42c0e77ad3018dc3c35da3da97274faf";
13 | string queryString = "http://api.openweathermap.org/data/2.5/weather?zip="
14 | + zipCode + "&appid=" + key;
15 | //02116
16 | try {
17 | var results = await DataService.getDataFromService (queryString).ConfigureAwait (false);
18 |
19 | Weather weather = new Weather {
20 | Title = (string)results["name"],
21 | Temperature = (string)results["main"]["temp"] + " F",
22 | Wind = (string)results["wind"]["speed"] + " mph",
23 | Humidity = (string)results["main"]["humidity"] + " %",
24 | Visibility = (string)results["weather"][0]["main"]
25 | };
26 | DateTime time = new System.DateTime (1970, 1, 1, 0, 0, 0, 0);
27 | DateTime sunrise = time.AddSeconds ((double)results["sys"]["sunrise"]);
28 | DateTime sunset = time.AddSeconds ((double)results["sys"]["sunset"]);
29 | weather.Sunrise = sunrise.ToString () + " UTC";
30 | weather.Sunset = sunset.ToString () + " UTC";
31 | return weather;
32 | }
33 | catch (Exception ex) {
34 |
35 | }
36 | return new Weather () {
37 | Title = "Postal Code not found"
38 | };
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/DataService.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using Newtonsoft.Json;
3 | using System.Net.Http;
4 | using Newtonsoft.Json.Linq;
5 |
6 | namespace WeatherApp
7 | {
8 | public class DataService
9 | {
10 | public static async Task getDataFromService(string queryString)
11 | {
12 | HttpClient client = new HttpClient ();
13 | var response = await client.GetAsync (queryString);
14 |
15 | JContainer data = null;
16 | if (response != null) {
17 | string json = response.Content.ReadAsStringAsync ().Result;
18 | data = (JContainer)JsonConvert.DeserializeObject (json);
19 | }
20 |
21 | return data;
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("WeatherApp")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("WeatherApp")]
14 | [assembly: AssemblyCopyright("Copyright © 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: NeutralResourcesLanguage("en")]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | //
26 | // You can specify all the values or you can default the Build and Revision Numbers
27 | // by using the '*' as shown below:
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("1.0.0.0")]
30 | [assembly: AssemblyFileVersion("1.0.0.0")]
31 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/Sensor/BaseHumiditySensor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 |
5 | namespace WeatherApp
6 | {
7 | public abstract class BaseHumiditySensor : IHumiditySensor
8 | {
9 | public event EventHandler NeedsRefresh;
10 | readonly CancellationTokenSource source;
11 |
12 | public string Temperature {
13 | get;
14 | protected set;
15 | }
16 |
17 | public string Humidity {
18 | get;
19 | protected set;
20 | }
21 |
22 | protected BaseHumiditySensor ()
23 | {
24 | source = new CancellationTokenSource ();
25 | }
26 |
27 | public override string ToString ()
28 | {
29 | return string.Format ("[HumiditySensor: Temperature={0}, Humidity={1}]", Temperature, Humidity);
30 | }
31 |
32 | public virtual void Stop ()
33 | {
34 | source.Cancel ();
35 | }
36 |
37 | public virtual void Start ()
38 | {
39 | Task.Run (() => {
40 | while (!source.IsCancellationRequested) {
41 | Refresh ();
42 | Task.Delay (3000).Wait ();
43 | }
44 |
45 | }, source.Token);
46 | }
47 |
48 | void Refresh ()
49 | {
50 | OnRefresh ();
51 | NeedsRefresh?.Invoke (this, EventArgs.Empty);
52 | }
53 |
54 | public abstract void OnRefresh ();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/Sensor/FakeHumiditySensor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WeatherApp
4 | {
5 | public class FakeHumiditySensor : BaseHumiditySensor
6 | {
7 | readonly Random rand;
8 |
9 | public FakeHumiditySensor ()
10 | {
11 | rand = new Random (DateTime.Now.Millisecond);
12 | }
13 |
14 | public override void OnRefresh ()
15 | {
16 | Temperature = string.Format ("{0}ºC", rand.Next (30, 90));
17 | Humidity = string.Format ("{0}%", rand.Next (30, 130));
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/Sensor/IHumiditySensor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace WeatherApp
4 | {
5 | public interface IHumiditySensor
6 | {
7 | event EventHandler NeedsRefresh;
8 | string Temperature { get; }
9 | string Humidity { get; }
10 | void Start ();
11 | }
12 | }
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/Weather.cs:
--------------------------------------------------------------------------------
1 | namespace WeatherApp
2 | {
3 | public class Weather
4 | {
5 | public string Title { get; set; }
6 | public string Temperature { get; set; }
7 | public string Wind { get; set; }
8 | public string Humidity { get; set; }
9 | public string Visibility { get; set; }
10 | public string Sunrise { get; set; }
11 | public string Sunset { get; set; }
12 |
13 | public Weather()
14 | {
15 | //Because labels bind to these values, set them to an empty string to
16 | //ensure that the label appears on all platforms by default.
17 | this.Title = " ";
18 | this.Temperature = " ";
19 | this.Wind = " ";
20 | this.Humidity = " ";
21 | this.Visibility = " ";
22 | this.Sunrise = " ";
23 | this.Sunset = " ";
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/WeatherApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 10.0
6 | Debug
7 | AnyCPU
8 | {6C871F12-A23B-4974-A3AB-5CBB9D642E41}
9 | Library
10 | Properties
11 | WeatherApp
12 | WeatherApp
13 | v4.5
14 | Profile111
15 | 512
16 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
17 |
18 |
19 |
20 |
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | WeatherPage.xaml
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | ..\..\packages\Newtonsoft.Json.10.0.2\lib\portable-net45+win8+wpa81+wp8\Newtonsoft.Json.dll
53 | True
54 |
55 |
56 | ..\..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net45+win8+wpa81\System.Net.Http.Extensions.dll
57 | True
58 |
59 |
60 | ..\..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net45+win8+wpa81\System.Net.Http.Primitives.dll
61 | True
62 |
63 |
64 | ..\..\packages\Xamarin.Forms.3.0.0\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll
65 | True
66 |
67 |
68 | ..\..\packages\Xamarin.Forms.3.0.0\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll
69 | True
70 |
71 |
72 | ..\..\packages\Xamarin.Forms.3.0.0\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll
73 | True
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | MSBuild:UpdateDesignTimeXaml
82 | Designer
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
109 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/WeatherPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
12 |
18 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
29 |
30 |
32 |
33 |
34 |
35 |
36 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
69 |
70 |
71 |
72 |
74 |
75 |
76 |
77 |
79 |
80 |
81 |
82 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/WeatherPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 |
4 | namespace WeatherApp
5 | {
6 | public partial class WeatherPage : ContentPage
7 | {
8 | void Humidity_NeedsRefresh (object sender, EventArgs e)
9 | {
10 | Device.BeginInvokeOnMainThread (() => {
11 | //humidity
12 | lblRealtime.Text = $"Temp={humidity.Temperature} Humidity={humidity.Humidity}";
13 | });
14 | }
15 |
16 | IHumiditySensor humidity;
17 | public Weather WeatherContext {
18 | get { return (Weather)BindingContext; }
19 | set {
20 | BindingContext = value;
21 | }
22 | }
23 | public WeatherPage ()
24 | {
25 | InitializeComponent ();
26 | this.Title = "Sample Weather App";
27 | }
28 |
29 | public WeatherPage (IHumiditySensor humidity)
30 | {
31 | this.humidity = humidity;
32 |
33 | InitializeComponent();
34 | this.Title = "Sample Weather App";
35 | getWeatherBtn.Clicked += GetWeatherBtn_Clicked;
36 |
37 | //Set the default binding to a default object for now
38 | WeatherContext = new Weather();
39 |
40 |
41 | humidity.NeedsRefresh += Humidity_NeedsRefresh;
42 |
43 | humidity.Start ();
44 | }
45 |
46 | private async void GetWeatherBtn_Clicked(object sender, EventArgs e)
47 | {
48 | if (!String.IsNullOrEmpty(zipCodeEntry.Text))
49 | {
50 | Weather weather = await Core.GetWeather(zipCodeEntry.Text);
51 | if (weather != null)
52 | {
53 | WeatherContext = weather;
54 | getWeatherBtn.Text = "Search Again";
55 | }
56 | }
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/Forms.Gtk/WeatherApp/WeatherApp/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Forms.Gtk/readme.md:
--------------------------------------------------------------------------------
1 | WeatherApp for Xamarin.Forms
2 | ==========
3 |
4 | WeatherApp is an example that accompanies [Learn app-building basics with Xamarin.Forms in Visual Studio](https://msdn.microsoft.com/library/mt679501.aspx) (MSDN Library).
5 |
6 | It consists of a PCL that contains all the UI and business logic. The platform-specific projects for Android, iOS, and Windows are the minimal app stubs.
7 |
8 | 
9 |
10 |
11 | To use this sample, you must first sign up for a free API key at [http://openweathermap.org/appid](http://openweathermap.org/appid). Paste that key in place of *YOUR API KEY HERE* in the following line of **WeatherApp/Core.cs**:
12 |
13 | ```
14 | string key = "YOUR API KEY HERE";
15 | ```
16 |
17 | Native Version
18 | --------------
19 |
20 | The equivalent app written with native UI layers, is [WeatherApp (Native)](https://github.com/xamarin/mobile-samples/tree/master/Weather).
21 |
22 | Authors
23 | -------
24 |
25 | Kraig Brockschmidt, Nicole Haugen
26 |
--------------------------------------------------------------------------------
/Hermes.Mqtt/IoTMqttTest.Server/IoTMqttTest.Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Hermes.Mqtt/IoTMqttTest.Server/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Net.Mqtt;
4 | using System.Net.Sockets;
5 | using System.Text;
6 | using System.Threading;
7 |
8 | namespace IoTMqttTest.Server
9 | {
10 | class Program
11 | {
12 | const int loopDelayTime = 250;
13 | const string topic = "test/chat/message";
14 | const string exitMessage = "exit";
15 |
16 | static void Main (string[] args)
17 | {
18 | bool isFinishing = false;
19 | var deviceIpAddress = GetLocalIPAddress();
20 | var config = new MqttConfiguration { Port = 55555 };
21 | var server = MqttServer.Create (config);
22 |
23 | server.Start ();
24 |
25 | var client = server.CreateClientAsync ().Result;
26 | var clientId = client.Id;
27 | var received = "";
28 |
29 | client.SubscribeAsync (topic, MqttQualityOfService.AtLeastOnce).Wait();
30 | client.MessageStream.Subscribe (message => {
31 | if (isFinishing)
32 | return;
33 | var data = Encoding.UTF8.GetString (message.Payload).Split (new string[] { ":" }, StringSplitOptions.None);
34 | Console.WriteLine ($"Message Received from {data[0]}: {data[1]}");
35 |
36 | received = data[1];
37 |
38 | PublishAsync (client, clientId, exitMessage);
39 |
40 | if (received == exitMessage)
41 | isFinishing = true;
42 | });
43 |
44 | Console.WriteLine ($"Server {deviceIpAddress}:{config.Port} with topic '{topic}' is up.");
45 | Console.WriteLine ($"Awaiting messages...");
46 |
47 | while (received != exitMessage) {
48 | Thread.Sleep (loopDelayTime);
49 | }
50 | Console.WriteLine("Shutting down... Received exit command.");
51 | }
52 |
53 | static void PublishAsync (IMqttConnectedClient client, string clientId, string message)
54 | {
55 | Console.WriteLine ($"Sending message to {clientId}: {message}");
56 | client.PublishAsync (new MqttApplicationMessage (topic, Encoding.UTF8.GetBytes ($"{clientId}:{message}")), MqttQualityOfService.AtLeastOnce).Wait();
57 | }
58 |
59 | public static string GetLocalIPAddress()
60 | {
61 | var host = Dns.GetHostEntry (Dns.GetHostName());
62 | foreach (var ip in host.AddressList) {
63 | if (ip.AddressFamily == AddressFamily.InterNetwork)
64 | return ip.ToString();
65 | }
66 | throw new Exception("Local IP Address Not Found!");
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Hermes.Mqtt/MqttHermesExample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MqttTest.Client", "MqttTest.Client\MqttTest.Client.csproj", "{B94C1D6C-1522-4BBB-B809-E96080742BD2}"
5 | EndProject
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTMqttTest.Server", "IoTMqttTest.Server\IoTMqttTest.Server.csproj", "{F0E119A6-5700-4B02-907E-852F0AAE1D63}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B94C1D6C-1522-4BBB-B809-E96080742BD2}.Debug|x86.ActiveCfg = Debug|Any CPU
15 | {B94C1D6C-1522-4BBB-B809-E96080742BD2}.Debug|x86.Build.0 = Debug|Any CPU
16 | {B94C1D6C-1522-4BBB-B809-E96080742BD2}.Release|x86.ActiveCfg = Release|Any CPU
17 | {B94C1D6C-1522-4BBB-B809-E96080742BD2}.Release|x86.Build.0 = Release|Any CPU
18 | {F0E119A6-5700-4B02-907E-852F0AAE1D63}.Debug|x86.ActiveCfg = Debug|Any CPU
19 | {F0E119A6-5700-4B02-907E-852F0AAE1D63}.Debug|x86.Build.0 = Debug|Any CPU
20 | {F0E119A6-5700-4B02-907E-852F0AAE1D63}.Release|x86.ActiveCfg = Release|Any CPU
21 | {F0E119A6-5700-4B02-907E-852F0AAE1D63}.Release|x86.Build.0 = Release|Any CPU
22 | EndGlobalSection
23 | EndGlobal
24 |
--------------------------------------------------------------------------------
/Hermes.Mqtt/MqttTest.Client/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Hermes.Mqtt/MqttTest.Client/MqttTest.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B94C1D6C-1522-4BBB-B809-E96080742BD2}
8 | Exe
9 | Properties
10 | MqttTest.Client
11 | MqttTest.Client
12 | v4.6
13 | 512
14 | true
15 |
16 |
17 |
18 | anycpu
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 | ..\packages\System.Diagnostics.Tracer.2.0.4\lib\net45\System.Diagnostics.Tracer.dll
41 | True
42 |
43 |
44 | ..\packages\System.Net.Mqtt.0.4.2-experimental\lib\netstandard1.3\System.Net.Mqtt.dll
45 | True
46 |
47 |
48 | ..\packages\System.Net.Sockets.4.1.0\lib\net46\System.Net.Sockets.dll
49 | True
50 |
51 |
52 | ..\packages\System.Reactive.Core.3.0.0\lib\net46\System.Reactive.Core.dll
53 | True
54 |
55 |
56 | ..\packages\System.Reactive.Interfaces.3.0.0\lib\net45\System.Reactive.Interfaces.dll
57 | True
58 |
59 |
60 | ..\packages\System.Reactive.Linq.3.0.0\lib\net46\System.Reactive.Linq.dll
61 | True
62 |
63 |
64 | ..\packages\System.Reactive.PlatformServices.3.0.0\lib\net46\System.Reactive.PlatformServices.dll
65 | True
66 |
67 |
68 | ..\packages\System.Reactive.Windows.Threading.3.0.0\lib\net45\System.Reactive.Windows.Threading.dll
69 | True
70 |
71 |
72 |
73 | ..\packages\System.Runtime.Serialization.Primitives.4.1.1\lib\net46\System.Runtime.Serialization.Primitives.dll
74 | True
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
100 |
--------------------------------------------------------------------------------
/Hermes.Mqtt/MqttTest.Client/MqttTest.Client.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Project
5 | true
6 |
7 |
--------------------------------------------------------------------------------
/Hermes.Mqtt/MqttTest.Client/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net;
3 | using System.Net.Mqtt;
4 | using System.Text;
5 | using System.Threading;
6 |
7 | namespace MqttTest.Client
8 | {
9 | class Program
10 | {
11 | const int loopDelayTime = 250;
12 | const string topic = "test/chat/message";
13 | const string exitMessage = "exit";
14 |
15 | static void Main (string[] args)
16 | {
17 | bool isFinishing = false;
18 | var config = new MqttConfiguration { Port = 55555 };
19 | var client = MqttClient.CreateAsync ("10.67.1.69", config).Result;
20 | var clientId = "XamarinClient";
21 | var received = "";
22 |
23 | client.ConnectAsync (new MqttClientCredentials (clientId)).Wait ();
24 | client.SubscribeAsync (topic, MqttQualityOfService.AtLeastOnce).Wait ();
25 | client.MessageStream.Subscribe (message => {
26 | if (isFinishing)
27 | return;
28 |
29 | var data = Encoding.UTF8.GetString (message.Payload).Split (new string[] { ":" }, StringSplitOptions.None);
30 | Console.WriteLine ($"Message Received from {data[0]}:{data[1]}");
31 | PublishAsync (client, clientId, exitMessage);
32 |
33 | //Send exit to server
34 | received = data[1];
35 |
36 | if (received == exitMessage)
37 | isFinishing = true;
38 | });
39 |
40 | Console.WriteLine ($"Client connected successfully to {client.Id}:{config.Port}");
41 | Console.WriteLine ($"Awaiting messages...");
42 |
43 | PublishAsync (client, clientId, "Connected.");
44 |
45 | while (received != exitMessage) {
46 | Thread.Sleep (loopDelayTime);
47 | }
48 | Console.WriteLine ("Shutting down... Received exit command.");
49 | }
50 |
51 | static void PublishAsync (IMqttClient client, string clientId, string message)
52 | {
53 | Console.WriteLine ($"Sending message: {message}");
54 | client.PublishAsync (new MqttApplicationMessage (topic, Encoding.UTF8.GetBytes ($"{clientId}:{message}")), MqttQualityOfService.AtLeastOnce).Wait();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Hermes.Mqtt/MqttTest.Client/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle ("MqttTest.Client")]
9 | [assembly: AssemblyDescription ("")]
10 | [assembly: AssemblyConfiguration ("")]
11 | [assembly: AssemblyCompany ("")]
12 | [assembly: AssemblyProduct ("MqttTest.Client")]
13 | [assembly: AssemblyCopyright ("Copyright © 2017")]
14 | [assembly: AssemblyTrademark ("")]
15 | [assembly: AssemblyCulture ("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible (false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid ("b94c1d6c-1522-4bbb-b809-e96080742bd2")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion ("1.0.0.0")]
36 | [assembly: AssemblyFileVersion ("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Hermes.Mqtt/MqttTest.Client/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/IoTSharp.Components/HubExamples/BlindHubTest.cs:
--------------------------------------------------------------------------------
1 | namespace IoTSharp.Components.Examples
2 | {
3 | public class BlindHubTest : IoTHubContainer
4 | {
5 | public void Configure (IIoTBlind blind)
6 | {
7 | AddComponent (blind);
8 | }
9 |
10 | public override void Init ()
11 | {
12 | var blind = GetComponent ();
13 | blind.Down ();
14 | blind.Up ();
15 | blind.Stop ();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/IoTSharp.Components/HubExamples/ButtonHubTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace IoTSharp.Components.Examples
4 | {
5 | public class ButtonHubTest : IoTHubContainer
6 | {
7 | IIoTButton button;
8 |
9 | public void Configure (IIoTRelay relay, IIoTButton button)
10 | {
11 | this.button = button;
12 | AddComponent (relay, button);
13 |
14 | button.ButtonDown += Button_ButtonDown;
15 | }
16 |
17 | public void Button_ButtonDown ()
18 | {
19 | GetComponent ().Toggle (0);
20 | }
21 |
22 | public override void Dispose ()
23 | {
24 | button.ButtonDown -= Button_ButtonDown;
25 | base.Dispose ();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/IoTSharp.Components/HubExamples/RelayHubTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 |
4 | namespace IoTSharp.Components.Examples
5 | {
6 | public class RelayHubTest : IoTHubContainer
7 | {
8 | public event EventHandler Step;
9 | public event EventHandler Finished;
10 | int count;
11 |
12 | public void Configure (IIoTRelay relay)
13 | {
14 | AddComponent (relay);
15 | SetDelayTime (250);
16 | }
17 |
18 | public override void Update ()
19 | {
20 | var relayComponent = GetComponent ();
21 | relayComponent.Toggle (0);
22 | Thread.Sleep (DelayTime);
23 | relayComponent.Toggle (1);
24 |
25 | if (count == 10) {
26 | Stop ();
27 | Finished?.Invoke (this, EventArgs.Empty);
28 | } else {
29 | count++;
30 | Step?.Invoke (this, count);
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/IoTSharp.Components/HubExamples/SensorHubTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace IoTSharp.Components.Examples
4 | {
5 | class SensorHubTest : IoTHubContainer
6 | {
7 | public void Configure (IIoTSensor presence, IIoTRelay relay)
8 | {
9 | AddComponent (presence, relay);
10 | }
11 |
12 | public override void Init ()
13 | {
14 | GetComponent ()
15 | .PresenceStatusChanged += PresenceStatusChanged;
16 | }
17 |
18 | public void PresenceStatusChanged (bool active) {
19 | Console.WriteLine ($"PresenceStatusChanged {active}");
20 | GetComponent ().EnablePin (0, active);
21 | }
22 |
23 | public override void Dispose ()
24 | {
25 | GetComponent ()
26 | .PresenceStatusChanged -= PresenceStatusChanged;
27 | base.Dispose ();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/IoTSharp.Components/IoTSharpComponents.Example.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 | 0.35
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/IoTSharp.Components/IoTSharpComponents.Example.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 15.00
3 | # Visual Studio 2017
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTSharpComponents.Example", "IoTSharpComponents.Example.csproj", "{4D71B749-A46E-40EC-9CB7-C5140B31A540}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {4D71B749-A46E-40EC-9CB7-C5140B31A540}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {4D71B749-A46E-40EC-9CB7-C5140B31A540}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {4D71B749-A46E-40EC-9CB7-C5140B31A540}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {4D71B749-A46E-40EC-9CB7-C5140B31A540}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | EndGlobal
18 |
--------------------------------------------------------------------------------
/IoTSharp.Components/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Threading;
4 |
5 | namespace IoTSharp.Components.Examples.Raspbian
6 | {
7 | class Program
8 | {
9 | const int maxCount = 4;
10 | const int delayTime = 150;
11 | static readonly ITracer tracer = Tracer.Get ();
12 | static int count;
13 |
14 | static void Main (string [] args)
15 | {
16 | Console.WriteLine ("Welcome to Raspberry Extensions tests");
17 |
18 | //Push Switch or button connected to Gpio27
19 | var button = new IoTButton (Connectors.GPIO27);
20 | button.ButtonDown += delegate {
21 | Console.WriteLine ($"DOWN!!!");
22 | };
23 | button.ButtonUp += delegate {
24 | Console.WriteLine ($"UP!!!");
25 | };
26 | button.Clicked += delegate {
27 | count++;
28 | Console.WriteLine ($"PRESSED THE BUTTON!!! {count}/{maxCount}");
29 | };
30 |
31 | while (count < maxCount) {
32 | button.Update ();
33 | Thread.Sleep (delayTime);
34 | }
35 |
36 | Console.WriteLine ("Finished execution.");
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/IoTSharp.Components/README.md:
--------------------------------------------------------------------------------
1 | # IoTSharp.Components
2 |
3 | This project is Open Source and code is available in:
4 | https://github.com/netonjm/iotsharp-components
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Xamarin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 | using UIKit;
3 |
4 | namespace HomeAutomation.Blind.IOS
5 | {
6 | // The UIApplicationDelegate for the application. This class is responsible for launching the
7 | // User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
8 | [Register ("AppDelegate")]
9 | public class AppDelegate : UIApplicationDelegate
10 | {
11 | // class-level declarations
12 |
13 | public override UIWindow Window {
14 | get;
15 | set;
16 | }
17 |
18 | public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
19 | {
20 | // Override point for customization after application launch.
21 | // If not required for your application you can safely delete this method
22 |
23 | return true;
24 | }
25 |
26 | public override void OnResignActivation (UIApplication application)
27 | {
28 | // Invoked when the application is about to move from active to inactive state.
29 | // This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
30 | // or when the user quits the application and it begins the transition to the background state.
31 | // Games should use this method to pause the game.
32 | }
33 |
34 | public override void DidEnterBackground (UIApplication application)
35 | {
36 | // Use this method to release shared resources, save user data, invalidate timers and store the application state.
37 | // If your application supports background exection this method is called instead of WillTerminate when the user quits.
38 | }
39 |
40 | public override void WillEnterForeground (UIApplication application)
41 | {
42 | // Called as part of the transiton from background to active state.
43 | // Here you can undo many of the changes made on entering the background.
44 | }
45 |
46 | public override void OnActivated (UIApplication application)
47 | {
48 | // Restart any tasks that were paused (or not yet started) while the application was inactive.
49 | // If the application was previously in the background, optionally refresh the user interface.
50 | }
51 |
52 | public override void WillTerminate (UIApplication application)
53 | {
54 | // Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
55 | }
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "idiom": "iphone",
5 | "size": "29x29",
6 | "scale": "1x"
7 | },
8 | {
9 | "idiom": "iphone",
10 | "size": "29x29",
11 | "scale": "2x"
12 | },
13 | {
14 | "idiom": "iphone",
15 | "size": "29x29",
16 | "scale": "3x"
17 | },
18 | {
19 | "idiom": "iphone",
20 | "size": "40x40",
21 | "scale": "2x"
22 | },
23 | {
24 | "idiom": "iphone",
25 | "size": "40x40",
26 | "scale": "3x"
27 | },
28 | {
29 | "idiom": "iphone",
30 | "size": "57x57",
31 | "scale": "1x"
32 | },
33 | {
34 | "idiom": "iphone",
35 | "size": "57x57",
36 | "scale": "2x"
37 | },
38 | {
39 | "idiom": "iphone",
40 | "size": "60x60",
41 | "scale": "2x"
42 | },
43 | {
44 | "idiom": "iphone",
45 | "size": "60x60",
46 | "scale": "3x"
47 | },
48 | {
49 | "idiom": "ipad",
50 | "size": "29x29",
51 | "scale": "1x"
52 | },
53 | {
54 | "idiom": "ipad",
55 | "size": "29x29",
56 | "scale": "2x"
57 | },
58 | {
59 | "idiom": "ipad",
60 | "size": "40x40",
61 | "scale": "1x"
62 | },
63 | {
64 | "idiom": "ipad",
65 | "size": "40x40",
66 | "scale": "2x"
67 | },
68 | {
69 | "idiom": "ipad",
70 | "size": "50x50",
71 | "scale": "1x"
72 | },
73 | {
74 | "idiom": "ipad",
75 | "size": "50x50",
76 | "scale": "2x"
77 | },
78 | {
79 | "idiom": "ipad",
80 | "size": "72x72",
81 | "scale": "1x"
82 | },
83 | {
84 | "idiom": "ipad",
85 | "size": "72x72",
86 | "scale": "2x"
87 | },
88 | {
89 | "idiom": "ipad",
90 | "size": "76x76",
91 | "scale": "1x"
92 | },
93 | {
94 | "idiom": "ipad",
95 | "size": "76x76",
96 | "scale": "2x"
97 | },
98 | {
99 | "size": "24x24",
100 | "idiom": "watch",
101 | "scale": "2x",
102 | "role": "notificationCenter",
103 | "subtype": "38mm"
104 | },
105 | {
106 | "size": "27.5x27.5",
107 | "idiom": "watch",
108 | "scale": "2x",
109 | "role": "notificationCenter",
110 | "subtype": "42mm"
111 | },
112 | {
113 | "size": "29x29",
114 | "idiom": "watch",
115 | "role": "companionSettings",
116 | "scale": "2x"
117 | },
118 | {
119 | "size": "29x29",
120 | "idiom": "watch",
121 | "role": "companionSettings",
122 | "scale": "3x"
123 | },
124 | {
125 | "size": "40x40",
126 | "idiom": "watch",
127 | "scale": "2x",
128 | "role": "appLauncher",
129 | "subtype": "38mm"
130 | },
131 | {
132 | "size": "44x44",
133 | "idiom": "watch",
134 | "scale": "2x",
135 | "role": "longLook",
136 | "subtype": "42mm"
137 | },
138 | {
139 | "size": "86x86",
140 | "idiom": "watch",
141 | "scale": "2x",
142 | "role": "quickLook",
143 | "subtype": "38mm"
144 | },
145 | {
146 | "size": "98x98",
147 | "idiom": "watch",
148 | "scale": "2x",
149 | "role": "quickLook",
150 | "subtype": "42mm"
151 | }
152 | ],
153 | "info": {
154 | "version": 1,
155 | "author": "xcode"
156 | }
157 | }
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/HomeAutomation.Blind.IOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | iPhoneSimulator
6 | {FF2C6E66-9E6F-4A0E-A74A-A7DB50F4B0A7}
7 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
8 | Exe
9 | HomeAutomation.Blind.IOS
10 | HomeAutomation.Blind.IOS
11 | Resources
12 |
13 |
14 | true
15 | full
16 | false
17 | bin\iPhoneSimulator\Debug
18 | DEBUG;ENABLE_TEST_CLOUD;
19 | prompt
20 | 4
21 | iPhone Developer
22 | true
23 | true
24 | true
25 | 47884
26 | None
27 | x86_64
28 | HttpClientHandler
29 | Default
30 | x86
31 | false
32 |
33 |
34 | pdbonly
35 | true
36 | bin\iPhone\Release
37 |
38 | prompt
39 | 4
40 | iPhone Developer
41 | true
42 | Entitlements.plist
43 | SdkOnly
44 | ARMv7, ARM64
45 | HttpClientHandler
46 | Default
47 | x86
48 |
49 |
50 | pdbonly
51 | true
52 | bin\iPhoneSimulator\Release
53 |
54 | prompt
55 | 4
56 | iPhone Developer
57 | None
58 | x86_64
59 | HttpClientHandler
60 | Default
61 | x86
62 |
63 |
64 | true
65 | full
66 | false
67 | bin\iPhone\Debug
68 | DEBUG;ENABLE_TEST_CLOUD;
69 | prompt
70 | 4
71 | iPhone Developer
72 | true
73 | true
74 | true
75 | true
76 | true
77 | Entitlements.plist
78 | SdkOnly
79 | ARMv7, ARM64
80 | HttpClientHandler
81 | Default
82 | x86
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | ViewController.cs
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleName
6 | HomeAutomation.Blind.IOS
7 | CFBundleIdentifier
8 | com.microsoft.appexplorer.homeautomation-ios
9 | CFBundleShortVersionString
10 | 1.0
11 | CFBundleVersion
12 | 1.0
13 | LSRequiresIPhoneOS
14 |
15 | MinimumOSVersion
16 | 10.2
17 | UIDeviceFamily
18 |
19 | 1
20 | 2
21 |
22 | UILaunchStoryboardName
23 | LaunchScreen
24 | UIMainStoryboardFile
25 | Main
26 | UIRequiredDeviceCapabilities
27 |
28 | armv7
29 |
30 | UISupportedInterfaceOrientations
31 |
32 | UIInterfaceOrientationPortrait
33 |
34 | XSAppIconAssets
35 | Assets.xcassets/AppIcon.appiconset
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/Main.cs:
--------------------------------------------------------------------------------
1 | using UIKit;
2 |
3 | namespace HomeAutomation.Blind.IOS
4 | {
5 | public class Application
6 | {
7 | // This is the main entry point of the application.
8 | static void Main (string [] args)
9 | {
10 | // if you want to use a different Application Delegate class from "AppDelegate"
11 | // you can specify it here.
12 | UIApplication.Main (args, null, "AppDelegate");
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
33 |
41 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/Remote.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xamarin/xamarin-iot-samples/f17750a1f4a3207eecbecfa40a71360df3fb9972/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/Remote.png
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/Settings.bundle/Root.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreferenceSpecifiers
6 |
7 |
8 | Type
9 | PSGroupSpecifier
10 | Title
11 | Server
12 |
13 |
14 | Type
15 | PSTextFieldSpecifier
16 | Title
17 | IPAddress
18 | KeyboardType
19 | Alphabet
20 | AutocapitalizationType
21 | None
22 | AutocorrectionType
23 | No
24 | IsSecure
25 |
26 | Key
27 | ipaddress
28 | DefaultValue
29 | 10.67.1.68
30 |
31 |
32 | Type
33 | PSTextFieldSpecifier
34 | Title
35 | Port
36 | Key
37 | port
38 | DefaultValue
39 | 8085
40 |
41 |
42 | StringsTable
43 | Root
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/ViewController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Net;
4 | using System.Threading.Tasks;
5 | using AudioToolbox;
6 | using Foundation;
7 | using UIKit;
8 |
9 | namespace HomeAutomation.Blind.IOS
10 | {
11 | public partial class ViewController : UIViewController
12 | {
13 | const int DefaultPort = 8085;
14 | string host;
15 | int port;
16 | string apiURL => $"http://{host}:{port}/blind/";
17 |
18 | enum BlindAction
19 | {
20 | Stop, Up, Down
21 | }
22 |
23 | protected ViewController (IntPtr handle) : base (handle)
24 | {
25 | // Note: this .ctor should not contain any initialization logic.
26 | }
27 |
28 | public override void ViewDidLoad ()
29 | {
30 | base.ViewDidLoad ();
31 |
32 | ParseSettings (out host, out port);
33 | }
34 |
35 | partial void BtnUp_TouchDownInside (UIButton sender)
36 | {
37 | btnUp.BackgroundColor = UIColor.Black;
38 | SystemSound.Vibrate.PlaySystemSound ();
39 | }
40 |
41 | partial void BtnDtop_TouchDownInside (UIButton sender)
42 | {
43 | btnStop.BackgroundColor = UIColor.Black;
44 | SystemSound.Vibrate.PlaySystemSound ();
45 | }
46 |
47 | partial void BtnDown_TouchDownInside (UIButton sender)
48 | {
49 | btnDown.BackgroundColor = UIColor.Black;
50 | SystemSound.Vibrate.PlaySystemSound ();
51 | }
52 |
53 | partial void BtnUp_TouchUpInside (UIButton sender)
54 | {
55 | btnUp.BackgroundColor = null;
56 | ExecuteBlindAction (BlindAction.Up);
57 | }
58 |
59 | partial void BtnStop_TouchUpInside (UIButton sender)
60 | {
61 | btnStop.BackgroundColor = null;
62 | ExecuteBlindAction (BlindAction.Stop);
63 | }
64 |
65 | partial void BtnDown_TouchUpInside (UIButton sender)
66 | {
67 | btnDown.BackgroundColor = null;
68 | ExecuteBlindAction (BlindAction.Down);
69 | }
70 |
71 | async void ExecuteBlindAction (BlindAction action)
72 | {
73 | var url = apiURL + (int)action;
74 | await FetchUrl (url);
75 | }
76 |
77 | public override void DidReceiveMemoryWarning ()
78 | {
79 | base.DidReceiveMemoryWarning ();
80 | // Release any cached data, images, etc that aren't in use.
81 | }
82 |
83 | // Gets weather data from the passed URL.
84 | async Task FetchUrl (string url)
85 | {
86 | try {
87 | // Create an HTTP web request using the URL:
88 | var request = (HttpWebRequest)WebRequest.Create (new Uri (url));
89 | request.ContentType = "application/json";
90 | request.Method = "GET";
91 |
92 | // Send the request to the server and wait for the response:
93 | using (WebResponse response = await request.GetResponseAsync ()) {
94 | // Get a stream representation of the HTTP web response:
95 | using (Stream stream = response.GetResponseStream ()) {
96 | // Use this stream to build a JSON document object:
97 | }
98 | }
99 | } catch (Exception ex) {
100 | System.Diagnostics.Debug.WriteLine (ex.Message);
101 | }
102 | }
103 |
104 | public void ParseSettings (out string host, out int port)
105 | {
106 | host = ""; port = 0;
107 | var settingsDict = new NSDictionary (NSBundle.MainBundle.PathForResource ("Settings.bundle/Root.plist", null));
108 | var prefSpecifierArray = settingsDict ["PreferenceSpecifiers"] as NSArray;
109 | foreach (var prefItem in NSArray.FromArray (prefSpecifierArray)) {
110 | var key = (NSString)prefItem ["Key"];
111 | if (key == null)
112 | continue;
113 |
114 | var val = prefItem ["DefaultValue"]?.ToString ();
115 | switch (key.ToString ()) {
116 | case "ipaddress":
117 | host = val;
118 | break;
119 | case "port":
120 | if (!int.TryParse (val, out port)) {
121 | port = DefaultPort;
122 | }
123 | break;
124 | }
125 | };
126 | }
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.IOS/ViewController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Xamarin Studio from the outlets and
4 | // actions declared in your storyboard file.
5 | // Manual changes to this file will not be maintained.
6 | //
7 | using Foundation;
8 | using System;
9 | using System.CodeDom.Compiler;
10 |
11 | namespace HomeAutomation.Blind.IOS
12 | {
13 | [Register ("ViewController")]
14 | partial class ViewController
15 | {
16 | [Outlet]
17 | [GeneratedCode ("iOS Designer", "1.0")]
18 | UIKit.UIButton btnDown { get; set; }
19 |
20 | [Outlet]
21 | [GeneratedCode ("iOS Designer", "1.0")]
22 | UIKit.UIButton btnStop { get; set; }
23 |
24 | [Outlet]
25 | [GeneratedCode ("iOS Designer", "1.0")]
26 | UIKit.UIButton btnUp { get; set; }
27 |
28 | [Action ("BtnDown_TouchDownInside:")]
29 | [GeneratedCode ("iOS Designer", "1.0")]
30 | partial void BtnDown_TouchDownInside (UIKit.UIButton sender);
31 |
32 | [Action ("BtnDown_TouchUpInside:")]
33 | [GeneratedCode ("iOS Designer", "1.0")]
34 | partial void BtnDown_TouchUpInside (UIKit.UIButton sender);
35 |
36 | [Action ("BtnDtop_TouchDownInside:")]
37 | [GeneratedCode ("iOS Designer", "1.0")]
38 | partial void BtnDtop_TouchDownInside (UIKit.UIButton sender);
39 |
40 | [Action ("BtnStop_TouchUpInside:")]
41 | [GeneratedCode ("iOS Designer", "1.0")]
42 | partial void BtnStop_TouchUpInside (UIKit.UIButton sender);
43 |
44 | [Action ("BtnUp_TouchDownInside:")]
45 | [GeneratedCode ("iOS Designer", "1.0")]
46 | partial void BtnUp_TouchDownInside (UIKit.UIButton sender);
47 |
48 | [Action ("BtnUp_TouchUpInside:")]
49 | [GeneratedCode ("iOS Designer", "1.0")]
50 | partial void BtnUp_TouchUpInside (UIKit.UIButton sender);
51 |
52 | void ReleaseDesignerOutlets ()
53 | {
54 | if (btnDown != null) {
55 | btnDown.Dispose ();
56 | btnDown = null;
57 | }
58 |
59 | if (btnStop != null) {
60 | btnStop.Dispose ();
61 | btnStop = null;
62 | }
63 |
64 | if (btnUp != null) {
65 | btnUp.Dispose ();
66 | btnUp = null;
67 | }
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.Server/HomeAutomation.Blind.Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net461
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Microsoft.AspNet.WebApi/HomeAutomation.Blind.Server/IoTFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using IoTSharp.Components;
5 |
6 | namespace HomeAutomation.Blind.Server
7 | {
8 | public static class IoTFactory
9 | {
10 | static readonly List