Simple Procedural Workflow using Windows Workflow Foundation 4.0

 


In this article, i will explain following below in Windows Workflow Foundation 4.0:

  • Simple sequence
  • Variables
  • Arguments
  • if-else activity

First, open your Visual Studio 2010, and create a new project and the template is "Workflow Console Application"


Then... you will see workfow designer, in toolbox, click "sequence" and drag it into workflow designer


In "Arguments tab" add these arguments :


In "Variables Tab" add this :


Then... you will add some activities, just drag them from toolbox, your sequence of activities can be like this :


OK... the workflow is nearly finished ! Last step is writing some code in Program.cs  to add parameters into workflow

Write the code below :

using System;
using System.Activities;
using System.Collections.Generic;

namespace WorkflowConsoleApp
{

class Program
{
static void Main(string[] args)
{
Dictionary<string, object> d = new Dictionary<string, object>();
d.Add("param1", 1);
d.Add("param2", 2);

WorkflowInvoker.Invoke(new Workflow1(), d);
Console.ReadKey();
}
}
}


Code explanation :

To passing parameter to workflow you must use Dictionary, how to add data into dictionary is Add(argument_name, value) ... so  i add two datas in dictionary with keys "param1" and "param2" (see arguments name above)

Run the program


You can download the solution here

Posted by azer89 | with no comments

Multi-Page Application in WPF

 

This tutorial is about a multi-page application in WPF, in other words an application that just have one window but it has multiple page.  Actually, this is the WPF version from multi-page Silverlight application.

The solution is quite cool but simple:

1. Create WPF Application project in Visual Studio (2008 or 2010)

2. Rename Window1 class into PageSwitcher

3. Your code in PageSwitcher.xaml.cs should be like this :


using System;
using System.Windows;
using System.Windows.Controls;

namespace WPFPageSwitch

{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class PageSwitcher : Window
{
public PageSwitcher()
{
InitializeComponent();
Switcher.pageSwitcher = this;
Switcher.Switch(new MainMenu());
}

public void Navigate(UserControl nextPage)
{
this.Content = nextPage;
}

public void Navigate(UserControl nextPage, object state)
{
this.Content = nextPage;
ISwitchable s = nextPage as ISwitchable;

if (s != null)
s.UtilizeState(state);
else
throw new ArgumentException("NextPage is not ISwitchable! "
+ nextPage.Name.ToString());
}
}
}

4. The next part is creating ISwitchable Interface



namespace WPFPageSwitch
{
public interface ISwitchable
{
void UtilizeState( object state );
}
}

5. Create a static class,  name of the class is Switcher



using System.Windows.Controls;

namespace WPFPageSwitch
{
public static class Switcher
{
public static PageSwitcher pageSwitcher;

public static void Switch(UserControl newPage)
{
pageSwitcher.Navigate(newPage);
}

public static void Switch(UserControl newPage, object state)
{
pageSwitcher.Navigate(newPage, state);
}
}
}

6. Each page is represented by an user control, implement all user controls with ISwitchable



7. If you want to navigate to other user control, just use this code :


Switcher.Switch(new YourUserControl());

8. How to do it, you just have to call UtilizeState(Object state) ....but you'll need to parse transfered object

9. Let see how it's look :


Download the solution here

Posted by azer89 | with no comments
Filed under: ,

Microsoft Technology Update Road Trip 2011 @ITS

MICROSOFT TECHNOLOGY UPDATE 2011

@Institut Teknologi Sepuluh Nopember Surabaya, Teknik Informatika

Pendahuluan

MSP Regional Jawa Timur pada bulan Maret 2011 berencana untuk mengadakan roadtrip ke lima kampus di Jawa Timur yang bertemal Microsoft Technology Update. Tujuan dari kegiatan ini adalah untuk memperkenalkan teknologi-teknologi terbaru dari Microsoft dan mengenai kompetisi Imagine Cup. Untuk kampus pertama yang dikunjungi adalah kampus ITS Surabaya.

Pembicara dalam kegiatan ini adalah Julius Fenata (Academic Developer Advisor Microsoft Indonesia), MSP ITS (Jeffrey Hermanto Halimsetiawan, Alexander Rahardjo, Izzuddin Gumilar, dan Reza Adhitya Saputra), serta MSP PENS-ITS (Taufan Ardhinata dan Febrianto Arif).

Pelaksanaan

Hari/Tanggal: Rabu, 2 Maret 2010

Waktu: 10.00 – 13.00 WIB

Tempat : Ruang Aula Lt. 2 Gedung Teknik Informatika ITS

Agenda

Salah satu hal yang menarik minat peserta roadtrip adalah mengenai Microsoft Kinect, oleh karena itu, selain mengadakan presentasi di ruang aula, satu stan khusus Xbox 360 dan Kinect disediakan untuk dicoba oleh para mahasiswa ITS. Terbukti perangkat Kinect ini sangat menarik perhatian karena stan sangat ramai oleh para mahasiswa yang ingin mencoba perangkat revolusioner ini secara langsung.

Untuk sesi pertama presentasi dibawakan oleh Julius Fenata dengan materi Cloud Computing. Dalam sesi kali ini ditunjukkan bagaimana solusi cloud computing sangat bermanfaat untuk pembangunan infrastuktur IT pada UKM yang sedang berkembang di Indonesia.

Sesi kedua dilanjutkan dengan presentasi Windows Phone 7 (WP7) yang dibawakan oleh Izzuddin Gumilar. Izzuddin memaparkan bagaimana WP7 merupakan smartphone yang kaya akan fitur maupun teknologi sehingga memiliki potensi yang cukup besar dalam persaingan smartphone pada saat ini. Sesi ini diakhiri dengan demo aplikasi WP7 yang dibuat oleh Izzuddin sendiri yaitu CityNews (http://students.netindonesia.net/blogs/izzuddin/archive/2011/01/30/wp7-challenge-city-news.aspx)

Sesi berikutnya dibawakan oleh Alexander Rahardjo yaitu mengenai Visual Studio Tools for Office (VSTO). Dengan menggunakan VSTO ini, seseorang dapat membuat suatu fungsionalitas atau add in ke dalam Microsoft Office dengan menggunakan bahasa-bahasa yang di support oleh .NET (C#, VB.NET, C++ Managed). Sesi presentasi kali ini ditutup dengan demo aplikasi menggunakan VSTO yaitu Word Mini Browser(http://students.netindonesia.net/blogs/alexrhd/archive/2011/02/21/word-mini-browser-2010-untuk-microsoft-word-2010-menggunakan-vsto-4-0.aspx), dimana aplikasi ini menambahkan fungsionalitas Microsoft Word agar dapat membuka halaman website layaknya browser.

Untuk Sesi terakhir dibawakan oleh Febrianto Arif mengenai XNA dan Microsoft Kinect. Febri menjelaskan tentang latar belakang dari pengembangan sensor gerak Kinect dan teknologi-teknologi yang terdapat pada perangkat ini. Sesi lalu dilanjutkan dengan demo aplikasi Kinect Adventure yang dimainkan oleh peserta roadrip dan MSP.

Foto-foto lainnya pada sesi roadtrip kali ini :

Posted by azer89 | with no comments
Filed under:

Simple WF 4.0 Program

In this tutorial, i will create simple "Hello World" application using Windows Workflow Foundation 4.0 or WF 4.0. Oh yeah, what is Windows Workflow Foundation ? Windows Workflow Foundation is a Microsoft technology for defining, executing, and managing workflows, the detail about Workflow Foundation can be found in here.

First we must create a new project, choose "Workflow Console Application" and name it "HelloWorkflow"

You will see workflow designer and toolbox tab in the left, just drag WriteLine Primitive Activity

Add Text with a string like "Hello World ! It is a Great Day !"

In your Program.cs, the code must be like this

using System;
using System.Linq;
using System.Activities;
using System.Activities.Statements;

namespace HelloWorkflow
{

class Program
{
static void Main(string[] args)
{
WorkflowInvoker.Invoke(new Workflow1());
Console.ReadKey();
}
}
}

And last step... run the program :

Posted by azer89 | with no comments

Augmented Reality Technology

Augmented Reality (AR), atau yang dikenal dengan realitas tertambah, adalah teknologi yang menggabungkan benda maya dua dimensi dan ataupun tiga dimensi ke dalam sebuah lingkungan nyata tiga dimensi lalu memproyeksikan benda-benda maya tersebut dalam waktu nyata.

Benda-benda maya menampilkan informasi yang tidak dapat diterima oleh pengguna dengan inderanya sendiri. Hal ini membuat realitas tertambah sesuai sebagai alat untuk membantu persepsi dan interaksi penggunanya dengan dunia nyata. Informasi yang ditampilkan oleh benda maya membantu pengguna melaksanakan kegiatan-kegiatan dalam dunia nyata. AR dapat diaplikasikan untuk semua indera, termasuk pendengaran, sentuhan, dan penciuman. Selain digunakan dalam bidang-bidang seperti kesehatan, militer, industri manufaktur, realitas tertambah juga telah diaplikasikan dalam perangkat-perangkat yang digunakan orang banyak, seperti pada telepon genggam.

Ada dua definisi dari AR yang diterima secara umum, salah satunya definisi dari Ronald Azuma pada tahun 1997, Azuma mendefinisikan bahwa:

  1. Menggabungkan kenyataan dan virtual
  2. Interaktif secara real time
  3. Tergolong kedalam lingkungan 3D

AR merupakan salah satu bidang HCI yang sampai saat ini sering diteliti dan terus mengalami berbagai macam perkembangan. AR sendiri sudah merambah ke berbagai macam bidang seperti kesehatan, manufaktur, hiburan, pelatihan militer, dan tak terlepas di bidang hiburan, yaitu video game. Perkembangan teknologi video game sendiri yang sedemikian pesat telah membawa perubahan pada pengembangan video game yang ada. Dalam hal ini, video game juga dapat mengadaptasi teknologi AR. AR memungkinkan untuk membuat game dimana objek virtual disatukan ke dalam lingkungan nyata dan objek nyata dapat digunakan untuk mengedalikan objek virtual. Penggabungan benda nyata dan maya dimungkinkan dengan teknologi tampilan yang sesuai, interaktivitas dimungkinkan melalui perangkat-perangkat input tertentu, dan integrasi yang baik memerlukan penjejakan yang efektif.

Kebanyakan video game saat ini masih didalam batas-batas dari sebuah komputer, konsol, atau perangkat genggam. Layar bertindak sebagai jendela tampilan ke dunia game virtual yang memisahkan pemain dari lingkungan fisik sekitarnya. Interaksi pemain juga dibatasi dengan menggunakan set perangkat yang relatif kecil seperti joystick. Bahkan sistem kontrol evolusioner seperi Nintendo Wii masih terbatas pada tombol pengendali dan sensor pendukung yang terbatas. Sebaliknya, AR memungkinkan menggabungkan objek dan virtual dengan menampilkan gambar atau suara virtual yang membaur dengan lingkungan nyata. Hal ini tentunya juga memungkinkan pemain untuk berinteraksi dengan objek virtual dengan memanipulasi objek fisik yang terdapat di lingkungan nyata. AR membuat lingkungan fisik menjadi bagian integral dari permainan mendukung pengalaman multiplayer, memungkinkan interaksi secara spasial, dan mempertahankan konteks dunia nyata di dalam gameplay itu sendiri.

 

Posted by azer89 | with no comments
Filed under:

C# Dictionary

 

Dictionary pada C# merupakan salah satu bentuk dari hash table.

Apa itu hash table ?

hash table adalam struktur data semacam array, tiap elemen memiliki value dan sebuah key. Key disini seperti indeks pada Array. Kompleksitas pencarian sebuah data pada hash table nyaris mencapai O(1).

Lengkapnya untuk penjelasan hash table baca disini.

Berikut ini contoh implementasi dari Dictionary. Disini saya contohkan valuenya adalah string dan key-nya adalah integer. tpe dari value dan key sendiri bebas... gak harus string dan integer.

Description: http://azerdark.wordpress.com/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif

kita buat class yang mengimplementasikan Dictionary

class DictionaryProgram
{
        Dictionary<string, int> d;  // ini objek dictionarynya
        int n;  // buat counter key

        public DictionaryProgram()
        {
            d = new Dictionary<string, int>();  // kita inisiasi dulu
            n = 0;

            // masukkan beberapa data dulu
            AddData("monyet");
            AddData("kambing");
            AddData("kucing");
            AddData("kodok");
            AddData("ayam");
        }
}

Nah, kita buat fungsi untuk menambahkan data


 public void AddData(string data)
 {
     d.Add(data, n);
     n++; // setiap data bertambah, counter juga bertambah
 }

Fungsi untuk mencari data


public string FindData(string toFind)
{
    if (d.ContainsKey(toFind))
    {
        int value = d[toFind];
        return "kata " + toFind + "ditemukan dengan indeks " + value;
    }

    return "kata " + toFind + "tidak ditemukan";
}

Fungsi untuk mengecek apakah sebuah data terdapat dalam Dictionary apa enggak


public bool isContain(string toFind)
{
    if (d.ContainsKey(toFind))
        return true;

    return false;
}

Fungsi untuk mencetak semua data dalam Dictionary (cara 1)


public void PrintAll()
{
    foreach (KeyValuePair<string, int> pair in d)
    {
        Console.WriteLine("{0}, {1}",pair.Key, pair.Value);
    }

}

Fungsi untuk mencetak semua data dalam Dictionary (cara 2)


public void PrintAll()
{
    foreach (var pair in d)
    {
        Console.WriteLine("{0}, {1}", pair.Key, pair.Value);
    }
}

Fungsi konversi Dictionary ke List


public List<string> StoreToList()
{
    List<string> list = new List<string>(d.Keys);

    return list;
}

Fungsi menghapus sebuah data


public void Remove(string data)
{
    d.Remove(data);
}

Fungsi untuk menghapus semua data dalam dictionary


public void RemoveAll()
{
    d.Clear();
}

 

Posted by azer89 | with no comments
Filed under:

XNA - Skydome

xna_logo

Skydome, is a simple sphere that representating virtual sky. Skydome have better realistic looking than skybox but it need advanced texturing. In this article, i'm using simple .x model file (full sphere) and a sky texture to creating skydome.

First, we need these fields :


GraphicsDevice device; // our graphics device
ContentManager content; // content manager for load texture and model
TextureMaterial textureMaterial; // texture material object
Matrix worldMatrix; // world matrix for skydome
float rotationY; // for rotating shere model
Vector3 position
Model skydomeModel; // model of full sphere

CullMode cullMode; // variable that save CullMode value for graphics device
bool depthBufferEnable; // variable that save depthBufferEnable value for graphics device
bool depthBufferWriteEnable; // variable that save depthBufferWriteEnable value for graphics device

SetEffectMaterial method that called in Draw() Method



private void SetEffectMaterial(BasicEffect basicEffect, Matrix viewMatrix, Matrix projectionMatrix)
{
basicEffect.DiffuseColor = Color.White.ToVector3();

// Texture Material
basicEffect.Texture = textureMaterial.Texture;
basicEffect.TextureEnabled = true;

// Transformation
basicEffect.World = worldMatrix;
basicEffect.View = viewMatrix;
basicEffect.Projection = projectionMatrix;
}
 

In Update() Method, we set all transformation effect and rotation effect. Oh yeah,  if you decide the skybox center is following camera position, always update position variable.

[sourcecode language="csharp"]
rotationY += (float)gameTime.ElapsedGameTime.TotalSeconds * 0.05f;

worldMatrix =
Matrix.CreateScale(80) *
//Matrix.CreateRotationX(-MathHelper.PiOver2) *
Matrix.CreateRotationY(rotationY)*
Matrix.CreateTranslation(position.X, position.Y, position.Y);
 

Here's the full code :


using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace GameEngine
{
public class Skydome
{
GraphicsDevice device;
ContentManager content;
TextureMaterial textureMaterial;
Matrix worldMatrix;
float rotationY;
Vector3 Position
Model skydomeModel;

CullMode cullMode;
bool depthBufferEnable;
bool depthBufferWriteEnable;

public Vector3 Position { get { return position; } set { position = value; } }

public Skydome(GraphicsDevice device, ContentManager content)
{
this.device = device;
this.content = content;
}

public void LoadContent()
{
skydomeModel = content.Load<Model>(content.RootDirectory + "/" + GameAssetsPath.MODELS + "sphere");
GetTextureMaterial("sky_dome2", Vector2.One);
}

public void LoadContent(string sphereModel, string texture)
{
skydomeModel = content.Load<Model>(content.RootDirectory + "/" + GameAssetsPath.MODELS + sphereModel);
GetTextureMaterial(texture, Vector2.One);
}

private void GetTextureMaterial(string textureFilename, Vector2 tile)
{
Texture2D texture = content.Load<Texture2D>(content.RootDirectory +
"/" + GameAssetsPath.TEXTURES +
textureFilename);
textureMaterial = new TextureMaterial(texture, tile);
}

private void SetEffectMaterial(BasicEffect basicEffect, Matrix viewMatrix, Matrix projectionMatrix)
{

basicEffect.DiffuseColor = Color.White.ToVector3();

// Texture Material
basicEffect.Texture = textureMaterial.Texture;
basicEffect.TextureEnabled = true;

// Transformation
basicEffect.World = worldMatrix;
basicEffect.View = viewMatrix;
basicEffect.Projection = projectionMatrix;
}

public void Update(GameTime gameTime, Vector3 camPosition)
{
rotationY += (float)gameTime.ElapsedGameTime.TotalSeconds * 0.05f;

worldMatrix =
Matrix.CreateScale(80) *
//Matrix.CreateRotationX(-MathHelper.PiOver2) *
Matrix.CreateRotationY(rotationY)*
Matrix.CreateTranslation(position.X, position.Y, position.Z);
}

private void SaveGraphicsDeviceState()
{

cullMode = device.RenderState.CullMode;
depthBufferEnable = device.RenderState.DepthBufferEnable;
depthBufferWriteEnable = device.RenderState.DepthBufferWriteEnable;

}

private void RestoreGraphicsDeviceState()
{

device.RenderState.CullMode = cullMode;
device.RenderState.DepthBufferEnable = depthBufferEnable;
device.RenderState.DepthBufferWriteEnable = depthBufferWriteEnable;
//device.RenderState.AlphaTestEnable = alphaTestEnable;

}

public void Draw(Matrix viewMatrix, Matrix projectionMatrix)
{
SaveGraphicsDeviceState();

device.RenderState.CullMode = CullMode.CullClockwiseFace;
device.RenderState.DepthBufferEnable = true;
device.RenderState.DepthBufferWriteEnable = true;

foreach (ModelMesh modelMesh in skydomeModel.Meshes)
{
// We are only rendering models with BasicEffect
foreach (BasicEffect basicEffect in modelMesh.Effects)
SetEffectMaterial(basicEffect, viewMatrix, projectionMatrix);

modelMesh.Draw();
}

device.RenderState.FillMode = FillMode.Solid;
RestoreGraphicsDeviceState();

}

}

public class TextureMaterial
{

Texture2D texture;
Vector2 uvTile;

#region Properties
public Texture2D Texture { get { return texture; } set { texture = value;} }

public Vector2 UVTile { get { return uvTile; } set { uvTile = value; } }
#endregion

public TextureMaterial() { }

public TextureMaterial(Texture2D texture, Vector2 uvTile)
{
this.texture = texture;
this.uvTile = uvTile;
}
}
}
 

To render skydome in wireframe simply add this line in Draw() method :


device.RenderState.FillMode = FillMode.WireFrame;
 

 

Posted by azer89 | 2 comment(s)
Filed under:

Robot Attack !!!

This is my AR Demo at Road To Imagine Cup 2011, using the latest Goblin XNA library, version 3.5 Beta This version also have some great improvements, for example, particle effects that you can see below

Credit :

Posted by azer89 | 2 comment(s)
Filed under: ,

Developing Game with XNA ? How to Deploy It into Xbox 360 ?

Okay, in this article, I will discuss about how to deploying XNA game into Xbox 360 console >:) As you develop your Xbox 360 games, it is convenient to deploy your executable to your gaming console for testing purposes.

We will begin these steps:

1. You MUST have an original Xbox 360 with a hard drive for your Xbox 360 console to be able to develop XNA games.

2. You MUST have XNA Creator Club Premium Membership Or Trial Membership.

3. Create Windows Live Email, xxx@hotmail.com OR xxx@live.com, either no problem

4. The real first step, connect your Xbox 360 console into Xbox LIVE.

5. And then in your Xbox 360 Menu, open Windows Marketplace, and create your Xbox LIVE profile, do not forget to use your Live email.

6. Yep, you now have a Xbox Live Profile ID.

7. You must download XNA Game Studio Connect from Xbox LIVE Marketplace, and install it on the Xbox 360 console. Go to the Xbox LIVE Marketplace to find XNA Game Studio Connect.

8. Now we will begin steps to connect your PC (that you using for developing XNA games) and your Xbox 360 console. 9. To connecting between PC and Xbox 360, simply using a regular LAN Card.

10. In the Xbox 360, From the Xbox Dashboard, go to My Xbox, select Games Library, launched XNA Game Studio Connect to generate a key connection.

11. In the PC, From the Start menu, select Programs, select XNA Game Studio 3.1, and launch the XNA Game Studio Device Center, and Click Add Device ... and then type previous connection key ... ok ... your PC is now connected with Xbox 360.

12. XNA Game Studio Device Center on the Windows-based computers will display "Successfully connected to the Xbox 360 console." XNA Game Studio Connect on the Xbox 360 console will display "Waiting for computer connection," followed by the name you have chosen for your Xbox 360 console in the XNA Game Studio Device Center.

13. Time to deploying :) 14. Simply choose the option deploy in your Visual Studio ... remember ... your XNA Project must be Xbox Game type, not Windows Game.

15. While you are in XNA Game Studio Connect or playing an XNA Game Studio game, you need to be connected to Xbox LIVE. 16. End :P for more detailed resources: http://msdn.microsoft.com/en-us/library/bb975643.aspx http://msdn.microsoft.com/en-us/library/bb203929.aspx
Posted by azer89 | with no comments
Filed under: ,

Koneksi Xbox LIVE menggunakan PC dan Modem USB

Di artikel ini saya akan membagi pengalaman saya bagaimana caranya melakukan koneksi Xbox LIVE melalui perantara PC yang dilengkapi Modem USB. Berikut ini jenis modem dan ISP yang sayai pakai buat eksperimen (semuanya berhasil).

Tested Modems :

  1. AT&T Modem
  2. Huawei Modem

ISPs :

  1. Telkomsel Flash
  2. XL-access

Langkah-langkahnya :

1. Matikan XBox 360

2. Pasangkan kabel LAN yang menghubungkan PC dengan Xbox

3. Pastikan modem telah terpasang dan terkoneksi ke internet dengan baik

4. Pada PC, Setting Modem agar mengijinkan sharing network.

Contoh konfigurasi pada Windows 7 (sebenernya saya gak merekomendasikan memakai Windows 7...lihat di akhir artikel):

Contoh konfigurasi pada Windows XP :

 

5. Lalu pada Ethernet Interface (Local Area Network yang menghubungkan PC dengan Xbox) disetting "Obtain IP Address automatically" pada bagian TCP/IPv4

6. Oke...setting jaringan pada PC sudah berhasil, saatnya kita menyetting Xbox

7. Sekali lagi, kabel LAN yang menghubungkan PC dengan Xbox pastikan terpasang dengan baik

8. Hidupkan Xbox

9. Masuk ke Menu "My Xbox", lalu masuk ke "System Settings"

10. Pilih "Network Setting", lalu pilih "Configure Network", pastikan semua Basic Settings di set ke Automatic

11. Terakhir, kembali ke menu "Network Settings", lalu pilih Test Xbox LIVE Connection

Voila !!!

Permasalahan :

Seringkali cara diatas tidak dapat digunakan, dan tidak bisa koneksi ke network sekalipun, caranya adalah :

(perhatikan benar-benar urutan)

1. Matikan Xbox 360, PC, dan cabut Modem dari PC

2. Cabut *** kabel power Xbox 360

3. Tunggu beberapa menit

4. Ulangi cara-cara diatas sesuai dengan urutan

5. Koneksi menggunakan Windows 7 seringkali sangat susah, saya juga gak ngerti kenapa, saya sarankan pakai Windows XP atau Vista

Posted by azer89 | with no comments
Filed under: ,