{"id":611,"date":"2016-11-16T13:00:59","date_gmt":"2016-11-16T13:00:59","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=21"},"modified":"2016-11-16T13:00:59","modified_gmt":"2016-11-16T13:00:59","slug":"creating-a-new-project","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/projects-general\/creating-a-new-project","title":{"rendered":"Creating A New Project"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Development Platform<\/h4>\n\n\n\n<p>Download the latest free Visual Studio community edition from Microsoft.<\/p>\n\n\n\n<p>When installing ensure the &#8220;Universal Windows Platform development&#8221; option is included.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Create A New Project<\/h4>\n\n\n\n<p>Menu &gt; File &gt; New Project<\/p>\n\n\n\n<p>Visual C# &gt; Blank App (Universal Windows)<\/p>\n\n\n\n<p>Give the project and name and location and create it.<\/p>\n\n\n\n<p>The version of Windows 10 to target it likely to be the most recent.<\/p>\n\n\n\n<p>Once created, in the&nbsp;architecture dropdown select &#8216;ARM&#8217;.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Add &#8220;Windows IoT Extension for UWP&#8221; to the&nbsp;project<\/h4>\n\n\n\n<p>Right click&nbsp;on your project. Then, select Add &gt; Reference..<\/p>\n\n\n\n<p>Select Universal Windows &gt; Exensions &gt; Windows IoT Extension for the UWP, select the latest version and press OK<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Setting App Capabilities<\/h4>\n\n\n\n<p>Open &#8220;Package.appxmanifest&#8221; and select the &#8216;Capabilities&#8217; tab.<\/p>\n\n\n\n<p>You need to select the items your app wants to use before you can use them.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Declaring App Links (Contracts) With Other Apps &amp; Windows<\/h4>\n\n\n\n<p>Open &#8220;Package.appxmanifest&#8221; and select the &#8216;Declarations&#8217; tab.<\/p>\n\n\n\n<p>Contracts (declarations) enable your app to cooperate with another app, or Windows itself, to complete a well-defined task. Every contract has a source that initiates the task and a target that completes it. Your app can be the source for a contract without doing anything in the package manifest&nbsp;(it just makes various API calls).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">The Project Files<\/h4>\n\n\n\n<p>App.xaml and App.xaml.cs. App.xaml<\/p>\n\n\n\n<p>The application definition. &nbsp;Its a special XAML file that doesn\u2019t define any visuals, but rather defines an App class that can handle application-level tasks. Usually the only reason to touch this XAML file is to place new application-wide resources, such as custom styles, inside its Application.Resources collection.<\/p>\n\n\n\n<p>Constructor &#8211;&nbsp;Effectively the app\u2019s main method. The plumbing that makes it the app\u2019s entry point is enabled by an \u201cEntry point\u201d setting in the package manifest (on the Application tab). When you create a project, Visual Studio automatically sets it to the namespace-qualified name of the project\u2019s App class.<\/p>\n\n\n\n<p>OnLaunched method &#8211;&nbsp;Enables the frame rate counter overlay in debug mode, navigates to the app\u2019s first page, and calls Window.Current.Activate to dismiss the splash screen. If you want to add a new page and make it be the starting point of the app, or if you want to customize the initialization logic, this is where you can do it.<\/p>\n\n\n\n<p>OnSuspending method &#8211;&nbsp;Attached to the base class\u2019s Suspending event. This gives you an opportunity to save state before your app is suspended, although the generated code does nothing here other than provide a TODO comment.<\/p>\n\n\n\n<p>MainPage.xaml and&nbsp;MainPage.xaml.cs<\/p>\n\n\n\n<p>A new Blank App template project is given a single window with a single page called MainPage. It defines what the user sees once your app has loaded and the splash screen has gone away.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Things We&nbsp;Add To The Project &amp; Default Class<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">App.xaml.cs Class Constructor<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>    sealed partial class App : Application\n    {\n\t\t\/\/---------------------------\n\t\t\/\/----- PRIVATE DEFINES -----\n\t\t\/\/---------------------------\n\t\t\/\/private \n\n\t\t\/\/--------------------------\n\t\t\/\/----- PUBLIC DEFINES -----\n\t\t\/\/--------------------------\n\t\t\/\/public \n\t\n\t\t\/\/---------------------------\n\t\t\/\/----- PRIVATE OBJECTS -----\n\t\t\/\/---------------------------\n\t\t\/\/private \n\n\t\n\t\t\/\/--------------------------\n\t\t\/\/----- PUBLIC OBJECTS -----\n\t\t\/\/--------------------------\n\t\t\/\/public \n\n\t\t\/\/*********************************\n\t\t\/\/*********************************\n\t\t\/\/********** CONSTRUCTOR **********\n\t\t\/\/*********************************\n\t\t\/\/*********************************\n\t\t\/\/\/ &lt;summary&gt;\n\t\t\/\/\/ Initializes the singleton application object.  This is the first line of authored code\n\t\t\/\/\/ executed, and as such is the logical equivalent of main() or WinMain().\n\t\t\/\/\/ &lt;\/summary&gt;\n\t\tpublic App()\n        {\n            this.InitializeComponent();\n            this.Suspending += OnSuspending;\n        }\n\n\t\t\/\/*********************************\n\t\t\/\/*********************************\n\t\t\/\/********** ON LAUNCHED **********\n\t\t\/\/*********************************\n\t\t\/\/*********************************\n\t\t\/\/\/ &lt;summary&gt;\n\t\t\/\/\/ Invoked when the application is launched normally by the end user.  Other entry points\n\t\t\/\/\/ will be used such as when the application is launched to open a specific file.\n\t\t\/\/\/ &lt;\/summary&gt;\n\t\t\/\/\/ &lt;param name=\"e\"&gt;Details about the launch request and process.&lt;\/param&gt;\n\t\tprotected override void OnLaunched(LaunchActivatedEventArgs e)\n        {<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Menu &gt; Project &gt; Add Class &gt; Create ApMain.cs&nbsp;and set it up like this:<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/*************************************\n\/\/*************************************\n\/\/********** VERSION HISTORY **********\n\/\/*************************************\n\/\/*************************************\n\/\/\n\/\/V1.00\t##\/##\/##\t\tDeveloper Name\n\/\/- Original release\n\n\/\/----- NEW VERSION CHECKLIST -----\n\/\/- Set MyProjectName &gt; Properties &gt; AssemblyInfo.cs &gt; AssemblyFileVersion and AssemblyVersion\n\n\nnamespace MyProjectNamespaceName\n{\n    public static class ApMain      \/\/&lt;&lt;&lt;&lt;&lt; ADD 'public static' TO THIS CLASS TO MAKE IT GLOBAL (STATIC SO NO INSTANCES CAN BE CREATED OF IT) &lt;&lt;&lt;&lt;\n    {\n        \/\/############################\n        \/\/############################\n        \/\/##### GLOBAL CONSTANTS #####\n        \/\/############################\n        \/\/############################\n        \/\/Use 'const' (no need for 'static' as const is static by nature)\n        public const string MyGlobalString1 = \"Hello1\";\n        public const int MyGlobalInt1 = 1;\n\n\t\/\/##########################\n\t\/\/##########################\n\t\/\/##### GLOBAL OBJETCS #####\n\t\/\/##########################\n\t\/\/##########################\n\t\/\/Use 'static' (all members inside a static class must also be static)\n\t\/\/public static string MyGlobalString2 = \"Hello2\";\n\n        \/\/############################\n        \/\/############################\n        \/\/##### GLOBAL VARIABLES #####\n        \/\/############################\n        \/\/############################\n        \/\/Use 'static' (all members inside a static class must also be static)\n        public static string MyGlobalString2 = \"Hello2\";\n        public static int MyGlobalInt2 = 2;\n\n        \/\/Use them in your code like this:\n        \/\/SomeString = ApMain.MyGlobalString1;\n        \/\/SomeValue = ApMain.MyGlobalInt2;\n    }<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Configuring Visual Studio Application<\/h4>\n\n\n\n<p>Some settings we use to ensure trouble free build, deploy, run operation:<\/p>\n\n\n\n<p>Tools &gt; Options &gt; Projects and Solutions &gt; Build and Run<\/p>\n\n\n\n<p>&#8216;Only build startup projects and dependencies on run&#8217; = unchecked<\/p>\n\n\n\n<p>&#8216;On Run, when project are out of date&#8217; = Always build<\/p>\n\n\n\n<p>Tools &gt; Options &gt; Text Editor &gt; C# &gt; Code Style &gt; Formatting &gt; General &gt; Automatically format on paste=off<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Development Platform Download the latest free Visual Studio community edition from Microsoft. When installing ensure the &#8220;Universal Windows Platform development&#8221; option is included. Create A New Project Menu &gt; File &gt; New Project Visual C# &gt; Blank App (Universal Windows) Give the project and name and location and create it. The version of Windows 10 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-611","post","type-post","status-publish","format-standard","hentry","category-projects-general"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=611"}],"version-history":[{"count":0,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/611\/revisions"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}