Www.johankarlsson.net: Visual Studio For Mac

Posted on

This is going to be a rather long post about building the Swiper control for iOS. There is also a WP and an Android-renderer available but in this post I'll focus on iOS.

The Swiper control is a image flipping control that displays images in a long line and allows for lazy-loading of new images. All source code is available at GitHub (and the bits can also be downloaded through nuget (What's the purpose with this blog post? What I did is that I took three UIImageView object called them left, middle and right. If we just look at the control, the middle image is the one you see. I then listen to touch events and track drag along the x axis, repositioning the images as the user moves his/hers finger. If the delta value of the drag is above a certain threshold when the user ends the draw the images are animated either left or right.

Www.johankarlsson.net: Visual Studio For Mac

Www.johankarlsson.net Visual Studio For Mac

As soon as the images are animated the position of the UIImageView objects are reset and the current index is updated and images are reset. You never see the 'jump'. This is part two in a three-part series about the Swiper control. The first part can be read, if you are new to custom control/renderers in Xamarin I suggest you read it first since I'll skip the parts that the renderers have in common. Why didn't I just use the native controls?I've been getting some comments about the iOS and Android implementation for this, stating that I could have done this a lot simpler by using the native controls (the ViewPager and the UICollectionView). This is perfectly true, but it wasn't the purpose why I created the control.

The reasons I choose to do it the way I did was. I originally planned to add custom graphic effects. I wanted to see if I could make it perfectly fluid on my own. I played around with a couple of different approaches to async image downloading. I ended up with the basic WebClient since it would be cool to have download progress if the images are large. Looking at the code now, I realize that it's not fully implemented yet. I registered an issue (#13) for this and hopefully I'll get something done.

The downloading works but the showing the progress is not completed yet. We just draw a loading text. We directly convert the downloaded bits into a Android Bitmap object. To find out the FontFamily name to use, you open up the ttf-file in Windows by simply double clicking it and you'll find it. Since my client is a client, they wanted to use a different typeface for the bold text.

No problem, I shouted and downloaded the bolder typeface perfectly named Roboto Condensed Bold. I then opened the ttf file in windows to check out the name and it was named exactly the same. How do I then distinguish between them? It turns out that the Bold font has the same name and will be used if you set FontAttributes='Bold'. Xrg mac xrg for mac. And if you use the above without importing the 'Roboto Condensed Bold' font it will Bold the regular font. Still, what's the problem?

This is the same post as the one for Android, except this one is for iOS. I didn't really plan to write this one since the same info can be found. However, I got some comments about the previous post being incomplete, so I guess I have to complete myself. Read this one first to get the background - I also moved the source to github since I might be adding stuff to it as I go along. Find it under. Download the fontDownload the and drop it in your Resource folder for the iOS project.

Remember to change the 'Copy to output directory' to 'Always', otherwise you'll get a null reference exception. To enable multitouch in CocosSharp (Forms version) you must create a custom renderer to set the MultipleTouchEnabled on the CCGameView (platform specific code) and then you must inherit from the CocosSharpView in order to make the registration of the custom renderer work. Code in the bottom of the post. Long version I've started a little secret project of my own that required two things:. A simple framework for drawing stuff.

A simple input scheme for multitouch So I checked out the available frameworks out there for Xamarin (especially for Xamarin Forms) and I decided to give CocosSharp a run for its money. I've done some small CocosSharp projects before and it fits my needs for the prototyping of this app. I'm using the Forms version of CocosSharp since I'm a big Xamarin Forms fan. The issue One of the first things I noticed was that the multitouch simply didn't work as I expected.

No matter what properties I set there was no multitouch going on. After some google-fu I found out that you have to set the MultipleTouchEnabled to true on the CCGameView instance. Well, the CCGameView is platform specific and there is no exposure of this property in the platform agnostic CocosSharpView that you use in the forms project. Custom renderer to the rescue. Thoughts on making TinyPubSub a little less tinyTinyPubSub is a very simple Publish/Subscribe library created mainly for passing events between views in an Xamarin Forms application that uses MVVM.

You can read about it at What I'm thinking about doing is extending it with two features. Passing of data. A stack based recipient model Passing of dataTinyPubSub only allows for publishing events from one source to many recipients. It was originally create for notifying other views to reload or refresh their data. At first this was pretty much all it was intended to do.

But now I can't help myself and I would really like to publish data as well. This is the original way to subscribe and publish an event. In the first view model. TinyPubSub.Publish ('duck-color-updated', c); An exampleLet's say you're buildning an app for configuring a car.

The first page is to choose the model. On this page there is a button to choose your color. The original page simply registers for the color-chosen event and waits happily for that to happen. We then create a generic choose color page that knows nothing about what page that really needs that color. When the color finally is choosen the page fires a color-chosen event and the first page will receive it. All is fine until you get another subpage that also wants a color choosen.

You can solve that in a number of ways. The first being to register different events for different colors choosers and pass an argument to when we create the color picker page. This is messy and could easily get out of hand. My proposed solution is to create a function where you can state that only the latest registered listener will handle the event. A stack based recipient modelEnter the stack based recipient model. The mechanism behind this is simple. The latest registered recipients of a specific event is the only one that will receive an event.

Since all events for a page is deregistered automatically in TinyPubSub it will be simple to reuse the color-picker page multiple times. To revisit the car example, just before clicking the button for coloring your car door you register to the color-chosen event with the ` SubscribeExclusive(.) method. When using MVVM as the pattern of choice for your app, make sure to use PropertyChanged.Fody to make your life a little easier. Install the nuget-package PropertyChanged.Fody. If using Xamarin studio, edit the Weavers.xml file in the root and add. This is done automatically in Visual Studio. Create a base class for ViewModels and decorate it with the ImplementPropertyChangedattribute. All your properties will be raising the PropertyChanged event on INotifyPropertyChanged.

The first hand recommendation is to use a MacBook (Air/Pro) with Parallels Desktop (virtualization software) to run Windows on the same machine. This allows for a seamless transition between OS X and Windows, enabling the developer to use Visual Studio to develop iOS apps. The second hand recommendation (perhaps in combination with the first recommendation) is to acquire a Mac Mini as a local build server. A windows client can connect to this build server and send all iOS builds to it. There is also the possibility to remote access the simulator directly from within Visual Studio.

Www.johankarlsson.net visual studio for mac

If you have a Windows computer (like a SurfaceBook) you also get multipoint touch in the simulator. Another option for build is to use Visual Studio Mobile Center (currently in preview) to take care of the builds for you. It’s a wrapper on top of multiple Azure services. Xamarin Forms or Traditional Xamarin developmentOne thing you have to do early in the project is to get a good grip of the difference between Xamarin Forms and Traditional Xamarin development. Xamarin Forms is a GUI abstraction that renders fully native user interfaces. It allows for a shared GUI codebase with the drawback of pixel perfect designs. Traditional Xamarin Development is best if you have a lot of differences between the platform user interfaces or simply like storyboarding and axml.

Regardless of which approach you take you should strive for moving as much of the logic away from the GUI and into shared code base as possible. Xamarin FormsXamarin Forms is a platform on top of Xamarin that abstracts the GUI-code (Xaml or C#) but still renders 100% native user interfaces. It is very possible to make beautiful apps in Xamarin Forms but it still requires that you have knowledge about the underlying platform. You also have to ability to drop down into platform specific code at any moment. Especially through the user of Dependency Injection which plays a vital role in a cross platform mobile architecture. You also have the ability to create separate views for each platform even if you declare them in the shared library. The most common architecture to use when writing a Xamarin Forms application is MVVM.

There are a lot of tooling and resources available. The basic idea in forms is that you declaratively define you UI using XAML or C#. Most common is to use XAML. For example, a button in XAML could look like this:. When this renders (or compiles if you use Compiled Xaml) this is turned into a UIButton on iOS and a Button on Android. The conversion between abstract and concrete classes is done by the concept of Renderers.

Every renderer can be extended or replaced. You can also write your own renderer. There is no hidden magic. And it’s all open source. Traditional Xamarin DevelopmentIn traditional development you define the GUI in the same way that you do it when developing apps using the vendor specific tooling.

(Java in Android Studio or Swift/Objective-C in Xcode). On iOS that usually means Storyboarding and on Android you are most likely defining the GUI in axml-files. You could also write it using C#, but it tends to be a lot of code to write. You can still (and should) choose to use an MVVM-framework to move all the common code out of the views. Xamarin Testcloud is one of those tools/services that allows you to run your app on thousands of hardware devices with the weirdest combination of OS versions installed. You simply cannot do this in an affordable way yourself.

You author your tests locally first, in code or with a test recorder. Then you submit the tests and a build to TestCloud and select what devices you want to run it on. You pay by the device minute used. It also works perfectly for iOS and even for apps that aren’t written in Xamarin at all.

The other great benefit of Testcloud (or services like Testcloud) is that you can recreate bugs on the actual device/OS combo that the bug was spotten on without having to buy that specific device. I finally got around to give a well deserved make over by adding some features that have been requested for a while. The toughest part is to keep it Tiny and not add to much bells and whistles to it. I also got some great help from my friend to set up a devops flow that will help me manage pull requests and nuget-package publishing. The features added to this version are;. Publish with arguments.

Publish using fire-and-forget (with or without argument). Publish async (with or without argument) Publish with argument.

GetCustomAttribute(typeof(AssemblyFileVersionAttribute)) It might actually return multiple attributes. And a piece of code inside Microsoft.Rest.ClientRuntime didn't like this. It seems like attributes that makes no sense duplicating has been duplicated, like AssemblyFileVersion. Why would you like to have two of those. I'm going to write a couple of hours of my clients bill now and tattoo 'always update nuget packages first' on a close by colleague so I will remember it in the future.

Www.johankarlsson.net: Visual Studio For Mac

Resources / sources. I've tried AutoMapper on numerous occasions and it's a great product. However, my mind seems to work a little bit different so I usually use a little different approach. I want to be able to follow my mappings so what I end up doing is to write the mappers by hand. (#bad) I do give AutoMapper a try from time to time, but I still favour this way of doing it.

It's just a personal preference! If you haven't heard of Automapper, check it out at before you embrace this technique!:) The pattern I use for this is simple (and the magic lies in the simplicity of it). Step 0 - Define the types on each side of the fence.

Microsoft Azure Stack is an extension of Azure—bringing the agility and innovation of cloud computing to your on-premises environment and enabling the only hybrid cloud that allows you to build and deploy hybrid applications anywhere. We bring together the best of the edge and cloud to deliver Azure services anywhere in your environment.