Uploading an Image from Windows Phone to Azure Blob Storage

Standard

Azure blob (binary large object) storage allows us to store files on the cloud and it can be used in many scenarios, such as storing user related files (e.g. profile pictures), keeping backup or storing audio and video files for our application. In this article, we’ll see how we can develop a Windows Phone application that takes (or selects) a picture and uploads it to Windows Azure.

Note: I was showing the latest uploaded image here, but unfortunately I had to cancel my Azure subscription. Therefore, the storage key in this example (and in the source code) will not work. Don’t forget to use your own storage account credential and key.

Then, let’s begin by opening up Visual Studio and creating a new Windows Phone project.

1

2

➤ Let’s see how we can upload an image to Azure…

Making Simple Animations with Blend in Windows Store Apps

Standard

When making an application, using animations is a good way to impress the user and make your application look better. Either for making a more lively menu with sliding buttons or adding some visual effects to the background, animations come as a very simple yet powerful tool for good looking applications. In this article we will be developing a Windows Store application that contains several different animations which show several different features.

I will explain how animations work as we build our application, so we will start with opening up Visual Studio and creating a new Windows Store app.

1

In the MainPage.xaml, add a button which will be used to start the animation.

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Button x:Name="startAnimationButton" Content="Let the show begin" HorizontalAlignment="Left" Margin="100,100,0,0" VerticalAlignment="Top"/>
    </Grid>

Then, right-click MainPage.xaml and select “Open in Blend”.

2

➤ Let’s see what we can make with animations…

Using and Debugging Background Tasks in Windows Store Apps

Standard

When we are developing a Windows Store app, we may need to do something even if our application is suspended or closed; such as updating our live tile, showing a tile notification, syncing data or performing another specific action. Since Windows 8 is an operating system that emphasizes on power saving, we are not allowed to keep our application working in the background. Therefore, to have this functionality Windows 8 supports a background task system which allows us to define a background task (basically, our own lines of code) that will be executed periodically or when certain conditions are met. An example for this would be the Store application on the start screen, which periodically checks if there are updates to our installed apps, but does so when we have an internet connection.

1

Before moving on to developing our application, there are a few key points we need to know about background tasks. Background tasks have CPU and network constraints, we can not execute code that takes a long time to complete in our background tasks. The network constraint is active only when the device is on battery, and it is not calculated in terms of bandwidth but the amount of battery used by the connection. The limits of these constraints change depending on the type of the background task used.

If it is an application that needs to be frequently updated (such as a mail or VOIP app), the app will need to placed on the lockscreen but the background task will have a more relaxed resource management (2 seconds of CPU time). The catch is that the maximum number of apps that can be on the lockscreen at the same time is 7, so your user will need to add your app to the lockscreen in order your background task to work. If the application does not need to be updated that frequently, however, we can use a maintenance task, which doesn’t require the app to be on lockscreen and will be triggered based on certain conditions, but has a more restrict resource management (1 second of CPU time).

2

➤ Let’s see how background tasks work…

Using Microsoft Translator in Windows Store Apps

Standard

Microsoft Translator is a translation portal by Microsoft as part of Bing services that can provide a machine-translation of texts or entire web pages in (currently) 40 different languages. Microsoft Translator also provides a set of web service APIs (that can be called via an HTTP REST service, an AJAX callable service, or a SOAP service) for developers who wish to use Microsoft Translator in their applications. In this article we will develop a Windows Store application that uses the SOAP service of Microsoft Translator to translate text between languages, and if supported, speak the translated text.

Microsoft Translator is available on Windows Azure Marketplace and is licensed monthly based on the number of characters sent to the translation service. However, it is free up to 2.000.000 characters each month, so we can just sign up and start using it for free.

We will start by going to Windows Azure Marketplace and signing in with our Live ID. If you don’t have a Windows Azure Marketplace account associated with the Live ID you used to sign in, you will simply create one by entering your name, surname, country (and optionally your organization).

1

2

After your registration is complete, either search for “Microsoft Translator” on Windows Azure Marketplace or click here to go to Microsoft Translator page, and click Sign Up at the bottom offer (2.000.000 characters).

3

➤ Let’s see how we can use Microsoft Translator…

Using IValueConverter in Windows Store Apps

Standard

When using data binding, we may sometimes want to alter the data before presenting it to user, or we may want to change the appearance of something based on the value of the data. For example, assuming we are binding a date value, we may want to change its formatting, or we may want to change the background color based on whether the date is before or after the current date, or even show something special on certain dates (such as flowers on February 14th).

When we bind a list of items to a control (such as GridView or ListView), we can not edit individual templates of the items. We may also be getting our data from another source, such as a webservice, so we may not have control over the data we receive. So, in order to implement the features I’ve explained on the previous paragraph, we will need to use IValueConverter interface, which provides exactly what we need. In this article, we will be developing a Windows Store application that uses the IValueConverter interface.

We’ll start by opening Visual Studio and creating a new Windows Store Blank App project. I’m naming the project IValueConverterApp.

1

For this example, we will have a list of students. Our students will have a grade between 0 and 100. Our application will display these students, but their grades will need to be in letters (between FF and AA), the item color will be different based on the grade (100 – 80 will be green, 79 – 60 will be orange, and 59 – 0 will be red), and if the grade is 100 we will put a star next to the student’s name.

➤ Let’s see how we can use IValueConverter…

Windows 8 GridView GroupedHeaders with Semantic Zoom

Standard

Hi everyone,

In Windows Store applications, GridView control provides us a visually attractive, flexible and customizable way of presenting our data to the users. Although we can edit the ItemTemplate to show each item the way we want, there may be situations where we need to use more advanced features of the GridView. One of these situations is when we wish to group our data (dynamically), and put headers on top of the groups. Here’s an example, grouped by their month and year:

1

As you can see, this functionality can come in handy in many situations. However, before going on to explain how we can do this, there is another issue we should think of. What if we have a lot of items in our GridView, or the user wishes to look at an item at last group (in the previous example, the earliest date)? In that case, the user would need to do a good amount of scrolling, and that reduces the usability for our application. To prevent this in our Windows Store apps, we can use semantic zoom.

2

Semantic zoom allows the user to see the categories of the items with a pinch move (or with ctrl + mousewheel), and then select them to go directly to that group. In the example, you can see that items are grouped by their month and years. We can add semantic zoom to our grouped gridview so the users can select and go directly to their desired group.

➤ Let’s see how we can use grouped headers and semantic zoom…

Veritabanında Nasıl Şifre Saklamalıyız – Hashing ve Salting

Standard

Merhabalar. Bu sefer biraz değişiklik yaparak kodu az, konusu bol, eğlenceli bir yazı yazmaya karar verdim. 🙂

Veritabanı bir yazılım veya bilgisayar mühendisinin öğrendiği en temel konulardandır, ama üniversitelerde verilen veritabanı derslerinde konunun her zaman için teorik kısmı ele alınır. Bu derslerde biz functional dependency’den girip 3NF – 4NF’ten çıkaduralım, pratik bilgi olmadan teorik bilginin pek de faydalı olmadığını ancak mezun olduktan sonra görebiliyoruz. Ki bu durum bile eğer ders doğru işleniyorsa geçerli; bende olduğu gibi grammar nazi hocanızdan bütün dönem boyunca yalnızca “tuition fee”nin ne demek olduğunu öğrenerek dersi geçiyorsanız durum daha da kötüleşiyor. 🙂

Fakat kullanıcı adının “Login” olması?

Bu eksik pratik bilgilerin en basit ve önemlilerinden biri ise, veritabanında şifrelerin nasıl saklanacağı. Bir veritabanı hacklendiğinde ilk hedef şifrelerdir ve açığa çıkmaları direk o sistemin çökmesine sebep olur, çünkü veritabanını hackleyen kişi istediği kullanıcının hesabına girerek hem bilgi çalabilir, hem de maddi – manevi zarara neden olabilir. Eğer internette kısa bir araştırma yaparsanız en büyük firmaların bile veritabanlarının hacklendiği haberlerine ulaşabilirsiniz, bkz. Adobe, Sony, Valve (Steam). Ki düşünün, eğer Valve veritabanındaki şifreleri doğru saklamayı bilmeseydi Steam’deki tüm hesaplar açığa çıkardı ve insanlar para vererek aldıkları oyunlarını kaybederdi (kredi kartı bilgileri kısmına girmiyorum bile).

Veritabanında şifre saklarken, yukarıda bahsettiğim pratik bilgi eksikliğine sahip olan bir mühendisin yapıp yapabileceği en büyük hata ise şifreleri plain text olarak (yani olduğu gibi) saklamaktır. Ya yanlış olduğu bilinmediği için, ya da “amaan yaa bir şey olmaz” diyerek (Türk mantığı :)) yapılan bu hata, aşağıdaki gibi doldurulmuş bir veritabanı ile karşılaştığında bir hackerın ağır alay konusu olmanıza sebep olabilir:

Peki hackerların gizli gizli Justin Bieber’ı sevdiğimizi öğrenmemeleri (ve kullanıcılarımızın hesaplarını ele geçirmemeleri) için ne yapmalıyız?

➤ b04f7cce31f09ac37aa764eca473f3ecb2cc025c3a0d6c839998497d8df4615e

Silverlight ile Veri Doğrulama – IDataErrorInfo

Standard

Kullanıcılar uygulamamıza veri girerken en çok dikkat etmemiz gereken şeylerden biri girilen verinin doğru olup olmadığını denetlemektir. Normalde bu doğrulamayı kendimiz teker teker girilen değerleri kontrol ederek gerçekleştiririz ve eğer girilen değerler doğru değilse bununla ilgili uyarıları ve/veya gerekli diğer işlemleri deyim yerindeyse “el ile” yaparız. Bu durum küçük miktarlarda veri girişinde sorun çıkarmasa da, eğer kullanıcıların çok miktarda veri girmesi gerekirse bir angarya haline gelerek gereksiz zaman ve enerji harcamamıza neden olabilir.

Bu tarz veri doğrulama işlemlerini TextBox yanına uyarıları içerecek olan görünmez TextBlock’lar koyup, veri her değiştiğinde kontrol ettikten sonra TextBlock’un görünürlüğünü ve TextBox’ın arkaplan rengini değiştirerek yapmaktansa, Silverlight uygulamamız içinde data binding ve IDataErrorInfo interface’ini kullanarak hem (aşağıdaki gibi) göze güzel gözüken bir şekilde, hem de daha kolay ve hızlı olarak gerçekleştirebiliriz. Bu yazımda, birlikte kullanıcı adı ve şifre kaydederken doğrulama yapan bir Silverlight uygulaması yazacağız.

➤ Devamını okuyun…

LINQ to SQL ile İleri Arama – PredicateBuilder

Standard

İleri arama (daha bilindik adı ile advanced search) kullanıcıların büyük miktarlardaki veriyi istedikleri şekilde filtrelemesini sağlar. Tipik bir ileri arama ekranı pek çok metin kutusu ve/veya liste bulundurur ve kullanıcılar bunların arasından istediklerini doldurup istediklerini boş bırakarak arama yaparlar. Bu yazımda birlikte bir veritabanından LINQ to SQL ile bu şekilde ileri arama yapabilen bir Silverlight uygulaması oluşturacağız.

Arkaplanında bir veritabanı olan uygulamamızda böyle bir ekran oluşturmak istediğimizde, ilk bakışta LINQ to SQL kullanarak “Select From Where” ile istediğimiz sonuca ulaşmamız gayet kolaymış gibi gelebilir. Ancak şimdi üzerinden gideceğimiz örneğe baktığımızda, bazı alanların boş bazılarının dolu olmasının işleri nasıl karıştırdığını ve sorgumuzun “Where” ifadesini dinamik olarak oluşturmamız gerektiğini göreceksiniz.

➤ Devamını okuyun…