2007. 6. 29. 20:48

Silverlight의 가장 큰 가치는 아무래도 미디어와 관련된 기능과 광고시장에 효과적이라는 것이다.
아래에 볼 수 있는 강좌에서는 동영상 플레이중에 광고이미지를 어떻게 사용하는지
보여주고 있다.
 Silverlight 1.0을 기반으로 하고 있기 때문에 Java Script를 이용하고 있으며
이 예제를 Silverlight 1.1기반으로 전환하는 작업도 흥미로운 작업이 될 것 같다.
아무튼 이번주만 지나면 좀 시간이 날텐데 ㅋㅋㅋ




-------------------------------------------------------
김영욱 Microsoft
MVP 2006~2007
-------------------------------------------------------
Email: iwinkey@hotmail.com
Blog: winkey.tistory.com
Phone: 016-817-0063
www.winkey.pe.kr
www.vismuri.com
-------------------------------------------------------
2007. 6. 29. 20:16

VS 2008 JavaScript Intellisense

One of the features that web developers will really like with VS 2008 is its built-in support for JavaScript intellisense.  This is enabled in both the free Visual Web Developer 2008 Express edition as well as in Visual Studio, and makes using JavaScript and building AJAX applications significantly easier. 

Below is a quick tour of some of the new JavaScript intellisense features to take advantage of:

JavaScript Type Inference

One of the things you'll notice immediately when you start typing within a script block is the richer support that Visual Studio 2008 now has for JavaScript keywords and language features:

JavaScript is a dynamic language, and doesn't support explicit type declarations, which has made implementing good intellisense difficult in the past.

Visual Studio 2008 adds support for type inference, which means that it evaluates and computes how a JavaScript block is being used and dynamically infers the variable usage and type information of the code to provide accurate intellisense support.

For example, Visual Studio below will infer that an html element is being retrieved by the document.getElementById() method, and provide appropriate html element intellisense for the variable result:

If I later assign a numeric value to the "myElement" variable (which in JavaScript converts it to a number), notice how VS will detect this and now provide integer intellisense for the variable later in the method:

Intellisense for External JavaScript Libraries

VS 2008 supports intellisense not just for in-line script, but also for externally referenced JavaScript files.  For example, assume we have a "getMessage" function like below defined within a "Util.js" javascript file:

I can then simply add a standard JavaScript script refrence element to my page, and I will then automatically receive intellisense support for it as I code:

Notice how VS automatically provides basic parameter intellisense information on the method without us having to do anything special to the JavaScript for it to appear:

Adding Intellisense Hints to JavaScript

As you saw above, Visual Studio will automatically provide basic intellisense help information for the method name and parameters of standard JavaScript.

You can optionally make this intellisense richer by adding comments to your JavaScript code that the intellisense engine can then pick up and use when you consume a method or library.  For example, I could add the below comments to the getMessage function in my util.js file:

And when I then code against it within my "Default.aspx" file Visual Studio will automatically display this summary information for the method:

As well as the parameter details:

We'll provide a tool that then allows you to automatically strip out your comments (and compress the whitespace and size) of your JavaScript once you've finished building your application.  For more details about the comment format that both VS and ASP.NET AJAX support, please read Bertrand Le Roy's post here.

Intellisense within External JavaScript files

Obviously you get full intellisense support within external JavaScript files, just like you do within script blocks inside .htm and .aspx files.

One of the interesting characteristics about external JavaScript files is that they can call and use the JavaScript functions and variables declared within other JavaScript files that a page loads. 

For example, if we declare two external Javascript files referenced on a page like so:

The JavaScript code within the "MyLibrary.js" javascript file will be able to call the methods declared within the Util.js file.

You can tell Visual Studio to provide intellisense for the "Util.js" library within the "MyLibrary.js" file by adding a /// <reference> comment at the top of the external library.  Once you do this, you'll get full intellisense support for those methods and variables:

This ends up being super useful when partitioning your JavaScript routines across multiple files.

To reference the ASP.NET AJAX client side JavaScript libraries, you can either add a <refrence> that points to your own copy of the .JS file (if you are manually including it in your project), or add a <reference> element with a name value if the library is being dynamically output by the <asp:scriptmanager> control on the host page:

Once you do this you'll get full intellisense for all of the JavaScript libraries and type-library patterns inside ASP.NET AJAX.

Calling Web Services using ASP.NET AJAX

ASP.NET AJAX makes it easy to expose methods on the server that can be called and accessed via client-side JavaScript.  For example, assume we define a simple webmethod in a .asmx web-service like below:

I could then have ASP.NET AJAX automatically create a client-side JavaScript proxy object that uses the JSON protocol to call and use it from the client by adding a reference to it with a <asp:scriptmanager> control in my page like below:

What is cool about VS 2008 is that when you declare a reference to a web-service using the <asp:scriptmanager> control like above, it will add client JavaScript intellisense support for it within the page automatically:

Obviously this makes it much easier to identify methods on the server and asynchronously call and invoke them.  You can use this to both exchange data between the client and server.  You can also use the AJAX UI templating technique I described here to retrieve HTML UI from the server using these callbacks and then dynamically update the page with them.

Creating Re-Usable ASP.NET AJAX Behaviors, Controls and Libraries

ASP.NET AJAX provides type-system support within JavaScript for defining classes, interfaces, and other object oriented concepts.  This makes it much easier to define re-usable libraries of JavaScript that encapsulate functionality and re-use it safely across pages and applications (without having to worry about the JavaScript conflicting with other JavaScript or libraries).

VS 2008 provides new "Add-Item" templates that makes it easy to create new ASP.NET AJAX behaviors, controls and libraries:

ASP.NET AJAX uses the "prototype" pattern within JavaScript to enable you to define classes and interfaces.  For example, I can create an encapsulated JavaScript class using this pattern using one of the project item templates above (notice below how the namespace created by Visual Studio by default is the same as my project namespace):

Obviously I then get full intellisense support when consuming my new library from any page or other JavaScript file:

Summary

Hopefully the above walkthrough provides a first look at some of the new JavaScript intellisense features coming soon (there are more - but this is a start).  In future blog-posts I'll also cover some of the new JavaScript debugging features that VS 2008 brings, as well as some of the WYSIWYG designer support for ASP.NET AJAX and the ASP.NET AJAX Control Toolkit.

To learn more about ASP.NET AJAX (and how you can use all of the runtime features I described above starting today with ASP.NET 2.0), I'd also highly recommend checking out these two new books that have recently been published and which cover the official ASP.NET AJAX 1.0 release:

Note that because of the new VS 2008 multi-targeting support, you can use the JavaScript intellisense features I showed above with both ASP.NET applications built using .NET 3.5 (which has ASP.NET AJAX built-in), as well as with existing ASP.NET 2.0 applications (including ones that use the separate ASP.NET AJAX 1.0 download). This provides a very compelling reason to start using VS 2008 - even if you are using it to only target .NET 2.0 applications.

-------------------------------------------------------
김영욱 Microsoft
MVP 2006~2007
-------------------------------------------------------
Email: iwinkey@hotmail.com
Blog: winkey.tistory.com
Phone: 016-817-0063
www.winkey.pe.kr
www.vismuri.com
-------------------------------------------------------

VS2008
2007. 6. 29. 03:09
국내에서는 많이 사용되고 있지 않지만 해외에서는 제법 인기 있는
웹사이트 빌더인 DotNetNuke에서도 Silverlight module이 제공된다.
Silverlight 1.0기준으로 제공되고 있다.

This module is a modification of the Video Service code provided in the Silverlight 1.0 SDK. It covers Silverlight integration with DotNetNuke including:

  • Injecting the Silverlight JavaScript files
  • Passing a parameter from DotNetNuke to the Silverlight application

The Silverlight Module

Install the Silverlight DotNetNuke Module using the directions at this link and place an instance of it on a page in your DotNetNuke website. From the configuration menu, select Configure



Use the Browse button to select a video file and click the Upload button.



Click the [Back] button and the video will then display.

 

The Module Flow

The first "page" of the module is SilverLightVideo.ascx. The code behind file (SilverLightVideo.ascx.cs) contains code that injects the required JavaScript files:

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "createSilverlight", CreateSilverlight());
                Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "Silverlight", this.TemplateSourceDirectory 
                + @"/js/Silverlight.js");
                Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "main", this.TemplateSourceDirectory + @"/js/main.js");
                Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "silverlightbutton", this.TemplateSourceDirectory 
                + @"/js/button.js");

The SilverLightVideo.ascx contains this code:

    <script type="text/javascript">
            createSilverlight();
    </script>

That calls the dynamically generated JavaScript function in the SilverLightVideo.ascx.cs file called createSilverlight():

            sb.Append("<script type='text/javascript'> ");
            sb.Append("function createSilverlight() ");
            sb.Append("{ ");
            sb.Append(String.Format("var scene = new VideoLibrary('{0}'); ", String.Format(@"http://{0}/{1}/{2}", Request.Url.Host, this.TemplateSourceDirectory, Convert.ToString(ModuleId) + "_silverlightvideo.wmv")));
            sb.Append("Sys.Silverlight.createObjectEx({ ");
            sb.Append(String.Format("source: '{0}', ", this.TemplateSourceDirectory + @"/xaml/Scene.xaml"));
            sb.Append("parentElement: document.getElementById('SilverlightControlHost'), ");
            sb.Append("id: 'SilverlightControl', ");
            sb.Append("properties: { ");
            sb.Append("width: '100%', ");
            sb.Append("height: '100%', ");
            sb.Append("version: '0.9', ");
            sb.Append("background: 'black' ");
            sb.Append("}, ");
            sb.Append("events: { ");
            sb.Append("onLoad: Sys.Silverlight.createDelegate(scene, scene.handleLoad) ");
            sb.Append("} ");
            sb.Append("}); ");
            sb.Append("} ");
            sb.Append("</script> ");

createSilverlight() contains a reference to the .xaml file that contains the layout and design of the media player. It also creates and instance of the VideoLibrary contained in the main.js file, passing the name of the video file to load. This value is stored in the globalmediasource variable. 

VideoLibrary = function(mediasource) 
{
    globalmediasource = mediasource;
}

This value is passed to the media player in the .xaml file and the video plays.


Complete Source Code

Examining the XAML file

The interface for the media player is contained in the XAML file. To examine it, download and install Expression Blend 2 (or higher).

Create a new Silverlight Application by selecting File from the toolbar menu then New Project.

 

Select Silverlight Application (JavaScript) from the Create New Project menu and click OK.

 

Right-click on the project in the Project Explorer and select Add Existing Item



Navigate to the scene.xaml file that is contained in the DotNetNuke module you installed
(Dotnetnuke root/DesktopModules/SilverLightVideo/xaml/scene.xaml) and select it.

 

The XAML file can now be viewed and modified

 

Download the example module here: SilverLightVideo_01.00.00_Install.zip

Note: when debug="true" in the DotNetNuke web.config, the module will cause JavaScript errors. To prevent this set debug="false"

-------------------------------------------------------
김영욱 Microsoft
MVP 2006~2007
-------------------------------------------------------
Email: iwinkey@hotmail.com
Blog: winkey.tistory.com
Phone: 016-817-0063
www.winkey.pe.kr
www.vismuri.com
-------------------------------------------------------

2007. 6. 29. 02:32

GOA Winforms live demo

Silverlight 2007. 6. 29. 02:32
Silverlight 1.1 Engine 위에서 다양한 Look and fill을 제공하는 회사가 나타났다.
이미 Silverlight.net에 연결되어 있는 외국 Blog에서는 소개하는 사람들이 있었지만
이제 여유가 나서 한번 살펴 보았다.
제품은 모두 Silverlight와 Flash를 모두 제공하고 있다.

Controls Quick Tour
Silverlight에서 제공하는 기능들을 이용해서 Windows의 기본 테마를 구현해 놓은 컨트롤이다.
Silverlight에서는 필요한 컨트롤들이 아직 거의 대부분 제공되지 않고 있는데
여기서는 Windows Controls의 거의 모든 형태를 제공해 준다.

Tool Strip Quick Tour
Windows 형태의 메뉴와 툴바를 제공해주는데 기능이 거의 동일해서 깜짝놀라게 해준다. ^^

DataGrid Demo
Silverlight에서 가장 아쉬운 부분중에 하나가 DataGrid가 아직 제공되지 않고 있는 점인데
여기서는 이미 DataGrid를 제공하고 있다. ^^
DataGrid는 대체로 무거운 객체이긴 한데 여기서도 예외는 아닌듯 하다.
반응속도가 떨어지고 무거우며 아직 휠 기능이 제공되지 않고 있어서 불편하다.
하지만 제공된다는 자체가 중요한것 이다.!!

Outlook like calender
요넘 쓸만하겠는걸 하고 열자마자 역시 급실망하고 말았다.
아웃록을 사용하는 사람마다 다소 다르겠지만 나 같은 경우는 일정을 입력할 때 시간을 선택하고
오른쪽 마우스를 클릭해서 새 일정을 선택하는 식으로 사용한다.
여기서는 오른쪽 마우스를 클릭하면 Silverlight의 소개를 볼 수 있다(OTL)
Silverlight의 자체 한계이기도 하지만 아무튼 다소 실망했다.
하지만 아직 모든게 정식이 아니기 때문에 이 만큼이라도 충분히 대단하다.

VS like form designer
마치 Visual Studio의 폼 디자이너를 옮겨 놓은 듯한 화면이다.
써보면 아~ 절로 감탄이 나온다.

Silverlight에 대한 기대와 관심 수준이 아니라 벌써 실질적인 시장을 기대하는 업체들이
속속나타나고 있다. --(*)--

Controls Quick Tour

Controls Quick Tour

Edition: GOA WinForms

This sample illustrates the use of all the major standard System.Window.Forms controls. You can manipulate buttons, checkboxes, comboboxes, lists, treeviews, windows and more.

Silverlight
Demo
Flash
Demo
ToolStrips Quick Tour

ToolStrips Quick Tour

Edition: GOA WinForms

GOA WinForms also supports the standard ToolStrips classes available in .NET 2.0. This sample lets you play with a set of WinWord-like toolbars and menus. Toolbars can be dragged of course.

Silverlight
Demo
Flash
Demo
DataGrid Demo

DataGrid Demo

Edition: GOA WinForms Professional

The Professional Edition of GOA WinForms includes a sophisticated DataGrid.This sample demonstrates a sample editable data grid. Columns can be sorted and first one is frozen.

Silverlight
Demo
Flash
Demo
Outlook-like Calendar

Outlook-like Calendar

Edition: GOA WinForms Professional

View how the Navigation Pane of GOA WinForms Professional can be used to quickly create an Outlook-like Calendar. This demo also illustrates GOA capabilities in RIA development.

Silverlight
Demo
Flash
Demo
VS-like Form Designer

VS-like Form Designer

Edition: GOA WinForms Professional

A small Visual Studio-like Designer on the Web? So easy to create with GOA WinForms Professional...


Silverlight
Demo
-------------------------------------------------------
김영욱 Microsoft
MVP 2006~2007
-------------------------------------------------------
Email: iwinkey@hotmail.com
Blog: winkey.tistory.com
Phone: 016-817-0063
www.winkey.pe.kr
www.vismuri.com
-------------------------------------------------------