Microsoft Imagine Cup – Wasteman Project

I proud to announce you that we just launched a Release Candidate version of our ImagineCup project, Wasteman.

I would like to thank my team, Atilla Ersen Öztekin and Onur Alp Aydın. We worked so hard and we will take our prize for this afford. Surely, there is someone else who deserves a special thanks Osman Çokakoğlu. He has great contribution to Wasteman as a mentor. We grateful to him for his great mentorship.

And now, guys, I am punching the game. Enjoy it:

 

Windows Phone Pivot Navigation

Most often asked question about WP 7′s Pivot Control “How can I navigate between two Pivot items?”

Actually, it is very easy. Firts of all, what we need is giving a name to the pivot item with x:name attribute.

give a name with x:name

After that you can call the pivot with its name. Just put a button in first PivotItem then create a click event for that button.

When you named the Pivot Control you have granted full access of that control. Thus, on click event you can call the PivotObject which is named before and you just realized that PivotObject has SelectedIndex attribute.

Use it wisely :)

Windows Phone Rounded Button

Hi,

I would like to share a brief information about how to create a rounded button in Windows Phone.

If you looking for an answer to this question you are in the right place.

It is very easy. Firstly, drag and drop a button on the stage. Then, you must edit the button’s template.

Click OK for next window.

click OK

You can change the name of style but it won’t be necessary in this case. After you click OK, you can change button template without any negative effects on original button template.

After that process, I would prefer editing codes rather than design stuff because I love XAML :)

Thus, I will find button’s border XAML and just set the corner radius to 55. Like this, CornerRadius=”55″.

Be careful;  the corner radius has already set to 0 so, do NOT add a new tag just use the existing one.

BB.

NOPcon UNI 2012

Lastly, we organized an amazing event called Nopcon uni 2012 as Istanbul Kultur University IT Society. Thanks to Evren Yalçın, he set all communication with the security community and also speakers. It was a great effort and totally, it was worth it.

I hope our audiences have been pleased this event. We are trying to do our best for our members.

Windows Phone Camp in Istanbul

Some of you may know that Microsoft Türkiye DPE team hosted a Windows Phone Camp event in our Istanbul Office. It was the second one of this event series. I missed the first one because of my schedule but when I heard the second one. I did not want to miss this amazing event. Of course, I didn’t mention the winner prize :) Frankly, the winner prize was very tempting. Thanks to Microsoft and Nokia, they gave a Nokia Lumia 800 with Windows Phone 7.5 Mango OS.

I am not writing this post just to tell you how the winner prize was amazing. I am writing this because I am the winner of Windows Phone hackathon :) and I am holding a great smart phone right now.

 

HTML5 Drag & Drop an Object

Lastly, I have learned “How to drag and drop an object” on HTML5. I will share that code snip first. This is our app code. There are some Javascript and HTML5:

HTML5 drag-drop code

Actually, I tried to share a working app on this post but I cannot figure it out inline Javascript on a wordpress post. Thus, we will go on with codes. I am sorry =)

Anyway; there is the key point. First of all: To make an element draggable, set the draggable attribute to true:

dragable

After that, you must declare what should happen when the element is dragged. In the above code element ondragstart attribute call drag function:

drag

This function sets the data type and the value of dragged element. Basically, it defines data type and element’s id.

In this case, the data type is “Text” and the value is the id of the draggable element “drag1″.

Other key point is preventDefault method because by default, the elements is not dropped another element.

prevent

After this point we just need to define what should happens when the element dropped. So, we need this function:

drop I think this feature is very handy for web applications. You can use it almost everywhere.

You can download this project here.

BB.

HTML5 Video Tag Cross-Browser Compatibility

As I mentioned it earlier, HTML5 has a lots of new special tags. In the previous post; I have created a video player with HTML5 but, as you can see this video player is compatible with Chrome and IE9 but it will not render in Firefox and Opera. Because of the video format.

Now, let’s take a quick tour between video format in HTML5. There are 3 supported video format for the <video> element:

Video Formats

Nowadays, If you want to use HTML5 for some reason, you must know the compatibility issue is a huge problem for you. Especially, in the business projects.

But, obviously, there are some methods for avoiding this issue. Let’s glance the solution:

video tag

In the above code, It seems easy. A few lines of code and you’r done. All you need is set different source with different video formats. Here is the result:

You can also change your video format with Javascript by using the canPlayType method:

Here, we defined a new source after that we checked the codec type of the browser and added a new source according to available codec. But you still need the sauce.

That’s it. This code will render all kind of new generation browser. Don’t forget, If the browser has not support HTML5. You still need a 3rd party plug-in.
BB

Video controls with HTML5

Hi there!

I am going to give a brief introduction about HTML5. This will be first HTML5 code in this blog. I will use video element in HTML5. I hope you enjoy it ;)

Before you start development, you have to consider these terms:

1. I am using Microsoft Expression Web 4 With SP1 (if you are looking for intellisense support, you must check here.)

2. I am going to use a sample video which is easy to find. Please check wikipedia resources here.

Okey, let’s start coding. You can easily set your video and a basic video player like this:

Using video tag

This video tag allows you to set your video in your page. As we mentioned earlier, this code, also, gives you a basic video player with basic controls (Play/pause, volume etc.). This is the easiest way for playing a video in your page.

Let’s getting deeper about videos in HTML5. Let me use a little bit javascript for all necessary controls (Play/Pause)

There is numerous methods for HTML5 video tag. For example, we can try to set a play/pause button for a clear understanding video concept on HTML5. I am going to use play and pause events to start or pause the video. But firstly, I must know the state of the video (Paused or not) so I will use paused property to sense the state.

Play/Pause option for video

In the above code I did a very simple video player which has got only 2 option play or pause. The excited side of this player; it is pure HTML and Javascript there is no third party plug-in etc. It is the HTML which is we all similar with.

BB

 

Windows 8 Metro UI’da Layout Konsepti

Windows 8 ile birlikte gelen en büyük yeniliklerden biri Windows Phone 7‘den alışık olduğumuz Metro UI Metro UI konseptinde uygulamalar geliştirebilmemiz için Visual Studio bize çeşitli Metro UI şablonları sunuyor.

Metro UI, visual studio 11

Visual Studio 11 ile gelen şablonlar

İlerleyen yazılarda bu şablonları tektek inceliyor olacağız bunları şimdilik böyle bırakıp; basit, düz bir Metro Application’ı alalım elimize. Yeni bir proje oluşturduğumuzda ilk fark ettiğimiz şey XAML bizim bildiğimiz XAML. Hani Silverlight ve WPF ile projeler yaparken gördüğümüz, bildiğimiz XAML. Bu sevindirici bir şey çünkü Metro UI ile birşeyler yaparken çok fazla yorulmamıza gerek kalmıyor. Şimdi gelelim Layout’a Windows 7‘de uygulama geliştirirken bizim Layout’umuzun uyması gereken durum sayısı aslında kısıtlıydı. Uygulama penceresinin boyutuna göre güzel bir Grid tasarladığımız zaman uygulama her pencere boyutunda güzelce çalışabilir duruma geliyordu. Ancak Windows 8‘de bu durum biraz farklı artık uygulamamızın güzel bir kullanıcı deneyimi yaratabilmesi için Layout‘un uyması gereken 3 tip durum var. Bunlar:

Layout görünümleri

Full Screen, Snapped ve Filled olmak üzere 3 durum söz konusu.

Bunlardan Full Screen adından da anlaşılacağı gibi uygulamanın tam ekran çalışma durumu. Snapped kullanıcını ekranın yanlarında herhangi bir başka uygulamayı aynı anda görmesi durumu. Filled ise ekranın yaklaşık 3′te 4′ünü kullanan programın bulunduğu durum (State). Bizler artık uygulama geliştiriciler olarak bu 3 durumu ayrı ayrı göz önünde bulundurmalıyız. Ayrıca bunların yanında Windows 8 hali hazırda bulunan arayüzü sayesinde Tablet‘ler içinde kullanılacak dolayısı ile tablet PC’ler ve akıllı telefonlar ile hayatımıza giren Orientation kavramınıda uygulamalarımızda kullanmamız büyük önem taşıyor. Burda da 4 durum söz konusu LandScape, LandScapeFlipped, Portrait ve PortraitFlipped hemen gözünüz korkmasın aslında bu durumlara ayak uydurmak çok kolay. Şimdi bunlarla ilgili küçük bir örnek yapalım:

Metro UI style’ların arasından Application seçeneğine tıklayıp açıyoruz ve karşımıza LayoutRoot olarak adlandırılmış bir Grid çıkıyor.

[sourcecode language="XML"]
<Grid x:Name="LayoutRoot" Background="#FF0C0C0C">
<StackPanel x:Name="MainPanel">
<Border x:Name="MainBorder"
Background="Pink"
Width="600" Height="600"
HorizontalAlignment="Center"
VerticalAlignment="Center">

<TextBlock x:Name="MainText"
Text="Hello World"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="Segoe UI"
FontSize="72" />
</Border>
</StackPanel>
</Grid>
[/sourcecode]

Uygulama ekranımıza Hello World yazdıkdıktan sonra yukarıda saydığımız durumlar (aslında bunlar State’ler oluyor) herbiri için birer State belirleyebiliriz.

[sourcecode language="XML"]
<Grid x:Name="LayoutRoot" Background="#FF0C0C0C">

<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="OrientationStates">
<VisualState x:Name="FullScreen" />
<VisualState x:Name="Filled" />
<VisualState x:Name="Snapped" />
<VisualState x:Name="Portrait" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

<StackPanel x:Name="MainPanel">
<Border x:Name="MainBorder"
Background="Pink"
Width="600" Height="600"
HorizontalAlignment="Center"
VerticalAlignment="Center">

<TextBlock x:Name="MainText"
Text="Hello World"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="Segoe UI"
FontSize="72" />
</Border>
</StackPanel>
</Grid>
[/sourcecode]

Peki cihazın ve/veya uygulamanın ne durumda olduğunu nasıl anlayacağız? İşte bu noktada arka tarafa geçip ufak bir kod yazmamız gerekiyor.

[sourcecode language="Csharp"]
namespace Application1
{
partial class MainPage
{
public MainPage()
{
InitializeComponent();

ApplicationLayout.GetForCurrentView().LayoutChanged
+= new TypedEventHandler<ApplicationLayout,
ApplicationLayoutChangedEventArgs>(MainPage_LayoutChanged);
}

void MainPage_LayoutChanged(ApplicationLayout sender,
ApplicationLayoutChangedEventArgs args)
{

}
}
}
[/sourcecode]

Yarattığımız bu EventListener ile Layout’un durumunda bir değişiklik olduğunda gereken State’te geçmesini söyleyeceğiz. Aslında bunun içinde cihazın layout’un geçtiği State’in adını bilmemiz gerekiyor.

[sourcecode language="Csharp"]
namespace Application1
{
partial class MainPage
{
public MainPage()
{
InitializeComponent();

ApplicationLayout.GetForCurrentView().LayoutChanged
+= new TypedEventHandler<ApplicationLayout,
ApplicationLayoutChangedEventArgs>(MainPage_LayoutChanged);
}

void MainPage_LayoutChanged(ApplicationLayout sender,
ApplicationLayoutChangedEventArgs args)
{
VisualStateManager.GoToState(this, hangiState(), false);
}
public static string hangiState()
{
var orientation = DisplayProperties.CurrentOrientation;

// portrait

if (orientation == DisplayOrientations.Portrait || orientation == DisplayOrientations.PortraitFlipped)
return "Portrait";

// else hangi state oldugunu soyle bana
return ApplicationLayout.Value.ToString();
}
}
}
[/sourcecode]

Artık State’in adınıda bildiğimize göre tek yapmamız gereken State’i istediğimiz gibi tasarlamak olacaktır.
Herkese kolay gelsin.

Windows Developer Preview, Metro UI “makepri.exe not found” Hatası

Eğer benim gibi Dual Layer DVD kullanamıyorsanız sizde Windows Developer Preview with Developer Tools sürümünü indirmek yerine Windows Developer Preview with Apps‘si indirmiş olabilirsiniz. Ardından birde VS11 Preview indirip hemen Metro UI bir uygulama yazayım diye kolları sıvadığınızda VS‘in projenizi compile etmediğini göreceksiniz ve aşağıdaki hata mesajlarını alırsanız eğer merak etmeyin çözümü çok basit:

  • Error 1 Tool makepri.exe cannot be found. Please install Windows Modern SDK. GridApplication1
  • Warning 2 No PRI files found to merge. GridApplication1
  • Error 3 Could not find a part of the path ‘C:Program Files (x86)Windows Kits8.0IncludeWinRTAppxManifestSchema.xsd’. GridApplication1

Buradan 8.0 dosyasını indirip klasörün içindeki dosyaları bilgisayarınızda bu path’e kopyalarsanız (C:Program Files (x86)Windows Kits8.0) herşeyin mükemmel olarak çalıştığını göreceksiniz.